This commit is contained in:
Jsj
2007-11-20 20:12:45 +00:00
parent d0793524be
commit 6e00716c47
149 changed files with 71953 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public partial class AnnotationInfo
{
public override string ToString()
{
return _SearchText;
}
}
public partial class AnnotationType
{
public override string ToString()
{
return _Name;
}
}
public partial class AnnotationTypeInfo
{
public override string ToString()
{
return _Name;
}
}
}

View File

@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public static class ColorTab
{
private static Dictionary<string, int> ColorIndx = null;
// This dictionary takes a color name and converts it to the rtf string:
private static Dictionary<string, string> ColorRtf = null;
public enum E_Colors : int
{
black = 1, blue, green, cyan, red, magenta, brown, lightgray, darkgray, lightblue, lightgreen,
lightcyan, lightred, lightmagenta, yellow, white, ro, editbackground
}
#region ColorIndex
// Do I need this anymore.... I was using it when entire color table was in the rtf box.
public static int GetIndex(string color)
{
// if the dictionary hasn't been set yet,
if (ColorIndx==null)
{
ColorIndx = new Dictionary<string, int>();
ColorIndx["black"] = 1;
ColorIndx["blue"] = 2;
ColorIndx["green"] = 3;
ColorIndx["cyan"] = 4;
ColorIndx["red"] = 5;
ColorIndx["magenta"] = 6;
ColorIndx["brown"] = 7;
ColorIndx["lightgray"] = 8;
ColorIndx["darkgray"] = 9;
ColorIndx["lightblue"] = 10;
ColorIndx["lightgreen"] = 11;
ColorIndx["lightcyan"] = 12;
ColorIndx["lightred"] = 13;
ColorIndx["lightmagenta"] = 14;
ColorIndx["yellow"] = 15;
ColorIndx["white"] = 16;
ColorIndx["ro"] = 17;
ColorIndx["trans"] = 18;
ColorIndx["editbackground"] = 19;
}
return ColorIndx[color];
}
#endregion
#region ColorRtf
// This gets the rtf color table string for the input color.
public static string GetTableString(string color)
{
Dictionary<string, int> ColorIndx = new Dictionary<string, int>();
if (ColorRtf == null)
{
ColorRtf = new Dictionary<string, string>();
// color table, from 16-bit code, is defined as (in order):
// black=0,0,0
// blue=0,0,255
// green=0,155,12
// cyan=0,136,159
// red=255,0,0
// magenta=202,28,175
// brown=128,64,0
// lightgray=0,0,0
// darkgray=0,0,0
// lightblue=0,0,255
// lightgreen=0,255,0
// lightcyan=0,0,255
// lightred=209,29,183
// lightmagenta=255,0,255
// yellow=255,0,0
// white=128,128,128
// ro=255,128,0
// editbackground=192,192,192
ColorRtf["black"] = "\\red0\\green0\\blue0;";
ColorRtf["blue"] = "\\red0\\green0\\blue255;";
ColorRtf["green"] = "\\red0\\green155\\blue12;";
ColorRtf["cyan"] = "\\red0\\green136\\blue159;";
ColorRtf["red"] = "\\red255\\green0\\blue0;";
ColorRtf["magenta"] = "\\red202\\green28\\blue175;";
ColorRtf["brown"] = "\\red128\\green64\\blue0;";
ColorRtf["lightgray"] = "\\red100\\green100\\blue100;";
ColorRtf["darkgray"] = "\\red10\\green10\\blue10;";
ColorRtf["lightblue"] = "\\red0\\green0\\blue255;";
ColorRtf["lightgreen"] = "\\red0\\green255\\blue0;";
ColorRtf["lightcyan"] = "\\red0\\green0\\blue255;";
ColorRtf["lightred"] = "\\red209\\green29\\blue183;";
ColorRtf["lightmagenta"] = "\\red255\\green0\\blue255;";
ColorRtf["yellow"] = "\\red255\\green0\\blue0;";
ColorRtf["white"] = "\\red128\\green128\\blue128;";
ColorRtf["ro"] = "\\red255\\green128\\blue0;";
ColorRtf["trans"] = "\\red255\\green128\\blue0;";
ColorRtf["editbackground"] = "\\red192\\green192\\blue192;";
}
return ColorRtf[color];
}
#endregion
}
}

View File

