private object GetDateFormat() { SystemDefaultRecordRequest req = new SystemDefaultRecordRequest(); req.Key = "dateFormat"; RecordResponse <KeyValuePair <string, string> > response = _systemService.ChildGetRecord <KeyValuePair <string, string> >(req); if (!response.Success) { } return(response.result.Value); }
private string GetNameFormat() { SystemDefaultRecordRequest req = new SystemDefaultRecordRequest(); req.Key = "nameFormat"; RecordResponse <KeyValuePair <string, string> > response = _systemService.ChildGetRecord <KeyValuePair <string, string> >(req); if (!response.Success) { } string paranthized = response.result.Value; paranthized = paranthized.Replace('{', ' '); paranthized = paranthized.Replace('}', ','); paranthized = paranthized.Substring(0, paranthized.Length - 1); paranthized = paranthized.Replace(" ", string.Empty); return(paranthized); }
private string GetNameFormat() { string format = ""; SystemDefaultRecordRequest req = new SystemDefaultRecordRequest(); req.Key = "nameFormat"; RecordResponse <KeyValuePair <string, string> > r = _systemService.ChildGetRecord <KeyValuePair <string, string> >(req); if (!r.Success) { Common.errorMessage(r);; return(null); } format = r.result.Value; if (string.IsNullOrEmpty(r.result.Value)) { PostRequest <KeyValuePair <string, string> > request = new PostRequest <KeyValuePair <string, string> >(); request.entity = new KeyValuePair <string, string>("nameFormat", "{firstName} {lastName}"); PostResponse <KeyValuePair <string, string> > resp = _systemService.ChildAddOrUpdate <KeyValuePair <string, string> >(request); if (!resp.Success) { Common.errorMessage(resp); return(null); } format = "{firstName} {lastName}"; } string paranthized = format; paranthized = paranthized.Replace('{', ' '); paranthized = paranthized.Replace('}', ','); paranthized = paranthized.Substring(0, paranthized.Length - 1); paranthized = paranthized.Replace(" ", string.Empty); return(paranthized); }
protected void SaveNewRecord(object sender, DirectEventArgs e) { SystemDefaultRecordRequest req = new SystemDefaultRecordRequest(); //Getting the id to check if it is an Add or an edit as they are managed within the same form. try { string obj = e.ExtraParams["values"]; string ldMethodParam = e.ExtraParams["ldMethod"]; string ldValueParam = e.ExtraParams["ldValue"]; loanSelfService b = JsonConvert.DeserializeObject <loanSelfService>(obj); string id = e.ExtraParams["id"]; if (string.IsNullOrEmpty(id)) { if (!string.IsNullOrEmpty(ldValueParam)) { b.ldValue = Convert.ToDouble(ldValueParam); } if (!string.IsNullOrEmpty(ldMethodParam)) { b.ldMethod = Convert.ToInt16(ldMethodParam); } if (b.ldMethod == null) { req.Key = "ldMethod"; RecordResponse <KeyValuePair <string, string> > defaults = _systemService.ChildGetRecord <KeyValuePair <string, string> >(req); if (!defaults.Success) { Common.errorMessage(defaults); return; } if (!string.IsNullOrEmpty(defaults.result.Value)) { b.ldMethod = Convert.ToInt16(defaults.result.Value); } } if (b.ldValue == null) { req.Key = "ldValue"; RecordResponse <KeyValuePair <string, string> > ldValueResponse = _systemService.ChildGetRecord <KeyValuePair <string, string> >(req); if (!ldValueResponse.Success) { Common.errorMessage(ldValueResponse); return; } if (!string.IsNullOrEmpty(ldValueResponse.result.Value)) { b.ldValue = Convert.ToInt16(ldValueResponse.result.Value); } } } if (b.ldMethod == null) { X.MessageBox.Alert(GetGlobalResourceObject("Common", "Error").ToString(), GetGlobalResourceObject("Errors", "emptyLdMethod").ToString()).Show(); return; } //if (string.IsNullOrEmpty(ldMethod) //b.ldMethod =Convert.ToInt16( ldMethod); // Define the object to add or edit as null //if (ldMethodCom.SelectedItem != null) // b.ldMethod = ldMethodCom.SelectedItem.Value; if (date.ReadOnly) { b.date = DateTime.Now; } //b.effectiveDate = new DateTime(b.effectiveDate.Year, b.effectiveDate.Month, b.effectiveDate.Day, 14, 0, 0); if (branchId.SelectedItem != null) { b.branchName = branchId.SelectedItem.Text; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <loanSelfService> request = new PostRequest <loanSelfService>(); request.entity = b; request.entity.employeeId = _systemService.SessionHelper.GetEmployeeId(); // request.entity.employeeName = new EmployeeName() { fullName="" }; request.entity.date = DateTime.Now; //request.entity.ltName = ""; //request.entity.currencyRef = ""; request.entity.apStatus = "1"; PostResponse <loanSelfService> r = _selfServiceService.ChildAddOrUpdate <loanSelfService>(request); //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { Store1.Reload(); //b.recordId = r.recordId; ////Add this record to the store //this.Store1.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); recordId.Text = b.recordId; SetTabPanelEnable(true); currentCase.Text = b.recordId; RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); this.EditRecordWindow.Close(); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { //getting the id of the record PostRequest <loanSelfService> request = new PostRequest <loanSelfService>(); request.entity = b; request.entity.employeeId = _systemService.SessionHelper.GetEmployeeId(); PostResponse <loanSelfService> r = _selfServiceService.ChildAddOrUpdate <loanSelfService>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { Store1.Reload(); // ModelProxy record = this.Store1.GetById(id); // BasicInfoTab.UpdateRecord(record); // record.Set("currencyRef", b.currencyRef); // if (date.ReadOnly) // record.Set("date", null); // record.Set("employeeName", b.employeeName); //// record.Set("branchName", b.branchName); // record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, ex.Message).Show(); } }
public void OpenCell(string EmployeeId) { SystemDefaultRecordRequest req = new SystemDefaultRecordRequest(); req.Key = "dailySchedule"; RecordResponse <KeyValuePair <string, string> > SystemDefaultResponse = _systemService.ChildGetRecord <KeyValuePair <string, string> >(req); if (!SystemDefaultResponse.Success) { X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", SystemDefaultResponse.ErrorCode) != null ? GetGlobalResourceObject("Errors", SystemDefaultResponse.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + SystemDefaultResponse.LogId : SystemDefaultResponse.Summary).Show(); return; } pnlTools.Hidden = false; currentEmployee.Text = EmployeeId; string rep_params = ""; Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("2", dateFrom.SelectedDate.ToString("yyyyMMdd")); parameters.Add("3", dateFrom.SelectedDate.ToString("yyyyMMdd")); parameters.Add("1", EmployeeId); foreach (KeyValuePair <string, string> entry in parameters) { rep_params += entry.Key.ToString() + "|" + entry.Value + "^"; } if (rep_params.Length > 0) { if (rep_params[rep_params.Length - 1] == '^') { rep_params = rep_params.Remove(rep_params.Length - 1); } } ReportGenericRequest reqFS = new ReportGenericRequest(); reqFS.paramString = rep_params; //BranchScheduleRecordRequest reqFS = new BranchScheduleRecordRequest(); //reqFS.EmployeeId = Convert.ToInt32(EmployeeId); //reqFS.FromDayId = dateFrom.SelectedDate.ToString("yyyyMMdd"); //reqFS.ToDayId = dateFrom.SelectedDate.ToString("yyyyMMdd"); //reqFS.BranchId = 0; ListResponse <FlatSchedule> response = _timeAttendanceService.ChildGetAll <FlatSchedule>(reqFS); if (!response.Success) { X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("ErrorGettingSchedule")).Show(); return; } this.pnlSchedule.Html = string.Empty; string html = @"<div style = 'margin: 5px auto; width: 99%; height: 98%; overflow:auto;' > <table id = 'tbCalendar' cellpadding = '5' cellspacing = '0' >"; if (response.Items.Count == 0) { Load_Click(new object(), new DirectEventArgs(null)); } // GetBranchSchedule(out startAt, out closeAt); string startAt = response.Items.Count != 0 ? response.Items.Min(x => x.dtFrom.TimeOfDay).ToString() : "00:00"; string closeAt = response.Items.Count != 0 ? response.Items.Max(x => x.dtTo.TimeOfDay).ToString() : "00:00"; TimeSpan tsStart = TimeSpan.Parse(startAt); //timeFrom.MinTime = tsStart; //timeTo.MinTime = tsStart.Add(TimeSpan.FromMinutes(Convert.ToInt32(SystemDefaultResponse.result.Value))); timeFrom.SelectedTime = tsStart; TimeSpan tsClose = TimeSpan.Parse(closeAt); //timeTo.MaxTime = tsClose; //Filling The Times Slot List <TimeSlot> timesList = new List <TimeSlot>(); DateTime dtStart, dtEnd; dtStart = new DateTime(dateFrom.SelectedDate.Year, dateFrom.SelectedDate.Month, 1, tsStart.Hours, tsStart.Minutes, 0); dtEnd = new DateTime(dateFrom.SelectedDate.Year, dateFrom.SelectedDate.Month, 1, tsClose.Hours, tsClose.Minutes, 0); if (dtStart >= dtEnd) { dtEnd = dtEnd.AddDays(1); } int counter = 0; do { TimeSlot ts = new TimeSlot(); ts.ID = dtStart.ToString("HH:mm"); ts.Time = dtStart.ToString("HH:mm"); timesList.Add(ts); dtStart = dtStart.AddMinutes(Convert.ToInt32(SystemDefaultResponse.result.Value)); counter++; } while (dtStart <= dtEnd && counter != 3000); html = FillFirstRow(html, timesList); html = FillOtherRow(html, timesList, response.Items); html += @"</table></div>"; this.pnlSchedule.Html = html; List <string> listIds = new List <string>(); foreach (FlatSchedule fs in response.Items) { DateTime activeDate = fs.dtFrom; DateTime fsfromDate = fs.dtFrom; DateTime fsToDate = fs.dtTo; counter = 0; do { listIds.Add(EmployeeId + "_" + fsfromDate.ToString("HH:mm")); fsfromDate = fsfromDate.AddMinutes(Convert.ToInt32(SystemDefaultResponse.result.Value)); counter++; } while (fsToDate > fsfromDate && counter != 3000); } var d = response.Items.GroupBy(x => x.employeeId); List <string> totaldayId = new List <string>(); List <string> totaldaySum = new List <string>(); d.ToList().ForEach(x => { totaldayId.Add(x.ToList()[0].employeeId + "_Total"); totaldaySum.Add(timeConverter(x.ToList().Sum(y => Convert.ToInt32(y.duration)), true)); }); X.Call("ColorifySchedule", JSON.JavaScriptSerialize(listIds)); X.Call("filldaytotal", totaldayId, totaldaySum); }
private void BuildSchedule(List <FlatSchedule> items) { string dailyScheduleVariation; SystemDefaultRecordRequest req = new SystemDefaultRecordRequest(); req.Key = "dailySchedule"; RecordResponse <KeyValuePair <string, string> > SystemDefaultResponse = _systemService.ChildGetRecord <KeyValuePair <string, string> >(req); if (!SystemDefaultResponse.Success) { X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", SystemDefaultResponse.ErrorCode) != null ? GetGlobalResourceObject("Errors", SystemDefaultResponse.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + SystemDefaultResponse.LogId : SystemDefaultResponse.Summary).Show(); return; } if (string.IsNullOrEmpty(SystemDefaultResponse.result.Value)) { dailyScheduleVariation = "60"; } else { dailyScheduleVariation = SystemDefaultResponse.result.Value; } string html = @"<div style = 'margin: 5px auto; width: 99%; height: 98%; overflow:auto;' > <table id = 'tbCalendar' cellpadding = '5' cellspacing = '0' style='width:auto;'>"; //string startAt, closeAt = string.Empty; //GetBranchSchedule(out startAt, out closeAt); string startAt = items.Count != 0 ? items.Min(x => x.dtFrom.TimeOfDay).ToString() : "00:00"; string closeAt = items.Count != 0 ? items.Max(x => x.dtTo.TimeOfDay).ToString() : "00:00"; if (string.IsNullOrEmpty(startAt) || string.IsNullOrEmpty(closeAt)) { html += @"</table></div>"; this.pnlSchedule.Html = html; X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("ErrorBranchWorkingHours")).Show(); return; } TimeSpan tsStart = TimeSpan.Parse(startAt); //timeFrom.MinTime = tsStart; //timeTo.MinTime = tsStart.Add(TimeSpan.FromMinutes(30)); TimeSpan tsClose = TimeSpan.Parse(closeAt); //timeTo.MaxTime = tsClose; TimeSpan EmployeeTsStart, EmployeeTsEnd; //items.ForEach(x => //{ // string newFrom = ""; // string newTo = ""; // List<string> fromList = x.dtFrom.TimeOfDay.Split(':').ToList(); // if (fromList.Count==2) // { // newFrom = (Convert.ToInt32(fromList.First()) % 24).ToString(); // newFrom += ":" + fromList.ElementAt(1); // EmployeeTsStart = TimeSpan.Parse(newFrom); // } // else // EmployeeTsStart = TimeSpan.Parse(x.from); // List<string> ToList = x.to.Split(':').ToList(); // if (ToList.Count == 2) // { // newTo = (Convert.ToInt32(ToList.First()) % 24).ToString(); // newTo += ":" + ToList.ElementAt(1); // EmployeeTsEnd = TimeSpan.Parse(newTo); // } // else // EmployeeTsEnd = TimeSpan.Parse(x.to); // if (EmployeeTsStart < tsStart || EmployeeTsEnd > tsClose) // { // html += @"</table></div>"; // this.pnlSchedule.Html = html; // X.Call("DisableTools"); // X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", "ErrorEmployeeTimeOutside").ToString() + x.employeeName).Show(); // return; // } //}); //Filling The Times Slot List <TimeSlot> timesList = new List <TimeSlot>(); DateTime dtStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, tsStart.Hours, tsStart.Minutes, 0); DateTime dtEnd; if (tsStart > tsClose) { DateTime endDate = DateTime.Now; endDate = endDate.AddDays(1); dtEnd = new DateTime(endDate.Year, endDate.Month, endDate.Day, tsClose.Hours, tsClose.Minutes, 0); } else { dtEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, tsClose.Hours, tsClose.Minutes, 0); } if (dtEnd == dtStart) { dtEnd = dtEnd.AddDays(1).AddMinutes(-Convert.ToInt32(dailyScheduleVariation)); } int counter = 0; do { TimeSlot ts = new TimeSlot(); ts.ID = dtStart.ToString("HH:mm"); ts.Time = dtStart.ToString("HH:mm"); timesList.Add(ts); dtStart = dtStart.AddMinutes(Convert.ToInt32(dailyScheduleVariation)); counter++; } while (dtStart <= dtEnd && !string.IsNullOrEmpty(dailyScheduleVariation) && counter != 3000); //filling the Day slots //int totalDays = Convert.ToInt32(Math.Ceiling((dateTo.SelectedDate - dateFrom.SelectedDate).TotalDays)); html = FillFirstRow(html, timesList); html = FillOtherRow(html, timesList, items); //Preparing the ids to get colorified List <string> listIds = new List <string>(); List <string> listDn = new List <string>(); List <string> listDS = new List <string>(); Dictionary <string, int> dic = new Dictionary <string, int>(); if (items.Count != 0 && items != null) { DateTime activeDate = items[0].dtFrom; DateTime fsfromDate, fsToDate; foreach (FlatSchedule fs in items) { DateTime from = fs.dtFrom; DateTime to = fs.dtTo; counter = 0; while (to > from && counter != 3000) { if (from.ToString("HH:mm") == "00:00") { listIds.Add(fs.employeeId + "_" + from.AddDays(-1).ToString("HH:mm")); listDn.Add(fs.employeeId + "_" + fs.departmentId + "_" + from.AddDays(-1).ToString("HH:mm")); listDS.Add(fs.departmentId.ToString()); from = from.AddMinutes(Convert.ToInt32(SystemDefaultResponse.result.Value)); counter++; continue; } listIds.Add(fs.employeeId + "_" + from.ToString("HH:mm")); listDn.Add(fs.employeeId + "_" + fs.departmentId + "_" + from.ToString("HH:mm")); listDS.Add(fs.departmentId.ToString()); from = from.AddMinutes(Convert.ToInt32(SystemDefaultResponse.result.Value)); counter++; } } listDn = listDn.Distinct().ToList(); listDS = listDS.Distinct().ToList(); //listDS.ForEach(departmentID => dic.Add(departmentID+, listDn.Where(stringToCheck => stringToCheck.Contains(departmentID)).Count())); fsfromDate = new DateTime(activeDate.Year, activeDate.Month, activeDate.Day, Convert.ToInt32(startAt.Split(':')[0]), Convert.ToInt32(startAt.Split(':')[1]), 0); fsToDate = new DateTime(activeDate.Year, activeDate.Month, activeDate.Day, Convert.ToInt32(closeAt.Split(':')[0]), Convert.ToInt32(closeAt.Split(':')[1]), 0); if (fsfromDate >= fsToDate) { fsToDate = fsToDate.AddDays(1); } counter = 0; do { listDS.ForEach(departmentID => { if (!dic.ContainsKey(departmentID + "-" + fsfromDate.ToString("HH:mm"))) { dic.Add(departmentID + "-" + fsfromDate.ToString("HH:mm"), listDn.Where(stringToCheck => stringToCheck.Contains(departmentID + "_" + fsfromDate.ToString("HH:mm"))).Count()); } }); fsfromDate = fsfromDate.AddMinutes(Convert.ToInt32(SystemDefaultResponse.result.Value)); counter++; } while (fsToDate >= fsfromDate && counter != 3000); } //var department= items.GroupBy(x => x.departmentId); //foreach (var de in department) //{ // fsfromDate = new DateTime(activeDate.Year, activeDate.Month, activeDate.Day, Convert.ToInt32(startAt.Split(':')[0]), Convert.ToInt32(startAt.Split(':')[1]), 0); // fsToDate = new DateTime(activeDate.Year, activeDate.Month, activeDate.Day, Convert.ToInt32(closeAt.Split(':')[0]), Convert.ToInt32(closeAt.Split(':')[1]), 0); // List<FlatSchedule> employee = de.ToList(); // do // { // listDn.Add(employee[0].departmentId + "-" + fsfromDate.ToString("HH:mm")); // int sum = 0; // employee.ForEach(x => // { // int employeeFromHour= Convert.ToInt32(x.from.Split(':')[0]); // int employeeToHour = Convert.ToInt32(x.to.Split(':')[0]); // int employeeFromMintues= Convert.ToInt32(x.from.Split(':')[1]); // int employeeTMintues = Convert.ToInt32(x.to.Split(':')[1]); // double employeeFromTotal = employeeFromHour * 100 + employeeFromMintues; // double employeeToTotal = employeeToHour * 100 + employeeTMintues; // double FsTotal = fsfromDate.Hour * 100 + fsfromDate.Minute; // if (FsTotal >= employeeFromTotal && FsTotal <= employeeToTotal) // sum++; // } // ); // listDS.Add(sum); // fsfromDate = fsfromDate.AddMinutes(30); // } while (fsToDate >= fsfromDate); //} var d = items.GroupBy(x => x.employeeId); List <string> totaldayId = new List <string>(); List <string> totaldaySum = new List <string>(); d.ToList().ForEach(x => { totaldayId.Add(x.ToList()[0].employeeId + "_Total"); totaldaySum.Add(timeConverter(x.ToList().Sum(y => Convert.ToInt32(y.duration)), true)); }); //List<string> employeeList = new List<string>(); //items.ForEach(x => employeeList.Add(x.employeeId.ToString())); html = FillSummaryRow(html, timesList, dic); html += @"</table></div>"; this.pnlSchedule.Html = html; X.Call("ColorifySchedule", JSON.JavaScriptSerialize(listIds)); X.Call("filldaytotal", totaldayId, totaldaySum); //X.Call("filldepartmentTotal", listDn, listDS); X.Call("filldepartmentTotal", dic); X.Call("employeeClick", items); //X.Call("Init"); //X.Call("DisableTools"); X.Call("FixHeader"); }