Example #1
0
        public static void Main(string[] args)
        {
            PushPayload pushPayload = new PushPayload();

            pushPayload.platform     = Platform.all();
            pushPayload.audience     = Audience.all();
            pushPayload.notification = new Notification().setAlert(ALERT);
            ScheduleClient scheduleclient = new ScheduleClient(app_key, master_secret);

            //init a TriggerPayload
            TriggerPayload triggerConstructor = new TriggerPayload(START, END, TIME_PERIODICAL, TIME_UNIT, FREQUENCY, POINT);
            //init a SchedulePayload
            SchedulePayload schedulepayloadperiodical = new SchedulePayload(NAME, ENABLED, triggerConstructor, pushPayload);

            try
            {
                var result = scheduleclient.sendSchedule(schedulepayloadperiodical);
                Console.WriteLine(result);
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            //init a pushpayload
            PushPayload pushPayload = new PushPayload();

            pushPayload.platform     = Platform.all();
            pushPayload.audience     = Audience.all();
            pushPayload.notification = new Notification().setAlert(ALERT);

            ScheduleClient scheduleclient = new ScheduleClient(app_key, master_secret);

            //get schedule by id
            try
            {
                var result = scheduleclient.getScheduleById(PUT_SCHEDULE_ID);
                Console.WriteLine(result.name);
                Console.WriteLine(result);
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }
        }
        private void Delete_Schedule(object sender, EventArgs e)
        {
            Schedule schedule = (Schedule)schedulesListBox.SelectedItem;

            schedulesListBox.Items.RemoveAt(schedulesListBox.SelectedIndex);
            ScheduleClient.DeleteSchedule(schedule.ID);
        }
Example #4
0
        public async Task ShouldCreateScheduleWhenRequested()
        {
            var workloadItems = new List <WorkloadItem>
            {
                Any.Instance <WorkloadItem>(),
                Any.Instance <WorkloadItem>()
            };

            var maintenanceWindowServiceLocation = new ServiceLocation
            {
                Location = new Uri("http://localhost:5678")
            };

            _mockServer.Given(
                Request.Create().UsingGet().WithPath("/MaintenanceWindowService"))
            .RespondWith(
                Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindowServiceLocation));

            var maintenanceWindows = Any.Instance <MaintenanceWindow>();

            _mockServer.Given(
                Request.Create().UsingGet().WithPath("/Planned"))
            .RespondWith(
                Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindows));

            var httpClient           = new HttpClient();
            var scheduleWebApiClient = new ScheduleClient(httpClient)
            {
                BaseUrl = ScheduleWebApiBaseUrl
            };

            var result = await scheduleWebApiClient.CreateScheduleAsync(workloadItems);

            result.Should().NotBe(Guid.Empty);
        }
 public ScheduleTeacherRemoteDataSource(
     ILogger <ScheduleTeacherRemoteDataSource> logger,
     ScheduleClient client,
     ScheduleTeacherRemoteConverter converter
     )
 {
     this.logger    = logger;
     this.client    = client;
     this.converter = converter;
 }
        public BackupSchedules()
        {
            InitializeComponent();

            List <Schedule> schedules = ScheduleClient.GetInfo();

            foreach (Schedule schedule in schedules)
            {
                schedulesListBox.Items.Add(schedule);
                //Debug.Print("aaa");
            }
        }
