Esempio n. 1
0
 public override void Excute(string args)
 {
     // create history
     _schedulerHistory = SchedulerHistoryServices.Create(Id, Name.ToUpper(), false, string.Empty, string.Empty, DateTime.Now, DateTime.MaxValue);
     // start process
     if (_schedulerHistory == null)
     {
         return;
     }
     // log start
     SchedulerLogServices.Create(_schedulerHistory.Id, "START");
     try
     {
         // progress
         DoTaskSample("TaskSample InProgress");
     }
     catch (Exception ex)
     {
         // log exception
         SchedulerLogServices.Create(_schedulerHistory.Id, "EXCEPTION: {0}".FormatWith(ex.ToString()));
     }
     finally
     {
         // log end
         SchedulerLogServices.Create(_schedulerHistory.Id, "END");
     }
 }
Esempio n. 2
0
        public override void Excute(string args)
        {
            // create history
            var schedulerHistory = SchedulerHistoryServices.Create(Id, Name.ToUpper(), false, string.Empty, string.Empty, DateTime.Now, DateTime.MaxValue);

            // start process
            if (schedulerHistory == null)
            {
                return;
            }

            // log start
            SchedulerLogServices.Create(schedulerHistory.Id, "START");

            // Chạy 0:05 ngày 1 hàng tháng
            var month = DateTime.Now.Month;
            var year  = DateTime.Now.Year;

            //Tao ngay phep mac dinh cho tat ca nhan vien
            var condition   = @"WorkStatusId = (select top 1 Id from cat_WorkStatus where Name like N'{0}')".FormatWith(ConstStatusWorking);
            var listRecords = hr_RecordServices.GetAll(condition);

            foreach (var item in listRecords)
            {
                //tạo mới bảng phép
                var leave = new hr_AnnualLeaveConfigure()
                {
                    RecordId             = item.Id,
                    AnnualLeaveDay       = ConstLeaveDay,
                    CreatedDate          = DateTime.Now,
                    Year                 = DateTime.Now.Year,
                    AllowUseFirstYear    = false,
                    AllowUsePreviousYear = false,
                    ExpiredDate          = null,
                };
                hr_AnnualLeaveConfigureServices.Create(leave);
            }
            SchedulerLogServices.Create(schedulerHistory.Id, "END");
        }
Esempio n. 3
0
 private void Insert()
 {
     try
     {
         var util             = new Util();
         var schedulerHistory = new SchedulerHistory();
         int schedulerId;
         if (int.TryParse(cbxScheduler.SelectedItem.Value, out schedulerId))
         {
             schedulerHistory.SchedulerId = schedulerId;
         }
         if (!string.IsNullOrEmpty(txtDescription.Text))
         {
             schedulerHistory.Description = txtDescription.Text.Trim();
         }
         schedulerHistory.HasError = chkHasError.Checked;
         if (!string.IsNullOrEmpty(txtErrorMessage.Text))
         {
             schedulerHistory.ErrorMessage = txtErrorMessage.Text.Trim();
         }
         if (!string.IsNullOrEmpty(txtErrorDescription.Text))
         {
             schedulerHistory.ErrorDescription = txtErrorDescription.Text.Trim();
         }
         if (!util.IsDateNull(txtStartTime.SelectedDate))
         {
             schedulerHistory.StartTime = txtStartTime.SelectedDate;
         }
         if (!util.IsDateNull(txtEndTime.SelectedDate))
         {
             schedulerHistory.EndTime = txtEndTime.SelectedDate;
         }
         SchedulerHistoryServices.Create(schedulerHistory);
     }
     catch (Exception ex)
     {
         Dialog.Alert("Có lỗi xảy ra trong quá trình thêm mới: {0}".FormatWith(ex.Message));
     }
 }
