コード例 #1
0
ファイル: Settings.xaml.cs プロジェクト: MichaelStgt/WinPass
        public Settings()
        {
            InitializeComponent();
            lstAutoSyncSettings.Items.Add(Strings.Settings_AutoUpdateInactive);
            lstAutoSyncSettings.Items.Add(Strings.Settings_AutoUpdateActive);
            lstAutoSyncSettings.Items.Add(Strings.Settings_AutoUpdateSWLAN);

            viewMode.Items.Add(Strings.Settings_ModeClassic);
            viewMode.Items.Add(Strings.Settings_ModeModern);
            viewMode.SelectedItem = Cache.InClassicStyle()
                ? Strings.Settings_ModeClassic
                : Strings.Settings_ModeModern;

            var version = PhoneHelper
                          .GetAppAttribute("Version");

            lblVersion.Text = string.Format(lblVersion.Text, version);

            Array.ForEach(cultures, item =>
            {
                var lang = new LanguageProxy(item);
                listpickerLanguage.Items.Add(lang);
                if (lang.Name == Thread.CurrentThread.CurrentCulture.Name)
                {
                    listpickerLanguage.SelectedItem = lang;
                }
            });
        }
コード例 #2
0
 public HelpPage()
 {
     InitializeComponent();
     #region Paid version Check
     if (App.isPaidVersion == true)
     {
         // disables ads
         adControl.Visibility = System.Windows.Visibility.Collapsed;
         //adControl.IsAutoRefreshEnabled = false;
         adControl.IsEnabled             = false;
         adControl.IsAutoCollapseEnabled = false;
         svHelp.Height = 605;
         svHelp.Margin = new Thickness(0, 0, 0, 549);
     }
     else
     {
         // enable ads
         adControl.Visibility = System.Windows.Visibility.Visible;
         //adControl.IsAutoRefreshEnabled = true;
         adControl.IsEnabled             = true;
         adControl.IsAutoCollapseEnabled = false;
     }
     #endregion
     txtAppName.Text     = PhoneHelper.GetAppAttribute("Title") + " by " + PhoneHelper.GetAppAttribute("Author");
     txtVersion.Text     = "version " + PhoneHelper.GetAppAttribute("Version");
     txtDescription.Text = PhoneHelper.GetAppAttribute("Description");
 }
コード例 #3
0
        // use task to open app http://www.windowsphonegeek.com/articles/6-how-to-use-marketplace-tasks-in-a-wp7-app

        public AppInfoPage()
        {
            InitializeComponent();
            MainPivot.Title = PhoneHelper.GetAppAttribute("Title").ToUpper();
            // txtHelp.Text = "We will continue to roll out new features and your suggestions.";
            txtAppName.Text = PhoneHelper.GetAppAttribute("Title") + " v" + PhoneHelper.GetAppAttribute("Version");
            //" by " + PhoneHelper.GetAppAttribute("Author");
            //   txtVersion.Text = "version " + PhoneHelper.GetAppAttribute("Version");
            txtDescription.Text = PhoneHelper.GetAppAttribute("Description");

            if (App.isPaidVersion == true)
            {
                adControl.Visibility = System.Windows.Visibility.Collapsed;
                //HelpScrollViewer.Height = 535;
                AppsListBox.Height       = 535;
                AboutScrollViewer.Height = 535;
            }
            else
            {
                AdvertiseInfo adInfo = new AdvertiseInfo();
                adControl = new Microsoft.Advertising.Mobile.UI.AdControl(adInfo.ApplicationID, adInfo.AdUnitID, true);
                //HelpScrollViewer.Height = 454;
                AppsListBox.Height       = 454;
                AboutScrollViewer.Height = 454;
            }
        }