@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
namespace VEPROMS.CSLA.Library
{
public partial class Content
{
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
}
public partial class ContentInfo
{
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
//public XmlNode ToXml(XmlNode xn)
//{
// XmlNode nd = xn.OwnerDocument.CreateElement("Content");
// xn.AppendChild(nd);
// AddAttribute(nd, "Number", _Number);
// AddAttribute(nd, "Text", _Text);
// AddAttribute(nd, "FormatID", _FormatID);
// AddAttribute(nd, "Config", _Config);
// return nd;
//}
//public void AddAttribute(XmlNode xn, string name, object o)
//{
// if (o != null && o.ToString() != "")
// {
// XmlAttribute xa = xn.OwnerDocument.CreateAttribute(name);
// xa.Value = o.ToString();
// xn.Attributes.Append(xa);
// }
//}
}
public partial class ContentInfoList
{
public static ContentInfoList GetList(int? itemID)
{
try
{
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ContentListCriteria(itemID));
ContentInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemInfoList.GetChildren", ex);
}
}
[Serializable()]
private class ContentListCriteria
{
public ContentListCriteria(int? itemID)
{
_ItemID = itemID;
}
private int? _ItemID;
public int? ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
private void DataPortal_Fetch(ContentListCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_ListContentsByItemID";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
}
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ContentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
}

View File

@@ -0,0 +1,735 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Drawing;
namespace VEPROMS.CSLA.Library
{
public class DisplayText
{
#region Properties
private ItemInfo _itemInfo;
// list of 'pieces of text' for this item. Pieces include symbols, ros,
// transitions & plain text.
private List<displayTextElement> _DisplayTextElementList;
public List<displayTextElement> DisplayTextElementList
{
get { return _DisplayTextElementList; }
set { _DisplayTextElementList = value; }
}
// dictionary for the font table for this item. Note that this may
// go away (it is not really used).
private Dictionary<int, string> _dicRtfFontTable;
public Dictionary<int, string> dicRtfFontTable
{
get { return _dicRtfFontTable; }
set { _dicRtfFontTable = value; }
}
private VE_Font _textFont; // Font from format for this item
public VE_Font TextFont
{
get { return _textFont; }
set { _textFont = value; }
}
public string OriginalText; // compare for save to see if change.
#endregion
#region Constructors
/// <summary>
/// DisplayText constructor:
/// Creates a DisplayText object that converts the database text into a list of
/// displayTextElement elements.
/// Arguments are:
/// ItemInfo itemInfo - the item whose text will be resolved
/// E_EditPrintMode ep_mode - edit or print.
/// E_ViewMode vw_mode - view or edit.
/// </summary>
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode)
{
_itemInfo = itemInfo;
DisplayTextElementList = new List<displayTextElement>();
OriginalText = itemInfo.MyContent.Text;
TextFont = GetItemFont();
string text = InsertRtfStyles();
// if in print mode or view mode, do replace words. Only if in edit mode are replace
// words left as is.
FormatInfo format = itemInfo.ActiveFormat;
if (epMode == E_EditPrintMode.PRINT || vwMode == E_ViewMode.VIEW) text = DoReplaceWords(text, format);
// displayTextElement List items are created for anything that is handled differently in RTB, i.e.
// symbols, ros, trans, text.
int startIndex = 0;
int index = -1;
while ((index = FindTokenChar(text, startIndex))>-1)
{
// Do any 'plain' text that preceeds the token.
if (index > startIndex) DoTextElement(text, startIndex, index);
// Now do any other types
if (text[index] == '\x15')
index = DoRO(text, index);
else if (text[index] == '\x252C' || text[index]=='\x2566')
index = DoTran(text, index);
else
index = DoSymbol(text, startIndex, index);
startIndex = index; // +1;
if (startIndex >= text.Length) break;
}
// Add any remaining text.
if (startIndex < text.Length) DoTextElement(text, startIndex, index);
}
#endregion
#region SaveData
public bool Save(RichTextBox rtb)
{
try
{
List<displayLinkElement> origList = GetLinkList(DisplayTextElementList);
// massage string to store in DisplayTextElementList...
RtfToDisplayTextElements(rtb);
// take the list & convert to data in the format to save to the database.
StringBuilder sret = new StringBuilder();
foreach (displayTextElement vte in DisplayTextElementList)
{
if (vte.Type == E_TextElementType.TEXT || vte.Type == E_TextElementType.SYMBOL)
sret.Append(vte.Text);
else if (vte.Type == E_TextElementType.RO)
sret.Append(ToData_RO((displayLinkElement)vte));
else if (vte.Type == E_TextElementType.TRANS_Single)
sret.Append(ToData_Trans((displayLinkElement)vte));
}
string modtext = sret.ToString();
if (modtext != OriginalText)
{
Item itm = _itemInfo.Get();
// check for different text, i.e. text from this itm doesn't match
// original text.
if (OriginalText != itm.MyContent.Text)
{
Console.WriteLine("Save Failed because text changed outside of this edit session.");
return false;
}
// Compare ro/transition lists and delete or add any to the item for any ros/transitions that have been
// added/deleted or modified.
ProcessRoTranChanges(itm, origList);
itm.MyContent.Text = modtext;
itm.Save();
}
else
return true; // no text changed, but did not fail so return true.
}
catch (Exception ex)
{
Console.WriteLine("Save Failed with error: {0}", ex.Message);
return false;
}
return true;
}
private void ProcessRoTranChanges(Item itm, List<displayLinkElement> origList)
{
// go through list. Note that only linked items are in the origList.
// 1) delete any that are in origList but not in the DisplayTextElementList
// (that represents the current text & links)
// 2) add any that are only in DisplayTextElementList
// 3) delete/add for modify?
// delete first - if in original, but not in current list, delete the one
// in the original list.
foreach (displayLinkElement odte in origList)
{
bool found = false;
foreach (displayTextElement dte in DisplayTextElementList)
{
if (dte.Type == odte.Type)
{
displayLinkElement l_dte = (displayLinkElement)dte;
if (odte.Link == l_dte.Link)
{
found = true;
break;
}
}
}
// remove the link element from the item.
if (!found)
{
// Get record id for ro or trans and then find the associated ro or transition
// in the item's list. remove it.
int recid = -1;
if (odte.Type != E_TextElementType.RO)
{
int sp = odte.Link.IndexOf(" ") + 1; // get past tran type
string srecid = odte.Link.Substring(sp, odte.Link.IndexOf(" ", sp) - sp);
recid = System.Convert.ToInt32(srecid);
foreach (ContentTransition ct in itm.MyContent.ContentTransitions)
{
if (ct.TransitionID == recid)
{
itm.MyContent.ContentTransitions.Remove(ct);
break;
}
}
}
else
{
int sp = odte.Link.IndexOf(" ");
//rousageid starts after "#Link:ReferencedObject:", i.e. index in link of 23
string srecid = odte.Link.Substring(23, sp-23);
recid = System.Convert.ToInt32(srecid);
foreach (ContentRoUsage cr in itm.MyContent.ContentRoUsages)
{
if (cr.ROUsageID == recid)
{
itm.MyContent.ContentRoUsages.Remove(cr);
break;
}
}
}
}
}
// now do insert, i.e. in new list, but not in old.
foreach (displayTextElement dte in DisplayTextElementList)
{
bool found = false;
if (dte.Type == E_TextElementType.RO || dte.Type == E_TextElementType.TRANS_Single || dte.Type == E_TextElementType.TRANS_Range)
{
foreach (displayLinkElement odte in origList)
{
if (dte.Type == odte.Type)
{
// if the link is the same, it exists, so no action is required.
displayLinkElement l_dte = (displayLinkElement)dte;
if (odte.Link == l_dte.Link)
{
found = true;
break;
}
}
}
// Insert the link (ro or transition) to the item
if (!found)
{
Console.WriteLine("New ro or trans");
}
}
}
}
private List<displayLinkElement> GetLinkList(List<displayTextElement> locDisplayTextElementList)
{
List<displayLinkElement> retList = new List<displayLinkElement>();
foreach (displayTextElement vte in locDisplayTextElementList)
{
if (vte.Type == E_TextElementType.RO || vte.Type == E_TextElementType.TRANS_Range || vte.Type == E_TextElementType.TRANS_Single)
{
displayLinkElement tmp = (displayLinkElement)vte;
displayLinkElement copy_vte = new displayLinkElement();
copy_vte.Type = tmp.Type;
copy_vte.Link = tmp.Link;
copy_vte.Text = tmp.Text;
retList.Add(copy_vte);
}
}
return retList;
}
private void RtfToDisplayTextElements(RichTextBox rtb)
{
// GetFontTable returns a non-negative number font number in the
// font table for the unicode font, if it is used (otherwise -1)
//int unicodeFont = GetFontTable(rtb.Rtf);
// strip off all rtf commands...
string noExtraRtfStr = StripRtfCommands(rtb.Rtf);
//Console.WriteLine("StripRtf: {0}", noExtraRtfStr);
DisplayTextElementList.Clear();
int startIndex = 0;
int index = -1;
while ((index = FindRtfChar(noExtraRtfStr, startIndex)) > -1)
{
int fndindx = -1;
// Do any 'plain' text that preceeds the token.
if (index > startIndex)
index = SaveTextElement(noExtraRtfStr, startIndex, index);
if ((fndindx = noExtraRtfStr.IndexOf("\\protect")) == index)
index = SaveLink(noExtraRtfStr, index);
else
index = SaveSymbolTE(noExtraRtfStr, index);
startIndex = index + 1;
if (startIndex >= noExtraRtfStr.Length) break;
}
// Add any remaining text.
if (startIndex < noExtraRtfStr.Length) DoTextElement(noExtraRtfStr, startIndex, index);
//Console.WriteLine(noExtraRtfStr);
}
private int SaveTextElement(string data, int startIndex, int index)
{
displayTextElement vte = new displayTextElement();
vte.Type = E_TextElementType.TEXT;
int len = (index == -1) ? data.Length - startIndex : index - startIndex;
vte.Text = data.Substring(startIndex, len);
DisplayTextElementList.Add(vte);
return index;
}
private int SaveSymbolTE(string data, int startIndex)
{
displayLinkElement vte = new displayLinkElement();
vte.Type = E_TextElementType.SYMBOL;
// symbols are just the unicode/rtf command, no font associated with it
// by the time it gets here... A symbol can be represented by \'xy or \uxyz?
// if the \'xy is used the length of the symbol number will always be two,
// otherwise find the index of the '?' to find the end.
int endindx = -1;
if (data[startIndex + 1] == '\'') endindx = startIndex + 3;
else endindx = data.IndexOf("?", startIndex);
if (endindx == -1) return startIndex; // not found - error
vte.Text = data.Substring(startIndex, endindx - startIndex + 1);
DisplayTextElementList.Add(vte);
return endindx + 1;
}
private int SaveLink(string data, int startIndex)
{
displayLinkElement vte = new displayLinkElement();
// first find if RO or trans, the RO has a #R.
int istart = data.IndexOf("#Link:", startIndex);
if (data[istart + 6] == 'R') return SaveROTE(data, startIndex);
else if (data.Substring(istart+6,11) == "TransitionR")
return SaveTranTE(data, startIndex, E_TextElementType.TRANS_Range);
return SaveTranTE(data, startIndex, E_TextElementType.TRANS_Single);
}
private int SaveTranTE(string data, int startIndex, E_TextElementType type)
{
displayLinkElement vte = new displayLinkElement();
vte.Type = type;
// \protect {transition text} \v #Link:Transition(Range): 1 2 3\protect0\v0 where 1 2 3 are transition type and ids
int indx = data.IndexOf("\\v #Link:Transition", startIndex);
vte.Text = data.Substring(startIndex + 9, indx - startIndex - 9); // get past \protect
int iend = data.IndexOf("\\protect0\\v0", indx);
if (iend == -1) iend = data.IndexOf("\\v0\\protect0", indx);
// get past \v #Link:Transition or \v #Link:TransitionRange
int bindx = indx + 3;
//if (type == E_TextElementType.TRANS_Range) bindx += 5;
vte.Link = data.Substring(bindx, iend - bindx);
DisplayTextElementList.Add(vte);
return iend + 11; // get past the \protect0\vo
}
private int SaveROTE(string data, int startIndex)
{
displayLinkElement vte = new displayLinkElement();
vte.Type = E_TextElementType.RO;
// \protect {rovalue} \v #Link:ReferencedObject (RoUsageId) {ROID}\protect0\v0
int indx = data.IndexOf("\\v #Link:ReferencedObject", startIndex);
vte.Text = data.Substring(startIndex + 9, indx - startIndex - 9); // get past \protect
int iend = data.IndexOf("\\protect0\\v0", indx);
if (iend == -1) iend = data.IndexOf("\\v0\\protect0", indx);
vte.Link = data.Substring(indx + 3, iend - indx - 3); // get past \v #Link:ReferencedObject
DisplayTextElementList.Add(vte);
return iend + 11; // get past the \protect0\vo
}
private int FindRtfChar(string text, int startIndex)
{
int prindx = text.IndexOf("\\protect", startIndex);
int symindx1 = text.IndexOf("\\'", startIndex);
int symindx2 = text.IndexOf("\\u", startIndex);
if (symindx2 > -1)
{
if (text[symindx2+2] == 'l') symindx2 = -1; // don't process underlines
}
if (prindx == -1 && symindx1 == -1 && symindx2 == -1) return -1;
if (prindx == -1) prindx = text.Length + 1;
if (symindx1 == -1) symindx1 = text.Length + 1;
if (symindx2 == -1) symindx2 = text.Length + 1;
// Which token has smallest number, to determine which item is next
// in the string. If it is a symbol - see if it has a font specifier
// first.
int symindx = symindx1 < symindx2 ? symindx1 : symindx2;
int smallest = (prindx < symindx ? prindx : symindx);
return smallest;
}
private int GetFontTable(string rtf)
{
dicRtfFontTable = new Dictionary<int, string>();
// return unicode (symbol) font number, if it exists, to expedite finding
// the font for symbols.
int unicodeFont = -1;
int bindx = rtf.IndexOf(@"{\fonttbl");
if (bindx < -1) return -1;
int eindx = rtf.IndexOf("}}", bindx);
// get font table string and then do regular expressions to get font number
// with font name.
string tbl = rtf.Substring(bindx + 9, eindx - bindx - 8);
tbl = tbl.Replace("{", "<");
tbl = tbl.Replace("}", ">");
string pat = @"(?:<\\f)([0-9]+)(?:[\S]+ )([\w ]+)";
StringBuilder sb = new StringBuilder();
foreach (Match m in Regex.Matches(tbl, pat))
{
int num = Convert.ToInt32(m.Result("${1}"));
string nam = m.Result("${2}");
dicRtfFontTable.Add(num, nam);
if ((unicodeFont == -1) && (nam == "Arial Unicode MS")) unicodeFont = num;
}
return unicodeFont;
}
private string RemoveRtfStyles(string rtf)
{
string retval = rtf;
// remove rtf commands for any styles that were added. Note that if
// the entire item has a style, and also contains 'pieces' of text with
// the same style, the underlying rtf box removes the embedded rtf commands,
// for example, if the entire step is bolded, and 'THEN' has bold on/off
// surrounding it, the rtf box removes the bold around the 'THEN'
// These remove the command with a following space or the command alone,
// either case may exist, because if there are rtf commands following the
// style command, there will be no space character following the style command.
if ((TextFont.Style & E_Style.BOLD) > 0)
{
retval = Regex.Replace(retval, @"\\b0 ?", "");
retval = Regex.Replace(retval, @"\\b ?","");
}
if ((TextFont.Style & E_Style.UNDERLINE) > 0)
{
retval = Regex.Replace(retval, @"\\ul0 ?", "");
retval = Regex.Replace(retval, @"\\ul ?", "");
}
if ((TextFont.Style & E_Style.ITALICS) > 0)
{
retval = Regex.Replace(retval, @"\\i0 ?", "");
retval = Regex.Replace(retval, @"\\i ?", "");
}
return retval;
}
public string ReplaceRTFClause(Match m)
{
switch (m.Value[1])
{
case 'u':
if (Regex.IsMatch(m.Value, @"\\u[0-9]+"))
return m.Value; // Special Charcaters
if (Regex.IsMatch(m.Value, @"\\ulnone"))
return m.Value;
if (Regex.IsMatch(m.Value, @"\\ul.*"))
return m.Value; // Underline
break;
case '\'': // Special Character
return m.Value;
case 'b': // Bold
return m.Value;
case 's': // sub or super....
if (m.Value == @"\sub") return m.Value;
if (m.Value == @"\super") return m.Value;
break;
case 'n': // nosubsuper...
if (m.Value == @"\nosupersub") return m.Value;
break;
case 'i': // Italics
return m.Value;
case 'v': // save link hidden info
if (m.Value == @"\v") return m.Value; // part of link
if (Regex.IsMatch(m.Value, @"\\v0"))
return m.Value; // hidden info off
break;
case 'p':
if (m.Value == @"\par") return "\r\n";
if (m.Value == @"\protect")
return m.Value;
if (m.Value == @"\protect0")
return m.Value;
break;
}
return "";//Strip All
}
private string StripRtfCommands(string rtf)
{
string retval = Regex.Replace(rtf, @"[\r\n]", "", RegexOptions.Singleline); // Strip Carriage Returns and Newlines
retval = Regex.Replace(retval, @"^\{(.*)\}$", "$1", RegexOptions.Singleline); // Strip Opening and Closing Braces
retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
retval = Regex.Replace(retval, @"\\[^ \\?]+", new MatchEvaluator(ReplaceRTFClause)); // take backslash xyz and evaluates them
// remove a space if there is one as the first character..
if (retval[0]==' ')retval = retval.Remove(0, 1);
// remove \r\n at end of string - this was added with the \par at the end of string by the rtf box
if (retval.Substring(retval.Length - 2, 2) == "\r\n") retval = retval.Remove(retval.Length - 2, 2);
retval = RemoveRtfStyles(retval);
return retval;
}
private string ToData_RO(displayLinkElement vte)
{
// get past the #Link:ReferencedObject part of the link.
return String.Format("\x15\\v RO\\v0 {0}\\v #{1}\\v0", vte.Text, vte.Link.Substring(23, vte.Link.Length-23));
}
private string ToData_Trans(displayLinkElement vte)
{
char trchar = vte.Type == E_TextElementType.TRANS_Single ? '\x252C' : '\x2566';
int indx = vte.Type == E_TextElementType.TRANS_Single ? 16 : 21;
return String.Format("{0}\\v TRAN\\v0 {1}\\v {2}\\v0", trchar, vte.Text, vte.Link.Substring(indx, vte.Link.Length-indx));
}
#endregion
#region StyleData
private VE_Font GetItemFont()
{
VE_Font font = null;
FormatInfo format = _itemInfo.ActiveFormat;
int type = (int)_itemInfo.MyContent.Type;
switch (type/10000)
{
case 0: // procedure
font = format.PlantFormat.FormatData.Font;
break;
case 1: // section
font = format.PlantFormat.FormatData.SectData.SectionHeader.Font;
break;
case 2: // step types
int typindx = type - 20000; // what to do for other types rather than steps
font = format.PlantFormat.FormatData.StepDataList[typindx].Font;
break;
}
TextFont = font;
return font;
}
private string InsertRtfStyles()
{
StringBuilder sb = new StringBuilder(_itemInfo.MyContent.Text);
if ((TextFont.Style & E_Style.BOLD)>0)
{
sb.Insert(0, "\\b ");
sb.Append("\\b0 ");
}
if ((TextFont.Style & E_Style.UNDERLINE) > 0)
{
sb.Insert(0, "\\ul ");
sb.Append("\\ul0 ");
}
if ((TextFont.Style & E_Style.ITALICS) > 0)
{
sb.Insert(0, "\\i ");
sb.Append("\\i0 ");
}
return sb.ToString();
}
#endregion
#region DoListElements
private int FindTokenChar(string txt, int startIndex)
{
// tokens are ro, transitions and possible symbol
char[] tok = { '\x15', '\x252C', '\x2566', '\\' };
bool done = false;
// If there is only an rtf token from the indexed position on, don't return the
// IndexOfAny index value, because it will by one character past the '\' and throw
// of the return value of where in the string the text should be saved. For example
// for the string '\b text \v somevalue \v0\b0', the first time through the while
// loop has the index at the '\b' char of the b0.
//int savstartIndex = startIndex;
while (!done)
{
int indx = txt.IndexOfAny(tok, startIndex);
if (indx < 0) return indx;
if (txt[indx] != '\\') return indx;
// see if symbol (but not underline) or another rtf command: has a 'u'
// followed by a non-underline or single quote, and if so, return it.
// Otherwise, get next index, must have been a slash or other rtf command.
if (((txt[indx + 1] == 'u' && txt[indx + 2] != 'l')) || (txt[indx + 1] == '\'')) return indx;
startIndex=indx+1;
}
return -1;
}
private int DoTextElement(string text, int startIndex, int index)
{
displayTextElement vte = new displayTextElement();
vte.Type = E_TextElementType.TEXT;
int len = (index == -1) ? text.Length - startIndex : index - startIndex;
vte.Text = text.Substring(startIndex, len);
DisplayTextElementList.Add(vte);
return index+1;
}
private string CreateLink(E_TextElementType type, string linktxt)
{
string retlink = "";
if (type == E_TextElementType.RO)
retlink = "#Link:ReferencedObject:" + linktxt;
else if (type == E_TextElementType.TRANS_Single)
retlink = "#Link:Transition:" + linktxt;
else
retlink = "#Link:TransitionRange:" + linktxt;
return retlink;
}
private int DoRO(string text, int index)
{
displayLinkElement vte = new displayLinkElement();
vte.Type = E_TextElementType.RO;
// ro has form \v RO\v0 9.5 psig\v #1 0001000000ec0000 \v0 - so find second
// \v0 to end the string.
int istart = text.IndexOf("\\v0",index) + 4;
int iend = text.IndexOf("\\v", istart);
vte.Text = text.Substring(istart, iend - istart);
istart = text.IndexOf("#", iend) + 1;
iend = text.IndexOf("\\v0", istart);
vte.Link = CreateLink(vte.Type, text.Substring(istart, iend - istart));
DisplayTextElementList.Add(vte);
// return the position past the end of the \v0. There is a space after the
// \v0 so account for that.
return iend + 4;
}
private string FixTransition(string link, string text)
{
int transitionID = Convert.ToInt32(link.Split(" ".ToCharArray())[1]);
// Find the transition
foreach (TransitionInfo ti in _itemInfo.MyContent.ContentTransitions)
{
if (ti.TransitionID == transitionID)
{
string path = ti.PathTo.Replace(" Section PROCEDURE STEPS ", ", ");
path = path.Replace(" Section PROCEDURE STEPS", "");
return path;
}
}
return text;
}
private int DoTran(string text,int index)
{
displayLinkElement vte = new displayLinkElement();
// transition (not range) has form \v TRAN\v0 (resolved transition text)\v type fromid toid [rangeid, if range]\v0
int istart = text.IndexOf("\\v0", index) + 4;
int iend = text.IndexOf("\\v", istart);
vte.Text = text.Substring(istart, iend - istart); // this stores the resolved transition text
istart = iend + 3; // get to transition type.
iend = text.IndexOf("\\v0", istart);
vte.Text = FixTransition(text.Substring(istart, iend - istart), vte.Text);
// Determine whether it is single or range transition. Can tell by number of spaces in
// link string.
string[] parts = text.Substring(istart, iend - istart).Split(" ".ToCharArray());
if (parts.Length == 3) vte.Type = E_TextElementType.TRANS_Single;
else vte.Type = E_TextElementType.TRANS_Range;
vte.Link = CreateLink(vte.Type, text.Substring(istart, iend - istart));
DisplayTextElementList.Add(vte);
// return the position past the end of the \v0. There is a space after the
// \v0 so account for that.
return iend + 4;
}
private int DoSymbol(string text, int startIndex, int index)
{
displayTextElement vte = new displayTextElement();
vte.Type = E_TextElementType.SYMBOL;
// symbols are the unicode/rtf command. A symbol can be represented by \'xy or
// in the text from the database \uxyz?. If the \'xy is used the length of the
// symbol number will always be two, otherwise find the index of the '?' to
// find the end.
int endindx = -1;
if (text[index + 1] == '\'') endindx = index + 3;
else endindx = text.IndexOf("?", index);
vte.Text = text.Substring(index, endindx - index + 1);
DisplayTextElementList.Add(vte);
// return the position just past the symbol.
return endindx+1;
}
#endregion
#region ReplaceWords
private ReplaceStr _rs;
private string ReplaceIt(Match m)
{
string s = m.ToString();
string t = s.Replace(_rs.ReplaceWord, _rs.ReplaceWith);
return m.ToString().Replace(_rs.ReplaceWord, _rs.ReplaceWith);
}
private string DoReplaceWords(string Text, FormatInfo format)
{
ReplaceStrList rsl = format.PlantFormat.FormatData.SectData.ReplaceStrList;
foreach (ReplaceStr rs in rsl)
{
if (_itemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps.
bool replaceit = false;
// note that the order of this check is important. Check in this order...
// background here
if (_itemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.HIGH)>0) replaceit = true;
else if ((_itemInfo.IsTable || _itemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.TABLE) > 0) replaceit = true;
else if (_itemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true;
else if (_itemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.CAUTION) > 0) replaceit = true;
else if (_itemInfo.IsNote && (rs.Flag & E_ReplaceFlags.NOTE) > 0) replaceit = true;
else if (_itemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.SUBSTEP) > 0) replaceit = true;
else if (_itemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.ATTACH) > 0) replaceit = true;
if (replaceit)
{
// CASEINSENS: Do ReplaceWords for all words that match, regardless of case, and replace
// with the ReplaceWith string as is
if ((rs.Flag & E_ReplaceFlags.CASEINSENS) > 0)
{
string res = "";
string fortest = Text.ToUpper();
string pat = @"(?<=\W|^)" + rs.ReplaceWord.ToUpper() + @"(?=\W|$)";
int cpindx = 0;
foreach (Match m in Regex.Matches(fortest, pat))
{
res += Text.Substring(cpindx, m.Index-cpindx);
cpindx += (m.Index - cpindx);
res += rs.ReplaceWith;
cpindx += rs.ReplaceWord.Length;
}
if (cpindx < Text.Length) res += Text.Substring(cpindx, Text.Length - cpindx);
Text = res;
}
// CASEINSENSALL: Do ReplaceWords for all words that match the ReplaceWord, regardless of case
else if ((rs.Flag & E_ReplaceFlags.CASEINSENSALL) > 0)
{
// not in hlp
}
// CASEINSENSFIRST: Do ReplaceWords for all words that exactly match the ReplaceWord,
// except the case where the first character may be different
else if ((rs.Flag & E_ReplaceFlags.CASEINSENSFIRST) > 0)
{
// not in hlp
}
else
{
string pat = @"(?<=\W|^)" + rs.ReplaceWord + @"(?=\W|$)";
Text = Regex.Replace(Text, pat, rs.ReplaceWith);
}
}
}
return Text;
}
#endregion
}
#region displayTextElementClass
public enum E_TextElementType : uint
{
TEXT = 0,
SYMBOL = 1,
RO = 2,
TRANS_Single = 3,
TRANS_Range = 4
};
public class displayTextElement
{
private E_TextElementType _Type;
public E_TextElementType Type
{
get { return _Type; }
set { _Type = value; }
}
private string _Text;
public string Text
{
get { return _Text; }
set { _Text = value; }
}
}
public class displayLinkElement : displayTextElement
{
private string _Link;
public string Link
{
get { return _Link; }
set { _Link = value; }
}
}
#endregion
}

