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))
{
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];
}
@@ -303,7 +303,7 @@ namespace AyaNova.PlugIn.V8
progress.Op("Exporting Business objects");
//BIZ objects
await ExportLocales(progress);
await ExportStaffUsers(progress);
await ExportStaffUsers(progress);
await ExportContracts(progress);
await ExportHeadOffices(progress);
await ExportClients(progress);
@@ -318,7 +318,7 @@ namespace AyaNova.PlugIn.V8
await ExportVendors(progress);
await ExportExternalUsers(progress);//needs vendors, clients and headoffices already exported so needs to be here late
await ExportMemos(progress);
await ExportServiceWorkorders(progress);
//todo: these are now invalid and awaiting RAVEN end implementation
//after which can copy mostly from service workorder block
@@ -852,8 +852,8 @@ namespace AyaNova.PlugIn.V8
d.webAddress = c.WebAddress;
d.popUpNotes = c.PopUpNotes;
d.billHeadOffice = c.BillHeadOffice;
if (c.HeadOfficeID != Guid.Empty)
{
d.headOfficeId = GetMap(c.HeadOfficeID, "HeadOffice for Client " + d.name);
@@ -861,7 +861,7 @@ namespace AyaNova.PlugIn.V8
d.techNotes = c.TechNotes;
d.accountNumber = c.AccountNumber;
d.usesBanking = c.UsesBanking;
if (c.ContractID != Guid.Empty)
{
d.contractId = GetMap(c.ContractID, "Contract for Client " + d.name);
@@ -1065,7 +1065,7 @@ namespace AyaNova.PlugIn.V8
{
d.contractId = GetMap(c.ContractID, "Contract for Head Office " + d.name);
}
d.contractExpires = c.ContractExpires;//?? dates
d.phone1 = c.Phone1;
d.phone2 = c.Phone2;
@@ -1755,19 +1755,19 @@ namespace AyaNova.PlugIn.V8
tags.Add(ImportTag);
Vendor c = Vendor.GetItem(i.ID);
var ObjectTID = new TypeAndID(RootObjectTypes.Vendor, c.ID);
var ObjectTID = new TypeAndID(RootObjectTypes.Vendor, c.ID);
dynamic d = new JObject();
d.name = GetUniqueName(c.Name);
if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue;
progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active;
d.notes = c.Notes;
d.contact = c.Contact;
d.contactNotes = c.ContactNotes;
d.contactNotes = c.ContactNotes;
d.webAddress = c.WebAddress;
d.accountNumber = c.AccountNumber;
d.phone1 = c.Phone1;
@@ -1859,47 +1859,53 @@ 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");
List<string> tags = new List<string>();
tags.Add(ImportTag);
foreach (MemoList.MemoListInfo i in pl)
//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;
List<string> tags = new List<string>();
tags.Add(ImportTag);
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 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());
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());
var rMainObject = await util.PostAsync("memo", d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
var rMainObject = await util.PostAsync("memo", d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
//-----
d = rMainObject.ObjectResponse["data"];
//-----
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());
//-----
//Event log fixup
await util.EventLog(util.AyaType.Project, RavenId, RavenFromId, RavenFromId, mem.Created, mem.Modified);
}
}
//------
}
#endregion Memos
@@ -2851,9 +2857,9 @@ namespace AyaNova.PlugIn.V8
else
RavenTypeAsString = ((int)util.RootObjectToAyaType(tid.RootObjectType)).ToString();
formDataContent.Add(new StringContent(RavenTypeAsString), name: "AttachToObjectType");
//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(dFileData.ToString()), name: "FileData");
@@ -2949,10 +2955,10 @@ namespace AyaNova.PlugIn.V8
else
RavenTypeAsString = ((int)util.RootObjectToAyaType(tid.RootObjectType)).ToString();
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(doc.Description + " (" + ImportTag + ")"), name: "Notes");
formDataContent.Add(new StringContent(dFileData.ToString()), name: "FileData");
@@ -2996,7 +3002,7 @@ namespace AyaNova.PlugIn.V8
MatchCollection mc = AyaBizUtils.rxAyaImageTags.Matches(content);
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() + "]" + "\">");
}