public bool Add(string name, string syntax)
    {
        try
        {
            if (CheckExistedSmsName(-1, name, syntax)) return false;

            var o = new SmsType {Name = name, Syntax = syntax};
            db.SmsTypes.InsertOnSubmit(o);
            db.SubmitChanges();
            return true;
        }
        catch
        {
            return false;
        }
    }
    protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
    {
        var editableItem = ((GridEditableItem)e.Item);
        SmsType S = new SmsType();
        Hashtable values = new Hashtable();
        editableItem.ExtractValues(values);
        
        try
        {
            var smsName = values["Name"] as string;
            var syntax = values["Syntax"] as string;

            if (string.IsNullOrEmpty(syntax) && string.IsNullOrEmpty(smsName))
            {
                ShowErrorMessage(Pharma.Provide_info_to_insert__please);
                e.Canceled = true;
            }
            else
            {
                if (smsName == null || string.IsNullOrEmpty(smsName.Trim())
                    || syntax == null || string.IsNullOrEmpty(syntax.Trim()))
                {
                    ShowErrorMessage(Pharma.Provide_full_name_to_save__please);
                    e.Canceled = true;
                }
                else
                {
                    var result = repo.Add(smsName, syntax);
                    if (!result)
                    {
                        ShowErrorMessage("SMS Type and Syntax are unique, please choose another one.");
                        e.Canceled = true;
                    }
                }
            }
        }
        catch (System.Exception ex)
        {
            ShowErrorMessage(Pharma.Administrator_Default_RadGrid1_InsertCommand_can_not_add__please_try_again_later_or_contact_admnistrator_);
            e.Canceled = true;
        }
    }
Beispiel #3
0
    /// <summary>
    /// 群发短信息
    /// </summary>
    /// <param name="personnumber">人员编码列表</param>
    /// <param name="content">短信内容</param>
    /// <param name="type">发送类型</param>
    /// <param name="msgid">隐患,三违,走动等ID信息。需要就写入。</param>
    /// <param name="sender">发送者</param>
    /// <returns>成功返回"1"</returns>
    public static string Send(List <string> personnumber, string content, string msgid, SmsType type, string sender)
    {
        string msg;
        string failmsg = "";
        int    success = 0;
        int    failure = 0;

        foreach (string p in personnumber)
        {
            msg = Send(p, content, type, msgid, sender);
            if (msg == "1")
            {
                success++;
            }
            else if (msg == "0")
            {
                failure++;
            }
            else
            {
                failure++;
                failmsg += msg + "\n";
            }
        }
        if (failure > 0)
        {
            return("共有" + failure + "条短信发送失败!原因如下:\n" + failmsg);
        }
        else
        {
            return("1");
        }
    }