View File

@@ -0,0 +1,155 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public partial class DocVersion: IVEDrillDown
{
#region VersionType
public VersionTypeEnum eVersionType
{
get { return (VersionTypeEnum)_VersionType; }
set { _VersionType = (int)value; }
}
#endregion
#region DocVersion Config
[NonSerialized]
private DocVersionConfig _DocVersionConfig;
public DocVersionConfig DocVersionConfig
{
get
{
if (_DocVersionConfig == null)
{
_DocVersionConfig = new DocVersionConfig(this);
_DocVersionConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_DocVersionConfig_PropertyChanged);
}
return _DocVersionConfig;
}
}
private void _DocVersionConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Config = _DocVersionConfig.ToString();
}
#endregion
public override string ToString()
{
return string.Format("{0} - {1}", Name, Title);
}
#region IVEDrillDown
public System.Collections.IList GetChildren()
{
return null;
}
public bool HasChildren
{
get { return _ItemID > 0; }
}
public IVEDrillDown ActiveParent
{
get
{
return MyFolder;
}
}
public Format ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
}
public Format LocalFormat
{
get { return MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return DocVersionConfig; }
}
#endregion
}
public partial class DocVersionInfo:IVEDrillDownReadOnly
{
#region DocVersion Config
[NonSerialized]
private DocVersionConfig _DocVersionConfig;
public DocVersionConfig DocVersionConfig
{ get { return (_DocVersionConfig != null ? _DocVersionConfig : _DocVersionConfig = new DocVersionConfig(this));} }
private void DocVersionConfigRefresh()
{
_DocVersionConfig = null;
}
#endregion
ItemInfoList _iil = null;
public ItemInfoList Procedures
{ get { return (_iil != null ? _iil: _iil = ItemInfoList.GetList(_ItemID,(int)E_FromType.Procedure)); } }
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
return Procedures;
}
//public bool ChildrenAreLoaded
//{
// get { return _iil == null; }
//}
public bool HasChildren
{
get { return _ItemID > 0; }
}
public IVEDrillDownReadOnly ActiveParent
{
get
{
return MyFolder;
}
}
public FormatInfo ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
}
public FormatInfo LocalFormat
{
get { return MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return Get().DocVersionConfig; }
}
//public bool HasStandardSteps()
//{ return false; }
public override string ToString()
{
return string.Format("{0} - {1}", Name, Title);
}
//public string ToString(string str,System.IFormatProvider ifp)
//{
// return ToString();
//}
#endregion
#region Extension
partial class DocVersionInfoExtension : extensionBase
{
public override void Refresh(DocVersionInfo tmp)
{
tmp.DocVersionConfigRefresh();
}
}
#endregion
}
public enum VersionTypeEnum : int
{
WorkingDraft = 0, Temporary = 1, Revision = 128, Approved = 129
}
}

