From 7ff6a6a80eee17c20f6c01cc184ab98cc6c0e587 Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 19 Feb 2015 17:43:23 +0000 Subject: [PATCH] Added code to handle a transition where the item the transition is going to does not have an active section Added code to handle the condition where no email address has been defined for a user. --- .../VEPROMS User Interface/dlgExportImport.cs | 14 +++-- .../frmBatchRefreshCheckedOut.cs | 54 +++++++++++-------- .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 7 ++- .../Extension/ItemInsertExt.cs | 18 ++++--- 4 files changed, 59 insertions(+), 34 deletions(-) diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index c14da438..d10240ce 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -2281,8 +2281,11 @@ namespace VEPROMS replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); cc.Text = cc.Text.Replace(lookfor, replacewith); bool forceConvertToText = false; - SectionConfig sc = TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection.MyConfig as SectionConfig; - forceConvertToText = (sc.SubSection_Edit == "N"); + if (TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection != null) + { + SectionConfig sc = TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection.MyConfig as SectionConfig; + forceConvertToText = (sc.SubSection_Edit == "N"); + } cc.FixTransitionText(TransitionInfo.Get(tt.TransitionID), forceConvertToText); cc.Save(); nd.InnerText = "done"; @@ -2319,8 +2322,11 @@ namespace VEPROMS else replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); cc.Text = cc.Text.Replace(lookfor, replacewith); - SectionConfig sc = TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection.MyConfig as SectionConfig; - forceConvertToText = (sc.SubSection_Edit == "N"); + if (TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection != null) + { + SectionConfig sc = TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection.MyConfig as SectionConfig; + forceConvertToText = (sc.SubSection_Edit == "N"); + } if (!forceConvertToText) //check to see if external with internal format { TransitionInfo tran = TransitionInfo.Get(transitionid); diff --git a/PROMS/VEPROMS User Interface/frmBatchRefreshCheckedOut.cs b/PROMS/VEPROMS User Interface/frmBatchRefreshCheckedOut.cs index c3d82e55..e5e335af 100644 --- a/PROMS/VEPROMS User Interface/frmBatchRefreshCheckedOut.cs +++ b/PROMS/VEPROMS User Interface/frmBatchRefreshCheckedOut.cs @@ -81,22 +81,27 @@ namespace VEPROMS UserInfo ui = UserInfo.GetByUserID(oi.SessionUserID); UserConfig uc = new UserConfig(ui.Config); string subject = "Please Check In A Procedure"; - if (!SendOutlookEmail(uc.User_UserEmail, subject, BuildEmailMessageBody(pi))) - (sender as Button).Enabled = false; + if (uc.User_UserEmail != string.Empty) + { + if (!SendOutlookEmail(uc.User_UserEmail, subject, BuildEmailMessageBody(pi))) + (sender as Button).Enabled = false; + } + else + MessageBox.Show("No email has been defined for this user. You will need to Force Check In this procedure", "No Email"); } private string BuildEmailMessageBody(ProcedureInfo pi) { StringBuilder body = new StringBuilder(); - body.AppendLine("THIS IS A TEST MESSAGE FROM JIM BODINE"); - body.AppendLine(); - body.AppendLine(string.Format("I need you to check in procedure {0} so I can continue a batch refresh process", pi.DisplayNumber)); - body.AppendLine(); - body.AppendLine("Obviously, you do not really have this procedure checked out, so you really do not have to do anything."); - body.AppendLine(); - body.AppendLine("However, I would appreciate it if you would reply to this email so I know the email worked"); - body.AppendLine(); - body.AppendLine("I will try NOT to overwhelm your email system :-)"); + //body.AppendLine("THIS IS A TEST MESSAGE FROM JIM BODINE"); + //body.AppendLine(); + body.AppendLine(string.Format("The administrator needs you to check in procedure {0} so the administrator can continue an administrative tool process", pi.DisplayNumber)); + //body.AppendLine(); + //body.AppendLine("Obviously, you do not really have this procedure checked out, so you really do not have to do anything."); + //body.AppendLine(); + //body.AppendLine("However, I would appreciate it if you would reply to this email so I know the email worked"); + //body.AppendLine(); + //body.AppendLine("I will try NOT to overwhelm your email system :-)"); return body.ToString(); } void ForceCheckIn_Click(object sender, EventArgs e) @@ -107,22 +112,27 @@ namespace VEPROMS UserConfig uc = new UserConfig(ui.Config); MySessionInfo.CheckInItem(oi.OwnerID); pnlList.Controls.Remove((sender as Button).Parent as Panel); - string subject = "A Procedure Was Forced Checked In"; - SendOutlookEmail(uc.User_UserEmail, subject, BuildForcedMessageBody(pi)); + if (uc.User_UserEmail != string.Empty) + { + string subject = "A Procedure Was Forced Checked In"; + SendOutlookEmail(uc.User_UserEmail, subject, BuildForcedMessageBody(pi)); + } + else + MessageBox.Show("No email has been defined for this user. The procedure will be Force Checked In, but the user will not be notified.", "No Email"); } private string BuildForcedMessageBody(ProcedureInfo pi) { StringBuilder body = new StringBuilder(); - body.AppendLine("THIS IS A TEST MESSAGE FROM JIM BODINE"); - body.AppendLine(); - body.AppendLine(string.Format("I needed to force check in procedure {0} so I could continue a batch refresh process", pi.DisplayNumber)); - body.AppendLine(); - body.AppendLine("Obviously, you do not really have this procedure checked out, so nothing really got forced checked in."); - body.AppendLine(); - body.AppendLine("However, I would appreciate it if you would reply to this email so I know the email worked"); - body.AppendLine(); - body.AppendLine("I will try NOT to overwhelm your email system :-)"); + //body.AppendLine("THIS IS A TEST MESSAGE FROM JIM BODINE"); + //body.AppendLine(); + body.AppendLine(string.Format("The administrator needed to force check in procedure {0} so the administrator could continue an administrative tool process", pi.DisplayNumber)); + //body.AppendLine(); + //body.AppendLine("Obviously, you do not really have this procedure checked out, so nothing really got forced checked in."); + //body.AppendLine(); + //body.AppendLine("However, I would appreciate it if you would reply to this email so I know the email worked"); + //body.AppendLine(); + //body.AppendLine("I will try NOT to overwhelm your email system :-)"); return body.ToString(); } private bool SendOutlookEmail(string email, string subject, string body) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index c7462ecd..fbb6eda8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -599,8 +599,11 @@ namespace VEPROMS.CSLA.Library //} if (!forceConvertToText) { - SectionConfig sc = traninfo.MyItemToID.ActiveSection.MyConfig as SectionConfig; - forceConvertToText = (sc.SubSection_Edit == "N"); + if (traninfo.MyItemToID.ActiveSection != null) + { + SectionConfig sc = traninfo.MyItemToID.ActiveSection.MyConfig as SectionConfig; + forceConvertToText = (sc.SubSection_Edit == "N"); + } if (forceConvertToText) { TranFixCount++; diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index 577227f3..51ba1508 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -681,9 +681,12 @@ namespace VEPROMS.CSLA.Library if (oldContent == null) oldContent = content; //check to see if noneditable bool forceConvertToText = false; - SectionConfig sc = tran.MyItemToID.ActiveSection.MyConfig as SectionConfig; - //SectionConfig sc = new SectionConfig(tran.MyItemToID.ActiveSection.MyConfig.ToString()); - forceConvertToText = (sc.SubSection_Edit == "N"); + if (tran.MyItemToID.ActiveSection != null) + { + SectionConfig sc = tran.MyItemToID.ActiveSection.MyConfig as SectionConfig; + //SectionConfig sc = new SectionConfig(tran.MyItemToID.ActiveSection.MyConfig.ToString()); + forceConvertToText = (sc.SubSection_Edit == "N"); + } if (!forceConvertToText) //check to see if external with internal format { if (tran.MyContent.ContentItems[0].MyProcedure.ItemID != tran.MyItemToID.MyProcedure.ItemID) @@ -727,9 +730,12 @@ namespace VEPROMS.CSLA.Library { //check to see if noneditable bool forceConvertToText = false; - SectionConfig sc = tran.MyItemToID.ActiveSection.MyConfig as SectionConfig; - //SectionConfig sc = new SectionConfig(tran.MyItemToID.ActiveSection.MyConfig.ToString()); - forceConvertToText = (sc.SubSection_Edit == "N"); + if (tran.MyItemToID.ActiveSection != null) + { + SectionConfig sc = tran.MyItemToID.ActiveSection.MyConfig as SectionConfig; + //SectionConfig sc = new SectionConfig(tran.MyItemToID.ActiveSection.MyConfig.ToString()); + forceConvertToText = (sc.SubSection_Edit == "N"); + } if (!forceConvertToText) //check to see if external with internal format { if (tran.MyContent.ContentItems[0].MyProcedure.ItemID != tran.MyItemToID.MyProcedure.ItemID)