//备份(导出)按钮中的代码
function(button, e) { var grid = this.getView(); var recs = grid.getSelectionModel().getSelection(); var url='/Pc/XiTongPublic/HeChaYaoDian1Backup'; window.open(util.urlFillAll(url),'_blank'); }
//备份(导出)VS中的代码
/// </summary> [HttpGet] [DontNeedPermit] public void XKZBackup(Guid[] IDs) { #region 实现 var fileName = $"许可证导出{DateTime.Now.ToString("yyyy-MM-dd-HH-mm")}"; fileName += $".xlsx"; var ShuJus = _ioc.Query<XuKeZheng>(); // 默认全部备份 var excel = new Excel() .AddSheet(ShuJus.ToSheet()); excel.WriteToResponse(Response, fileName); excel.Close(); #endregion }
//恢复(导入)按钮中的代码
function(button, e) { var grid = this.getView(); var win = Ext.create('ux.win.Recover', { url: '/Pc/XiTongPublic/HeChaYaoDian1Recover', confirmMessage: '恢复数据将会清空现有相同名称的核查要点并且无法再恢复,确认吗?', listeners:{ close: function() { grid.getStore().reload(); } } }); grid.add(win); win.showBy(grid); //相对整个视图居中显示 }
//恢复(导入)VS中的代码
/// 核查要点表餐饮服务数据恢复 /// </summary> [HttpGet] [DontNeedPermit] public HyResultBase XKZRecover(Guid FileID) { #region 实现 var r = new HyResultBase(); string sFileName = UploadFile.GetFileSaveToTempFile(FileID); FileInfo file = new FileInfo(sFileName); if (!file.Exists) { r.Errors.Add("要导入的文件不存在,可能的原因:1、没有上传;2、虽已上传但目前已不存在;"); return r; } var excel = new Excel(sFileName); var msg = ""; var entityIDs = new List<Guid>(); var total = 0; IRepository<XuKeZheng> db = null; _ioc.Query<XuKeZheng>().Delete().SaveToDB(); // 以下注意恢复次序。以免产生外键约束错误 excel.GetSheet<XuKeZheng>().ForEach(e => { total++; e.Insert().MergingTempSave(db).SaveToTemp(out db); }); db?.SaveToDB(); excel.CloseAndDeleteFile(); r.Success = true; msg += " " + "-".Repeat(10); msg += $"共上传[{total}]个许可证数据!"; r.Messages.Add(msg + "-".Repeat(10)); return r; #endregion }