1
duan
2024-08-21 f71a02229c1ba00fbecaead19256593ffb052753
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
using DIXPad.DataProtocol;
using DIXPadWPF.Helper;
using DIXWeb.Business.MySQLBiz;
using DIXWeb.DataRepository;
using DIXWeb.Entity.MySQLEntity;
using DIXWeb.Util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
 
namespace DIXPadWPF
{
    /// <summary>
    /// DixPadUpLoad.xaml 的交互逻辑
    /// </summary>
    public partial class DixPadUpLoad : Page
    {
        MySQLInspectAreaBiz ABIZ = null;
        MySQLInspectObjectTypeBiz BIZ = null;
        MySQLInspectObjectBiz OBIZ = null;
        MySQLInspectBaseBiz BBIZ = null;
        MySQLInspectFrequencyBiz BFZ = null;
        string _ServiceUrl { get; set; } = "";
        public DixPadUpLoad()
        {
            InitializeComponent();
            _ServiceUrl = System.Configuration.ConfigurationManager.AppSettings["ServiceUrl"].ToString();
            ABIZ = new MySQLInspectAreaBiz();
            OBIZ = new MySQLInspectObjectBiz();
            BBIZ = new MySQLInspectBaseBiz();
            BIZ = new MySQLInspectObjectTypeBiz();
            BFZ = new MySQLInspectFrequencyBiz();
        }
 
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            string inspectobjecttype = cbInspectObjectType.Text;
            string inspectArea = cbInspectArea.Text;
            string inspectFreq = cbInspectFreq.Text;
            DataTable dt = OBIZ.GetAllInspectedItem(inspectobjecttype, inspectArea, inspectFreq);
            UploadDataGrid.ItemsSource = dt.DefaultView;
            cbInspectObjectType.SelectedIndex = -1;
            cbInspectArea.SelectedIndex = -1;
            cbInspectFreq.SelectedIndex = -1;
        }
        public void GetInspectObjectType()
        {
            cbInspectObjectType.Items.Clear();
            cbInspectObjectType.Items.Add("全选");
            List<MySQLInspectObjectType> list = BIZ.GetDataList("", "", new Pagination());
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    string typename = list[i].Name;
                    cbInspectObjectType.Items.Add(typename);
                }
            }
        }
        public void GetInspectArea()
        {
            cbInspectArea.Items.Clear();
            cbInspectArea.Items.Add("全选");
            List<MySQLInspectArea> list = ABIZ.GetDataList(0, new Pagination());
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    string typename = list[i].Name;
                    cbInspectArea.Items.Add(typename);
                }
            }
        }
        public void GetInspectFreq()
        {
            cbInspectFreq.Items.Clear();
            cbInspectFreq.Items.Add("全选");
            List<MySQLInspectFrequency> list = BFZ.GetDataList(0, new Pagination());
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    string typename = list[i].Frequency;
                    cbInspectFreq.Items.Add(typename);
                }
            }
        }
        private void btnUpLoad_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ResultMessage r = NetWorkCheck.NetWorkCheckResult();
                if (r.Count < 0)
                {
                    MessageBox.Show(r.Msg, "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    DataTable dtinfo = BBIZ.GetInspectedItems();
                    if (dtinfo.Rows.Count > 0)
                    {
                        string sn = Guid.NewGuid().ToString();
                        DIXPad.RSLC.BizServiceProxy localProxy = new DIXPad.RSLC.BizServiceProxy(_ServiceUrl);
                        DataTable table = new DataTable(Guid.NewGuid().ToString());
                        table.Columns.Add("sn", typeof(string));
                        table.Columns.Add("InspectObjectId", typeof(int));
                        table.Columns.Add("InspectItemId", typeof(int));
                        table.Columns.Add("CheckType", typeof(string));
                        table.Columns.Add("InspectLimit", typeof(double));
                        table.Columns.Add("NGReason", typeof(string));
                        table.Columns.Add("TotalJudge", typeof(bool));
                        table.Columns.Add("InspectTimes", typeof(int));
                        table.Columns.Add("CreateTime", typeof(DateTime));
                        table.Columns.Add("InspectOperator", typeof(string));
                        table.Columns.Add("IsImprovedOnSite", typeof(bool));
                        table.Columns.Add("DealDetial", typeof(string));
                        table.Columns.Add("ReInspectTimes", typeof(int));
                        table.Columns.Add("ImgString", typeof(string));
                        table.Columns.Add("IsBackup", typeof(int));
                        for (int i = 0; i < dtinfo.Rows.Count; i++)
                        {
                            DataRow dr = table.NewRow();
                            dr["sn"] = sn;
                            dr["InspectObjectId"] = Convert.ToInt32(dtinfo.Rows[i]["InspectObjectId"].ToString());
                            dr["InspectItemId"] = Convert.ToInt32(dtinfo.Rows[i]["InspectItemId"].ToString());
                            dr["CheckType"] = dtinfo.Rows[i]["CheckType"].ToString();
                            dr["InspectLimit"] = double.Parse(dtinfo.Rows[i]["InspectLimit"].ToString());
                            dr["NGReason"] = dtinfo.Rows[i]["NGReason"].ToString();
                            string judge = dtinfo.Rows[i]["TotalJudge"].ToString();
                            if (judge == "True")
                            {
                                dr["TotalJudge"] = true;
                            }
                            else
                            {
                                dr["TotalJudge"] = false;
                            }
                            dr["InspectTimes"] = Convert.ToInt32(dtinfo.Rows[i]["InspectTimes"].ToString());
                            dr["CreateTime"] = Convert.ToDateTime(dtinfo.Rows[i]["CreateTime"].ToString());
                            dr["InspectOperator"] = dtinfo.Rows[i]["InspectOperator"];
                            string improved = dtinfo.Rows[i]["IsImprovedOnSite"].ToString();
                            if (improved == "1")
                            {
                                dr["IsImprovedOnSite"] = true;
                            }
                            else
                            {
                                dr["IsImprovedOnSite"] = false;
                            }
                            dr["DealDetial"] = dtinfo.Rows[i]["DealDetial"];
                            dr["ReInspectTimes"] = Convert.ToInt32(dtinfo.Rows[i]["ReInspectTimes"]);
                            if (dtinfo.Rows[i]["ImgString"].ToString() == "")
                            {
                                dr["ImgString"] = "";
                            }
                            else
                            {
                                dr["ImgString"] = dtinfo.Rows[i]["ImgString"].ToString();
                            }
                            dr["IsBackup"] = Convert.ToInt32(dtinfo.Rows[i]["isbackup"].ToString());
                            table.Rows.Add(dr);
                        }
 
                        Dictionary<string, string> dir = new Dictionary<string, string>();
                        dir.Add("sn", "sn");
                        dir.Add("InspectObjectId", "InspectObjectId");
                        dir.Add("InspectItemId", "InspectItemId");
                        dir.Add("CheckType", "CheckType");
                        dir.Add("InspectLimit", "InspectLimit");
                        dir.Add("NGReason", "NGReason");
                        dir.Add("TotalJudge", "TotalJudge");
                        dir.Add("InspectTimes", "InspectTimes");
                        dir.Add("CreateTime", "CreateTime");
                        dir.Add("InspectOperator", "InspectOperator");
                        dir.Add("IsImprovedOnSite", "IsImprovedOnSite");
                        dir.Add("DealDetial", "DealDetial");
                        dir.Add("ReInspectTimes", "ReInspectTimes");
                        dir.Add("ImgString", "ImgString");
                        dir.Add("IsBackup", "IsBackup");
                        Dictionary<string, object> pdir = new Dictionary<string, object>();
                        pdir.Add("@sn", sn);
 
                        string imgsn = Guid.NewGuid().ToString();
                        DataTable dtimg = BBIZ.GetImageItems();
                        DataTable imgtable = new DataTable(Guid.NewGuid().ToString());
                        imgtable.Columns.Add("TableSN", typeof(string));
                        imgtable.Columns.Add("SN", typeof(string));
                        imgtable.Columns.Add("ImgId", typeof(int));
                        imgtable.Columns.Add("ImgString", typeof(string));
                        for (int i = 0; i < dtimg.Rows.Count; i++)
                        {
                            DataRow dr = imgtable.NewRow();
                            dr["TableSN"] = imgsn;
                            dr["SN"] = dtimg.Rows[i]["SN"].ToString();
                            dr["ImgId"] = Convert.ToInt32(dtimg.Rows[i]["ImgId"].ToString());
                            dr["ImgString"] = dtimg.Rows[i]["ImgString"].ToString();
                            imgtable.Rows.Add(dr);
                        }
                        Dictionary<string, string> imgdir = new Dictionary<string, string>();
                        imgdir.Add("TableSN", "TableSN");
                        imgdir.Add("SN", "SN");
                        imgdir.Add("ImgId", "ImgId");
                        imgdir.Add("ImgString", "ImgString");
                        Dictionary<string, object> idir = new Dictionary<string, object>();
                        idir.Add("@sn", imgsn);
 
                        MsgObject msg = localProxy.WSBulkCopyDataToDBWithHook(table, "InspectItemInfoDetial", dir, pdir, "yp_InspectItemInfo_bk2", DIXPad.RSLC.DBKeys.DIX);
                        if (msg.Count > 0)
                        {
                            MsgObject msg1 = localProxy.WSBulkCopyDataToDBWithHook(imgtable, "ItemImgDetial", imgdir, idir, "yp_GetImageList", DIXPad.RSLC.DBKeys.DIX);
                            if (msg1.Count > 0)
                            {
                                BBIZ.UpdateInspectedItems();
                                MessageBox.Show("点检数据上传至服务端成功!", "上传成功", MessageBoxButton.OK, MessageBoxImage.Information);
                                DataTable dt = OBIZ.GetAllInspectedItem("", "", "");
                                UploadDataGrid.ItemsSource = dt.DefaultView;
                            }
                            else
                            {
                                MessageBox.Show("点检数据上传至服务端失败!" + msg1.Msg, "上传失败", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("点检数据上传至服务端失败!" + msg.Msg, "上传失败", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("当前无可上传的点检数据!请点检其他设备后再进行上传!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
         }
 
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                DataTable dt = OBIZ.GetAllInspectedItem("", "", "");
                UploadDataGrid.ItemsSource = dt.DefaultView;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 
        private void btnChange_Click(object sender, RoutedEventArgs e)
        {
            var a = UploadDataGrid.CurrentItem as DataRowView;
            if (a != null)
            {
                MySQLInspectTypeBiz TBIZ = new MySQLInspectTypeBiz();
                string inspecttypes = a.Row[3].ToString();
                string loadstatus= a.Row[0].ToString();
                string code = a.Row[5].ToString();
                int times = Convert.ToInt32(a.Row[11].ToString());
                List<MySQLInspectObject> list = OBIZ.GetDataList("InspectObjectCode", code, new Pagination());
                if (list.Count > 0)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        int inspecttypeid = list[i].InspectTypeId;
                        List<MySQLInspectType> tlist = TBIZ.GetDataList(inspecttypeid, new Pagination());
                        string inspecttypestr = tlist[0].Name;
                        if (inspecttypestr == inspecttypes)
                        {
                            DIXPadInspectItemPage dpi = new DIXPadInspectItemPage();
                            dpi.mpcObject = list[i];
                            dpi.InspectTimes = times;
                            dpi.Code = "Update";
                            dpi.loadstatus = loadstatus;
                            dpi.createtime = Convert.ToDateTime(a.Row[12].ToString());
                            this.NavigationService.Navigate(dpi);
                        }
                    }
                }
            }
        }
 
        private void cbInspectObjectType_DropDownOpened(object sender, EventArgs e)
        {
            GetInspectObjectType();
        }
 
        private void cbInspectArea_DropDownOpened(object sender, EventArgs e)
        {
            GetInspectArea();
        }
 
        private void cbInspectFreq_DropDownOpened(object sender, EventArgs e)
        {
            GetInspectFreq();
        }
    }
}