/// <summary> /// Initializes a new instance of the <see cref="Mutex"/> class. /// </summary> public Mutex() { _lhs = new List <LeftHandSideCondition>(); _rhs = new List <RightHandSideCondition>(); _inferredFacts = new List <Activation>(); _status = ProductionStatus.Ready; }
public async Task <bool> JobCompletedSuccessfullyAsync(int workspaceArtifactId, int productionSetArtifactId, int maxWaitInMinutes) { bool jobComplete = false; const int maxTimeInMilliseconds = (Constants.Waiting.MAX_WAIT_TIME_IN_MINUTES * 60 * 1000); const int sleepTimeInMilliSeconds = Constants.Waiting.SLEEP_TIME_IN_SECONDS * 1000; int currentWaitTimeInMilliseconds = 0; Guid fieldGuid = Constants.Guids.Fields.ProductionSet.Status; try { while (currentWaitTimeInMilliseconds < maxTimeInMilliseconds && jobComplete == false) { Thread.Sleep(sleepTimeInMilliSeconds); Production production = await ProductionManager.ReadSingleAsync(workspaceArtifactId, productionSetArtifactId); ProductionStatus productionStatus = production.ProductionMetadata.Status; if (productionStatus == ProductionStatus.Produced || productionStatus == ProductionStatus.ProducedWithErrors) { jobComplete = true; } currentWaitTimeInMilliseconds += sleepTimeInMilliSeconds; } return(jobComplete); } catch (Exception ex) { throw new Exception($@"Error when checking for Production Job Completion. [ErrorMessage: {ex}]", ex); } }
/// <summary> /// Initializes a new instance of the <see cref="Aggregator"/> class. /// </summary> public Aggregator() { _lhs = new List <LeftHandSideCondition>(); _inferredFacts = new List <Activation>(); _status = ProductionStatus.Ready; _conditionType = ConditionType.Assert; }
/// <summary> /// Initializes a new instance of the <see cref="Mutex"/> class. /// </summary> public Mutex() { _lhs = new List<LeftHandSideCondition>(); _rhs = new List<RightHandSideCondition>(); _inferredFacts = new List<Activation>(); _status = ProductionStatus.Ready; }
private void ucCasting_Load(object sender, EventArgs e) { SmeltBatchProductionInfo data = GetWorkUnitProductionInfo(); if (data != null) { prdtStatus = ProductionStatus.Busy; edtOperator.Text = string.Format( "[{0}]{1}", data.OperatorCode, data.OperatorName); edtProductDate.DateTime = data.BatchStartDate; lblBatchNo.Text = data.BatchNumber; } else { prdtStatus = ProductionStatus.Idle; edtProductDate.DateTime = DateTime.Now; } RefreshForm(); }
/// <summary> /// Initializes a new instance of the <see cref="Production"/> class. /// </summary> public Production() { _lhs = new List <LeftHandSideCondition>(); _rhs = new List <RightHandSideCondition>(); _variableList = new Dictionary <string, int>(); _inferredFacts = new List <Activation>(); _status = ProductionStatus.Ready; _timeStamp = DateTime.Now; }
private void ucPrdtParams_Ionitriding_Load(object sender, EventArgs e) { grdPWOs.DataSource = pwos; BatchProductInfo data = GetWorkUnitProductionInfo(); if (data != null) { if (data.InProduction == 0) { prdtStatus = ProductionStatus.Idle; pwos = LoadFromFile(stationInfo.T133Code); grdPWOs.DataSource = pwos; grdvPWOs.BestFitColumns(); GetMethodStandards(0, 0, ""); } else { prdtStatus = ProductionStatus.Busy; pwos = data.GetPWOsFromXML(); grdPWOs.DataSource = pwos; grdvPWOs.BestFitColumns(); currentOperator = new STB006() { UserCode = data.OperatorCode, UserName = data.OperatorName, }; currentBatchNo = data.BatchNumber; startDatetime = data.BatchStartDate; if (pwos.Count > 0) { GetMethodStandards(0, stationInfo.T216LeafID, currentBatchNo); } } edtOperatorCode.Text = string.Format( "{0}[{1}]", currentOperator.UserName, currentOperator.UserCode); lblBatchNo.Text = currentBatchNo; } else { pwos = LoadFromFile(stationInfo.T133Code); grdPWOs.DataSource = pwos; grdvPWOs.BestFitColumns(); } RefreshForm(); }
private void ucFurnacePrdtParams_Load(object sender, EventArgs e) { grdPWOs.DataSource = pwos; BatchProductInfo data = GetWorkUnitProductionInfo(); if (data != null) { currentOperator = new STB006() { UserCode = data.OperatorCode, UserName = data.OperatorName, }; currentBatchNo = data.BatchNumber; startDatetime = data.BatchStartDate; if (data.InProduction == 0) { prdtStatus = ProductionStatus.Idle; GetMethodStandards(0, 0, ""); } else { prdtStatus = ProductionStatus.Busy; pwos = GetPWOWithBatchNo(currentBatchNo); grdPWOs.DataSource = pwos; grdvPWOs.BestFitColumns(); if (pwos.Count > 0) { DateTime dt; if (DateTime.TryParse(pwos[0].BatchStartDate, out dt)) { startDatetime = dt; } GetMethodStandards(0, stationInfo.T216LeafID, currentBatchNo); } } edtOperatorCode.Text = string.Format( "{0}[{1}]", currentOperator.UserName, currentOperator.UserCode); lblBatchNo.Text = currentBatchNo; lblStartTime.Text = startDatetime.ToString("yyyy-MM-dd HH:mm:ss"); } else { GetDevices(); } RefreshForm(); }
public int AddProdustionStatus(ProductionStatus mFile) { //insert databse values SqlCommand insetComm = new SqlCommand(); insetComm.Connection = this.mConnectionUser; insetComm.CommandType = CommandType.Text; insetComm.Parameters.Add("@EPD_ShpID", SqlDbType.BigInt); insetComm.Parameters.Add("@EPD_ShipmentID", SqlDbType.NVarChar); insetComm.Parameters.Add("@EPD_ISBN", SqlDbType.NVarChar); insetComm.Parameters.Add("@EPD_UID", SqlDbType.NVarChar); insetComm.Parameters.Add("@EPD_FormatName", SqlDbType.NVarChar); insetComm.Parameters.Add("@EPD_DoneDate", SqlDbType.DateTime); insetComm.Parameters.Add("@EPD_Status", SqlDbType.NVarChar); insetComm.Parameters["@EPD_ShpID"].Value = mFile.ProductID; insetComm.Parameters["@EPD_ShipmentID"].Value = mFile.ShipmentID; insetComm.Parameters["@EPD_ISBN"].Value = mFile.ISBN; insetComm.Parameters["@EPD_UID"].Value = mFile.UserID; insetComm.Parameters["@EPD_FormatName"].Value = mFile.FormatName; insetComm.Parameters["@EPD_DoneDate"].Value = mFile.StartDate; insetComm.Parameters["@EPD_Status"].Value = mFile.Status; insetComm.CommandText = "INSERT INTO ProductionStatus(ProductID,ShipmentID,ISBN,UserID,FormatName,StartDate,Status) VALUES (@EPD_ShpID,@EPD_ShipmentID,@EPD_ISBN,@EPD_UID,@EPD_FormatName,@EPD_DoneDate,@EPD_Status)"; int ans = insetComm.ExecuteNonQuery(); if (ans > 0) { return(ans); } else { return(0); } }
public int UpdateProductionStatusLog(ProductionStatus mStatus) { //insert databse values SqlCommand updateComm = new SqlCommand(); updateComm.Connection = this.mConnectionUser; updateComm.CommandType = CommandType.Text; updateComm.Parameters.Add("@Log_ShpID", SqlDbType.BigInt); updateComm.Parameters.Add("@Log_ShipmentID", SqlDbType.NVarChar); updateComm.Parameters.Add("@Log_FormatName", SqlDbType.NVarChar); updateComm.Parameters.Add("@Log_ISBN", SqlDbType.NVarChar); updateComm.Parameters.Add("@Log_UID", SqlDbType.NVarChar); updateComm.Parameters.Add("@Log_StartDate", SqlDbType.DateTime); updateComm.Parameters.Add("@Log_PrStatus", SqlDbType.NVarChar); updateComm.Parameters["@Log_ShpID"].Value = mStatus.ProductID; updateComm.Parameters["@Log_ShipmentID"].Value = mStatus.ShipmentID; updateComm.Parameters["@Log_FormatName"].Value = mStatus.FormatName; updateComm.Parameters["@Log_ISBN"].Value = mStatus.ISBN; updateComm.Parameters["@Log_UID"].Value = mStatus.UserID; updateComm.Parameters["@Log_StartDate"].Value = mStatus.StartDate; updateComm.Parameters["@Log_PrStatus"].Value = mStatus.Status; updateComm.CommandText = "UPDATE ProductionStatus SET Status=@Log_PrStatus, StartDate=@Log_StartDate, WHERE ProductID=@Log_ShpID AND ShipmentID=@Log_ShipmentID AND FormatName=@Log_FormatName AND ISBN=@Log_ISBN AND UserID=@Log_UID"; int ans = updateComm.ExecuteNonQuery(); if (ans > 0) { return(ans); } else { return(0); } }
private void btnEnd_Click(object sender, EventArgs e) { string strProcedureName = string.Format( "{0}.{1}", className, MethodBase.GetCurrentMethod().Name); WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { int errCode = 0; string errText = ""; IRAPMESClient.Instance.usp_SaveFact_BatchProductionEnd( IRAPUser.Instance.CommunityID, stationInfo.T216LeafID, stationInfo.T107LeafID, currentBatchNo, IRAPUser.Instance.SysLogID, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode != 0) { XtraMessageBox.Show( string.Format("在生产结束时发生错误:[{0}]", errText), "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { currentOperator = null; currentBatchNo = ""; startDatetime = DateTime.Now; pwos.Clear(); ppp.Clear(); InitMethodParamsGrid(ppp); edtOperatorCode.Text = ""; cboPrdtType.SelectedIndex = -1; lblBatchNo.Text = ""; lblProductTimeSpan.Text = ""; lblStartTime.Text = ""; grdParams.RefreshDataSource(); grdPWOs.RefreshDataSource(); prdtStatus = ProductionStatus.Idle; RefreshForm(); } } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } }
private void ucBatchSysProduction_Load(object sender, EventArgs e) { grdPWOs.DataSource = pwos; BatchProductInfo data = GetWorkUnitProductionInfo(); if (data != null) { currentOperator = new STB006() { UserCode = data.OperatorCode, UserName = data.OperatorName, }; currentBatchNo = data.BatchNumber; startDatetime = data.BatchStartDate; if (data.InProduction == 0) { prdtStatus = ProductionStatus.Idle; } else { prdtStatus = ProductionStatus.Busy; } pwos = data.GetPWOsFromXML(); #region 遍历所有生产工单,获取生产工单的在制品的材质 //foreach (EntityBatchPWO pwo in pwos) //{ // int errCode = 0; // string errText = ""; // string texture = // GetTextureCodeFromMaterialCode( // pwo.T102Code, // out errCode, // out errText); // if (errCode == 0) // pwo.Texture = texture; // else // pwo.Texture = ""; //} #endregion grdPWOs.DataSource = pwos; grdvPWOs.BestFitColumns(); edtOperatorCode.Text = string.Format( "{0}[{1}]", currentOperator.UserName, currentOperator.UserCode); lblBatchNo.Text = currentBatchNo; lblStartTime.Text = startDatetime.ToString("yyyy-MM-dd HH:mm:ss"); cboPrdtType.SelectedIndex = -1; for (int i = 0; i < cboPrdtType.Properties.Items.Count; i++) { BatchRingCategory prdtType = (BatchRingCategory)cboPrdtType.Properties.Items[i]; if (prdtType.T131LeafID == data.T131LeafID) { cboPrdtType.SelectedIndex = i; break; } } //GetMethodStandards(data.T131LeafID, stationInfo.T216LeafID, data.BatchNumber); } RefreshForm(); }
private void btnBegin_Click(object sender, EventArgs e) { #region 数据检验 if (currentOperator == null) { XtraMessageBox.Show( "请刷卡记录您的身份!", "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); edtOperatorCode.Focus(); return; } if (cboPrdtType.SelectedIndex < 0) { XtraMessageBox.Show( "请选择!", "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); cboPrdtType.Focus(); return; } if (pwos.Count <= 0) { XtraMessageBox.Show( "还没有添加工单信息,请至少增加一个生产工单!", "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); btnPWONew.Focus(); return; } #endregion string strProcedureName = string.Format( "{0}.{1}", className, MethodBase.GetCurrentMethod().Name); WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { int errCode = 0; string errText = ""; IRAPMESBatchClient.Instance.usp_SaveFact_BatchProductionStart( IRAPUser.Instance.CommunityID, stationInfo.T216LeafID, stationInfo.T107LeafID, currentOperator.UserCode, ((BatchRingCategory)cboPrdtType.SelectedItem).T131LeafID, GenerateBatchProductionStartXML(pwos), IRAPUser.Instance.SysLogID, out currentBatchNo, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode != 0) { XtraMessageBox.Show( string.Format("在生产开始时发生错误:[{0}]", errText), "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } startDatetime = DateTime.Now; lblBatchNo.Text = currentBatchNo; lblStartTime.Text = startDatetime.ToString("yyyy-MM-dd HH:mm:ss"); prdtStatus = ProductionStatus.Busy; RefreshForm(); }
private void btnBegin_Click(object sender, EventArgs e) { #region 数据检验 if (currentOperator == null) { XtraMessageBox.Show( "请刷卡记录您的身份!", "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); edtOperatorCode.Focus(); return; } #endregion #region 记录生产开始 string strProcedureName = string.Format( "{0}.{1}", className, MethodBase.GetCurrentMethod().Name); WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { int errCode = 0; string errText = ""; currentBatchNo = ((BatchByEquipment)cboBatchNos.SelectedItem).BatchNumber; IRAPMESBatchClient.Instance.usp_SaveFact_BatchProductionStart_QuenchAndTemper( IRAPUser.Instance.CommunityID, stationInfo.T216LeafID, stationInfo.T107LeafID, currentOperator.UserCode, 0, GenerateBatchProductionStartXML(pwos), IRAPUser.Instance.SysLogID, ref currentBatchNo, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode != 0) { XtraMessageBox.Show( string.Format("在生产开始时发生错误:[{0}]", errText), "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } #endregion startDatetime = DateTime.Now; lblBatchNo.Text = currentBatchNo; lblStartTime.Text = startDatetime.ToString("yyyy-MM-dd HH:mm:ss"); // 如果当前生产批次号中有工单,则获取生产过程参数 if (pwos.Count > 0) { GetMethodStandards(0, stationInfo.T216LeafID, currentBatchNo); } prdtStatus = ProductionStatus.Busy; RefreshForm(); }
private void btnTerminate_Click(object sender, EventArgs e) { if ( IRAPMessageBox.Instance.Show( $"是否要终止当前炉次【{currentBatchNo}】的生产?", "生产终止", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } string strProcedureName = string.Format( "{0}.{1}", className, MethodBase.GetCurrentMethod().Name); WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { int errCode = 0; string errText = ""; IRAPMESClient.Instance.usp_SaveFact_BatchBreakProduction( IRAPUser.Instance.CommunityID, stationInfo.T216LeafID, stationInfo.T107LeafID, currentBatchNo, IRAPUser.Instance.SysLogID, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode != 0) { XtraMessageBox.Show( string.Format("在生产终止时发生错误:[{0}]", errText), "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { currentOperator = null; currentBatchNo = ""; startDatetime = DateTime.Now; pwos.Clear(); ppp.Clear(); InitMethodParamsGrid(ppp); edtOperatorCode.Text = ""; lblBatchNo.Text = ""; lblProductTimeSpan.Text = ""; lblStartTime.Text = ""; GetDevices(); grdPWOs.RefreshDataSource(); GetMethodStandards(0, 0, ""); prdtStatus = ProductionStatus.Idle; RefreshForm(); } } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } }
public static string (this ProductionStatus status) { return(((int)status).ToString("000", CultureInfo.InvariantCulture));
private void btnBegin_Click(object sender, EventArgs e) { #region 数据检验 if (currentOperator == null) { XtraMessageBox.Show( "请刷卡记录您的身份!", "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error); edtOperatorCode.Focus(); return; } if (pwos.Count <= 0) { if (IRAPMessageBox.Instance.Show( "没有添加工单信息!\n 如果该炉次是试样,请忽略提示信息," + "点击“Yes”按钮,否则请点击“No”按钮", "提问", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { btnPWONew.Focus(); return; } } #endregion #region 记录生产开始 string strProcedureName = string.Format( "{0}.{1}", className, MethodBase.GetCurrentMethod().Name); WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { int errCode = 0; string errText = ""; IRAPMESBatchClient.Instance.usp_SaveFact_BatchProductionStart_QuenchAndTemper( IRAPUser.Instance.CommunityID, stationInfo.T216LeafID, stationInfo.T107LeafID, currentOperator.UserCode, 0, GenerateBatchProductionStartXML(pwos), IRAPUser.Instance.SysLogID, ref currentBatchNo, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode != 0) { IRAPMessageBox.Instance.ShowErrorMessage( $"在生产开始时发生错误:[{errText}]", "系统信息"); return; } } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } #endregion startDatetime = DateTime.Now; lblBatchNo.Text = currentBatchNo; SavePreparationPWOs( stationInfo.T133Code, new List <EntityBatchPWO>()); // 如果当前生产批次号中有工单,则获取生产过程参数 if (pwos.Count > 0) { GetMethodStandards(0, stationInfo.T216LeafID, currentBatchNo); } prdtStatus = ProductionStatus.Busy; RefreshForm(); }
public static void ReadParameters() { if (productionStatus != ProductionStatus.Idle) { throw new InvalidOperationException("Production state invalid"); } productionStatus = ProductionStatus.Communication; comCts = new CancellationTokenSource(); StationRepository.ResetPortComParamStatus(PortComParamStatus.NotRead); var activeStations = StationRepository.GetAllOccupiedByMeters(); SmlComManager.Init(activeStations); try { Parallel.ForEach(activeStations, s => SmlComManager.ReadData(s, comCts.Token)); if (comCts.IsCancellationRequested) { productionStatus = ProductionStatus.Idle; return; } } catch (Exception ex) { Log.ErrorException("Read parameters failed", ex); } productionStatus = ProductionStatus.Idle; }
public static void WriteParameters() { if (productionStatus != ProductionStatus.Idle) { throw new InvalidOperationException("Production state invalid"); } productionStatus = ProductionStatus.Communication; comCts = new CancellationTokenSource(); StationRepository.ResetPortComParamStatus(PortComParamStatus.Writing); var activeStations = StationRepository.GetAllOccupiedByMeters().Where(s => s.ComParamStatus != PortComParamStatus.ReadBackOk).ToList(); SmlComManager.Init(activeStations); try { Parallel.ForEach(activeStations, s => SmlComManager.WriteData(s, comCts.Token, true)); activeStations = StationRepository.GetAllOccupiedByMeters().ToList(); if (activeStations.Any(s => s.ComParamStatus != PortComParamStatus.ReadBackOk)) { throw new ApplicationException("Not all meters are written successfully"); } if (comCts.IsCancellationRequested) { return; } } catch (Exception ex) { Log.ErrorException("Write parameters failed", ex); throw; } finally { productionStatus = ProductionStatus.Idle; } }
public static void CancelProductionStep() { if (comCts != null) { comCts.Cancel(); } var lastProductionStatus = productionStatus; productionStatus = ProductionStatus.Idle; var activeStations = StationRepository.GetAllOccupiedByMeters(); if (lastProductionStatus == ProductionStatus.ScanMatrixCode || lastProductionStatus == ProductionStatus.ScanPcbCode) { foreach (var activeStation in activeStations) { if (activeStation.ScanMatrixStatus == PortScanStatus.Scanning) { StationRepository.SetPortScanMatrixStatus(activeStation.ComPort, PortScanStatus.NotScanned); } } } if (lastProductionStatus == ProductionStatus.Communication) { foreach (var activeStation in activeStations) { if (activeStation.ComParamStatus == PortComParamStatus.Reading) { StationRepository.SetPortComParamStatus(activeStation.ComPort, PortComParamStatus.NotRead); } if (activeStation.ComParamStatus == PortComParamStatus.Writing) { StationRepository.SetPortComParamStatus(activeStation.ComPort, PortComParamStatus.NotWritten); } } } }
private void btnAssignUID_Click(object sender, EventArgs e) { //validate User ID if (cmbUserID.Text != "") { try { DialogResult result; result = MessageBox.Show("Do You want to assign User " + cmbUserID.Text + " to this file?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); //Confirm by user if (result == DialogResult.Yes) { //validate Production ID if (cmbPID.Text != "") { int rowIndex = dataGridBeforeAssignedUID.CurrentRow.Index; ProductionManagementHeader mProductionHdr = new ProductionManagementHeader(); ProductionManagementDetail mProductionDtl = new ProductionManagementDetail(); ShipmentDetailFormats mShipmetDetail = new ShipmentDetailFormats(); ProductionStatus mLog = new ProductionStatus(); //Production Management Header Value mProductionHdr.ShpID = int.Parse(cmbPID.Text); mProductionHdr.ShipmentID = cmbShipment.Text; mProductionHdr.FormatName = cmbFormat.Text; //Production Management Detail Value mProductionDtl.ShpID = int.Parse(cmbPID.Text); mProductionDtl.ShipmentID = cmbShipment.Text; mProductionDtl.Format = cmbFormat.Text; mProductionDtl.ISBN = dataGridBeforeAssignedUID.Rows[rowIndex].Cells[2].Value.ToString(); mProductionDtl.UserID = cmbUserID.Text; mProductionDtl.PageCount = int.Parse(dataGridBeforeAssignedUID.Rows[rowIndex].Cells[8].Value.ToString()); mProductionDtl.StartDate = dateTimePickerStartDate.Value; mProductionDtl.ProductionStatus = "Process By User"; //Shipment Detail Formats Value mShipmetDetail.ShpID = int.Parse(cmbPID.Text); mShipmetDetail.ShipmentID = cmbShipment.Text; mShipmetDetail.FormatName = cmbFormat.Text; mShipmetDetail.ProductionStatus = "Process By User"; //Production Status Log Value mLog.ProductID = int.Parse(cmbPID.Text); mLog.ShipmentID = cmbShipment.Text; mLog.ISBN = dataGridBeforeAssignedUID.Rows[rowIndex].Cells[2].Value.ToString(); mLog.StartDate = DateTime.Now; mLog.FormatName = cmbFormat.Text; mLog.UserID = lblCUID.Text; mLog.Status = "Production assign to User " + cmbUserID.Text + " by Access User " + lblCUID.Text; ProductionManagementDetailMng mProductionDtlMng = new ProductionManagementDetailMng(conn); ShipmentDetailFormatsMng mShipmentDetailMng = new ShipmentDetailFormatsMng(conn); //Add Prodution Management Header table if (new ProductionManagementHeaderMng(this.conn).AddProductionManagementHeader(mProductionHdr) > 0) { //Update Shipment Format table mShipmentDetailMng.UpdateProductionOnSipmentFormatFile(mShipmetDetail); //Add Prodution Management Detail table mProductionDtlMng.AddProductionManagementDetail(mProductionDtl); MessageBox.Show("File has been assigned.\n\n ISBN: " + mProductionDtl.ISBN + "\n User ID: " + cmbUserID.Text + "\n Start Date: " + dateTimePickerStartDate.Value.ToString("dd/MMM/yyyy"), "File Assigned", MessageBoxButtons.OK, MessageBoxIcon.Information); //Production Log table new ProductionStatusLogMng(this.conn).AddProdustionStatus(mLog); RefreshData(); } } else { MessageBox.Show("Production ID cannot be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbPID.Focus(); } } } catch (Exception ex) { if (ex.HResult == -2146232060) { MessageBox.Show("This Format is already assigned to a User.\n Please check Format & User ID again.", "Cannot Assign", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Error" + ex.Message); } } } else { MessageBox.Show("Plese select User ID to assign file.", "Cannot Assign", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbUserID.Focus(); } }
private void btnReturnFile_Click(object sender, EventArgs e) { try { int rowIndex = dataGridViewFeedbackFile.CurrentRow.Index; DialogResult result; Feedback mCF = new Feedback(); ShipmetDetail mSD = new ShipmetDetail(); ProductionStatus mPS = new ProductionStatus(); //Initialize Feedback data to Feedback Table mCF.ShpID = int.Parse(dataGridViewFeedbackFile.Rows[rowIndex].Cells[0].Value.ToString()); mCF.ShipmentID = dataGridViewFeedbackFile.Rows[rowIndex].Cells[1].Value.ToString(); mCF.ISBN = dataGridViewFeedbackFile.Rows[rowIndex].Cells[2].Value.ToString(); mCF.FormatName = dataGridViewFeedbackFile.Rows[rowIndex].Cells[3].Value.ToString(); //Initialize Feedback data to Shipment Detail Table mSD.ShpID = int.Parse(dataGridViewFeedbackFile.Rows[rowIndex].Cells[0].Value.ToString()); mSD.ShipmentID = dataGridViewFeedbackFile.Rows[rowIndex].Cells[1].Value.ToString(); mSD.TransmissionDone = 0; //Production Status Log Values Initialize mPS.ProductID = int.Parse(dataGridViewFeedbackFile.Rows[rowIndex].Cells[0].Value.ToString()); mPS.ShipmentID = dataGridViewFeedbackFile.Rows[rowIndex].Cells[1].Value.ToString(); mPS.ISBN = dataGridViewFeedbackFile.Rows[rowIndex].Cells[2].Value.ToString(); mPS.FormatName = dataGridViewFeedbackFile.Rows[rowIndex].Cells[3].Value.ToString(); mPS.UserID = lblUID.Text; mPS.StartDate = DateTime.Now; mPS.Status = "Feedback Removed by System Access User " + lblUID.Text; ShipmentDetailMng mSDMng = new ShipmentDetailMng(conn); FeedbackMng mCFMng = new FeedbackMng(conn); ProductionStatusLogMng mPSMng = new ProductionStatusLogMng(conn); result = MessageBox.Show("Do you really want to remove feedback?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { //Remove data from Feedback Table if (mCFMng.DeleteFeedback(mCF) > 0) { //Update Shipment Detail Table mSDMng.UpdateFeedbackStatusInShipment(mSD); MessageBox.Show("Client feedback sucessfully removed.", "Feedback Removed", MessageBoxButtons.OK, MessageBoxIcon.Information); //Production Status Log mPSMng.AddProdustionStatus(mPS); RefreshData(); } } } catch (Exception ex) { if (ex.HResult == -2147467261) { MessageBox.Show("There is no file selected to remove feedback.\n Please select a file from Feedback File list or Click Referesh button.", "Cannot Remove", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Error" + ex.Message); } } }
public static int ScanMatrixCode(int stationNumber) { if (productionStatus != ProductionStatus.ScanMatrixCode) { productionStatus = ProductionStatus.ScanMatrixCode; comCts = new CancellationTokenSource(); // set all to scanning when scan is started StationRepository.ResetPortScanMatrixStatus(PortScanStatus.Scanning); } var nextStation = StationRepository.GetNextForMatrixScan(); if (nextStation == null) { productionStatus = ProductionStatus.Idle; return 0; } if (stationNumber != 0 && stationNumber != nextStation.Number) { throw new InvalidOperationException("Expected station is " + nextStation.Number + ", got: " + stationNumber); } var station = StationRepository.GetOne(nextStation.Number); var meter = MeterRepository.GetOne(station.MeterNo); if (meter == null) { throw new NullReferenceException("meter"); } if (meter.Parameters == null || meter.Parameters.Count == 0) { throw new NullReferenceException("DvseMeter parameters null or empty"); } if (comCts.IsCancellationRequested) { throw new OperationCanceledException("Scan cancelled"); } var paramEigNr = meter.GetParameter(ParameterTagId.Eigentumsnummer); var paramType = meter.GetParameter(ParameterTagId.Typ); var paramServerId = meter.GetParameter(ParameterTagId.ServerId); var paramPubKey = meter.GetParameter(ParameterTagId.PublicKey); var paramSerialNo = meter.GetParameter(ParameterTagId.ManufacturerSerialNumber); if (AppConfigRepository.Get().IsFakeCom) { paramEigNr.ScannedValue = paramEigNr.TargetValue; paramType.ScannedValue = paramType.TargetValue; paramServerId.ScannedValue = paramServerId.TargetValue; paramPubKey.ScannedValue = paramPubKey.TargetValue; paramSerialNo.ScannedValue = paramSerialNo.TargetValue; StationRepository.SetPortScanMatrixStatus(station.ComPort, PortScanStatus.ScanOk); meter.IsScanMatrixCodeCompleted = true; MeterRepository.Update(meter); } else { try { var appConfig = AppConfigRepository.Get(); var matrixCode = ScannerUtil.ReadMatrixCode(appConfig.ScannerTimeout); paramEigNr.ScannedValue = matrixCode.Eigentumsnummer; paramType.ScannedValue = matrixCode.TypCode; paramServerId.ScannedValue = matrixCode.ServerId; paramPubKey.ScannedValue = matrixCode.PublicKey; paramSerialNo.ScannedValue = matrixCode.SerialNo; if (paramEigNr.IsScannedValid && paramType.IsScannedValid && paramServerId.IsScannedValid && paramSerialNo.IsScannedValid) { StationRepository.SetPortScanMatrixStatus(station.ComPort, PortScanStatus.ScanOk); meter.IsScanMatrixCodeCompleted = true; MeterRepository.Update(meter); } else { StationRepository.SetPortScanMatrixStatus(station.ComPort, PortScanStatus.ScanFailed); MeterRepository.Update(meter); } } catch (Exception ex) { StationRepository.SetPortScanMatrixStatus(station.ComPort, PortScanStatus.Scanning); Log.ErrorException("Scan matrix code failed for station #" + stationNumber, ex); } } nextStation = StationRepository.GetNextForMatrixScan(); if (nextStation == null) { productionStatus = ProductionStatus.Idle; return 0; } return nextStation.Number; }
public static int ScanPcbCode(int stationNumber) { Log.Debug("Scanning PCB code for station no {0}...", stationNumber); if (productionStatus != ProductionStatus.ScanPcbCode) { productionStatus = ProductionStatus.ScanPcbCode; comCts = new CancellationTokenSource(); // set all to scanning when scan is started StationRepository.ResetPortScanPcbStatus(PortScanStatus.Scanning); } Log.Debug("Getting next station number for PCB scan..."); var nextStation = StationRepository.GetNextForPcbScan(); if (nextStation == null) { productionStatus = ProductionStatus.Idle; return 0; } if (stationNumber != 0 && stationNumber != nextStation.Number) { throw new InvalidOperationException("Expected station is " + nextStation.Number + ", got: " + stationNumber); } Log.Debug("Getting station for number {0}...", nextStation.Number); var station = StationRepository.GetOne(nextStation.Number); Log.Debug("Getting meter for meterNo {0}...", station.MeterNo); var meter = MeterRepository.GetOne(station.MeterNo); if (meter == null) { throw new NullReferenceException("meter"); } if (meter.Parameters == null || meter.Parameters.Count == 0) { throw new NullReferenceException("DvseMeter parameters null or empty"); } if (comCts.IsCancellationRequested) { throw new OperationCanceledException("Scan cancelled"); } Log.Debug("Getting parameter for pcb bar code..."); var paramPcb = meter.GetParameter(ParameterTagId.PcbBarCode); if (AppConfigRepository.Get().IsFakeCom) { paramPcb.ScannedValue = "12345678"; var rnd = new Random(); if (rnd.Next(1, 10) < 7) { StationRepository.SetPortScanPcbStatus(station.ComPort, PortScanStatus.ScanOk); meter.IsScanPcbCodeCompleted = true; MeterRepository.Update(meter); } else { StationRepository.SetPortScanPcbStatus(station.ComPort, PortScanStatus.ScanFailed); } } else { try { var appConfig = AppConfigRepository.Get(); Log.Debug("Scanning barcode with timeout {0}...", appConfig.ScannerTimeout); var pcbCode = ScannerUtil.ReadPcbCode(appConfig.ScannerTimeout); if (!string.IsNullOrWhiteSpace(pcbCode)) { paramPcb.ScannedValue = pcbCode; StationRepository.SetPortScanPcbStatus(station.ComPort, PortScanStatus.ScanOk); meter.IsScanPcbCodeCompleted = true; MeterRepository.Update(meter); } else { StationRepository.SetPortScanPcbStatus(station.ComPort, PortScanStatus.ScanFailed); } } catch (Exception ex) { StationRepository.SetPortScanPcbStatus(station.ComPort, PortScanStatus.Scanning); Log.ErrorException("Scan pcb code failed for station #" + stationNumber, ex); } } nextStation = StationRepository.GetNextForPcbScan(); if (nextStation == null) { productionStatus = ProductionStatus.Idle; return 0; } return nextStation.Number; }
public void SetStatus(ProductionStatus Satus) { status = Status; }
private void btnRemoveUID_Click(object sender, EventArgs e) { try { DialogResult result; int rowIndex = dataGridAfterAssignedUID.CurrentRow.Index; if (dataGridAfterAssignedUID.Rows[rowIndex].Cells[7].Value.ToString() == "Process By User") { String ISBN = dataGridAfterAssignedUID.Rows[rowIndex].Cells[2].Value.ToString(); result = MessageBox.Show("Do you really want to remove User ID from ISBN: " + ISBN + "?", "Remove User from Assign File", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { QRDetail mQRD = new QRDetail(); QRHeader mQRH = new QRHeader(); EmployeeProduction mEMP = new EmployeeProduction(); ProductionManagementDetail mProductionDtl = new ProductionManagementDetail(); ProductionManagementHeader mProductionHdr = new ProductionManagementHeader(); ShipmentDetailFormats mShipmentDetailFormats = new ShipmentDetailFormats(); ProductionStatus mLog = new ProductionStatus(); //initilize values for QR Detail to delete mQRD.ProductID = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString()); mQRD.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString(); mQRD.ISBN = ISBN; mQRD.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString(); //initilize values for QR Header to delete mQRH.ProductID = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString()); mQRH.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString(); mQRH.ISBN = ISBN; mQRH.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString(); //initilize values for Employee Production to delete mEMP.ProductID = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString()); mEMP.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString(); mEMP.ISBN = ISBN; mEMP.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString(); mEMP.Status = "Complete By User"; //initilize values for Production Detail to delete mProductionDtl.ShpID = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString()); mProductionDtl.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString(); mProductionDtl.ISBN = ISBN; mProductionDtl.Format = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString(); //initilize values for Production Detail Header to delete mProductionHdr.ShpID = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString()); mProductionHdr.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString(); mProductionHdr.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString(); //initilize values for Detail Format to delete mShipmentDetailFormats.ShpID = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString()); mShipmentDetailFormats.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString(); mShipmentDetailFormats.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString(); //Production Status Log Value mLog.ProductID = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString()); mLog.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString(); mLog.ISBN = dataGridBeforeAssignedUID.Rows[rowIndex].Cells[2].Value.ToString(); mLog.StartDate = DateTime.Now; mLog.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString(); mLog.UserID = lblCUID.Text; String aUID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[4].Value.ToString(); mLog.Status = "Removed assigned User " + aUID + " from Assgned Production by System Access User " + lblCUID.Text; QRDetailMng mQRDMng = new QRDetailMng(conn); QRHeaderMng mQRHMng = new QRHeaderMng(conn); EmployeeProductionMng mEPMMng = new EmployeeProductionMng(conn); ProductionManagementDetailMng mShipmentDetailMng = new ProductionManagementDetailMng(conn); ProductionManagementHeaderMng mProductionHdrMng = new ProductionManagementHeaderMng(conn); ShipmentDetailFormatsMng mShipmentDetailFormatsMng = new ShipmentDetailFormatsMng(conn); // Delete Production Manegement Detail if (mShipmentDetailMng.DeleteAssignedProductionManagementDetail(mProductionDtl) > 0) { // Delete Production Manegement Header mProductionHdrMng.DeleteProductionManagementHeader(mProductionHdr); // Delete QR Detail if (mQRDMng.DeleteQRDetail(mQRD) > 0) { // Delete QR Header mQRHMng.DeleteQRHeader(mQRH); } // Delete Employee Production mEPMMng.DeleteUserProdcutionDone(mEMP); // Update Employee Shipment Detail Formats to Not Assign mShipmentDetailFormatsMng.UpdateProductionOnToBeAssignFormatFile(mShipmentDetailFormats); MessageBox.Show("Selected assigned User successfully cleared from File..!", "Assigned File Clear", MessageBoxButtons.OK, MessageBoxIcon.Information); //Production Log table new ProductionStatusLogMng(this.conn).AddProdustionStatus(mLog); RefreshData(); } } } else { MessageBox.Show("This file is already in process by User. \nFirst modify status before remove User ID.", "Cannot Remove", MessageBoxButtons.OK, MessageBoxIcon.Error); btnModifyUID.Focus(); } } catch (Exception ex) { if (ex.HResult == -2147467261) { MessageBox.Show("First select a file to remove User ID.", "Cannot Remove", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbShipment.Focus(); } else { MessageBox.Show("Error" + ex.Message); } } }