private void btnChange_Click_1(object sender, EventArgs e) { try { if (index < videoList.Length - 1) { index++; } else { index = 0; } string serverUrl = CommonUtil.getServerIpAndPort(); url = videoList[index]; if (!string.IsNullOrEmpty(url)) { string videoUrl = serverUrl + "inspection/videoPlayer.jsp?video_url=" + url; this.webBrowser1.Url = new Uri(videoUrl); } } catch (Exception ex) { MessagePrompt.Show("播放时出错,错误信息:" + ex.Message); } }
private void VideoPlayer_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(url)) { //解析视频地址 videoList = url.Split(';'); if (videoList.Length > 0) { url = videoList[0]; } if (!string.IsNullOrEmpty(url)) { string serverUrl = CommonUtil.getServerIpAndPort(); string videoUrl = serverUrl + "inspection/videoPlayer.jsp?video_url=" + url; this.webBrowser1.Url = new Uri(videoUrl); } else { MessagePrompt.Show("未找到视频链接,重新打开试一下!"); } } else { MessagePrompt.Show("未找到视频链接,重新打开试一下!"); } }
private bool uploadUnSubmitForm(string json) { bool flag = false; try { string content = ""; byte[] data = encoding.GetBytes(json); string url = CommonUtil.getServerIpAndPort() + "ThreadingOperation/saveThreadInspectionRecordOfWinform.action"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.KeepAlive = false; request.Method = "POST"; request.ContentType = "application/json;characterSet:utf-8"; request.ContentLength = data.Length; using (Stream sm = request.GetRequestStream()) { sm.Write(data, 0, data.Length); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream streamResponse = response.GetResponseStream(); using (StreamReader sr = new StreamReader(streamResponse)) { content = sr.ReadToEnd(); } response.Close(); if (content != null) { JObject jobject = JObject.Parse(content); string rowsJson = jobject["rowsData"].ToString(); if (rowsJson.Trim().Contains("success")) { flag = true; } else { flag = false; } } } catch (Exception e) { flag = false; } return(flag); }
public void excuteDelteInspectionRecord(int index) { try { //获取删除选中行的检验记录编号 object obj1 = this.dataGridView1.Rows[index].Cells["thread_inspection_record_code"].Value; if (obj1 == null) { MessagePrompt.Show("删除失败!"); return; } string thread_inspection_record_code = obj1.ToString(); JObject jsonData = new JObject { { "thread_inspection_record_code", thread_inspection_record_code } }; ASCIIEncoding encoding = new ASCIIEncoding(); String content = ""; byte[] data = encoding.GetBytes(jsonData.ToString()); string url = CommonUtil.getServerIpAndPort() + "ThreadingOperation/delThreadInspectionRecordOfWinform.action"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.KeepAlive = false; request.Method = "POST"; request.ContentType = "application/json;characterSet:UTF-8"; request.ContentLength = data.Length; using (Stream sm = request.GetRequestStream()) { sm.Write(data, 0, data.Length); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream streamResponse = response.GetResponseStream(); StreamReader streamRead = new StreamReader(streamResponse, Encoding.UTF8); Char[] readBuff = new Char[1024]; int count = streamRead.Read(readBuff, 0, 1024); while (count > 0) { String outputData = new String(readBuff, 0, count); content += outputData; count = streamRead.Read(readBuff, 0, 1024); } response.Close(); string jsons = content; if (jsons == null) { MessagePrompt.Show("删除失败!"); return; } JObject jobject = JObject.Parse(jsons); string rowsJson = jobject["rowsData"].ToString(); if (rowsJson.Trim().Contains("{}")) { MessagePrompt.Show("删除失败!"); return; } if (rowsJson.Contains("True")) { MessagePrompt.Show("删除成功!"); //刷新检验记录列表(dataGridView) getThreadingProcessData(); } else { MessagePrompt.Show("删除失败!"); } } catch (Exception ex) { MessagePrompt.Show("删除失败,失败原因:" + ex.Message); } }
public void getThreadingProcessData() { try { //封装查询螺纹检验记录的参数(参数依次是:操作工工号、班别、班次、合同号、接箍类型、外径、壁厚、炉号、试批号、开始日期、结束日期) JObject jsonData = new JObject { { "operator_no", this.txtOperatorno.Text.Trim() }, { "production_crew", this.cmbProductionCrew.Text.Trim() }, { "production_shift", this.cmbProductionShift.Text.Trim() }, { "contract_no", this.cmbContractNo.Text.Trim() }, { "threading_type", this.cmbThreadingType.Text.Trim() }, { "od", this.cmbOd.Text.Trim() }, { "wt", this.cmbWt.Text.Trim() }, { "pipe_heat_no", this.cmbPipeHeatNo.Text.Trim() }, { "pipe_lot_no", this.cmbPipeLotNo.Text.Trim() }, { "beginTime", this.dateTimePicker1.Value.ToString("yyyy-MM-dd") }, { "endTime", this.dateTimePicker2.Value.ToString("yyyy-MM-dd") } }; ASCIIEncoding encoding = new ASCIIEncoding(); String content = null; byte[] data = encoding.GetBytes(jsonData.ToString()); string url = CommonUtil.getServerIpAndPort() + "ThreadingOperation/getThreadInspectionRecordOfWinform.action"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.KeepAlive = false; request.Method = "POST"; request.ContentType = "application/json;characterSet:UTF-8"; request.ContentLength = data.Length; using (Stream sm = request.GetRequestStream()) { sm.Write(data, 0, data.Length); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream streamResponse = response.GetResponseStream(); using (StreamReader sr = new StreamReader(streamResponse)) { content = sr.ReadToEnd(); } response.Close(); if (content != null) { JObject jobject = JObject.Parse(content); string rowsJson = jobject["rowsData"].ToString(); if (!rowsJson.Trim().Contains("{}")) { //将搜索到json格式的螺纹检验数据转换成对象 List <ThreadInspectionRecord> list = JsonConvert.DeserializeObject <List <ThreadInspectionRecord> >(rowsJson); foreach (ThreadInspectionRecord item in list) { //此时item.Inspection_time格式如:1531909218000,需转换成用户可读的时间类型 item.Inspection_time = CommonUtil.ConvertTimeStamp(item.Inspection_time); } //设置dataGridView数据源为list集合 this.dataGridView1.DataSource = list; } else { this.dataGridView1.DataSource = null; } } } catch (Exception e) { //throw e; } }
private void getSearchParam() { try { JObject json = new JObject { }; ASCIIEncoding encoding = new ASCIIEncoding(); String content = null; byte[] data = encoding.GetBytes(json.ToString()); string url = CommonUtil.getServerIpAndPort() + "Contract/getAllContractNoOfWinform.action"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.KeepAlive = false; request.Method = "POST"; request.ContentType = "application/json;characterSet:UTF-8"; request.ContentLength = data.Length; using (Stream sm = request.GetRequestStream()) { sm.Write(data, 0, data.Length); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream streamResponse = response.GetResponseStream(); using (StreamReader sr = new StreamReader(streamResponse)) { content = sr.ReadToEnd(); } response.Close(); if (content != null) { JObject jobject = JObject.Parse(content); string rowsJson = jobject["rowsData"].ToString(); //将获取到的json格式的合同信息转成List对象 List <ContractInfo> list = JsonConvert.DeserializeObject <List <ContractInfo> >(rowsJson); //添加空白选项 this.cmbContractNo.Items.Add(""); this.cmbOd.Items.Add(""); this.cmbWt.Items.Add(""); this.cmbThreadingType.Items.Add(""); this.cmbPipeHeatNo.Items.Add(""); this.cmbPipeLotNo.Items.Add(""); //遍历合同信息集合 foreach (ContractInfo item in list) { //如果合同编号不为空 if (!string.IsNullOrWhiteSpace(item.Contract_no)) { //如果合同编号下拉框没有当前合同编号 if (!cmbContractNo.Items.Contains(item.Contract_no)) { //添加当前合同编号到合同编号下拉框中 this.cmbContractNo.Items.Add(item.Contract_no); } } //追加外径到外径下拉框中 if (!string.IsNullOrWhiteSpace(item.Od)) { if (!this.cmbOd.Items.Contains(item.Od)) { this.cmbOd.Items.Add(item.Od); } } //追加壁厚到壁厚下拉框中 if (!string.IsNullOrWhiteSpace(item.Wt)) { if (!this.cmbWt.Items.Contains(item.Wt)) { this.cmbWt.Items.Add(item.Wt); } } //追加螺纹类型到螺纹类型下拉框中 if (!string.IsNullOrWhiteSpace(item.Threading_type)) { if (!this.cmbThreadingType.Items.Contains(item.Threading_type)) { this.cmbThreadingType.Items.Add(item.Threading_type); } } //追加炉号到炉号下拉框中 if (!string.IsNullOrWhiteSpace(item.Pipe_heat_no)) { if (!this.cmbPipeHeatNo.Items.Contains(item.Pipe_heat_no)) { this.cmbPipeHeatNo.Items.Add(item.Pipe_heat_no); } } //追加试批号到试批号下拉框中 if (!string.IsNullOrWhiteSpace(item.Pipe_lot_no)) { if (!this.cmbPipeLotNo.Items.Contains(item.Pipe_lot_no)) { this.cmbPipeLotNo.Items.Add(item.Pipe_lot_no); } } } //设置主窗体搜索参数下拉框默认选择第一条空白选项 this.cmbProductionCrew.SelectedIndex = 0; this.cmbProductionShift.SelectedIndex = 0; this.cmbContractNo.SelectedIndex = 0; this.cmbOd.SelectedIndex = 0; this.cmbWt.SelectedIndex = 0; this.cmbThreadingType.SelectedIndex = 0; this.cmbPipeHeatNo.SelectedIndex = 0; this.cmbPipeLotNo.SelectedIndex = 0; this.cmbPipeHeatNo.SelectedIndex = 0; } } catch (Exception e) { //MessagePrompt.Show("获取查询条件时出错,错误原因:" + e.Message); } }
private void button1_Click(object sender, EventArgs e) { //加密当前mac地址 string verification_code = CommonUtil.Encrypt(); //操作工工号 string employee_no = this.txtLoginName.Text.Trim(); //密码 string upwd = this.txtLoginPwd.Text.Trim(); this.button1.Text = "登录中..."; this.button1.Enabled = false; try { this.label_msg.Text = "发送登录请求。。。"; //封装客户端登录所传数据 JObject json = new JObject { { "employee_no", employee_no }, { "ppassword", upwd }, { "verification_code", verification_code } }; ASCIIEncoding encoding = new ASCIIEncoding(); String content = ""; byte[] data = encoding.GetBytes(json.ToString()); string url = CommonUtil.getServerIpAndPort() + "Login/userLoginOfWinform.action"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.KeepAlive = false; request.Method = "POST"; request.ContentType = "application/json;characterSet:UTF-8"; request.ContentLength = data.Length; using (Stream sm = request.GetRequestStream()) { sm.Write(data, 0, data.Length); } this.label_msg.Text = "登录验证中。。。"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream streamResponse = response.GetResponseStream(); using (StreamReader sr = new StreamReader(streamResponse)) { content = sr.ReadToEnd(); } response.Close(); if (content != null) { //如果返回的数据为"{}" this.label_msg.Text = ""; if (content.Trim().Contains("{}")) { this.label_msg.Text = "登录异常!"; MessagePrompt.Show("登录异常!"); } else { //如果登录成功,返回的数据格式为{success:'True/False',msg:'',rowsData:''},rowsData存放的为当前登录用户的信息 JObject jobject = JObject.Parse(content); string loginFlag = jobject["success"].ToString().Trim(); string msg = jobject["msg"].ToString().Trim(); if (loginFlag.Contains("True")) { string rowsJson = jobject["rowsData"].ToString(); if (rowsJson != null) { //登录成功返回当前登录用户的信息,将返回的json格式的信息转换成指定对象 this.label_msg.Text = "登录成功,初始化控件中..."; Person person = JsonConvert.DeserializeObject <Person>(rowsJson); IndexWindow.getForm().Show(); NumberKeyboardForm.getForm(); AlphabetKeyboardForm.getForm(); ScanerHook.executeScanerHook(); this.Hide(); } else { this.label_msg.Text = "系统繁忙,请稍后重试!"; MessagePrompt.Show("系统繁忙,请稍后重试!"); } } else { this.label_msg.Text = msg; MessagePrompt.Show(msg); } } } this.button1.Enabled = true; this.button1.Text = "登录"; } catch (WebException ex) { MessagePrompt.Show("网络错误,错误信息:" + ex.Message); this.button1.Enabled = true; this.button1.Text = "登录"; } catch (Exception ec) { MessagePrompt.Show("连接服务器失败,失败原因:" + ec.Message); this.button1.Enabled = true; this.button1.Text = "登录"; } }