View File

@@ -0,0 +1,138 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace VEPROMS.CSLA.Library
{
public partial class DocumentInfo
{
public string DocumentTitle
{
get
{
if (_LibTitle == "") return string.Format("Document {0}", _DocID);
return _LibTitle;
}
}
}
public class DSOFile : IDisposable
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Fields
private bool _IsDisposed;
private static string _TemporaryFolder = null;
private DocumentInfo _MyDocument = null;
private FileInfo _MyFile = null;
private string _Extension = "DOC";
#endregion
#region Properties
public static string TemporaryFolder
{
get
{
if (_TemporaryFolder == null)
{
_TemporaryFolder = string.Format(@"C:\Documents and Settings\{0}\Local Settings\Temp", Environment.UserName);
if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
_TemporaryFolder += @"\VE-PROMS";
if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
}
return _TemporaryFolder;
}
}
public DocumentInfo MyDocument
{
get { return _MyDocument; }
set
{
TryDelete();
_MyDocument = value;
CreateFile();
}
}
public FileInfo MyFile
{
get { return _MyFile; }
}
public string Extension
{
get { return _Extension; }
set { _Extension = value; }
}
#endregion
#region Private Methods
private void TryDelete()
{
if (_MyDocument == null) return;
if (_MyFile == null) return;
if (_MyFile.Exists)
{
try
{
_MyFile.Delete();
}
catch (IOException ex)
{
_MyLog.Error("TryDelete",ex);
}
finally
{
_MyFile = null;
_MyDocument = null;
}
}
}
private void CreateFile()
{
if (_MyDocument == null) return;
_MyFile = new FileInfo(string.Format(@"{0}\tmp_{1}." + Extension , TemporaryFolder, MyDocument.DocID));
FileStream fs = _MyFile.Create();
fs.Write(MyDocument.DocContent, 0, MyDocument.DocContent.Length);
fs.Close();
_MyFile.CreationTime = _MyDocument.DTS;
_MyFile.LastWriteTime = _MyDocument.DTS;
}
public void SaveFile()
{
// TODO: Add Try & Catch logic
if (_MyDocument == null) return;
Document doc = _MyDocument.Get();
FileStream fs = _MyFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Byte[] buf = new byte[_MyFile.Length];
fs.Read(buf,0,buf.Length);
fs.Close();
doc.DocContent = buf;
doc.UserID = Environment.UserName;
doc.DTS = _MyFile.LastWriteTime;
doc.Save();
}
#endregion
#region Constructors
public DSOFile(DocumentInfo myDocument)
{
MyDocument = myDocument;
}
#endregion
#region Destructor
~DSOFile()
{
Dispose(false);
}
public void Dispose()
{
Dispose(false);
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
{
if (!_IsDisposed)
{
_IsDisposed = true;
TryDelete();
}
}
#endregion
}
}

