private void upload()//修改上传列表校验情况,上传成功更新没成功的情况 { if (this.DetailsForUpload.Count == 0 || !this.ifCanConnectToServer) { Thread.Sleep(5000); upload(); } else { Models.DeviceData DeviceData = this.DetailsForUpload.Dequeue(); if (DeviceData.IfUpload == 0) { SendProjectDetailsToServer(DeviceData);//上传 } else { BLL.FunctionResult result = this.deviceBLL.Edit(DeviceData); if (result.ExcuteState) { } else { this.DetailsForUpload.Enqueue(DeviceData);//上传成功 更新失败 } } } }
private void button2_Click(object sender, EventArgs e) { BLL.UserBLL bll = new BLL.UserBLL(); if (bll.GetData().Rows.Count == 0) { Models.Users user = new Models.Users() { UserId = Utils.getGUID(), UserName = this.textBox1.Text, UserPassword = this.textBox2.Text }; BLL.FunctionResult result = bll.Create(user); if (result.ExcuteState) { MessageBox.Show("添加用户成功"); bind(); } } }
private void SendProjectDetailsToServer(Models.DeviceData DeviceData) { Models.DeviceData dd = deviceBLL.GetModel(DeviceData.DataId); ServerOption.ServerDataReceive rec = new ServerOption.ServerDataReceive(); Models.DataForSend ds = new Models.DataForSend() { Biaoduan = RFIDApplication.Properties.Settings.Default.BiaoduanCode, Item = dd }; string str = Newtonsoft.Json.JsonConvert.SerializeObject(ds); string urlstr = "http://www.intellconst.com/wbs/YLJMenuRFID.aspx?username=YLJJK&password=YLJJK123&TypeID=SendYLJDATA"; Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("para", str); string Str = postSynchronous(urlstr, parameters); if (Str.IndexOf("Sucess") >= 0) { DeviceData.IfUpload = 1; BLL.FunctionResult result = this.deviceBLL.Edit(DeviceData); if (result.ExcuteState) { } else { this.DetailsForUpload.Enqueue(DeviceData);//上传成功 更新失败 } } else if (Str.ToLower().Contains("chongfu")) { dd.NotUploadReason = "RFID重复"; this.deviceBLL.Edit(dd); } else { this.DetailsForUpload.Enqueue(DeviceData);//上传失败 添加到待上传队列 } setProcess(); upload(); }
private void button1_Click(object sender, EventArgs e) { //Task.Factory.StartNew(() => //{ if (yanzhengGroupText()) { Models.ProjectDetails details = detailsBLL.GetModel(this.comboBox4.SelectedValue.ToString()); //details.DeviceDataList = new List<Models.DeviceData>(); BLL.DeviceDataBLL DeviceDataBLL = new BLL.DeviceDataBLL(); List <string> list = new List <string>() { "A", "B", "C", "D", "E", "F", "G", "H", "I" }; int n = (this.GroupInfo.SelectedIndex + 1) * 3; bool ifSuccess = true; string CreateDataStr = DateTime.Now.ToString("yyyyMMddHHmmss"); string CreateDataStrGroup = ""; int m = this.GroupTextlist.Where(p => !string.IsNullOrWhiteSpace(p.Text)).Count(); int a = m / 3; int b = m % 3; //if (a == 0) //{ // DialogResult dr = MessageBox.Show("至少需要填写一组数据,是否继续","提示",MessageBoxButtons.OKCancel ); // if (dr != DialogResult.OK) // { // MoveToNextText(); // return; // } //} if (b != 0) { string messagestr = ""; if (this.GroupInfo.SelectedIndex == 0) { if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0) { messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n"; } } else if (this.GroupInfo.SelectedIndex == 1) { if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0) { messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n"; } if (textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0) { messagestr += "第二组数据不完整,是否继续提交绑定\r\n\r\n"; } } else if (this.GroupInfo.SelectedIndex == 2) { if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0) { messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n"; } if (textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0) { messagestr += "第二组数据不完整,是否继续提交绑定\r\n\r\n"; } if (textBox7.Text.Length == 0 || textBox8.Text.Length == 0 || textBox9.Text.Length == 0) { messagestr += "第三组数据不完整,是否继续提交绑定\r\n\r\n"; } } DialogResult dr = MyDialogOption.show("提示", messagestr, "是,继续完成绑定", "否,返回补充完整"); // DialogResult dr = MessageBoxEx.Show("数据不完整,是否继续提交绑定", "提示", MessageBoxButtons.OKCancel, new string[] { "是,继续完成绑定", "否,返回补充完整" }); // DialogResult dr = MessageBox.Show("数据不完整,是否继续提交绑定?", "确认", MessageBoxButtons.OKCancel); if (dr != DialogResult.OK) { MoveToNextText(); return; } } for (int i = 0; i < n; i++) { if (list[i] == "A" || list[i] == "B" || list[i] == "C") { CreateDataStrGroup = CreateDataStr + "A"; } else if (list[i] == "D" || list[i] == "E" || list[i] == "F") { CreateDataStrGroup = CreateDataStr + "B"; } else { CreateDataStrGroup = CreateDataStr + "C"; } Models.DeviceData deviceData = new Models.DeviceData() { DataId = this.comboBox4.SelectedValue.ToString() + "_" + list[i] + "_" + Utils.getGUID(), DeviceValue = this.GroupTextlist[i].Text, GroupName = list[i], ProjectDetailId = this.comboBox4.SelectedValue.ToString(), Instar = this.Instar.SelectedItem.ToString(), YangSheng = this.yangsheng.SelectedItem.ToString(), SamplingDate = this.SamplingDate.Value.ToString("yyyy-MM-dd"), CreateDate = CreateDataStrGroup, IfUpload = 0, NotUploadReason = "网络" }; if (!Regex.IsMatch(deviceData.DeviceValue, "^\\d{15}$")) { continue; } //判断重复 if (DeviceDataBLL.GetModelByWhere(" DeviceValue='" + deviceData.DeviceValue + "'") != null) { MessageBox.Show("绑定数据库中已经存在[" + deviceData.DeviceValue + "]RFID编号请核实!"); return; } BLL.FunctionResult result = DeviceDataBLL.Create(deviceData); if (!result.ExcuteState) { ifSuccess = false; break; } this.DeviceDataTotal++; setProcess(); this.DetailsForUpload.Enqueue(deviceData); } if (ifSuccess) { details.DetailState = 1; this.Invoke(new EventHandler((aa, bb) => { MessageBox.Show("绑定数据完成!"); resetTextBox(); MoveToNextText(); })); } } //}); }