/// <summary> /// مدل سرانه را به پروکسی مربوطه تبدیل می کند /// </summary> /// <param name="item">مدل</param> /// <returns>پروکسی</returns> public OverTimeProxy ConvertToProxy(OverTimeDetail item) { try { OverTimeProxy proxy = new OverTimeProxy(); proxy.ID = item.ID; proxy.Date = item.OverTime.Date; proxy.IsActive = item.OverTime.IsActive; proxy.DepartmentName = item.Department.Name; if (personList != null) { proxy.OverTimePersonCount = personList.Where(c => c.Department.ParentPath != null && (c.Department.ID == item.Department.ID || c.Department.ParentPath.Contains("," + item.Department.ID + ",")) && c.PersonTASpec.OverTimeWork == true).Count(); proxy.NightlyPersonCount = personList.Where(c => c.Department.ParentPath != null && (c.Department.ID == item.Department.ID || c.Department.ParentPath.Contains("," + item.Department.ID + ",")) && c.PersonTASpec.NightWork == true).Count(); proxy.HolidayPersonCount = personList.Where(c => c.Department.ParentPath != null && (c.Department.ID == item.Department.ID || c.Department.ParentPath.Contains("," + item.Department.ID + ",")) && c.PersonTASpec.HolidayWork == true).Count(); } else { proxy.OverTimePersonCount = bPerson.GetAllPersonsCountByDepartmentParentID(item.Department.ID, OverTimePersuasiveType.OverTimeWork); proxy.NightlyPersonCount = bPerson.GetAllPersonsCountByDepartmentParentID(item.Department.ID, OverTimePersuasiveType.NightWork); proxy.HolidayPersonCount = bPerson.GetAllPersonsCountByDepartmentParentID(item.Department.ID, OverTimePersuasiveType.HolidayWork); } proxy.MaxOverTime = item.MaxOverTime; proxy.MaxHoliday = item.MaxHoliday; proxy.MaxNightly = item.MaxNightly; return(proxy); } catch (Exception ex) { throw ex; } }
public OverTimeProxy GetItem(decimal id) { try { var overTimeDetail = OverTimeDetailBusiness.GetByID(id); OverTimeProxy overTimeProxy = OverTimeDetailBusiness.ConvertToProxy(overTimeDetail); return(overTimeProxy); } catch (Exception ex) { throw ex; } }
public OverTimeProxy GetItem(decimal id) { try { var overTimeDetail = OverTimeDetailBusiness.GetByID(id); OverTimeProxy overTimeProxy = OverTimeDetailBusiness.ConvertToProxy(overTimeDetail); return(overTimeProxy); } catch (Exception ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); throw ex; } }
public void Edit(decimal id, OverTimeProxy viewModel) { try { OverTimeDetail model = OverTimeDetailBusiness.GetByID(id); model.MaxHoliday = viewModel.MaxHoliday; model.MaxNightly = viewModel.MaxNightly; model.MaxOverTime = viewModel.MaxOverTime; OverTimeDetailBusiness.UpdateOverTimeDetail(model); } catch (Exception ex) { throw ex; } }
public void Edit(decimal id, OverTimeProxy viewModel) { try { OverTimePersonDetail model = OverTimePersonDetailBusiness.GetByID(id); model.MaxHoliday = viewModel.MaxHoliday; model.MaxNightly = viewModel.MaxNightly; model.MaxOverTime = viewModel.MaxOverTime; OverTimePersonDetailBusiness.UpdateOverTimePersonDetail(model, ApprovalScheduleType.Administrative, BUser.CurrentUser.Person.ID); } catch (Exception ex) { throw ex; } }
public HttpResponseMessage Edit(decimal id, OverTimeProxy viewModel) { try { decimal ManagerPersonId; if (viewModel.ManagerPersonId == 0) { ManagerPersonId = BUser.CurrentUser.Person.ID; } else { ManagerPersonId = viewModel.ManagerPersonId; } //------------------------------------------------------------------------ Person person = PersonBusiness.GetByID(ManagerPersonId); //تشخیص اینکه طرف معاون هست یا خیر - جهت اعمال محدودیت زمان بندی تایید به تفکیک مدیران و معاونین ApprovalScheduleType approvalType = ApprovalScheduleType.Manager; var personParamAssistance = person.PersonTASpec.GetParamValue(person.ID, "IsAssistance", DateTime.Now); bool stateAssistance = personParamAssistance != null?Utility.ToInteger(personParamAssistance.Value) > 0 : false; if (stateAssistance) { approvalType = ApprovalScheduleType.Assistance; } OverTimePersonDetailBusiness.UpdateOverTimePersonDetail(id, viewModel, approvalType, ManagerPersonId); return(Request.CreateResponse(HttpStatusCode.OK, viewModel)); } catch (UIValidationExceptions ex) { this.exceptionHandler.ApiHandleException("OverTimePersonController", ex); return(Request.CreateResponse(HttpStatusCode.NotFound, ex.ExceptionList.Count > 0 ? ex.ExceptionList[0].Message : ex.Message)); } catch (Exception ex) { this.exceptionHandler.ApiHandleException("OverTimePersonController", ex); return(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message)); } }
public HttpResponseMessage Edit(decimal id, OverTimeProxy viewModel) { try { OverTimeDetail model = OverTimeDetailBusiness.GetByID(id); model.MaxHoliday = viewModel.MaxHoliday; model.MaxNightly = viewModel.MaxNightly; model.MaxOverTime = viewModel.MaxOverTime; OverTimeDetailBusiness.UpdateOverTimeDetail(model); return(Request.CreateResponse(HttpStatusCode.OK, viewModel)); } catch (UIValidationExceptions ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ExceptionList.Count > 0 ? ex.ExceptionList[0].Message : ex.Message)); } catch (Exception ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
/// <summary> /// سرانه های اضافه کار تشویقی, شب کاری تشویقی, تعطیل کار تشویقی مربوط به ماه/سال مشخص به صورت صفحه بندی شده بر می گرداند /// بر اساس دسترسی کاربر به دپارتمان /// </summary> /// <param name="parentDepartmentId">آی دی ارگان/سازمان جهت جستجو</param> /// <param name="departmentName">نام معاونت جهت جستجو</param> /// <param name="year">سال</param> /// <param name="month">ماه</param> /// <param name="pageIndex">ایندکس صفحه</param> /// <param name="pageSize">اندازه صفحه</param> /// <param name="count">تعداد کل رکوردها بدون صفحه بندی</param> /// <returns>لیست پروکسی سرانه</returns> public IList <OverTimeProxy> GetDetails(decimal parentDepartmentId, string departmentName, int year, int month, int pageIndex, int pageSize, out int count) { DateTime Date; if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { Date = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, month, 1)); } else { Date = new DateTime(year, month, 1); } //----------------------------------------------------------------- //چک کن اگه موجودیت والد برای این ماه/سال در دیتابیس وجود نداشت, یه موجودیت والد ذخیره کن this.CheckOverTimeExists(Date); //----------------------------------------------------------------- OverTime overTimeAlias = null; OverTimeDetail overTimeDetailAlias = null; Department departmentAlias = null; IQueryOver <OverTimeDetail, OverTimeDetail> searchQuery; IList <decimal> accessableIDs = accessPort.GetAccessibleDeparments(); if (accessableIDs.Count < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100) { searchQuery = NHSession.QueryOver(() => overTimeDetailAlias) .JoinAlias(() => overTimeDetailAlias.OverTime, () => overTimeAlias) .JoinAlias(() => overTimeDetailAlias.Department, () => departmentAlias) .Where(() => departmentAlias.ID.IsIn(accessableIDs.ToList()) && overTimeAlias.Date == Date && departmentAlias.ParentPath.IsLike("," + parentDepartmentId + ",", MatchMode.Anywhere) && departmentAlias.DepartmentType == DepartmentType.Assistance && overTimeAlias.IsActive == true); } else { GTS.Clock.Model.Temp.Temp tempAlias = null; string operationGUID = this.bTemp.InsertTempList(accessableIDs); searchQuery = NHSession.QueryOver(() => overTimeDetailAlias) .JoinAlias(() => overTimeDetailAlias.OverTime, () => overTimeAlias) .JoinAlias(() => overTimeDetailAlias.Department, () => departmentAlias) .JoinAlias(() => departmentAlias.TempList, () => tempAlias) .Where(() => tempAlias.OperationGUID == operationGUID && overTimeAlias.Date == Date && departmentAlias.ParentPath.IsLike("," + parentDepartmentId + ",", MatchMode.Anywhere) && departmentAlias.DepartmentType == DepartmentType.Assistance && overTimeAlias.IsActive == true); this.bTemp.DeleteTempList(operationGUID); } if (!Utility.IsEmpty(departmentName)) { searchQuery.Where(() => departmentAlias.Name.IsLike(departmentName, MatchMode.Anywhere)); } count = searchQuery.RowCount(); IList <OverTimeDetail> list = new List <OverTimeDetail>(); list = searchQuery.Skip(pageIndex * pageSize).Take(pageSize).List <OverTimeDetail>(); personList = bPerson.GetPersonsInfoForOverTime(); IList <OverTimeProxy> proxyList = new List <OverTimeProxy>(); var calendarList = bCalendar.GetCalendarListByDateRange(Date, Date.AddMonths(1), "6"); foreach (var item in list) { OverTimeProxy proxy = ConvertToProxy(item); proxy.MonthHolidayCount = calendarList != null?calendarList.Count() : 0; proxyList.Add(proxy); } return(proxyList); }