View File

@@ -0,0 +1,154 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public partial class Folder : IVEDrillDown
{
#region Folder Config
[NonSerialized]
private FolderConfig _FolderConfig;
public FolderConfig FolderConfig
{
get
{
if (_FolderConfig == null)
{
_FolderConfig = new FolderConfig(this);
_FolderConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_FolderConfig_PropertyChanged);
}
return _FolderConfig;
}
}
public void FolderConfigRefresh()
{
_FolderConfig = null;
}
private void _FolderConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Config = _FolderConfig.ToString();
}
#endregion
public override string ToString()
{
return _Title;
}
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
if (FolderDocVersionCount != 0) return FolderDocVersions;
if (ChildFolderCount != 0) return ChildFolders;
return null;
}
public bool HasChildren
{
get { return _FolderDocVersionCount > 0 || _ChildFolderCount > 0; }
}
public IVEDrillDown ActiveParent
{
get
{
return MyParent;
}
}
public Format ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : (ActiveParent != null ? ActiveParent.ActiveFormat : null); }
}
public Format LocalFormat
{
get { return MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return FolderConfig; }
}
#endregion
}
public partial class FolderInfo:IVEDrillDownReadOnly
{
#region Folder Config (Read-Only)
[NonSerialized]
private FolderConfig _FolderConfig;
public FolderConfig FolderConfig
{ get {
return (_FolderConfig != null ? _FolderConfig : _FolderConfig = new FolderConfig(this));
} }
private void FolderConfigRefresh()
{
_FolderConfig = null;
}
#endregion
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
if(FolderDocVersionCount != 0)return FolderDocVersions;
if (ChildFolderCount != 0) return ChildFolders;
return null;
}
//public bool ChildrenAreLoaded
//{
// get { return _FolderDocVersions != null || _ChildFolders != null; }
//}
public bool HasChildren
{
get { return _FolderDocVersionCount > 0 || _ChildFolderCount > 0; }
}
public IVEDrillDownReadOnly ActiveParent
{
get
{
return MyParent;
}
}
public FormatInfo ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : ( ActiveParent != null ? ActiveParent.ActiveFormat : null); }
}
public FormatInfo LocalFormat
{
get { return MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return Get().FolderConfig; }
}
public override string ToString()
{
return string.Format("{0} - {1}", Name, Title);
}
//public string ToString(string str, System.IFormatProvider ifp)
//{
// return ToString();
//}
#endregion
public Color BackColor
{ get { return FolderConfig.Default_BkColor; } }
#region Extension
partial class FolderInfoExtension : extensionBase
{
public override void Refresh(FolderInfo tmp)
{
tmp.FolderConfigRefresh();
}
}
#endregion
}
}

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public static class FontTab
{
private static Dictionary<string, int> FontIndx = null;
// This dictionary takes a color name and converts it to the rtf string:
private static Dictionary<string, string> FontRtf = null;
public enum E_Fonts : int
{
None = 0, PrestigeEliteTall = 64, CourierNew = 2, TimesNewRoman = 0, LetterGothic = 66, Arial = 202, VolianDraw = 70, GothicUltra = 63, LetterGothicTall = 67, VolianScript = 71, ArialUnicode = 35
}
#region FontIndex
/// <summary>
/// GetIndex - Use this to get the number of the font in the font table based on the input
/// string.
/// </summary>
/// <param name="font"></param>
/// <returns></returns>
public static int GetIndex(string font)
{
// if the dictionary hasn't been set yet,
if (FontIndx==null)
{
FontIndx = new Dictionary<string, int>();
FontIndx["Prestige Elite Tall"] = 64;
FontIndx["Courier New"] = 2;
FontIndx["Times New Roman"] = 0;
FontIndx["Letter Gothic"] = 66;
FontIndx["Arial"] = 202;
FontIndx["Volian Draw"] = 70;
FontIndx["Gothic Ultra"] = 63;
FontIndx["Letter Gothic Tall"] = 67;
FontIndx["VolianScript"] = 71;
FontIndx["Arial Unicode"] = 35;
}
return FontIndx[font];
}
#endregion
#region ColorRtf
/// <summary>
/// GetTableString - Use this to get the string to add to font table based on the input
/// string.
/// </summary>
public static string GetTableString(string font)
{
if (FontRtf == null)
{
FontRtf = new Dictionary<string, string>();
FontRtf["Prestige Elite Tall"] = "{\\f64\\fmodern\\fcharset2\\fprq1 Prestige Elite Tall;}";
FontRtf["Courier New"] = "{\\f2\\fmodern\\fcharset0\\fprq1 Courier New;}";
FontRtf["Times New Roman"] = "{\\f0\\froman\\fcharset0\\fprq2 Times New Roman;}";
FontRtf["Letter Gothic"] = "{\\f66\\fmodern\\fcharset2\\fprq1 Letter Gothic;}";
FontRtf["Arial"] = "{\\f1\\fswiss\\fcharset0\\fprq2 Arial;}";
FontRtf["Volian Draw"] = "{\\f70\\fmodern\\fcharset2\\fprq1 VolianDraw;}";
FontRtf["Gothic Ultra"] = "{\\f63\\fmodern\\fcharset2\\fprq1 Gothic Ultra;}";
FontRtf["Letter Gothic Tall"] = "{\\f67\\fmodern\\fcharset2\\fprq1 Letter Gothic Tall;}";
FontRtf["VolianScript"] = "{\\f71\\fswiss\\fcharset2\\fprq2 VolianScript;}";
FontRtf["Arial Unicode"] = "{\\f35\\fswiss\\fcharset128\\fprq2 Arial Unicode MS;}";
}
return FontRtf[font];
}
#endregion
}
}

