public void AnalyzeLeave(List <ColumnInfo> _atdtParameters, List <ColumnInfo> _personalParameters, tlvleaapp _leaveApp, bool _isSaveDetail) { try { //analatBll.GetAnalyzeDateRange(_atdtParameters, ref AnalStartDate, ref AnalEndDate); AnalStartDate = Convert.ToDateTime(_atdtParameters[0].ColumnValue); AnalEndDate = Convert.ToDateTime(_atdtParameters[1].ColumnValue); analatBll.GetPersonals(_personalParameters, ref lstStaff, ref sSqlStaff, AnalStartDate); lstPriCalendar = analatBll.GetPrivateCalendar(_personalParameters, sSqlStaff, AnalStartDate, AnalEndDate); lstCalendarDetails = analatBll.GetCalendar(AnalStartDate, AnalEndDate); lstRosterDetails = analatBll.GetRosterDetails(AnalStartDate, AnalEndDate); lstRosterHistory = analatBll.GetRosterHistory(sSqlStaff, AnalStartDate, AnalEndDate); //lstLeaveApp = analatBll.GetLeaveApp(sSqlStaff, AnalStartDate, AnalEndDate); DoAnalyze(_leaveApp, _isSaveDetail); } catch (UtilException ex) { throw ex; } catch (Exception ex) { throw new UtilException(ex.Message, ex); } }
private void CreateAlarmForLeave(tlvleaapp _leaveApp) { vw_employment emp = GetEmploymee(_leaveApp.emno); tstalarm alarmMdl = new tstalarm(); alarmMdl.alid = Function.GetGUID(); alarmMdl.alst = "Unhandled"; alarmMdl.alty = "Board"; alarmMdl.apnm = Parameter.APPLICATION_NAME; alarmMdl.bdtx = BuildAlarmBodyForLeaveApplication(_leaveApp, emp); alarmMdl.cc = string.Empty; alarmMdl.crtm = DateTime.Now; alarmMdl.crur = Function.GetCurrentUser(); alarmMdl.extm = DateTime.Now.AddDays(30); //will expire in 30 days. alarmMdl.mtyp = "Leave Application"; alarmMdl.reci = new stalsubsBll().GetRecipicientsBoard(emp.emno); alarmMdl.remk = _leaveApp.remk; alarmMdl.subj = emp.ntnm.Trim() + "'s Leave Application [" + _leaveApp.apno + "]"; if (alarmMdl.reci == string.Empty) { alarmMdl.reci = "Unknown"; } DoInsert <tstalarm>(alarmMdl); }
public void Edit() { string message = "{}"; try { string record = this.Request["record"]; Hashtable ht = JavaScriptConvert.DeserializeObject <Hashtable>(record); List <ColumnInfo> parameters = JavaScriptConvert.DeserializeObject <List <ColumnInfo> >(ht["keycolumns"].ToString()); tlvleaapp obj = JavaScriptConvert.DeserializeObject <tlvleaapp>(ht["params"].ToString()); //new BaseBll().DoInsert<T>(obj); lvleaappBll bll = new lvleaappBll(); bll.UpdateLeaveApplication(obj); message = "{status:'success',msg:'" + HRMSRes.Public_Message_EditWell + "'}"; } catch (Exception ex) { message = "{status:'failure',msg:'" + ExceptionPaser.Parse(HRMSRes.Public_Message_EditBad, ex, true) + "'}"; } Response.Write(message); }
public void CalcLeaveTime() { string message = "{}"; try { string record = this.Request["record"]; Hashtable ht = JavaScriptConvert.DeserializeObject <Hashtable>(record); tlvleaapp obj = new tlvleaapp(); obj.emno = ht["emno"].ToString(); obj.frtm = Convert.ToDateTime(ht["fromdate"].ToString()); obj.totm = Convert.ToDateTime(ht["todate"].ToString()); lvleaappBll bll = new lvleaappBll(); string json = bll.CalcLeaveTime(obj); message = "{status:'success'," + json + "}"; } catch (Exception ex) { message = "{status:'failure',msg:'" + ExceptionPaser.Parse(HRMSRes.Public_Message_EditBad, ex, true) + "'}"; } Response.Write(message); }
public void UpdateLeaveApplication(tlvleaapp _leaveApp) { try { //分析请假并保存 lvanalevBll bll = new lvanalevBll(); List <ColumnInfo> dateParameters = new List <ColumnInfo>(); dateParameters.Add(new ColumnInfo() { ColumnName = "lvstart", ColumnValue = UtilDatetime.FormateDateTime1(_leaveApp.frtm) }); dateParameters.Add(new ColumnInfo() { ColumnName = "lvend", ColumnValue = UtilDatetime.FormateDateTime1(_leaveApp.totm), ColumnType = "datetime" }); List <ColumnInfo> personParameters = new List <ColumnInfo>(); personParameters.Add(new ColumnInfo() { ColumnName = "emp.emno", ColumnValue = _leaveApp.emno }); using (TransactionScope scope = new TransactionScope()) { //先删除leave detail List <ColumnInfo> apnoParameters = new List <ColumnInfo>() { new ColumnInfo() { ColumnName = "apno", ColumnValue = _leaveApp.apno } }; dal.DeleteLeaveAppDtl(apnoParameters); //如果审核过,则分析休假,并生成leave detail if (_leaveApp.lvst == "Approved") { bll.AnalyzeLeave(dateParameters, personParameters, _leaveApp, true); } DoUpdate <tlvleaapp>(_leaveApp, apnoParameters); scope.Complete(); } } catch (UtilException ex) { throw ex; } catch (Exception ex) { throw new UtilException(ex.Message, ex); } }
private string BuildAlarmBodyForLeaveApplication(tlvleaapp _leaveApp, vw_employment emp) { string bdtx = string.Empty; bdtx += "<LeaveApplication>"; //<LeaveApplication> bdtx += "<No>" + _leaveApp.apno + "</No>"; //No bdtx += "<Employee>" + emp.sfid + " - " + emp.ntnm + "</Employee>"; //Employee bdtx += "<Leave Type>" + _leaveApp.tlvleatyp.ltnm + "</Leave Type>"; //Leave Type bdtx += "<Leave Reason>" + _leaveApp.tlvlearsn.lrnm + "</Leave Reason>"; //Leave Reason bdtx += "<From Time>" + UtilDatetime.FormateDateTime1(_leaveApp.frtm) + "</From Time>"; //From Time bdtx += "<To Time>" + UtilDatetime.FormateDateTime1(_leaveApp.totm) + "</To Time>"; //To Time bdtx += "<Summary>" + "D:" + _leaveApp.days.ToString() + " / H:" + _leaveApp.hurs.ToString() + "</TSummary>"; //Summary bdtx += "<Remark>" + _leaveApp.remk + "</Remark>"; //Remark bdtx += "<br></LeaveApplication>"; //</LeaveApplication> return(bdtx); }
public string CalcLeaveTime(tlvleaapp leaveApp) { try { //只分析请假 lvanalevBll bll = new lvanalevBll(); List <ColumnInfo> dateParameters = new List <ColumnInfo>(); dateParameters.Add(new ColumnInfo() { ColumnName = "lvstart", ColumnValue = UtilDatetime.FormateDateTime1(leaveApp.frtm) }); dateParameters.Add(new ColumnInfo() { ColumnName = "lvend", ColumnValue = UtilDatetime.FormateDateTime1(leaveApp.totm), ColumnType = "datetime" }); List <ColumnInfo> personParameters = new List <ColumnInfo>(); personParameters.Add(new ColumnInfo() { ColumnName = "emp.emno", ColumnValue = leaveApp.emno }); bll.AnalyzeLeave(dateParameters, personParameters, null, false); return("totallvhours:'" + bll.TotalLvHours.ToString() + "',totallvdays:'" + bll.TotalLvDays.ToString() + "'"); } catch (UtilException ex) { throw ex; } catch (Exception ex) { throw new UtilException(ex.Message, ex); } }
public void DoAnalyze(tlvleaapp _leaveApp, bool _isSaveDetail) { for (int i = 0; i < lstStaff.Count; i++) { TotalLvHours = 0; TotalLvDays = 0; try { DateTime calcStart = AnalStartDate; DateTime calcEnd = AnalEndDate; DateTime tmpStart = calcStart; DateTime tmpEnd; //如果请假跨天,需要拆分成多条数据 for (float k = 0; k < (calcEnd - calcStart).TotalDays; k++) { if ((calcEnd - tmpStart).TotalDays > 1) { tmpEnd = Convert.ToDateTime(UtilDatetime.FormatDate1(tmpStart.AddDays(1)) + " 00:00:00"); } else { tmpEnd = calcEnd; } //取轮班历史 List <tatroshi> lstEmpRosterHistory = lstRosterHistory.Where(p => p.emno == lstStaff[i].emno && ((p.exdt.HasValue == false) || (p.exdt.Value > tmpEnd)) && (p.efdt <= tmpStart) ).ToList(); //确定轮班和班次 if (lstEmpRosterHistory.Count > 0) { //如果发现多条,则只取第一条 tatroshi curRosterHistory = lstEmpRosterHistory[0]; List <tatrosdtl> lstEmpRosterDtl = lstRosterDetails.Where(p => p.rscd == curRosterHistory.rscd).ToList(); //确定轮班明细和班次 tatrosdtl curRosterDtl = getCurrentRoster(curRosterHistory, lstEmpRosterDtl, tmpStart); tatshift curShift = curRosterDtl.tatshift; //分析此天的休假 AnalyzeOneDay(lstStaff[i], curRosterDtl, curShift, curRosterHistory, tmpStart, tmpEnd, _leaveApp, _isSaveDetail); tmpStart = tmpEnd; } else { //如果没有定义轮班该如何计算???? } } } catch (Exception ex) { throw ex; } } }
private void AnalyzeOneDay(vw_employment _emp, tatrosdtl curRosterDtl, tatshift curShift, tatroshi curRosterHistory, DateTime _calcStart, DateTime _calcEnd, tlvleaapp _leaveApp, bool _isSaveDetail) { store = new AtCalculationInfo(); store.EmpInfo = _emp; store.CurDay = _calcStart; //curDayR = store.CurDay; //取得标准班次设定时间 analatBll.GetStandardValue(curRosterDtl, curShift, ref store); //判断是否是休息日 analatBll.CheckIsRestDay(curRosterDtl, curShift, curRosterHistory, lstPriCalendar, ref store); if (store.IsRestDay == false) { #region 非休息日 if ((_calcStart <= store.StdTimeIn) && (_calcEnd >= store.StdTimeOut)) { //抓班次设定的工作小时数和天数 store.LvStart = store.StdTimeIn; store.LvEnd = store.StdTimeOut; store.LvHours = Convert.ToDouble(curShift.wkhr); store.LvDays = Convert.ToDouble(curShift.wkda); } else { if (_calcStart <= store.StdTimeIn) { store.LvStart = store.StdTimeIn; } else { store.LvStart = _calcStart; } if (_calcEnd >= store.StdTimeOut) { store.LvEnd = store.StdTimeOut; } else { store.LvEnd = _calcEnd; } store.LvHours = CountLeaveTime(store.LvStart, store.LvEnd, curShift, store); store.LvHours = Math.Round(store.LvHours, 2); //计算天数 store.LvDays = Math.Round((store.LvHours / Convert.ToDouble(curShift.wkhr)) * Convert.ToDouble(curShift.wkda), 2); } #endregion } else { #region 休息日 store.LvHours = 0; store.LvDays = 0; #endregion } TotalLvHours += store.LvHours; TotalLvDays += store.LvDays; if ((_isSaveDetail) && (_leaveApp != null) && (store.LvHours > 0)) { //如果需要保存则保存每一条明细到DTL表 tlvleaapd newdtl = new tlvleaapd(); newdtl.emno = _emp.emno; newdtl.days = store.LvDays; newdtl.hurs = store.LvHours; newdtl.ltcd = _leaveApp.ltcd; newdtl.apno = _leaveApp.apno; newdtl.totm = store.LvEnd.Value; newdtl.frtm = store.LvStart.Value; DoInsert <tlvleaapd>(newdtl); } }