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.SubOp("");
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>();
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();
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());
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);
//-----
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());
await util.EventLog(util.AyaType.Project, RavenId, RavenFromId, RavenFromId, mem.Created, mem.Modified);
}
}
//------
}
#endregion Memos
#region Service Workorders

View File

@@ -201,6 +201,9 @@
<Compile Include="GZTW.AyaNova.BLL\ClientExistanceChecker.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientNoteEr.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\ClientServiceRequestListRI.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientServiceRequestNameFetcher.cs" />
@@ -269,7 +272,6 @@
<Compile Include="GZTW.AyaNova.BLL\ClientWorkorderList.cs" />
<Compile Include="GZTW.AyaNova.BLL\AyaFile.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\ClientWorkorderListEx.cs" />
<Compile Include="GZTW.AyaNova.BLL\ClientNotesReportList.cs" />
@@ -318,6 +320,7 @@
<Compile Include="GZTW.AyaNova.BLL\UnitMeterReadingListRI.cs" />
<Compile Include="GZTW.AyaNova.BLL\UnitOfMeasurePickList.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\UserTimeZoneOffsetFetcher.cs" />
<Compile Include="GZTW.AyaNova.BLL\WikiPageExistanceChecker.cs" />

View File

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

View File

@@ -376,19 +376,6 @@ namespace GZTW.AyaNova.BLL
{
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
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) " +
sbIN.ToString() + " " +
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