View File

@@ -0,0 +1,51 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.Xml;
using System.Drawing;
namespace VEPROMS.CSLA.Library
{
public partial class Format
{
#region PlantFormat
//[NonSerialized]
private PlantFormat _PlantFormat;
public PlantFormat PlantFormat
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this)); } }
#endregion
public override string ToString()
{
//return Name;
return PlantFormat.FormatData.Name;
}
}
public partial class FormatInfo
{
#region PlantFormat
//[NonSerialized]
private PlantFormat _PlantFormat;
public PlantFormat PlantFormat
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this.Get())); } }
#endregion
public override string ToString()
{
//return Name;
return PlantFormat.FormatData.Name;
}
}
}

View File

@@ -0,0 +1,785 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.Drawing;
namespace VEPROMS.CSLA.Library
{
#region Item
public partial class Item:IVEDrillDown
{
public override string ToString()
{
return string.Format("{0} {1}", MyContent.Number, MyContent.Text);
}
#region IVEDrillDown
public System.Collections.IList GetChildren()
{
return this.MyContent.ContentParts;
}
public bool HasChildren
{
get { return this.MyContent.ContentPartCount > 0; }
}
private IVEDrillDown _ActiveParent=null;
public IVEDrillDown ActiveParent
{
get
{
if (_ActiveParent == null)
{
if (MyPrevious != null)
_ActiveParent = _MyPrevious.ActiveParent;
else
{
if (ItemDocVersionCount > 0)
_ActiveParent = this.ItemDocVersions[0].MyDocVersion;
else
{
if (this.ItemParts == null || this.ItemPartCount == 0)
_ActiveParent = this;
else
_ActiveParent = this.ItemParts[0].MyContent.ContentItems[0].MyItem;
}
}
}
return _ActiveParent==this ? null : _ActiveParent;
}
}
private Format _ActiveFormat=null;// Added to cache ActiveFormat
public Format ActiveFormat
{
get
{
if(_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
return _ActiveFormat;
}
}
public Format LocalFormat
{
get { return MyContent.MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return null; }
}
#endregion
}
#endregion
#region ItemInfo
public partial class ItemInfo:IVEDrillDownReadOnly
{
public bool IsType(string type)
{
int stepType = ((int)MyContent.Type) % 10000;
StepDataList sdlist = ActiveFormat.PlantFormat.FormatData.StepDataList;
StepData sd = sdlist[stepType];
// TODO: RHM20071115 while (sd.Index != 0)
// TODO: RHM20071115 {
// TODO: RHM20071115 if (sd.Type == type) return true;
// TODO: RHM20071115 sd = sdlist[sd.ParentType];
// TODO: RHM20071115 }
return false;
}
public bool IsCaution
{
get
{
return IsType("CAUTION");
}
}
public bool IsNote
{
get
{
return IsType("NOTE");
}
}
public bool IsTable
{
get
{
return IsType("TABLE");
}
}
public bool IsFigure
{
get
{
return IsType("FIGURE");
}
}
public bool IsOr
{
get
{
return IsType("OR");
}
}
public bool IsAnd
{
get
{
return IsType("AND");
}
}
public bool IsEquipmentList
{
get
{
return IsType("EQUIPMENTLIST");
}
}
public bool IsTitle
{
get
{
return IsType("TITLE");
}
}
public bool IsAccPages
{
get
{
return IsType("ACCPAGES");
}
}
public bool IsParagraph
{
get
{
return IsType("PARAGRAPH");
}
}
public bool IsDefault
{
get
{
return IsType("DEFAULT");
}
}
public bool IsContAcSequential
{
get
{
return IsType("CONTACSEQUENTIAL");
}
}
public bool IsHigh
{
get
{
// check to see if ActiveParent is a section, if so it is a high level step
if (MyContent.Type / 10000 != 2) return false;
ItemInfo parent = (ItemInfo)ActiveParent;
if ((parent.MyContent.Type / 10000) == 1)
return true;
return false;
}
}
public bool IsSequential
{
get
{
if (((MyContent.Type / 10000) == 2) && ((((int)MyContent.Type) % 10000) == 0)) return true;
return false;
}
}
public bool IsRNO
{
get
{
return ((ItemPartCount > 0) && (ItemParts[0].PartType == E_FromType.RNO));
}
}
public bool IsInRNO
{
get
{
if (IsHigh) return false;
if (IsRNO) return true;
return ((ItemInfo)ActiveParent).IsInRNO;
}
}
public ItemInfo FirstSibling
{
get
{
ItemInfo temp = this;
while (temp.MyPrevious != null) temp = temp.MyPrevious;
return temp;
}
}
public bool IsSubStep
{
get
{
ItemInfo temp = FirstSibling;
return ((temp.ItemPartCount > 0) && (temp.ItemParts[0].PartType == E_FromType.Step));
}
}
public bool IsInSubStep
{
get
{
if (IsHigh) return false;
if (IsSubStep) return true;
return ((ItemInfo)ActiveParent).IsInSubStep;
}
}
public bool IsInFirstLevelSubStep
{
get
{
ItemInfo temp = FirstSibling;
while (((ItemInfo)temp.ActiveParent).IsHigh == false) temp = ((ItemInfo)temp.ActiveParent).FirstSibling;
return temp.IsSubStep;
}
}
private E_FromType ItemType
{
get
{
if (MyContent.Type == 0) return E_FromType.Procedure;
if (MyContent.Type < 20000) return E_FromType.Section;
return E_FromType.Step;
}
}
public Item GetByType()
{
Item tmp = null;
switch (ItemType)
{
case E_FromType.Procedure:
tmp = Procedure.Get(_ItemID);
break;
//case E_FromType.Section:
// itemInfo = new Section(dr);
// break;
//default:
// itemInfo = new Step(dr);
// break;
}
return tmp;
}
private int? _Ordinal;
public int Ordinal
{
get
{
//int retval = 1;
//for (ItemInfo ii = MyParent; ii != null; ii = ii.MyParent) retval++;
//return retval;
//if (_Ordinal != null) return (int)_Ordinal; // Cache Ordinal
if (MyPrevious != null) return (int)(_Ordinal = MyPrevious.Ordinal + 1);
return (int)(_Ordinal = 1);
}
}
public string CslaType
{ get { return this.GetType().FullName; } }
public override string ToString()
{
//Item editable = Item.GetExistingByPrimaryKey(_ItemID);
//return string.Format("{0}{1} {2}", (editable == null ? "" : (editable.IsDirty ? "* " : "")),
// (MyContent.Type >= 20000 ? Ordinal.ToString() + "." : MyContent.Number), MyContent.Text);
ContentInfo cont = MyContent;
string number = cont.Number;
if (cont.Type >= 20000) number = Ordinal.ToString() + ".";
return string.Format("{0} {1}", number, cont.Text);
//return string.Format("{0} {1}", cont.Number, cont.Text);
//return "Now is the time for all good men to come to the aid of their country!";
}
//public string ToString(string str,System.IFormatProvider ifp)
//{
// return ToString();
//}
public string nz(string str, string def)
{
return (str == null ? def : str);
}
public string Path
{
get
{
string number = (MyContent.Type >= 20000 ? Ordinal.ToString() + "." : (nz(MyContent.Number,"")==""? MyContent.Text: MyContent.Number));
ItemInfo parent = this;
while (parent.MyPrevious != null) parent = parent.MyPrevious;
if (parent.ItemPartCount == 0)
return number + ", " + MyContent.Text;
else
{
PartInfo partInfo = parent.ItemParts[0];
return partInfo.MyContent.ContentItems.Items[0].Path + " " + ((E_FromType)partInfo.FromType).ToString() + " " + number;
}
}
}
public ContentInfo ParentContent
{
get
{
string number = (MyContent.Type >= 20000 ? Ordinal.ToString() + "." : (nz(MyContent.Number, "") == "" ? MyContent.Text : MyContent.Number));
ItemInfo parent = this;
while (parent.MyPrevious != null) parent = parent.MyPrevious;
if (parent.ItemPartCount == 0)
return null;
else
{
return parent.ItemParts[0].MyContent;
}
}
}
public ItemInfo MyParent
{
get
{
//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;
return parentContent.ContentItems[0];
}
}
private ItemInfoList Lookup(int fromType, ref ItemInfoList itemInfoList)
{
if (itemInfoList != null) return itemInfoList;
if (MyContent.ContentPartCount != 0)
foreach (PartInfo partInfo in MyContent.ContentParts)
if (partInfo.FromType == fromType)
{
itemInfoList = partInfo._MyItems = ItemInfoList.GetList(partInfo.ItemID,partInfo.FromType);
return itemInfoList;
}
return null;
}
private ItemInfoList _Procedures;
public ItemInfoList Procedures
{ get { return Lookup(1,ref _Procedures); } }
private ItemInfoList _Sections;
public ItemInfoList Sections
{ get { return Lookup(2,ref _Sections); } }
private ItemInfoList _Cautions;
public ItemInfoList Cautions
{ get { return Lookup(3,ref _Cautions); } }
private ItemInfoList _Notes;
public ItemInfoList Notes
{ get { return Lookup(4,ref _Notes); } }
private ItemInfoList _RNOs;
public ItemInfoList RNOs
{ get { return Lookup(5,ref _RNOs); } }
private ItemInfoList _Steps;
public ItemInfoList Steps
{ get { return Lookup(6,ref _Steps); } }
private ItemInfoList _Tables;
public ItemInfoList Tables
{ get { return Lookup(7,ref _Tables); } }
//public XmlDocument ToXml()
//{
// XmlDocument retval = new XmlDocument();
// retval.LoadXml("<root/>");
// return ToXml(retval.DocumentElement);
//}
//public void AddList(XmlNode xn,string name, ItemInfoList itemInfoList)
//{
// if (itemInfoList != null)
// {
// XmlNode nd = xn.OwnerDocument.CreateElement(name);
// xn.AppendChild(nd);
// itemInfoList.ToXml(xn);
// }
//}
//public XmlDocument ToXml(XmlNode xn)
//{
// XmlNode nd = MyContent.ToXml(xn);
// // Now add the children
// AddList(nd, "Procedures", Procedures);
// AddList(nd, "Sections", Sections);
// AddList(nd, "Cautions", Cautions);
// AddList(nd, "Notes", Notes);
// AddList(nd, "RNOs", RNOs);
// AddList(nd, "Steps", SubItems);
// AddList(nd, "Tables", Tables);
// return xn.OwnerDocument;
//}
#region IVEReadOnlyItem
PartInfoList _PartInfoList;
public System.Collections.IList GetChildren()
{
_PartInfoList = this.MyContent.ContentParts;
return _PartInfoList;
}
//public bool ChildrenAreLoaded
//{
// get { return _PartInfoList == null; }
//}
public bool HasChildren
{
get { return this.MyContent.ContentPartCount > 0; }
}
private IVEDrillDownReadOnly _ActiveParent = null;
public IVEDrillDownReadOnly ActiveParent
{
get
{
if (_ActiveParent == null)
{
if (MyPrevious != null)
_ActiveParent = _MyPrevious.ActiveParent;
else
{
if (ItemDocVersionCount > 0)
_ActiveParent = this.ItemDocVersions[0];
else
{
ContentInfo parentContent = ParentContent;
if (parentContent == null || parentContent.ContentItemCount == 0)
_ActiveParent = this;
else
_ActiveParent = parentContent.ContentItems[0];
}
}
}
return _ActiveParent==this ? null : _ActiveParent;
}
//get
//{
// if (MyPrevious != null) return _MyPrevious.ActiveParent;
// if (ItemDocVersionCount > 0) return ItemDocVersions[0];
// ContentInfo parentContent = ParentContent;
// if (parentContent == null || parentContent.ContentItemCount == 0) return null;
// return parentContent.ContentItems[0];
//}
}
private FormatInfo _ActiveFormat = null;
public FormatInfo ActiveFormat
{
get
{
if(_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
return _ActiveFormat;
}
//get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
}
public FormatInfo LocalFormat
{
get { return MyContent.MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return null; }
}
//public bool HasStandardSteps()
//{ return MyContent.ContentItemCount > 1; }
public Color ForeColor
{ get { return (HasBrokenRules != null ? Color.Red : (MyContent.ContentItemCount > 1 ? Color.Blue : Color.Black)); } }
public Color BackColor
{ get { return (ItemAnnotationCount > 0 ? Color.Yellow : Color.White); } }
#endregion
}
#endregion ItemInfo
#region ItemInfoList
public partial class ItemInfoList
{
//public void ToXml(XmlNode xn)
//{
// foreach (ItemInfo itemInfo in this)
// {
// itemInfo.ToXml(xn);
// }
//}
public static ItemInfoList GetList(int? itemID,int type)
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListCriteria(itemID,type));
ItemInfo.AddList(tmp);
tmp.AddEvents();
ContentInfoList.GetList(itemID);
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemInfoList.GetChildren", ex);
}
}
[Serializable()]
private class ItemListCriteria
{
public ItemListCriteria(int? itemID,int type)
{
_ItemID = itemID;
_Type = type;
}
private int? _ItemID;
public int? ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private int _Type;
public int Type
{
get { return _Type; }
set { _Type = value; }
}
}
private void DataPortal_Fetch(ItemListCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_ListItems";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
{
ItemInfo itemInfo = null;
switch ((E_FromType)criteria.Type)
{
case E_FromType.Procedure:
itemInfo = new ProcedureInfo(dr);
break;
case E_FromType.Section:
itemInfo = new SectionInfo(dr);
break;
default:
itemInfo = new StepInfo(dr);
break;
}
this.Add(itemInfo);
}
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ItemInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ProcedureInfo
[Serializable()]
public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly
{
public ProcedureInfo(SafeDataReader dr) : base(dr) { }
public new Procedure Get()
{
return (Procedure) (_Editable = Procedure.Get(ItemID));
}
#region ProcedureConfig
[NonSerialized]
private ProcedureConfig _ProcedureConfig;
public ProcedureConfig ProcedureConfig
{ get { return (_ProcedureConfig != null ? _ProcedureConfig : _ProcedureConfig = new ProcedureConfig(this)); } }
#endregion
public new DynamicTypeDescriptor MyConfig
{
get { return ProcedureConfig ; }
}
}
#endregion
#region Procedure
[Serializable()]
public partial class Procedure : Item
{
public new static Procedure Get(int itemID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
Procedure tmp = (Procedure)GetExistingByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Procedure>(new PKCriteria(itemID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Item.Get", ex);
}
}
public new Procedure Save()
{
return (Procedure)base.Save();
}
#region ProcedureConfig
[NonSerialized]
private ProcedureConfig _ProcedureConfig;
public ProcedureConfig ProcedureConfig
{
get
{
if (_ProcedureConfig == null)
{
_ProcedureConfig = new ProcedureConfig(this);
_ProcedureConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_ProcedureConfig_PropertyChanged);
}
return _ProcedureConfig;
}
}
private void _ProcedureConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
MyContent.Config = _ProcedureConfig.ToString();
}
#endregion
}
#endregion
#region SectionInfo
[Serializable()]
public partial class SectionInfo : ItemInfo, IVEDrillDownReadOnly
{
public SectionInfo(SafeDataReader dr) : base(dr) { }
public new Section Get()
{
return (Section)(_Editable = Section.Get(ItemID));
}
#region SectionConfig
[NonSerialized]
private SectionConfig _SectionConfig;
public SectionConfig SectionConfig
{ get { return (_SectionConfig != null ? _SectionConfig : _SectionConfig = new SectionConfig(this)); } }
#endregion
public new DynamicTypeDescriptor MyConfig
{
get { return SectionConfig; }
}
}
#endregion
#region Section
[Serializable()]
public partial class Section : Item
{
public new static Section Get(int itemID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
Section tmp = (Section)GetExistingByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Section>(new PKCriteria(itemID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Item.Get", ex);
}
}
public new Section Save()
{
return (Section)base.Save();
}
#region SectionConfig
[NonSerialized]
private SectionConfig _SectionConfig;
public SectionConfig SectionConfig
{
get
{
if (_SectionConfig == null)
{
_SectionConfig = new SectionConfig(this);
_SectionConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_SectionConfig_PropertyChanged);
}
return _SectionConfig;
}
}
private void _SectionConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
MyContent.Config = _SectionConfig.ToString();
}
#endregion
}
#endregion
#region StepInfo
[Serializable()]
public partial class StepInfo : ItemInfo
{
//public override string ToString()
//{
// return "Step " + base.ToString();
//}
public StepInfo(SafeDataReader dr) : base(dr) { }
public new Step Get()
{
return (Step)(_Editable = Step.Get(ItemID));
}
//public E_FromType FromType
//{ get { return E_FromType.Step; } }
}
#endregion
#region Step
[Serializable()]
public partial class Step : Item
{
public new static Step Get(int itemID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
Step tmp = (Step)GetExistingByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Step>(new PKCriteria(itemID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Item.Get", ex);
}
}
//#region StepConfig
//[NonSerialized]
//private StepConfig _StepConfig;
//public StepConfig StepConfig
//{
// get
// {
// if (_StepConfig == null)
// {
// _StepConfig = new StepConfig(this);
// _StepConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_StepConfig_PropertyChanged);
// }
// return _SectionConfig;
// }
//}
//private void _StepConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
//{
// MyContent.Config = _StepConfig.ToString();
//}
//#endregion
}
#endregion
}

