Beispiel #1
0
        public static string Send(string[] msg, string number = "15802600278")
        {
            string ret = null;

            CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK();
            //ip格式如下,不带https://
            bool isInit = api.init("app.cloopen.com", "8883"); //  生产) Rest URL:https://app.cloopen.com:8883   测试sandboxapp.cloopen.com

            api.setAccount("aaf98f894e2360b4014e32c97baf0d57", "0740a208144f4fa3a5b38666da37acb9");
            api.setAppId("8a48b55153cb69470153e5b9ee1e255b");

            try
            {
                if (isInit)
                {
                    Dictionary <string, object> retData = api.SendTemplateSMS(number, "78674", msg);
                    ret = getDictionaryData(retData);
                }
                else
                {
                    ret = "初始化失败";
                }
            }
            catch (Exception exc)
            {
                ret = exc.Message;
            }

            return(ret);
        }
Beispiel #2
0
        public Result <dynamic> Send(string mobile, byte smsType)
        {
            int smsCode = GenerateSMSCode();
            var entity  = new SmsModel()
            {
                MobilePhone = mobile,
                SmsType     = smsType,
                SmsCode     = smsCode,
                SmsStatus   = 0,
                ExpireTime  = DateTime.Now.AddMinutes(10),
                CreateTime  = DateTime.Now
            };

            if (SmsRepository.Add(entity))
            {
                var account_id    = ConfigurationManager.AppSettings["SMS_Account_Sid"];
                var account_token = ConfigurationManager.AppSettings["SMS_Account_Token"];
                var app_Id        = ConfigurationManager.AppSettings["SMS_App_Id"];

                string result = string.Empty;

                CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK();
                bool init = api.init("sandboxapp.cloopen.com", "8883");
                api.setAccount(account_id, account_token);
                api.setAppId(app_Id);
                try
                {
                    if (init)
                    {
                        string[] param = { smsCode.ToString(), "10分钟" };
                        Dictionary <string, object> retApiData = api.SendTemplateSMS(mobile, "125246", param);
                        result = GetDictionaryData(retApiData);
                    }
                    else
                    {
                        return(new Result <dynamic>()
                        {
                            Code = ResultCode.Error,
                            Message = "初始化失败"
                        });
                    }
                }
                catch { }
                if (result.ToLower().Contains("statuscode=000000;statusmsg=成功"))
                {
                    /* 调用短信接口发送短信验证码 */
                    return(new Result <dynamic>()
                    {
                        Code = ResultCode.Success,
                        Message = "验证码发送成功"
                    });
                }
            }
            return(new Result <dynamic>()
            {
                Code = ResultCode.Error,
                Message = "验证码发送失败"
            });
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ret = null;

            CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK();
            //ip格式如下,不带https://
            bool isInit = api.init("sandboxapp.cloopen.com", "8883");
            api.setAccount("8a48b5514d32a2a8014d89972a303d91", "97b599886b6841c18c772040c960ea1e");
            api.setAppId("aaf98f894d7439d8014d8998e0760dfe");

            try
            {
                if (isInit)
                {
                    Dictionary<string, object> retData = api.CreateSubAccount("testff30");

                    List<string> list = new List<string>();
                    list.Add("dateCreated");
                    list.Add("subAccountSid");
                    list.Add("subToken");
                    list.Add("voipAccount");
                    list.Add("voipPwd");
                    KV kv = new KV(retData, list);
                    if (kv.isVerify())
                    {
                        ret = kv.getKvv();
                    }
                    else
                    {
                       ret = getDictionaryData(retData);
                    }
                }
                else
                {
                    ret = "初始化失败";
                }
            }
            catch (Exception exc)
            {
                ret = exc.Message;
            }
            finally
            {
                Response.Write(ret);
            }
        }
Beispiel #4
0
    public string call(string from,string to,string other,string me)
    {
        CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK();

        //ip格式如下,不带https://
        bool isInit = api.init(RESTADDRESS, RESTPORT);
        //api.setAccount(ACCOUNTSID, ACCOUNTTOKEN);
        api.setSubAccount(ACCOUNTSID, ACCOUNTTOKEN, "80000300592148", "eRuJZAO8");
        api.setAppId(APPID);
        Dictionary<string, object> retData = api.CallBack(from, to, other, me, "");
        List<string> list = new List<string>();
        list.Add("statusCode");
        list.Add("statusMsg");
        KV kv = new KV(retData, list);
        if (kv.IsVerify())
        {
            return kv.GetKvv();
        }
        return "error";
    }