コード例 #4
0
ファイル: AboutViewModel.cs プロジェクト: mvaal/bgdbwp8
        public AboutViewModel()
        {
            Version   = PhoneHelper.GetAppAttribute("Version");
            Title     = PhoneHelper.GetAppAttribute("Title");
            Author    = PhoneHelper.GetAppAttribute("Author");
            Publisher = PhoneHelper.GetAppAttribute("Publisher");

            AboutMenuItem[] aboutMenuItems = new AboutMenuItem[] {
                new AboutMenuItem("rate", AppResources.AboutAboutRateHeader, "post a 5-star rating in the windows phone store", "/Assets/Images/heart.png"),
                new AboutMenuItem("feedback", AppResources.AboutAboutFeedbackHeader, "tech support, feature requests, and suggestions", "/Assets/Images/feedback.png"),
                new AboutMenuItem("apps", AppResources.AboutAboutAppsHeader, "more apps by this developer", "/Assets/Images/windows.png"),
            };
            AboutMenuItems = new ObservableCollection <AboutMenuItem>(aboutMenuItems);

            HistoryMenuItem[] historyMenuItem = new HistoryMenuItem[] {
                new HistoryMenuItem("1.0.0.0", "Initial public release."),
            };
            HistoryMenuItems = new ObservableCollection <HistoryMenuItem>(historyMenuItem.Reverse());

            CreditsMenuItem[] creditsMenuItems = new CreditsMenuItem[] {
                new CreditsMenuItem("http://silverlight.codeplex.com", "Microsoft Silverlight Toolkit"),
                new CreditsMenuItem("http://boardgamegeek.com", "Board Game Geek"),
                new CreditsMenuItem("http://htmlagilitypack.codeplex.com/releases/view/90925", "HtmlAgilityPack"),
                new CreditsMenuItem("http://www.telerik.com/products/windows-phone.aspx", "Telerik"),
                new CreditsMenuItem("http://coding4fun.codeplex.com/", "Coding4Fun Toolkit"),
                new CreditsMenuItem("http://www.windowsphone.com/en-US/store/publishers?publisherId=taropuff", "taropuff", "Thanks for the images."),
            };

            CreditsMenuItems = new ObservableCollection <CreditsMenuItem>(creditsMenuItems);
        }
コード例 #5
0
 private void IsAcceptBtnEnable()
 {
     AcceptButton.IsEnabled =
         !string.IsNullOrEmpty(PhoneTB.Text) &&
         !string.IsNullOrEmpty(PassTB.Text) &&
         (PhoneHelper.ValidPhoneNumber(PhoneTB.Text) != null);
 }
コード例 #6
0
ファイル: PopupHelper.cs プロジェクト: phamy/WP7-Official
        /// <summary>
        /// Arrange the popup.
        /// <param name="finalSize">The <see cref="T:Size"/> from <see cref="M:AutoCompleteBox.ArrangeOverride"/>.</param>
        /// </summary>
        public void Arrange(Size?finalSize)
        {
            if (Popup == null ||
                PopupChild == null ||
                Application.Current == null ||
                OutsidePopupCanvas == null ||
                Application.Current.Host == null ||
                Application.Current.Host.Content == null)
            {
                return;
            }
            PhoneApplicationFrame frame;

            if (!PhoneHelper.TryGetPhoneApplicationFrame(out frame))
            {
                return;
            }
            Size            frameSize       = frame.GetUsefulSize();
            Thickness       margin          = GetMargin();
            Size            controlSize     = GetControlSize(margin, finalSize);
            MatrixTransform matrixTransform = GetControlMatrixTransform();

            if (matrixTransform == null)
            {
                return;
            }
            Point controlPoint = MatrixTransformPoint(matrixTransform, margin);
            Size  displaySize  = frame.GetSipUncoveredSize();
            bool  isChildAbove = IsChildAbove(displaySize, controlSize, controlPoint);
            Size  childSize    =
                isChildAbove ?
                AboveChildSize(controlSize, controlPoint) :
                BelowChildSize(displaySize, controlSize, controlPoint);

            if (frameSize.Width == 0 || frameSize.Height == 0 || childSize.Height == 0)
            {
                return;
            }
            Point childPoint = isChildAbove ? AboveChildPoint(margin) : BelowChildPoint(margin, controlSize);

            Popup.HorizontalOffset = 0;
            Popup.VerticalOffset   = 0;

            PopupChild.Width               = PopupChild.MaxWidth = PopupChild.MinWidth = controlSize.Width;
            PopupChild.MinHeight           = 0;
            PopupChild.MaxHeight           = childSize.Height;
            PopupChild.HorizontalAlignment = HorizontalAlignment.Left;
            PopupChild.VerticalAlignment   = VerticalAlignment.Top;
            Canvas.SetLeft(PopupChild, childPoint.X);
            Canvas.SetTop(PopupChild, childPoint.Y);

            OutsidePopupCanvas.Width  = controlSize.Width;
            OutsidePopupCanvas.Height = frameSize.Height;
            Matrix fromFrameToControl = matrixTransform.Matrix;
            Matrix fromControlToFrame;

            fromFrameToControl.Invert(out fromControlToFrame);
            matrixTransform.Matrix             = fromControlToFrame;
            OutsidePopupCanvas.RenderTransform = matrixTransform;
        }
