Exemplo n.º 1
0
    public bool TryPredictivePush(Vector3Int from, Vector2Int dir)
    {
        if (isNotPushable || !CanPredictPush || Pushable == null || !isAllowedDir(dir))
        {
            return(false);
        }
        lastReliablePos = registerTile.WorldPosition;
        if (from != lastReliablePos)
        {
            return(false);
        }
        Vector3Int target = from + Vector3Int.RoundToInt(( Vector2 )dir);

        if (!MatrixManager.IsPassableAt(from, target) ||
            MatrixManager.IsNoGravityAt(target))               //not allowing predictive push into space
        {
            return(false);
        }

        bool success = Pushable.PredictivePush(dir);

        if (success)
        {
            prediction           = PushState.InProgress;
            approval             = ApprovalState.None;
            predictivePushTarget = target;
            Logger.LogTraceFormat("Started predictive push {0}->{1}", Category.PushPull, from, target);
        }

        return(success);
    }
Exemplo n.º 2
0
 public Row(Guid id, DateTime createdDate, Dictionary <string, string> fields, ApprovalState approvalState = ApprovalState.Undecided)
 {
     Id            = id;
     Fields        = fields;
     CreatedDate   = createdDate;
     ApprovalState = approvalState;
 }
Exemplo n.º 3
0
        public static List <ApprovalViewModel> GetApprovals(ApprovalState approvalState)
        {
            var approvals          = ApprovalRepository.FindApprovalsByApprovalState(approvalState);
            var approvalViewModels = ApprovalViewModelAssembler.Assemble(approvals);

            return(approvalViewModels);
        }
Exemplo n.º 4
0
 private Picture(ApprovalState state, Guid id, string asBase64, Pixel[][] pixels)
 {
     State    = state;
     Id       = id;
     AsBase64 = asBase64;
     Pixels   = pixels;
 }
Exemplo n.º 5
0
        public FormData GetSubmittedValues(IPublishedContent content, int page = 1, int perPage     = 10, string sortField = null,
                                           bool sortDescending = false, ApprovalState approvalState = ApprovalState.Approved, string searchQuery = null, string[] searchFields = null)

        {
            var index = IndexHelper.GetIndex(content.Id);

            IApprovalIndex approvalIndex = null;

            if (index is IApprovalIndex)
            {
                // we need to load the prevalues to figure out if we're using approval or not
                LoadPreValues(content);
                approvalIndex = UseApproval ? index as IApprovalIndex : null;
            }

            var result = approvalIndex != null
                                ? approvalIndex.Get(searchQuery, searchFields, sortField, sortDescending, perPage, (page - 1) *perPage, approvalState)
                                : index.Get(searchQuery, searchFields, sortField, sortDescending, perPage, (page - 1) * perPage);

            result = result ?? Result.Empty(sortField, sortDescending);

            var fields = AllValueFields().ToArray();

            var rows = ExtractSubmittedValues(result, fields, (field, value, row) => value == null ? null : field.FormatValueForFrontend(value, content, row.Id));

            return(new FormData
            {
                TotalRows = result.TotalRows,
                SortDescending = result.SortDescending,
                SortField = result.SortField,
                Rows = rows.ToArray(),
                Fields = fields.Select(f => ToDataField(null, f, null))
            });
        }
Exemplo n.º 6
0
 internal void ApproveMe(IAccount approver, StaffRank rank, ApprovalState state = ApprovalState.Approved)
 {
     State        = state;
     ApprovedBy   = approver;
     ApprovedOn   = DateTime.Now;
     ApproverRank = rank;
 }
Exemplo n.º 7
0
 private void FinishPrediction()
 {
     Logger.LogTraceFormat("Finishing predictive push", Category.PushPull);
     prediction           = PushState.None;
     approval             = ApprovalState.None;
     predictivePushTarget = TransformState.HiddenPos;
     lastReliablePos      = TransformState.HiddenPos;
 }
Exemplo n.º 8
0
 public FormData GetSubmittedValues(int page = 1, int perPage = 10, string sortField = null, bool sortDescending = false,
                                    ApprovalState approvalState = ApprovalState.Approved)
 {
     if (RequestedContent == null)
     {
         return(new FormData());
     }
     return(GetSubmittedValues(RequestedContent, page, perPage, sortField, sortDescending, approvalState));
 }
