Пример #1
0
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string sFun = context.Request["fn"];

        try
        {
            LanguageHelper langHelper = GetLanguageHelper(context.Session);

            switch (sFun)//操作函数调用
            {
            case "VerifyCode":
                context.Session["VerifyCode"] = UserMgr.CreateVerifyCodePicture(context.Response.OutputStream);
                context.Response.ContentType  = "image/jpeg";
                break;

            case "CheckVerifyCode":
                Thread.Sleep(500);     //通过ajax每500毫秒只能对比一次校验码,防止暴力刷新
                if (string.IsNullOrEmpty(context.Request["VerifyCode"]) ||
                    string.Equals((string)context.Session["VerifyCode"], context.Request["VerifyCode"], StringComparison.OrdinalIgnoreCase) == false)
                {
                    throw new Exception(langHelper.GetText("Verify Code Is Incorrect !"));
                }
                else
                {
                    context.Response.Write(new JavaScriptSerializer().Serialize(new { Result = true }));
                }
                break;

            case "GetUserInfo":
                //context.Response.Write(new JavaScriptSerializer().Serialize(BLL.LoadEmployeeInfo(context.Request["sUserName"])));
                context.Response.Write(ExtendedJavaScriptConverter <EmployeeInfo> .ToJson(UserMgr.LoadEmployeeInfo(context.Request["sUserName"]), "yyyy-MM-dd HH:mm:ss"));
                Thread.Sleep(500);     //通过ajax每500毫秒只能取得一次用户信息,防止暴力刷新
                break;

            case "GetLogedUserName":
                EmployeeInfo empInfo = context.Session["LogonEmployee"] as EmployeeInfo;
                if (empInfo != null)
                {
                    context.Response.Write(new JavaScriptSerializer().Serialize(empInfo));
                }
                break;

            case "logout":
                context.Session["LogonEmployee"] = null; break;

            case "TableEdit":
                TableEdit(context);
                break;

            case "GetPISData":
                GetPISData(context);
                break;

            case "GetAutoSolderData":
                GetAutoSolderData(context);
                break;

            case "GetConnection":
                //GetConnection(context);
                break;

            case "GetProductLineData":
                GetProductLineData(context);
                break;

            case "GetAutoSolderData_Grid":
                GetAutoSolderData_Grid(context);
                break;

            case "SaveNetSetting":
                SaveNetSetting(context);
                break;

            case "ExportExcel":
                ExportExcel(context);
                break;

            case "GetReflowerProfile_Grid":
                GetReflowerProfile_Grid(context);
                break;

            case "GetCommonProductLine":
                GetCommonProductLine(context);
                break;

            case "GetAllDeviceData":
                GetAllDeviceData(context);
                break;

            case "GetAllDeviceDataChart":
                GetAllDeviceDataChart(context);
                break;
            }
        }
        catch (Exception err)
        {
            string sJson = new JavaScriptSerializer().Serialize(new tagErrMsg(err.Message));
            switch (sFun)
            {
            default:
                context.Response.Write(sJson); break;
            }
        }
    }