コード例 #7
0
ファイル: AdminHelper.cs プロジェクト: SA-MP-Developer/SemiRP
        public static Phone GivePhone(Player sender, Player target)
        {
            if (!sender.AccountData.HavePerm("admin.cmds.give.phone"))
            {
                throw new Exception("Vous n'avez pas les permissions pour cela.");
            }

            Phone phone = PhoneHelper.CreatePhone();

            if (PhoneHelper.GetDefaultPhone(target.ActiveCharacter) == null)
            {
                phone.DefaultPhone = true;
            }

            try
            {
                InventoryHelper.AddItemToCharacter(target.ActiveCharacter, phone);

                ServerDbContext dbContext = ((GameMode)GameMode.Instance).DbContext;
                dbContext.SaveChanges();
                return(phone);
            }
            catch
            {
                PhoneHelper.DeletePhone(phone);
                throw new Exception("Le téléphone n'a pas pu être ajouté à l'utilisateur.");
            }
        }
コード例 #8
0
        private void appbar_button_MarketplaceSearch_Click(object sender, EventArgs e)
        {
            MarketplaceSearchTask _marketplaceSearch = new MarketplaceSearchTask();

            _marketplaceSearch.SearchTerms = PhoneHelper.GetAppAttribute("Author");
            _marketplaceSearch.Show();
        }
コード例 #9
0
ファイル: ErrorReport.cs プロジェクト: oldlaurel/WinPass
        private static void AddAppInfo(StringBuilder sb)
        {
            sb.AppendLine("WinPass info:");

            sb.Append("Version: ");
            sb.AppendLine(PhoneHelper.GetAppAttribute("Version"));
        }
コード例 #10
0
        public void Sure()
        {
            try
            {
                if (!PhoneHelper.ValidateMobile(UserName))
                {
                    SendMsg("resetPassWord", "userNameError");
                    return;
                }
                if (CheckCode == "")
                {
                    SendMsg("resetPassWord", "checkCodeError");
                    return;
                }
                if (Password == "")
                {
                    SendMsg("resetPassWord", "passWordError");
                    return;
                }

                var result = new LoginLogic().ResetPassWord(InterfacePath.Default.ResetPassWord, CheckCode, UserName, Password);
                SendMsg("resetPassWord", result.code.ToString());
                Log4Helper.Info(this.GetType(), $"手机号:{UserName},找回密码:{result.msg}");
            }
            catch (Exception ex)
            {
                SendMsg("resetPassWord", "Error");
                Log4Helper.Error(this.GetType(), ex);
            }
        }
コード例 #11
0
        async void AcceptButton_Clicked(object sender, EventArgs e)
        {
            AcceptButton.IsEnabled = false;

            var phone = PhoneHelper.ValidPhoneNumber(PhoneTB.Text);

            if (phone == 0)
            {
                return;
            }

            AppBusyPage.Show("Авторизация...");
            App.ClearTestLog();
            var res = await ApiService.Auth(PhoneTB.Text, PassTB.Text);

            await App.ShowTestLog(this);

            if (!string.IsNullOrEmpty(res))
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", res, "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }
            if (autoLogin)
            {
                //AppData.Crew.Online = lastOnline;
                AppData.Crew.CrewTypeId = lastCrewTypeId;
            }

            AppBusyPage.Show("Получение списка типов бригад...");
            App.ClearTestLog();
            res = await ApiService.GetCrewTypes();

            await App.ShowTestLog(this);

            if (!string.IsNullOrEmpty(res))
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", res, "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }

            if ((AppData.CrewTypes?.Count ?? 0) == 0)
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", "Не удалось получить список типов бригад", "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }

            AppBusyPage.Close();
            sctPage = new SelectCrewTypePage();
            sctPage.Disappearing += CrewTypePopup_Disappearing;
            await PopupNavigation.Instance.PushAsync(sctPage, true);
        }
コード例 #12
0
 /// <summary>
 /// 重发
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnRepeat_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (!PhoneHelper.ValidateMobile(PhoneNo.Text))
     {
         MessageBox.Show("手机号格式不正确!");
         return;
     }
     else
     {
         //发短信
         LoginLogic  logic = new LoginLogic();
         ResultModel model = logic.SendMessage(InterfacePath.Default.SendMessage, PhoneNo.Text, CheckCodeTypeEnum.RESET_PASSWORD.ToString());
         if (model.code == 200)
         {
             secondCount       = 59;
             BtnRepeat.Content = "重发";
             this.timer.Start();
         }
         else
         {
             string result = ((MessageStateEnum)model.code).ToString();
             Log4Helper.Error(this.GetType(), $"手机号:{PhoneNo.Text}发送重置密码短信失败!原因:{result}");
             MessageBox.Show(result);
         }
     }
 }