Exemplo n.º 9
0
 private void FinishPrediction()
 {
     Logger.LogTraceFormat("Finishing predictive push", Category.PushPull);
     pushPrediction       = PushState.None;
     pushApproval         = ApprovalState.None;
     predictivePushTarget = TransformState.HiddenPos;
     lastReliablePos      = TransformState.HiddenPos;
     this.TryStopCoroutine(ref revertPredictivePushHandle);
 }
Exemplo n.º 10
0
        public ActionResult Reject(string batchNo, string reason)
        {
            Result <int>  result = new Result <int>();
            ApprovalState state  = ApprovalState.ApprFailure;

            using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request)))
            {
                result = proxy.ChangePlanState(batchNo, state, reason);
            }
            return(Json(result.ToResultView()));
        }
Exemplo n.º 11
0
        public ActionResult Audit(string batchNo)
        {
            Result <int>  result = new Result <int>();
            ApprovalState state  = ApprovalState.ApprSuccess;

            using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request)))
            {
                result = proxy.ChangePlanState(batchNo, state, "");
            }
            return(Json(result.ToResultView()));
        }
Exemplo n.º 12
0
        private Result GetResult(int count, int skip, string query = null, ApprovalState approvalState = ApprovalState.Any)
        {
            var pageNumber = (skip / count) + 1;
            var page       = GetPage(pageNumber, count, query, approvalState);

            var rows = page != null && page.Items.Any()
                                ? page.Items.Select(ToFormRow).Where(r => r != null).ToList()
                                : new List <StorageRow>();

            return(new Result(page != null ? (int)page.TotalItems : 0, rows, "Id", true));
        }
Exemplo n.º 13
0
 public void Reject()
 {
     if (ApprovalState == ApprovalState.Pending)
     {
         ApprovalState = ApprovalState.Denied;
         EmailServerServiceFactory.EmailServer.SendEmail(CustomerEmail, FormatRejectedEmail());
     }
     else
     {
         throw new ApprovalException("Approval not in Pending state");
     }
 }
Exemplo n.º 14
0
 private Page <Entry> GetPage(int pageNumber, int count, string query = null, ApprovalState approvalState = ApprovalState.Any)
 {
     // the field values were serialized into one column when they were added to the index, so we
     // can't sort on sortField. instead we'll sort on Id DESC so we always return the newest entries first.
     // full text search is likewise kinda lo-fi with a LIKE match on the serialized field values.
     return(Database.Page <Entry>(pageNumber, count,
                                  $"WHERE ContentId=@0 AND (@1 = '' OR FieldValues LIKE @1){(approvalState != ApprovalState.Any ? " AND Approval = @2" : "")} ORDER BY Id DESC",
                                  _contentId,
                                  string.IsNullOrEmpty(query) ? string.Empty : $"%{query.Trim('%')}%",
                                  (int)approvalState
                                  ));
 }
Exemplo n.º 15
0
    /// For prediction
    private void OnUpdateReceived(Vector3Int serverPos)
    {
        if (IsBeingPulledClient)
        {
            this.RestartCoroutine(RevertPullTimer(), ref revertPredictivePullHandle);
        }

        if (pushPrediction == PushState.None)
        {
            return;
        }

        pushApproval = serverPos == predictivePushTarget ? ApprovalState.Approved : ApprovalState.Unexpected;
        Logger.LogTraceFormat("{0} predictive push to {1}", Category.PushPull, pushApproval, serverPos);

        //if predictive lerp is finished
        if (pushApproval == ApprovalState.Approved)
        {
            if (pushPrediction == PushState.Finished)
            {
                FinishPrediction();
            }
            else if (pushPrediction == PushState.InProgress)
            {
                Logger.LogTraceFormat("Approved and waiting till lerp is finished", Category.PushPull);
            }
        }
        else if (pushApproval == ApprovalState.Unexpected)
        {
            var info = "";
            if (serverPos == lastReliablePos)
            {
                info += $"lastReliablePos match!({lastReliablePos})";
            }
            else
            {
                info += "NO reliablePos match";
            }
            if (pushPrediction == PushState.Finished)
            {
                info += ". Finishing!";
                FinishPrediction();
            }
            else
            {
                info += ". NOT Finishing yet";
            }
            Logger.LogFormat("Unexpected push detected OnUpdateRecieved {0}", Category.PushPull, info);
        }
    }
