Пример #1
0
        /// <summary>
        /// Insert or Update scheduler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InsertOrUpdate(object sender, DirectEventArgs e)
        {
            // init model
            var model = new SchedulerModel(null);

            // check id
            if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0)
            {
                var result = SchedulerController.GetById(Convert.ToInt32(hdfId.Text));
                if (result != null)
                {
                    model = result;
                }
            }
            // set new props for model
            model.Name         = txtName.Text;
            model.Description  = txtDescription.Text;
            model.Arguments    = txtArguments.Text;
            model.IntervalTime = !string.IsNullOrEmpty(txtIntervalTime.Text)
                ? Convert.ToInt32(txtIntervalTime.Text) : 0;
            model.ExpiredAfter = !string.IsNullOrEmpty(txtExpiredAfter.Text)
                ? Convert.ToInt32(txtExpiredAfter.Text) : 0;
            model.Enabled         = chkEnable.Checked;
            model.SchedulerTypeId = Convert.ToInt32(hdfSchedulerType.Text);
            model.RepeatType      = (SchedulerRepeatType)Enum.Parse(typeof(SchedulerRepeatType), hdfSchedulerRepeatType.Text);
            model.Scope           = (SchedulerScope)Enum.Parse(typeof(SchedulerScope), hdfSchedulerScope.Text);
            model.Status          = (SchedulerStatus)Enum.Parse(typeof(SchedulerStatus), hdfSchedulerStatus.Text);
            model.NextRunTime     = DateTime.TryParseExact(txtNextRuntime.Text, "yyyy/MM/dd HH:mm",
                                                           CultureInfo.InvariantCulture, DateTimeStyles.None, out var nextRunTime)
                ? nextRunTime
                : DateTime.Now;
            // check model id
            if (model.Id > 0)
            {
                // update
                SchedulerController.Update(model);
            }
            else
            {
                // insert
                SchedulerController.Create(model);
            }
            // hide window
            wdSetting.Hide();
            // reload data
            gpScheduler.Reload();
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveDynamicColumnClick(object sender, DirectEventArgs e)
        {
            try
            {
                //Update status schedule create new timeSheet
                var scheduler = SchedulerController.GetByName(SchedulerName);
                if (scheduler != null)
                {
                    scheduler.Status = SchedulerStatus.Ready;
                    var symbol = string.Empty;
                    foreach (var itemRow in chkSelectionModelSymbol.SelectedRows)
                    {
                        symbol += "," + itemRow.RecordID;
                    }

                    if (!string.IsNullOrEmpty(symbol))
                    {
                        scheduler.Arguments = "-column {0} -symbol {1} -payrollId {2}".FormatWith(hdfColumnCode.Text, symbol.TrimStart(','), Convert.ToInt32(hdfPayrollId.Text));

                        SchedulerController.Update(scheduler);
                    }
                }

                //close window
                wdDynamicColumn.Hide();
                hdfColumnCode.Reset();
                cbxColumnCode.Reset();
                hdfPayrollId.Reset();
                cboPayroll.Reset();
                chkSelectionModelSymbol.ClearSelections();
            }
            catch (Exception exception)
            {
                Dialog.Alert(exception.Message);
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Delete_Click(object sender, DirectEventArgs e)
        {
            if (!string.IsNullOrEmpty(hdfChoseMonth.Text) && !string.IsNullOrEmpty(hdfChoseYear.Text))
            {
                if (!string.IsNullOrEmpty(hdfGroupWorkShiftId.Text))
                {
                    var groupWorkShiftId = Convert.ToInt32(hdfGroupWorkShiftId.Text);

                    //get all detail workShift
                    var order        = " [StartDate] ASC ";
                    var lstWorkShift =
                        TimeSheetWorkShiftController.GetAll(null, false, groupWorkShiftId, null, null, null, null, Convert.ToInt32(hdfChoseMonth.Text), Convert.ToInt32(hdfChoseYear.Text), order, null);

                    var listWorkShiftIds = lstWorkShift.Select(ws => ws.Id).ToList();
                    if (listWorkShiftIds.Count > 0)
                    {
                        TimeSheetEventController.DeleteByCondition(listWorkShiftIds, null, null, null, TimeSheetAdjustmentType.Default);
                    }

                    //Update status schedule create new timeSheet
                    var scheduler = SchedulerController.GetByName(Constant.SchedulerTimeSheet);
                    if (scheduler != null)
                    {
                        scheduler.Status    = SchedulerStatus.Ready;
                        scheduler.Arguments = "-m {0} -y {1} -groupWorkShiftId {2}".FormatWith(hdfChoseMonth.Text, hdfChoseYear.Text, hdfGroupWorkShiftId.Text);
                        //update
                        SchedulerController.Update(scheduler);
                    }
                }

                hdfGroupWorkShiftId.Reset();
                wdWindow.Hide();
                //reload
                gpScheduler.Reload();
            }
        }