Beispiel #5
0
        public async Task <IHttpActionResult> GetSmsCode([FromBody] string PhoneNumber)
        {
            var result = new ApiResult <string>();

            CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK();
            //ip格式如下,不带https://
            bool isInit = api.init("app.cloopen.com", "8883");

            api.setAccount("8aaf0708588b1d2301588ff10eb00346", "3e902b274a844cb899b672bcaf4fde2f");
            api.setAppId("8aaf0708588b1d2301588ff10f16034b");

            var expireMin  = 10;
            var expireTime = DateTime.Now.AddMinutes(expireMin);

            //1分钟内不允许再次发送
            var limitTime      = DateTime.Now.AddMinutes(-1);
            var hasSendInLimit = SmsCodeService.GetAll().Count(x => x.PhoneNumber == PhoneNumber && x.CreateTime > limitTime) > 0;

            if (hasSendInLimit)
            {
                result.Code = 3;
                result.Info = "短信已发送给您,请耐心等待!";
                return(Ok(result));
            }

            var smsCode = new SmsCode()
            {
                Code        = getRandCode(6),
                CodeType    = CodeType.Register,
                CreateTime  = DateTime.Now,
                ExpireTime  = expireTime,
                PhoneNumber = PhoneNumber
            };

            try
            {
                if (isInit)
                {
                    Dictionary <string, object> retData = api.SendTemplateSMS(PhoneNumber, "1", new string[] { smsCode.Code, expireMin.ToString() });

                    if (retData["statusCode"].ToString() == "000000")
                    {
                        await SmsCodeService.InsertAsync(smsCode);
                    }
                }
                else
                {
                    result.Code = 2;
                    result.Info = "短信验证码服务,初始化失败!";
                    return(Ok(result));
                }
            }
            catch (Exception exc)
            {
                result.Code = 1;
                result.Info = exc.Message;
                return(Ok(result));
            }

            result.Info = "短信发送成功";
            result.Data = "success";
            return(Ok(result));
        }