View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
namespace VEPROMS.CSLA.Library
{
public partial class ContentPart
{
public override string ToString()
{
return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
}
}
public partial class ItemPart
{
public override string ToString()
{
return string.Format("{0} {1}", _MyContent.Number, MyContent.Text);
}
}
public partial class Part
{
public override string ToString()
{
return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
}
}
public partial class PartInfo : IVEDrillDownReadOnly
{
public E_FromType PartType
{ get { return (E_FromType)_FromType; } }
public E_FromTypes PartTypes
{ get { return (E_FromTypes)_FromType; } }
public override string ToString()
{
return string.Format("{0}", PartTypes);
}
//public string ToString(string str, System.IFormatProvider ifp)
//{
// return ToString();
//}
#region IVEDrillDownReadOnly
public ItemInfoList _MyItems;
public ItemInfoList MyItems
{ get { return (_MyItems != null? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID,_FromType)); } }
public System.Collections.IList GetChildren()
{
return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType));
}
//public bool ChildrenAreLoaded
//{
// get { return _MyItems == null; }
//}
public bool HasChildren
{
get { return this.MyContent.ContentPartCount > 0; }
}
public IVEDrillDownReadOnly ActiveParent
{
get
{
ContentInfo parentContent = MyContent;
if (parentContent == null || parentContent.ContentItemCount == 0) return null;
return parentContent.ContentItems[0];
}
}
public FormatInfo ActiveFormat
{
get { return ActiveParent.ActiveFormat; }
}
public FormatInfo LocalFormat
{
get { return null; }
}
public DynamicTypeDescriptor MyConfig
{
get { return null; }
}
//public bool HasStandardSteps()
//{ return false; }
#endregion
}
public enum E_FromType : int
{
Procedure = 1, Section = 2, Caution = 3, Note = 4, RNO = 5, Step = 6, Table = 7
}
public enum E_FromTypes : int
{
Procedures = 1, Sections = 2, Cautions = 3, Notes = 4, RNOs = 5, Steps = 6, Tables = 7
}
}