Exemplo n.º 16
0
        /// <summary>
        /// Change the approval status of this thing
        /// </summary>
        /// <returns>success</returns>
        public bool ChangeApprovalStatus(IAccount approver, StaffRank rank, ApprovalState newState)
        {
            //Can't approve/deny your own stuff
            if (rank < StaffRank.Admin && Creator.Equals(approver))
            {
                return(false);
            }

            DataAccess.FileSystem.ConfigData accessor = new DataAccess.FileSystem.ConfigData();
            ApproveMe(approver, rank, newState);

            PersistToCache();
            accessor.WriteEntity(this);

            return(true);
        }
Exemplo n.º 17
0
        public void Approve()
        {
            if (ApprovalRepository.FindApprovalsByApprovalState(ApprovalState.Approved).Count != 0)
            {
                throw new ApprovalException("Another Approval has already been Approved");
            }

            if (ApprovalState == ApprovalState.Pending)
            {
                ApprovalState = ApprovalState.Approved;
                EmailServerServiceFactory.EmailServer.SendEmail(CustomerEmail, FormatApprovedEmail());
            }
            else
            {
                throw new ApprovalException("Approval not in Pending state");
            }
        }
Exemplo n.º 18
0
        public bool SetApprovalState(ApprovalState approvalState, Guid rowId)
        {
            var doc = GetDocument(rowId);

            if (doc == null)
            {
                return(false);
            }
            doc.RemoveField(ApprovalField);
            doc.Add(new LuceneField(ApprovalField, approvalState.ToString(), LuceneField.Store.YES, LuceneField.Index.NOT_ANALYZED));

            var writer = GetIndexWriter();

            writer.UpdateDocument(new Term(IdField, rowId.ToString()), doc);
            writer.Close();

            return(true);
        }
Exemplo n.º 19
0
 public Result Get(string searchQuery, string[] searchFields, string sortField, bool sortDescending, int count, int skip, ApprovalState approvalState)
 {
     return(GetSearchResults(searchQuery, searchFields, sortField, sortDescending, count, skip, approvalState));
 }
