This commit is contained in:
2020-05-02 20:48:51 +00:00
parent 050f9fafef
commit 2a4ca525df

View File

@@ -149,7 +149,7 @@ namespace AyaNova.PlugIn.V8
} }
Opt dOpt = new Opt(); Opt dOpt = new Opt();
var ro = dOpt.ShowDialog(); var ro = dOpt.ShowDialog();
if (ro == DialogResult.Cancel) if (ro == DialogResult.Cancel)
{ {
return; return;
@@ -176,7 +176,7 @@ namespace AyaNova.PlugIn.V8
/// </summary> /// </summary>
private async void DoExport() private async void DoExport()
{ {
//Show progress form //Show progress form
ProgressForm progress = new ProgressForm(); ProgressForm progress = new ProgressForm();
progress.Show(); progress.Show();
@@ -187,7 +187,7 @@ namespace AyaNova.PlugIn.V8
progress.Op("Preparing to export...."); progress.Op("Preparing to export....");
Map.Clear(); Map.Clear();
TagMap.Clear(); TagMap.Clear();
LocaleMap.Clear(); LocaleMap.Clear();
@@ -249,15 +249,14 @@ namespace AyaNova.PlugIn.V8
progress.Op("Exporting objects"); progress.Op("Exporting objects");
//BIZ objects //BIZ objects
if (progress.KeepGoing) //if (progress.KeepGoing)
await ExportLocales(progress); // await ExportLocales(progress);
if (progress.KeepGoing) if (progress.KeepGoing)
await ExportUsers(progress); await ExportUsers(progress);
//dumpGlobalSettings(tempArchiveFolder, progress); //dumpGlobalSettings(tempArchiveFolder, progress);
@@ -294,7 +293,7 @@ namespace AyaNova.PlugIn.V8
finally finally
{ {
progress.FinishedImport(); progress.FinishedImport();
} }
@@ -325,7 +324,7 @@ namespace AyaNova.PlugIn.V8
{ {
User admin = User.GetItem(User.AdministratorID); User admin = User.GetItem(User.AdministratorID);
progress.Op("Administrator account"); progress.Op("Administrator account");
var adminTid=new TypeAndID(RootObjectTypes.User, User.AdministratorID); var adminTid = new TypeAndID(RootObjectTypes.User, User.AdministratorID);
//Attachments and wiki //Attachments and wiki
string AdminWikiContent = null; string AdminWikiContent = null;
var hasWiki = WikiPage.HasWiki(User.AdministratorID); var hasWiki = WikiPage.HasWiki(User.AdministratorID);
@@ -355,7 +354,7 @@ namespace AyaNova.PlugIn.V8
await util.PutAsync("User/1", d.ToString()); await util.PutAsync("User/1", d.ToString());
} }
} }
#endregion admin export #endregion admin export
@@ -373,7 +372,7 @@ namespace AyaNova.PlugIn.V8
User c = User.GetItem(i.ID); User c = User.GetItem(i.ID);
var UserTID=new TypeAndID(RootObjectTypes.User, c.ID); var UserTID = new TypeAndID(RootObjectTypes.User, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.FirstName + " " + c.LastName; d.name = c.FirstName + " " + c.LastName;
@@ -439,7 +438,10 @@ namespace AyaNova.PlugIn.V8
d = rOptions.ObjectResponse["data"]; d = rOptions.ObjectResponse["data"];
d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor)); d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor));
d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress; d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress;
d.translationId = LocaleMap[c.DefaultLanguage]; if (LocaleMap.ContainsKey(c.DefaultLanguage))
d.translationId = LocaleMap[c.DefaultLanguage];
else
d.translationId = 1;
await util.PutAsync("UserOptions/" + RavenId.ToString(), d.ToString()); await util.PutAsync("UserOptions/" + RavenId.ToString(), d.ToString());
} }
@@ -448,13 +450,16 @@ namespace AyaNova.PlugIn.V8
await ExportAttachments(UserTID, progress); await ExportAttachments(UserTID, progress);
//docs //docs
string NonFileUrls= await ExportDocs(UserTID, c.Docs, progress); string NonFileUrls = await ExportDocs(UserTID, c.Docs, progress);
if (!string.IsNullOrEmpty(NonFileUrls)) { if (!string.IsNullOrEmpty(NonFileUrls))
//need to repost the user with the notes modified {
d = rMainObject.ObjectResponse["data"]; //need to repost the user with the notes modified
d.notes = NonFileUrls + "\r\n-----------------\r\n" + d.notes; d = rMainObject.ObjectResponse["data"];
await util.PutAsync("User", d.ToString()); d.login = null;
} d.password = null;
d.notes = NonFileUrls + "\n-----------------\n" + d.notes;
await util.PutAsync("User/" + RavenId.ToString(), d.ToString());
}
} }
@@ -471,7 +476,7 @@ namespace AyaNova.PlugIn.V8
await util.EventLog(3, newId, creator, modifier, c.Created, c.Modified); await util.EventLog(3, newId, creator, modifier, c.Created, c.Modified);
} }
} }
#endregion clients #endregion clients
@@ -549,7 +554,7 @@ namespace AyaNova.PlugIn.V8
var exportName = i.Locale + " (" + RavenLocaleName + ")"; var exportName = i.Locale + " (" + RavenLocaleName + ")";
progress.SubOp(""); progress.SubOp("");
progress.Op("Exporting " + i.Locale + " to " + exportName); progress.Op("Exporting " + i.Locale + " to " + exportName);
var t = new util.NameIdItem { Name = exportName, Id = x }; var t = new util.NameIdItem { Name = exportName, Id = x };
a = await util.PostAsync("Translation/Duplicate", JObject.FromObject(t).ToString()); a = await util.PostAsync("Translation/Duplicate", JObject.FromObject(t).ToString());
var targetTranslationId = util.IdFromResponse(a); var targetTranslationId = util.IdFromResponse(a);
@@ -859,7 +864,7 @@ namespace AyaNova.PlugIn.V8
//-------------------------------------------- //--------------------------------------------
#endregion object export #endregion object export
#region Custom fields exporter #region Custom fields exporter
@@ -1048,11 +1053,11 @@ namespace AyaNova.PlugIn.V8
} }
#endregion attachments #endregion attachments
#region Assigned docs exporter #region Assigned docs exporter
private async System.Threading.Tasks.Task<string> ExportDocs(TypeAndID tid, AssignedDocs docs, ProgressForm progress) private async System.Threading.Tasks.Task<string> ExportDocs(TypeAndID tid, AssignedDocs docs, ProgressForm progress)
{ {
if (!ExportAssignedDocs) return null; if (!ExportAssignedDocs) return null;
@@ -1063,29 +1068,29 @@ namespace AyaNova.PlugIn.V8
foreach (AssignedDoc doc in docs) foreach (AssignedDoc doc in docs)
{ {
if (!progress.KeepGoing) return null; if (!progress.KeepGoing) return null;
//is it a local file? //is it a local file?
if (!new Uri(doc.URL).IsFile) if (!new Uri(doc.URL).IsFile)
{ {
NonFileUrls+=(doc.Description + "("+ImportTag+ ")\n" + doc.URL+"\n"); NonFileUrls += (doc.Description + "(" + ImportTag + ")\n" + doc.URL + "\n");
continue; continue;
} }
//can we see it? //can we see it?
if (!File.Exists(doc.URL)) if (!File.Exists(doc.URL))
{ {
NonFileUrls+=(ImportTag + " - Assigned doc. file not found:\n" + doc.Description + "\n" + doc.URL + "\n"); NonFileUrls += (ImportTag + " - Assigned doc. file not found:\n" + doc.Description + "\n" + doc.URL + "\n");
continue; continue;
} }
//get the file info //get the file info
FileInfo fi = new FileInfo(doc.URL); FileInfo fi = new FileInfo(doc.URL);
progress.SubOp("Assigned doc: \"" + doc.URL + "\" " + AyaBizUtils.FileSizeDisplay((decimal)fi.Length)); progress.SubOp("Assigned doc: \"" + doc.URL + "\" " + AyaBizUtils.FileSizeDisplay((decimal)fi.Length));
//Compile the FileData property //Compile the FileData property
DateTimeOffset dtLastModified = fi.LastWriteTimeUtc; DateTimeOffset dtLastModified = fi.LastWriteTimeUtc;
dynamic dFileData = new JArray(); dynamic dFileData = new JArray();
dynamic dFile = new JObject(); dynamic dFile = new JObject();
dFile.name = fi.Name; dFile.name = fi.Name;
@@ -1099,7 +1104,7 @@ namespace AyaNova.PlugIn.V8
//Form data like the bizobject type and id //Form data like the bizobject type and id
formDataContent.Add(new StringContent(util.RootObjectToAyaType(tid.RootObjectType).ToString()), name: "AttachToObjectType"); formDataContent.Add(new StringContent(util.RootObjectToAyaType(tid.RootObjectType).ToString()), 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(doc.Description+" ("+ImportTag+")"), name: "Notes"); formDataContent.Add(new StringContent(doc.Description + " (" + ImportTag + ")"), name: "Notes");
formDataContent.Add(new StringContent(dFileData.ToString()), name: "FileData"); formDataContent.Add(new StringContent(dFileData.ToString()), name: "FileData");
StreamContent AttachmentFile = new StreamContent(fi.OpenRead()); StreamContent AttachmentFile = new StreamContent(fi.OpenRead());