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

@@ -1859,48 +1859,54 @@ namespace AyaNova.PlugIn.V8
progress.Op("Start Memos export"); progress.Op("Start Memos export");
progress.SubOp(""); progress.SubOp("");
var ObjectTypeName = "Memo"; var ObjectTypeName = "Memo";
//Step 2: export the objects
MemoList pl = MemoList.GetListForSingleItem(PluginID);
progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s");
foreach (MemoList.MemoListInfo i in pl)
{
if (!progress.KeepGoing) return;
List<string> tags = new List<string>(); List<string> tags = new List<string>();
tags.Add(ImportTag); tags.Add(ImportTag);
//Get all user id's then get all memo id's for each user id then fetch each memo and finally export
UserPickList upl = UserPickList.GetList(false);
foreach (UserPickList.UserPickListInfo upli in upl)
{
if (!progress.KeepGoing) return;
UserMemoIdList umidl = UserMemoIdList.GetList(upli.ID);
foreach (UserMemoIdList.UserMemoIdListInfo mid in umidl)
{
if (!progress.KeepGoing) return;
Memo mem = Memo.GetItem(mid.mID, PluginID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = i.LT_Memo_Label_Subject.Display; dynamic dmemo = new JObject();
d.notes = i.LT_Memo_Label_Message; dynamic duserid = new JArray();
//d.customFields = "{}"; dmemo.name = mem.Subject;
//d.tags = "[]"; dmemo.notes = mem.Message;
d.viewed = i.LT_Memo_Label_Viewed; dmemo.viewed = mem.Viewed;
d.replied = i.LT_Memo_Label_Replied; dmemo.replied = mem.Replied;
d.fromId = SafeGetUserMap(i.LT_Memo_Label_FromID.Value); var RavenFromId=SafeGetUserMap(mem.FromID);
d.sent = i.LT_Memo_Label_Sent; dmemo.fromId = RavenFromId;
dmemo.sent = mem.Created;
progress.Op(ObjectTypeName + " " + i.ID.ToString());
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()); var rMainObject = await util.PostAsync("memo", d.ToString());
long RavenId = util.IdFromResponse(rMainObject); long RavenId = util.IdFromResponse(rMainObject);
//-----
d = rMainObject.ObjectResponse["data"]; d = rMainObject.ObjectResponse["data"];
//----- //-----
//Event log fixup //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()); await util.EventLog(util.AyaType.Project, RavenId, RavenFromId, RavenFromId, mem.Created, mem.Modified);
} }
} }
//------
}
#endregion Memos #endregion Memos
#region Service Workorders #region Service Workorders

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" />

View File

