Esempio n. 1
0
 public bool WorkFLowNameAlreadyExistOrNot(WorkFlowAc workFlowDetails)
 {
     try
     {
         if (workFlowDetails.WorkFlowDetailParentId != 0)
         {
             int workFlowCount = _workFlowDataRepository.Fetch(x => x.WorkFlowName == workFlowDetails.WorkFlowName && x.Id != workFlowDetails.WorkFlowDetailParentId).Count();
             if (workFlowCount != 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             int workFlowCount = _workFlowDataRepository.Fetch(x => x.WorkFlowName == workFlowDetails.WorkFlowName).Count();
             if (workFlowCount != 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Esempio n. 2
0
 public IHttpActionResult WorkFLowNameAlreadyExistOrNot(WorkFlowAc workFlowDetails)
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             var nameAlreadyExist = _workFlowRepository.WorkFLowNameAlreadyExistOrNot(workFlowDetails);
             return(Ok(new { status = nameAlreadyExist }));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Esempio n. 3
0
        public WorkFlowAc EditWorkFlowInformationById(int workFlowId)
        {
            try
            {
                var workFlowAc      = new WorkFlowAc();
                var workFlowDetails = _workFlowDataRepository.GetById(workFlowId);
                if (workFlowDetails != null)
                {
                    int parentId;
                    if (workFlowDetails.ParentActivityId == 0)
                    {
                        parentId = workFlowDetails.Id;
                    }
                    else
                    {
                        parentId = ParentNodeForTreeView(workFlowDetails.ParentActivityId);
                    }

                    var parentActivityDetails = _workFlowDataRepository.FirstOrDefault(x => x.Id == parentId);
                    //int getParentId = ParentNodeForTreeView(workFlowDetails.ParentActivityId);
                    workFlowAc.ParentActivityId         = parentActivityDetails.ActivityId;
                    workFlowAc.WorkFlowParentActivityId = workFlowDetails.ParentActivityId;
                    workFlowAc.WorkFlowDetailParentId   = parentId;
                    workFlowAc.PermissionId             = workFlowDetails.WorkFlowId;
                    workFlowAc.ActivityId             = workFlowDetails.ActivityId;
                    workFlowAc.IsApproval             = workFlowDetails.IsApproval;
                    workFlowAc.IsCondition            = workFlowDetails.IsCondition;
                    workFlowAc.WorkFlowName           = parentActivityDetails.WorkFlowName;
                    workFlowAc.IsAllowOtherBranchUser = parentActivityDetails.Activity.IsAllowOtherBranchUser;
                    //  workFlowAc.Operator = workFlowDetails.Operator;
                    var workFlowColllection = new List <WorkFlowPermission>();
                    if (workFlowDetails.IsParentAction)
                    {
                        var workFlowDetail = new WorkFlowPermission
                        {
                            WorkFlowId  = workFlowDetails.WorkFlowId,
                            InitiatorId = workFlowDetails.InitiatorId,
                            AssignedId  = workFlowDetails.AssignedId,
                            //OldStatus = childAction.OldStatusId,
                            //NewStatus = childAction.NewStatusId,
                            IsApproval             = workFlowDetails.IsApproval,
                            IsReview               = workFlowDetails.IsReview,
                            IsParentAction         = workFlowDetails.IsParentAction,
                            IsApprovePanel         = workFlowDetails.IsApprovePanel,
                            IsRejectPanel          = workFlowDetails.IsRejectPanel,
                            ActivityId             = workFlowDetails.ActivityId,
                            NextActivityId         = workFlowDetails.NextActivityId,
                            ParentActivityId       = workFlowDetails.ParentActivityId,
                            IsActivityClose        = workFlowDetails.NextActivity.IsClosed,
                            workFlowActionId       = workFlowDetails.Id,
                            IsChild                = workFlowDetails.IsChildAction,
                            IsCondition            = workFlowDetails.IsCondition,
                            OtherWorkFlowId        = workFlowDetails.OtherWorkFlowId,
                            IsAllowOtherBranchUser = workFlowDetails.IsAllowOtherBranchUser,
                            //Variable1 = workFlowDetails.Variable1,
                            //Variable2 = workFlowDetails.Variable2,
                            //Operator = workFlowDetails.Operator
                        };
                        if (workFlowDetails.IsCondition)
                        {
                            var condtitionalOperatorCollection = new List <WorkFlowConditionalOperator>();
                            var conditionalDetails             =
                                _conditionalDataRepository.Fetch(x => x.WorkFlowDetailId == workFlowDetails.Id);
                            foreach (var conditionalOperator in conditionalDetails)
                            {
                                WorkFlowConditionalOperator workFlowConditionalOperator =
                                    ApplicationClassHelper.ConvertType <ConditionalOperator, WorkFlowConditionalOperator>
                                        (conditionalOperator);
                                workFlowConditionalOperator.ConditionalOperatorId = conditionalOperator.Id;
                                workFlowConditionalOperator.ConditionInfo         = conditionalOperator.Condition;
                                workFlowConditionalOperator.IsActiveConditional   = true;
                                condtitionalOperatorCollection.Add(workFlowConditionalOperator);
                            }
                            workFlowDetail.ConditionalOperator = condtitionalOperatorCollection;
                        }
                        workFlowDetail.Children = ChildWorkFlowPermissio(workFlowDetails.Id);
                        workFlowColllection.Add(workFlowDetail);
                        workFlowAc.Permission = workFlowColllection;
                    }
                    else
                    {
                        var workFlowDetail = new WorkFlowPermission
                        {
                            WorkFlowId  = workFlowDetails.WorkFlowId,
                            InitiatorId = workFlowDetails.InitiatorId,
                            AssignedId  = workFlowDetails.AssignedId,
                            //OldStatus = workFlowDetails.OldStatusId,
                            //NewStatus = workFlowDetails.NewStatusId,
                            IsChild                = workFlowDetails.IsParentAction,
                            IsParentAction         = workFlowDetails.IsParentAction,
                            IsApprovePanel         = false,
                            IsRejectPanel          = false,
                            ActivityId             = workFlowDetails.ActivityId,
                            NextActivityId         = workFlowDetails.NextActivityId,
                            ParentActivityId       = workFlowDetails.ParentActivityId,
                            workFlowActionId       = workFlowDetails.Id,
                            IsActivityClose        = workFlowDetails.NextActivity.IsClosed,
                            IsCondition            = workFlowDetails.IsCondition,
                            IsAllowOtherWorkFlow   = workFlowDetails.IsAllowOtherWorkFlow,
                            OtherWorkFlowId        = workFlowDetails.OtherWorkFlowId,
                            IsAllowOtherBranchUser = workFlowDetails.IsAllowOtherBranchUser
                                                     //Variable1 = workFlowDetails.Variable1,
                                                     //Variable2 = workFlowDetails.Variable2,Operator = workFlowDetails.Operator
                        };
                        workFlowColllection.Add(workFlowDetail);
                        workFlowAc.Permission = workFlowColllection;
                    }
                    return(workFlowAc);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
Esempio n. 4
0
        public IHttpActionResult SaveWorkFlowDetails(WorkFlowAc workFlowDetails)
        {
            try
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    var userId         = HttpContext.Current.User.Identity.GetUserId();
                    var companyDetails = _companyDataRepository.FirstOrDefault(x => x.UserId == userId);
                    if (companyDetails != null)
                    {
                        foreach (var workFlow in workFlowDetails.Permission)
                        {
                            if (workFlow != null)
                            {
                                if (workFlow.IsApproval || workFlow.IsReview || workFlow.IsClosed || workFlow.IsCondition)
                                {
                                    var workFlowDetail = new WorkFlowDetail
                                    {
                                        WorkFlowName = workFlowDetails.WorkFlowName,
                                        WorkFlowId   = workFlowDetails.PermissionId,
                                        InitiatorId  = workFlow.InitiatorId,
                                        AssignedId   = workFlow.AssignedId,
                                        //OldStatusId = workFlow.OldStatus,
                                        //NewStatusId = workFlow.NewStatus,
                                        //CreatedDateTime = DateTime.UtcNow,
                                        CreatedBy  = HttpContext.Current.User.Identity.GetUserId(),
                                        IsApproval = workFlow.IsApproval,
                                        IsReview   = workFlow.IsReview,
                                        // WorkFlowActionId = workFlow.ActionId,
                                        CompanyId      = companyDetails.Id,
                                        ActivityId     = workFlow.ActivityId,
                                        NextActivityId = workFlow.NextActivityId,
                                        IsClosed       = workFlow.IsClosed,
                                        IsParentAction = true,
                                        Id             = workFlowDetails.workFlowActionId,
                                        //Variable1 = workFlow.Variable1,
                                        //Variable2 = workFlow.Variable2,
                                        //Operator = workFlow.Operator,
                                        IsCondition            = workFlow.IsCondition,
                                        IsAllowOtherBranchUser = workFlow.IsAllowOtherBranchUser,
                                        ParentActivityId       = 0,
                                    };
                                    IsChildCondtion   = workFlowDetail.IsCondition;
                                    _parentActivityId = _workFlowRepository.SaveWorkFlowActionDetails(workFlowDetail);
                                    if (workFlow.IsCondition)
                                    {
                                        foreach (var workFlowConditionalOperator in workFlow.ConditionalOperator)
                                        {
                                            //if (workFlowConditionalOperator.ConditionInfo == null)
                                            //{
                                            var conditionlOperator = new ConditionalOperator
                                            {
                                                Id        = workFlowConditionalOperator.ConditionalOperatorId,
                                                Variable1 = workFlowConditionalOperator.Variable1,
                                                Variable2 = workFlowConditionalOperator.Variable2,
                                                Condition = workFlowConditionalOperator.ConditionInfo,
                                                //CreatedDateTime = DateTime.UtcNow,
                                                Operator                    = workFlowConditionalOperator.Operator,
                                                WorkFlowDetailId            = _parentActivityId,
                                                IsBoolenCondtion            = workFlowConditionalOperator.IsBoolenCondtion,
                                                ParentConditionalOperatorId = _conditionalOperatorParentId
                                            };

                                            _conditionalOperatorParentId = _workFlowRepository.SaveWorkConditionalOperatorDetails(conditionlOperator);
                                            // }
                                            //else
                                            //{
                                            //    var conditionlOperator = new ConditionalOperator
                                            //    {
                                            //        Id = workFlowConditionalOperator.ConditionalOperatorId,
                                            //        Variable1 = workFlowConditionalOperator.Variable1,
                                            //        Variable2 = workFlowConditionalOperator.Variable2,
                                            //        Condition = workFlowConditionalOperator.ConditionInfo,
                                            //        CreatedDateTime = DateTime.UtcNow,
                                            //        Operator = workFlowConditionalOperator.Operator,
                                            //        WorkFlowDetailId = _parentActivityId,
                                            //        ParentConditionalOperatorId = _conditionalOperatorParentId
                                            //    };
                                            //    _conditionalOperatorChildId =
                                            //        _workFlowRepository.SaveWorkConditionalOperatorDetails(conditionlOperator);
                                            //}
                                        }
                                    }
                                }
                                else
                                {
                                    var workFlowDetail = new WorkFlowDetail
                                    {
                                        // WorkFlowName = workFlowDetails.WorkFlowName,
                                        WorkFlowId  = workFlowDetails.PermissionId,
                                        InitiatorId = workFlow.InitiatorId,
                                        AssignedId  = workFlow.AssignedId,
                                        //OldStatusId = workFlow.OldStatus,
                                        //NewStatusId = workFlow.NewStatus,
                                        //CreatedDateTime = DateTime.UtcNow,
                                        CreatedBy  = HttpContext.Current.User.Identity.GetUserId(),
                                        IsApproval = workFlow.IsApproval,
                                        IsReview   = workFlow.IsReview,
                                        // WorkFlowActionId = workFlow.ActionId,
                                        CompanyId            = companyDetails.Id,
                                        ActivityId           = workFlow.ActivityId,
                                        NextActivityId       = workFlow.NextActivityId,
                                        IsClosed             = workFlow.IsClosed,
                                        IsApprovePanel       = workFlow.IsApprovePanel,
                                        IsRejectPanel        = workFlow.IsRejectPanel,
                                        ParentActivityId     = _parentActivityId,
                                        IsChildAction        = true,
                                        IsAllowOtherWorkFlow = workFlow.IsAllowOtherWorkFlow,
                                        OtherWorkFlowId      = workFlow.OtherWorkFlowId,
                                        Id = workFlow.workFlowActionId,
                                        IsAllowOtherBranchUser = workFlow.IsAllowOtherBranchUser,
                                        //Variable2 = workFlow.Variable2,


                                        // Variable1 = workFlow.Variable1,

                                        //Operator = workFlow.Operator,
                                        IsCondition      = workFlow.IsCondition,
                                        IsChildCondition = IsChildCondtion,
                                    };
                                    _childActivityId = _workFlowRepository.SaveWorkFlowDetails(workFlowDetail);
                                }
                            }
                        }
                        workFlowDetails.PermissionId = _parentActivityId;
                    }


                    //var workFlowCollection = _workFlowRepository.GetWorkFlowDetailsForTreeViewByActivityId(workFlowDetails.ActivityId);
                    return(Ok(workFlowDetails));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }