protected void ProcessData(object sender, DirectEventArgs e) { try { OvertimeImportingService service = null; service = new OvertimeImportingService(new CSVImporter(CurrentPath.Text)); List <OvertimeSetting> shifts = service.ImportUnvalidated(CurrentPath.Text); File.Delete(CurrentPath.Text); DictionarySessionStorage storage = new DictionarySessionStorage(); storage.Save("AccountId", _systemService.SessionHelper.Get("AccountId")); storage.Save("UserId", _systemService.SessionHelper.Get("UserId")); storage.Save("key", _systemService.SessionHelper.Get("Key")); SessionHelper h = new SessionHelper(storage, new APIKeyBasedTokenGenerator()); EmployeeService emp = new EmployeeService(new EmployeeRepository(), h); SystemService _system = new SystemService(new SystemRepository(), h); TimeAttendanceService time = new TimeAttendanceService(h, new TimeAttendanceRepository()); OvertimeBatchRunner runner = new OvertimeBatchRunner(_system, time, emp) { Items = shifts, OutputPath = MapPath("~/Imports/" + _systemService.SessionHelper.Get("AccountId") + "/") }; runner.Process(); this.ResourceManager1.AddScript("{0}.startTask('longactionprogress');", this.TaskManager1.ClientID); } catch { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation).Show(); this.ResourceManager1.AddScript("{0}.stopTask('longactionprogress');", this.TaskManager1.ClientID); } }
protected void ProcessData(object sender, DirectEventArgs e) { try { JobInfoImportingService service = null; service = new JobInfoImportingService(new CSVImporter(CurrentPath.Text)); List <JobInfo> shifts = service.ImportUnvalidated(CurrentPath.Text); File.Delete(CurrentPath.Text); DictionarySessionStorage storage = new DictionarySessionStorage(); storage.Save("AccountId", _systemService.SessionHelper.Get("AccountId")); storage.Save("UserId", _systemService.SessionHelper.Get("UserId")); storage.Save("key", _systemService.SessionHelper.Get("Key")); SessionHelper h = new SessionHelper(storage, new APIKeyBasedTokenGenerator()); IEmployeeService emp = new EmployeeService(new EmployeeRepository(), h); SystemService _system = new SystemService(new SystemRepository(), h); ICompanyStructureService cs = new CompanyStructureService(new CompanyStructureRepository(), h); JobInfoBatchRunner runner = new JobInfoBatchRunner(storage, _system, cs, emp) { Items = shifts, OutputPath = MapPath("~/Imports/" + _systemService.SessionHelper.Get("AccountId") + "/") }; runner.Process(); this.ResourceManager1.AddScript("{0}.startTask('longactionprogress');", this.TaskManager1.ClientID); } catch (Exception exp) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation + " " + Resources.Common.LineNO + " " + exp.Source).Show(); this.ResourceManager1.AddScript("{0}.stopTask('longactionprogress');", this.TaskManager1.ClientID); Viewport1.ActiveIndex = 0; } }
//{ // EmployeeListRequest req = new EmployeeListRequest(); // req.DepartmentId = "0"; // req.BranchId = "0"; // req.IncludeIsInactive = 2; // req.SortBy = GetNameFormat(); // req.StartAt = "0"; // req.Size = "20"; // req.Filter = query; // ListResponse<Employee> response = _employeeService.GetAll<Employee>(req); // return response.Items; //} //private string GetNameFormat() //{ // return _systemService.SessionHelper.Get("nameFormat").ToString(); //} protected void StartLongAction(object sender, DirectEventArgs e) { this.Session["LongActionProgressSync"] = 0; DictionarySessionStorage storage = new DictionarySessionStorage(); storage.Save("AccountId", _systemService.SessionHelper.Get("AccountId")); storage.Save("UserId", _systemService.SessionHelper.Get("UserId")); storage.Save("key", _systemService.SessionHelper.Get("Key")); h = new SessionHelper(storage, new APIKeyBasedTokenGenerator()); //HttpRuntime.Cache.Insert("TotalRecords", 0); //HttpRuntime.Cache.Insert("LongActionProgress", 0); //HttpRuntime.Cache.Insert("finished", "0"); HttpRuntime.Cache.Remove("isThreadSafe"); ThreadPool.QueueUserWorkItem(LongAction, new object[] { h, activityId.SelectedItem.Value }); this.ResourceManager1.AddScript("{0}.startTask('longactionprogress');", TaskManager1.ClientID); }
protected void ProcessData(object sender, DirectEventArgs e) { try { PayCodeImportingService service = null; service = new PayCodeImportingService(new CSVImporter(CurrentPath.Text)); List <PayCode> shifts = service.ImportUnvalidated(CurrentPath.Text); File.Delete(CurrentPath.Text); DictionarySessionStorage storage = new DictionarySessionStorage(); storage.Save("AccountId", _systemService.SessionHelper.Get("AccountId")); storage.Save("UserId", _systemService.SessionHelper.Get("UserId")); storage.Save("key", _systemService.SessionHelper.Get("Key")); SessionHelper h = new SessionHelper(storage, new APIKeyBasedTokenGenerator()); IPayrollService PS = new PayrollService(new PayrollRepository(), h); ICompanyStructureService _timeAtt = new CompanyStructureService(new CompanyStructureRepository(), h); SystemService _system = new SystemService(new SystemRepository(), h); PayCodeBatchRunner runner = new PayCodeBatchRunner(storage, _system, _timeAtt, PS) { Items = shifts, OutputPath = MapPath("~/Imports/" + _systemService.SessionHelper.Get("AccountId") + "/") }; runner.Process(); this.ResourceManager1.AddScript("{0}.startTask('longactionprogress');", this.TaskManager1.ClientID); } catch (Exception exp) { string[] errorDetails = exp.Source.Split(';'); if (errorDetails.Length == 3) { X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation + "<br />" + Resources.Common.LineNO + errorDetails[2] + "<br />" + GetGlobalResourceObject("Common", "FieldDetails") + ":" + errorDetails[0] + " " + errorDetails[1] + "<br />" + GetGlobalResourceObject("Common", "ExceptionMessage") + exp.Message).Show(); } else { X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation + "<br />" + Resources.Common.LineNO + errorDetails[1] + "<br />" + GetGlobalResourceObject("Common", "FieldDetails") + ":" + errorDetails[0] + "<br />" + GetGlobalResourceObject("Common", "ExceptionMessage") + exp.Message).Show(); } //X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation + "<br /> " + Resources.Common.LineNO + exp.HelpLink + "<br />" + GetGlobalResourceObject("Common", "FieldDetails") + ":" + exp.Source + " " + exp.Message).Show(); this.ResourceManager1.AddScript("{0}.stopTask('longactionprogress');", this.TaskManager1.ClientID); Viewport1.ActiveIndex = 0; } }
protected void StartLongAction(object sender, DirectEventArgs e) { //this.Session["LongActionProgressGenAD"] = 0; DictionarySessionStorage storage = new DictionarySessionStorage(); storage.Save("AccountId", _systemService.SessionHelper.Get("AccountId")); storage.Save("UserId", _systemService.SessionHelper.Get("UserId")); storage.Save("key", _systemService.SessionHelper.Get("Key")); storage.Save("LanguageId", _systemService.SessionHelper.Get("Language").ToString() == "en" ? "1" : "2"); SessionHelper h = new SessionHelper(storage, new APIKeyBasedTokenGenerator()); //HttpRuntime.Cache.Insert("TotalRecords", 0); //HttpRuntime.Cache.Insert("LongActionProgress", 0); //HttpRuntime.Cache.Insert("finished", "0"); string tamplate = templateId.SelectedItem.Value; ThreadPool.QueueUserWorkItem(MailEm, new object[] { h, tamplate, vals.Text }); this.ResourceManager1.AddScript("{0}.startTask('longactionprogress');", TaskManager1.ClientID); }
protected void ProcessData(object sender, DirectEventArgs e) { try { PunchesImportingService service = null; service = new PunchesImportingService(new CSVImporter(CurrentPath.Text)); List <Check> shifts = service.ImportUnvalidated(CurrentPath.Text); //shifts = shifts.Distinct() shifts.ForEach(x => { TimeSpan ts = new TimeSpan(x.clockStamp.Hour, x.clockStamp.Minute, 0); x.clockStamp = x.clockStamp.Date + ts; }); IEnumerable <Check> noduplicates = shifts.Distinct(new CheckComparer()); shifts = noduplicates.ToList(); shifts = shifts.OrderBy(x => x.employeeRef).ThenBy(c => c.clockStamp).ToList(); File.Delete(CurrentPath.Text); DictionarySessionStorage storage = new DictionarySessionStorage(); storage.Save("AccountId", _systemService.SessionHelper.Get("AccountId")); storage.Save("UserId", _systemService.SessionHelper.Get("UserId")); storage.Save("key", _systemService.SessionHelper.Get("Key")); storage.Save("LanguageId", _systemService.SessionHelper.Get("Language").ToString() == "en" ? "1" : "2"); SessionHelper h = new SessionHelper(storage, new APIKeyBasedTokenGenerator()); EmployeeService emp = new EmployeeService(new EmployeeRepository(), h); ITimeAttendanceService _timeAtt = new TimeAttendanceService(h, new TimeAttendanceRepository()); SystemService _system = new SystemService(new SystemRepository(), h); //Dictionary<string, string> arabicErrors = new Dictionary<string, string>(); //if (_systemService.SessionHelper.CheckIfArabicSession()) //{ // System.Resources.ResourceManager MyResourceClass = new System.Resources.ResourceManager(typeof(Resources.Errors /* Reference to your resources class -- may be named differently in your case */)); // ResourceSet resourceSet = Resources.Errors.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true); // foreach (DictionaryEntry entry in resourceSet) // { // arabicErrors[entry.Key.ToString()] = entry.Value.ToString(); // } //} PunchesBatchRunner runner = new PunchesBatchRunner(storage, emp, _system, _timeAtt, GetGlobalResourceObject("Errors", "Error_1").ToString()) { Items = shifts, OutputPath = MapPath("~/Imports/" + _systemService.SessionHelper.Get("AccountId") + "/") }; runner.Process(); this.ResourceManager1.AddScript("{0}.startTask('longactionprogress');", this.TaskManager1.ClientID); } catch (Exception exp) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Viewport1.ActiveIndex = 0; List <string> errorDetails = exp.Source.Split(';').ToList(); if (errorDetails.Count == 5) { X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation + "<br />" + Resources.Common.LineNO + errorDetails[errorDetails.Count - 2] + "<br />" + GetGlobalResourceObject("Common", "FieldDetails") + ":" + errorDetails[0] + " " + errorDetails[1] + "<br />" + GetGlobalResourceObject("Common", "ExceptionMessage") + errorDetails[errorDetails.Count - 1]).Show(); } else { X.MessageBox.Alert(Resources.Common.Error, exp.Message).Show(); } //X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation + "<br /> " + Resources.Common.LineNO + exp.HelpLink + "<br />" + GetGlobalResourceObject("Common", "FieldDetails") + ":" + exp.Source + " " + exp.Message).Show(); this.ResourceManager1.AddScript("{0}.stopTask('longactionprogress');", this.TaskManager1.ClientID); } }