zgq
2021-07-12 97bc78d6500360aca073b29a5a1c387fd98f6c14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using WebAPI.Models;
 
namespace WebAPI.Controllers
{
    public class CellWidthController : ApiController
    {
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public WebServer webserver = new WebServer();
 
 
        #region 单据保存列宽
        /// <summary>
        /// 单据列表保存
        /// </summary>
        /// <returns></returns>
        [Route("tb_CellWidth/GetMouldScrapInHouseCellWidth")]
        [HttpPost]
        public object GetMouldScrapInHouseCellWidth()
        {
 
            string Item = HttpContext.Current.Request["myMap"];
            string Name = HttpContext.Current.Request["Name"];
            string[] sArray = Item.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg3 = sArray[0].ToString();
            //按 },{来拆分数组 //去掉【和】
            msg3 = msg3.Substring(1, msg3.Length - 2);
            msg3 = msg3.Replace("\\", "");
            msg3 = msg3.Replace("\n", "");  //\n
            string[] myMap = msg3.Split(','); //字符串转数组
 
            SaveGridView(myMap, Name, HttpContext.Current.Server.MapPath("~/bin"));
 
            try
            {
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "成功!";
                objJsonResult.data = null;
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = ex.ToString();
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
 
        #region 列宽保存
        public object SaveGridView(string[] _value, string KeyItem, string AppPath)
        {
            string text = "";
            try
            {
                for (int i = 0; i <= _value.Length - 1; i++)
                {
                    bool flag = i == 0;
                    if (flag)
                    {
                        text = _value[i].ToString();
                    }
                    else
                    {
                        text = text + "," + _value[i].ToString();
                    }
                }
                ClsIni clsIni = new ClsIni();
                bool flag2 = ClsIni.WriteIni("GridSave", KeyItem, text, AppPath + "\\grdWidth.wyini");
                if (flag2)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "操作成功!";
                    objJsonResult.data = null;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "操作失败!";
                    objJsonResult.data = null;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message;
                objJsonResult.data = null;
            }
 
            return objJsonResult;
        }
        #endregion
 
        #region 列宽查询
 
        [Route("tb_CellWidth/GetMouldScrapInHouseCellWidthList")]
        [HttpGet]
        public object GetGridView(int colNum, string Name)
        {
            try
            {
 
                char c = Convert.ToChar(",");
                string text = ClsIni.ReadIni("GridSave", Name, HttpContext.Current.Server.MapPath("~/bin") + "\\grdWidth.wyini");
                bool flag = text != "没有找到!";
                if (flag)
                {
                    string[] array = text.Split(new char[]
                    {
                        c
                    });
                    bool flag2 = colNum > array.Length;
                    int num;
                    if (flag2)
                    {
                        num = array.Length;
                    }
                    else
                    {
                        num = colNum;
                    }
                    for (int i = 0; i < num; i++)
                    {
                        bool flag3 = ClsPub.isInt(array[i]) > 500;
                        if (flag3)
                        {
                            array[i] = ClsPub.isInt(array[i]).ToString();
                        }
                        else
                        {
                            array[i] = ClsPub.isInt(array[i]).ToString();
                        }
                    }
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取列宽成功!";
                    objJsonResult.data = array;
                }
                else
                {
                    objJsonResult.code = "-1";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无设置!";
                    objJsonResult.data = null;
                }
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "设置列宽失败!" + ex.Message;
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
    }
}