コード例 #13
0
        /// <summary>
        /// 确定
        /// </summary>
        public void Sure()
        {
            try
            {
                if (!PhoneHelper.ValidateMobile(UserName))
                {
                    SendMsg("register", "userNameError");
                    return;
                }
                if (CheckCode == "")
                {
                    SendMsg("register", "checkCodeError");
                    return;
                }
                if (Password == "")
                {
                    SendMsg("register", "passWordError");
                    return;
                }

                LoginLogic          loginLogic = new LoginLogic();
                ResultModel <Token> result     = loginLogic.Register(InterfacePath.Default.Register, CheckCode, UserName, NickName, Password, "", "");
                SendMsg("register", result.code.ToString());
                Log4Helper.Info(this.GetType(), $"手机号:{UserName},注册:{result.msg}");
            }
            catch (Exception ex)
            {
                SendMsg("register", "Error");
                Log4Helper.Error(this.GetType(), ex);
            }
        }
コード例 #14
0
        public HelpPage()
        {
            InitializeComponent();

            txtAppName.Text     = PhoneHelper.GetAppAttribute("Title") + " by " + PhoneHelper.GetAppAttribute("Author");
            txtVersion.Text     = "version " + PhoneHelper.GetAppAttribute("Version");
            txtDescription.Text = PhoneHelper.GetAppAttribute("Description");
        }
コード例 #15
0
        private void appbar_button_ContactUs_Click(object sender, EventArgs e)
        {
            EmailComposeTask _emailComposeTask = new EmailComposeTask();

            _emailComposeTask.To      = "*****@*****.**";
            _emailComposeTask.Subject = PhoneHelper.GetAppAttribute("Title") + "v" + PhoneHelper.GetAppAttribute("Version") + " Feedback";
            _emailComposeTask.Show();
        }
コード例 #16
0
 public InfoPage()
 {
     InitializeComponent();
     txtHelp.Text        = "We will continue to roll out new features and your suggestions.";
     txtAppName.Text     = PhoneHelper.GetAppAttribute("Title") + " by " + PhoneHelper.GetAppAttribute("Author");
     txtVersion.Text     = "version " + PhoneHelper.GetAppAttribute("Version");
     txtDescription.Text = PhoneHelper.GetAppAttribute("Description");
 }
コード例 #17
0
        /// <summary>
        /// Call to DB API REST to get the Company list
        /// </summary>
        /// <returns>A list of Company objects</returns>
        public static List <Company> GetCompanies(int id = 0)
        {
            List <Company> companies = new List <Company>();

            string request = Properties.Resources.base_url + "company/list"; //Properties.Settings.Default.base_url + "/Company/list";

            if (id > 0)
            {
                request += "?id_company=" + id;
            }
            string response = Functions.readRequest(request);

            if (id > 0)
            {
                JObject        resp      = JObject.Parse(response);
                Company        company   = parseCompany(resp.GetValue("0").ToString());
                List <Phone>   phones    = new List <Phone>();
                List <string>  emails    = new List <string>();
                List <Address> addresses = new List <Address>();

                foreach (JObject item in resp.GetValue(DBKeys.Company.PHONE_LIST))
                {
                    phones.Add(PhoneHelper.parsePhone(item.ToString()));
                }

                foreach (JObject item in resp.GetValue(DBKeys.Company.EMAIL_LIST))
                {
                    emails.Add(item.GetValue(DBKeys.CompanyHasEmail.ADDRESS).ToString());
                }

                foreach (JObject item in resp.GetValue(DBKeys.Company.ADDRESS_LIST))
                {
                    addresses.Add(AddressHelper.parseAddress(item.ToString()));
                }

                company.phones    = phones;
                company.emails    = emails;
                company.addresses = addresses;
                companies.Add(company);
            }
            else
            {
                JArray jsonArray = JArray.Parse(response);
                foreach (JObject item in jsonArray)
                {
                    string  str        = item.ToString();
                    Company newCompany = parseCompany(str);
                    if (newCompany != null)
                    {
                        companies.Add(newCompany);
                    }
                }

                companies.Sort();
            }
            return(companies);
        }
