private void MES_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(MES.Text) || String.IsNullOrEmpty(MES.Text)) { MES.Select(0, 0); } }
public void Init() { this.mes = Current.mes; this.tbFlag.Text = "1"; this.tbTerminal.Text = Current.mes.Terminal; this.tbUserId.Text = Current.mes.UserId; }
void Details(MES mes) { txtEmployee.EditValue = mes.EmployeeId; txtOffice.EditValue = mes.OfficeId; txtRequest.Text = mes.Request; txtItemSpec.Text = mes.ItemSpec; lblMESNo.Text = mes.MESId; txtPosition.Text = mes.Position; }
private void importador_objetivos_Load(object sender, EventArgs e) { string MES; DateTime fecha_hoy = DateTime.Now; MES = MonthName(fecha_hoy.Month); MES_N = fecha_hoy.Month; comboBox1.Text = MES.ToUpper(); noc.Columns.Add("ERROR", typeof(string)); }
public frmAddEditMES(MES oldItem, MethodType methodType) { InitializeComponent(); dtDate.DateTime = DateTime.Now; this.oldItem = oldItem; this.methodType = methodType; Details(oldItem); }
public static void Insert() { if (Battery.Id > 0) { Context.InsulationContext.DataLogs.Add(new InsulationDataLog() { User = AppCurrent.User, Battery = Battery, Resistance = 0, Voltage = 0, TimeSpan = 0, Temperature = 0, IsUploaded = false, DateTime = DateTime.Now }); Context.InsulationContext.SaveChanges(); AppCurrent.YieldNow.FeedingOK++; Battery = new Battery(); } if (Resistance > -1) { var data = Context.InsulationContext.DataLogs.Where(d => d.Resistance == 0) .OrderByDescending(d => d.DateTime).Take(3).OrderBy(d => d.DateTime).FirstOrDefault(); if (data != null) { data.Resistance = Resistance; data.Voltage = Voltage; data.TimeSpan = TimeSpan; Context.InsulationContext.SaveChanges(); } Resistance = -1; } if (Temperature > -1) { var data = Context.InsulationContext.DataLogs.Where(d => d.Temperature == 0) .OrderByDescending(d => d.DateTime).Take(3).OrderBy(d => d.DateTime).FirstOrDefault(); if (data != null) { data.Temperature = Temperature; Context.InsulationContext.SaveChanges(); if (data.Id > 0) { MES.Upload(data.Id); } } Temperature = -1; } }
public void minimum_edit_script() { MES mes = new MES(); { var script = mes.Find("SITTING", "KITTEN"); Assert.AreEqual(3, script.Last().Distance); int i = 0; var expected = new Tuple <char, char, EditActions>[] { new Tuple <char, char, EditActions>('S', 'K', EditActions.Substitute), new Tuple <char, char, EditActions>('I', 'E', EditActions.Substitute), new Tuple <char, char, EditActions>('G', 'N', EditActions.Insert) }; for (int x = 0; x < script.Count; x++) { if (script[x].Edit != EditActions.Copy) { Assert.AreEqual(expected[i].Item1, script[x].A); Assert.AreEqual(expected[i].Item2, script[x].B); Assert.AreEqual(expected[i].Item3, script[x].Edit); i++; } } } { var script = mes.Find("SATURDAY", "SUNDAY"); Assert.AreEqual(3, script.Last().Distance); int i = 0; var expected = new Tuple <char, char, EditActions>[] { new Tuple <char, char, EditActions>('A', 'S', EditActions.Insert), new Tuple <char, char, EditActions>('T', 'S', EditActions.Insert), new Tuple <char, char, EditActions>('R', 'N', EditActions.Substitute) }; for (int x = 0; x < script.Count; x++) { if (script[x].Edit != EditActions.Copy) { Assert.AreEqual(expected[i].Item1, script[x].A); Assert.AreEqual(expected[i].Item2, script[x].B); Assert.AreEqual(expected[i].Item3, script[x].Edit); i++; } } } }
private void BtnUpload_Click(object sender, EventArgs e) { var barcode = this.tbBarcode.Text.Trim(); var flag = this.tbFlag.Text.Trim(); var terminal = this.tbTerminal.Text.Trim(); var userId = this.tbUserId.Text.Trim(); if (string.IsNullOrEmpty(barcode)) { Tip.Alert("输入电芯条码为空!"); return; } if (string.IsNullOrEmpty(flag)) { Tip.Alert("输入调用类型为空!"); return; } if (string.IsNullOrEmpty(terminal)) { Tip.Alert("输入调用工位为空!"); return; } if (string.IsNullOrEmpty(userId)) { Tip.Alert("输入调用者为空!"); return; } MesRequest request = new MesRequest() { Barcode = barcode, Flag = flag, Terminal = terminal, UserId = userId }; Thread t = new Thread(() => { var response = MES.UploadBatteryInfo(request); this.BeginInvoke(new MethodInvoker(() => { this.tbRtCode.Text = response.Code.ToString(); this.tbRtMsg.Text = response.RtMsg; Color fore = response.Code == 0 ? Color.Green : Color.Red; this.tbRtCode.ForeColor = fore; this.tbRtMsg.ForeColor = fore; })); }); t.Start(); }
private void balancestorage(string qrcode) { if (qrcode == "NOREAD") { return; } ushort s2; string dstr = "select jitaiid from barcodelog where qrcode = '" + qrcode.ToString() + "';"; DataSet myds = MES.GetDataSet(dstr, "barcodelog"); string jitaiid = myds.Tables[0].Rows[0]["jitaiid"].ToString(); string dstr2 = "select * from tyremaintenance where jitaiid = '" + jitaiid + "';"; DataSet myds2 = MES.GetDataSet(dstr2, "luntaiguige"); string luntaiguige = myds2.Tables[0].Rows[0]["luntaiguige"].ToString(); string singleheight = myds2.Tables[0].Rows[0]["singleheight"].ToString(); /* DataSet myds = new DataSet(); * dStr = " select id,rimgrade from tyre where qrcode = '" + qrcode + "';"; * myds = Utils.DatabaseUtils.GetDataSet(dStr, "rimgrade"); * int rimgrade = int.Parse(myds.Tables[0].Rows[0]["rimgrade"].ToString());//轮辋等级 * int s1 = int.Parse(myds.Tables[0].Rows[0]["id"].ToString());*/ if (rimgrade < 1000) { //让去动平衡前暂存区1 s2 = 1; } if (rimgrade > 1000 && rimgrade < 2000) { //让去动平衡前暂存区2 s2 = 2; } else { //让去动平衡前暂存区3 s2 = 3; } if (myLine.SetMove2(s1, s2)) { DataSet myds1 = new DataSet(); dStr1 = "update tyre set tyrestatus = 4 where qrcode = '" + qrcode + "';"; } else { Trace.WriteLine("通讯失败!"); } }
void Add(MES mes) { try { using (UnitOfWork unitOfWork = new UnitOfWork()) { mes.Id = this.mESId; mes.MESId = this.mESId.ToString("EPiS-0000"); mes.DateCreated = DateTime.Now; unitOfWork.MESRepo.Update(mes); unitOfWork.Save(); } } catch (Exception e) { MessageBox.Show(e.Message, e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void Edit(MES mes) { try { using (UnitOfWork unitOfWork = new UnitOfWork()) { mes.Id = oldItem.Id; mes.DateCreated = oldItem.DateCreated; mes.ReceivedBy = oldItem.ReceivedBy; mes.MESId = oldItem.Id.ToString("EPiS-0000"); unitOfWork.MESRepo.Update(mes); unitOfWork.Save(); } } catch (Exception e) { MessageBox.Show(e.Message, e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public LoginWindow() { InitializeComponent(); new DbInitializer().Initialize(); this.DataContext = Current.App; myMediaTimeline.Source = new Uri(AppDomain.CurrentDomain.BaseDirectory + "Videos/LoginHead.mp4"); if (Current.Option.IsRememberMe) { var user = TengDa.Wpf.Context.UserContext.Users.SingleOrDefault(u => u.Id == Current.Option.LastLoginUserId); if (user != null) { this.userNameTextBox.Text = user.Name; this.passwordBox.Password = Base64.DecodeBase64(user.Password); this.ProfileImage.Source = new BitmapImage(new Uri(user.ProfilePicture, UriKind.Relative));; } } MES.GetInfo(); }
private void BtnUpload_Click(object sender, EventArgs e) { var selectName = this.cbInterfaceName.SelectedItem.ToString(); var request = this.tbRequest.Text; var response = ""; new Thread(() => { this.BeginInvoke(new MethodInvoker(() => { this.btnUpload.Enabled = false; })); if (selectName == "身份验证接口") { response = MES.IdentityVerification(request); Current.option.MesManuIdentityVerificationInput = request; } else if (selectName == "电芯与托盘信息查询接口") { response = MES.GetTrayBindingInfo(request); Current.option.MesManuGetTrayBindingInfoInput = request; } else if (selectName == "记录设备状态接口") { response = MES.RecordDeviceStatus(request); Current.option.MesManuRecordDeviceStatusInput = request; } else if (selectName == "二次高温数据上传接口") { response = MES.UploadSecondaryHighTempData(request); Current.option.MesManuUploadSecondaryHighTempDataInput = request; } this.BeginInvoke(new MethodInvoker(() => { this.tbResponse.Text = response; this.btnUpload.Enabled = true; })); }).Start(); }
protected override void Seed(AppContext context) { var storages = new List <Storage>(); for (var i = 0; i < Common.STOR_COL_COUNT; i++) { for (int j = 0; j < Common.STOR_FLOOR_COUNT; j++) { var name = string.Format("料仓{0:D2}-{1}", i + 1, j + 1); storages.Add(new Storage() { Name = name, Company = "SZYitong", CreateTime = DateTime.Now, Location = "", ModelNumber = "", SerialNumber = "", IsEnabled = true, Column = i + 1, Floor = j + 1, StillTimeSpan = 120 }); } } storages.ForEach(o => context.Storages.Add(o)); var mes = new MES() { Name = "MES", Host = "127.0.0.1", Company = "GMCC", ReadTimeout = 10, CommInterval = 1000, CommType = "", CreateTime = DateTime.Now, IsEnabled = false, Location = "", SerialNumber = "", ModelNumber = "", }; context.MESs.Add(mes); var plc = new PLC() { Name = "PLC", IP = "192.168.1.239", Port = 9600, Company = "OMRON", ModelNumber = "CJ2M-CP33", ReadTimeout = 0, CommInterval = 1000, CommType = "OmronFinsTcp", CreateTime = DateTime.Now, IsEnabled = true, Location = "", SerialNumber = "", }; context.PLCs.Add(plc); var batteryScaner = new BatteryScaner() { Name = "电池扫码枪", IP = "192.168.3.100", Port = 51236, Company = "Datalogic", ModelNumber = "MATRIX 300N 482-011", ReadTimeout = 800, CommInterval = 1000, ScanCommand = "T", CommType = "Ethernet", CreateTime = DateTime.Now, IsEnabled = true, Location = "", SerialNumber = "", }; context.BatteryScaners.Add(batteryScaner); var trayScaners = new List <TrayScaner>() { new TrayScaner() { Name = "绑盘托盘扫码枪", PortName = "COM9", BaudRate = 115200, Parity = System.IO.Ports.Parity.None, DataBits = 8, StopBits = System.IO.Ports.StopBits.None, Company = "Honeywell", ModelNumber = "3320G-2-INT", ReadTimeout = 800, CommInterval = 1500, ScanCommand = "16 54 0D", CommType = "Serial", CreateTime = DateTime.Now, IsEnabled = true, Location = "", SerialNumber = "", }, new TrayScaner() { Name = "解盘托盘扫码枪", PortName = "COM10", BaudRate = 115200, Parity = System.IO.Ports.Parity.None, DataBits = 8, StopBits = System.IO.Ports.StopBits.None, Company = "Honeywell", ModelNumber = "3320G-2-INT", ReadTimeout = 800, CommInterval = 1000, ScanCommand = "16 54 0D", CommType = "Serial", CreateTime = DateTime.Now, IsEnabled = true, Location = "", SerialNumber = "", } }; trayScaners.ForEach(o => context.TrayScaners.Add(o)); var task = new CurrentTask() { Type = TaskType.未知, PreType = TaskType.未知, ProcTrayId = -1, StorageId = -1, StartTime = Default.DateTime, Status = Model.TaskStatus.完成 }; context.CurrentTasks.Add(task); }
private void OutOven(object obj) { string code = obj.ToString(); Clamp clamp = Current.ovens[i].Floors[j].Clamps.Single(c => c.Code == code); string msg = string.Empty; lock (locker) { try { if (Current.mes.IsAlive) { if (Current.mes.IsOffline) { Current.mes.IsOffline = false; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 正在上传料盒信息..."; this.lbTip.ForeColor = Color.LightGreen; })); if (!MES.UploadCellInfo(clamp)) { this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = string.Format("{0}: {1}", code, "上传失败"); this.lbTip.ForeColor = Color.Red; })); LogHelper.WriteError(string.Format("{0}: {1}", code, "上传失败")); return; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 上传MES成功"; this.lbTip.ForeColor = Color.LightGreen; })); LogHelper.WriteInfo(code + " 上传MES成功"); Thread.Sleep(100); } else { if (TengDa.WF.Current.user.Group.Level > 2 && !Current.mes.IsOffline) { Current.mes.IsOffline = true; } if (!Current.mes.IsOffline) { MesOfflineVerify m = new MesOfflineVerify(); DialogResult dr = m.ShowDialog(); if (dr == DialogResult.OK) { if (!Current.mes.IsOffline) { Current.mes.IsOffline = true; } } else { Error.Alert("无法连接至MES,无法入腔!"); return; } } } Yield.BlankingOK += clamp.Batteries.Count; Current.ovens[i].Floors[j].Clamps.Remove(clamp); string clampids = string.Empty; foreach (Clamp c in Current.ovens[i].Floors[j].Clamps) { clampids += c.Id + ","; } Current.ovens[i].Floors[j].ClampIds = clampids.TrimEnd(','); this.BeginInvoke(new MethodInvoker(() => { foreach (ListViewItem li in this.lvClampCodes.Items) { foreach (ListViewItem.ListViewSubItem subli in li.SubItems) { if (subli.Text == code) { this.lvClampCodes.Items.Remove(li); } } } })); clampCodes.Remove(code); } catch (Exception ex) { Error.Alert(ex.ToString()); } } }
private void InOven(object obj) { string code = obj.ToString().Split(',')[0]; int index = TengDa._Convert.StrToInt(obj.ToString().Split(',')[1], -1); string msg = string.Empty; string techNo = string.Empty; lock (locker) { try { List <Cell> cells = new List <Cell>(); List <TechStandard> techStandards = new List <TechStandard>(); if (Current.mes.IsAlive) { if (Current.mes.IsOffline) { Current.mes.IsOffline = false; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 正在获取电芯数据和工艺参数..."; this.lbTip.ForeColor = Color.LightGreen; })); if (!MES.GetInfo(Current.ovens[i].Floors[j].Number, code, out techNo, out cells, out techStandards, out msg)) { this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = string.Format("{0}: {1}", code, msg); this.lbTip.ForeColor = Color.Red; })); LogHelper.WriteError(string.Format("{0}: {1}", code, msg)); return; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 获取数据成功"; this.lbTip.ForeColor = Color.LightGreen; })); LogHelper.WriteInfo(code + " 获取数据成功"); Thread.Sleep(100); } else { if (TengDa.WF.Current.user.Group.Level > 2 && !Current.mes.IsOffline) { Current.mes.IsOffline = true; } if (!Current.mes.IsOffline) { MesOfflineVerify m = new MesOfflineVerify(); DialogResult dr = m.ShowDialog(); if (dr == DialogResult.OK) { if (!Current.mes.IsOffline) { Current.mes.IsOffline = true; } } else { Error.Alert("无法连接至MES,无法入腔!"); return; } } } //料盒/托盘保存到数据库 Clamp clamp = new Clamp(); clamp.Code = code; clamp.EnterTime = DateTime.Now; clamp.FloorId = Current.ovens[i].Floors[j].Id; clamp.Location = index.ToString(); clamp.OutTime = TengDa.Common.DefaultTime; clamp.BakingStartTime = TengDa.Common.DefaultTime; clamp.BakingStopTime = TengDa.Common.DefaultTime; clamp.isUploaded = false; clamp.isFinished = false; clamp.techNo = techNo; int clampid = Clamp.Add(clamp, out msg); if (clampid < 1) { Error.Alert("clampid < 1"); return; } Current.ovens[i].Floors[j].Clamps.Add(new Clamp(clampid)); string clampids = string.Empty; foreach (Clamp c in Current.ovens[i].Floors[j].Clamps) { clampids += c.Id + ","; } Current.ovens[i].Floors[j].ClampIds = clampids.TrimEnd(','); this.BeginInvoke(new MethodInvoker(() => { ListViewItem li = new ListViewItem();//创建行对象 li.Text = (++clampNum).ToString(); li.SubItems.Add(code); li.SubItems.Add(""); this.lvClampCodes.Items.Add(li); })); clampCodes.Add(code); if (Current.mes.IsAlive) { //电芯数据保存到数据库 List <Battery> batteries = new List <Battery>(); for (int ii = 0; ii < cells.Count; ii++) { Battery battery = new Battery(); battery.Code = cells[ii].sfc_no; battery.ClampId = clampid; battery.Location = cells[ii].seq_no; batteries.Add(battery); } this.BeginInvoke(new MethodInvoker(() => { ListViewItem li_n = lvClampCodes.Items.Cast <ListViewItem>().First(x => x.SubItems[1].Text == code); if (li_n != null) { li_n.SubItems[2].Text = batteries.Count.ToString(); } })); if (!Battery.Add(batteries, out msg)) { this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 电芯数据存入数据库失败!"; this.lbTip.ForeColor = Color.Red; })); LogHelper.WriteError(code + " 电芯数据存入数据库失败"); return; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 电芯数据存入数据库成功!"; this.lbTip.ForeColor = Color.LightGreen; })); LogHelper.WriteInfo(code + " 电芯数据存入数据库成功!"); Thread.Sleep(100); //工艺参数保存到数据库 if (!TechStandard4DB.Add(techStandards, clampid, out msg)) { this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 工艺参数存入数据库失败!"; this.lbTip.ForeColor = Color.Red; })); LogHelper.WriteError(code + " 工艺参数存入数据库失败"); return; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 工艺参数存入数据库成功!"; this.lbTip.ForeColor = Color.LightGreen; })); LogHelper.WriteInfo(code + " 工艺参数存入数据库成功!"); } else if (Current.mes.IsOffline) { Battery battery = new Battery(); battery.Code = code + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); battery.ClampId = clampid; battery.Location = "1"; if (Battery.Add(battery, out msg) < 1) { this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " MES离线模式,生成电芯数据存入数据库失败!"; this.lbTip.ForeColor = Color.Red; })); LogHelper.WriteInfo(code + " MES离线模式,生成电芯数据存入数据库失败!"); return; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " MES离线模式,生成电芯数据存入数据库成功!"; this.lbTip.ForeColor = Color.LightGreen; })); LogHelper.WriteError(code + " MES离线模式,生成电芯数据存入数据库成功!"); Thread.Sleep(100); } } catch (Exception ex) { Error.Alert(ex.ToString()); } } }
private void btnLoginOrRegister_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.userNameTextBox.Text)) { Tip.Alert("请输入用户名"); return; } if (string.IsNullOrEmpty(this.passwordBox.Text)) { Tip.Alert("请输入密码"); return; } if (!Current.App.IsLoginWindow && string.IsNullOrEmpty(this.confirmPasswordBox.Text)) { Tip.Alert("请输入确认密码"); return; } if (!Current.App.IsLoginWindow && this.confirmPasswordBox.Text != this.passwordBox.Text) { Tip.Alert("两次输入密码不相同"); return; } string msg = string.Empty; //登录 if (Current.App.IsLoginWindow) { if (Current.Option.IsMesLogin) { if (!Current.Mes.IsPingSuccess) { Error.Alert("无法连接至MES服务器,登录失败!"); return; } //MES登录 if (MES.Login(this.userNameTextBox.Text, this.passwordBox.Password, out msg)) { AfterLogin(); } else { Tip.Alert(msg); } } else { //普通登录 if (User.Login(this.userNameTextBox.Text, this.passwordBox.Password, out msg)) { AfterLogin(); } else { Tip.Alert(msg); } } } else //注册 { if (User.Register(this.userNameTextBox.Text, this.passwordBox.Password, out msg)) { AfterRegister(); } else { Tip.Alert(msg); } } }