This commit is contained in:
2020-12-16 00:29:44 +00:00
parent 88d3ea747a
commit 58ea3c7189
5 changed files with 1290 additions and 1089 deletions

View File

@@ -188,7 +188,7 @@ namespace AyaNova.PlugIn.V8
{ {
if (!Map.ContainsKey(id)) if (!Map.ContainsKey(id))
{ {
throw new Exception("Error: GetMap (source id: "+ id.ToString() +") [" + details + "] - v7 Id not previously exported, missing or corrupted source data, export can not complete until fixed"); throw new Exception("Error: GetMap (source id: " + id.ToString() + ") [" + details + "] - v7 Id not previously exported, missing or corrupted source data, export can not complete until fixed");
} }
return Map[id]; return Map[id];
} }
@@ -1859,47 +1859,53 @@ namespace AyaNova.PlugIn.V8
progress.Op("Start Memos export"); progress.Op("Start Memos export");
progress.SubOp(""); progress.SubOp("");
var ObjectTypeName = "Memo"; var ObjectTypeName = "Memo";
List<string> tags = new List<string>();
tags.Add(ImportTag);
//Step 2: export the objects //Get all user id's then get all memo id's for each user id then fetch each memo and finally export
MemoList pl = MemoList.GetListForSingleItem(PluginID); UserPickList upl = UserPickList.GetList(false);
foreach (UserPickList.UserPickListInfo upli in upl)
progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s");
foreach (MemoList.MemoListInfo i in pl)
{ {
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
List<string> tags = new List<string>(); UserMemoIdList umidl = UserMemoIdList.GetList(upli.ID);
tags.Add(ImportTag); foreach (UserMemoIdList.UserMemoIdListInfo mid in umidl)
{
if (!progress.KeepGoing) return;
Memo mem = Memo.GetItem(mid.mID, PluginID);
dynamic d = new JObject();
dynamic dmemo = new JObject();
dynamic duserid = new JArray();
dmemo.name = mem.Subject;
dmemo.notes = mem.Message;
dmemo.viewed = mem.Viewed;
dmemo.replied = mem.Replied;
var RavenFromId=SafeGetUserMap(mem.FromID);
dmemo.fromId = RavenFromId;
dmemo.sent = mem.Created;
duserid.Add(SafeGetUserMap(mem.ToID));
d.users = duserid;
d.memo = dmemo;
SetTags(d, tags);
progress.Op(ObjectTypeName + " " + mem.ID.ToString());
var rMainObject = await util.PostAsync("memo", d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
dynamic d = new JObject(); d = rMainObject.ObjectResponse["data"];
d.name = i.LT_Memo_Label_Subject.Display;
d.notes = i.LT_Memo_Label_Message;
//d.customFields = "{}";
//d.tags = "[]";
d.viewed = i.LT_Memo_Label_Viewed;
d.replied = i.LT_Memo_Label_Replied;
d.fromId = SafeGetUserMap(i.LT_Memo_Label_FromID.Value);
d.sent = i.LT_Memo_Label_Sent;
progress.Op(ObjectTypeName + " " + i.ID.ToString()); //-----
//Event log fixup
await util.EventLog(util.AyaType.Project, RavenId, RavenFromId, RavenFromId, mem.Created, mem.Modified);
}
var rMainObject = await util.PostAsync("memo", d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
//-----
d = rMainObject.ObjectResponse["data"];
//-----
//Event log fixup
await util.EventLog(util.AyaType.Project, RavenId, SafeGetUserMap(i.LT_Memo_Label_FromID.Value), SafeGetUserMap(i.LT_Memo_Label_FromID.Value), i.LT_Memo_Label_Sent.ToString(), i.LT_Memo_Label_Sent.ToString());
} }
//------
} }
#endregion Memos #endregion Memos
@@ -2853,7 +2859,7 @@ namespace AyaNova.PlugIn.V8
formDataContent.Add(new StringContent(RavenTypeAsString), name: "AttachToObjectType"); formDataContent.Add(new StringContent(RavenTypeAsString), name: "AttachToObjectType");
//formDataContent.Add(new StringContent(Map[tid.ID].ToString()), name: "AttachToObjectId"); //formDataContent.Add(new StringContent(Map[tid.ID].ToString()), name: "AttachToObjectId");
formDataContent.Add(new StringContent(GetMap(tid.ID, "Object ID for attachment export (tid:"+tid.ToString()+") ").ToString()), name: "AttachToObjectId"); formDataContent.Add(new StringContent(GetMap(tid.ID, "Object ID for attachment export (tid:" + tid.ToString() + ") ").ToString()), name: "AttachToObjectId");
formDataContent.Add(new StringContent(ImportTag), name: "Notes"); formDataContent.Add(new StringContent(ImportTag), name: "Notes");
formDataContent.Add(new StringContent(dFileData.ToString()), name: "FileData"); formDataContent.Add(new StringContent(dFileData.ToString()), name: "FileData");
@@ -2949,7 +2955,7 @@ namespace AyaNova.PlugIn.V8
else else
RavenTypeAsString = ((int)util.RootObjectToAyaType(tid.RootObjectType)).ToString(); RavenTypeAsString = ((int)util.RootObjectToAyaType(tid.RootObjectType)).ToString();
formDataContent.Add(new StringContent(RavenTypeAsString), name: "AttachToObjectType"); formDataContent.Add(new StringContent(RavenTypeAsString), name: "AttachToObjectType");
// formDataContent.Add(new StringContent(Map[tid.ID].ToString()), name: "AttachToObjectId"); // formDataContent.Add(new StringContent(Map[tid.ID].ToString()), name: "AttachToObjectId");
formDataContent.Add(new StringContent(GetMap(tid.ID, "Object ID for attached docs export (tid:" + tid.ToString() + ") ").ToString()), name: "AttachToObjectId"); formDataContent.Add(new StringContent(GetMap(tid.ID, "Object ID for attached docs export (tid:" + tid.ToString() + ") ").ToString()), name: "AttachToObjectId");
@@ -2996,7 +3002,7 @@ namespace AyaNova.PlugIn.V8
MatchCollection mc = AyaBizUtils.rxAyaImageTags.Matches(content); MatchCollection mc = AyaBizUtils.rxAyaImageTags.Matches(content);
foreach (Match m in mc) foreach (Match m in mc)
{ {
var RavenId = GetMap(new Guid(m.Groups["guid"].Value), "Object id for Wiki export (tid:" + tid.ToString()+")"); //Map[new Guid(m.Groups["guid"].Value)]; var RavenId = GetMap(new Guid(m.Groups["guid"].Value), "Object id for Wiki export (tid:" + tid.ToString() + ")"); //Map[new Guid(m.Groups["guid"].Value)];
content = content.Replace(m.Value, "<img src=\"" + "[ATTACH:" + RavenId.ToString() + "]" + "\">"); content = content.Replace(m.Value, "<img src=\"" + "[ATTACH:" + RavenId.ToString() + "]" + "\">");
} }

