Exemplo n.º 1
0
        private async void UpdateStatus(List <string> lstMessageId)
        {
            try
            {
                var api     = new Sms.Api(cls.API.Trim());
                var resList = api.Status(lstMessageId);

                foreach (var item in resList)
                {
                    var log = await SmsLogBussines.GetAsync(item.Messageid);

                    if (log == null)
                    {
                        continue;
                    }
                    log.StatusText = item.Statustext;
                    await SmsLogBussines.SaveAsync(log);
                    await LoadDataAsync();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 2
0
        private async void mnuRemain_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }

                var ret = await Utilities.PingHostAsync();

                if (ret.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(ret.ErrorMessage);
                    return;
                }


                var guid  = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var panel = await SmsPanelsBussines.GetAsync(guid);

                if (panel == null)
                {
                    return;
                }

                var api = new Sms.Api(panel.API.Trim());
                var res = api.AccountInfo();

                MessageBox.Show(this, $"مانده حساب پنل {panel.Name} {res.RemainCredit} ریال می باشد");
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 3
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                var ret = await Utilities.PingHostAsync();

                if (ret.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(ret.ErrorMessage);
                    return;
                }


                if (lbxNumbers.Items.Count <= 0)
                {
                    frmNotification.PublicInfo.ShowMessage("هیچ شماره ای جهت ارسال، وارد نشده است");
                    txtNumber.Focus();
                    return;
                }
                if (string.IsNullOrWhiteSpace(txtMessage.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("متن پیام ارسالی نمی تواند خالی باشد");
                    txtMessage.Focus();
                    return;
                }

                var list = new List <string>();
                foreach (var item in lbxNumbers.Items)
                {
                    list.Add(item.ToString());
                }

                var panel = SmsPanelsBussines.Get((Guid)cmbPanel.SelectedValue);
                if (panel == null)
                {
                    return;
                }
                var sApi = new Sms.Api(panel.API.Trim());

                var index = 0;
                var frm   = new frmSplash(list.Count);
                frm.Show(this);

                var res = sApi.Send(panel.Sender, list, txtMessage.Text);

                if (res.Count <= 0)
                {
                    return;
                }
                foreach (var result in res)
                {
                    frm.Level = index;
                    var smsLog = new SmsLogBussines()
                    {
                        Guid       = Guid.NewGuid(),
                        UserGuid   = UserBussines.CurrentUser.Guid,
                        Cost       = result.Cost,
                        Message    = result.Message,
                        MessageId  = result.Messageid,
                        Reciver    = result.Receptor,
                        Sender     = result.Sender,
                        StatusText = result.StatusText
                    };

                    await smsLog.SaveAsync();

                    index++;
                }

                frmNotification.PublicInfo.ShowMessage("ارسال پیامک با موفقیت انجام شد");

                Close();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 4
0
        private async Task BackUpAsync(string path, bool isAuto, EnBackUpType type)
        {
            try
            {
                if (!isAuto)
                {
                    if (string.IsNullOrEmpty(clsBackUp.BackUpOpen) || !clsBackUp.BackUpOpen.ParseToBoolean())
                    {
                        return;
                    }
                    path = Path.Combine(path, "AradBackUp");
                }

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                var file = Path.GetFileName(Assembly.GetEntryAssembly()?.Location)
                           ?.Replace(".exe", "__");
                var d = Calendar.MiladiToShamsi(DateTime.Now).Replace("/", "_");
                d    += "__" + DateTime.Now.Hour + " - " + DateTime.Now.Minute;
                file += d;
                file  = file.Replace(" ", "");
                var newPath = Path.Combine(path, file + ".NPZ2");
                await DataBaseUtilities.DataBase.BackUpStartAsync(this, AppSettings.DefaultConnectionString,
                                                                  ENSource.Building, type,
                                                                  newPath);

                if (isAuto)
                {
                    if (!string.IsNullOrEmpty(clsBackUp.BackUpSms) && clsBackUp.BackUpSms.ParseToBoolean() &&
                        VersionAccess.Sms)
                    {
                        if (string.IsNullOrEmpty(Settings.Classes.Payamak.DefaultPanelGuid))
                        {
                            return;
                        }
                        var text = $"مدیریت محترم مجموعه {clsEconomyUnit.EconomyName ?? ""} \r\n" +
                                   $"{clsEconomyUnit.ManagerName ?? ""} عزیز \r\n" +
                                   $"در تاریخ {Calendar.MiladiToShamsi(DateTime.Now)} \r\n" +
                                   $"و در ساعت {DateTime.Now.ToShortTimeString()} \r\n" +
                                   $"پشتیبان گیری خودکار از داده ها انجام شد \r\n" +
                                   $"باتشکر \r\n" +
                                   $"گروه مهندسی آراد";

                        var panel = SmsPanelsBussines.Get(Guid.Parse(Settings.Classes.Payamak.DefaultPanelGuid));
                        if (panel == null)
                        {
                            return;
                        }

                        var sApi = new Sms.Api(panel.API.Trim());


                        var result = sApi.Send(panel.Sender, clsEconomyUnit.ManagerMobile ?? "", text);

                        var smsLog = new SmsLogBussines()
                        {
                            Guid       = Guid.NewGuid(),
                            UserGuid   = UserBussines.CurrentUser?.Guid ?? Guid.Empty,
                            Cost       = result.Cost,
                            Message    = result.Message,
                            MessageId  = result.Messageid,
                            Reciver    = result.Receptor,
                            Sender     = result.Sender,
                            StatusText = result.StatusText
                        };

                        await smsLog.SaveAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 5
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid = Guid.NewGuid();
                }

                if (string.IsNullOrWhiteSpace(txtPass1.Text))
                {
                    res.AddError("کلمه عبور نمی تواند خالی باشد");
                    txtPass1.Focus();
                }

                if (string.IsNullOrWhiteSpace(txtPass2.Text))
                {
                    res.AddError("تکرار کلمه عبور نمی تواند خالی باشد");
                    txtPass2.Focus();
                }

                if (txtPass1.Text != txtPass2.Text)
                {
                    res.AddError("کلمه عبور با تکرار آن همخوانی ندارد");
                    txtPass1.Focus();
                }

                if (res.HasError)
                {
                    return;
                }
                var ue        = new UTF8Encoding();
                var bytes     = ue.GetBytes(txtPass1.Text.Trim());
                var md5       = new MD5CryptoServiceProvider();
                var hashBytes = md5.ComputeHash(bytes);
                cls.Password = System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(hashBytes), "-", "")
                               .ToLower();

                res.AddReturnedValue(await cls.SaveAsync());
                if (res.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                    return;
                }

                var text = $"کاربر گرامی: {cls?.Name} عزیز " +
                           $"\r\n در تاریخ {Calendar.MiladiToShamsi(DateTime.Now)} رمز ورود به سیستم شما تعویض شد" +
                           $"\r\n گروه مهندسی آراد";

                if (_type != 0)
                {
                    return;
                }
                if (string.IsNullOrEmpty(Settings.Classes.Payamak.DefaultPanelGuid))
                {
                    return;
                }

                var panel = SmsPanelsBussines.Get(Guid.Parse(Settings.Classes.Payamak.DefaultPanelGuid));
                if (panel == null)
                {
                    return;
                }

                var sApi = new Sms.Api(panel.API.Trim());


                var result = sApi.Send(panel.Sender, cls?.Mobile ?? "", text);

                var smsLog = new SmsLogBussines()
                {
                    Guid       = Guid.NewGuid(),
                    UserGuid   = cls?.Guid ?? Guid.Empty,
                    Cost       = result.Cost,
                    Message    = result.Message,
                    MessageId  = result.Messageid,
                    Reciver    = result.Receptor,
                    Sender     = result.Sender,
                    StatusText = result.StatusText
                };

                res.AddReturnedValue(await smsLog.SaveAsync());
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
                res.AddReturnedValue(exception);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ثبت رمز عبور کاربر");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Exemplo n.º 6
0
        public static async Task <ReturnedSaveFuncInfo> SendAsync(BuildingRequestBussines bu)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                res.AddReturnedValue(await Utilities.PingHostAsync());
                if (res.HasError)
                {
                    return(res);
                }


                var text = Text(bu);
                if (string.IsNullOrEmpty(text))
                {
                    res.AddReturnedValue(ReturnedState.Error, "متن پیش فرض خالی می باشد");
                    return(res);
                }

                if (string.IsNullOrEmpty(Settings.Classes.Payamak.DefaultPanelGuid))
                {
                    res.AddReturnedValue(ReturnedState.Error, "پنل پبش فرض تعریف نشده است");
                    return(res);
                }

                var panel = SmsPanelsBussines.Get(Guid.Parse(Settings.Classes.Payamak.DefaultPanelGuid));
                if (panel == null)
                {
                    res.AddReturnedValue(ReturnedState.Error, "پنل پیش فرض معتبر نمی باشد");
                    return(res);
                }

                var sApi = new Sms.Api(panel.API.Trim());

                var list = new List <string>();
                var pe   = await PhoneBookBussines.GetAllAsync(bu.AskerGuid, true);

                foreach (var item in pe)
                {
                    list.Add(item.Tell);
                }

                var res_ = sApi.Send(panel.Sender, list, text);
                if (res_.Count <= 0)
                {
                    res.AddReturnedValue(ReturnedState.Error, "ارتباط با پنل با شکست مواجه شد");
                    return(res);
                }

                foreach (var result in res_)
                {
                    var smsLog = new SmsLogBussines()
                    {
                        Guid       = Guid.NewGuid(),
                        UserGuid   = UserBussines.CurrentUser.Guid,
                        Cost       = result.Cost,
                        Message    = result.Message,
                        MessageId  = result.Messageid,
                        Reciver    = result.Receptor,
                        Sender     = result.Sender,
                        StatusText = result.StatusText
                    };

                    await smsLog.SaveAsync();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }