Example #1
0
 public bool isFirstWorkFlowNode(int nodeId, out string errorStr)
 {
     errorStr = "";
     try
     {
         PardisDBEntities db           = new PardisDBEntities();
         Workflows        objWorkflows = db.Workflows.Where(q => q.StartNodeID == nodeId).FirstOrDefault();
         if (objWorkflows != null)
         {
             return(true);
         }
         return(false);
     }
     catch
     {
         errorStr = "سیستم قادر به بدست آوردن وضعیت گره جاری نمی باشد !";
         return(false);
     }
 }
Example #2
0
        public Boolean CreateRequestActivity(short RequestTypeId, short WorkFlowID, int FromNodeID, short StatusCode, string FromUserAccount,
                                             string ToUserAccount, int GroupID, string Description, string ClientIP, bool isTransfer, out string error, out long requestId)
        {
            error     = "";
            requestId = 0;
            PardisDBEntities db = new PardisDBEntities();
            int StartNode       = 0;

            #region 'تعیین نود شروع'
            try
            {
                Workflows objWorkFlow = db.Workflows.Where(q => q.ID == WorkFlowID).SingleOrDefault();
                if (objWorkFlow == null)
                {
                    error = "گردش کار معتبر نمی باشد !";
                    return(false);
                }
                else if (objWorkFlow.StartNodeID == 0)
                {
                    error = "نود شروع گردش کار جاری مشخص نشده است !";
                    return(false);
                }
                else if (objWorkFlow.StartNodeID != FromNodeID)
                {
                    error = "نود شروع گردش کار با نود اقدام کننده یکی نمی باشد !";
                    return(false);
                }
                StartNode = objWorkFlow.StartNodeID;
            }
            catch (Exception ex)
            {
                error = "در بدست آوردن نود شروع گردش کار جاری خطایی رخ داده است !";
                return(false);
            }
            #endregion
            Requests objRequest = GeneratePureRequest(FromUserAccount, RequestTypeId);
            if (objRequest == null)
            {
                error = "در ایجاد درخواست خطایی رخ داده است !";
                return(false);
            }

            WFActivity objSourceActivity = new WFActivity();
            objSourceActivity.WorkFlowID          = WorkFlowID;
            objSourceActivity.RequestID           = objRequest.ID;
            objSourceActivity.PreActivityID       = 0;
            objSourceActivity.FromNodeID          = StartNode;
            objSourceActivity.ToNodeID            = FromNodeID;
            objSourceActivity.StatusId            = (short)Enums.StatusCodeTypes.Waiting;
            objSourceActivity.GroupID             = GroupID;
            objSourceActivity.LogicalDelete       = false;
            objSourceActivity.ToUserAccount       = "";
            objSourceActivity.UserAccount         = FromUserAccount;
            objSourceActivity.ActivityDate        = System.DateTime.Now;
            objSourceActivity.ActivityDescription = Description;

            try
            {
                db.WFActivity.Add(objSourceActivity);
                db.SaveChanges();
                if (isTransfer)
                {
                    #region 'Transfer'
                    int toNodeId = GetToNodeIdtoTransferRequestByStatus(WorkFlowID, FromNodeID, StatusCode);
                    if (toNodeId > 0)
                    {
                        try
                        {
                            #region
                            WFActivity objConfirmActivity = new WFActivity();
                            objConfirmActivity.WorkFlowID          = WorkFlowID;
                            objConfirmActivity.RequestID           = objRequest.ID;
                            objConfirmActivity.PreActivityID       = objSourceActivity.ID;
                            objConfirmActivity.FromNodeID          = objSourceActivity.FromNodeID;
                            objConfirmActivity.ToNodeID            = objSourceActivity.ToNodeID;
                            objConfirmActivity.StatusId            = (short)Enums.StatusCodeTypes.Confirm;
                            objConfirmActivity.GroupID             = GroupID;
                            objConfirmActivity.LogicalDelete       = false;
                            objConfirmActivity.ToUserAccount       = "";
                            objConfirmActivity.UserAccount         = FromUserAccount;
                            objConfirmActivity.ActivityDate        = System.DateTime.Now;
                            objConfirmActivity.ActivityDescription = Description;
                            db.WFActivity.Add(objConfirmActivity);
                            db.SaveChanges();
                            WFActivity objNextActivity = new WFActivity();
                            objNextActivity.WorkFlowID          = WorkFlowID;
                            objNextActivity.RequestID           = objRequest.ID;
                            objNextActivity.PreActivityID       = objConfirmActivity.ID;
                            objNextActivity.FromNodeID          = objSourceActivity.ToNodeID;
                            objNextActivity.ToNodeID            = toNodeId;
                            objNextActivity.StatusId            = (short)Enums.StatusCodeTypes.Waiting;
                            objNextActivity.GroupID             = GroupID;
                            objNextActivity.LogicalDelete       = false;
                            objNextActivity.ToUserAccount       = ToUserAccount;
                            objNextActivity.UserAccount         = FromUserAccount;
                            objNextActivity.ActivityDate        = System.DateTime.Now;
                            objNextActivity.ActivityDescription = Description;
                            db.WFActivity.Add(objNextActivity);
                            db.SaveChanges();
                            #endregion
                            return(true);
                        }
                        catch
                        {
                            error = "در ارسال درخواست خطایی رخ داده است !";
                            return(false);
                        }
                    }
                    else
                    {
                        error = "از گره جاری مسیری جهت ارسال درخواست وجود ندارد ! ";
                        return(false);
                    }
                    #endregion
                }
                requestId = objRequest.ID;
                return(true);
            }
            catch (Exception ex) {
                error = "در ثبت درخواست خطایی رخ داده است !";
                return(false);
            }
        }