Esempio n. 1
0
        /// <summary>
        /// 请求数据
        /// </summary>
        private void RequestData()
        {
            string         errmsg  = "";
            string         urltype = Request["urltype"]; //请求类型,IIS,Tomcat
            string         pageurl = Request["pageurl"]; //代码
            string         data    = Request["data"];    //数据
            ResultInfo     outjson = new ResultInfo();
            BLLRequestData mybll   = new BLLRequestData();
            bool           result  = true;
            string         json    = "";

            switch (urltype)
            {
            case "IIS3676":
                result = mybll.RequestIIS3676Data(pageurl, data, ref json, ref errmsg);
                if (!result)
                {
                    outjson.errcode = -1;
                    outjson.errmsg  = errmsg;
                }
                break;

            case "IIS3380":
                result = mybll.RequestIIS3380Data(pageurl, data, ref json, ref errmsg);
                if (!result)
                {
                    outjson.errcode = -1;
                    outjson.errmsg  = errmsg;
                }
                break;

            case "Tomcat":

                break;

            default:
                result          = false;
                outjson.errcode = -1;
                outjson.errmsg  = "请求出错,未找到对应服务器";
                break;
            }
            if (result)
            {
                Response.Write(json);
                Response.End();
            }
            else
            {
                Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                Response.End();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 请求数据
        /// </summary>
        private void RequestData()
        {
            string     errmsg  = "";
            string     urltype = Request["urltype"]; //请求类型,IIS,Tomcat
            string     pageurl = Request["pageurl"]; //代码
            string     data    = Request["data"];    //数据
            ResultInfo outjson = new ResultInfo();

            if (Session["userinfo"] != null)
            {
                UserInfo userinfo = new UserInfo();
                userinfo = (UserInfo)Session["userinfo"];
                switch (pageurl)
                {
                case "MaterialQSApi.aspx?action=closeoraclematerialqs":    //关闭Oracle数据库的物料齐套
                    RequestMaterialQSCR rq = ObjectSeriallizeHelper.JsonToObject <RequestMaterialQSCR>(data);
                    rq.usercode = userinfo.usercode;
                    data        = ObjectSeriallizeHelper.ObjectToJson(rq);
                    break;
                }

                BLLRequestData mybll  = new BLLRequestData();
                bool           result = true;
                string         json   = "";
                switch (urltype)
                {
                case "IIS":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIISData(pageurl, userinfo.usercode, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "IIS3676":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIIS3676Data(pageurl, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "IIS3380":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIIS3380Data(pageurl, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "IIS3382":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIIS3382Data(pageurl, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "IIS3738":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIIS3738Data(pageurl, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "Tomcat":

                    break;

                default:
                    result          = false;
                    outjson.errcode = -1;
                    outjson.errmsg  = "请求出错,未找到对应服务器";
                    break;
                }
                if (result)
                {
                    Response.Write(json);
                    Response.End();
                }
                else
                {
                    Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                    Response.End();
                }
            }
            else
            {
                outjson.errcode = -1;
                outjson.errmsg  = "登录信息已过期,请重新登录";
                Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                Response.End();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 表格导出
        /// </summary>
        private void TableExport()
        {
            string errmsg = "";

            string     urltype  = Request["urltype"];  //请求类型,IIS,Tomcat
            string     pageurl  = Request["pageurl"];  //代码
            string     data     = Request["data"];     //数据
            string     filename = Request["filename"]; //文件名
            ResultInfo outjson  = new ResultInfo();

            if (Session["userinfo"] != null)
            {
                UserInfo userinfo = new UserInfo();
                userinfo = (UserInfo)Session["userinfo"];
                string usercode = userinfo.usercode;
                bool   result   = true;
                string json     = "";

                #region 获取表格要导出的字段
                BLLRequestData mybll = new BLLRequestData();
                result = mybll.RequestIISData("/Console/TableSetting.aspx?action=gettableconfiglist", usercode, data, ref json, ref errmsg);
                ResultTableFieldListInfo[] 表格字段列表 = null;
                if (result)
                {
                    ResultTableList tblist = ObjectSeriallizeHelper.JsonToObject <ResultTableList>(json);
                    if (tblist != null && tblist.data != null && tblist.data.Length > 0)
                    {
                        ResultTableListInfo[] 表格列表 = tblist.data;
                        for (int i = 0; i < 表格列表.Length; i++)
                        {
                            if (表格列表[i].页面url.Trim() == pageurl.Trim())
                            {
                                GetTableFieldInfo finfo = new GetTableFieldInfo();
                                finfo.usercode = usercode;
                                finfo.tbcode   = 表格列表[i].表格代码;
                                result         = mybll.RequestIISData("/Console/TableSetting.aspx?action=getusertablefieldinfolist", usercode, ObjectSeriallizeHelper.ObjectToJson(finfo), ref json, ref errmsg);
                                if (result)
                                {
                                    ResultTableFieldList rfl = ObjectSeriallizeHelper.JsonToObject <ResultTableFieldList>(json);
                                    if (rfl != null && rfl.data != null && rfl.data.Length > 0)
                                    {
                                        表格字段列表 = rfl.data;
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion

                switch (pageurl)
                {
                case "MaterialQSApi.aspx?action=closeoraclematerialqs":    //关闭Oracle数据库的物料齐套
                    RequestMaterialQSCR rq = ObjectSeriallizeHelper.JsonToObject <RequestMaterialQSCR>(data);
                    rq.usercode = userinfo.usercode;
                    data        = ObjectSeriallizeHelper.ObjectToJson(rq);
                    break;
                }


                switch (urltype)
                {
                case "IIS":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIISData(pageurl, userinfo.usercode, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "IIS3676":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIIS3676Data(pageurl, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "IIS3380":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIIS3380Data(pageurl, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "IIS3382":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIIS3382Data(pageurl, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "IIS3738":
                    data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                    data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                    result = mybll.RequestIIS3738Data(pageurl, data, ref json, ref errmsg);
                    if (!result)
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    break;

                case "Tomcat":

                    break;

                default:
                    result          = false;
                    outjson.errcode = -1;
                    outjson.errmsg  = "请求出错,未找到对应服务器";
                    break;
                }
                if (result)
                {
                    try
                    {
                        ExcelTable obj      = ObjectSeriallizeHelper.JsonToObject <ExcelTable>(json);
                        string     str_data = ObjectSeriallizeHelper.ObjectToJson(obj.data);
                        DataTable  dt       = ObjectSeriallizeHelper.JsonToDataTable(str_data);

                        DataTable 导出表格 = new DataTable();

                        if (表格字段列表 != null && 表格字段列表.Length > 0)
                        {
                            for (int i = 0; i < 表格字段列表.Length; i++)
                            {
                                if (表格字段列表[i].是否显示 == "1" && 表格字段列表[i].字段名 != "操作")
                                {
                                    for (int j = 0; j < dt.Columns.Count; j++)
                                    {
                                        if (dt.Columns[j].ToString().ToLower().Trim() == 表格字段列表[i].字段名.ToLower().Trim())
                                        {
                                            导出表格.Columns.Add(表格字段列表[i].别名, Type.GetType("System.String"));
                                        }
                                    }
                                }
                            }

                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                DataRow newRow;
                                newRow = 导出表格.NewRow();
                                for (int j = 0; j < 表格字段列表.Length; j++)
                                {
                                    if (表格字段列表[j].是否显示 == "1" && 表格字段列表[j].字段名 != "操作")
                                    {
                                        string 字段名 = 表格字段列表[j].字段名.ToLower();
                                        try
                                        {
                                            newRow[表格字段列表[j].别名] = dt.Rows[i][字段名].ToString();
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                导出表格.Rows.Add(newRow);
                            }
                            CreateExcel(导出表格, filename);
                        }
                        else
                        {
                            CreateExcel(dt, filename);
                        }
                    }
                    catch (Exception ex)
                    {
                        errmsg          = ex.Message.ToString();
                        result          = false;
                        outjson.errcode = -1;
                        outjson.errmsg  = errmsg;
                    }
                    if (!result)
                    {
                        Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                        Response.End();
                    }
                }
                else
                {
                    Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                    Response.End();
                }
            }
            else
            {
                outjson.errcode = -1;
                outjson.errmsg  = "登录信息已过期,请重新登录";
                Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                Response.End();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 表格导入
        /// </summary>
        private void TableImport()
        {
            Response.ContentType = "text/html";
            string     errmsg  = "";
            string     urltype = Request["urltype"]; //请求类型,IIS,Tomcat
            string     pageurl = Request["pageurl"]; //代码
            string     data    = "";                 //数据
            ResultInfo outjson = new ResultInfo();
            DataTable  dt      = new DataTable();
            string     path    = HttpRuntime.AppDomainAppPath.ToString();

            if (System.Web.HttpContext.Current.Request.Files.Count == 0)
            {
                errmsg          = "未选择文件";
                outjson.errcode = -1;
                outjson.errmsg  = errmsg;
                Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                Response.End();
            }
            else
            {
                System.IO.Stream stream = System.Web.HttpContext.Current.Request.Files[0].InputStream;
                bool             result = DataHelp.ExcelFileStreamToDataTable(path, stream, ref dt, ref errmsg);
                if (result)
                {
                    data = ObjectSeriallizeHelper.DataTableToJson(dt, ObjectSeriallizeHelper.ColumnNameLetterCase.Original);
                    if (Session["userinfo"] != null)
                    {
                        UserInfo userinfo = new UserInfo();
                        userinfo = (UserInfo)Session["userinfo"];
                        BLLRequestData mybll = new BLLRequestData();
                        string         json  = "";
                        switch (urltype)
                        {
                        case "IIS":
                            data   = data.Replace("", "");
                            data   = data.Replace(" ", "");
                            data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                            data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                            result = mybll.RequestIISData(pageurl, userinfo.usercode, data, ref json, ref errmsg);
                            if (!result)
                            {
                                outjson.errcode = -1;
                                outjson.errmsg  = errmsg;
                            }
                            break;

                        case "IIS3676":
                            data = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                            data = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");

                            result = mybll.RequestIIS3676Data(pageurl, data, ref json, ref errmsg);
                            if (!result)
                            {
                                outjson.errcode = -1;
                                outjson.errmsg  = errmsg;
                            }
                            break;

                        case "IIS3380":
                            data   = data.Replace("\"usercode\":\"\"", "\"usercode\": \"" + userinfo.usercode + "\"");
                            data   = data.Replace("\"operation_usercode\":\"\"", "\"operation_usercode\": \"" + userinfo.usercode + "\"");
                            result = mybll.RequestIIS3380Data(pageurl, data, userinfo.usercode, ref json, ref errmsg);
                            if (!result)
                            {
                                outjson.errcode = -1;
                                outjson.errmsg  = errmsg;
                            }
                            break;

                        case "Tomcat":

                            break;

                        default:
                            result          = false;
                            outjson.errcode = -1;
                            outjson.errmsg  = "请求出错,未找到对应服务器";
                            break;
                        }
                        if (result)
                        {
                            Response.Write(json);
                            Response.End();
                        }
                        else
                        {
                            Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                            Response.End();
                        }
                    }
                    else
                    {
                        outjson.errcode = -1;
                        outjson.errmsg  = "登录信息已过期,请重新登录";
                        Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                        Response.End();
                    }
                }
                else
                {
                    outjson.errcode = -1;
                    outjson.errmsg  = errmsg;
                    Response.Write(ObjectSeriallizeHelper.ObjectToJson(outjson));
                    Response.End();
                }
            }
        }