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.
This commit is contained in:
Rich 2015-02-19 17:43:23 +00:00
parent cbc3df3023
commit 7ff6a6a80e
4 changed files with 59 additions and 34 deletions

View File

@ -2281,8 +2281,11 @@ namespace VEPROMS
replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid);
cc.Text = cc.Text.Replace(lookfor, replacewith); cc.Text = cc.Text.Replace(lookfor, replacewith);
bool forceConvertToText = false; bool forceConvertToText = false;
SectionConfig sc = TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection.MyConfig as SectionConfig; if (TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection != null)
forceConvertToText = (sc.SubSection_Edit == "N"); {
SectionConfig sc = TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection.MyConfig as SectionConfig;
forceConvertToText = (sc.SubSection_Edit == "N");
}
cc.FixTransitionText(TransitionInfo.Get(tt.TransitionID), forceConvertToText); cc.FixTransitionText(TransitionInfo.Get(tt.TransitionID), forceConvertToText);
cc.Save(); cc.Save();
nd.InnerText = "done"; nd.InnerText = "done";
@ -2319,8 +2322,11 @@ namespace VEPROMS
else else
replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid);
cc.Text = cc.Text.Replace(lookfor, replacewith); cc.Text = cc.Text.Replace(lookfor, replacewith);
SectionConfig sc = TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection.MyConfig as SectionConfig; if (TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection != null)
forceConvertToText = (sc.SubSection_Edit == "N"); {
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 if (!forceConvertToText) //check to see if external with internal format
{ {
TransitionInfo tran = TransitionInfo.Get(transitionid); TransitionInfo tran = TransitionInfo.Get(transitionid);

View File

@ -81,22 +81,27 @@ namespace VEPROMS
UserInfo ui = UserInfo.GetByUserID(oi.SessionUserID); UserInfo ui = UserInfo.GetByUserID(oi.SessionUserID);
UserConfig uc = new UserConfig(ui.Config); UserConfig uc = new UserConfig(ui.Config);
string subject = "Please Check In A Procedure"; string subject = "Please Check In A Procedure";
if (!SendOutlookEmail(uc.User_UserEmail, subject, BuildEmailMessageBody(pi))) if (uc.User_UserEmail != string.Empty)
(sender as Button).Enabled = false; {
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) private string BuildEmailMessageBody(ProcedureInfo pi)
{ {
StringBuilder body = new StringBuilder(); StringBuilder body = new StringBuilder();
body.AppendLine("THIS IS A TEST MESSAGE FROM JIM BODINE"); //body.AppendLine("THIS IS A TEST MESSAGE FROM JIM BODINE");
body.AppendLine(); //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(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();
body.AppendLine("Obviously, you do not really have this procedure checked out, so you really do not have to do anything."); //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();
body.AppendLine("However, I would appreciate it if you would reply to this email so I know the email worked"); //body.AppendLine("However, I would appreciate it if you would reply to this email so I know the email worked");
body.AppendLine(); //body.AppendLine();
body.AppendLine("I will try NOT to overwhelm your email system :-)"); //body.AppendLine("I will try NOT to overwhelm your email system :-)");
return body.ToString(); return body.ToString();
} }
void ForceCheckIn_Click(object sender, EventArgs e) void ForceCheckIn_Click(object sender, EventArgs e)
@ -107,22 +112,27 @@ namespace VEPROMS
UserConfig uc = new UserConfig(ui.Config); UserConfig uc = new UserConfig(ui.Config);
MySessionInfo.CheckInItem(oi.OwnerID); MySessionInfo.CheckInItem(oi.OwnerID);
pnlList.Controls.Remove((sender as Button).Parent as Panel); pnlList.Controls.Remove((sender as Button).Parent as Panel);
string subject = "A Procedure Was Forced Checked In"; if (uc.User_UserEmail != string.Empty)
SendOutlookEmail(uc.User_UserEmail, subject, BuildForcedMessageBody(pi)); {
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) private string BuildForcedMessageBody(ProcedureInfo pi)
{ {
StringBuilder body = new StringBuilder(); StringBuilder body = new StringBuilder();
body.AppendLine("THIS IS A TEST MESSAGE FROM JIM BODINE"); //body.AppendLine("THIS IS A TEST MESSAGE FROM JIM BODINE");
body.AppendLine(); //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(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();
body.AppendLine("Obviously, you do not really have this procedure checked out, so nothing really got forced checked in."); //body.AppendLine("Obviously, you do not really have this procedure checked out, so nothing really got forced checked in.");
body.AppendLine(); //body.AppendLine();
body.AppendLine("However, I would appreciate it if you would reply to this email so I know the email worked"); //body.AppendLine("However, I would appreciate it if you would reply to this email so I know the email worked");
body.AppendLine(); //body.AppendLine();
body.AppendLine("I will try NOT to overwhelm your email system :-)"); //body.AppendLine("I will try NOT to overwhelm your email system :-)");
return body.ToString(); return body.ToString();
} }
private bool SendOutlookEmail(string email, string subject, string body) private bool SendOutlookEmail(string email, string subject, string body)

View File

@ -599,8 +599,11 @@ namespace VEPROMS.CSLA.Library
//} //}
if (!forceConvertToText) if (!forceConvertToText)
{ {
SectionConfig sc = traninfo.MyItemToID.ActiveSection.MyConfig as SectionConfig; if (traninfo.MyItemToID.ActiveSection != null)
forceConvertToText = (sc.SubSection_Edit == "N"); {
SectionConfig sc = traninfo.MyItemToID.ActiveSection.MyConfig as SectionConfig;
forceConvertToText = (sc.SubSection_Edit == "N");
}
if (forceConvertToText) if (forceConvertToText)
{ {
TranFixCount++; TranFixCount++;

View File

@ -681,9 +681,12 @@ namespace VEPROMS.CSLA.Library
if (oldContent == null) oldContent = content; if (oldContent == null) oldContent = content;
//check to see if noneditable //check to see if noneditable
bool forceConvertToText = false; bool forceConvertToText = false;
SectionConfig sc = tran.MyItemToID.ActiveSection.MyConfig as SectionConfig; if (tran.MyItemToID.ActiveSection != null)
//SectionConfig sc = new SectionConfig(tran.MyItemToID.ActiveSection.MyConfig.ToString()); {
forceConvertToText = (sc.SubSection_Edit == "N"); 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 (!forceConvertToText) //check to see if external with internal format
{ {
if (tran.MyContent.ContentItems[0].MyProcedure.ItemID != tran.MyItemToID.MyProcedure.ItemID) if (tran.MyContent.ContentItems[0].MyProcedure.ItemID != tran.MyItemToID.MyProcedure.ItemID)
@ -727,9 +730,12 @@ namespace VEPROMS.CSLA.Library
{ {
//check to see if noneditable //check to see if noneditable
bool forceConvertToText = false; bool forceConvertToText = false;
SectionConfig sc = tran.MyItemToID.ActiveSection.MyConfig as SectionConfig; if (tran.MyItemToID.ActiveSection != null)
//SectionConfig sc = new SectionConfig(tran.MyItemToID.ActiveSection.MyConfig.ToString()); {
forceConvertToText = (sc.SubSection_Edit == "N"); 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 (!forceConvertToText) //check to see if external with internal format
{ {
if (tran.MyContent.ContentItems[0].MyProcedure.ItemID != tran.MyItemToID.MyProcedure.ItemID) if (tran.MyContent.ContentItems[0].MyProcedure.ItemID != tran.MyItemToID.MyProcedure.ItemID)