Пример #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;
            }

            try
            {
                SPChannelWrapper obj = new SPChannelWrapper();
                obj.Name         = this.txtName.Text.Trim();
                obj.Description  = this.txtDescription.Text.Trim();
                obj.Area         = this.txtArea.Text.Trim();
                obj.ChannelCode  = this.txtChannelCode.Text.Trim();
                obj.FuzzyCommand = this.txtFuzzyCommand.Text.Trim();
                obj.Port         = this.txtPort.Value.ToString();
                obj.ChannelType  = this.txtChannelType.Text.Trim();
                obj.Price        = Convert.ToDecimal(this.txtPrice.Value);
                obj.Rate         = Convert.ToInt32(this.txtRate.Value);
                if (this.cmbChannelCodeParamsName.SelectedItem != null)
                {
                    obj.ChannelCodeParamsName = this.cmbChannelCodeParamsName.SelectedItem.Value;
                }
                else
                {
                    obj.ChannelCodeParamsName = "";
                }
                obj.IsAllowNullLinkID = chkIsAllowNullLinkID.Checked;
                obj.Status            = 0;
                obj.CreateTime        = System.DateTime.Now;
                obj.CreateBy          = this.ParentPage.CurrentLoginUser.UserID;
                obj.OkMessage         = txtOkMessage.Text.Trim();
                obj.FailedMessage     = txtFailedMessage.Text.Trim();
                obj.RecStatReport     = chkRecStatReport.Checked;
                obj.StatParamsName    = txtStatParamName.Text.Trim();
                obj.StatParamsValues  = txtStatValues.Text.Trim();

                obj.HasRequestTypeParams = chkHasRequestTypeParams.Checked;
                obj.RequestTypeParamName = txtRequestTypeParamName.Text.Trim();
                obj.RequestTypeValues    = txtRequestTypeValues.Text.Trim();


                obj.HasFilters          = chkHasFilters.Checked;
                obj.StatSendOnce        = chkStatSendOnce.Checked;
                obj.IsMonitoringRequest = chkIsMonitoringRequest.Checked;

                SPChannelWrapper.Save(obj);

                obj.RefreshChannelInfo();

                winSPChannelAdd.Hide();
            }
            catch (Exception ex)
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess      = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = "错误信息:" + ex.Message;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                IHttpRequest httpRequest = new HttpGetPostRequest(context.Request);

                //context.Request.s

                //检测是否存在ashx
                if (string.IsNullOrEmpty(httpRequest.RequestFileName))
                {
                    LogWarnInfo(httpRequest, "请求失败:没有指定ashx路径。\n", 0, 0);

                    return;
                }

                SPChannelWrapper channel = SPChannelWrapper.GetChannelByPath(Path.GetFileNameWithoutExtension(httpRequest.RequestFileName));

                //如果没有找到通道
                if (channel == null)
                {
                    LogWarnInfo(httpRequest, "处理请求失败:无法找到对应的通道。\n", 0, 0);

                    return;
                }



                saveLogFailedRequestToDb = channel.LogFailedRequestToDb;

                //如果通道未能运行
                if (channel.CStatus != ChannelStatus.Run)
                {
                    LogWarnInfo(httpRequest, "请求失败:\n" + "通道“" + channel.Name + "”未运行。\n", channel.Id, 0);

                    context.Response.Write(channel.GetFailedCode(httpRequest));

                    return;
                }
                //如果通道是监视通道,记录请求。
                if (channel.IsMonitoringRequest.HasValue && channel.IsMonitoringRequest.Value)
                {
                    SPMonitoringRequestWrapper.SaveRequest(httpRequest, channel.Id);
                }


                if (channel.Id == 88)
                {
                    if (httpRequest.RequestParams.ContainsKey("command"))
                    {
                        if (httpRequest.RequestParams["command"].ToString().ToLower().Equals("z6"))
                        {
                            httpRequest.RequestParams["command"] = " 6";
                        }
                    }
                    if (httpRequest.RequestParams.ContainsKey("command"))
                    {
                        if (httpRequest.RequestParams["command"].ToString().ToLower().Equals("71") && httpRequest.RequestParams["sp_no"].ToString().ToLower().Equals("1066885031"))
                        {
                            httpRequest.RequestParams["command"] = "7";
                        }
                    }
                }
                if (channel.Id == 66)
                {
                    if (httpRequest.RequestParams.ContainsKey("spnumber") && httpRequest.RequestParams.ContainsKey("momsg"))
                    {
                        if (httpRequest.RequestParams["momsg"].ToString().ToLower().StartsWith("8dm") && httpRequest.RequestParams["spnumber"].ToString().ToLower().Equals("106268001"))
                        {
                            httpRequest.RequestParams["spnumber"] = "106268000";
                        }
                    }
                }


                if (channel.FuzzyCommand.Trim().ToLower().Equals("quantt"))
                {
                    if (httpRequest.RequestParams.ContainsKey("reportcode"))
                    {
                        if (!string.IsNullOrEmpty(httpRequest.RequestParams["reportcode"].ToString()))
                        {
                            httpRequest.RequestParams.Add("status", httpRequest.RequestParams["reportcode"].ToString().Substring(0, 1));
                            httpRequest.RequestParams.Add("msg", httpRequest.RequestParams["reportcode"].ToString().Substring(1, httpRequest.RequestParams["reportcode"].ToString().Length - 1));
                        }
                    }
                }

                if (channel.HasConvertRule.HasValue && channel.HasConvertRule.Value)
                {
                    try
                    {
                        PreProcessRequest(httpRequest.RequestParams, context, channel.FuzzyCommand);
                    }
                    catch (Exception ex)
                    {
                        LogWarnInfo(httpRequest, "数据转换错误:" + ex.Message, channel.Id, 0);
                    }
                }



                //如果状态报告通道
                if (channel.RecStatReport.HasValue && channel.RecStatReport.Value)
                {
                    RequestError requestError1 = new RequestError();

                    bool result1 = false;

                    //分类型请求
                    if (channel.HasRequestTypeParams.HasValue && channel.HasRequestTypeParams.Value)
                    {
                        //报告状态请求
                        if (httpRequest.IsRequestContainValues(channel.RequestTypeParamName, channel.RequestReportTypeValue))
                        {
                            if (httpRequest.IsRequestContainValues(channel.StatParamsName, channel.StatParamsValues))
                            {
                                result1 = channel.RecState(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString(), out requestError1);
                            }
                            else
                            {
                                //channel.SaveStatReport(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString());

                                context.Response.Write(channel.GetOkCode(httpRequest));

                                return;
                            }
                        }
                        //发送数据请求
                        else if (httpRequest.IsRequestContainValues(channel.RequestTypeParamName, channel.RequestDataTypeValue))
                        {
                            result1 = channel.ProcessStateRequest(httpRequest, out requestError1);
                        }
                        else
                        {
                            LogWarnInfo(httpRequest, "未知类型请求", channel.Id, 0);

                            context.Response.Write(channel.GetFailedCode(httpRequest));

                            return;
                        }
                    }
                    else
                    {
                        if (httpRequest.RequestParams.ContainsKey(channel.StatParamsName.ToLower()))
                        {
                            if (httpRequest.IsRequestContainValues(channel.StatParamsName, channel.StatParamsValues))
                            {
                                if (channel.StatSendOnce.HasValue && channel.StatSendOnce.Value)
                                {
                                    result1 = channel.ProcessRequest(httpRequest, out requestError1);
                                }
                                else
                                {
                                    result1 = channel.RecState(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString(), out requestError1);
                                }
                            }
                            else
                            {
                                //channel.SaveStatReport(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString());

                                context.Response.Write(channel.GetOkCode(httpRequest));

                                return;
                            }
                        }
                        else
                        {
                            result1 = channel.ProcessStateRequest(httpRequest, out requestError1);
                        }
                    }

                    //正确数据返回OK
                    if (result1)
                    {
                        context.Response.Write(channel.GetOkCode(httpRequest));
                        return;
                    }



                    //重复数据返回OK
                    if (requestError1.ErrorType == RequestErrorType.RepeatLinkID)
                    {
                        logger.Warn(requestError1.ErrorMessage);
                        context.Response.Write(channel.GetOkCode(httpRequest));
                        return;
                    }

                    //其他错误类型记录错误请求
                    LogWarnInfo(httpRequest, requestError1.ErrorMessage, channel.Id, 0);

                    context.Response.Write(channel.GetFailedCode(httpRequest));

                    return;
                }

                RequestError requestError;

                bool result = channel.ProcessRequest(httpRequest, out requestError);

                if (result)
                {
                    context.Response.Write(channel.GetOkCode(httpRequest));

                    return;
                }

                //重复数据返回OK
                if (requestError.ErrorType == RequestErrorType.RepeatLinkID)
                {
                    logger.Warn(requestError.ErrorMessage);
                    context.Response.Write(channel.GetOkCode(httpRequest));
                    return;
                }

                LogWarnInfo(httpRequest, requestError.ErrorMessage, channel.Id, 0);

                context.Response.Write(channel.GetFailedCode(httpRequest));
            }
            catch (Exception ex)
            {
                try
                {
                    IHttpRequest failRequest = new HttpGetPostRequest(context.Request);

                    string errorMessage = "处理请求失败:\n错误信息:" + ex.Message;

                    logger.Error(errorMessage + "\n请求信息:\n" + failRequest.RequestData, ex);

                    if (saveLogFailedRequestToDb)
                    {
                        SPFailedRequestWrapper.SaveFailedRequest(failRequest, errorMessage, 0, 0);
                    }
                }
                catch (Exception e)
                {
                    logger.Error("处理请求失败:\n错误信息:" + e.Message);
                }
            }
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                xmlString = HttpXmlPostRequest.GetXmlPostValueFromRequest(context.Request);

                //logger.Error(xmlString);

                IHttpRequest httpRequest = new HttpXmlPostRequest(context.Request, xmlString, GetXmlNodeName());

                //检测是否存在ashx
                if (string.IsNullOrEmpty(httpRequest.RequestFileName))
                {
                    LogWarnInfo(httpRequest, "请求失败:没有指定ashx路径。\n", 0, 0);

                    return;
                }

                SPChannelWrapper channel = SPChannelWrapper.GetChannelByPath(GetChannelCodeName(context));

                //如果没有找到通道
                if (channel == null)
                {
                    LogWarnInfo(httpRequest, "处理请求失败:无法找到对应的通道。\n", 0, 0);

                    return;
                }

                saveLogFailedRequestToDb = channel.LogFailedRequestToDb;

                //如果通道未能运行
                if (channel.CStatus != ChannelStatus.Run)
                {
                    LogWarnInfo(httpRequest, "请求失败:\n" + "通道“" + channel.Name + "”未运行。\n", channel.Id, 0);

                    context.Response.Write(channel.GetFailedCode(httpRequest));

                    return;
                }
                //如果通道是监视通道,记录请求。
                if (channel.IsMonitoringRequest.HasValue && channel.IsMonitoringRequest.Value)
                {
                    SPMonitoringRequestWrapper.SaveRequest(httpRequest, channel.Id);
                }

                if (channel.HasConvertRule.HasValue && channel.HasConvertRule.Value)
                {
                    try
                    {
                        PreProcessRequest(httpRequest.RequestParams, context, channel.FuzzyCommand);
                    }
                    catch (Exception ex)
                    {
                        LogWarnInfo(httpRequest, "数据转换错误:" + ex.Message, channel.Id, 0);
                    }
                }


                //如果状态报告通道
                if (channel.RecStatReport.HasValue && channel.RecStatReport.Value)
                {
                    RequestError requestError1 = new RequestError();

                    bool result1 = false;

                    if (channel.HasRequestTypeParams.HasValue && channel.HasRequestTypeParams.Value)
                    {
                        //报告状态请求
                        if (httpRequest.IsRequestContainValues(channel.RequestTypeParamName, channel.RequestReportTypeValue))
                        {
                            if (httpRequest.IsRequestContainValues(channel.StatParamsName, channel.StatParamsValues))
                            {
                                result1 = channel.RecState(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString(), out requestError1);
                            }
                            else
                            {
                                //channel.SaveStatReport(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString());

                                context.Response.Write(channel.GetOkCode(httpRequest));

                                return;
                            }
                        }
                        //发送数据请求
                        else if (httpRequest.IsRequestContainValues(channel.RequestTypeParamName, channel.RequestDataTypeValue))
                        {
                            result1 = channel.ProcessStateRequest(httpRequest, out requestError1);
                        }
                        else
                        {
                            LogWarnInfo(httpRequest, "未知类型请求", channel.Id, 0);

                            context.Response.Write(channel.GetFailedCode(httpRequest));

                            return;
                        }
                    }
                    else
                    {
                        if (httpRequest.RequestParams.ContainsKey(channel.StatParamsName.ToLower()))
                        {
                            if (httpRequest.IsRequestContainValues(channel.StatParamsName, channel.StatParamsValues))
                            {
                                if (channel.StatSendOnce.HasValue && channel.StatSendOnce.Value)
                                {
                                    result1 = channel.ProcessRequest(httpRequest, out requestError1);
                                }
                                else
                                {
                                    result1 = channel.RecState(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString(), out requestError1);
                                }
                            }
                            else
                            {
                                //channel.SaveStatReport(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString());

                                context.Response.Write(channel.GetOkCode(httpRequest));

                                return;
                            }
                        }
                        else
                        {
                            result1 = channel.ProcessStateRequest(httpRequest, out requestError1);
                        }
                    }

                    //正确数据返回OK
                    if (result1)
                    {
                        context.Response.Write(channel.GetOkCode(httpRequest));
                        return;
                    }



                    //重复数据返回OK
                    if (requestError1.ErrorType == RequestErrorType.RepeatLinkID)
                    {
                        logger.Warn(requestError1.ErrorMessage);
                        context.Response.Write(channel.GetOkCode(httpRequest));
                        return;
                    }

                    //其他错误类型记录错误请求
                    LogWarnInfo(httpRequest, requestError1.ErrorMessage, channel.Id, 0);

                    context.Response.Write(channel.GetFailedCode(httpRequest));

                    return;
                }

                RequestError requestError;

                bool result = channel.ProcessRequest(httpRequest, out requestError);

                if (result)
                {
                    context.Response.Write(channel.GetOkCode(httpRequest));

                    return;
                }

                //重复数据返回OK
                if (requestError.ErrorType == RequestErrorType.RepeatLinkID)
                {
                    logger.Warn(requestError.ErrorMessage);
                    context.Response.Write(channel.GetOkCode(httpRequest));
                    return;
                }

                LogWarnInfo(httpRequest, requestError.ErrorMessage, channel.Id, 0);

                context.Response.Write(channel.GetFailedCode(httpRequest));
            }
            catch (Exception ex)
            {
                try
                {
                    IHttpRequest failRequest = new HttpXmlPostRequest(context.Request, xmlString, GetXmlNodeName());

                    string errorMessage = "处理请求失败:\n错误信息:" + ex.Message;

                    logger.Error(errorMessage + "\n请求信息:\n" + failRequest.RequestData, ex);
                    if (saveLogFailedRequestToDb)
                    {
                        SPFailedRequestWrapper.SaveFailedRequest(failRequest, errorMessage, 0, 0);
                    }
                }
                catch (Exception e)
                {
                    logger.Error("处理请求失败:\n错误信息:" + e.Message + xmlString);
                }
            }
        }
        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         = chkRecStatReport.Checked;
                obj.StatParamsName        = txtStatParamName.Text.Trim();
                obj.StatParamsValues      = txtStatValues.Text.Trim();
                obj.IsDisable             = false;


                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.QuickAdd(obj, this.txtLinkParamsName.Text.Trim(), this.txtMobileParamsName.Text.Trim(), this.txtSPcodeParamsName.Text.Trim(), this.txtMoParamsName.Text.Trim(), clientUser.UserID);

                obj.RefreshChannelInfo();
            }
            catch (Exception ex)
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess      = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = "错误信息:" + ex.Message;
            }
        }
