/// <summary> /// تنظیم تاریخها /// </summary> /// <param name="substitute"></param> /// <param name="action"></param> protected override void GetReadyBeforeSave(Substitute substitute, UIActionType action) { decimal mangerPersonId = substitute.ManagerPersonId; substitute.FromDate = Utility.GTSMinStandardDateTime; substitute.ToDate = Utility.GTSMinStandardDateTime; if (!Utility.IsEmpty(substitute.TheFromDate) && !Utility.IsEmpty(substitute.TheToDate)) { if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { substitute.FromDate = Utility.ToMildiDate(substitute.TheFromDate); substitute.ToDate = Utility.ToMildiDate(substitute.TheToDate); } else { substitute.FromDate = Utility.ToMildiDateTime(substitute.TheFromDate); substitute.ToDate = Utility.ToMildiDateTime(substitute.TheToDate); } } if (substitute.ManagerPersonId > 0) { BManager busManager = new BManager(); Manager manager = busManager.GetManager(substitute.ManagerPersonId); substitute.Manager = manager; } //PrecardList Recover if (action == UIActionType.EDIT && !substitute.PrecardAccessIsSet) { Substitute sub = this.GetByID(substitute.ID); substitute.PrecardList = sub.PrecardList; NHibernateSessionManager.Instance.ClearSession(); } }
public IList <Manager> GetManagerFlow(decimal flowID) { try { IList <Manager> list = new BManager().GetManagerFlow(flowID); return(list); } catch (Exception ex) { LogException(ex, "BFlow", "GetManagerFlow"); throw ex; } }
/// <summary> /// لیست بخش های تحت مدیریت یک مدیر را برمیگرداند /// </summary> /// <param name="mangerId"></param> /// <returns></returns> public IList <Department> GetUnderManagmentDepartmentByManager(decimal mangerId) { if (mangerId > 0) { IList <Department> depList = new List <Department>(); List <decimal> nodeParentChildsId = new List <decimal>(); Manager manager = new BManager().GetByID(mangerId); var flows = from n in manager.ManagerFlowList select n.Flow; IList <Flow> flowList = flows.ToList(); foreach (Flow flow in flowList) { foreach (UnderManagment underManagment in flow.UnderManagmentList) { if (underManagment.Department != null && underManagment.Department.ID > 0) { nodeParentChildsId.Add(underManagment.Department.ID); nodeParentChildsId.AddRange(underManagment.Department.ParentPathList); if (underManagment.ContainInnerChilds) { nodeParentChildsId = GetDepartmentChildsIdList(underManagment.Department); } } else { throw new InvalidDatabaseStateException(UIFatalExceptionIdentifiers.UnderManagmentDepartmentNull, "بخش مربوط به افراد تحت مدیریت در هیچ صورتی نباید تهی باشد", ExceptionSrc); } } } nodeParentChildsId = nodeParentChildsId.GroupBy(x => x).Select(x => x.First()).ToList(); foreach (decimal id in nodeParentChildsId) { depList.Add(new Department() { ID = id }); } return(depList); } else { throw new IllegalServiceAccess(String.Format("این سرویس تنها توسط مدیران قابل استفاده میباشد. شناسه کاربری {0} میباشد", this.workingUsername), ExceptionSrc); } }
/// <summary> /// لیست افراد تحت مدیریت یک مدیر را برمیگرداند /// </summary> /// <param name="mangerId"></param> /// <returns></returns> public IList <Person> GetUnderManagmentPersonsByManager(decimal mangerId) { List <Person> result = new List <Person>(); if (mangerId > 0) { IList <Department> depList = new List <Department>(); List <decimal> nodeParentChildsId = new List <decimal>(); Manager manager = new BManager().GetByID(mangerId); var flows = from n in manager.ManagerFlowList select n.Flow; IList <Flow> flowList = flows.ToList(); foreach (Flow flow in flowList) { result.AddRange(this.GetUnderManagmentPersonsByFlow(flow)); } } return(result); }
/// <summary> /// بروزرسانی مدیرهای یک جریان خاص /// </summary> /// <param name="flowId">کد جریان</param> /// <param name="activeFlow">وضعیت فعال بودن</param> /// <param name="mngrFlows">مدیران جریان کاری</param> public void UpdateManagerFlows(decimal flowId, bool activeFlow, bool mainFlow, IList <ManagerProxy> mngrFlows) { ManagerRepository managerRep = new ManagerRepository(false); using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { if (Utility.IsEmpty(mngrFlows)) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(new ValidationException(ExceptionResourceKeys.FlowMustHaveOneManagerFlow, "جریان کاری باید حداقل دارای یک مدیر در خود باشد", ExceptionSrc)); throw exception; } BManager bManager = new BManager(); Flow flow = base.GetByID(flowId); flow.ActiveFlow = activeFlow; flow.MainFlow = mainFlow; flow.ManagerFlowList = new List <ManagerFlow>(); flowRep.DeleteManagerFlows(flowId); foreach (ManagerProxy mp in mngrFlows) { ManagerFlow managerFlow = new ManagerFlow(); Manager mng; if (mp.OwnerID == 0) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(new ValidationException(ExceptionResourceKeys.FlowPersonOrOrganizationMustSpecified, "یا شخص یا پست سازمانی باید مقداردهی شود", ExceptionSrc)); throw exception; } if (mp.ManagerType == ManagerType.Person) { mng = managerRep.GetManagerByPersonID(mp.OwnerID); if (mng == null || mng.ID == 0) { Manager manager = new Manager(); manager.Person = new Person() { ID = mp.OwnerID }; manager.Active = true; bManager.SaveChanges(manager, UIActionType.ADD); mng = manager; } } else { mng = managerRep.GetManagerByOrganID(mp.OwnerID); if (mng == null || mng.ID == 0) { Manager manager = new Manager(); manager.OrganizationUnit = new OrganizationUnit() { ID = mp.OwnerID }; manager.Active = true; bManager.SaveChanges(manager, UIActionType.ADD); mng = manager; } } managerFlow.Active = true; managerFlow.Manager = mng; managerFlow.Flow = flow; managerFlow.Level = mp.Level; flow.ManagerFlowList.Add(managerFlow); } SaveChanges(flow, UIActionType.EDIT); managerRep.SetManagerActivation(); LogUserAction(flow, "Change Manager Flow Levels"); NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { NHibernateSessionManager.Instance.RollbackTransactionOn(); LogException(ex); throw ex; } } }