This commit is contained in:
Kathy Ruffing 2009-09-01 14:28:22 +00:00
parent de9081036c
commit 17575c0f69
4 changed files with 237 additions and 3 deletions

View File

@ -515,6 +515,11 @@ namespace VEPROMS.CSLA.Library
{ {
int stepType = ((int)MyContent.Type) % 10000; int stepType = ((int)MyContent.Type) % 10000;
StepDataList sdlist = ActiveFormat.PlantFormat.FormatData.StepDataList; StepDataList sdlist = ActiveFormat.PlantFormat.FormatData.StepDataList;
if (stepType > sdlist.Count)
{
Console.WriteLine("Error getting type - contentid = {0}", MyContent.ContentID);
return false;
}
StepData sd = sdlist[stepType]; StepData sd = sdlist[stepType];
while (sd.Index != 0) while (sd.Index != 0)
{ {
@ -897,6 +902,60 @@ namespace VEPROMS.CSLA.Library
{ {
get { return _SearchAnnotationType; } get { return _SearchAnnotationType; }
} }
private ProcedureConfig _ProcedureConfig = null;
public ProcedureConfig.PrintChangeBar PrintChangeBar
{
get
{
if (_ProcedureConfig == null) SetProcedureConfig();
return _ProcedureConfig.Print_ChangeBar;
}
}
public ProcedureConfig.PrintChangeBarLoc PrintChangeBarLoc
{
get
{
if (_ProcedureConfig == null) SetProcedureConfig();
return _ProcedureConfig.Print_ChangeBarLoc;
}
}
public ProcedureConfig.PrintChangeBarText PrintChangeBarText
{
get
{
if (_ProcedureConfig == null) SetProcedureConfig();
return _ProcedureConfig.Print_ChangeBarText;
}
}
public string PrintChangeBarUsrMsg1
{
get
{
if (_ProcedureConfig == null) SetProcedureConfig();
return _ProcedureConfig.Print_UserCBMess1;
}
}
public string PrintChangeBarUsrMsg2
{
get
{
if (_ProcedureConfig == null) SetProcedureConfig();
return _ProcedureConfig.Print_UserCBMess2;
}
}
private void SetProcedureConfig()
{
// Walk up tree until find my procedure. Then get its change bar (default will
// get inherited information if not set at this level).
// Find the procedure level and its config.
ItemInfo tmpitm = this;
while (tmpitm.MyContent.Type != 0)
tmpitm = tmpitm.MyParent;
ProcedureInfo pi = ProcedureInfo.Get(tmpitm.ItemID);
if (pi == null) return;
_ProcedureConfig = pi.MyConfig as ProcedureConfig;
}
public string DisplayText public string DisplayText
{ {
get { return ConvertToDisplayText(MyContent.Text); } get { return ConvertToDisplayText(MyContent.Text); }
@ -1128,6 +1187,29 @@ namespace VEPROMS.CSLA.Library
return DisplayText.Replace("\u2011", "-").Split(" ,.;:-_".ToCharArray())[0]+ "..."; return DisplayText.Replace("\u2011", "-").Split(" ,.;:-_".ToCharArray())[0]+ "...";
} }
} }
#region Change Bar
public bool HasChangeBar()
{
if (this.IsAccPages || this.IsProcedure || this.IsSection) return false;
StepInfo si = this as StepInfo;
if (si == null) return false;
StepConfig sc = si.MyConfig as StepConfig;
if (sc == null) return false;
// if there is no override & return whether there was a change to the text.
if (sc.Step_CBOverride == null)
return (DTS > MyProcedure.DTS);
else // override is on:
{
// If the date time stamp says that text was changed so a change bar should exist,
// check override to see how change bar controls are set. The override flag can
// be either On or Off.
if (DTS > MyProcedure.DTS)
return (sc.Step_CBOverride == "On");
else
return (sc.Step_CBOverride == "Off");
}
}
#endregion
#region IVEReadOnlyItem #region IVEReadOnlyItem
PartInfoList _PartInfoList; PartInfoList _PartInfoList;
public System.Collections.IList GetChildren() public System.Collections.IList GetChildren()

View File

@ -48,7 +48,11 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
if (_docVer == null) _docVer = DocVersion.Get(this.ROFstAssociations[0].MyDocVersion.VersionID); if (_docVer == null)
{
if (ROFstAssociations.Count == 0) return null;
_docVer = DocVersion.Get(this.ROFstAssociations[0].MyDocVersion.VersionID);
}
return _docVer; return _docVer;
} }
set set
@ -161,7 +165,7 @@ namespace VEPROMS.CSLA.Library
/// the current one. /// the current one.
/// <param name="docver" - hook into this doc version></param> /// <param name="docver" - hook into this doc version></param>
/// <returns>ROFst: Returns the created rofst object</returns> /// <returns>ROFst: Returns the created rofst object</returns>
public static ROFst UpdateRoFst(RODbInfo rdi, DocVersionAssociation dva, DocVersion docver) public static ROFst UpdateRoFst(RODbInfo rdi, DocVersionAssociation dva, DocVersion docver, ROFstInfo origROFst)
{ {
// file validity checks are done before getting here - just do the import // file validity checks are done before getting here - just do the import
// here. // here.
@ -200,9 +204,47 @@ namespace VEPROMS.CSLA.Library
} }
} }
} }
// Now update the usages: compare old to new rofsts and update usages accordingly, i.e. modified
// values, deleted ros, etc.
UpdateROValuesText(origROFst, rofst);
return rofst; return rofst;
} }
} }
private static void UpdateROValuesText(ROFstInfo origROFstInfo, ROFst newROFst)
{
ROFSTLookup origLU = new ROFSTLookup(origROFstInfo);
ROFSTLookup newLU = new ROFSTLookup(newROFst);
List <string> delList = new List<string>();
List<string> chgList = newLU.GetValueDifferences(origLU, ref delList);
foreach (string chg in chgList)
{
string newvalue = newLU.GetRoValue(chg);
string desc = string.Format("Change in RO Values: Old value = {0}, New value = {1}", origLU.GetRoValue(chg), newvalue);
// roid's are stored in database as 16 characters long in the rousages table. They may be stored
// as 12 characters in the ro.fst.
string padroid = chg.Length <= 12 ? chg + "0000" : chg;
RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid, desc, "Changed");
foreach (RoUsageInfo roUsg in affected)
{
using (Content content = Content.Get(roUsg.MyContent.ContentID))
{
content.FixContentText(roUsg, newvalue);
if (content.IsDirty)
content.Save();
}
}
}
foreach (string del in delList)
{
Console.WriteLine("Deleted ROID = {0}", del);
string desc = string.Format("Deleted RO: Value = {0}", origLU.GetRoValue(del));
string padroiddel = del.Length <= 12 ? del + "0000" : del;
RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroiddel, desc, "Deleted");
}
}
private static string NewROName(string roName) private static string NewROName(string roName)
{ {
string retval = roName; string retval = roName;

View File

@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
namespace VEPROMS.CSLA.Library
{
public partial class RoUsageInfoList
{
[Serializable()]
private class AffectedROUsagesCriteria
{
public AffectedROUsagesCriteria(int roDbID, string roid, string roDesc, string command, string userID)
{
_RODbID = roDbID;
_ROID = roid;
_RODesc = roDesc;
_Command = command;
_UserID = userID;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
private string _ROID;
public string ROID
{
get { return _ROID; }
set { _ROID = value; }
}
private string _RODesc;
public string RODesc
{
get { return _RODesc; }
set { _RODesc = value; }
}
private string _Command;
public string Command
{
get { return _Command; }
set { _Command = value; }
}
private string _UserID;
public string UserID
{
get { return _UserID; }
set { _UserID = value; }
}
}
public static RoUsageInfoList GetAffected(int roDbID, string roid, string roDesc, string command)
{
try
{
RoUsageInfoList tmp = DataPortal.Fetch<RoUsageInfoList>(new AffectedROUsagesCriteria(roDbID, roid, roDesc, command, Environment.UserName));
RoUsageInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROUsageInfoList.GetAffected", ex);
}
}
private void DataPortal_Fetch(AffectedROUsagesCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROUsageInfoList.DataPortal_FetchAffected", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAffectedRoUsages";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
cm.Parameters.AddWithValue("@ROID", criteria.ROID);
cm.Parameters.AddWithValue("@RODesc", criteria.RODesc);
cm.Parameters.AddWithValue("@Command", criteria.Command);
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
this.Add(new RoUsageInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfoList.DataPortal_FetchAffected", ex);
throw new DbCslaException("ROUsageInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
}

View File

@ -67,7 +67,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(AffectedTransitonsCriteria criteria) private void DataPortal_Fetch(AffectedTransitonsCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_FetchFromID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_FetchAffected", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)