View File

@@ -201,6 +201,9 @@
<Compile Include="GZTW.AyaNova.BLL\ClientExistanceChecker.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientExistanceChecker.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientNoteEr.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientNoteEr.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientNoteList.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientNoteList.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientNotificationList.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GZTW.AyaNova.BLL\ClientPopUpNotesFetcher.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientPopUpNotesFetcher.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientServiceRequestListRI.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientServiceRequestListRI.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientServiceRequestNameFetcher.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientServiceRequestNameFetcher.cs" />
@@ -269,7 +272,6 @@
<Compile Include="GZTW.AyaNova.BLL\ClientWorkorderList.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientWorkorderList.cs" />
<Compile Include="GZTW.AyaNova.BLL\AyaFile.cs" /> <Compile Include="GZTW.AyaNova.BLL\AyaFile.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientNotifyEvent.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientNotifyEvent.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientNotificationList.cs" />
<Compile Include="GZTW.AyaNova.BLL\AddressFieldPickList.cs" /> <Compile Include="GZTW.AyaNova.BLL\AddressFieldPickList.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientWorkorderListEx.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientWorkorderListEx.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientNotesReportList.cs" /> <Compile Include="GZTW.AyaNova.BLL\ClientNotesReportList.cs" />
@@ -318,6 +320,7 @@
<Compile Include="GZTW.AyaNova.BLL\UnitMeterReadingListRI.cs" /> <Compile Include="GZTW.AyaNova.BLL\UnitMeterReadingListRI.cs" />
<Compile Include="GZTW.AyaNova.BLL\UnitOfMeasurePickList.cs" /> <Compile Include="GZTW.AyaNova.BLL\UnitOfMeasurePickList.cs" />
<Compile Include="GZTW.AyaNova.BLL\UnitServiceTypePickList.cs" /> <Compile Include="GZTW.AyaNova.BLL\UnitServiceTypePickList.cs" />
<Compile Include="GZTW.AyaNova.BLL\UserMemoIdList.cs" />
<Compile Include="GZTW.AyaNova.BLL\UserTypeFetcher.cs" /> <Compile Include="GZTW.AyaNova.BLL\UserTypeFetcher.cs" />
<Compile Include="GZTW.AyaNova.BLL\UserTimeZoneOffsetFetcher.cs" /> <Compile Include="GZTW.AyaNova.BLL\UserTimeZoneOffsetFetcher.cs" />
<Compile Include="GZTW.AyaNova.BLL\WikiPageExistanceChecker.cs" /> <Compile Include="GZTW.AyaNova.BLL\WikiPageExistanceChecker.cs" />

