Added second overloaded method SetParentSectionAnDocVersion to ItemInfo class to support multi unit
Added IsApplicable property to ItemInfo class Changed DisplayText method to handle <u> in text Changed DisplayNumber methid to handle <U-ID> and <S\u8209?ID> in number Added TransistionLookup class to suppport transition updates in multi unit Added property MyLookup to ProcedureInfo class Added GetItemAndChildrenByUnit method to ProcedureInfo class Changed ProcedureConfig property of ProcedureInfo class to support multi unit Removed AddToCache call in CopyPasteItemInfoFetch of ItemInfo class Removed AddToCache call in NewItemInfoFetch method of ItemInfo class
This commit is contained in:
parent
bdf8150326
commit
3036b5fb7d
@ -329,6 +329,50 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (ItemInfo ii in pi.MyItems)
|
||||
SetParentSectionAndDocVersion(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, procInfo, docVersionInfo);
|
||||
}
|
||||
internal static void SetParentSectionAndDocVersion(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
|
||||
{
|
||||
if (itemInfo == null) return;
|
||||
itemInfo.LoadAllAtOnce = true;
|
||||
itemInfo.ActiveParent = itemParent;
|
||||
itemInfo.ActiveSection = sectionInfo;
|
||||
itemInfo.MyDocVersion = docVersionInfo;
|
||||
ROFstInfo rofstinfo = docVersionInfo.DocVersionAssociations[0].MyROFst;
|
||||
rofstinfo.docVer = docVersionInfo;
|
||||
ROFSTLookup lookup = rofstinfo.ROFSTLookup;
|
||||
lookup.DocVersionInfo = docVersionInfo;
|
||||
if (itemInfo.MyContent.ContentRoUsageCount > 0)
|
||||
{
|
||||
foreach (RoUsageInfo rousage in itemInfo.MyContent.ContentRoUsages)
|
||||
{
|
||||
if (sectionInfo != null)
|
||||
{
|
||||
string roval = lookup.GetTranslatedRoValue(rousage.ROID, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
|
||||
ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID);
|
||||
itemInfo.MyContent.FixContentText(rousage, roval, roch.type, rofstinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemInfo.MyContent.ContentPartCount > 0)
|
||||
{
|
||||
foreach (PartInfo pi in itemInfo.MyContent.ContentParts)
|
||||
{
|
||||
foreach (ItemInfo ii in pi.MyItems)
|
||||
{
|
||||
Console.WriteLine(ii.ItemID.ToString());
|
||||
SetParentSectionAndDocVersion(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, docVersionInfo, tranLookup);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemInfo.MyContent.ContentTransitionCount > 0)
|
||||
{
|
||||
//itemInfo.UpdateTransitionText();
|
||||
foreach (TransitionInfo traninfo in itemInfo.MyContent.ContentTransitions)
|
||||
{
|
||||
//itemInfo.UpdateTransitionText();
|
||||
itemInfo.MyContent.FixTransitionText(traninfo, tranLookup);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _PrintBias = 0;
|
||||
public int PrintBias
|
||||
{
|
||||
@ -1380,16 +1424,39 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Formatting of Text
|
||||
//jcb added inherited applicability
|
||||
public bool IsApplicable(int apple)
|
||||
{
|
||||
if (apple == -1)
|
||||
return true;
|
||||
ItemInfo parent = this.ActiveParent as ItemInfo;
|
||||
IItemConfig cfg = this.MyConfig as IItemConfig;
|
||||
return (this.IsProcedure || parent.IsApplicable(apple)) && (cfg.MasterSlave_Applicability.GetFlags().Count == 0 || cfg.MasterSlave_Applicability.GetFlags().Contains(apple));
|
||||
}
|
||||
//end jcb added inherited applicability
|
||||
public string DisplayText
|
||||
{
|
||||
get { return ConvertToDisplayText(MyContent.Text); }
|
||||
get
|
||||
{
|
||||
string str = MyContent.Text;
|
||||
if (str.Contains("<u>"))
|
||||
str = str.Replace("<u>", MyDocVersion.DocVersionConfig.Unit_Number);
|
||||
return ConvertToDisplayText(str);
|
||||
}
|
||||
}
|
||||
public string DisplayNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
string str = (this.IsProcedure)?MyDocVersion.UnitSpecific(MyContent.Number,0):MyContent.Number;
|
||||
return ConvertToDisplayText(str);
|
||||
{
|
||||
string str = (this.IsProcedure) ? MyDocVersion.UnitSpecific(MyContent.Number, 0) : MyContent.Number;
|
||||
if (str.Contains("<U-ID>"))
|
||||
str = str.Replace("<U-ID>", MyDocVersion.DocVersionConfig.Unit_ID);
|
||||
//if (str.Contains(@"<S\u8209?ID>"))
|
||||
// str = str.Replace(@"<S\u8209?ID>", MyDocVersion.DocVersionConfig.Unit_ID);
|
||||
str = ConvertToDisplayText(str);
|
||||
if (str.Contains("<u>"))
|
||||
Console.WriteLine("it is still there");
|
||||
return str;
|
||||
}
|
||||
//get { return ConvertToDisplayText(MyContent.Number); }
|
||||
}
|
||||
@ -1613,9 +1680,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_MyParent == null)
|
||||
{
|
||||
//if (ItemDocVersionCount > 0) return ItemDocVersions[0]; Need to create one interface to support Folders, DocVersions and Items
|
||||
ContentInfo parentContent = ParentContent;
|
||||
if (parentContent == null || parentContent.ContentItemCount == 0) return null;
|
||||
//if (ItemDocVersionCount > 0) return ItemDocVersions[0]; Need to create one interface to support Folders, DocVersions and Items
|
||||
ContentInfo parentContent = ParentContent;
|
||||
if (parentContent == null || parentContent.ContentItemCount == 0) return null;
|
||||
_MyParent = parentContent.ContentItems[0];
|
||||
}
|
||||
return _MyParent;
|
||||
@ -1645,7 +1712,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if(LoadAllAtOnce)
|
||||
itemInfoList = partInfo._MyItems;// = ItemInfoList.GetList(partInfo.ItemID, partInfo.FromType);
|
||||
else
|
||||
itemInfoList = partInfo._MyItems = ItemInfoList.GetList(partInfo.ItemID, partInfo.FromType);
|
||||
itemInfoList = partInfo._MyItems = ItemInfoList.GetList(partInfo.ItemID, partInfo.FromType);
|
||||
return itemInfoList;
|
||||
}
|
||||
return null;
|
||||
@ -1766,9 +1833,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (MyContent.MyEntry == null)
|
||||
{
|
||||
if (DisplayNumber == string.Empty)
|
||||
if(DisplayNumber == string.Empty)
|
||||
return DisplayText.Replace("\u2011", "-").Split(" ,.;:-_".ToCharArray())[0] + "...";
|
||||
return DisplayNumber.Replace("\u2011", "-");
|
||||
return DisplayNumber.Replace("\u2011","-");
|
||||
}
|
||||
if (MyContent.Number != "") // Add LIB to the Section Number
|
||||
return ((MyContent.MyEntry.MyDocument.LibTitle ?? "") == "" ? "" : "\u1D38\u1D35\u1D2E ") + DisplayNumber;
|
||||
@ -1856,11 +1923,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_MyProcedure == null)
|
||||
{
|
||||
// Walk up active parents until the parent is not an item
|
||||
ItemInfo tmp = this;
|
||||
while (tmp.ActiveParent != null && !tmp.ActiveParent.IsDocVersion)
|
||||
tmp = (ItemInfo)tmp.ActiveParent;
|
||||
if (tmp is ProcedureInfo)
|
||||
// Walk up active parents until the parent is not an item
|
||||
ItemInfo tmp = this;
|
||||
while (tmp.ActiveParent != null && !tmp.ActiveParent.IsDocVersion)
|
||||
tmp = (ItemInfo)tmp.ActiveParent;
|
||||
if (tmp is ProcedureInfo)
|
||||
_MyProcedure = tmp as ProcedureInfo;
|
||||
else
|
||||
_MyProcedure = ProcedureInfo.Get(tmp.ItemID);
|
||||
@ -1904,8 +1971,8 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (ActiveParent == null) return null;
|
||||
_MyDocVersion = (ActiveParent as ItemInfo).MyDocVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _MyDocVersion;
|
||||
}
|
||||
set { _MyDocVersion = value; }
|
||||
@ -1996,8 +2063,8 @@ namespace VEPROMS.CSLA.Library
|
||||
int typ = (int)ActiveSection.MyContent.Type;
|
||||
int subtyp = typ % 10000;
|
||||
_MyDocStyle = ActiveFormat.PlantFormat.DocStyles.DocStyleList[subtyp];
|
||||
}
|
||||
return _MyDocStyle;
|
||||
}
|
||||
return _MyDocStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
@ -2177,7 +2244,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_MyTab.Text = "";
|
||||
_MyTab.CleanText = "";
|
||||
return;
|
||||
}
|
||||
}
|
||||
int stepType = (int)(MyContent.Type % 10000);
|
||||
string tbformat = IsInRNO ? FormatStepData.TabData.RNOIdentPrint : FormatStepData.TabData.IdentPrint;
|
||||
if (ActiveFormat.Name.ToUpper() == "WCNCKL" || ActiveFormat.Name.ToUpper() == "WSTCKL")
|
||||
@ -2233,7 +2300,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
int itmp = (localPrintLevel + PrintBias) % seqtabs.Count;
|
||||
if (!tbformat.Contains("C0"))
|
||||
tbformat = seqtabs[itmp].PrintTabFormat; // seqtab in 16bit, i.e. '. or )' etc.
|
||||
tbformat = seqtabs[itmp].PrintTabFormat; // seqtab in 16bit, i.e. '. or )' etc.
|
||||
else
|
||||
tbformat = tbformat.Replace("{seq}", seqtabs[itmp].PrintTabFormat);
|
||||
string tbtoken = seqtabs[localPrintLevel % seqtabs.Count].TabToken; // seqstart in 16bit, number/letter
|
||||
@ -2545,7 +2612,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
tbformat = tbformat + ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IdentB;
|
||||
if (TabToIdentBAdjustFont())
|
||||
_MyTab.RemovedStyleUnderline = true;
|
||||
_MyTab.RemovedStyleUnderline = true;
|
||||
}
|
||||
return tbformat;
|
||||
}
|
||||
@ -2883,7 +2950,7 @@ namespace VEPROMS.CSLA.Library
|
||||
//public void ToXml(XmlNode xn)
|
||||
//{
|
||||
// foreach (ItemInfo itemInfo in this)
|
||||
// {
|
||||
// {
|
||||
// itemInfo.ToXml(xn);
|
||||
// }
|
||||
//}
|
||||
@ -3673,10 +3740,96 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
#region new class TransitionLookup
|
||||
public delegate ProcedureInfo TransitionLookupEvent(object sender, TransitionLookupEventArgs args);
|
||||
public class TransitionLookupEventArgs
|
||||
{
|
||||
private int _ProcID;
|
||||
public int ProcID
|
||||
{
|
||||
get { return _ProcID; }
|
||||
set { _ProcID = value; }
|
||||
}
|
||||
private int _UnitID;
|
||||
public int UnitID
|
||||
{
|
||||
get { return _UnitID; }
|
||||
set { _UnitID = value; }
|
||||
}
|
||||
private DocVersionInfo _MyDocVersion;
|
||||
public DocVersionInfo MyDocVersion
|
||||
{
|
||||
get { return _MyDocVersion; }
|
||||
set { _MyDocVersion = value; }
|
||||
}
|
||||
private TransitionLookup _MyTranLookup;
|
||||
public TransitionLookup MyTranLookup
|
||||
{
|
||||
get { return _MyTranLookup; }
|
||||
set { _MyTranLookup = value; }
|
||||
}
|
||||
public TransitionLookupEventArgs(int procID, int unitID, DocVersionInfo dvi, TransitionLookup tl)
|
||||
{
|
||||
_ProcID = procID;
|
||||
_UnitID = unitID;
|
||||
_MyDocVersion = dvi;
|
||||
_MyTranLookup = tl;
|
||||
}
|
||||
}
|
||||
public partial class TransitionLookup
|
||||
{
|
||||
public event TransitionLookupEvent NewLookupNeeded;
|
||||
private Dictionary<int, Dictionary<int, ItemInfo>> _MyLookups;
|
||||
public Dictionary<int, Dictionary<int, ItemInfo>> MyLookups
|
||||
{
|
||||
get { return _MyLookups; }
|
||||
set { _MyLookups = value; }
|
||||
}
|
||||
private int _ApplicabilityUnit;
|
||||
public int ApplicabilityUnit
|
||||
{
|
||||
get { return _ApplicabilityUnit; }
|
||||
set { _ApplicabilityUnit = value; }
|
||||
}
|
||||
public TransitionLookup(int applicabilityUnit, int procID, Dictionary<int,ItemInfo> mylookup)
|
||||
{
|
||||
_MyLookups = new Dictionary<int, Dictionary<int, ItemInfo>>();
|
||||
_MyLookups.Add(procID, mylookup);
|
||||
_ApplicabilityUnit = applicabilityUnit;
|
||||
}
|
||||
public void AddProcLookup(int procID, Dictionary<int, ItemInfo> mylookup)
|
||||
{
|
||||
if(!_MyLookups.ContainsKey(procID))
|
||||
_MyLookups.Add(procID, mylookup);
|
||||
}
|
||||
public ItemInfo this[int itemID]
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (Dictionary<int, ItemInfo> mylookup in MyLookups.Values)
|
||||
{
|
||||
if (mylookup.ContainsKey(itemID))
|
||||
return mylookup[itemID];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public bool ContainsKey(int itemID)
|
||||
{
|
||||
foreach (Dictionary<int, ItemInfo> mylookup in MyLookups.Values)
|
||||
{
|
||||
if (mylookup.ContainsKey(itemID))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region ProcedureInfo
|
||||
[Serializable()]
|
||||
public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly
|
||||
{
|
||||
public Dictionary<int, ItemInfo> MyLookup = null;
|
||||
public override void SetupTags()
|
||||
{
|
||||
base.SetupTags();
|
||||
@ -3733,11 +3886,153 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
return (Procedure) (_Editable = Procedure.Get(ItemID));
|
||||
}
|
||||
//jcb add 20120501 item and children by unit
|
||||
public static ProcedureInfo GetItemAndChildrenByUnit(int? itemID, int? parentID, int? unitID)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProcedureInfo tmp = DataPortal.Fetch<ProcedureInfo>(new ItemAndChildrenByUnitCriteria(itemID, parentID, unitID));
|
||||
AddToCache(tmp);
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
if (tmp != null)
|
||||
{
|
||||
tmp.MyDocVersion.DocVersionConfig.SelectedSlave = (int)unitID;
|
||||
TransitionLookup tranLookup = new TransitionLookup((int)unitID, (int)itemID, tmp.MyLookup);
|
||||
tranLookup.NewLookupNeeded += new TransitionLookupEvent(GetNewLookup);
|
||||
SetParentSectionAndDocVersion(tmp, tmp.MyDocVersion, null, tmp.MyDocVersion, tranLookup);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ItemInfoList.GetChildren", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static ProcedureInfo GetNewLookup(object sender, TransitionLookupEventArgs args)
|
||||
{
|
||||
ProcedureInfo tmp = DataPortal.Fetch<ProcedureInfo>(new ItemAndChildrenByUnitCriteria(args.ProcID, 0, args.UnitID));
|
||||
return tmp;
|
||||
}
|
||||
// Criteria to get Item and children by unit
|
||||
[Serializable()]
|
||||
private class ItemAndChildrenByUnitCriteria
|
||||
{
|
||||
public ItemAndChildrenByUnitCriteria(int? itemID, int? parentID, int? unitID)
|
||||
{
|
||||
_ItemID = itemID;
|
||||
_ParentID = parentID;
|
||||
_UnitID = unitID;
|
||||
}
|
||||
private int? _ItemID;
|
||||
public int? ItemID
|
||||
{
|
||||
get { return _ItemID; }
|
||||
set { _ItemID = value; }
|
||||
}
|
||||
private int? _ParentID;
|
||||
public int? ParentID
|
||||
{
|
||||
get { return _ParentID; }
|
||||
set { _ParentID = value; }
|
||||
}
|
||||
private int? _UnitID;
|
||||
public int? UnitID
|
||||
{
|
||||
get { return _UnitID; }
|
||||
set { _UnitID = value; }
|
||||
}
|
||||
}
|
||||
// Data Portal to Get Item and Children by unit
|
||||
private void DataPortal_Fetch(ItemAndChildrenByUnitCriteria criteria)
|
||||
{
|
||||
//ItemInfo tmp = null;
|
||||
Dictionary<int, ItemInfo> lookup = new Dictionary<int, ItemInfo>(); ;
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "vesp_ListItemAndChildrenByUnit";
|
||||
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
|
||||
cm.Parameters.AddWithValue("@ParentID", criteria.ParentID);
|
||||
cm.Parameters.AddWithValue("@UnitID", criteria.UnitID);
|
||||
DateTime start = DateTime.Now;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
if (dr.GetInt32("Level") == 0)
|
||||
{
|
||||
//tmp = itemInfo;
|
||||
ReadData(dr);
|
||||
AddContent(dr);
|
||||
lookup[this.ItemID] = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemInfo itemInfo = null;
|
||||
int itemType = dr.GetInt32("Type") / 10000;
|
||||
switch (itemType)
|
||||
{
|
||||
case 0:
|
||||
itemInfo = new ProcedureInfo(dr);
|
||||
break;
|
||||
case 1:
|
||||
itemInfo = new SectionInfo(dr);
|
||||
break;
|
||||
case 2:
|
||||
itemInfo = new StepInfo(dr);
|
||||
break;
|
||||
}
|
||||
// Load Children
|
||||
itemInfo._Ordinal = dr.GetInt32("Ordinal") + 1;
|
||||
itemInfo.AddContent(dr);
|
||||
ItemInfo parent = lookup[dr.GetInt32("ParentID")];
|
||||
itemInfo._ActiveParent = parent;
|
||||
itemInfo._MyParent = parent;
|
||||
itemInfo._ActiveSection = (itemInfo.IsSection ? itemInfo : parent._ActiveSection);
|
||||
parent.AddPart(dr, itemInfo);
|
||||
lookup.Add(itemInfo.ItemID, itemInfo);
|
||||
}
|
||||
}
|
||||
//Console.WriteLine("I'm here {0}",this.MyContent.ContentPartCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ItemInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
MyLookup = lookup;
|
||||
}
|
||||
//jcb end add 20120501 item and children by unit
|
||||
|
||||
#region ProcedureConfig
|
||||
[NonSerialized]
|
||||
private ProcedureConfig _ProcedureConfig;
|
||||
public ProcedureConfig ProcedureConfig
|
||||
{ get { return (_ProcedureConfig != null ? _ProcedureConfig : _ProcedureConfig = new ProcedureConfig(this)); } }
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ProcedureConfig == null)
|
||||
{
|
||||
_ProcedureConfig = new ProcedureConfig(this);
|
||||
this.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
|
||||
}
|
||||
return _ProcedureConfig;
|
||||
// return (_ProcedureConfig != null ? _ProcedureConfig : _ProcedureConfig = new ProcedureConfig(this));
|
||||
}
|
||||
}
|
||||
|
||||
void MyContent_Changed(object sender)
|
||||
{
|
||||
this.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
|
||||
}
|
||||
#endregion
|
||||
public new ConfigDynamicTypeDescriptor MyConfig
|
||||
{
|
||||
@ -3778,7 +4073,7 @@ namespace VEPROMS.CSLA.Library
|
||||
set { _ItemID = value; }
|
||||
}
|
||||
}
|
||||
// Data Portal to Get Item and Children
|
||||
// Data Portal to Get Item and Children
|
||||
private void DataPortal_Fetch(ItemAndChildrenCriteria criteria)
|
||||
{
|
||||
//ItemInfo tmp = null;
|
||||
|
@ -394,7 +394,6 @@ namespace VEPROMS.CSLA.Library
|
||||
else
|
||||
tmp = DataPortal.Fetch<StepInfo>(new PastingPartCriteria(copyStartID, itemID, addType, type, fromType, DateTime.Now, Volian.Base.Library.VlnSettings.UserID));
|
||||
}
|
||||
AddToCache(tmp);
|
||||
return tmp;
|
||||
|
||||
}
|
||||
@ -456,7 +455,6 @@ namespace VEPROMS.CSLA.Library
|
||||
else
|
||||
tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
|
||||
}
|
||||
AddToCache(tmp);
|
||||
return tmp;
|
||||
}
|
||||
public void UpdateTransitionText()
|
||||
|
Loading…
x
Reference in New Issue
Block a user