Example #7
0
        public async Task ShouldRetrieveCreatedSchedule()
        {
            var workloadItems = new List <WorkloadItem>
            {
                new WorkloadItem
                {
                    Identifier      = Guid.NewGuid(),
                    DurationInHours = 7
                },
                new WorkloadItem
                {
                    Identifier      = Guid.NewGuid(),
                    DurationInHours = 3
                }
            };

            var maintenanceWindowServiceLocation = new ServiceLocation
            {
                Location = new Uri("http://localhost:5678")
            };

            _mockServer.Given(
                Request.Create().UsingGet().WithPath("/MaintenanceWindowService"))
            .RespondWith(
                Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindowServiceLocation));

            var maintenanceWindows = new MaintenanceWindow
            {
                LengthInHours = 5
            };

            _mockServer.Given(
                Request.Create().UsingGet().WithPath("/Planned"))
            .RespondWith(
                Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindows));

            var httpClient           = new HttpClient();
            var scheduleWebApiClient = new ScheduleClient(httpClient)
            {
                BaseUrl = ScheduleWebApiBaseUrl
            };

            var scheduleId = await scheduleWebApiClient.CreateScheduleAsync(workloadItems);

            var result = await scheduleWebApiClient.GetScheduleByIdAsync(scheduleId);

            result.Count.Should().Be(2);
            result.Should().Contain(x => x.Identifier == workloadItems[0].Identifier &&
                                    x.Order == 2);
            result.Should().Contain(x => x.Identifier == workloadItems[1].Identifier &&
                                    x.Order == 1);
        }
Example #8
0
        void SetUpUI()
        {
            if (play != null)
            {
                play.Click += (sender, e) => OnPlayButtonClick();
            }

            if (pause != null)
            {
                pause.Click += (sender, e) => OnPauseButtonClick();
            }

            var scheduleClient = new ScheduleClient();

            webView.Settings.JavaScriptEnabled = true;
            webView.SetWebViewClient(scheduleClient);
            webView.LoadUrl("https://godswayradio.com/live/");

            _manager                = (AudioManager)Application.Context.GetSystemService(Context.AudioService);
            volume.Max              = _manager.GetStreamMaxVolume(Stream.Music);
            volume.Progress         = _manager.GetStreamVolume(Stream.Music);
            volume.ProgressChanged += (sender, e) => { _manager.SetStreamVolume(Stream.Music, e.Progress, VolumeNotificationFlags.ShowUi); };

            Mvx.Resolve <IDeviceTimer>().StartTimer(new TimeSpan(0, 0, 3), () =>
            {
                if (!_continueTimer)
                {
                    return(false);
                }

                schedule = scheduleClient.GetSchedule();

                if (schedule != null)
                {
                    mainLabel.Text = schedule.ToArray()[0];
                    subLabel.Text  = schedule.ToArray()[1];
                    _service.UpdateNotification(schedule.ToArray()[0] + "-" + schedule.ToArray()[1], "God's Way Radio");
                }
                else
                {
                    mainLabel.Text = "God's Way Radio";
                    subLabel.Text  = "104.7 WAYG";
                    _service.UpdateNotification("God's Way Radio - 104.7 WAYG", "God's Way Radio");
                }

                return(true);
            });
        }
Example #9
0
        /// <summary>
        /// 定时推送的功能
        /// </summary>
        public static void PushSchedule()
        {
            string START           = "2016-12-21 12:30:00";
            string END             = "2016-12-24 12:30:00";
            string TIME_UNIT       = "WEEK";       //时间单位
            string TIME_PERIODICAL = "17:00:00";   //推送的时间点
            int    FREQUENCY       = 1;
            string NAME            = "Test";       //推送的内容
            bool   ENABLED         = true;

            string[] POINT = new String[] { "WED", "FRI" };

            //init a pushpayload
            PushPayload pushPayload = new PushPayload();

            pushPayload.platform     = Platform.all();
            pushPayload.audience     = Audience.all();
            pushPayload.notification = new Notification().setAlert(NAME);

            ScheduleClient scheduleclient = new ScheduleClient(app_key, master_secret);

            //init a TriggerPayload
            TriggerPayload triggerConstructor = new TriggerPayload(START, END, TIME_PERIODICAL, TIME_UNIT, FREQUENCY, POINT);
            //init a SchedulePayload
            SchedulePayload schedulepayloadperiodical = new SchedulePayload(NAME, ENABLED, triggerConstructor, pushPayload);

            try
            {
                var result = scheduleclient.sendSchedule(schedulepayloadperiodical);
                Console.WriteLine(result);
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorMessage);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine();
            }
        }
