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; } }
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; } }