Example #1
0
        protected void btnSaveSPChannel_Click(object sender, AjaxEventArgs e)
        {
            if (SPChannelWrapper.GetChannelByPath(this.txtFuzzyCommand.Text.Trim()) != null)
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess      = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = "错误信息:提交别名已存在!";
                return;
            }


            string loginID = "default" + this.txtFuzzyCommand.Text.Trim();

            if (SystemUserWrapper.GetUserByLoginID(loginID) != null)
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess      = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = "错误信息:用户登录ID已存在!";
                return;
            }

            try
            {
                SPChannelWrapper obj = new SPChannelWrapper();
                obj.Name                  = this.txtName.Text.Trim();
                obj.Description           = obj.Name;
                obj.Area                  = "";
                obj.ChannelCode           = this.txtChannelCode.Text.Trim();
                obj.FuzzyCommand          = this.txtFuzzyCommand.Text.Trim();
                obj.Port                  = "";
                obj.ChannelType           = "";
                obj.Price                 = 0;
                obj.Rate                  = 0;
                obj.ChannelCodeParamsName = "cpid";
                obj.IsAllowNullLinkID     = chkIsAllowNullLinkID.Checked;
                obj.Status                = 0;
                obj.CreateTime            = System.DateTime.Now;
                obj.CreateBy              = this.ParentPage.CurrentLoginUser.UserID;
                obj.OkMessage             = "ok";
                obj.FailedMessage         = "failed";
                obj.RecStatReport         = false;
                obj.StatParamsName        = "";
                obj.StatParamsValues      = "";
                obj.IsDisable             = false;

                Uri url = new Uri(obj.InterfaceUrl);

                string fileName = Path.GetFileName(url.AbsolutePath);

                string saveivrPath = HttpContext.Current.Server.MapPath("~/SPSInterface/") + fileName;

                if (obj.FuzzyCommand.ToLower().EndsWith("ivr"))
                {
                    if (!File.Exists(saveivrPath))
                    {
                        File.WriteAllText(saveivrPath, "", Encoding.UTF8);
                    }
                }


                Membership.CreateUser(loginID, "123456", loginID + "@163.com");

                SystemUserWrapper clientUser = SystemUserWrapper.GetUserByLoginID(loginID);

                clientUser.UserName = loginID;

                SystemUserWrapper.Update(clientUser);

                SystemRoleWrapper clientRole = SystemRoleWrapper.GetRoleByName("SPDownUser");

                SystemUserWrapper.PatchAssignUserRoles(clientUser, new List <string> {
                    clientRole.RoleID.ToString()
                });

                //SPChannelWrapper.QuickAddIVR();
                SPChannelWrapper.QuickAddIVR(obj, this.txtLinkParamsName.Text.Trim(),
                                             this.txtMobileParamsName.Text.Trim(), this.txtSPcodeParamsName.Text.Trim()
                                             , this.txtStartTimeParamsName.Text.Trim()
                                             , this.txtEndTimeParamsName.Text.Trim()
                                             , this.txtFeeTimeParamsName.Text.Trim()
                                             , clientUser.UserID);

                obj.RefreshChannelInfo();
            }
            catch (Exception ex)
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess      = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = "错误信息:" + ex.Message;
            }
        }