Exemplo n.º 20
0
        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public Result <int> UpdateDangerousWorkState(long id, ApprovalState state)
        {
            int          preState;
            Result <int> result = new Result <int>();

            try
            {
                var model = DataOperateBusiness <Epm_DangerousWork> .Get().GetModel(id);

                preState = model.State.Value;
                if (preState == (int)ApprovalState.WorkPartAppr)
                {
                    if (state == ApprovalState.ApprFailure)
                    {
                        state = ApprovalState.ApprSuccess;
                    }
                    else if (state == ApprovalState.ApprSuccess)
                    {
                        state = ApprovalState.WorkFinish;
                    }
                }
                model.State           = (int)state;
                model.OperateUserId   = CurrentUserID.ToLongReq();
                model.OperateUserName = CurrentUserName;
                model.OperateTime     = DateTime.Now;
                var rows = DataOperateBusiness <Epm_DangerousWork> .Get().Update(model);

                if (state != ApprovalState.WorkPartAppr)
                {
                    //处理待办
                    var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault();

                    if (temp != null)
                    {
                        ComplateApprover(temp.Id);
                    }
                }
                result.Data = rows;
                result.Flag = EResultFlag.Success;
                WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Delete.GetText(), "更新状态: " + rows);

                if (preState == (int)ApprovalState.WorkPartAppr)
                {
                    var sence = DataOperateBusiness <Epm_WorkUploadRealScene> .Get().GetList(t => t.WorkId == model.Id && t.State == (int)ApprovalState.WaitAppr).FirstOrDefault();

                    if (sence != null)
                    {
                        if (state == ApprovalState.WorkFinish)
                        {
                            sence.State = (int)ApprovalState.ApprSuccess;
                        }
                        else
                        {
                            sence.State = (int)ApprovalState.ApprFailure;
                        }
                    }

                    DataOperateBusiness <Epm_WorkUploadRealScene> .Get().Update(sence);
                }
                string title = CurrentUserName + "上传了危险作业实景,待审核";

                if (state == ApprovalState.ApprSuccess && preState == (int)ApprovalState.WaitAppr)
                {
                    title = model.CreateUserName + "提报的危险作业单已审核通过";
                    #region 生成待办
                    List <Epm_Approver> list = new List <Epm_Approver>();
                    Epm_Approver        app  = new Epm_Approver();
                    app.Title            = model.CreateUserName + "提报的危险作业单已审核通过";
                    app.Content          = model.CreateUserName + "提报的危险作业单已审核通过";
                    app.SendUserId       = CurrentUserID.ToLongReq();
                    app.SendUserName     = CurrentUserName;
                    app.SendTime         = model.CreateTime;
                    app.LinkURL          = string.Empty;
                    app.BusinessTypeNo   = BusinessType.Dangerous.ToString();
                    app.Action           = SystemRight.Check.ToString();
                    app.BusinessTypeName = BusinessType.Dangerous.GetText();
                    app.BusinessState    = (int)(ApprovalState.ApprSuccess);
                    app.BusinessId       = model.Id;
                    app.ApproverId       = model.CreateUserId;
                    app.ApproverName     = model.CreateUserName;
                    app.ProjectId        = model.ProjectId;
                    app.ProjectName      = model.ProjectName;
                    list.Add(app);
                    AddApproverBatch(list);
                    WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "审核通过危险作业生成待办: " + model.Id);
                    #endregion
                }
                else if (state == ApprovalState.ApprSuccess && preState == (int)ApprovalState.WorkPartAppr)
                {
                    title = model.CreateUserName + "上传的作业实景,审核不通过";
                    #region 生成待办
                    List <Epm_Approver> list = new List <Epm_Approver>();
                    Epm_Approver        app  = new Epm_Approver();
                    app.Title            = model.CreateUserName + "上传的作业实景,审核不通过";
                    app.Content          = model.CreateUserName + "上传的作业实景,审核不通过";
                    app.SendUserId       = CurrentUserID.ToLongReq();
                    app.SendUserName     = CurrentUserName;
                    app.SendTime         = model.CreateTime;
                    app.LinkURL          = string.Empty;
                    app.BusinessTypeNo   = BusinessType.Dangerous.ToString();
                    app.Action           = SystemRight.UnCheck.ToString();
                    app.BusinessTypeName = BusinessType.Dangerous.GetText();
                    app.BusinessState    = (int)(ApprovalState.ApprFailure);
                    app.BusinessId       = model.Id;
                    app.ApproverId       = model.CreateUserId;
                    app.ApproverName     = model.CreateUserName;
                    app.ProjectId        = model.ProjectId;
                    app.ProjectName      = model.ProjectName;
                    list.Add(app);
                    AddApproverBatch(list);
                    WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "审核通过危险作业生成待办: " + model.Id);
                    #endregion
                }
                else if (state == ApprovalState.WorkFinish)
                {
                    title = model.CreateUserName + "提报的危险作业单,已完成";
                    #region 生成待办
                    List <Epm_Approver> list = new List <Epm_Approver>();
                    Epm_Approver        app  = new Epm_Approver();
                    app.Title            = model.CreateUserName + "提报的危险作业单,已完成";
                    app.Content          = model.CreateUserName + "提报的危险作业单,已完成";
                    app.SendUserId       = CurrentUserID.ToLongReq();
                    app.SendUserName     = CurrentUserName;
                    app.SendTime         = model.CreateTime;
                    app.LinkURL          = string.Empty;
                    app.BusinessTypeNo   = BusinessType.Dangerous.ToString();
                    app.Action           = SystemRight.Check.ToString();
                    app.BusinessTypeName = BusinessType.Dangerous.GetText();
                    app.BusinessState    = (int)(ApprovalState.WorkFinish);
                    app.BusinessId       = model.Id;
                    app.ApproverId       = model.CreateUserId;
                    app.ApproverName     = model.CreateUserName;
                    app.ProjectId        = model.ProjectId;
                    app.ProjectName      = model.ProjectName;
                    list.Add(app);
                    AddApproverBatch(list);
                    WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "审核通过危险作业生成待办: " + model.Id);
                    #endregion
                }
                else if (state == ApprovalState.Discarded)
                {
                    title = model.CreateUserName + "提报的危险作业单已废弃,请处理";
                    #region 生成待办
                    var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value);

                    List <Epm_Approver> list = new List <Epm_Approver>();
                    Epm_Approver        app  = new Epm_Approver();
                    app.Title            = model.CreateUserName + "提报的危险作业单已废弃,请处理";
                    app.Content          = model.CreateUserName + "提报的危险作业单已废弃,请处理";
                    app.SendUserId       = CurrentUserID.ToLongReq();
                    app.SendUserName     = CurrentUserName;
                    app.SendTime         = DateTime.Now;
                    app.LinkURL          = string.Empty;
                    app.BusinessTypeNo   = BusinessType.Dangerous.ToString();
                    app.Action           = SystemRight.Invalid.ToString();
                    app.BusinessTypeName = BusinessType.Dangerous.GetText();
                    app.BusinessState    = (int)(ApprovalState.Discarded);
                    app.BusinessId       = model.Id;
                    app.ApproverId       = project.ContactUserId;
                    app.ApproverName     = project.ContactUserName;
                    app.ProjectId        = model.ProjectId;
                    app.ProjectName      = project.Name;
                    list.Add(app);
                    AddApproverBatch(list);
                    WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Invalid.GetText(), "废弃危险作业生成待办: " + model.Id);
                    #endregion

                    #region 发送短信
                    //WriteSMS(model.CreateUserId, 0, MessageStep.WorkReject, null);
                    #endregion
                }
                else if (state == ApprovalState.ApprFailure)
                {
                    title = model.CreateUserName + "提报的危险作业单已被驳回,请处理";
                    #region 生成待办
                    List <Epm_Approver> list = new List <Epm_Approver>();
                    Epm_Approver        app  = new Epm_Approver();
                    app.Title            = model.CreateUserName + "提报的危险作业单已被驳回,请处理";
                    app.Content          = model.CreateUserName + "提报的危险作业单已被驳回,请处理";
                    app.SendUserId       = CurrentUserID.ToLongReq();
                    app.SendUserName     = CurrentUserName;
                    app.SendTime         = model.CreateTime;
                    app.LinkURL          = string.Empty;
                    app.BusinessTypeNo   = BusinessType.Dangerous.ToString();
                    app.Action           = SystemRight.UnCheck.ToString();
                    app.BusinessTypeName = BusinessType.Dangerous.GetText();
                    app.BusinessState    = (int)(ApprovalState.ApprFailure);
                    app.BusinessId       = model.Id;
                    app.ApproverId       = model.CreateUserId;
                    app.ApproverName     = model.CreateUserName;
                    app.ProjectId        = model.ProjectId;
                    app.ProjectName      = model.ProjectName;
                    list.Add(app);
                    AddApproverBatch(list);
                    WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "驳回危险作业生成待办: " + model.Id);
                    #endregion

                    #region 发送短信
                    //WriteSMS(model.CreateUserId, 0, MessageStep.WorkReject, null);
                    #endregion
                }

                #region 消息
                var waitSend = GetWaitSendMessageList(model.ProjectId.Value);
                foreach (var send in waitSend)
                {
                    Epm_Massage modelMsg = new Epm_Massage();
                    modelMsg.ReadTime     = null;
                    modelMsg.RecId        = send.Key;
                    modelMsg.RecName      = send.Value;
                    modelMsg.RecTime      = DateTime.Now;
                    modelMsg.SendId       = CurrentUserID.ToLongReq();
                    modelMsg.SendName     = CurrentUserName;
                    modelMsg.SendTime     = DateTime.Now;
                    modelMsg.Title        = title;
                    modelMsg.Content      = title;
                    modelMsg.Type         = 2;
                    modelMsg.IsRead       = false;
                    modelMsg.BussinessId  = model.Id;
                    modelMsg.BussinesType = BusinessType.Dangerous.ToString();
                    modelMsg.ProjectId    = model.ProjectId.Value;
                    modelMsg.ProjectName  = model.ProjectName;
                    modelMsg = base.SetCurrentUser(modelMsg);
                    modelMsg = base.SetCreateUser(modelMsg);
                    DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg);
                }
                #endregion
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "UpdateDangerousWorkState");
            }
            return(result);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 审核、驳回服务商PM和负责人
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public Result <bool> AuditProjectCompanyPmAndLink(long Id, ApprovalState state)
        {
            Result <bool> result = new Result <bool>();

            try
            {
                Epm_ProjectCompany pc = DataOperateBusiness <Epm_ProjectCompany> .Get().GetModel(Id);

                if (state == ApprovalState.ApprSuccess)
                {
                    pc.PMId      = pc.PMId_New;
                    pc.PM        = pc.PM_New;
                    pc.PMPhone   = pc.PMPhone_New;
                    pc.LinkManId = pc.LinkManId_New;
                    pc.LinkMan   = pc.LinkMan_New;
                    pc.LinkPhone = pc.LinkPhone_New;
                    pc.SafeManId = pc.SafeManId_New;
                    pc.SafeMan   = pc.SafeMan_New;
                    pc.SafePhone = pc.SafePhone_New;
                    pc           = base.FiterUpdate(pc, pc);
                }
                pc.State     = (int)state;
                pc.LinkState = (int)state;
                DataOperateBusiness <Epm_ProjectCompany> .Get().Update(pc);

                #region 处理待办
                var tempApp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == pc.Id && t.IsApprover == false).FirstOrDefault();

                if (tempApp != null)
                {
                    ComplateApprover(tempApp.Id);
                }
                #endregion

                #region 消息
                var waitSend = GetWaitSendMessageList(pc.ProjectId.Value);
                var model    = DataOperateBusiness <Epm_Project> .Get().GetModel(pc.ProjectId.Value);

                foreach (var send in waitSend)
                {
                    Epm_Massage modelMsg = new Epm_Massage();
                    modelMsg.ReadTime = null;
                    modelMsg.RecId    = send.Key;
                    modelMsg.RecName  = send.Value;
                    modelMsg.RecTime  = DateTime.Now;
                    modelMsg.SendId   = CurrentUserID.ToLongReq();
                    modelMsg.SendName = CurrentUserName;
                    modelMsg.SendTime = DateTime.Now;
                    if (state == ApprovalState.ApprSuccess)
                    {
                        modelMsg.Title   = CurrentUserName + "审核通过了你提交的服务商用户修改信息";
                        modelMsg.Content = CurrentUserName + "审核通过了你提交的服务商用户修改信息";
                    }
                    else if (state == ApprovalState.ApprFailure)
                    {
                        modelMsg.Title   = CurrentUserName + "驳回了你提交的服务商用户修改信息";
                        modelMsg.Content = CurrentUserName + "驳回了你提交的服务商用户修改信息";
                    }
                    modelMsg.Type          = 2;
                    modelMsg.IsRead        = false;
                    modelMsg.BussinessId   = model.Id;
                    modelMsg.BussinesType  = BusinessType.Project.ToString();
                    modelMsg.BussinesChild = "ISP";
                    modelMsg.ProjectId     = model.Id;
                    modelMsg.ProjectName   = model.Name;
                    modelMsg = base.SetCurrentUser(modelMsg);
                    modelMsg = base.SetCreateUser(modelMsg);
                    DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg);
                }
                #endregion

                result.Flag = EResultFlag.Success;
                result.Data = true;
            }
            catch (Exception ex)
            {
                result.Flag      = EResultFlag.Failure;
                result.Data      = false;
                result.Exception = new ExceptionEx(ex, "AuditProjectCompanyPmAndLink");
            }
            return(result);
        }
