Enhancements for handling checkout/modifications at folder and session level
This commit is contained in:
parent
e61ee1051c
commit
ab03dfd2ff
@ -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, Folder = 3
|
Procedure = 0, Document = 1, DocVersion = 2, Folder = 3, Session = 4
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region SessionInfoList stuff
|
#region SessionInfoList stuff
|
||||||
@ -132,7 +132,7 @@ 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 (objectType == CheckOutType.Session)
|
||||||
{
|
{
|
||||||
if (sil.Count == 1)
|
if (sil.Count == 1)
|
||||||
{
|
{
|
||||||
@ -166,6 +166,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
else if (si.SessionID != this.SessionID && objectType == CheckOutType.DocVersion)
|
else if (si.SessionID != this.SessionID && objectType == CheckOutType.DocVersion)
|
||||||
{
|
{
|
||||||
|
// gets here if other session has working draft open & click on sam working draft.
|
||||||
OwnerInfo oi = OwnerInfo.GetBySessionIDandVersionID(si.SessionID, objectID);
|
OwnerInfo oi = OwnerInfo.GetBySessionIDandVersionID(si.SessionID, objectID);
|
||||||
if(oi.OwnerType == 0)
|
if(oi.OwnerType == 0)
|
||||||
message = message + string.Format("The procedure {0} is already checked out to {1}", ItemInfo.Get(oi.OwnerItemID).MyProcedure.DisplayNumber, si.UserID) + Environment.NewLine;
|
message = message + string.Format("The procedure {0} is already checked out to {1}", ItemInfo.Get(oi.OwnerItemID).MyProcedure.DisplayNumber, si.UserID) + Environment.NewLine;
|
||||||
@ -175,6 +176,24 @@ namespace VEPROMS.CSLA.Library
|
|||||||
message = message + string.Format("The working draft is already checked out to {0}", si.UserID);
|
message = message + string.Format("The working draft is already checked out to {0}", si.UserID);
|
||||||
rv = rv && false;
|
rv = rv && false;
|
||||||
}
|
}
|
||||||
|
else if (si.SessionID != this.SessionID && objectType == CheckOutType.Folder)
|
||||||
|
{
|
||||||
|
// gets here if other session has working draft open & click on folder above. Gets here
|
||||||
|
// if other session has wd open and click on top folder - query returns empty.
|
||||||
|
OwnerInfo oi = OwnerInfo.GetBySessionIDandFolderID(si.SessionID, objectID);
|
||||||
|
if (oi != null)
|
||||||
|
{
|
||||||
|
if (oi.OwnerType == 0)
|
||||||
|
message = message + string.Format("The procedure {0} is already checked out to {1}", ItemInfo.Get(oi.OwnerItemID).MyProcedure.DisplayNumber, si.UserID) + Environment.NewLine;
|
||||||
|
else if (oi.OwnerType == 1)
|
||||||
|
message = message + string.Format("The document {0} is already checked out to {1}", DocumentInfo.Get(oi.OwnerItemID).DocumentEntries[0].MyContent.Text, si.UserID) + Environment.NewLine;
|
||||||
|
else if (oi.OwnerType == 2)
|
||||||
|
message = message + string.Format("The working draft is already checked out to {0}", si.UserID);
|
||||||
|
else if (oi.OwnerType == 3)
|
||||||
|
message = message + string.Format("The folder is already checked out to {0}", si.UserID);
|
||||||
|
rv = rv && false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -756,6 +775,74 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public partial class OwnerInfo
|
public partial class OwnerInfo
|
||||||
{
|
{
|
||||||
|
public static OwnerInfo GetBySessionIDandFolderID(int sessionID, int folderID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OwnerInfo tmp = DataPortal.Fetch<OwnerInfo>(new GetBySessionIDandFolderIDCriteria(sessionID, folderID));
|
||||||
|
if (tmp.ErrorMessage == "No Record Found")
|
||||||
|
{
|
||||||
|
tmp.Dispose(); // Clean-up SessionInfo
|
||||||
|
tmp = null;
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new DbCslaException("Error on OwnerInfo.GetBySessionIDandFolderID", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[Serializable()]
|
||||||
|
protected class GetBySessionIDandFolderIDCriteria
|
||||||
|
{
|
||||||
|
private int _SessionID;
|
||||||
|
public int SessionID
|
||||||
|
{ get { return _SessionID; } }
|
||||||
|
private int _FolderID;
|
||||||
|
public int FolderID
|
||||||
|
{ get { return _FolderID; } }
|
||||||
|
public GetBySessionIDandFolderIDCriteria(int sessionID, int folderID)
|
||||||
|
{
|
||||||
|
_SessionID = sessionID;
|
||||||
|
_FolderID = folderID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void DataPortal_Fetch(GetBySessionIDandFolderIDCriteria criteria)
|
||||||
|
{
|
||||||
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.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 = "getOwnerBySessionIDandFolderID";
|
||||||
|
cm.Parameters.AddWithValue("@SessionID", criteria.SessionID);
|
||||||
|
cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
|
||||||
|
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("OwnerInfo.DataPortal_Fetch", ex);
|
||||||
|
_ErrorMessage = ex.Message;
|
||||||
|
throw new DbCslaException("OwnerInfo.DataPortal_Fetch", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
public static OwnerInfo GetBySessionIDandVersionID(int sessionID, int versionID)
|
public static OwnerInfo GetBySessionIDandVersionID(int sessionID, int versionID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
x
Reference in New Issue
Block a user