294 lines
7.8 KiB
C#

/*********************************************************************************************
* Copyright 2005 - Volian Enterprises, Inc. All rights reserved.
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
* ------------------------------------------------------------------------------
* $Workfile: AppConflict.cs $ $Revision: 4 $
* $Author: Kathy $ $Date: 8/16/05 2:55p $
*
* $History: AppConflict.cs $
*
* ***************** Version 4 *****************
* User: Kathy Date: 8/16/05 Time: 2:55p
* Updated in $/LibSource/VEObject
* B2005-030: error if missing ndx
*
* ***************** Version 3 *****************
* User: Jsj Date: 6/02/05 Time: 11:32a
* Updated in $/LibSource/VEObject
* fix for approving with conditional ROs
*
* ***************** Version 2 *****************
* User: Kathy Date: 3/22/05 Time: 10:01a
* Updated in $/LibSource/VEObject
* Add procnum to transition message
*
* ***************** Version 1 *****************
* User: Kathy Date: 3/08/05 Time: 1:50p
* Created in $/LibSource/VEObject
* Approval
*********************************************************************************************/
using System;
using System.Text;
using System.Collections.Specialized;
namespace VEObject
{
/// <summary>
/// Summary description for AppConflict.
/// </summary>
public enum AppConflictTypes
{
RO=0, Trans=1, LibDoc=2
};
public class AppConflict
{
public AppConflictTypes CType;
public string ProcNum;
public string SeqNum;
public VEO_DummySet DummySet;
public AppConflict()
{
}
public string GetLocStr(string pnum, string snum)
{
string locstr=null;
string secnumtitle = DummySet.GetSectionNumAndTitle(pnum,snum);
if (snum.Length>1)
{
char tmp = System.Convert.ToChar(snum.Substring(1,1));
string stpnum = System.Convert.ToString(tmp-'0');
locstr = secnumtitle + " Step " + stpnum;
}
else
locstr = secnumtitle;
return locstr;
}
public virtual StringCollection GetStrForDlg()
{
return null;
}
public virtual string GetStrForEdit()
{
return null;
}
}
public class AppROConflict : AppConflict
{
public string ROID;
public string AccID;
public bool IsImage;
public string Val1, Val2;
public AppROConflict(VEO_DummySet ds, string rid, string pnum, string snum, bool image, string v1, string v2)
{
CType = AppConflictTypes.RO;
ROID = rid;
DummySet = ds;
ProcNum = pnum;
SeqNum = snum;
IsImage=image;
Val1=v1; //if image, this will contain image file path
Val2=v2;
if (Val1==null) Val1=" not defined ";
if (Val2==null) Val2=" not defined ";
}
public override string GetStrForEdit()
{
// For ROs:
// reference line is trimmed to 100 chars & consists of...
// 12 chars - sequence number where RO is used
// 20 chars - procedure number where RO is used
// 88 chars - menu item text, i.e. what's shown on dialog.
StringBuilder sb = new StringBuilder(125);
sb.Append(SeqNum.PadRight(12,' '));
sb.Append(ProcNum.PadRight(20,' '));
string locstr = GetLocStr(ProcNum,SeqNum);
string tmp=null;
if (IsImage)
tmp = "RO: Image File Difference: " + Val1.Replace("\n"," ") + " used in " + locstr;
else
tmp = "RO: New Value = " + Val1.Replace("\n"," ") + " Old Value = " + Val2.Replace("\n"," ") + " used in " + locstr;
int len = tmp.Length;
if (len==88)
sb.Append(tmp);
else if (len > 88)
sb.Append(tmp.Substring(0,88));
else
sb.Append(tmp.PadRight(88,' '));
return sb.ToString();
}
public override StringCollection GetStrForDlg()
{
StringCollection retstrs = new StringCollection();
StringBuilder sb = new StringBuilder();
string retstr;
string locstr = GetLocStr(ProcNum,SeqNum);
if (IsImage)
{
sb.Append(" RO Image File Difference At: ");
sb.Append(locstr);
retstrs.Add(sb.ToString());
sb.Remove(0,sb.Length);
sb.Append(" RO Value: ");
sb.Append(Val1);
retstrs.Add(sb.ToString());
}
else
{
int nlptr = -1;
int idx = 0;
sb.Append(" RO Difference At: ");
sb.Append(locstr);
retstrs.Add(sb.ToString());
sb.Remove(0,sb.Length);
sb.Append(" New Value = ");
nlptr = Val1.IndexOf("\n");
while (nlptr > -1)
{
sb.Append(Val1.Substring(idx,nlptr-idx));
retstrs.Add(sb.ToString());
sb.Remove(0,sb.Length);
idx = nlptr+1;
nlptr = Val1.IndexOf("\n",idx);
sb.Append(" ");
}
sb.Append(Val1.Substring(idx));
retstrs.Add(sb.ToString());
sb.Remove(0,sb.Length);
sb.Append(" Old Value = ");
idx = 0;
nlptr = Val2.IndexOf("\n");
while (nlptr > -1)
{
sb.Append(Val2.Substring(idx,nlptr-idx));
retstrs.Add(sb.ToString());
sb.Remove(0,sb.Length);
idx = nlptr+1;
nlptr = Val2.IndexOf("\n",idx);
sb.Append(" ");
}
sb.Append(Val2.Substring(idx));
retstrs.Add(sb.ToString());
}
return retstrs;
}
}
public class AppTransConflict : AppConflict
{
public string ToNum;
public string ToSeq;
public string OldTo;
public AppTransConflict(VEO_DummySet ds, string pnum, string snum, string tpnum, string tsnum, string old)
{
CType = AppConflictTypes.Trans;
DummySet = ds;
ProcNum = pnum;
SeqNum = snum;
ToNum=tpnum;
ToSeq=tsnum;
OldTo = old;
}
public override StringCollection GetStrForDlg()
{
StringCollection retstrs = new StringCollection();
StringBuilder sb = new StringBuilder();
sb.Append(" Transition: From = ");
sb.Append(ProcNum);
sb.Append(" ");
sb.Append(GetLocStr(ProcNum,SeqNum));
retstrs.Add(sb.ToString());
sb.Remove(0,sb.Length);
sb.Append(" To = ");
sb.Append(ToNum);
sb.Append(" ");
sb.Append(GetLocStr(ToNum,ToSeq));
retstrs.Add(sb.ToString());
return retstrs;
}
public override string GetStrForEdit()
{
// For Trans:
// reference line is trimmed to 100 chars & consists of...
// 12 chars - sequence number where Tran is used
// 20 chars - procedure number where Tran is used
// 88 chars - menu item text, i.e. what's shown on dialog.
StringBuilder sb = new StringBuilder(125);
sb.Append(SeqNum.PadRight(12,' '));
sb.Append(ProcNum.PadRight(20,' '));
string tmp = "Transition: To = " + " " + GetLocStr(ToNum,ToSeq);
int len = tmp.Length;
if (len==88)
sb.Append(tmp);
else if (len > 88)
sb.Append(tmp.Substring(0,88));
else
sb.Append(tmp.PadRight(88,' '));
return sb.ToString();
}
}
public class AppLibDocConflict : AppConflict
{
public string LibDocName;
public AppLibDocConflict(VEO_DummySet ds, string pnum, string seq, string Lname)
{
CType = AppConflictTypes.LibDoc;
DummySet = ds;
ProcNum = pnum;
SeqNum = seq;
LibDocName = Lname;
}
public override StringCollection GetStrForDlg()
{
StringCollection retstrs = new StringCollection();
StringBuilder sb = new StringBuilder();
sb.Append(" Library Doc = ");
sb.Append(LibDocName);
sb.Append(" used in ");
sb.Append(GetLocStr(ProcNum,SeqNum));
retstrs.Add(sb.ToString());
return retstrs;
}
public override string GetStrForEdit()
{
// For libdoc:
// reference line is trimmed to 100 chars & consists of...
// 12 chars - sequence number where LibDoc is used
// 20 chars - procedure number where LibDoc is used
// 88 chars - menu item text, i.e. what's shown on dialog.
StringBuilder sb = new StringBuilder(125);
sb.Append(SeqNum.PadRight(12,' '));
sb.Append(ProcNum.PadRight(20,' '));
string tmp = "Library Document: File Name = " + LibDocName + " used in " + GetLocStr(ProcNum,SeqNum);
int len = tmp.Length;
if (len==88)
sb.Append(tmp);
else if (len > 88)
sb.Append(tmp.Substring(0,88));
else
sb.Append(tmp.PadRight(88,' '));
return sb.ToString();
}
}
}