Пример #1
0
        public async void NewAddress()
        {
            Value = true;
            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Warning,
                    Languages.CheckConnection,
                    Languages.Ok);

                return;
            }
            var emailPattern = "^[a-z0-9._-]+@[a-z0-9._-]+\\.[a-z]{2,6}$";

            if (string.IsNullOrEmpty(Email))
            {
                Value = true;
                return;
            }
            if (!String.IsNullOrWhiteSpace(Email) && !(Regex.IsMatch(Email, emailPattern)))
            {
                Value = true;
                return;
            }

            List <AddAddress> addAddresses = new List <AddAddress>();

            addAddresses.Add(new AddAddress()
            {
                code        = "#MailSender",
                addressMail = Email,
                duplicate   = false
            });
            var _jobCron = new AddJobCron
            {
                addresses = addAddresses
            };
            var cookie = Settings.Cookie;  //.Split(11, 33)
            var res    = cookie.Substring(11, 32);

            var response = await apiService.Save <AddJobCron>(
                "https://portalesp.smart-path.it",
                "/Portalesp",
                "/mailSender/save",
                res,
                _jobCron);

            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok");

                return;
            }
            Value = false;
            MessagingCenter.Send((App)Application.Current, "OnSaved");
            DependencyService.Get <INotification>().CreateNotification("PortalSP", "Email Added");
            await App.Current.MainPage.Navigation.PopPopupAsync(true);
        }
        public async void NewJobCron()
        {
            Value = true;
            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Warning,
                    Languages.CheckConnection,
                    Languages.Ok);

                return;
            }

            /* if (string.IsNullOrEmpty(Days))
             * {
             *   Value = true;
             *   return;
             * }*/
            List <AddConfigs> addConfigs = new List <AddConfigs>();

            addConfigs.Add(new AddConfigs()
            {
                code = "#PostedReports",
                cron = "0 " + Minute + " " + Hour + " ? * " + Days + " *"
            });
            var _jobCron = new AddJobCron
            {
                configs = addConfigs
            };
            var cookie = Settings.Cookie;  //.Split(11, 33)
            var res    = cookie.Substring(11, 32);

            var response = await apiService.Save <AddJobCron>(
                "https://portalesp.smart-path.it",
                "/Portalesp",
                "/postedReports/saveMails",
                res,
                _jobCron);

            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok");

                return;
            }
            Value = false;
            MessagingCenter.Send((App)Application.Current, "OnSaved");
            DependencyService.Get <INotification>().CreateNotification("PortalSP", "Job Cron Added");
            await App.Current.MainPage.Navigation.PopPopupAsync(true);
        }