File diff suppressed because it is too large Load Diff

View File

@@ -20,78 +20,78 @@ namespace GZTW.AyaNova.BLL
{ {
#pragma warning disable 1591 #pragma warning disable 1591
/// <summary> /// <summary>
/// Lightweight read only list of <see cref="MemoList.MemoListInfo"/> objects representing <see cref="Memo"/> object /// Lightweight read only list of <see cref="MemoList.MemoListInfo"/> objects representing <see cref="Memo"/> object
/// ///
/// </summary> /// </summary>
[Serializable] [Serializable]
public class MemoList : ReadOnlyCollectionBase public class MemoList : ReadOnlyCollectionBase
{ {
#region Data structure #region Data structure
/// <summary> /// <summary>
/// Properties /// Properties
/// </summary> /// </summary>
[Serializable] [Serializable]
public struct MemoListInfo public struct MemoListInfo
{ {
internal Guid mID; internal Guid mID;
internal SmartDate mCreated; internal SmartDate mCreated;
internal GridRelativeTimeCellItem mCreatedRelative; internal GridRelativeTimeCellItem mCreatedRelative;
internal GridNameValueCellItem mSubject; internal GridNameValueCellItem mSubject;
internal string mMessage; internal string mMessage;
internal GridNameValueCellItem mFrom; internal GridNameValueCellItem mFrom;
//internal Guid mFrom; //internal Guid mFrom;
internal bool mViewed; internal bool mViewed;
internal bool mReplied; internal bool mReplied;
//ID Not localized as it's an invisible field //ID Not localized as it's an invisible field
[Display(DisplayType.Hidden)] [Display(DisplayType.Hidden)]
public Guid ID public Guid ID
{ {
get get
{ {
return mID; return mID;
} }
} }
[SqlColumnNameAttribute("aMemo.aCreated"), Display(DisplayType.DateTime)] [SqlColumnNameAttribute("aMemo.aCreated"),Display(DisplayType.DateTime)]
public object LT_Memo_Label_Sent public object LT_Memo_Label_Sent
{ {
get get
{ {
return mCreated.DBValue; return mCreated.DBValue;
} }
} }
[SqlColumnNameAttribute("grid"), Display(DisplayType.Text)] [SqlColumnNameAttribute("grid"), Display(DisplayType.Text)]
public GridRelativeTimeCellItem LT_Memo_Label_Sent_Relative public GridRelativeTimeCellItem LT_Memo_Label_Sent_Relative
{ {
get get
{ {
return mCreatedRelative; return mCreatedRelative;
} }
} }
[SqlColumnNameAttribute("aUser.aLastName", [SqlColumnNameAttribute("aUser.aLastName",
"aMemo.aFromID"), "aMemo.aFromID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Client)] Display(DisplayType.Button, RootObjectType = RootObjectTypes.Client)]
public GridNameValueCellItem LT_Memo_Label_FromID public GridNameValueCellItem LT_Memo_Label_FromID
{ {
get get
{ {
return mFrom; return mFrom;
} }
} }
[SqlColumnNameAttribute("aMemo.aSubject", "aMemo.aID"), Display(DisplayType.Button, RootObjectType = RootObjectTypes.Memo)] [SqlColumnNameAttribute("aMemo.aSubject", "aMemo.aID"), Display(DisplayType.Button, RootObjectType = RootObjectTypes.Memo)]
public GridNameValueCellItem LT_Memo_Label_Subject public GridNameValueCellItem LT_Memo_Label_Subject
{ {
get get
{ {
return mSubject; return mSubject;
} }
} }
[Display(DisplayType.Hidden)] [Display(DisplayType.Hidden)]
public string LT_Memo_Label_Message public string LT_Memo_Label_Message
@@ -103,118 +103,118 @@ namespace GZTW.AyaNova.BLL
} }
[SqlColumnNameAttribute("aMemo.aViewed"), Display(DisplayType.Hidden)]//case 1805 added column name attribute so can set criteria for dashboard [SqlColumnNameAttribute("aMemo.aViewed"), Display(DisplayType.Hidden)]//case 1805 added column name attribute so can set criteria for dashboard
public bool LT_Memo_Label_Viewed public bool LT_Memo_Label_Viewed
{ {
get get
{ {
return mViewed; return mViewed;
} }
} }
//Special control, i.e. in this case image checkbox showing replied graphic or not replied graphic //Special control, i.e. in this case image checkbox showing replied graphic or not replied graphic
[Display(DisplayType.SpecialControl)] [Display(DisplayType.SpecialControl)]
public bool LT_Memo_Label_Replied public bool LT_Memo_Label_Replied
{ {
get get
{ {
return this.mReplied; return this.mReplied;
} }
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="obj"></param> /// <param name="obj"></param>
public bool Equals(MemoListInfo obj) public bool Equals(MemoListInfo obj)
{ {
return this.ID.Equals(obj.ID); return this.ID.Equals(obj.ID);
} }
}//end MemoListInfo }//end MemoListInfo
#endregion #endregion
#region Constructor #region Constructor
private RelativeTimeFormatter rtfm = null; private RelativeTimeFormatter rtfm=null;
protected MemoList() protected MemoList()
{ {
rtfm = RelativeTimeFormatter.GetItem(User.CurrentUserLanguage); rtfm=RelativeTimeFormatter.GetItem(User.CurrentUserLanguage);
// AllowSort=false; // AllowSort=false;
// AllowFind=true; // AllowFind=true;
// AllowEdit=false; // AllowEdit=false;
// AllowNew=false; // AllowNew=false;
// AllowRemove=false; // AllowRemove=false;
} }
#endregion #endregion
#region Business properties and methods #region Business properties and methods
/// <summary> /// <summary>
/// Get item by index /// Get item by index
/// </summary> /// </summary>
/// <param name="Item"></param> /// <param name="Item"></param>
public MemoListInfo this[int Item] public MemoListInfo this[int Item]
{ {
get get
{ {
return (MemoListInfo)List[Item]; return (MemoListInfo) List[Item];
} }
} }
/// <summary> /// <summary>
/// Returns display text that matches passed in itemid value /// Returns display text that matches passed in itemid value
/// </summary> /// </summary>
/// <param name="ItemID"></param> /// <param name="ItemID"></param>
public string this[Guid ItemID] public string this[Guid ItemID]
{ {
get get
{ {
foreach (MemoListInfo child in List) foreach (MemoListInfo child in List)
{ {
if (child.ID == ItemID) return child.ToString(); if(child.ID==ItemID) return child.ToString();
} }
return "Missing: " + ItemID.ToString(); return "Missing: "+ItemID.ToString();
} }
} }
#endregion #endregion
#region contains #region contains
/// <summary> /// <summary>
/// Check if item in collection /// Check if item in collection
/// </summary> /// </summary>
/// <param name="obj"></param> /// <param name="obj"></param>
public bool Contains(MemoListInfo obj) public bool Contains(MemoListInfo obj)
{ {
foreach (MemoListInfo child in List) foreach (MemoListInfo child in List)
{ {
if (child.Equals(obj)) return true; if(child.Equals(obj)) return true;
} }
return false; return false;
} }
#endregion #endregion
#region Reporting and shared UI editor helpers #region Reporting and shared UI editor helpers
/// <summary> /// <summary>
/// Returns the report key which is a property of /// Returns the report key which is a property of
/// reports used to link all reports that can be used /// reports used to link all reports that can be used
/// with a particular data source. /// with a particular data source.
/// </summary> /// </summary>
public static string ReportKey public static string ReportKey
{ {
get get
{ {
return "MemoList"; return "MemoList";
} }
} }
/// <summary> /// <summary>
/// Returns the Detailed report key /// Returns the Detailed report key
@@ -298,9 +298,9 @@ namespace GZTW.AyaNova.BLL
} }
} }
#endregion #endregion
#region Static methods #region Static methods
/// <summary> /// <summary>
/// Internal method used by list factory /// Internal method used by list factory
@@ -310,16 +310,16 @@ namespace GZTW.AyaNova.BLL
return (MemoList)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords)); return (MemoList)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords));
} }
/// <summary> /// <summary>
/// Get all Memo (filtered by crit) /// Get all Memo (filtered by crit)
/// </summary> /// </summary>
/// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param> /// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
/// <returns>list of <see cref="MemoList.MemoListInfo"/> objects</returns> /// <returns>list of <see cref="MemoList.MemoListInfo"/> objects</returns>
public static MemoList GetList(string xmlCriteria) public static MemoList GetList(string xmlCriteria)
{ {
return (MemoList)DataPortal.Fetch(new Criteria(xmlCriteria, null, -1)); return (MemoList)DataPortal.Fetch(new Criteria(xmlCriteria, null, -1));
} }
/// <summary> /// <summary>
/// Takes a single ID and returns a "list" of one object /// Takes a single ID and returns a "list" of one object
@@ -349,73 +349,60 @@ namespace GZTW.AyaNova.BLL
return (MemoList)DataPortal.Fetch(new Criteria("", IDList, -1)); return (MemoList)DataPortal.Fetch(new Criteria("", IDList, -1));
} }
/// <summary> /// <summary>
/// Return an empty list /// Return an empty list
/// used for initializing grid /// used for initializing grid
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static MemoList GetEmptyList() public static MemoList GetEmptyList()
{ {
return new MemoList(); return new MemoList();
} }
#endregion #endregion
#region DAL DATA ACCESS #region DAL DATA ACCESS
/// ///
/// <param name="Criteria"></param> /// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria) protected override void DataPortal_Fetch(object Criteria)
{ {
Criteria crit = (Criteria)Criteria; Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null; SafeDataReader dr = null;
DateTime dtNow = DBUtil.CurrentWorkingDateTime; DateTime dtNow = DBUtil.CurrentWorkingDateTime;
try try
{ {
if (crit.IDList != null) if (crit.IDList != null)
{ {
//v8 Migrate related change //Case 556
//this is a workaround to get all the memos even though the current user is not the recipient of all of them System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
if (crit.IDList.Count == 1 && crit.IDList[0] == new Guid("{BD608E8A-820C-46D1-9D81-4CCB6E71B213}"))//v8 migrate plugin id sbIN.Append(" WHERE (aMemo.aID in (");
foreach (Guid gItem in crit.IDList)
{ {
dr = DBUtil.GetReaderFromSQLString( sbIN.Append("'");
"SELECT aMemo.aID, aMemo.aCreated, " + sbIN.Append("{");
"aMemo.aViewed, aMemo.aReplied, aMemo.aSubject, aMemo.aMessage, " + sbIN.Append(gItem.ToString().ToUpperInvariant());
"aMemo.aFromID, aMemo.aToId, " + sbIN.Append("}");
"'first' as afirstname, 'last' as alastname, 'ii' as ainitials, 'en' as aemployeenumber, 'r' as aregionname " + sbIN.Append("',");
"FROM aMemo order by amemo.acreated");
} }
else sbIN.Length = sbIN.Length - 1;
{ sbIN.Append(")) ");
//Case 556
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
sbIN.Append(" WHERE (aMemo.aID in (");
foreach (Guid gItem in crit.IDList)
{
sbIN.Append("'");
sbIN.Append("{");
sbIN.Append(gItem.ToString().ToUpperInvariant());
sbIN.Append("}");
sbIN.Append("',");
}
sbIN.Length = sbIN.Length - 1;
sbIN.Append(")) ");
//************************************************************ //************************************************************
dr = DBUtil.GetReaderFromSQLString( dr = DBUtil.GetReaderFromSQLString(
"SELECT aMemo.aID, aMemo.aCreated, " + "SELECT aMemo.aID, aMemo.aCreated, " +
"aMemo.aViewed, aMemo.aReplied, aMemo.aSubject, aMemo.aMessage, " + "aMemo.aViewed, aMemo.aReplied, aMemo.aSubject, aMemo.aMessage, " +
"aMemo.aFromID, aUser.aFirstName, aUser.aLastName, aUser.aInitials, AREGION.ANAME AS AREGIONNAME, " + "aMemo.aFromID, aUser.aFirstName, aUser.aLastName, aUser.aInitials, AREGION.ANAME AS AREGIONNAME, " +
"aUser.aEmployeeNumber FROM aMemo " + "aUser.aEmployeeNumber FROM aMemo " +
" LEFT OUTER JOIN aUser ON aMemo.aFromID = aUser.aID " +
" LEFT OUTER JOIN AREGION ON (AUSER.AREGIONID=AREGION.AID) " +
sbIN.ToString() + " " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML));
" LEFT OUTER JOIN aUser ON aMemo.aFromID = aUser.aID " +
" LEFT OUTER JOIN AREGION ON (AUSER.AREGIONID=AREGION.AID) " +
sbIN.ToString() + " " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML));
}
} }
@@ -441,20 +428,20 @@ namespace GZTW.AyaNova.BLL
dr = DBUtil.GetReaderFromSQLString(q, CurrentUserID); dr = DBUtil.GetReaderFromSQLString(q, CurrentUserID);
} }
while (dr.Read()) while(dr.Read())
{ {
//******************************************* //*******************************************
MemoListInfo info = new MemoListInfo(); MemoListInfo info=new MemoListInfo();
info.mID = dr.GetGuid("aID"); info.mID=dr.GetGuid("aID");
info.mCreated = DBUtil.ToLocal(dr.GetSmartDate("aCreated")); info.mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
info.mCreatedRelative = new GridRelativeTimeCellItem(rtfm.Format(dtNow, info.mCreated)); info.mCreatedRelative = new GridRelativeTimeCellItem(rtfm.Format(dtNow,info.mCreated));
info.mFrom = new GridNameValueCellItem( info.mFrom=new GridNameValueCellItem(
dr.GetGuid("aFromID"), dr.GetGuid("aFromID"),
User.NameFormatter(dr.GetString("aFirstName"), dr.GetString("aLastName"), dr.GetString("aInitials"), User.NameFormatter(dr.GetString("aFirstName"),dr.GetString("aLastName"),dr.GetString("aInitials"),
dr.GetString("aEmployeeNumber"), dr.GetString("AREGIONNAME"), AyaBizUtils.GlobalSettings.DefaultScheduleableUserNameDisplayFormat) dr.GetString("aEmployeeNumber"), dr.GetString("AREGIONNAME"), AyaBizUtils.GlobalSettings.DefaultScheduleableUserNameDisplayFormat)
, RootObjectTypes.User); ,RootObjectTypes.User);
info.mSubject = new GridNameValueCellItem( info.mSubject = new GridNameValueCellItem(
dr.GetGuid("aID"), dr.GetGuid("aID"),
@@ -462,24 +449,24 @@ namespace GZTW.AyaNova.BLL
RootObjectTypes.Memo); RootObjectTypes.Memo);
info.mViewed = dr.GetBoolean("aViewed"); info.mViewed=dr.GetBoolean("aViewed");
info.mReplied = dr.GetBoolean("aReplied"); info.mReplied=dr.GetBoolean("aReplied");
info.mMessage = dr.GetString("aMessage"); info.mMessage = dr.GetString("aMessage");
InnerList.Add(info); InnerList.Add(info);
//******************************************* //*******************************************
} }
} }
finally finally
{ {
if (dr != null) dr.Close(); if(dr!=null) dr.Close();
} }
} }
#endregion #endregion
#region criteria #region criteria
/// <summary> /// <summary>
/// Criteria for identifying existing object /// Criteria for identifying existing object
/// </summary> /// </summary>
@@ -496,8 +483,8 @@ namespace GZTW.AyaNova.BLL
MaxRecords = _MaxRecords; MaxRecords = _MaxRecords;
} }
} }
#endregion #endregion
}//end MemoList }//end MemoList
#pragma warning restore 1591 #pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL }//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,188 @@
///////////////////////////////////////////////////////////
// UserMemoIdList.cs
// Implementation of Class UserMemoIdList
// CSLA type: Read only collection
// Created on: 11-Dec-2008
// Object design: John
// Coded: 11-Dec-2008
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// List of UserMemoIds for internal migration processing
///
/// </summary>
[Serializable]
public class UserMemoIdList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct UserMemoIdListInfo
{
public Guid mID;
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(UserMemoIdListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end UserMemoIdListInfo
#endregion
#region Constructor
protected UserMemoIdList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public UserMemoIdListInfo this[int Item]
{
get
{
return (UserMemoIdListInfo)List[Item];
}
}
/// <summary>
/// Returns UserMemoIdListInfo item that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public UserMemoIdListInfo this[Guid ItemID]
{
get
{
foreach (UserMemoIdListInfo child in List)
{
if (child.mID == ItemID) return child;
}
throw new ArgumentException("UserMemoIdList: ID not found:\r\n" + ItemID.ToString());
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(UserMemoIdListInfo obj)
{
foreach (UserMemoIdListInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get all for user
/// </summary>
/// <returns></returns>
public static UserMemoIdList GetList(Guid UserId)
{
return (UserMemoIdList)DataPortal.Fetch(new Criteria(UserId));
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
//case 1163
//SmartDate rightnow=new SmartDate(DateTime.Now);
DateTime dtNowUTC = DateTime.Now.ToUniversalTime();
dr = DBUtil.GetReaderFromSQLString(
//************************************************************
"SELECT AMEMO.AID FROM AMEMO WHERE ATOID=@ID",crit.ID
//************************************************************
)
;
while (dr.Read())
{
//*******************************************
UserMemoIdListInfo info = new UserMemoIdListInfo();
info.mID = dr.GetGuid("aID");
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Criteria(Guid _ID)
{
ID = _ID;
}
}
#endregion
}//end UserMemoIdList
}//end namespace GZTW.AyaNova.BLL