Beispiel #4
0
    /// <summary>
    /// 发送短信息
    /// </summary>
    /// <param name="personnumber">人员编码</param>
    /// <param name="content">短信内容</param>
    /// <param name="type">发送类型</param>
    /// <param name="msgid">隐患,三违,走动等ID信息。需要就写入。</param>
    /// <param name="sender">发送者</param>
    /// <returns>成功返回"1"</returns>
    public static string Send(string personnumber, string content, SmsType type, string msgid, string sender)
    {
        string phone = GetPhone(personnumber).Trim() == "" ? "0" : GetPhone(personnumber);

        if (VerifyNumber(phone))
        {
            DBSCMDataContext dc  = new DBSCMDataContext();
            TblSmsendtask    sms = new TblSmsendtask();
            sms.Count            = 1;
            sms.Creatorid        = "000";
            sms.Destaddr         = phone;
            sms.Destaddrtype     = 0;
            sms.Feecode          = 0;
            sms.Feetype          = "01";
            sms.Messageid        = 0;
            sms.Msgid            = "";
            sms.Needstatereport  = 0;
            sms.Operationtype    = "WAS";
            sms.Orgaddr          = "1065730615390000";
            sms.Reserve1         = "";
            sms.Reserve2         = "";
            sms.Sendlevel        = 0;
            sms.Sendstate        = 0;
            sms.Sendtime         = DateTime.Now.AddSeconds(2);
            sms.Sendtype         = 1;
            sms.Serviceid        = "MAH0510101";
            sms.SmContent        = GetSmsType(type) + content + "\n" + sender;
            sms.Smsendednum      = 0;
            sms.Smtype           = 0;
            sms.Suboperationtype = 66;
            sms.Subtime          = DateTime.Now;
            sms.Successid        = 0;
            sms.Taskname         = "";
            sms.Taskstatus       = 0;
            sms.Trytimes         = 3;
            string strSql = "INSERT INTO [tbl_SMSendTask]( [CreatorID], [TaskName], [SmSendedNum], [OperationType], [SuboperationType], [SendType], [OrgAddr], [DestAddr],  [SM_Content], [SendTime], [NeedStateReport], [ServiceID], [FeeType], [FeeCode], [MsgID], [SMType], [MessageID], [DestAddrType], [SubTime], [TaskStatus],  [SendLevel], [SendState], [TryTimes], [Count], [SuccessID], [Reserve1], [Reserve2]) values ('" + sms.Creatorid + "','" + sms.Taskname + "'," + sms.Smsendednum.Value.ToString() + ",'" + sms.Operationtype + "'," + sms.Suboperationtype.Value.ToString() + "," + sms.Sendtype.Value.ToString() + ",'" + sms.Orgaddr + "','" + sms.Destaddr + "','" + sms.SmContent + "','" + sms.Sendtime.Value + "'," + sms.Needstatereport.Value.ToString() + ",'" + sms.Serviceid + "','" + sms.Feetype + "'," + sms.Feecode.Value.ToString() + ",'" + sms.Msgid + "'," + sms.Smtype.Value.ToString() + "," + sms.Messageid.Value.ToString() + "," + sms.Destaddrtype.Value.ToString() + ",'" + sms.Subtime.Value + "'," + sms.Taskstatus.Value.ToString() + "," + sms.Sendlevel.Value.ToString() + "," + sms.Sendstate.Value.ToString() + "," + sms.Trytimes.Value.ToString() + "," + sms.Count.Value.ToString() + "," + sms.Successid.Value.ToString() + ",'" + sms.Reserve1 + "','" + sms.Reserve2 + "')";
            try
            {
                if (SQLHelper.ExecuteSql(strSql) >= 1)
                {
                    sms.Successid = 1;
                    sms.Taskname  = GetSmsType(type);
                    sms.Msgid     = msgid;
                    dc.TblSmsendtask.Insert(sms);
                    dc.SubmitChanges();
                    return("1");
                }
                else
                {
                    dc.TblSmsendtask.Insert(sms);
                    dc.SubmitChanges();
                    return("0");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
        else
        {
            return("非法的手机号码!");
        }
    }
Beispiel #5
0
 partial void DeleteSmsType(SmsType instance);
Beispiel #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="appSign"></param>
 /// <param name="mobile"></param>
 /// <param name="parms"></param>
 /// <param name="content"></param>
 /// <param name="smsType"></param>
 /// <param name="funcType"></param>
 public void SendSmsMsg(string appSign, string mobile, Dictionary <string, object> parms, string content, SmsType smsType, SmsFuncType funcType)
 {
     service.SendSmsMessage(appSign, mobile, parms, content, smsType, funcType);
 }
Beispiel #7
0
 partial void InsertSmsType(SmsType instance);
Beispiel #8
0
 partial void UpdateSmsType(SmsType instance);
Beispiel #9
0
 public SendSmsResponse SendAnSms(string @from, string to, string text, SmsType type = SmsType.text, Credentials creds = null) =>
 throw new System.NotImplementedException();
Beispiel #10
0
 public Task <SendSmsResponse> SendAnSmsAsync(string from, string to, string text, SmsType type = SmsType.text, Credentials creds = null)
 {
     _logger.LogInformation($"SMS sent from {from} to {to} with text: {text}");
     return(Task.FromResult(new SendSmsResponse()));
 }
Beispiel #11
0
 public SmsSender To(string number)
 {
     _smsType = SmsType.Private;
     return To(new string[] { number });
 }
Beispiel #12
0
 public SmsSender To(string[] numbers)
 {
     _smsType = SmsType.Public;
     _numbers = numbers;
     return this;
 }
Beispiel #13
0
 public SendSmsResponse SendAnSms(string from, string to, string text, SmsType type = SmsType.text, Credentials creds = null)
 {
     return(SendAnSms(new SendSmsRequest {
         From = from, To = to, Type = type, Text = text
     }, creds));
 }