Change Manager
This commit is contained in:
@@ -55,6 +55,126 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public partial class FormatInfo : IFormatOrFormatInfo
|
||||
{
|
||||
public static bool HasLatestChanges()
|
||||
{
|
||||
if (!HasTopMargin()) return false;
|
||||
if (!HasWCN2_MacroB9()) return false;
|
||||
return true;
|
||||
}
|
||||
private static bool HasTopMargin()
|
||||
{
|
||||
using (FormatInfo fi = FormatInfo.Get("WCN2"))
|
||||
{
|
||||
XmlDocument xd = new XmlDocument();
|
||||
xd.LoadXml(fi.Data);
|
||||
XmlNodeList xl = xd.SelectNodes("//DocStyle/Layout/@TopMargin");
|
||||
if (xl.Count == 0)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("DocStyle TopMargin is missing", "Inconsistent Format Files", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private static bool HasWCN2_MacroB9()
|
||||
{
|
||||
using (FormatInfo fi = FormatInfo.Get("WCN2"))
|
||||
{
|
||||
XmlDocument xd = new XmlDocument();
|
||||
xd.LoadXml(fi.GenMac);
|
||||
XmlNodeList xl = xd.SelectNodes("//*[@id='B9']");
|
||||
if (xl.Count == 0)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("B9 macro is missing in WCN2 GenMac","Inconsistent Format Files", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static FormatInfo Get(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
FormatInfo tmp = DataPortal.Fetch<FormatInfo>(new NameCriteria(name));
|
||||
//AddToCache(tmp);
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up FormatInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
Exception ex = ex1;
|
||||
while (ex.InnerException != null)
|
||||
ex = ex.InnerException;
|
||||
if (ex.Message.StartsWith("Could not find stored procedure"))
|
||||
{
|
||||
int formatID = 0;
|
||||
using (FormatInfoList fil = FormatInfoList.Get())
|
||||
{
|
||||
foreach (FormatInfo fi in fil)
|
||||
{
|
||||
if (fi.Name == name)
|
||||
{
|
||||
formatID = fi.FormatID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (formatID != 0) return FormatInfo.Get(formatID);
|
||||
throw new DbCslaException("Format not found " + name, ex);
|
||||
}
|
||||
else
|
||||
throw new DbCslaException("Error on FormatInfo.Get By Name", ex);
|
||||
}
|
||||
}
|
||||
protected class NameCriteria
|
||||
{
|
||||
private string _Name;
|
||||
public string Name
|
||||
{ get { return _Name; } }
|
||||
public NameCriteria(string name)
|
||||
{
|
||||
_Name = name;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(NameCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
ApplicationContext.LocalContext["cn"] = cn;
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getFormatByName";
|
||||
cm.Parameters.AddWithValue("@Name", criteria.Name);
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
if (!dr.Read())
|
||||
{
|
||||
_ErrorMessage = "No Record Found";
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
}
|
||||
}
|
||||
// removing of item only needed for local data portal
|
||||
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
|
||||
ApplicationContext.LocalContext.Remove("cn");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
#region PlantFormat
|
||||
[NonSerialized]
|
||||
private PlantFormat _PlantFormat;
|
||||
|
Reference in New Issue
Block a user