private void _ifactoryClient_OnReceiveResult(RequestResultPair args) { ThreadPool.QueueUserWorkItem(o => { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new Action<RequestResultPair>((RequestResultPair rst) => { string msg = args.Result != null ? args.Result.msg : ""; }), args); }); throw new NotImplementedException(); }
private void btnOK_Click(object sender, RoutedEventArgs e) { StringBuilder AssetsNO_temp = new StringBuilder(1024); StringBuilder ProductLineNO_temp = new StringBuilder(1024); StringBuilder DeviceGroupDID_temp = new StringBuilder(1024); string filePath = new DirectoryInfo(@"../dbinfo.ini").FullName; readIni("IFactoryMqtt", "assetsNO", "no key", AssetsNO_temp, 1024, filePath); readIni("IFactoryMqtt", "productLineNO", "no key", ProductLineNO_temp, 1024, filePath); readIni("IFactoryMqtt", "deviceGroupDID", "no key", DeviceGroupDID_temp, 1024, filePath); RequestResultPair rst = null; BaseResult req_rst = null; if (this.model == null) return; if (string.IsNullOrEmpty(this.PRODUCTNO.Text)) { MessageBox.Show("请输入产品型号", "提示"); } else if (string.IsNullOrEmpty(this.ENDPRODUCTNO.Text)) { MessageBox.Show("请输入成品编码", "提示"); } else if (string.IsNullOrEmpty(this.CRAFTWORK.Text)) { MessageBox.Show("请输入工艺", "提示"); } else if (string.IsNullOrEmpty(this.PROCESS.Text)) { MessageBox.Show("请输入工序", "提示"); } else if (string.IsNullOrEmpty(this.FACTORYID.Text)) { MessageBox.Show("请输入工厂编号", "提示"); } else if (string.IsNullOrEmpty(this.QUARTERS.Text)) { MessageBox.Show("请输入岗位名称", "提示"); } else if (string.IsNullOrEmpty(this.SEGMENT.Text)) { MessageBox.Show("请输入工段", "提示"); } else if (string.IsNullOrEmpty(this.model.staffid)) { MessageBox.Show("请输入工号", "提示"); } else { json_input.AssetsNO = AssetsNO_temp.ToString();//"P9-2724"; json_input.ProductLineNO = ProductLineNO_temp.ToString();// "M5-3F-S-STF01"; json_input.DeviceGroupDID = DeviceGroupDID_temp.ToString();// "COL#1"; json_input.ProductNO = this.PRODUCTNO.Text; json_input.EndProductNO = this.ENDPRODUCTNO.Text; json_input.CraftWork = this.CRAFTWORK.Text; json_input.Process = this.PROCESS.Text; json_input.FactoryID = this.FACTORYID.Text; json_input.Segment = this.SEGMENT.Text; json_input.Quarters = this.QUARTERS.Text; json_input.StaffID = this.model.staffid; sendStaffID = this.model.staffid; List<JsonData> list = new List<JsonData>(); JsonData data = new JsonData() { AssetsNO = json_input.AssetsNO, ProductLineNO= json_input.ProductLineNO, DeviceGroupDID= json_input.DeviceGroupDID, ProductNO= json_input.ProductNO, EndProductNO= json_input.EndProductNO, CraftWork= json_input.CraftWork, Process= json_input.Process, FactoryID= json_input.FactoryID, Segment = json_input.Segment, Quarters = json_input.Quarters, StaffID= json_input.StaffID }; string jsconDatastr = JsonConvert.SerializeObject(data); req_rst = _ifactoryClient.RequstWithResult("produce.device.startup","validate", jsconDatastr, true,out rst); if(!File.Exists(@".\log.txt")) { FileStream fs = new FileStream(@".\log.txt",FileMode.Create,FileAccess.Write); StreamWriter sw = new StreamWriter(fs); string msg = "MSG:" + req_rst.msg + "\r\nResult:" + rst.Result.ToString() + "\r\nJson:" + jsconDatastr; sw.WriteLine(msg); sw.Close(); fs.Close(); } else { FileStream fs = new FileStream(@".\log.txt", FileMode.Open, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); string msg = "MSG:" + req_rst.msg + "\r\nResult:" + rst.Result.ToString() + "\r\nJson:" + jsconDatastr; sw.WriteLine(msg); sw.Close(); fs.Close(); } if (req_rst.code == 0) { MainWindow.m_MainWindow.userCheckFlag = true; OpenStatus(); btnStatus = "注销"; writeIni("UserVerify", "EndProductNo", json_input.EndProductNO, filePath); writeIni("UserVerify", "ProductNo", json_input.ProductNO, filePath); //LoginResponse loginResponse = LocalApi.Execute(new LoginRequest() //{ // UserName = "******", // Password = "******" //}); //AppContext.Current.Reset(); //AppContext.Current.Name = loginResponse.Name; //AppContext.Current.UserId = loginResponse.UserId; //if (!string.IsNullOrEmpty(loginResponse.PermissionCodes)) // AppContext.Current.PermissionCodes.AddRange(loginResponse.PermissionCodes.Split(',')); //if (!string.IsNullOrEmpty(loginResponse.CraftDIDs)) // AppContext.Current.CraftDIDs.AddRange(((IEnumerable<string>)loginResponse.CraftDIDs.Split(',')).Select<string, int>(m => int.Parse(m))); //AppContext.Current.Name = json_input.StaffID; //MainWindow mainWindow = new MainWindow(); //mainWindow.Show(); //Application.Current.MainWindow = mainWindow; this.Close(); } else { MessageBox.Show("不存在此用户", "提示"); //this.Close(); } } }