Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        private void LongAction(object state)
        {
            object[]      array    = state as object[];
            SessionHelper h        = (SessionHelper)array[0];
            int           activity = Convert.ToInt32(array[1]);



            _emp = new EmployeeService(new EmployeeRepository(), h);
            LoanTrackingService    _lt = new LoanTrackingService(new LoanTrackingRepository(), h);
            LeaveManagementService _lm = new LeaveManagementService(h, new LeaveManagementRepository());
            TimeAttendanceService  _ta = new TimeAttendanceService(h, new TimeAttendanceRepository());
            AssetManagementService _am = new AssetManagementService(new AssetManagementRepository(), h);

            _system = new SystemService(new SystemRepository(), h);
            _help   = new HelpFunctionService(new HelpFunctionRepository(), h);


            try
            {
                SyncActivity SA = new SyncActivity();
                SA.startDate = startingDate.SelectedDate;
                SA.endDate   = endingDate.SelectedDate;

                PostRequest <SyncActivity> req = new PostRequest <SyncActivity>();
                req.entity = SA;
                PostResponse <SyncActivity> resp = new PostResponse <SyncActivity>();

                switch (activity)
                {
                case 1:
                    resp = _ta.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 2:
                    resp = _lm.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 3:
                    resp = _lm.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 4:
                    resp = _lt.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 5:
                    resp = _emp.ChildAddOrUpdate <SyncActivity>(req);
                    break;

                case 6:
                    resp = _am.ChildAddOrUpdate <SyncActivity>(req);
                    break;
                }


                if (!resp.Success)
                {
                    HttpRuntime.Cache.Insert("ErrorMsgSync", resp.Error);
                    HttpRuntime.Cache.Insert("LogIdMsgSync", resp.LogId);
                }



                HttpRuntime.Cache.Insert("syncAC_RecordId", resp.recordId);
            }

            catch (Exception exp)
            {
                HttpRuntime.Cache.Insert("ExceptionMsgSync", exp.Message);
            }
        }
Ejemplo n.º 4
0
        private void LongAction(object state)
        {
            object[]      array = state as object[];
            SessionHelper h     = (SessionHelper)array[0];



            //if (HttpRuntime.Cache["TotalRecords"] == null)
            //    HttpRuntime.Cache.Insert("TotalRecords",0);
            //if (HttpRuntime.Cache["LongActionProgress"] == null)
            //    HttpRuntime.Cache.Insert("LongActionProgress", 0);



            _time = new TimeAttendanceService(h, new TimeAttendanceRepository());


            try
            {
                GenerateAttendanceDay GD = new GenerateAttendanceDay();
                PostRequest <GenerateAttendanceDay> request = new PostRequest <GenerateAttendanceDay>();
                GD.employeeId = Convert.ToInt32(employeeFilter.Value);
                //GD.fromDayId = startingDate.SelectedDate.ToString("yyyyMMdd");
                //GD.toDayId = endingDate.SelectedDate.ToString("yyyyMMdd");
                //if (string.IsNullOrEmpty(branchId.Value.ToString()))
                //    GD.branchId = 0;
                //else
                //    GD.branchId = Convert.ToInt32(branchId.Value);

                request.entity = GD;


                PostResponse <GenerateAttendanceDay> resp = _time.ChildAddOrUpdate <GenerateAttendanceDay>(request);
                if (!resp.Success)
                { //Show an error saving...
                    if (resp.ErrorCode == "Error_1")
                    {
                        HttpRuntime.Cache.Insert("ErrorMsgGenAD", Resources.Errors.Error_1);
                        HttpRuntime.Cache.Insert("ErrorLogIdGenAD", " ");
                    }
                    else
                    {
                        HttpRuntime.Cache.Insert("ErrorMsgGenAD", resp.Error);
                        HttpRuntime.Cache.Insert("ErrorLogIdGenAD", resp.LogId);
                    }
                    //      HttpRuntime.Cache.Insert("ErrorErrorCodeGenAD", resp.ErrorCode);
                }
                else
                {
                    HttpRuntime.Cache.Insert("genFS_RecordId", resp.recordId);
                }



                //if (HttpRuntime.Cache["TotalRecords"] != null)
                //    HttpRuntime.Cache.Remove("TotalRecords");
                //HttpRuntime.Cache["TotalRecords"] = emps.count;
            }

            catch (Exception exp)
            {
                HttpRuntime.Cache.Insert("ErrorMsgGenAD", exp.Message);
            }
        }