C2025-027-AnnotationsTypeSelect
This commit is contained in:
463
PROMS/VEPROMS.CSLA.Library/Minimal/AnnotationstypeSections.cs
Normal file
463
PROMS/VEPROMS.CSLA.Library/Minimal/AnnotationstypeSections.cs
Normal file
@@ -0,0 +1,463 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
//namespace VEPROMS.CSLA.Library;
|
||||
|
||||
// C2025-027 this new file is used to support (data retrival) for selecting Annotation types to display on the Annotation screen.
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public class AnnotationstypeSelections
|
||||
{
|
||||
public static DataTable Get(string UserID, int ItemID)
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getAnnotationstypeSelections";
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
cm.Parameters.AddWithValue("@UsrID", UserID);
|
||||
SqlDataAdapter da = new SqlDataAdapter(cm);
|
||||
SqlDataReader reader = cm.ExecuteReader();
|
||||
DataTable dt = new DataTable();
|
||||
dt.Load(reader);
|
||||
// if the user has not created a annotation sub-set list saved to AnnotationTypeSelections table.
|
||||
if (dt.Rows.Count < 1)
|
||||
{
|
||||
//dt.Rows.Add(DataPortal.Fetch<AnnotationTypeInfoList>());
|
||||
//DataPortal.Fetch<AnnotationTypeInfoList>();
|
||||
DataRow row;
|
||||
int rowflg = 0;
|
||||
foreach (AnnotationTypeInfo annosel in DataPortal.Fetch<AnnotationTypeInfoList>())
|
||||
{
|
||||
// C2025-027 need to use a datatable instead of AnnotationTypeInfoList so the global search Annotations will not be effected by the Annotation select list selections
|
||||
if (rowflg == 0)
|
||||
{
|
||||
row = dt.NewRow();
|
||||
dt.Rows.Add(row);
|
||||
rowflg = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
row = dt.NewRow();
|
||||
row["TypeID"] = annosel.TypeID;
|
||||
row["ItemID"] = ItemID;
|
||||
row["Name"] = annosel.Name;
|
||||
row["Config"] = annosel.Config;
|
||||
row["DTS"] = annosel.DTS;
|
||||
row["UserID"] = annosel.UserID;
|
||||
row["IsEPAnnotationType"] = annosel.IsEPAnnotationType;
|
||||
dt.Rows.Add(row);
|
||||
}
|
||||
|
||||
//row = dt.NewRow();
|
||||
//row["TypeID"] = annosel.TypeID;
|
||||
//row["ItemID"] = ItemID;
|
||||
//row["Name"] = annosel.Name;
|
||||
//row["Config"] = annosel.Config;
|
||||
//row["DTS"] = annosel.DTS;
|
||||
//row["UserID"] = annosel.UserID;
|
||||
//row["IsEPAnnotationType"] = annosel.IsEPAnnotationType;
|
||||
|
||||
//dt.Rows.Add(row);
|
||||
|
||||
//dt.Rows.Add(0,annosel.TypeID, ItemID, annosel.Name, annosel.Config, annosel.DTS, annosel.UserID, 0x0000000000000000, annosel.IsEPAnnotationType);
|
||||
};
|
||||
}
|
||||
return dt;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//B2025-004
|
||||
//if it fails loading previously open tabs, simply treat it as if no tabs were open
|
||||
//instead of crashing
|
||||
return new DataTable();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public static DataTable Retrieve(string UserID)
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getAnnotationstypeSelections";
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
cm.Parameters.AddWithValue("@UsrID", UserID);
|
||||
SqlDataAdapter da = new SqlDataAdapter(cm);
|
||||
SqlDataReader reader = cm.ExecuteReader();
|
||||
DataTable dt = new DataTable();
|
||||
dt.Load(reader);
|
||||
|
||||
return dt;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//B2025-004
|
||||
//if it fails loading previously open tabs, simply treat it as if no tabs were open
|
||||
//instead of crashing
|
||||
return new DataTable();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public static DataTable GetAnnoTypes(string UserID)
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getAnnotationSelectListTypes";
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
SqlDataAdapter da = new SqlDataAdapter(cm);
|
||||
cm.Parameters.AddWithValue("@UserID", UserID);
|
||||
SqlDataReader reader = cm.ExecuteReader();
|
||||
DataTable dt = new DataTable();
|
||||
dt.Load(reader);
|
||||
|
||||
return dt;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//B2025-004
|
||||
//if it fails loading previously open tabs, simply treat it as if no tabs were open
|
||||
//instead of crashing
|
||||
return new DataTable();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void Update(string UserID, int TypeID, int dltFlg, string Name = "")
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "UpdateAnnotationstypeSelections";
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
cm.Parameters.AddWithValue("@UserID", UserID);
|
||||
cm.Parameters.AddWithValue("@TypeID", TypeID);
|
||||
cm.Parameters.AddWithValue("@dltFlg", dltFlg);
|
||||
cm.Parameters.AddWithValue("@Name", Name);
|
||||
|
||||
cm.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static AnnotationTypeInfoList AnnotationSelectByItem(int itemID)
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (_AnnotationTypeInfoList != null)
|
||||
// return _AnnotationTypeInfoList;
|
||||
AnnotationTypeInfoList tmp = (AnnotationTypeInfoList)DataPortal.Fetch(new AnnotationSelectByItemIDCriteria(itemID));
|
||||
if (tmp.Count < 1)
|
||||
{
|
||||
tmp = DataPortal.Fetch<AnnotationTypeInfoList>();
|
||||
}
|
||||
AnnotationTypeInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
return tmp;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on AnnotationTypeInfoList.Get", ex);
|
||||
}
|
||||
}
|
||||
private int _TypeID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int TypeID
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
return _TypeID;
|
||||
}
|
||||
}
|
||||
private int _ItemID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int ItemID
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
return _ItemID;
|
||||
}
|
||||
}
|
||||
private string _Name = string.Empty;
|
||||
public string Name
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
return _Name;
|
||||
}
|
||||
}
|
||||
private string _Config = string.Empty;
|
||||
public string Config
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
return _Config;
|
||||
}
|
||||
}
|
||||
private DateTime _DTS = new DateTime();
|
||||
public DateTime DTS
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
return _DTS;
|
||||
}
|
||||
}
|
||||
private string _UserID = string.Empty;
|
||||
public string UserID
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
return _UserID;
|
||||
}
|
||||
}
|
||||
private int _AnnotationTypeAnnotationCount = 0;
|
||||
public int AnnotationTypeAnnotationCount
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
return _AnnotationTypeAnnotationCount;
|
||||
}
|
||||
}
|
||||
//C2025-023 - Electronic Procedures - Modifications to PROMS
|
||||
// Is Annotation Type an EP Annotation?
|
||||
private bool _IsEPAnnotationType = false;
|
||||
public bool IsEPAnnotationType
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
return _IsEPAnnotationType;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
if (_IsEPAnnotationType != value)
|
||||
{
|
||||
_IsEPAnnotationType = value;
|
||||
//PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Log4Net
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
[Serializable()]
|
||||
protected class retrieveAnnotSelections
|
||||
{
|
||||
private int _itemID;
|
||||
public int itemID { get { return _itemID; } }
|
||||
|
||||
public retrieveAnnotSelections(int itemID)
|
||||
{
|
||||
_itemID = itemID;
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
public class retrieveAnnotSelectionsList
|
||||
{
|
||||
private int _TypeID;
|
||||
public int TypeID
|
||||
{
|
||||
get { return _TypeID; }
|
||||
set { _TypeID = value; }
|
||||
}
|
||||
private int _ItemID;
|
||||
public int ItemID
|
||||
{
|
||||
get { return _ItemID; }
|
||||
set { _ItemID = value; }
|
||||
}
|
||||
private string _Name;
|
||||
public string Name
|
||||
{
|
||||
get { return _Name; }
|
||||
set { _Name = value; }
|
||||
}
|
||||
private string _Config;
|
||||
public string Config
|
||||
{
|
||||
get { return _Config; }
|
||||
set { _Config = value; }
|
||||
}
|
||||
private DateTime _DTS;
|
||||
public DateTime DTS
|
||||
{
|
||||
get { return _DTS; }
|
||||
set { _DTS = value; }
|
||||
}
|
||||
private string _UserID;
|
||||
public string UserID
|
||||
{
|
||||
get { return _UserID; }
|
||||
set { _UserID = value; }
|
||||
}
|
||||
private bool _IsEPAnnotationType;
|
||||
public bool IsEPAnnotationType
|
||||
{
|
||||
get { return _IsEPAnnotationType; }
|
||||
set { _IsEPAnnotationType = value; }
|
||||
}
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
}
|
||||
|
||||
private void DataPortal_Fetch(retrieveAnnotSelections criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getAnnotationstypeSelections";
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
cm.Parameters.AddWithValue("@itemID", criteria.itemID);
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
if (!dr.Read())
|
||||
{
|
||||
_ErrorMessage = "No Record Found";
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("retrieveAnnotSelectionsList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("retrieveAnnotSelectionsList.DataPortal_Fetch", ex);
|
||||
}
|
||||
//this.RaiseListChangedEvents = true;
|
||||
}
|
||||
[Serializable()]
|
||||
protected class AnnotationSelectByItemIDCriteria
|
||||
{
|
||||
private int _itemID;
|
||||
public int ItemID
|
||||
{ get { return _itemID; } }
|
||||
|
||||
public AnnotationSelectByItemIDCriteria(int itemID)
|
||||
{
|
||||
_itemID = itemID;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(AnnotationSelectByItemIDCriteria criteria)
|
||||
{
|
||||
//this.RaiseListChangedEvents = false;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfoList.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getAnnotationTypes2";
|
||||
cm.Parameters.AddWithValue("@itemID", criteria.ItemID);
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
//IsReadOnly = false;
|
||||
//while (dr.Read()) this.Add(new AnnotationTypeInfo(dr));
|
||||
//IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("AnnotationTypeInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
//this.RaiseListChangedEvents = true;
|
||||
}
|
||||
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] retrieveAnnotSelectionsList.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
_TypeID = dr.GetInt32("TypeID");
|
||||
_ItemID = dr.GetInt32("ItemID");
|
||||
_Name = dr.GetString("Name");
|
||||
_Config = dr.GetString("Config");
|
||||
_DTS = dr.GetDateTime("DTS");
|
||||
_UserID = dr.GetString("UserID");
|
||||
_AnnotationTypeAnnotationCount = dr.GetInt32("AnnotationCount");
|
||||
if (dr.GetSchemaTable().Rows.OfType<DataRow>().Any(row => row["ColumnName"].ToString() == "IsEPAnnotationType"))
|
||||
_IsEPAnnotationType = (bool)dr.GetValue("IsEPAnnotationType");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("retrieveAnnotSelectionsList.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("retrieveAnnotSelectionsList.ReadData", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user