protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateScheduleRequest request;

            try
            {
                request = new UpdateScheduleRequest
                {
                    WorkspaceId           = WorkspaceId,
                    ApplicationKey        = ApplicationKey,
                    ScheduleKey           = ScheduleKey,
                    UpdateScheduleDetails = UpdateScheduleDetails,
                    IfMatch      = IfMatch,
                    OpcRequestId = OpcRequestId
                };

                response = client.UpdateSchedule(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Schedule);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Example #2
0
        private async Task ShouldUpdateAndRetrieveMonthlyPayoutSchedules()
        {
            var scheduleRequest = new UpdateScheduleRequest
            {
                Enabled    = true,
                Threshold  = 1000,
                Recurrence = new ScheduleFrequencyMonthlyRequest {
                    ByMonthDay = new[] { 3, 5 }
                }
            };

            var emptyResponse = await GetPayoutSchedulesCheckoutApi().AccountsClient()
                                .UpdatePayoutSchedule("ent_sdioy6bajpzxyl3utftdp7legq", Currency.USD, scheduleRequest);

            emptyResponse.ShouldNotBeNull();
            emptyResponse.HttpStatusCode.ShouldNotBeNull();
            emptyResponse.ResponseHeaders.ShouldNotBeNull();

            var response = await GetPayoutSchedulesCheckoutApi().AccountsClient()
                           .RetrievePayoutSchedule("ent_sdioy6bajpzxyl3utftdp7legq");

            response.ShouldNotBeNull();
            response.Currency.ShouldNotBeEmpty();
            CurrencySchedule currencySchedule = response.Currency[Currency.USD];

            currencySchedule.ShouldNotBeNull();
            currencySchedule.Enabled.ShouldNotBeNull();
            currencySchedule.Threshold.ShouldNotBeNull();
            currencySchedule.Recurrence.ShouldBeOfType(typeof(ScheduleFrequencyMonthlyResponse));
            ((ScheduleFrequencyMonthlyResponse)currencySchedule.Recurrence).ByMonthDay.Count.ShouldBe(2);
        }
Example #3
0
        public async Task <IActionResult> Update([FromBody] UpdateScheduleRequest request)
        {
            var command = new UpdateScheduleCommand(request.ScheduleId, request.Day, request.Hour, request.CustomerId, request.ServiceId);
            var result  = await updateScheduleService.Process(command);

            return(Ok(new ApiReturnItem <ScheduleResult>
            {
                Item = result,
                Success = true
            }));
        }
Example #4
0
 public async Task <EmptyResponse> UpdatePayoutSchedule(string entityId, Currency currency,
                                                        UpdateScheduleRequest updateScheduleRequest,
                                                        CancellationToken cancellationToken = default)
 {
     CheckoutUtils.ValidateParams("entityId", entityId, "currency", currency, "updateScheduleRequest",
                                  updateScheduleRequest);
     return(await ApiClient.Put <EmptyResponse>(
                BuildPath(AccountsPath, EntitiesPath, entityId, PayoutSchedulePath),
                SdkAuthorization(SdkAuthorizationType.OAuth),
                new Dictionary <Currency, UpdateScheduleRequest>() { { currency, updateScheduleRequest } },
                cancellationToken));
 }
Example #5
0
 // Use this for initialization
 void Awake()
 {
     layout                = transform.Find("ScrollPanel/Layout");
     scheduleItem          = Resources.Load <GameObject>("UIItem/ScheduleItem");
     addScheduleRequest    = GetComponent <AddScheduleRequest>();
     updateScheduleRequest = GetComponent <UpdateScheduleRequest>();
     deleteScheduleRequest = GetComponent <DeleteScheduleRequest>();
     datePicker            = transform.Find("Calendar").GetComponent <DatePicker>();
     transform.Find("BackButton").GetComponent <Button>().onClick.AddListener(Back);
     transform.Find("AddButton").GetComponent <Button>().onClick.AddListener(Add);
     addPanel = transform.Find("AddPanel").gameObject;
     dateText = addPanel.transform.Find("Date").GetComponent <Text>();
     addPanel.transform.Find("SaveButton").GetComponent <Button>().onClick.AddListener(Save);
     content      = addPanel.transform.Find("Content").GetComponent <InputField>();
     noticeToggle = addPanel.transform.Find("NoticeToggle").GetComponent <Toggle>();
     for (int i = 0; i < 4; i++)
     {
         DateRange[i] = addPanel.transform.Find("DateRange/InputField" + i).GetComponent <InputField>();
         var j = i;
         DateRange[i].onEndEdit.AddListener(x => DateRange[j].text = (int.Parse(x) % (j % 2 == 0?24:60)).ToString());
     }
     addPanel.SetActive(false);
     Debug.Log(datePicker.VisibleDate);
 }
        public ActionResult UpdateSchedule(UpdateScheduleRequest request)
        {
            string logContent = "";
            string errorMsg   = null;
            string path;

            if (string.IsNullOrEmpty(request.SystemCode))
            {
                path = GlobalSchedulePath;
            }
            else
            {
                path = string.Format(ApplicationSchedulePath, request.SystemCode);
            }

            TaskService ts = default(TaskService);

            try
            {
                logContent += ("初始化ScheduleService");
                var scheduleServer = ConfigHelper.GetValue("ScheduleServer");
                if (string.IsNullOrEmpty(scheduleServer))
                {
                    ts = new TaskService();
                }
                else
                {
                    ts = new TaskService(scheduleServer);
                }
            }
            catch (Exception ex)
            {
                errorMsg = "初始化ScheduleService错误:" + ex.Message + ex.InnerException;
            }
            if (string.IsNullOrEmpty(errorMsg))
            {
                bool       found  = false;
                TaskFolder folder = ts.RootFolder;
                try
                {
                    try
                    {
                        folder = ts.GetFolder(path);
                        if (null != folder)
                        {
                            found = true;
                        }
                        else
                        {
                            found = false;
                        }
                    }
                    catch (Exception)
                    {
                        found = false;
                    }
                    logContent += ("found:" + found.ToString());
                    if (!found)
                    {
                        folder = ts.RootFolder.CreateFolder(path);
                    }

                    TaskDefinition td = ts.NewTask();

                    td.RegistrationInfo.Description = request.Descr;


                    Microsoft.Win32.TaskScheduler.TimeTrigger tr = new TimeTrigger();
                    if (!string.IsNullOrEmpty(request.StartDate))
                    {
                        tr.StartBoundary = DateTime.Parse(request.StartDate);
                    }

                    if (!string.IsNullOrEmpty(request.EndDate))
                    {
                        tr.EndBoundary = DateTime.Parse(request.EndDate);
                    }
                    tr.Repetition.Duration = new TimeSpan(0);
                    tr.Repetition.Interval = new TimeSpan(0, int.Parse(request.Period), 0);
                    tr.Enabled             = true;
                    td.Triggers.Add(tr);

                    td.Actions.Add(new ExecAction(ConfigHelper.GetValue("TaskExecutorPath"), request.ScheduleId));

                    if (!string.IsNullOrEmpty(request.RetryCount))
                    {
                        var retryCountInt = int.Parse(request.RetryCount);
                        td.Settings.RestartCount    = retryCountInt;
                        td.Settings.RestartInterval = new TimeSpan(0, 1, 0);
                    }

                    //if (folder.Tasks.Count(o => o.Name == scheduleObj.ScheduleCode) > 0)
                    //{
                    //    folder.DeleteTask(scheduleObj.ScheduleCode);
                    //}
                    //td.Principal.LogonType = TaskLogonType.Password;
                    //td.Principal.RunLevel = TaskRunLevel.Highest;
                    //td.Principal =
                    //using (System.Web.Hosting.HostingEnvironment.Impersonate())
                    //{
                    td.Settings.Enabled = !string.IsNullOrEmpty(request.ScheduleStatus) && request.ScheduleStatus == ((int)EnumRecordStatus.Enabled).ToString();
                    //td.Settings. = false;
                    var ScheduleUser     = ConfigHelper.GetValue("ScheduleUser");
                    var SchedulePassword = ConfigHelper.GetValue("SchedulePassword");
                    logContent += ("|ScheduleUser:"******"|SchedulePassword:"******"web.config 中没有配置ScheduleUser 和 SchedulePassword";

                        //Task task = folder.RegisterTaskDefinition(scheduleObj.ScheduleCode, td, TaskCreation.Create, @"gzdemo-MSFT\gzdemo", "Pass@word1", TaskLogonType.Password, null);
                    }
                    else
                    {
                        Task task = folder.RegisterTaskDefinition(request.ScheduleCode, td, TaskCreation.CreateOrUpdate, ScheduleUser, SchedulePassword, TaskLogonType.Password, null);
                    }
                    logContent += "初始化成功";
                    //task.Definition.Principal.RunLevel = TaskRunLevel.Highest;
                    //folder.RegisterTaskDefinition(scheduleObj.ScheduleCode, task.Definition, TaskCreation.Update, @"gzdemo-MSFT\gzdemo", "Pass@word1", TaskLogonType.Password, null);
                    //Task task = folder.RegisterTaskDefinition(scheduleObj.ScheduleCode, td);
                    //}
                }
                catch (Exception ex)
                {
                    errorMsg = ex.Message + ex.InnerException;
                }
                finally
                {
                    folder = null;
                    ts     = null;
                }
            }
            if (!string.IsNullOrEmpty(errorMsg))
            {
                return(new JsonResult(new { Success = false, Msg = logContent, ErrorMsg = errorMsg }));
            }

            return(new JsonResult(new { Success = true, Msg = logContent }));
        }