View File

@@ -0,0 +1,95 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections;
namespace VEPROMS.CSLA.Library
{
public partial class ChildFoldersPropertyDescriptor
{
public override string DisplayName
{ get { return Item.Name; } }
public override string Description
{ get { return Item.Title; } }
public override string Name
{ get { return Item.Name; } }
}
public partial class FolderDocVersionsPropertyDescriptor
{
public override string DisplayName
{ get { return Item.Name; } }
public override string Description
{ get { return Item.Name; } }
public override string Name
{ get { return Item.Name; } }
}
public class FormatList : System.ComponentModel.StringConverter
{
private static SortedList<string,FormatInfo> _FormatInfoList;
private static void LoadSortedList()
{
if (_FormatInfoList == null)
{
_FormatInfoList = new SortedList<string, FormatInfo>();
foreach (FormatInfo formatInfo in FormatInfoList.Get())
{
_FormatInfoList.Add(formatInfo.Name, formatInfo);
}
_FormatInfoList.Add("", null);
}
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
LoadSortedList();
return new StandardValuesCollection((ICollection)_FormatInfoList.Values);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
public static int? ToInt(string formatName)
{
if (formatName == null || formatName == string.Empty) return null;
LoadSortedList();
foreach (FormatInfo formatInfo in _FormatInfoList.Values)
if (formatInfo != null && formatInfo.Name == formatName) return formatInfo.FormatID;
return null;
}
public static string ToString(int? formatID)
{
if (formatID == null) return null;
LoadSortedList();
foreach (FormatInfo formatInfo in _FormatInfoList.Values)
if (formatInfo != null && formatInfo.FormatID == formatID) return formatInfo.ToString();
return null;
}
public static Format ToFormat(string formatName)
{
if (formatName == null || formatName == string.Empty) return null;
LoadSortedList();
foreach (FormatInfo formatInfo in _FormatInfoList.Values)
if (formatInfo != null && formatInfo.ToString() == formatName) return formatInfo.Get();
return null;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public partial class TransitionInfo
{
public string PathTo
{
get
{
//return "To " + MyItemToID.Path;
return MyItemToID.Path;
}
}
public string PathFrom
{
get
{
//return "From " + MyContent.ContentItems[0].Path;
return MyContent.ContentItems[0].Path;
}
}
}
}