优化:更新遥测代码,统一上传文件

pull/1443/MERGE
ChenX 4 years ago
parent 34331f8a26
commit f2980177a0

@ -1,11 +1,9 @@
import { end } from 'xaop'; import { end } from 'xaop';
import { app } from '../ApplicationServices/Application'; import { app } from '../ApplicationServices/Application';
import { ReportError } from '../Common/ErrorMonitoring';
import { safeEval } from '../Common/eval'; import { safeEval } from '../Common/eval';
import { KeyWord } from '../Common/InputState'; import { KeyWord } from '../Common/InputState';
import { KeyCode } from '../Common/KeyEnum'; import { KeyCode } from '../Common/KeyEnum';
import { FixedNotZero } from '../Common/Utils'; import { FixedNotZero } from '../Common/Utils';
import { CADFiler } from '../DatabaseServices/CADFiler';
import { Board } from '../DatabaseServices/Entity/Board'; import { Board } from '../DatabaseServices/Entity/Board';
import { Curve } from '../DatabaseServices/Entity/Curve'; import { Curve } from '../DatabaseServices/Entity/Curve';
import { Polyline } from '../DatabaseServices/Entity/Polyline'; import { Polyline } from '../DatabaseServices/Entity/Polyline';
@ -67,27 +65,15 @@ export class CommandFillet implements Command
res2.Entity.UpdateJigMaterial(); res2.Entity.UpdateJigMaterial();
lastCu = res2.Entity as Curve; lastCu = res2.Entity as Curve;
try let fres = this.m_FilletUtils.Fillet(enRes1, res2);
if (fres)
{ {
let fres = this.m_FilletUtils.Fillet(enRes1, res2); if (fres.arc)
if (fres) JigUtils.Draw(fres.arc);
{ if (fres.cu1)
if (fres.arc) JigUtils.Draw(fres.cu1);
JigUtils.Draw(fres.arc); if (fres.cu2)
if (fres.cu1) JigUtils.Draw(fres.cu2);
JigUtils.Draw(fres.cu1);
if (fres.cu2)
JigUtils.Draw(fres.cu2);
}
}
catch (error)
{
let f = new CADFiler;
f.WriteObject(enRes1.Entity);
f.Write(enRes1.Point.toArray());
f.WriteObject(enRes2.Entity);
f.Write(enRes2.Point.toArray());
ReportError(f.ToString(), "倒角失败");
} }
app.Editor.UpdateScreen(); app.Editor.UpdateScreen();

@ -233,14 +233,14 @@ export class SaveAsBinary implements Command
} }
//有时候打开的图纸我们无法撤销,这是预期内的,因为我们备份的文件是PU过的,此时我们的历史记录尝试去还原这个操作的时候就会出错 //有时候打开的图纸我们无法撤销,这是预期内的,因为我们备份的文件是PU过的,此时我们的历史记录尝试去还原这个操作的时候就会出错
function UploadFileHistory(file: any) export function UploadFileHistory(file: any, historyCount = 3)
{ {
let fileServer = FileServer.GetInstance() as FileServer; let fileServer = FileServer.GetInstance() as FileServer;
let fileId = fileServer.m_CurFileId; let fileId = fileServer.m_CurFileId;
let userName = localStorage.getItem(StoreageKeys.UserName); let userName = localStorage.getItem(StoreageKeys.UserName);
//记录历史记录 //记录历史记录
let hisStart = app.Database.hm.curIndex - 3 + 1;//前n条历史记录 let hisStart = app.Database.hm.curIndex - historyCount + 1;//前n条历史记录
let hisIndex = app.Database.hm.curIndex; let hisIndex = app.Database.hm.curIndex;
//修正当前开始位置 //修正当前开始位置
if (hisStart < 0) if (hisStart < 0)
@ -248,7 +248,7 @@ function UploadFileHistory(file: any)
else else
hisIndex -= hisStart; hisIndex -= hisStart;
let hisEnd = Math.min(app.Database.hm.historyRecord.length, app.Database.hm.curIndex + 3 + 1);//后n条历史记录 let hisEnd = Math.min(app.Database.hm.historyRecord.length, app.Database.hm.curIndex + historyCount + 1);//后n条历史记录
let hisf = new CADFiler(); let hisf = new CADFiler();
//参考HistoryManager的序列化 //参考HistoryManager的序列化

@ -1,4 +1,7 @@
import { UploadFileHistory } from "../Add-on/Save";
import { app } from "../ApplicationServices/Application";
import { FileServer } from "../DatabaseServices/FileServer"; import { FileServer } from "../DatabaseServices/FileServer";
import { deflate } from "./SerializeMaterial";
import { StoreageKeys } from "./StoreageKeys"; import { StoreageKeys } from "./StoreageKeys";
const { detect } = require('detect-browser'); const { detect } = require('detect-browser');
@ -70,10 +73,34 @@ export async function ReportError(stack: any, msg: string = "未捕获的错误!
'content-type': 'application/json' 'content-type': 'application/json'
}, },
}); });
//将图纸上传到备份文件
// if (CURRENT_HOST === "https://chenfeng.tech:7779")
ReportFile();
console.log("上报成功"); console.log("上报成功");
} }
catch (error) catch (error)
{ {
console.log("上报失败", error); console.log("上报失败", error);
} }
function ReportFile()
{
//备份,清理
let hrBak = app.Database.hm.historyRecord;
let hrIndex = app.Database.hm.curIndex;
app.Database.hm.historyRecord = [];
app.Database.hm.curIndex = -1;
let fileData = app.FileOut().Data;
//还原
app.Database.hm.historyRecord = hrBak;
app.Database.hm.curIndex = hrIndex;
let file = JSON.stringify(fileData);
file = deflate(file);
UploadFileHistory(file, 50);
}
} }

Loading…
Cancel
Save