Example #10
0
        public static void Main(string[] args)
        {
            //init a pushpayload
            PushPayload pushPayload = new PushPayload();

            pushPayload.platform     = Platform.all();
            pushPayload.audience     = Audience.all();
            pushPayload.notification = new Notification().setAlert(ALERT);

            ScheduleClient scheduleclient = new ScheduleClient(app_key, master_secret);

            //init a TriggerPayload
            TriggerPayload triggerConstructor = new TriggerPayload(START, END, TIME_PERIODICAL, TIME_UNIT, FREQUENCY, POINT);
            //init a SchedulePayload
            SchedulePayload schedulepayloadperiodical = new SchedulePayload(NAME, ENABLED, triggerConstructor, pushPayload);

            //PUT the name
            SchedulePayload putschedulepayload = new SchedulePayload();

            putschedulepayload.setName(NAME);

            //the default enabled is true,if you want to change it,you have to set it to false
            try
            {
                var result = scheduleclient.putSchedule(putschedulepayload, SCHEDULE_ID);
                Console.WriteLine(result);
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #11
0
        public override string SendMessage()
        {
            ScheduleClient scheduleclient = new ScheduleClient(app_key, master_secret);
            PushPayload    payload_all    = PushObject_All_All_Alert();

            //init a TriggerPayload
            TriggerPayload triggerConstructor = new TriggerPayload(START, END, TIME_PERIODICAL, TIME_UNIT, FREQUENCY, POINT);
            //init a SchedulePayload
            SchedulePayload schedulepayloadperiodical = new SchedulePayload(NAME, ENABLED, triggerConstructor, payload_all);

            try
            {
                var result = scheduleclient.sendSchedule(schedulepayloadperiodical);
            }
            catch
            {
                return("failed");
            }

            SchedulePayload schedulepayloadsingle = new SchedulePayload();
            TriggerPayload  triggersingle         = new TriggerPayload(TIME);

            schedulepayloadsingle.setPushPayload(payload_all);
            schedulepayloadsingle.setTrigger(triggersingle);
            schedulepayloadsingle.setName(NAME);
            schedulepayloadsingle.setEnabled(ENABLED);

            try
            {
                var result = scheduleclient.sendSchedule(schedulepayloadsingle);
            }
            catch
            {
                return("failed");
            }

            return("succeed");
        }
Example #12
0
        private void ApplySchedule(object sender, EventArgs e)
        {
            string selectFtp = ftpServers.GetItemText(this.ftpServers.SelectedItem);

            serverSettings = selectFtp;
            Upload up = new Upload();

            up.ShowDialog();
            if (ftpServers.SelectedIndex < 0)
            {
                MessageBox.Show("Please Select Server", "Select Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //validation
            if (this.ValidateChildren())//ama petuxan ola ta validation tote kanonika ginete to schedule
            {
                if (fullAutomaticRadio.Checked)
                {
                    if (generalVariables.GetVariable("dbBinFolder") != null)
                    {
                        if (ScheduleClient.AddSchedule(BuildSchedule()))// ama ola phgan ok.
                        {
                            applyFeedback.Text      = "Schedule, successful added";
                            applyFeedback.ForeColor = System.Drawing.Color.DodgerBlue;
                        }
                        else
                        {
                            applyFeedback.Text      = "Failed to add schedule";
                            applyFeedback.ForeColor = System.Drawing.Color.Red;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Can't continue, with full automatic backup. Please setup first, the path to mysql bin folder.", "Can't apply", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    if (File.Exists(databaseFilePath.Text))
                    {
                        if (ScheduleClient.AddSchedule(BuildSchedule()))// ama ola phgan ok.
                        {
                            applyFeedback.Text      = "Schedule, successful added";
                            applyFeedback.ForeColor = System.Drawing.Color.DodgerBlue;
                        }
                        else
                        {
                            applyFeedback.Text      = "Failed to add schedule";
                            applyFeedback.ForeColor = System.Drawing.Color.Red;
                        }
                    }
                    else
                    {
                        MessageBox.Show("The database, file not exist.", "Can't apply", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }

                // 2. ama den exei dialeksei automatic prepei na uparxei to arxeio pou exei dwsei
            }
            else//DEN prepei na ginei to schedule
            {
            }
            //end validation
        }
Example #13
0
        public static string serverSettings; //mia static gia na krataw to server pou epelexse o xristis.


        public Form1()
        {
            InitializeComponent();

            //gia to logfiles folder
            Directory.CreateDirectory(Path.GetFullPath(@".\LogFiles"));
            Directory.CreateDirectory(Path.GetFullPath(@".\var"));
            Directory.CreateDirectory(@".\servers");
            logVariables     = new VariableStorage(Path.GetFullPath(@".\LogFiles\logV"));
            generalVariables = new VariableStorage(Path.GetFullPath(@".\var\genV"));
            stream           = new ObjectStream(@".\servers\saveServer");
            Fillinit();
            try
            {
                //gia to service
                ServiceController serviceController = new ServiceController("ScheduleService");
                switch (serviceController.Status)
                {
                case ServiceControllerStatus.Paused:
                    serviceController.Start();
                    break;

                case ServiceControllerStatus.Stopped:
                    serviceController.Start();
                    break;
                }
                serviceController.Refresh();
                //end service
            }
            catch (Exception ex)
            {
            }

            //stream.ClearFile();
            SetDownloadPanelNotVisble(); //kanw not visible ta download panel

            //ola ta nea panels prepei na mpoun se auton ton pinaka, kai meta sthn switch (method MenuClick)
            panels       = new Panel[] { databasePanel, serversPanel, backupPanel, logPanel, downloadPanel }; //krata ola ta panel gia na mporeis na ta allazeis
            currentPanel = databasePanel;                                                                     //einai to arxiko

            //declare gia ta panels
            for (int i = 1; i < panels.Length; i++)
            {
                panels[i].Visible = false;
            }
            currentPanel.Visible = true;
            //end panels
            serverType.SelectedIndex = 0;

            //VariableStorage logVariables = new VariableStorage(System.IO.Path.GetFullPath(@"..\..\LogFiles\logV"));
            try
            {
                ScheduleClient.SetLogFile(new LogFile());//stelnw to log file sto service
            }
            catch (Exception ex)
            {
                Debug.Print("Error");
            }

            //giati ksekina me to database panel gemizw to textbox
            object dbBinFolder = generalVariables.GetVariable("dbBinFolder");

            if (dbBinFolder != null)
            {
                binFolderPath.TextBox.Text = dbBinFolder.ToString();
            }

            //TestService test = new TestService();
        }
        static void Main(string[] args)
        {
            //init a pushpayload
            PushPayload pushPayload = new PushPayload();

            pushPayload.platform     = Platform.all();
            pushPayload.audience     = Audience.all();
            pushPayload.notification = new Notification().setAlert(ALERT);

            ScheduleClient scheduleclient = new ScheduleClient(app_key, master_secret);

            //init a TriggerPayload
            TriggerPayload triggerConstructor = new TriggerPayload(START, END, TIME_PERIODICAL, TIME_UNIT, FREQUENCY, POINT);
            //init a SchedulePayload
            SchedulePayload schedulepayloadperiodical = new SchedulePayload(NAME, ENABLED, triggerConstructor, pushPayload);

            try
            {
                var result = scheduleclient.sendSchedule(schedulepayloadperiodical);
                //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法
                System.Threading.Thread.Sleep(10000);
                Console.WriteLine(result);
                //保留这里获取的schedule_id,作为后面删除schedule的参数,如果不想删除这个可以删掉这一行,另外设置一个schedule_id
                schedule_id = result.schedule_id;
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }


            SchedulePayload schedulepayloadsingle = new SchedulePayload();
            TriggerPayload  triggersingle         = new TriggerPayload(TIME);

            //SchedulePayload schedulepayloadsingle = new SchedulePayload();
            schedulepayloadsingle.setPushPayload(pushPayload);
            schedulepayloadsingle.setTrigger(triggersingle);
            schedulepayloadsingle.setName(NAME);
            schedulepayloadsingle.setEnabled(ENABLED);

            try
            {
                var result = scheduleclient.sendSchedule(schedulepayloadsingle);
                //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法
                System.Threading.Thread.Sleep(10000);
                Console.WriteLine(result);
                //保留这里获取的schedule_id,作为后面删除schedule的参数,如果不想删除这个可以删掉这一行,另外设置一个schedule_id
                schedule_id = result.schedule_id;
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }


            //get schedule
            try
            {
                var result = scheduleclient.getSchedule(PAGEID);
                //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法
                System.Threading.Thread.Sleep(10000);
                Console.WriteLine(result.schedules[0].name);

                //if the test Schedule is too much,delete it

                /*
                 * for (int counter = 0; counter <= 40; counter++) {
                 *  scheduleclient.deleteSchedule(result.schedules[counter].schedule_id);
                 * }
                 */
                Console.WriteLine(result.schedules);
                Console.WriteLine(result);
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }


            //get schedule by id
            try
            {
                var result = scheduleclient.getScheduleById(PUT_SCHEDULE_ID);
                //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法
                System.Threading.Thread.Sleep(10000);
                Console.WriteLine(result.name);
                Console.WriteLine(result);
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }

            //put the name

            SchedulePayload putschedulepayload = new SchedulePayload();

            putschedulepayload.setName(NAME);

            /*
             * putschedulepayload.setPushPayload(null);
             * putschedulepayload.setTrigger(null);
             */
            //the default enabled is true,if you want to change it,you have to set it to false
            try
            {
                var result = scheduleclient.putSchedule(putschedulepayload, schedule_id);
                //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法
                System.Threading.Thread.Sleep(10000);
                Console.WriteLine(result);
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }


            //deleteSchedule
            try
            {
                //删除的是第一次创建的schedule_id,如果要保留第一次创建的,请重新传入schedule_id
                var result = scheduleclient.deleteSchedule(schedule_id);
                //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法
                System.Threading.Thread.Sleep(10000);
                Console.WriteLine(result);
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }

            //
            SchedulePayload schedulepayloadSet = new SchedulePayload();
            TriggerPayload  triggerSet         = new TriggerPayload();

            triggerSet.setStart(START);
            triggerSet.setEnd(END);
            triggerSet.setTime(TIME_PERIODICAL);
            triggerSet.setTime_unit(TIME_UNIT);
            triggerSet.setFrequency(FREQUENCY);
            triggerSet.setPoint(POINT);

            schedulepayloadSet.setPushPayload(pushPayload);
            schedulepayloadSet.setTrigger(triggerSet);
            schedulepayloadSet.setName(NAME);
            schedulepayloadSet.setEnabled(ENABLED);

            try
            {
                var result = scheduleclient.sendSchedule(schedulepayloadSet);
                //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法
                System.Threading.Thread.Sleep(10000);
                Console.WriteLine(result);
                //保留这里获取的schedule_id,作为后面删除schedule的参数,如果不想删除这个可以删掉这一行,另外设置一个schedule_id
                schedule_id1 = result.schedule_id;
            }
            catch (APIRequestException e)
            {
                Console.WriteLine("Error response from JPush server. Should review and fix it. ");
                Console.WriteLine("HTTP Status: " + e.Status);
                Console.WriteLine("Error Code: " + e.ErrorCode);
                Console.WriteLine("Error Message: " + e.ErrorCode);
            }
            catch (APIConnectionException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #15
0
 public ScheduleRemoteDataSource(ScheduleClient client, ScheduleRemoteConverter converter)
 {
     this.client    = client;
     this.converter = converter;
 }