コード例 #18
0
 private void OnAboutButtonClicked(object sender, EventArgs e)
 {
     if (!_aboutMsgBoxLock)
     {
         _aboutMsgBoxLock = true;
         Version version = new Version(PhoneHelper.GetAppAttribute("Version"));
         MessageBox.Show(String.Format(FileLanguage.VERSION, version.Major, version.Minor, version.Revision));
         _aboutMsgBoxLock = false;
     }
 }
コード例 #19
0
        protected internal void email_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            var email = new EmailComposeTask
            {
                To      = EmailAddress,
                Subject = PhoneHelper.GetAppAttribute("Title") + " Feedback"
            };

            email.Show();
        }
コード例 #20
0
        private void appbar_button_Share_Click(object sender, EventArgs e)
        {
            ShareLinkTask shareLinkTask = new ShareLinkTask();
            ShareInfo     appInfo       = new ShareInfo();

            shareLinkTask.Title   = PhoneHelper.GetAppAttribute("Title");
            shareLinkTask.LinkUri = new Uri(appInfo.LinkUri, UriKind.Absolute);
            shareLinkTask.Message = appInfo.LinkMessage;
            shareLinkTask.Show();
        }
コード例 #21
0
        public About()
        {
            InitializeComponent();

            var version = PhoneHelper
                          .GetAppAttribute("Version");

            lblVersion.Text = string.Format(
                lblVersion.Text, version);
        }
コード例 #22
0
 private static void SendSMS(Player sender, string number, string message)
 {
     try
     {
         PhoneHelper.SendSMS(sender, number, message);
     }
     catch (Exception e)
     {
         Chat.ErrorChat(sender, "Le sms n'a pas pu être envoyé : " + e.Message);
     }
 }
コード例 #23
0
        async void CrewTypePopup_Disappearing(object sender, EventArgs e)
        {
            if (sctPage.SelectedCrewType?.Id == null)
            {
                await DisplayAlert("Ошибка", "Не выбран тип бригады", "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }

            AppBusyPage.Show("Сохранение данных на сервер...");
            App.ClearTestLog();
            var res = await ApiService.SetCrewType(sctPage.SelectedCrewType);

            await App.ShowTestLog(this);

            if (!string.IsNullOrEmpty(res))
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", res, "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }
            AppData.Crew.CrewTypeId = sctPage.SelectedCrewType.Id;

            AppBusyPage.Show("Получение активного заказа...");
            App.ClearTestLog();
            res = await ApiService.GetActiveOrder();

            await App.ShowTestLog(this);

            if (!string.IsNullOrEmpty(res))
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", res, "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }

            Settings.AppState.LastPhone     = PhoneHelper.ValidPhoneNumber(PhoneTB.Text);
            Settings.AppState.LastPin       = PassTB.Text;
            Settings.AppState.LastLoginDate = DateTime.Now;
            Settings.AppState.Save();

            AppBusyPage.Close();
            App.Current.MainPage = new MainPage(PageType.ActiveOrder);

            /*if (AppData.Crew.ActiveOrder != null)
             *  App.Current.MainPage = new MainPage(PageType.ActiveOrder);
             * else
             *  App.Current.MainPage = new MainPage(PageType.FreeOrders);*/
        }
コード例 #24
0
 private static void Call(Player sender, string number)
 {
     try
     {
         PhoneHelper.Call(sender, number);
     }
     catch (Exception e)
     {
         Chat.ErrorChat(sender, "L'appel a échoué : " + e.Message);
     }
 }
コード例 #25
0
 private static void HangUp(Player sender)
 {
     try
     {
         PhoneHelper.HangUp(sender);
     }
     catch (Exception e)
     {
         Chat.ErrorChat(sender, "Le raccrochage a échoué : " + e.Message);
     }
 }
コード例 #26
0
 private static void Number(Player sender)
 {
     try
     {
         PhoneHelper.DisplayPhoneNumber(sender);
     }
     catch (Exception e)
     {
         Chat.ErrorChat(sender, "Le numéro n'a pas pu être affiché : " + e.Message);
     }
 }
コード例 #27
0
        private void btnAddPhone_Click(object sender, RoutedEventArgs e)
        {
            Phone phone = new Phone(textBoxPhoneNumber.Text, textBoxPhoneArea.Text, ((PhoneType)comboBoxPhoneType.SelectedItem).id, comboBoxPhoneType.Text);

            textBoxPhoneNumber.Text = "";
            textBoxPhoneArea.Text   = "";

            phones.Add(phone);

            PhoneHelper.setPhoneGrid(dataGridPhones, phones);
        }