Exemplo n.º 22
0
 public Result Get(string sortField, bool sortDescending, int count, int skip, ApprovalState approvalState)
 {
     return(GetSearchResults(null, null, sortField, sortDescending, count, skip, approvalState));
 }
Exemplo n.º 23
0
        public FormData GetSubmittedValuesFilterByUserAttribute(IPublishedContent content, int page = 1, int perPage     = 10, string sortField = null,
                                                                bool sortDescending = false, ApprovalState approvalState = ApprovalState.Approved, string userAttribute = null, string formAttribute = null)
        {
            string query = null;

            string[] queryFields = null;

            if (!string.IsNullOrEmpty(userAttribute))
            {
                query       = CreateUserAttributeQuery(userAttribute);
                queryFields = new[] { formAttribute };
            }

            return(GetSubmittedValues(content, page, perPage, sortField, sortDescending, approvalState, query, queryFields));
        }
Exemplo n.º 24
0
 public void MakeDecision(ApprovalState state)
 {
     State = state;
 }
        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="id">危险作业Id</param>
        /// <param name="state"></param>
        /// <returns></returns>
        public Result <int> UpdateWorkRealScenenState(long id, ApprovalState state)
        {
            Result <int> result = new Result <int>();

            try
            {
                int WorkWaitAppr = (int)ApprovalState.WaitAppr;
                var list         = DataOperateBusiness <Epm_WorkUploadRealScene> .Get().GetList(t => t.WorkId == id && t.State == WorkWaitAppr).ToList();

                if (list.Any())
                {
                    string uploadTime = "";
                    foreach (var item in list)
                    {
                        uploadTime           = item.UploadTime.Value.ToShortDateString();
                        item.State           = (int)state;
                        item.OperateUserId   = CurrentUserID.ToLongReq();
                        item.OperateUserName = CurrentUserName;
                        item.OperateTime     = DateTime.Now;
                        var rows = DataOperateBusiness <Epm_WorkUploadRealScene> .Get().Update(item);
                    }

                    result.Data = list.Count;
                    result.Flag = EResultFlag.Success;
                    WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Delete.GetText(), "更新状态: " + list.Count);

                    var work = DataOperateBusiness <Epm_DangerousWork> .Get().GetModel(id);

                    //最后一天实景审核通过时,危险作业标记完成
                    if (state == ApprovalState.ApprSuccess)
                    {
                        if (uploadTime == work.EndTime.Value.ToShortDateString())
                        {
                            work.State           = (int)ApprovalState.WorkFinish;
                            work.OperateUserId   = CurrentUserID.ToLongReq();
                            work.OperateUserName = CurrentUserName;
                            work.OperateTime     = DateTime.Now;
                            DataOperateBusiness <Epm_DangerousWork> .Get().Update(work);
                        }

                        //处理待办
                        var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == work.Id && t.IsApprover == false).FirstOrDefault();

                        if (temp != null)
                        {
                            ComplateApprover(temp.Id);
                        }

                        #region 生成待办
                        List <Epm_Approver> li  = new List <Epm_Approver>();
                        Epm_Approver        app = new Epm_Approver();
                        app.Title            = work.CreateUserName + "上传的作业实景,审核通过";
                        app.Content          = work.CreateUserName + "上传的作业实景,审核通过";
                        app.SendUserId       = work.CreateUserId;
                        app.SendUserName     = work.CreateUserName;
                        app.SendTime         = work.CreateTime;
                        app.LinkURL          = string.Empty;
                        app.BusinessTypeNo   = BusinessType.Dangerous.ToString();
                        app.Action           = SystemRight.Check.ToString();
                        app.BusinessTypeName = BusinessType.Dangerous.GetText();
                        app.BusinessState    = (int)(ApprovalState.ApprSuccess);
                        app.BusinessId       = work.Id;
                        app.ApproverId       = work.CreateUserId;
                        app.ApproverName     = work.CreateUserName;
                        app.ProjectId        = work.ProjectId;
                        app.ProjectName      = work.ProjectName;
                        li.Add(app);
                        AddApproverBatch(li);
                        WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "审核通过危险作业生成待办: " + work.Id);
                        #endregion
                    }

                    #region 消息
                    Epm_Massage modelMsg = new Epm_Massage();
                    modelMsg.ReadTime     = null;
                    modelMsg.RecId        = work.CreateUserId;
                    modelMsg.RecName      = work.CreateUserName;
                    modelMsg.RecTime      = DateTime.Now;
                    modelMsg.SendId       = CurrentUserID.ToLongReq();
                    modelMsg.SendName     = CurrentUserName;
                    modelMsg.SendTime     = DateTime.Now;
                    modelMsg.Title        = work.CreateUserName + "上传的作业实景,审核通过";
                    modelMsg.Content      = work.CreateUserName + "上传的作业实景,审核通过";
                    modelMsg.Type         = 2;
                    modelMsg.IsRead       = false;
                    modelMsg.BussinessId  = work.Id;
                    modelMsg.BussinesType = BusinessType.Dangerous.ToString();
                    modelMsg.ProjectId    = work.ProjectId.Value;
                    modelMsg.ProjectName  = work.ProjectName;
                    modelMsg = base.SetCurrentUser(modelMsg);
                    modelMsg = base.SetCreateUser(modelMsg);
                    DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg);

                    #endregion
                }
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "UpdateWorkRealScenenState");
            }
            return(result);
        }
