Exemple #1
0
        public IList <Department> GetDepartmentChilds(decimal nodeID, decimal flowId)
        {
            BFlow bFlow = new BFlow();
            IList <Department> departmentsList = new BDepartment().GetAll();

            return(bFlow.GetDepartmentChilds(nodeID, flowId, departmentsList));
        }
Exemple #2
0
 public decimal UpdateFlow(decimal flowID, decimal accessGroupId, string flowName, IList <UnderManagment> underMnagList)
 {
     try
     {
         BFlow bflow = new BFlow();
         Flow  flow  = bflow.GetByID(flowID);
         flow.ID          = flowID;
         flow.FlowName    = flowName;
         flow.AccessGroup = new PrecardAccessGroup()
         {
             ID = accessGroupId
         };
         flow.UnderManagmentList = new List <UnderManagment>();
         foreach (UnderManagment un in underMnagList)
         {
             un.Flow = flow;
             flow.UnderManagmentList.Add(un);
         }
         UnderManagmentRepository underRep = new UnderManagmentRepository(false);
         underRep.DeleteUnderManagments(flow.ID);
         bflow.SaveChanges(flow, UIActionType.EDIT);
         return(flow.ID);
     }
     catch (Exception ex)
     {
         LogException(ex, "BManager", "UpdateFlow");
         throw ex;
     }
 }