@@ -44,6 +44,9 @@ namespace GZTW.AyaNova.BLL
private Guid mToID; private Guid mToID;
private bool mViewed; private bool mViewed;
//case 3832
private bool mReplied;
#endregion #endregion
@@ -302,6 +305,16 @@ namespace GZTW.AyaNova.BLL
} }
} }
//case 3832
public bool Replied
{
get
{
return mViewed;
}
}
/// <summary> /// <summary>
/// Throw an error when a read only user /// Throw an error when a read only user
/// tries to set a property /// tries to set a property
@@ -458,8 +471,11 @@ namespace GZTW.AyaNova.BLL
/// ///
/// <param Subject="_ID">Memo Guid</param> /// <param Subject="_ID">Memo Guid</param>
public static Memo GetItem(Guid _ID) public static Memo GetItem(Guid _ID, Guid __ID)//case 3832 for v8 migrate
{ {
if (__ID == new Guid("{BD608E8A-820C-46D1-9D81-4CCB6E71B213}"))
return (Memo)DataPortal.Fetch(new Criteria(_ID));
else
//Memo is write only, once it's sent you can't retrieve it again //Memo is write only, once it's sent you can't retrieve it again
throw new System.Security.SecurityException( throw new System.Security.SecurityException(
string.Format( string.Format(
@@ -537,51 +553,51 @@ namespace GZTW.AyaNova.BLL
#region DAL DATA ACCESS #region DAL DATA ACCESS
#region Fetch #region Fetch
// /// //case 3832
// /// <param Subject="Criteria"></param> protected override void DataPortal_Fetch(object Criteria)
// protected override void DataPortal_Fetch(object Criteria) {
// { //set to false to load items initially
// //set to false to load items initially bReadOnly = false;
// bReadOnly=false;
// Criteria crit = (Criteria)Criteria;
// Criteria crit = (Criteria)Criteria; SafeDataReader dr = null;
// SafeDataReader dr = null; try
// try {
// { dr = DBUtil.GetReaderFromSQLString("SELECT * FROM aMemo WHERE aID=@ID;", crit.ID);
// dr=DBUtil.GetReaderFromSQLString("SELECT * FROM aMemo WHERE aID=@ID;",crit.ID); if (!dr.Read())
// if(!dr.Read()) DBUtil.ThrowFetchError("Memo ID: " + crit.ID.ToString());
// DBUtil.ThrowFetchError("Memo ID: " + crit.ID.ToString());
// //Standard fields
// //Standard fields mID = dr.GetGuid("aID");
// mID=dr.GetGuid("aID"); mCreated = DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
// mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated")); mModified = DBUtil.ToLocal(dr.GetSmartDate("aModified"));
// mModified=DBUtil.ToLocal(dr.GetSmartDate("aModified")); mCreator = dr.GetGuid("aCreator");
// mCreator=dr.GetGuid("aCreator"); mModifier = dr.GetGuid("aModifier");
// mModifier=dr.GetGuid("aModifier");
//
// //Memo fields
// //Memo fields //Important: use property not internal field
// //Important: use property not internal field //so that initial broken rule is unbroken on fetch
// //so that initial broken rule is unbroken on fetch Subject = dr.GetString("aSubject");
// Subject=dr.GetString("aSubject"); mMessage = dr.GetString("aMessage");
// mMessage=dr.GetString("aMessage"); mFromID = dr.GetGuid("aFromID");
// mFromID=dr.GetGuid("aFromID"); mToID = dr.GetGuid("aToID");
// mToID=dr.GetGuid("aToID"); mViewed = dr.GetBoolean("aViewed");
// mViewed=dr.GetBoolean("aViewed"); mReplied = dr.GetBoolean("aReplied");
//
//
// } }
// finally finally
// { {
// if(dr!=null) dr.Close(); if (dr != null) dr.Close();
// } }
// MarkOld(); MarkOld();
//
//
// //Get access rights level //Get access rights level
// bReadOnly=AyaBizUtils.Right("Object.Memo")<(int)SecurityLevelTypes.ReadWrite; bReadOnly = AyaBizUtils.Right("Object.Memo") < (int)SecurityLevelTypes.ReadWrite;
// } }
//
#endregion fetch #endregion fetch
#region Update #region Update
@@ -888,7 +904,8 @@ namespace GZTW.AyaNova.BLL
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Description("LT:Memo.Label.Event.Created")] Created=1 [Description("LT:Memo.Label.Event.Created")]
Created = 1
} }
#endregion #endregion

View File

@@ -376,19 +376,6 @@ namespace GZTW.AyaNova.BLL
{ {
if (crit.IDList != null) if (crit.IDList != null)
{
//v8 Migrate related change
//this is a workaround to get all the memos even though the current user is not the recipient of all of them
if (crit.IDList.Count == 1 && crit.IDList[0] == new Guid("{BD608E8A-820C-46D1-9D81-4CCB6E71B213}"))//v8 migrate plugin id
{
dr = DBUtil.GetReaderFromSQLString(
"SELECT aMemo.aID, aMemo.aCreated, " +
"aMemo.aViewed, aMemo.aReplied, aMemo.aSubject, aMemo.aMessage, " +
"aMemo.aFromID, aMemo.aToId, " +
"'first' as afirstname, 'last' as alastname, 'ii' as ainitials, 'en' as aemployeenumber, 'r' as aregionname " +
"FROM aMemo order by amemo.acreated");
}
else
{ {
//Case 556 //Case 556
System.Text.StringBuilder sbIN = new System.Text.StringBuilder(); System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
@@ -415,7 +402,7 @@ namespace GZTW.AyaNova.BLL
" LEFT OUTER JOIN AREGION ON (AUSER.AREGIONID=AREGION.AID) " + " LEFT OUTER JOIN AREGION ON (AUSER.AREGIONID=AREGION.AID) " +
sbIN.ToString() + " " + sbIN.ToString() + " " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML)); AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML));
}
} }

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