Esempio n. 4
0
        public override void Excute(string args)
        {
            // create history
            var schedulerHistory = SchedulerHistoryServices.Create(Id, Name.ToUpper(), false, string.Empty, string.Empty, DateTime.Now, DateTime.MaxValue);

            // start process
            if (schedulerHistory == null)
            {
                return;
            }
            // log start
            SchedulerLogServices.Create(schedulerHistory.Id, "START");

            // Chạy 0:05 ngày 1 hàng tháng
            var month            = !string.IsNullOrEmpty(GetArgValue("-m")) ? Convert.ToInt32(GetArgValue("-m")) : DateTime.Now.Month;
            var year             = !string.IsNullOrEmpty(GetArgValue("-y")) ? Convert.ToInt32(GetArgValue("-y")) : DateTime.Now.Year;
            var groupWorkShiftId = !string.IsNullOrEmpty(GetArgValue("-groupWorkShiftId")) ? Convert.ToInt32(GetArgValue("-groupWorkShiftId")) : 0;

            //get all detail workShift
            var order        = " [StartDate] ASC ";
            var lstWorkShift =
                TimeSheetWorkShiftController.GetAll(null, false, groupWorkShiftId, null, null, null, null, month, year, order, null);
            var listWorkShiftIds = lstWorkShift.Select(ws => ws.Id).ToList();

            if (listWorkShiftIds.Count > 0)
            {
                TimeSheetEventController.DeleteByCondition(listWorkShiftIds, null, null, null, TimeSheetAdjustmentType.Default);
            }

            //get all employee in group
            var listEmployeeGroupWorkShift =
                TimeSheetEmployeeGroupWorkShiftController.GetAll(null, null, null, groupWorkShiftId, null, null);
            //list recordId
            var listRecordIds = listEmployeeGroupWorkShift.Select(gws => gws.RecordId).Distinct().ToList();

            //get symbolId undefined
            GetSymbolUndefined();

            //get symbolId unleave
            GetSymbolUnLeave();

            //create new timeSheet for employee
            foreach (var recordId in listRecordIds)
            {
                //get timeSheetCode by recordId
                var timeSheetCodeCondition = " [RecordId] = {0} ".FormatWith(recordId) +
                                             " AND [IsActive] = 1 ";
                var listTimeSheetCodes = hr_TimeSheetCodeServices.GetAll(timeSheetCodeCondition);
                if (listTimeSheetCodes.Count > 0)
                {
                    //ma cham cong
                    var timeSheetCodes   = string.Join(",", listTimeSheetCodes.Select(t => t.Code).ToList());
                    var arrTimeSheetCode = FormatList(timeSheetCodes);

                    //serial may cham cong
                    var machineIds       = listTimeSheetCodes.Select(tc => tc.MachineId).ToList();
                    var machineCondition = Constant.ConditionDefault;
                    machineCondition += " AND [Id] IN ({0})".FormatWith(string.Join(",", machineIds));
                    var machines      = hr_TimeSheetMachineService.GetAll(machineCondition);
                    var serialNumbers =
                        string.Join(",", machines.Select(t => t.SerialNumber).ToList());
                    var arrSerialNumber = FormatList(serialNumbers);

                    foreach (var workShiftModel in lstWorkShift)
                    {
                        //calculate timeSheet
                        CalculateTimeSheet(workShiftModel, recordId, string.Join(",", arrTimeSheetCode), string.Join(",", arrSerialNumber));
                    }
                }
            }

            SchedulerLogServices.Create(schedulerHistory.Id, "END");
        }
Esempio n. 5
0
        public override void Excute(string args)
        {
            // create history
            var schedulerHistory = SchedulerHistoryServices.Create(Id, Name.ToUpper(), false, string.Empty, string.Empty, DateTime.Now, DateTime.MaxValue);

            // start process
            if (schedulerHistory == null)
            {
                return;
            }
            // log start
            SchedulerLogServices.Create(schedulerHistory.Id, "START");

            //get param
            var payrollId  = !string.IsNullOrEmpty(GetArgValue("-payrollId")) ? Convert.ToInt32(GetArgValue("-payrollId")) : 0;
            var columnCode = GetArgValue("-column");
            var symbol     = GetArgValue("-symbol");
            var symbolArr  = symbol.Split(',');

            if (string.IsNullOrEmpty(columnCode))
            {
                return;
            }

            var boardList = sal_PayrollServices.GetById(payrollId);

            //Lay danh sach nhan vien tu bang luong
            var conditionPayroll = " [SalaryBoardId] = {0} ".FormatWith(payrollId);
            var salaryInfos      = hr_SalaryBoardInfoServices.GetAll(conditionPayroll);

            foreach (var salaryInfo in salaryInfos)
            {
                //Kiem tra column dong da duoc tao chua, neu chua co thi tao moi khong thi cap nhat lai
                var conditionBoardDynamic = Constant.ConditionDefault;
                conditionBoardDynamic += " AND [RecordId] = {0} ".FormatWith(salaryInfo.RecordId) +
                                         " AND [ColumnCode] = '{0}' ".FormatWith(columnCode);

                var dynamic = hr_SalaryBoardDynamicColumnService.GetByCondition(conditionBoardDynamic);
                if (dynamic != null)
                {
                    // get value
                    GetValueDynamicColumn(boardList, salaryInfo, symbolArr, columnCode, dynamic);
                    //update
                    hr_SalaryBoardDynamicColumnService.Update(dynamic);
                }
                else
                {
                    //create
                    var colDynamic = new hr_SalaryBoardDynamicColumn()
                    {
                        RecordId      = salaryInfo.RecordId,
                        SalaryBoardId = payrollId,
                        ColumnCode    = columnCode,
                        CreatedDate   = DateTime.Now
                    };
                    //set value
                    GetValueDynamicColumn(boardList, salaryInfo, symbolArr, columnCode, colDynamic);
                    //create
                    hr_SalaryBoardDynamicColumnService.Create(colDynamic);
                }
            }

            SchedulerLogServices.Create(schedulerHistory.Id, "END");
        }