Exemplo n.º 26
0
 public bool SetApprovalState(ApprovalState approvalState, Guid rowId)
 {
     return(Database.Execute("UPDATE FormEditorEntries SET Approval = @0 WHERE EntryId = @1", (int)approvalState, rowId) > 0);
 }
Exemplo n.º 27
0
 public static List <Approval> FindApprovalsByApprovalState(ApprovalState approvalState)
 {
     return(TransactionManager.FindWhere <Approval>(app => app.ApprovalState == approvalState).ToList());
 }
Exemplo n.º 28
0
 public Result Get(string sortField, bool sortDescending, int count, int skip, ApprovalState approvalState)
 {
     return(GetResult(count, skip, approvalState: approvalState));
 }
Exemplo n.º 29
0
        private Result GetSearchResults(string searchQuery, string[] searchFields, string sortField, bool sortDescending, int count, int skip, ApprovalState approvalState = ApprovalState.Any)
        {
            var reader   = GetIndexReader();
            var searcher = GetIndexSearcher(reader);

            string sortFieldName;

            if (string.IsNullOrWhiteSpace(sortField))
            {
                sortField      = sortFieldName = CreatedField;
                sortDescending = true;
            }
            else if (sortField == CreatedField)
            {
                sortFieldName = CreatedField;
            }
            else
            {
                sortFieldName = FieldNameForSorting(sortField);
            }

            Query query;

            if (string.IsNullOrWhiteSpace(searchQuery) == false && searchFields != null && searchFields.Any())
            {
                //searchQuery = searchQuery.Replace("*", "").Replace(" ", "* ") + "*";
                if (searchFields.Count() > 1)
                {
                    var parser = new MultiFieldQueryParser(Version.LUCENE_29, searchFields, GetAnalyzer());
                    parser.SetDefaultOperator(QueryParser.Operator.AND);
                    Log.Info("searchQuery =" + searchQuery, null);

                    try
                    {
                        query = parser.Parse(searchQuery.Trim());
                    }
                    catch (ParseException ex)
                    {
                        Log.Error(ex, ex.Message, null);

                        query = parser.Parse(QueryParser.Escape(searchQuery.Trim()));
                    }
                }
                else
                {
                    query = new QueryParser(Version.LUCENE_29, searchFields.FirstOrDefault(), GetAnalyzer()).Parse(searchQuery);
                }
            }
            else
            {
                query = approvalState == ApprovalState.Any
                                        ? new MatchAllDocsQuery()
                                        : (Query) new TermQuery(new Term(ApprovalField, approvalState.ToString()));
            }

            var docs = searcher.Search(
                query,
                null, reader.MaxDoc(),
                new Sort(new SortField(sortFieldName, SortField.STRING, sortDescending))
                );

            var scoreDocs = docs.ScoreDocs;

            var rows = new List <Row>();

            for (var i = skip; i < (skip + count) && i < scoreDocs.Length; i++)
            {
                if (reader.IsDeleted(scoreDocs[i].doc))
                {
                    continue;
                }
                var doc = searcher.Doc(scoreDocs[i].doc);
                var row = ParseRow(doc);
                rows.Add(row);
            }

            searcher.Close();
            reader.Close();

            return(new Result(scoreDocs.Count(), rows, sortField, sortDescending));
        }