private bool work(BackgroundWorker bk) { DataTable t = ProjectBLL.GetData(" ProjectLevel = " + Models.ProjectLevels.项目工程); this.Invoke(new EventHandler((a, b) => { this.comboBox1.DisplayMember = "ProjectName"; this.comboBox1.ValueMember = "ProjectId"; this.comboBox1.DataSource = t; this.Instar.SelectedIndex = 4; this.yangsheng.SelectedIndex = 0; this.GroupInfo.SelectedIndex = 0; })); DataTable table = this.deviceBLL.GetData(" ifUpload = 0 "); if (table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { Models.DeviceData detail = deviceBLL.GetModelByRow(row); this.DetailsForUpload.Enqueue(detail); } } setProcess(); upload(); return(true); }
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);//上传成功 更新失败 } } } }
public void Add(Models.DeviceData data) { var x = new DeviceData { DeviceID = data.DeviceID, ValueA = data.ValueA, ValueB = data.ValueB, ValueC = data.ValueC, ValueD = data.ValueD, CreatedDateTime = DateTime.Now.ToString() }; var y = new MongoLayer("Devices", "test"); y.Add(x); //return false; }
private bool SaveDeviceDate(Models.DeviceData data) { Models.ProjectDetails ProjectDetail = data.ProjectDetail; if (SaveProjectDetails(ProjectDetail)) { /* * 读卡数据处理逻辑 */ return(dataBll.Create(data).ExcuteState); } return(false); }
public bool DataReceive(string str) { try { Models.DeviceData details = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.DeviceData>(str); Thread.Sleep(200); } catch (Exception ex) { throw new Exception("无效的参数"); } return(true); }
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 AddEetailsToUpload(Models.DeviceData details) { this.DetailsForUpload.Enqueue(details); }
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(); })); } } //}); }