コード例 #1
0
 private async Task LoadDataAsync(string search = "")
 {
     try
     {
         Invoke(new MethodInvoker(async() =>
         {
             var list = await PhoneBookBussines.GetAllAsync(ParentGuid, search, (EnPhoneBookGroup)cmbGroup.SelectedIndex);
             phoneBookBindingSource.DataSource =
                 list.Where(q => q.Status == _st).OrderBy(q => q.Name).ToSortableBindingList();
         }));
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
コード例 #2
0
 private async Task LoadDataAsync(string search = "")
 {
     try
     {
         if (list.Count <= 0)
         {
             list = await PhoneBookBussines.GetAllAsync(parentGuid, search,
                                                        (EnPhoneBookGroup)cmbGroup.SelectedIndex);
         }
         list = list.Where(q => q.Status).ToList();
         LoadData_(parentGuid, search, (EnPhoneBookGroup)cmbGroup.SelectedIndex);
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
コード例 #3
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);
        }