/// <summary> /// Validating Existence of Asset,New GMU NO, Serial No /// </summary> /// <param name="item_ags"></param> /// <param name="ErrorMsg"></param> /// <returns></returns> private bool Vaildate(BMC.Transport.AGSdetails item_ags, ref string ErrorMsg) { bool retval = true; try { int mygmuno = 0; int.TryParse(item_ags.GMUNo, out mygmuno); if (mygmuno == 0) { ErrorMsg = "MessageID524"; retval = false; } else if (mygmuno > 0 && mygmuno > 99999) { ErrorMsg = "MessageID525"; retval = false; } else if (UpdateGMUNo.CreateInstance().CheckAGSCombination(item_ags.ActualAssetNo, item_ags.GMUNo, item_ags.SerialNo)) { ErrorMsg = "MessageID510"; retval = false; } } catch (Exception ex) { retval = false; ErrorMsg = "MessageID511"; ExceptionManager.Publish(ex); } return(retval); }
/// <summary> /// Send AGS details to enterprise /// </summary> /// <param name="item_ags"></param> private void SaveAGSCombination(BMC.Transport.AGSdetails item_ags) { try { string strXml = UpdateGMUNo.CreateInstance().ExportAGSDetails(item_ags.MachineID, item_ags.GMUNo); Proxy oProxy = new Proxy(Settings.SiteCode); if (oProxy.UpdateGMUNumber(strXml))//Send AGS Details to Enterprise { LogManager.WriteLog(strScreenName + "Enterprise GMU Number Updated Successfully", LogManager.enumLogLevel.Info); if (UpdateGMUNo.CreateInstance().UpdateGMUDetails(item_ags.MachineID, item_ags.GMUNo, item_ags.Installation_No.Value)) //After Vaildating in Enterprise Updating GMUNo in Exchange { if (SendDetailsToExcomms(item_ags)) //Send to Excomms i.e. GMU No is modified { BMC.Presentation.MessageBox.ShowBox("MessageID506", BMC_Icon.Information); LogManager.WriteLog(strScreenName + "Exchange GMU Number Updated Successfully GMUNo: " + item_ags.OldGMUNo + "-->" + item_ags.GMUNo, LogManager.enumLogLevel.Info); AuditModule("GMU Updated Successfully for an Asset ", item_ags.AssetNo, item_ags.OldGMUNo, item_ags.GMUNo); } else { AuditModule("GMU Updated Failed for an Asset ", item_ags.AssetNo, item_ags.OldGMUNo, item_ags.GMUNo); UpdateGMUNo.CreateInstance().UpdateGMUDetails(item_ags.MachineID, item_ags.OldGMUNo, item_ags.Installation_No.Value); LogManager.WriteLog(strScreenName + "Rollback GMU Number Updation in Exchange GMUNo: " + item_ags.GMUNo + "-->" + item_ags.OldGMUNo, LogManager.enumLogLevel.Info); strXml = UpdateGMUNo.CreateInstance().ExportAGSDetails(item_ags.MachineID, item_ags.OldGMUNo); oProxy.UpdateGMUNumber(strXml); LogManager.WriteLog(strScreenName + "Rollback GMU Number Updation in Enterprise GMUNo: " + item_ags.GMUNo + "-->" + item_ags.OldGMUNo, LogManager.enumLogLevel.Info); item_ags.GMUNo = item_ags.OldGMUNo; AuditModule("Rollback GMU Number Updation for an Asset ", item_ags.AssetNo, item_ags.GMUNo, item_ags.OldGMUNo); } } else { AuditModule("GMU Updated Failed for an Asset ", item_ags.AssetNo, item_ags.OldGMUNo, item_ags.GMUNo); BMC.Presentation.MessageBox.ShowBox("MessageID507", BMC_Icon.Information); LogManager.WriteLog(strScreenName + "Exchange GMU Number Updated Failed for GMUNo: " + item_ags.GMUNo, LogManager.enumLogLevel.Info); item_ags.GMUNo = item_ags.OldGMUNo; } } else { BMC.Presentation.MessageBox.ShowBox("MessageID529", BMC_Icon.Information); // AuditModule("GMU Updated Failed for an Asset ", item_ags.AssetNo, item_ags.OldGMUNo, item_ags.GMUNo); LogManager.WriteLog(strScreenName + "Enterprise GMU Number Updated Failed for GMUNo: " + item_ags.GMUNo, LogManager.enumLogLevel.Info); item_ags.GMUNo = item_ags.OldGMUNo; } } catch (Exception Ex) { AuditModule("GMU Updated Failed for an Asset ", item_ags.AssetNo, item_ags.OldGMUNo, item_ags.GMUNo); BMC.Presentation.MessageBox.ShowBox("MessageID507", BMC_Icon.Information); item_ags.GMUNo = item_ags.OldGMUNo; ExceptionManager.Publish(Ex); } }
private void txt_GMUNo_GotFocus(object sender, RoutedEventArgs e) { try { TextBox txtGMUNo = sender as TextBox; BMC.Transport.AGSdetails item_ags = GetCurrentItem(txtGMUNo.Tag.ToString()); if (item_ags != null && txtGMUNo.Text.Trim() != "") { item_ags.OldGMUNo = txtGMUNo.Text.Trim(); } } catch (Exception ex) { ExceptionManager.Publish(ex); } }
///// <summary> ///// This Method will retry around certain number of times if it fails ///// </summary> ///// <param name="Key"></param> ///// <param name="Installation_No"></param> ///// <param name="Bar_Pos_Port"></param> ///// <param name="DisableMachine"></param> ///// <returns></returns> //private bool InvokeMethod(string Key, int Installation_No, int Bar_Pos_Port, int DisableMachine) //{ // bool retVal = false; // int Count = 0; // try // { // while (Count < RetryCount) // { // ar_wait.WaitOne(2000); // if (Key == "RemoveMachineFromPollingList") // { // if (di_Method[Key].Invoke(Installation_No, DisableMachine)) // { // ar_wait.Set(); // retVal = true; // break; // } // } // else // { // if (di_Method[Key].Invoke(Installation_No, Bar_Pos_Port)) // { // ar_wait.Set(); // retVal = true; // break; // } // } // Count++; // } // } // catch (Exception Ex) // { // ExceptionManager.Publish(Ex); // } // return retVal; //} /// <summary> /// Remove machine from polling list and then adding to polling list with same installtion /// </summary> /// <param name="item_ags"></param> /// <returns>true or false</returns> private bool SendDetailsToExcomms(BMC.Transport.AGSdetails item_ags) { bool retVal = false; try { EnrollmentDataAccess enrollmentDataAccess = new EnrollmentDataAccess(); int Bar_Pos_Port = enrollmentDataAccess.GetBarPosPort(item_ags.Installation_No.Value); if (item_ags.IsNull) { if (UpdateGMUNo.CreateInstance().RemoveMachineFromPollingList(item_ags.Installation_No.Value, 0)) { LogManager.WriteLog(strScreenName + " Remove Machine From PollingList Succeed InstallationNo:" + item_ags.Installation_No.Value, LogManager.enumLogLevel.Info); LogManager.WriteLog(strScreenName + "'NULL' string updated successfully for an asset :" + item_ags.AssetNo, LogManager.enumLogLevel.Info); bool retGMUEvent = UpdateGMUNo.CreateInstance().UpdateGMUDownEvent(item_ags.Installation_No.Value); LogManager.WriteLog(strScreenName + "'GMUDownEvent inserted - " + retGMUEvent.ToString() + " - for an asset :" + item_ags.AssetNo, LogManager.enumLogLevel.Info); retVal = true; } else { BMC.Presentation.MessageBox.ShowBox("MessageID208", BMC_Icon.Error); LogManager.WriteLog(strScreenName + "Unable to Remove Machine From PollingList InstallationNo:" + item_ags.Installation_No.Value, LogManager.enumLogLevel.Info); } } else { if (UpdateGMUNo.CreateInstance().AddToPollingList(item_ags.Installation_No.Value, Bar_Pos_Port)) { LogManager.WriteLog(strScreenName + "Add Machine To PollingList Succeed InstallationNo:" + item_ags.Installation_No.Value, LogManager.enumLogLevel.Info); retVal = true; } else { BMC.Presentation.MessageBox.ShowBox("MessageID508", BMC_Icon.Error); LogManager.WriteLog(strScreenName + "Unable to Add Machine To PollingList InstallationNo:" + item_ags.Installation_No.Value, LogManager.enumLogLevel.Info); } } } catch (Exception ex) { ExceptionManager.Publish(ex); } return(retVal); }
private void btn_EditSave_Click(object sender, RoutedEventArgs e) { try { Button bt_edit = sender as Button; BMC.Transport.AGSdetails item_ags = GetCurrentItem(bt_edit.Tag.ToString()); lvGMUNo.SelectedItem = item_ags; if (item_ags.EditSave == "Edit") { item_ags.IsNull = false; int tmpGMU = 0; item_ags.OldGMUNo = item_ags.GMUNo; if (int.TryParse(item_ags.GMUNo, out tmpGMU)) { item_ags.GMUNo = strNULL; item_ags.IsNull = true; } else { item_ags.GMUNo = ""; } item_ags.IsEnabled = !item_ags.IsNull; item_ags.EditSave = "Save"; } else { item_ags.IsEnabled = false; item_ags.EditSave = "Edit"; string ErrorMsg = ""; item_ags.OldGMUNo = item_ags.OldGMUNo.Trim(); int tmpGMU = 0; if (int.TryParse(item_ags.GMUNo, out tmpGMU)) { item_ags.GMUNo = tmpGMU.ToString(); } else { item_ags.GMUNo = item_ags.GMUNo.Trim(); } if (item_ags.IsNull || Vaildate(item_ags, ref ErrorMsg)) { if (BMC.Presentation.MessageBox.ShowBox("MessageID509", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.Yes) { SaveAGSCombination(item_ags); item_ags.OldGMUNo = item_ags.GMUNo; } else { item_ags.GMUNo = item_ags.OldGMUNo; } } else { LogManager.WriteLog(strScreenName + "Vaildation Failed ErrorMsg:" + ErrorMsg, LogManager.enumLogLevel.Info); BMC.Presentation.MessageBox.ShowBox(ErrorMsg, BMC_Icon.Error); item_ags.GMUNo = item_ags.OldGMUNo; } } } catch (Exception Ex) { ExceptionManager.Publish(Ex); } }