Exemple #3
0
        /// <summary>
        /// درج جریان کاری
        /// </summary>
        /// <param name="personId">شناسه پست سلزمانی مدیر اولیه</param>
        /// <param name="accessGroup">شناسه گروه دسترسی</param>
        /// <param name="flowName">نام جریان کاری</param>
        /// <param name="underMnagList">افراد و بخشهای تحت مدیریت</param>
        /// <returns></returns>
        public decimal InsertFlowByOrganization(decimal organizationId, decimal accessGroup, string flowName, IList <UnderManagment> underMnagList)
        {
            Flow flow = new Flow();

            using (NHibernateSessionManager.Instance.BeginTransactionOn())
            {
                try
                {
                    flow.FlowName    = flowName;
                    flow.AccessGroup = new PrecardAccessGroup()
                    {
                        ID = accessGroup
                    };
                    flow.ActiveFlow         = true;
                    flow.ManagerFlowList    = new List <ManagerFlow>();
                    flow.UnderManagmentList = new List <UnderManagment>();

                    Manager mng = managerRep.GetManagerByOrganID(organizationId);
                    if (mng == null || mng.ID == 0)
                    {
                        Manager manager = new Manager();
                        manager.OrganizationUnit = new OrganizationUnit()
                        {
                            ID = organizationId
                        };
                        manager.Active = true;
                        this.SaveChanges(manager, UIActionType.ADD);
                        mng = manager;
                    }

                    ManagerFlow managerFlow = new ManagerFlow();
                    managerFlow.Flow    = flow;
                    managerFlow.Manager = mng;
                    managerFlow.Level   = 1;
                    managerFlow.Active  = true;
                    flow.ManagerFlowList.Add(managerFlow);

                    foreach (UnderManagment un in underMnagList)
                    {
                        un.Flow = flow;
                        flow.UnderManagmentList.Add(un);
                    }


                    BFlow bflow = new BFlow();
                    bflow.SaveChanges(flow, UIActionType.ADD);

                    NHibernateSessionManager.Instance.CommitTransactionOn();
                    return(flow.ID);
                }

                catch (Exception ex)
                {
                    NHibernateSessionManager.Instance.RollbackTransactionOn();
                    LogException(ex, "BManager", "InsertFlowByOrganization");
                    throw ex;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// همه پیشکارتها را جهت نمایش گروهی برمیگرداند
        /// اگر پارامتر ورودی صفر باشد بدین معنی است که
        /// در مد اینزرت هستیم
        /// </summary>
        /// <param name="accessGroupId"></param>
        /// <returns></returns>
        public IList <PrecardGroups> GetPrecardTree(decimal substituteId, decimal flowId)
        {
            try
            {
                BPrecardAccessGroup bpAccess = new BPrecardAccessGroup();
                BFlow flow = new BFlow();
                PrecardAccessGroup    group = flow.GetByID(flowId).AccessGroup;
                IList <PrecardGroups> list  = bpAccess.GetPrecardTree(group.ID);

                Substitute      substitute = this.GetByID(substituteId);
                IList <Precard> precards   = substitute.PrecardList;


                foreach (PrecardGroups g in list)
                {
                    int childCount = 0;
                    foreach (Precard p in g.PrecardList)
                    {
                        p.ContainInPrecardAccessGroup = false;
                        if (precards.Where(x => x.ID == p.ID).Count() > 0)
                        {
                            p.ContainInPrecardAccessGroup = true;
                            childCount++;
                        }
                    }
                    g.ContainInPrecardAccessGroup = false;
                    if (childCount == g.PrecardList.Count)
                    {
                        g.ContainInPrecardAccessGroup = true;
                    }
                }
                return(list);
            }
            catch (Exception ex)
            {
                LogException(ex, "BSubstitute", "GetPrecardTree");
                throw ex;
            }
        }
Exemple #5
0
        /// <summary>
        /// پیشکارتهای یک جانشین را ثبت میکند
        /// اگر پارانتر آخر تهی باشد بدین معنی است که جریان حذف شود یعنی تمام پیشکارتهایش خالی شود
        /// </summary>
        /// <param name="substituteId"></param>
        /// <param name="flowId"></param>
        /// <param name="accessGroupList"></param>
        /// <returns></returns>
        public bool UpdateByProxy(decimal substituteId, decimal flowId, IList <AccessGroupProxy> accessGroupList)
        {
            try
            {
                if (substituteId == 0 || flowId == 0)
                {
                    UIValidationExceptions exception = new UIValidationExceptions();
                    exception.Add(new ValidationException(ExceptionResourceKeys.SubstituteUpdateFlowAndSubstituteIdRequeiered, "کد جریان و جانشین نامشخص است", ExceptionSrc));
                }
                bool  substituteContainsFlow = false;//تیک جریان کاری در گرید مربوطه
                BFlow flow = new BFlow();
                PrecardAccessGroup precardAccessGroup     = flow.GetByID(flowId).AccessGroup;
                EntityRepository <PrecardGroups> groupRep = new EntityRepository <PrecardGroups>(false);
                IList <Precard> removeList = new List <Precard>();
                Substitute      substitute = this.GetByID(substituteId);
                substitute.PrecardAccessIsSet = true;
                substitute.TheFromDate        = Utility.ToPersianDate(substitute.FromDate);
                substitute.TheToDate          = Utility.ToPersianDate(substitute.ToDate);
                //ابتدا همگی حذف و سپس ایجاد میگردد
                substitute.PrecardList = new List <Precard>();

                if (accessGroupList != null)
                {
                    foreach (AccessGroupProxy proxy in accessGroupList)
                    {
                        if (proxy.IsParent)
                        {
                            PrecardGroups group = groupRep.GetById(proxy.ID, false);
                            foreach (Precard p in group.PrecardList)
                            {
                                substituteContainsFlow = true;
                                substitute.PrecardList.Add(p);
                            }
                        }
                        else if (proxy.Checked)
                        {
                            substituteContainsFlow = true;
                            substitute.PrecardList.Add(new Precard()
                            {
                                ID = proxy.ID
                            });
                        }
                        else
                        {
                            removeList.Add(new Precard()
                            {
                                ID = proxy.ID
                            });
                        }
                    }
                    foreach (Precard p in removeList)
                    {
                        substitute.PrecardList.Remove(p);
                    }
                }
                SaveChanges(substitute, UIActionType.EDIT);
                return(substituteContainsFlow);
            }
            catch (Exception ex)
            {
                LogException(ex, "BSubstitute", "UpdateByProxy");
                throw ex;
            }
        }
Exemple #6
0
        public IList <Person> GetDepartmentPerson(decimal departmentID, decimal flowId)
        {
            BFlow bFlow = new BFlow();

            return(bFlow.GetDepartmentPerson(departmentID, flowId));
        }
Exemple #7
0
        public IList <Department> GetDepartmentChilds(decimal nodeID, decimal flowId)
        {
            BFlow bFlow = new BFlow();

            return(bFlow.GetDepartmentChilds(nodeID, flowId));
        }
Exemple #8
0
        public Department GetDepartmentRoot()
        {
            BFlow bFlow = new BFlow();

            return(bFlow.GetDepartmentRoot());
        }