public new AutoWeldHistory Save() { var db = new DataProcess(); if (Id == null) { Id = db.saveAutoWeldHistory(this); foreach (var sig in Signals) { sig.Delta = 0; var interval = sig.Timestamp - Signals[0].Timestamp; var delta = (int)interval.TotalMilliseconds; // Ignore time less tham 1ms. sig.Delta = delta; sig.History = this; sig.Save(); } } else { db.updateAutoWeldHistory(this); } return this; }
private void UpdateUI(bool autoWeld = false) { historiesList.Items.Clear(); var db = new DataProcess(); if (autoWeld) { var list = db.AutoWeldHistoryList(); if (Histories == null) { Histories = new List <History>(); } else { Histories.Clear(); } list.ForEach((item) => { Histories.Add(item); }); Text = "控制记录"; } else { Histories = db.HistoryList(); Text = "焊接历史"; } Histories.ForEach((history) => { var name = history.Name.Trim(); var defaultName = autoWeld ? "(未命名控制记录)" : "(未命名焊接记录)"; historiesList.Items.Add(name.Length == 0 ? defaultName : name); }); ShowHistory(); }
public static new AutoWeldHistory Find(long history_id) { var db = new DataProcess(); var history = db.autoWeldHistoryOfId(history_id); return(history); }
private void AddButton_Click(object sender, EventArgs e) { var input = new InputBox("请输入一个名字:", "新增操作者", ""); var result = input.ShowDialog(this); if (result == DialogResult.OK) { var name = input.InputResult.Trim(); bool nameExists = false; foreach (string n in OperatorsListBox.Items) { if (n == name) { nameExists = true; break; } } if (!nameExists) { var db = new DataProcess(); db.addOperator(name); OperatorsListBox.Items.Add(name); } else { MessageBox.Show(this, "名字已存在,请勿重复添加。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }
private void SaveAutoWeldHistory(bool interupted = false) { //SaveRecordButton.Enabled = false; // Disable it. var dict = new Dictionary <string, object>(); dict["task_name"] = TaskNameTextBox.Text.Trim(); dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim(); dict["welding_item"] = WeldingItemComboBox.Text.Trim(); dict["welding_current"] = WeldingCurrentTextBox.Text.Trim(); dict["ar_flow"] = ArGasFlowTextBox.Text.Trim(); dict["room_temperature"] = RoomTempTextBox.Text.Trim(); var op = OperatorNameComboBox.Text.Trim(); dict["operator"] = op; dict["history_id"] = History.Id; if (op != "") // Valid op. { var db = new DataProcess(); var ops = db.OperatorList(); if (!ops.Contains(op)) { db.addOperator(op); // Save operator } } // If all OK, close. DateTime dt = DateTime.Now; dict["created_at"] = dt; try { dict["name"] = ""; dict["interupted"] = false; var history = new AutoWeldHistory(dict); history.Signals = signalCache; // Decide interupted by signal count. // We can decide interupt by pass in argument. // Fixme: Which is better? if (history.Template.Signals.Count() == signalCache.Count()) { history.Interupted = false; } else { #if DEBUG Console.WriteLine("Control signals: {0}, received signals: {1}", history.Template.Signals.Count(), signalCache.Count()); #endif history.Interupted = true; } history.Save(); } catch (Exception excp) { #if DEBUG Console.WriteLine(excp.StackTrace); #endif throw; } }
public new AutoWeldHistory Save() { var db = new DataProcess(); if (Id == null) { Id = db.saveAutoWeldHistory(this); foreach (var sig in Signals) { sig.Delta = 0; var interval = sig.Timestamp - Signals[0].Timestamp; var delta = (int)interval.TotalMilliseconds; // Ignore time less tham 1ms. sig.Delta = delta; sig.History = this; sig.Save(); } } else { db.updateAutoWeldHistory(this); } return(this); }
public void Delete() { var db = new DataProcess(); if (Id != null) { db.deleteTemplate(this); } }
public void Delete() { var db = new DataProcess(); if (Id != null) { db.deleteSignal(this); } }
private void LoadOperatorsList() { OperatorsListBox.Items.Clear(); var db = new DataProcess(); var operatorList = db.OperatorList(); operatorList.ForEach((item) => { OperatorsListBox.Items.Add(item); }); }
private void DeleteButton_Click(object sender, EventArgs e) { var name = OperatorsListBox.SelectedItem; if (name != null) { var db = new DataProcess(); db.deleteOperator(name.ToString()); LoadOperatorsList(); } }
private void PopulateData() { var db = new DataProcess(); var templates = db.TemplateList(); var sortedTemplates = from tpl in templates orderby tpl.Item, int.Parse(tpl.Type) select tpl; SortedTemplates = sortedTemplates.ToList(); TemplatesListBox.Items.Clear(); SortedTemplates.ForEach((template) => { TemplatesListBox.Items.Add(template.ShortDescription()); }); }
private void PopulateData() { var db = new DataProcess(); var templates = db.TemplateList(); var sortedTemplates = from tpl in templates orderby tpl.Item, int.Parse(tpl.Type) select tpl; SortedTemplates = sortedTemplates.ToList(); SortedTemplates.ForEach((tpl) => { TemplateListView.Items.Add(tpl.ToListItem()); }); TemplateListLabel.Text = string.Format("焊接模板(共{0}条)", SortedTemplates.Count()); }
public static History LatestHistory() { var db = new DataProcess(); var histories = db.HistoryList(); var sortedHistories = from h in histories where true orderby h.CreatedAt descending select h; if (sortedHistories.Count() == 0) { return(null); } else { return(sortedHistories.First()); } }
private void SaveSignalDataAndClose() { var dict = new Dictionary <string, object>(); dict["task_name"] = TaskNameTextBox.Text.Trim(); dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim(); dict["welding_item"] = WeldingItemComboBox.Text.Trim(); dict["welding_current"] = WeldingCurrentTextBox.Text.Trim(); dict["ar_flow"] = ArGasFlowTextBox.Text.Trim(); dict["room_temperature"] = RoomTempTextBox.Text.Trim(); var op = OperatorNameComboBox.Text.Trim(); dict["operator"] = op; if (op != "") // Valid op. { var db = new DataProcess(); var ops = db.OperatorList(); if (!ops.Contains(op)) { db.addOperator(op); // Save operator } } // If all OK, close. DateTime dt = DateTime.Now; dict["created_at"] = dt; try { //Fixme: Generate a meaningful name. dict["name"] = ""; var history = new History(dict); history.Signals = signalCache; history.Save(); Console.WriteLine("Signal history saved."); } catch (Exception excp) { //TODO: Save Result and crash. #if DEBUG Console.WriteLine(excp.StackTrace); #endif throw; } DialogResult = DialogResult.OK; }
// Load static data from database to UI. private void loadWeldingDataLists() { var db = new DataProcess(); var gangtaoList = db.GangTaoList(); gangtaoList.ForEach((item) => { GangTaoTypeComboBox.Items.Add(item); }); var operatorList = db.OperatorList(); operatorList.ForEach((item) => { OperatorNameComboBox.Items.Add(item); }); var weldingItemList = db.WeldingItemList(); weldingItemList.ForEach((item) => { WeldingItemComboBox.Items.Add(item); }); }
public Template Save() { var db = new DataProcess(); if (History == null) { throw new TemplateException("Template should have a history reference."); } else { if (Id == null) { Id = db.saveTemplate(this); } else { db.updateTemplate(this); } return this; } }
private void LoadWeldingDataLists() { var db = new DataProcess(); var gangtaoList = db.GangTaoList(); GangTaoTypeComboBox.Items.Clear(); gangtaoList.ForEach((item) => { GangTaoTypeComboBox.Items.Add(item); }); var weldingItemList = db.WeldingItemList(); WeldingItemComboBox.Items.Clear(); weldingItemList.ForEach((item) => { WeldingItemComboBox.Items.Add(item); }); histories = db.HistoryList(); HistoriesListBox.Items.Clear(); histories.ForEach((item) => { HistoriesListBox.Items.Add(item.ShortDescription()); }); }
public Signal Save() { var db = new DataProcess(); if (History == null) { throw new SignalException("Signal should be associated to history."); } else { if (this.Id == null) { Id = db.saveSignal(this); } else { db.updateSignal(this); } return(this); } }
public Template Save() { var db = new DataProcess(); if (History == null) { throw new TemplateException("Template should have a history reference."); } else { if (Id == null) { Id = db.saveTemplate(this); } else { db.updateTemplate(this); } return(this); } }
// Load static data from database to UI. private void loadWeldingDataLists() { #if DEBUG sendMessageInfoLabel.Visible = true; sendMessageButton.Visible = true; #else sendMessageInfoLabel.Visible = false; sendMessageButton.Visible = false; #endif var db = new DataProcess(); var gangtaoList = db.GangTaoList(); gangtaoList.ForEach((item) => { GangTaoTypeComboBox.Items.Add(item); }); var operatorList = db.OperatorList(); operatorList.ForEach((item) => { OperatorNameComboBox.Items.Add(item); }); var weldingItemList = db.WeldingItemList(); weldingItemList.ForEach((item) => { WeldingItemComboBox.Items.Add(item); }); }
public virtual void Delete() { var db = new DataProcess(); db.deleteHistory(this); }
private void SaveSignalDataAndClose() { var dict = new Dictionary<string, object>(); dict["task_name"] = TaskNameTextBox.Text.Trim(); dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim(); dict["welding_item"] = WeldingItemComboBox.Text.Trim(); dict["welding_current"] = WeldingCurrentTextBox.Text.Trim(); dict["ar_flow"] = ArGasFlowTextBox.Text.Trim(); dict["room_temperature"] = RoomTempTextBox.Text.Trim(); var op = OperatorNameComboBox.Text.Trim(); dict["operator"] = op; if (op != "") // Valid op. { var db = new DataProcess(); var ops = db.OperatorList(); if (!ops.Contains(op)) { db.addOperator(op); // Save operator } } // If all OK, close. DateTime dt = DateTime.Now; dict["created_at"] = dt; try { //Fixme: Generate a meaningful name. dict["name"] = ""; var history = new History(dict); history.Signals = signalCache; history.Save(); Console.WriteLine("Signal history saved."); } catch (Exception excp) { //TODO: Save Result and crash. #if DEBUG Console.WriteLine(excp.StackTrace); #endif throw; } DialogResult = DialogResult.OK; }
private void SaveAutoWeldHistory(bool interupted = false) { //SaveRecordButton.Enabled = false; // Disable it. var dict = new Dictionary<string, object>(); dict["task_name"] = TaskNameTextBox.Text.Trim(); dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim(); dict["welding_item"] = WeldingItemComboBox.Text.Trim(); dict["welding_current"] = WeldingCurrentTextBox.Text.Trim(); dict["ar_flow"] = ArGasFlowTextBox.Text.Trim(); dict["room_temperature"] = RoomTempTextBox.Text.Trim(); var op = OperatorNameComboBox.Text.Trim(); dict["operator"] = op; dict["history_id"] = History.Id; if (op != "") // Valid op. { var db = new DataProcess(); var ops = db.OperatorList(); if (!ops.Contains(op)) { db.addOperator(op); // Save operator } } // If all OK, close. DateTime dt = DateTime.Now; dict["created_at"] = dt; try { dict["name"] = ""; dict["interupted"] = false; var history = new AutoWeldHistory(dict); history.Signals = signalCache; // Decide interupted by signal count. // We can decide interupt by pass in argument. // Fixme: Which is better? if (history.Template.Signals.Count() == signalCache.Count()) { history.Interupted = false; } else { #if DEBUG Console.WriteLine("Control signals: {0}, received signals: {1}", history.Template.Signals.Count(), signalCache.Count()); #endif history.Interupted = true; } history.Save(); } catch (Exception excp) { #if DEBUG Console.WriteLine(excp.StackTrace); #endif throw; } }
public static new AutoWeldHistory Find(long history_id) { var db = new DataProcess(); var history = db.autoWeldHistoryOfId(history_id); return history; }
public override void Delete() { var db = new DataProcess(); db.deleteAutoWeldHistory(this); }
public static History LatestHistory() { var db = new DataProcess(); var histories = db.HistoryList(); var sortedHistories = from h in histories where true orderby h.CreatedAt descending select h; if (sortedHistories.Count() == 0) { return null; } else { return sortedHistories.First(); } }
private void UpdateUI(bool autoWeld = false) { historiesList.Items.Clear(); var db = new DataProcess(); if (autoWeld) { var list = db.AutoWeldHistoryList(); if (Histories == null) { Histories = new List<History>(); } else { Histories.Clear(); } list.ForEach((item) => { Histories.Add(item); }); Text = "控制记录"; } else { Histories = db.HistoryList(); Text = "焊接历史"; } Histories.ForEach((history) => { var name = history.Name.Trim(); var defaultName = autoWeld ? "(未命名控制记录)" : "(未命名焊接记录)"; historiesList.Items.Add(name.Length == 0 ? defaultName : name); }); ShowHistory(); }
public Signal Save() { var db = new DataProcess(); if (History == null) { throw new SignalException("Signal should be associated to history."); } else { if (this.Id == null) { Id = db.saveSignal(this); } else { db.updateSignal(this); } return this; } }