Added GetByName method to AnnotationTypeInfo class
Added code to manage checking out a folder to allow for exporting or importing docversions Added new commands TurnChangeManagerOff and TurnChangeManagerOn.
This commit is contained in:
parent
ad7307ab87
commit
adf9d6d19c
@ -53,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
return _Name;
|
return _Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public partial class AnnotationTypeInfo
|
public partial class AnnotationTypeInfo
|
||||||
{
|
{
|
||||||
public static List<AnnotationTypeInfo> AllList()
|
public static List<AnnotationTypeInfo> AllList()
|
||||||
@ -65,7 +65,69 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
return _Name;
|
return _Name;
|
||||||
}
|
}
|
||||||
}
|
public static AnnotationTypeInfo GetByName(string name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AnnotationTypeInfo tmp = DataPortal.Fetch<AnnotationTypeInfo>(new GetByNameCriteria(name));
|
||||||
|
if (tmp.ErrorMessage == "No Record Found")
|
||||||
|
{
|
||||||
|
tmp.Dispose(); // Clean-up AnnotationTypeInfo
|
||||||
|
tmp = null;
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new DbCslaException("Error on AnnotationTypeInfo.GetByName", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[Serializable()]
|
||||||
|
protected class GetByNameCriteria
|
||||||
|
{
|
||||||
|
private string _Name;
|
||||||
|
public string Name { get { return _Name; } }
|
||||||
|
public GetByNameCriteria(string name)
|
||||||
|
{
|
||||||
|
_Name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void DataPortal_Fetch(GetByNameCriteria criteria)
|
||||||
|
{
|
||||||
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.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 = "getAnnotationTypeByName";
|
||||||
|
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("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
||||||
|
_ErrorMessage = ex.Message;
|
||||||
|
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public partial class AnnotationTypeInfoList
|
public partial class AnnotationTypeInfoList
|
||||||
{
|
{
|
||||||
public static void Refresh()
|
public static void Refresh()
|
||||||
|
@ -12,7 +12,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#region Enum stuff
|
#region Enum stuff
|
||||||
public enum CheckOutType : int
|
public enum CheckOutType : int
|
||||||
{
|
{
|
||||||
Procedure = 0, Document = 1, DocVersion = 2
|
Procedure = 0, Document = 1, DocVersion = 2, Folder = 3
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region SessionInfoList stuff
|
#region SessionInfoList stuff
|
||||||
@ -105,6 +105,25 @@ namespace VEPROMS.CSLA.Library
|
|||||||
SessionInfoList sil = DataPortal.Fetch<SessionInfoList>(new SessionInfoList.CanCheckOutItemCriteria(objectID, objectType));
|
SessionInfoList sil = DataPortal.Fetch<SessionInfoList>(new SessionInfoList.CanCheckOutItemCriteria(objectID, objectType));
|
||||||
if (sil.Count == 0)
|
if (sil.Count == 0)
|
||||||
return true;
|
return true;
|
||||||
|
if (objectType == CheckOutType.Folder)
|
||||||
|
{
|
||||||
|
if (sil.Count == 1)
|
||||||
|
{
|
||||||
|
OwnerInfoList oil = OwnerInfoList.GetBySessionID(sil[0].SessionID);
|
||||||
|
if (oil.Count == 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = "Export Procedure Set and Import Procedure Set are not available because you have open procedures or documents";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = "Export Procedure Set and Import Procedure Set are not available because there are other sessions open in the database";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
bool rv = true;
|
bool rv = true;
|
||||||
foreach (SessionInfo si in sil)
|
foreach (SessionInfo si in sil)
|
||||||
{
|
{
|
||||||
@ -256,7 +275,73 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
public class ResetSecurity : CommandBase
|
public class TurnChangeManagerOff : CommandBase
|
||||||
|
{
|
||||||
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#region Factory Methods
|
||||||
|
public static void Execute()
|
||||||
|
{
|
||||||
|
TurnChangeManagerOff cmd = new TurnChangeManagerOff();
|
||||||
|
DataPortal.Execute<TurnChangeManagerOff>(cmd);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Server-Side code
|
||||||
|
protected override void DataPortal_Execute()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||||
|
{
|
||||||
|
using (SqlCommand cmd = new SqlCommand("vesp_TurnChangeManagerOFF", cn))
|
||||||
|
{
|
||||||
|
cmd.CommandType = CommandType.StoredProcedure;
|
||||||
|
cmd.CommandTimeout = 0;
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("TurnChangeManagerOff Error", ex);
|
||||||
|
throw new ApplicationException("Failure on TurnChangeManagerOff", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
public class TurnChangeManagerOn : CommandBase
|
||||||
|
{
|
||||||
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#region Factory Methods
|
||||||
|
public static void Execute()
|
||||||
|
{
|
||||||
|
TurnChangeManagerOn cmd = new TurnChangeManagerOn();
|
||||||
|
DataPortal.Execute<TurnChangeManagerOn>(cmd);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Server-Side code
|
||||||
|
protected override void DataPortal_Execute()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||||
|
{
|
||||||
|
using (SqlCommand cmd = new SqlCommand("vesp_TurnChangeManagerON", cn))
|
||||||
|
{
|
||||||
|
cmd.CommandType = CommandType.StoredProcedure;
|
||||||
|
cmd.CommandTimeout = 0;
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("TurnChangeManagerOn Error", ex);
|
||||||
|
throw new ApplicationException("Failure on TurnChangeManagerOn", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
public class ResetSecurity : CommandBase
|
||||||
{
|
{
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user