Пример #5
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                IHttpRequest httpRequest = new HttpSP0025PostRequest(context.Request);

                //检测是否存在ashx
                if (string.IsNullOrEmpty(httpRequest.RequestFileName))
                {
                    LogWarnInfo(httpRequest, "请求失败:没有指定ashx路径。\n", 0, 0);

                    return;
                }

                SPChannelWrapper channel = SPChannelWrapper.GetChannelByPath(httpRequest.GetChannelCode());

                bool isReportRequest = false;

                //如果没有找到通道
                if (channel == null)
                {
                    LogWarnInfo(httpRequest, "处理请求失败:无法找到对应的通道。\n", 0, 0);

                    return;
                }

                saveLogFailedRequestToDb = channel.LogFailedRequestToDb;

                //如果通道未能运行
                if (channel.CStatus != ChannelStatus.Run)
                {
                    LogWarnInfo(httpRequest, "请求失败:\n" + "通道“" + channel.Name + "”未运行。\n", channel.Id, 0);

                    context.Response.Write(channel.GetFailedCode(httpRequest));

                    return;
                }
                //如果通道是监视通道,记录请求。
                if (channel.IsMonitoringRequest.HasValue && channel.IsMonitoringRequest.Value)
                {
                    SPMonitoringRequestWrapper.SaveRequest(httpRequest, channel.Id);
                }

                if (httpRequest.RequestParams.ContainsKey("spnumber"))
                {
                    if (httpRequest.RequestParams["spnumber"].ToString().ToLower().Equals("91605"))
                    {
                        httpRequest.RequestParams["spnumber"] = "106691605";
                    }
                    else if (httpRequest.RequestParams["spnumber"].ToString().ToLower().Equals("91608"))
                    {
                        httpRequest.RequestParams["spnumber"] = "106691608";
                    }
                    else if (httpRequest.RequestParams.ContainsKey("exspnumber") && httpRequest.RequestParams["exspnumber"] != null && !string.IsNullOrEmpty(httpRequest.RequestParams["exspnumber"].ToString()))
                    {
                        httpRequest.RequestParams["spnumber"] = httpRequest.RequestParams["exspnumber"];
                    }
                }



                //如果状态报告通道
                if (channel.RecStatReport.HasValue && channel.RecStatReport.Value)
                {
                    RequestError requestError1 = new RequestError();

                    bool result1 = false;

                    //分类型请求
                    if (channel.HasRequestTypeParams.HasValue && channel.HasRequestTypeParams.Value)
                    {
                        //报告状态请求
                        if (httpRequest.IsRequestContainValues(channel.RequestTypeParamName, channel.RequestReportTypeValue))
                        {
                            if (httpRequest.IsRequestContainValues(channel.StatParamsName, channel.StatParamsValues))
                            {
                                isReportRequest = true;
                                result1         = channel.RecState(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString(), out requestError1);
                            }
                            else
                            {
                                //channel.SaveStatReport(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString());

                                context.Response.Write(channel.GetOkCode(httpRequest));

                                return;
                            }
                        }
                        //发送数据请求
                        else if (httpRequest.IsRequestContainValues(channel.RequestTypeParamName, channel.RequestDataTypeValue))
                        {
                            result1 = channel.ProcessStateRequest(httpRequest, out requestError1);
                        }
                        else
                        {
                            LogWarnInfo(httpRequest, "未知类型请求", channel.Id, 0);

                            context.Response.Write(channel.GetFailedCode(httpRequest));

                            return;
                        }
                    }
                    else
                    {
                        if (httpRequest.RequestParams.ContainsKey(channel.StatParamsName.ToLower()))
                        {
                            if (httpRequest.IsRequestContainValues(channel.StatParamsName, channel.StatParamsValues))
                            {
                                if (channel.StatSendOnce.HasValue && channel.StatSendOnce.Value)
                                {
                                    result1 = channel.ProcessRequest(httpRequest, out requestError1);
                                }
                                else
                                {
                                    result1 = channel.RecState(httpRequest, httpRequest.RequestParams[channel.StatParamsName.ToLower()].ToString(), out requestError1);
                                }
                            }
                            else
                            {
                                context.Response.Write(channel.GetOkCode(httpRequest));

                                return;
                            }
                        }
                        else
                        {
                            result1 = channel.ProcessStateRequest(httpRequest, out requestError1);
                        }
                    }

                    //正确数据返回OK
                    if (result1)
                    {
                        if (isReportRequest)
                        {
                            context.Response.Write(string.Format("received commandid={0}", context.Request["commandid"]));
                            return;
                        }
                        context.Response.Write(channel.GetOkCode(httpRequest));
                        return;
                    }



                    //重复数据返回OK
                    if (requestError1.ErrorType == RequestErrorType.RepeatLinkID)
                    {
                        logger.Warn(requestError1.ErrorMessage);
                        context.Response.Write(channel.GetOkCode(httpRequest));
                        return;
                    }

                    //其他错误类型记录错误请求

                    LogWarnInfo(httpRequest, requestError1.ErrorMessage, channel.Id, 0);

                    context.Response.Write(channel.GetFailedCode(httpRequest));

                    return;
                }

                RequestError requestError;

                bool result = channel.ProcessRequest(httpRequest, out requestError);

                if (result)
                {
                    context.Response.Write(channel.GetOkCode(httpRequest));

                    return;
                }

                //重复数据返回OK
                if (requestError.ErrorType == RequestErrorType.RepeatLinkID)
                {
                    logger.Warn(requestError.ErrorMessage);
                    context.Response.Write(channel.GetOkCode(httpRequest));
                    return;
                }

                LogWarnInfo(httpRequest, requestError.ErrorMessage, channel.Id, 0);

                context.Response.Write(channel.GetFailedCode(httpRequest));
            }
            catch (Exception ex)
            {
                try
                {
                    IHttpRequest failRequest = new HttpGetPostRequest(context.Request);

                    string errorMessage = "处理请求失败:\n错误信息:" + ex.Message;

                    logger.Error(errorMessage + "\n请求信息:\n" + failRequest.RequestData, ex);

                    if (saveLogFailedRequestToDb)
                    {
                        SPFailedRequestWrapper.SaveFailedRequest(failRequest, errorMessage, 0, 0);
                    }
                }
                catch (Exception e)
                {
                    logger.Error("处理请求失败:\n错误信息:" + e.Message);
                }
            }
        }
Пример #6
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;
            }
        }