コード例 #1
0
ファイル: frmPanel.cs プロジェクト: Majidkhackpour/Advertise
        private async void mnuDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount == 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var accGuid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var Acc     = await PanelBussines.GetAsync(accGuid);

                var message = "آیا از حذف پنل " + Acc.Name + " " + "اطمینان دارید؟";

                if (FarsiMessegeBox.Show(message, "حذف", FMessegeBoxButtons.YesNo, FMessegeBoxIcons.Question) !=
                    DialogResult.Yes)
                {
                    return;
                }
                Acc = PanelBussines.Change_Status(accGuid, false);
                await Acc.SaveAsync();
                await LoadData();
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }
コード例 #2
0
ファイル: frmPanel.cs プロジェクト: Majidkhackpour/Advertise
 private void mnuIns_Click(object sender, EventArgs e)
 {
     try
     {
         cls = new PanelBussines();
         grpAccount.Enabled        = true;
         expandablePanel1.Expanded = true;
     }
     catch (Exception exception)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(exception);
     }
 }
コード例 #3
0
        private async Task LoadPanels()
        {
            try
            {
                var list = await PanelBussines.GetAllAsync();

                list = list.Where(q => q.Status).OrderBy(q => q.Name).ToList();
                PanelBindingSource.DataSource = list;
            }
            catch (Exception e)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(e);
            }
        }
コード例 #4
0
        public static async Task SendSMS(string reciver, string text)
        {
            try
            {
                var a   = SettingBussines.GetAll();
                var cls = a.Count > 0 ? a[0] : new SettingBussines();
                if (cls.PanelGuid == null || cls.PanelGuid == Guid.Empty)
                {
                    return;
                }
                if (cls.LineNumberGuid == null || cls.LineNumberGuid == Guid.Empty)
                {
                    return;
                }
                var panel = await PanelBussines.GetAsync(cls.PanelGuid ?? Guid.Empty);

                var line = await PanelLineNumberBussines.GetAsync(cls.LineNumberGuid ?? Guid.Empty);

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(panel.API);

                    var content = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("Action", SMSAction.Send.Value),
                        new KeyValuePair <string, string>("username", panel.UserName),
                        new KeyValuePair <string, string>("password", panel.Password),
                        new KeyValuePair <string, string>("type", ((int)SMSType.SMS).ToString()),
                        new KeyValuePair <string, string>("from", line.LineNumber.ToString()),
                        new KeyValuePair <string, string>("text", text),
                        new KeyValuePair <string, string>("receivers", reciver),
                    });
                    var result = await client.PostAsync(client.BaseAddress, content);

                    var resultContent = await result.Content.ReadAsStringAsync();
                }
            }
            catch (Exception e)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(e);
            }
        }
コード例 #5
0
ファイル: frmPanel.cs プロジェクト: Majidkhackpour/Advertise
        private async void mnuEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                cls = await PanelBussines.GetAsync(guid);
                await SetData();

                grpAccount.Enabled        = true;
                expandablePanel1.Expanded = true;
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }
コード例 #6
0
        private async Task Send()
        {
            try
            {
                PanelBussines panel = null;
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(async() => panel = await PanelBussines.GetAsync((Guid)cmbPanel.SelectedValue)));
                }
                else
                {
                    panel = await PanelBussines.GetAsync((Guid)cmbPanel.SelectedValue);
                }
                if (panel == null)
                {
                    return;
                }
                var list = new List <string>();
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(() =>
                    {
                        foreach (var item in lbxNumbers.Items)
                        {
                            list.Add(item.ToString());
                        }
                    }));
                }
                else
                {
                    foreach (var item in lbxNumbers.Items)
                    {
                        list.Add(item.ToString());
                    }
                }

                var  api      = panel.API;
                var  action   = SMSAction.Send.Value;
                var  userName = panel.UserName;
                var  passWord = panel.Password;
                var  type     = SMSType.SMS;
                long from     = 0;
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(() => from = cmbLineNumber.Text.ParseToLong()));
                }
                else
                {
                    from = cmbLineNumber.Text.ParseToLong();
                }
                string text = null;
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(() => text = txtMessage.Text));
                }
                else
                {
                    text = txtMessage.Text;
                }
                await SMS.SendSMSList(list, api, action, userName, passWord, (int)type, from, text);
            }
            catch (Exception e)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(e);
            }
        }