Beispiel #6
0
 protected void btn_Sub_Click(object sender, EventArgs e)
 {
     //判断是否超过最大用户限制
     if(ZWL.Common.PublicMethod.IFExists("UserName", "ERPUser", 0, this.TextBox1.Text) == true) {
         if(ZWL.Common.PublicMethod.IFExists("Serils", "ERPUser", 0, this.TextBox4.Text) == true) {
             ZWL.BLL.ERPUser MyBuMen = new ZWL.BLL.ERPUser();
             MyBuMen.UserName = this.TextBox1.Text;
             MyBuMen.UserPwd = ZWL.Common.DEncrypt.DESEncrypt.Encrypt(this.TextBox2.Text);
             MyBuMen.TrueName = this.TextBox3.Text;
             MyBuMen.Serils = this.TextBox4.Text;
             MyBuMen.Department = this.TextBox5.Text;
             MyBuMen.JiaoSe = this.TextBox6.Text;
             MyBuMen.ZhiWei = this.TextBox7.Text;
             MyBuMen.ZaiGang = this.TextBox8.Text;
             MyBuMen.EmailStr = this.TextBox9.Text;
             MyBuMen.IfLogin = this.RadioButtonList1.SelectedItem.Text;
             MyBuMen.Sex = this.TextBox10.Text;
             MyBuMen.BackInfo = this.TextBox11.Text;
             //MyBuMen.BirthDay = this.TextBox12.Text;
             //MyBuMen.MingZu = this.TextBox13.Text;
             //MyBuMen.SFZSerils = this.TextBox14.Text;
             //MyBuMen.HunYing = this.TextBox15.Text;
             //MyBuMen.ZhengZhiMianMao = this.TextBox16.Text;
             //MyBuMen.JiGuan = this.TextBox17.Text;
             //MyBuMen.HuKou = this.TextBox18.Text;
             //MyBuMen.XueLi = this.TextBox19.Text;
             //MyBuMen.ZhiCheng = this.TextBox20.Text;
             //MyBuMen.BiYeYuanXiao = this.TextBox21.Text;
             //MyBuMen.ZhuanYe = this.TextBox22.Text;
             //MyBuMen.CanJiaGongZuoTime = this.TextBox23.Text;
             //MyBuMen.JiaRuBenDanWeiTime = this.TextBox24.Text;
             MyBuMen.JiaTingDianHua = this.TextBox25.Text;
             //MyBuMen.JiaTingAddress = this.TextBox26.Text;
             //MyBuMen.GangWeiBianDong = this.TextBox27.Text;
             //MyBuMen.JiaoYueBeiJing = this.TextBox28.Text;
             //MyBuMen.GongZuoJianLi = this.TextBox29.Text;
             //MyBuMen.SheHuiGuanXi = this.TextBox30.Text;
             //MyBuMen.JiangChengJiLu = this.TextBox31.Text;
             //MyBuMen.ZhiWuQingKuang = this.TextBox32.Text;
             //MyBuMen.PeiXunJiLu = this.TextBox33.Text;
             //MyBuMen.DanBaoJiLu = this.TextBox34.Text;
             //MyBuMen.NaoDongHeTong = this.TextBox35.Text;
             //MyBuMen.SheBaoJiaoNa = this.TextBox36.Text;
             //MyBuMen.TiJianJiLu = this.TextBox37.Text;
             //MyBuMen.BeiZhuStr = this.TextBox38.Text;
             MyBuMen.FuJian = ZWL.Common.PublicMethod.GetSessionValue("WenJianList");
             int UserID = MyBuMen.Add();
             #region 生成Voip
             string ACCOUNT_SID = "aaf98f894ff91386014ffacfd8ca02c4";
             string AUTH_TOKEN = "89a0d9b29af1480e96ec8e23486e7ee7";
             string APP_ID = "8a48b5514ff923b4014ffad344e40684";
             string ret = null;
             CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK();
             ZWL.BLL.ERPUser User = new ZWL.BLL.ERPUser();
             ZWL.BLL.AccountInfo AccountInfo = new ZWL.BLL.AccountInfo();
             //ip格式如下,不带https://
             if(UserID > 0) {
                 bool isInit = api.init("app.cloopen.com", "8883");
                 api.setAccount(ACCOUNT_SID, AUTH_TOKEN);
                 api.setAppId(APP_ID);
                 try {
                     if(isInit) {
                         Dictionary<string, object> retData = api.CreateSubAccount(this.TextBox1.Text);
                         ret = getDictionaryData(retData);
                     }
                     else {
                         ret = "初始化失败";
                     }
                 }
                 catch(Exception exc) {
                     ret = exc.Message;
                 }
                 finally {
                     BLLHelper.PassDataInsert passData = JsonHelper.JsonToObject<BLLHelper.PassDataInsert>(ret);
                     if(passData.statusCode != "111150") {
                         string voip = passData.SubAccount.voipAccount;
                         string subAccountSid = passData.SubAccount.subAccountSid;
                         User.ID = UserID;
                         User.VoipAccount = passData.SubAccount.voipAccount;
                         User.AddVoip();
                         AccountInfo.CreateDate = DateTime.Now;
                         AccountInfo.DateCreated = Convert.ToDateTime(passData.SubAccount.dateCreated);
                         AccountInfo.VoipAccount = passData.SubAccount.voipAccount;
                         AccountInfo.VoipPwd = passData.SubAccount.voipPwd;
                         AccountInfo.SubAccountSid = passData.SubAccount.subAccountSid;
                         AccountInfo.SubToken = passData.SubAccount.subToken;
                         AccountInfo.Add();
                     }
                 }
             }
             #endregion
             //写系统日志
             ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
             MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName");
             MyRiZhi.DoSomething = "用户添加新用户(" + this.TextBox1.Text + ")";
             MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
             MyRiZhi.Add();
             Response.Write("<script>alert('用户信息添加成功!');window.location.href='SystemUser.aspx';</script>");
             //ZWL.Common.MessageBox.ShowAndRedirect(this, "用户信息添加成功!", "SystemUser.aspx");
         }
         else {
             Response.Write("<script>alert('该用户编号已经存在,请更改其他用户编号!');</script>");
             //ZWL.Common.MessageBox.Show(this, "该用户编号已经存在,请更改其他用户编号!");
         }
     }
     else {
         Response.Write("<script>alert('该用户名已经存在,请更改其他用户名!');</script>");
         //ZWL.Common.MessageBox.Show(this, "该用户名已经存在,请更改其他用户名!");
     }
 }