コード例 #28
0
ファイル: Settings.xaml.cs プロジェクト: mroddy/8Pass
        public Settings()
        {
            InitializeComponent();
            lstAutoSyncSettings.Items.Add(Strings.Settings_AutoUpdateInactive);
            lstAutoSyncSettings.Items.Add(Strings.Settings_AutoUpdateActive);
            lstAutoSyncSettings.Items.Add(Strings.Settings_AutoUpdateSWLAN);

            var version = PhoneHelper
                          .GetAppAttribute("Version");

            lblVersion.Text = string.Format(lblVersion.Text, version);
        }
コード例 #29
0
        /// <summary>
        /// 获取验证码
        /// </summary>
        /// <param name="uniacid">商户ID</param>
        /// <param name="phoneNumber">手机号码</param>
        /// <returns></returns>
        public IActionResult GetSmsVerifyCode(string uniacid, string phoneNumber)
        {
            var filter = Builders <VerifyCodeModel> .Filter;
            var mongo  = new MongoDBTool();

            var company = mongo.GetMongoCollection <CompanyModel>().Find(x => x.uniacid.Equals(uniacid)).FirstOrDefault();

            if (company == null || company.YTX == null)
            {
                var em = new ExceptionModel()
                {
                    Content = "商户未设置云通信信息"
                };
                em.Save();
                return(this.JsonErrorStatus());
            }

            var collection = mongo.GetMongoCollection <VerifyCodeModel>();
            var date       = DateTime.Now.AddMinutes(VerifyTimeOut);

            collection.DeleteMany(filter.Lt(x => x.CreateTime, date) & filter.Eq(x => x.uniacid, uniacid));
            var             filterSum = filter.Eq(x => x.PhoneNumber, phoneNumber) & filter.Gt(x => x.CreateTime, date);
            VerifyCodeModel vcm       = collection.FindOneAndDelete(filterSum);

            if (vcm == null)
            {
                vcm = new VerifyCodeModel()
                {
                    PhoneNumber = phoneNumber,
                    CreateTime  = DateTime.Now,
                    uniacid     = uniacid
                };
            }
            string jsonData = JsonConvert.SerializeObject(new SMSModel()
            {
                appid  = company.YTX.AppID,
                mobile = vcm.PhoneNumber,
                datas  = new string[] { vcm.VerifyCode, VerifyTimeOut + "" }
            });
            string url = "/sms/TemplateSMS.wx";

            string result = new PhoneHelper(company.YTX).SendRequest(url, jsonData);
            var    jObj   = (JObject)JsonConvert.DeserializeObject(result);
            JToken statuscode;
            bool   hasVal = jObj.TryGetValue("statusCode", out statuscode);

            if (hasVal && statuscode.ToString().Equals("0"))
            {
                collection.InsertOne(vcm);
                return(this.JsonErrorStatus());
            }
            return(this.JsonErrorStatus());
        }
コード例 #30
0
        public string SendSms(string phone, string body)
        {
            try
            {
                phone = PhoneHelper.NormalizePhone(phone);
            }
            catch (Exception e)
            {
                throw new InvalidPhoneException(e);
            }

            if (!FakeMode)
            {
                var url        = "http://sms.ru/sms/send";
                var parameters = string.Format("api_id={0}&to={1}&text={2}&from={3}", ApiId, phone, body, From);

                var request = WebRequest.Create(url);
                request.ContentType = "application/x-www-form-urlencoded";
                request.Method      = "POST";
                var bytes = Encoding.UTF8.GetBytes(parameters);
                request.ContentLength = bytes.Length;
                using (var requestStream = request.GetRequestStream())
                {
                    requestStream.Write(bytes, 0, bytes.Length);
                    requestStream.Close();
                }

                string answer;
                using (var response = request.GetResponse())
                {
                    using (var streamReader = new StreamReader(response.GetResponseStream()))
                    {
                        answer = streamReader.ReadToEnd().Trim();
                    }
                }

                var lines      = answer.Split(new[] { "\n" }, StringSplitOptions.None);
                var resultCode = Convert.ToInt32(lines[0]);

                if (resultCode != 100)
                {
                    throw new SendSmsException(resultCode);
                }

                var externalId = lines[1];

                return(externalId);
            }
            else
            {
                return(Guid.NewGuid().ToString());
            }
        }