public IActionResult DeleteAll() { var state = false; var users = _context.EngineerInfo.ToList(); var user = this.GetAuthUser(); if (user.Power != 1) { return(StatusCode(403)); } foreach (var item in users) { _context.EngineerInfo.Remove(item); state = _context.SaveChanges() > 0; } if (state == true) { //成功时执行以下操作 //获取header中的token var providedApiKey = long.Parse(Request.Headers["Authorization"].ToString()); //获取日志信息 ModifyInfo NewModify = modify.DeleteInfo(DateTime.Now, "Engineer", users.Count(), providedApiKey); //保存日志信息 _context.Add(NewModify); } return(Json(new { success = state })); }
public IActionResult DeleteById(int id) { var state = false; var user = this.GetAuthUser(); if (user.Power != 2) { return(StatusCode(403)); } var u = _context.UserInfo.SingleOrDefault(s => s.ID == id); if (u != null) { _context.UserInfo.Remove(u); state = _context.SaveChanges() > 0; } if (state == true) { var providedApiKey = long.Parse(Request.Headers["Authorization"].ToString()); //获取日志信息 ModifyInfo NewModify = modify.DeleteInfo(DateTime.Now, "User", 1, providedApiKey); //保存日志信息 _context.Add(NewModify); } return(Json(new { sucess = state })); }
public async Task DeleteCharge(SimpleUser user, string id) { string cn = await Context.ChargeInfos.Where(x => x.ID == id).Select(x => x.ChargeNo).FirstOrDefaultAsync(); ChargeInfo ci = new ChargeInfo() { ID = id, IsDeleted = true, DeleteTime = DateTime.Now, DeleteUser = user.Id, ChargeNo = cn }; var entry = Context.ChargeInfos.Attach(ci); entry.Property(c => c.IsDeleted).IsModified = true; entry.Property(c => c.DeleteTime).IsModified = true; entry.Property(c => c.DeleteUser).IsModified = true; ModifyInfo mi = new ModifyInfo() { Id = Guid.NewGuid().ToString("N").ToLower(), ChargeId = id, CreateTime = DateTime.Now, CreateUser = user.Id, Department = user.OrganizationId, Type = ModifyTypeEnum.Deleted, TypeMemo = ModifyTypeConstans.Deleted }; Context.ModifyInfos.Add(mi); await Context.SaveChangesAsync(); }
public async Task <PaymentInfo> Payment(SimpleUser user, PaymentInfo payment) { decimal total = await Context.PaymentInfo.AsNoTracking().Where(x => x.ChargeId == payment.ChargeId).SumAsync(x => x.PaymentAmount); var old = await Context.PaymentInfo.Where(x => x.Id == payment.Id).FirstOrDefaultAsync(); if (old != null) { total = total - old.PaymentAmount; //更新 old.Memo = payment.Memo; old.Payee = payment.Payee; old.PaymentAmount = payment.PaymentAmount; old.PaymentDate = payment.PaymentDate; old.Status = payment.Status; } else { //新增 payment.CreateTime = DateTime.Now; payment.CreateUser = user.Id; payment.Department = user.OrganizationId; Context.PaymentInfo.Add(payment); } total = total + payment.PaymentAmount; var ci = await Context.ChargeInfos.AsNoTracking().Where(x => x.ID == payment.ChargeId).FirstOrDefaultAsync(); var entry = Context.ChargeInfos.Attach(ci); if (ci.ChargeAmount == total) { ci.IsPayment = true; ci.PaymentTime = payment.PaymentDate; } ci.PaymentAmount = total; ModifyInfo mi = new ModifyInfo() { Id = Guid.NewGuid().ToString("N").ToLower(), ChargeId = ci.ID, CreateTime = DateTime.Now, CreateUser = user.Id, Department = user.OrganizationId, Status = ci.Status, RelativeId = payment.Id, Type = ModifyTypeEnum.Payment, TypeMemo = ModifyTypeConstans.Payment }; Context.ModifyInfos.Add(mi); await Context.SaveChangesAsync(); payment.ChargeInfo = ci; return(payment); }
public IActionResult UpdataById(int id, [FromBody] UserInfo NewUser) { var u = _context.UserInfo.Update(NewUser); var user = this.GetAuthUser(); if (user.Power != 2) { return(StatusCode(403)); } if (u == null) { return(Json(new { sucess = false })); } try { var providedApiKey = long.Parse(Request.Headers["Authorization"].ToString()); //获取日志信息 ModifyInfo NewModify = modify.UpdataInfo(DateTime.Now, "User", 1, providedApiKey); //保存日志信息 _context.Add(NewModify); _context.SaveChanges(); } catch (Exception e) { return(Json(new { sucess = false })); } return(Json(new { sucess = true })); }
public IActionResult UpdataById(int id, [FromBody] EngineerInfo Newengineer) { var user = this.GetAuthUser(); if (user.Power != 1) { return(StatusCode(403)); } var u = _context.EngineerInfo.Update(Newengineer); if (u == null) { return(Json(new { success = false })); } //成功时执行以下操作 //获取header中的token var providedApiKey = long.Parse(Request.Headers["Authorization"].ToString()); //获取日志信息 ModifyInfo NewModify = modify.UpdataInfo(DateTime.Now, "Engineer", 1, providedApiKey); //保存日志信息 _context.Add(NewModify); return(Json(new { success = _context.SaveChanges() > 0 })); }
/// <summary> /// b.验证文件完整性,寻找对应的补丁信息 /// </summary> public void ValidateAndFindModifyInfo() { // 寻找对应文件版本与SHA1的修改信息 foreach (FileHexEditor editor in editors) // 多种文件 { // 通过SHA1和文件版本判断是否可以打补丁 根据不同结果返回不同的提示 ModifyInfo matchingSHA1Before = null, matchingSHA1After = null, matchingVersion = null; foreach (ModifyInfo modifyInfo in config.FileModifyInfos[editor.FileName]) // 多个版本信息 { if (modifyInfo.Name == editor.FileName) // 保险用的无用判断 { if (editor.FileSHA1 == modifyInfo.SHA1After) { matchingSHA1After = modifyInfo; } else if (editor.FileSHA1 == modifyInfo.SHA1Before) { matchingSHA1Before = modifyInfo; } if (editor.FileVersion == modifyInfo.Version) { matchingVersion = modifyInfo; } } } // 补丁前SHA1匹配上,肯定是正确的dll if (matchingSHA1Before != null) { editor.FileModifyInfo = matchingSHA1Before; continue; } // 补丁后SHA1匹配上,肯定已经打过补丁 if (matchingSHA1After != null) { throw new BusinessException("installed", $"你已经安装过此补丁,文件路径:{editor.FilePath}"); } // 全部不匹配,说明不支持 if (matchingSHA1Before == null && matchingSHA1After == null && matchingVersion == null) { throw new BusinessException("not_support", $"不支持此版本:{editor.FileVersion},文件路径:{editor.FilePath}"); } // SHA1不匹配,版本匹配,可能dll已经被其他补丁程序修改过 if ((matchingSHA1Before == null && matchingSHA1After == null) && matchingVersion != null) { throw new BusinessException("maybe_modified", $"程序支持此版本:{editor.FileVersion}。但是文件校验不通过,请确认是否使用过其他补丁程序。文件路径:{editor.FilePath}"); } } }
public async Task UpdateStatus(SimpleUser user, string id, int status, string message, ModifyTypeEnum mtype, string mtypememo) { string cn = await Context.ChargeInfos.Where(x => x.ID == id).Select(x => x.ChargeNo).FirstOrDefaultAsync(); ChargeInfo ci = new ChargeInfo() { ID = id, Status = status, UpdateTime = DateTime.Now, UpdateUser = user.Id, ChargeNo = cn, ConfirmMessage = message, SubmitUser = user.Id, SubmitTime = DateTime.Now }; var entry = Context.ChargeInfos.Attach(ci); entry.Property(c => c.Status).IsModified = true; entry.Property(c => c.UpdateUser).IsModified = true; entry.Property(c => c.UpdateTime).IsModified = true; if (message != null) { entry.Property(c => c.ConfirmMessage).IsModified = true; } if (status == 4) { entry.Property(c => c.SubmitTime).IsModified = true; entry.Property(c => c.SubmitUser).IsModified = true; } ModifyInfo mi = new ModifyInfo() { Id = Guid.NewGuid().ToString("N").ToLower(), ChargeId = id, CreateTime = DateTime.Now, CreateUser = user.Id, Department = user.OrganizationId, Status = status, Type = mtype, TypeMemo = mtypememo }; Context.ModifyInfos.Add(mi); await Context.SaveChangesAsync(); }
private void setModifiedData(Session session, ModifyInfo info) { if (info.GraphKey == "font" || info.GraphKey == "kcs_flash" || info.ResourceIniPath == null) { return; } string graphStr = Regex.Match(jsonData, @"\{([^{]+?)" + info.GraphKey + @"([^}]+?)\}").Groups[0].Value; string sortNo = Regex.Match(graphStr, @"api_sortno"":(\d+)").Groups[1].Value; string infoStr = Regex.Match(jsonData, @"\{([^{]+?)api_sortno"":" + sortNo + @"([^}]+?)\}").Groups[0].Value; string graphReplaceStr = graphStr; string infoReplaceStr = infoStr; var str = getIniValue(info.ResourceIniPath, "info", "ship_name"); if (str != "") { infoReplaceStr = Regex.Replace(infoReplaceStr, @"api_name"":""(.+?)""", @"api_name"":""" + str + @""""); } var modList = new string[] { "boko_n", "boko_d", "kaisyu_n", "kaisyu_d", "kaizo_n", "kaizo_d", "map_n", "map_d", "ensyuf_n", "ensyuf_d", "ensyue_n", "battle_n", "battle_d" }; foreach (var mod in modList) { str = getIniValue(info.ResourceIniPath, "graph", mod + "_left"); if (str != "") { graphReplaceStr = Regex.Replace(graphReplaceStr, mod + @""":\[([\d-]+),([\d-]+)\]", mod + @""":[" + str + @",$2]"); } str = getIniValue(info.ResourceIniPath, "graph", mod + "_top"); if (str != "") { graphReplaceStr = Regex.Replace(graphReplaceStr, mod + @""":\[([\d-]+),([\d-]+)\]", mod + @"_"":[$1," + str + @"]"); } } jsonData = jsonData.Replace(graphStr, graphReplaceStr); jsonData = jsonData.Replace(infoStr, infoReplaceStr); }
public async Task UpdateExamineStatus(string modifyId, ExamineStatusEnum status, CancellationToken cancellationToken = default(CancellationToken)) { ModifyInfo buildings = new ModifyInfo() { ID = modifyId, ExamineTime = DateTime.Now, ExamineStatus = (int)status }; Context.Attach(buildings); var entry = Context.Entry(buildings); entry.Property(x => x.ExamineStatus).IsModified = true; entry.Property(x => x.ExamineTime).IsModified = true; try { await Context.SaveChangesAsync(cancellationToken); } catch (DbUpdateConcurrencyException) { throw; } }
public async Task CreateModifyAsync(SimpleUser userinfo, string contractid, string modifyid, int ntype, string checkaction, ExamineStatusEnum exa = ExamineStatusEnum.UnSubmit, bool updatetocontract = true, string ext1 = null, string ext2 = null, string ext3 = null, string ext4 = null, string ext5 = null, CancellationToken cancellationToken = default(CancellationToken)) { if (contractid != null) { if (string.IsNullOrEmpty(modifyid)) { modifyid = Guid.NewGuid().ToString(); } var tmodify = new ModifyInfo(); tmodify.ID = modifyid; tmodify.ContractID = contractid; tmodify.ModifyStartTime = DateTime.Now; tmodify.ExamineTime = tmodify.ModifyStartTime; tmodify.Type = ntype; tmodify.ModifyPepole = userinfo.Id; tmodify.ExamineStatus = (int)exa; tmodify.Ext1 = ext1; tmodify.Ext2 = ext2; tmodify.Ext3 = ext3; tmodify.Ext4 = ext4; tmodify.Ext5 = ext5; tmodify.ModifyCheck = checkaction; if (updatetocontract) { ContractInfo info = new ContractInfo() { ID = contractid, CurrentModify = modifyid }; var entry = Context.Attach(info); entry.Property(x => x.CurrentModify).IsModified = true; } Context.Add(tmodify); await Context.SaveChangesAsync(cancellationToken); } }
public async Task PreChangeHuman(SimpleUser userinfo, string modifyid, string huid, string info, string idcard, string checkaction, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(modifyid)) { modifyid = Guid.NewGuid().ToString(); } var modify = new ModifyInfo(); modify.ID = modifyid; modify.Type = ChangeHumanModifyType; modify.IDCard = idcard; modify.ModifyPepole = userinfo.Id; modify.ModifyStartTime = DateTime.Now; modify.ExamineStatus = ExamineStatusEnum.Auditing; modify.ExamineTime = modify.ModifyStartTime; modify.ModifyCheck = checkaction; modify.Ext1 = huid; modify.Ext2 = info; Context.Add(modify); await Context.SaveChangesAsync(cancellationToken); }
public async Task <HumanInfo> CreateAsync(SimpleUser userinfo, HumanInfo humaninfo, string modifyid, string checkaction, CancellationToken cancellationToken = default(CancellationToken)) { if (userinfo == null) { throw new ArgumentNullException(nameof(userinfo)); } if (string.IsNullOrEmpty(modifyid)) { modifyid = Guid.NewGuid().ToString(); } var modify = new ModifyInfo(); modify.ID = modifyid; modify.Type = CreateHumanModifyType;//创建 modify.IDCard = humaninfo.IDCard; modify.ModifyPepole = userinfo.Id; modify.ModifyStartTime = DateTime.Now; modify.ExamineStatus = ExamineStatusEnum.Auditing; modify.ExamineTime = modify.ModifyStartTime; modify.ModifyCheck = checkaction; modify.Ext1 = humaninfo.Id; modify.Ext2 = humaninfo.Name; humaninfo.CreateUser = userinfo.Id; humaninfo.Modify = 1; humaninfo.RecentModify = modifyid; humaninfo.CreateTime = DateTime.Now; humaninfo.StaffStatus = StaffStatus.NonEntry;//-1黑名单 0 未入职 1离职 2入职 3转正 Context.Add(humaninfo); Context.Add(modify); await Context.SaveChangesAsync(cancellationToken); return(humaninfo); }
public async Task <ContractInfo> CreateAsync(SimpleUser userinfo, ContractInfo buildingBaseInfo, string modifyid, string ext1, string ext2, string checkaction, CancellationToken cancellationToken = default(CancellationToken)) { if (buildingBaseInfo == null) { throw new ArgumentNullException(nameof(buildingBaseInfo)); } if (string.IsNullOrEmpty(modifyid)) { modifyid = Guid.NewGuid().ToString(); } var modify = new ModifyInfo(); modify.ID = modifyid; modify.Type = 1;//创建 modify.ContractID = buildingBaseInfo.ID; modify.ModifyPepole = userinfo.Id; modify.ModifyStartTime = DateTime.Now; modify.ExamineStatus = (int)ExamineStatusEnum.Auditing; modify.ExamineTime = modify.ModifyStartTime; modify.ModifyCheck = checkaction; modify.Ext1 = ext1; modify.Ext2 = ext2; buildingBaseInfo.IsDelete = false; buildingBaseInfo.CreateUser = userinfo.Id; buildingBaseInfo.CreateDepartment = userinfo.OrganizationName; buildingBaseInfo.Modify = 1; buildingBaseInfo.CurrentModify = modifyid; buildingBaseInfo.CreateTime = DateTime.Now; Context.Add(buildingBaseInfo); Context.Add(modify); await Context.SaveChangesAsync(cancellationToken); return(buildingBaseInfo); }
public async Task Save(SimpleUser user, ChargeInfo chargeInfo) { var q = from c in Context.ChargeInfos where c.ID == chargeInfo.ID select c; var old = await q.FirstOrDefaultAsync(); if (old == null) { chargeInfo.CreateTime = DateTime.Now; chargeInfo.CreateUser = user.Id; if (chargeInfo.Status == 4) { chargeInfo.SubmitTime = DateTime.Now; chargeInfo.SubmitUser = user.Id; } Context.ChargeInfos.Add(chargeInfo); ModifyInfo mi = new ModifyInfo() { Id = Guid.NewGuid().ToString("N").ToLower(), ChargeId = chargeInfo.ID, CreateTime = DateTime.Now, CreateUser = user.Id, Department = user.OrganizationId, RelativeId = chargeInfo.ChargeNo, Status = chargeInfo.Status, Type = chargeInfo.Status == 4 ? ModifyTypeEnum.Submit : ModifyTypeEnum.Add, TypeMemo = chargeInfo.Status == 4 ? ModifyTypeConstans.Submit : ModifyTypeConstans.Add }; Context.ModifyInfos.Add(mi); } else { //修改 old.BillCount = chargeInfo.BillCount; old.BillAmount = chargeInfo.BillAmount; old.ChargeAmount = chargeInfo.ChargeAmount; old.IsPayment = chargeInfo.IsPayment; old.PaymentAmount = chargeInfo.PaymentAmount; old.Status = chargeInfo.Status; old.Memo = chargeInfo.Memo; old.IsBackup = chargeInfo.IsBackup; old.BillStatus = chargeInfo.BillStatus; old.UpdateTime = DateTime.Now; old.UpdateUser = user.Id; old.ExpectedPaymentDate = chargeInfo.ExpectedPaymentDate; if (chargeInfo.Status == 4 && old.Status != 4) { old.SubmitTime = DateTime.Now; old.SubmitUser = user.Id; } ModifyInfo mi = new ModifyInfo() { Id = Guid.NewGuid().ToString("N").ToLower(), ChargeId = chargeInfo.ID, CreateTime = DateTime.Now, CreateUser = user.Id, Department = user.OrganizationId, RelativeId = chargeInfo.ChargeNo, Status = chargeInfo.Status, Type = chargeInfo.Status == 4 ? ModifyTypeEnum.Submit : ModifyTypeEnum.Modify, TypeMemo = chargeInfo.Status == 4 ? ModifyTypeConstans.Submit : ModifyTypeConstans.Modify }; Context.ModifyInfos.Add(mi); } await Context.SaveChangesAsync(); }
public async Task <ChargeInfo> BackupBill(SimpleUser user, ChargeInfo chargeInfo) { //后补发票 var ci = new ChargeInfo() { ID = chargeInfo.ID, BillAmount = chargeInfo.BillAmount, BillCount = chargeInfo.BillCount, BillStatus = chargeInfo.BillStatus, Backuped = chargeInfo.Backuped, ChargeNo = chargeInfo.ChargeNo }; var ciEntry = Context.ChargeInfos.Attach(ci); ciEntry.Property(c => c.BillAmount).IsModified = true; ciEntry.Property(c => c.BillCount).IsModified = true; ciEntry.Property(c => c.BillStatus).IsModified = true; ciEntry.Property(c => c.Backuped).IsModified = true; //单据更新 var oldBills = await Context.ReceiptInfos.Where(x => x.ChargeId == chargeInfo.ID).ToListAsync(); List <String> bids = oldBills.Select(x => x.Id).Distinct().ToList(); List <FileScopeInfo> oldFileScopes = new List <FileScopeInfo>(); if (bids.Count > 0) { oldFileScopes = await Context.FileScopeInfo.Where(x => bids.Contains(x.ReceiptId)).ToListAsync(); } List <FileInfo> oldFiles = new List <FileInfo>(); List <string> fsIds = oldFileScopes.Select(x => x.FileGuid).Distinct().ToList(); if (fsIds.Count > 0) { oldFiles = await Context.FileInfos.Where(x => fsIds.Contains(x.FileGuid)).ToListAsync(); } //新增的 var addBills = chargeInfo.BillList.AddedItems(oldBills, (a, b) => a.Id == b.Id); addBills.ForEach(item => { item.CreateTime = DateTime.Now; item.CreateUser = user.Id; Context.ReceiptInfos.Add(item); }); //删除的 var removedBills = chargeInfo.BillList.RemovedItems(oldBills, (a, b) => a.Id == b.Id); if (removedBills.Count > 0) { Context.ReceiptInfos.RemoveRange(removedBills); } //更新的 var updatedBills = oldBills.UpdatedItems(chargeInfo.BillList, (a, b) => a.Id == b.Id); if (updatedBills.Count > 0) { updatedBills.ForEach(item => { var newItem = chargeInfo.BillList.FirstOrDefault(x => x.Id == item.Id); item.ReceiptMoney = newItem.ReceiptMoney; item.ReceiptNumber = newItem.ReceiptNumber; item.Memo = newItem.Memo; }); } //更新文件列表 var newFileScopes = chargeInfo.BillList.SelectMany(b => b.FileScopes ?? new List <FileScopeInfo>()).ToList(); var addedFileScopes = newFileScopes.AddedItems(oldFileScopes, (a, b) => a.FileGuid == b.FileGuid); if (addedFileScopes.Count > 0) { Context.FileScopeInfo.AddRange(addedFileScopes); } var removedFileScopes = newFileScopes.RemovedItems(oldFileScopes, (a, b) => a.FileGuid == b.FileGuid); if (removedFileScopes.Count > 0) { Context.FileScopeInfo.RemoveRange(removedFileScopes); } //文件 Func <FileInfo, FileInfo, bool> checkFile = (a, b) => a.FileGuid == b.FileGuid && a.Type == b.Type && a.FileExt == b.FileExt; var newFiles = newFileScopes.SelectMany(x => x.FileList ?? new List <FileInfo>()).ToList(); var addedFiles = newFiles.AddedItems(oldFiles, checkFile); if (addedFiles.Count > 0) { Context.FileInfos.AddRange(addedFiles); } var removedFiles = newFiles.RemovedItems(oldFiles, checkFile); if (removedFiles.Count > 0) { removedFiles.ForEach(fi => { fi.IsDeleted = true; fi.DeleteTime = DateTime.Now; fi.DeleteUser = user.Id; }); } ModifyInfo mi = new ModifyInfo() { Id = Guid.NewGuid().ToString("N").ToLower(), ChargeId = chargeInfo.ID, CreateTime = DateTime.Now, CreateUser = user.Id, Department = user.OrganizationId, Status = chargeInfo.Status, Type = ci.BillStatus == 4? ModifyTypeEnum.SubmitBill: ModifyTypeEnum.Backup, TypeMemo = ci.BillStatus == 4 ? ModifyTypeConstans.SubmitBill :ModifyTypeConstans.Backup }; Context.ModifyInfos.Add(mi); await Context.SaveChangesAsync(); return(chargeInfo); }
public async Task Save(SimpleUser user, ChargeInfo chargeInfo) { var q = from c in Context.ChargeInfos where c.ID == chargeInfo.ID select c; var old = await q.FirstOrDefaultAsync(); if (old == null) { chargeInfo.CreateTime = DateTime.Now; chargeInfo.CreateUser = user.Id; if (chargeInfo.Status == 4) { chargeInfo.SubmitTime = DateTime.Now; chargeInfo.SubmitUser = user.Id; } // chargeInfo.ChargeNo = GetChargeNo() //新增 Context.ChargeInfos.Add(chargeInfo); if (chargeInfo.FeeList != null && chargeInfo.FeeList.Count > 0) { Context.CostInfos.AddRange(chargeInfo.FeeList); } if (chargeInfo.BillList != null && chargeInfo.BillList.Count > 0) { chargeInfo.BillList.ForEach(item => { item.CreateUser = user.Id; item.CreateTime = DateTime.Now; }); Context.ReceiptInfos.AddRange(chargeInfo.BillList); chargeInfo.BillList.ForEach(item => { if (item.FileScopes != null && item.FileScopes.Count > 0) { Context.FileScopeInfo.AddRange(item.FileScopes); item.FileScopes.ForEach(f => { if (f.FileList != null && f.FileList.Count > 0) { f.FileList.ForEach(fi => { fi.CreateTime = DateTime.Now; fi.CreateUser = user.Id; }); Context.FileInfos.AddRange(f.FileList); } }); } }); } ModifyInfo mi = new ModifyInfo() { Id = Guid.NewGuid().ToString("N").ToLower(), ChargeId = chargeInfo.ID, CreateTime = DateTime.Now, CreateUser = user.Id, Department = user.OrganizationId, RelativeId = chargeInfo.ChargeNo, Status = chargeInfo.Status, Type = chargeInfo.Status == 4 ? ModifyTypeEnum.Submit : ModifyTypeEnum.Add, TypeMemo = chargeInfo.Status == 4 ? ModifyTypeConstans.Submit : ModifyTypeConstans.Add }; Context.ModifyInfos.Add(mi); } else { //修改 old.BillCount = chargeInfo.BillCount; old.BillAmount = chargeInfo.BillAmount; old.ChargeAmount = chargeInfo.ChargeAmount; old.IsPayment = chargeInfo.IsPayment; old.PaymentAmount = chargeInfo.PaymentAmount; old.Status = chargeInfo.Status; old.Memo = chargeInfo.Memo; old.IsBackup = chargeInfo.IsBackup; old.BillStatus = chargeInfo.BillStatus; old.UpdateTime = DateTime.Now; old.UpdateUser = user.Id; if (chargeInfo.Status == 4 && old.Status != 4) { old.SubmitTime = DateTime.Now; old.SubmitUser = user.Id; } var fl = await Context.CostInfos.Where(x => x.ChargeId == chargeInfo.ID).ToListAsync(); var dl = fl.Where(x => !chargeInfo.FeeList.Any(y => y.Id == x.Id)).ToList(); if (dl.Count > 0) { Context.CostInfos.RemoveRange(dl); } var al = chargeInfo.FeeList.Where(x => !fl.Any(y => y.Id == x.Id)).ToList(); if (al.Count > 0) { Context.CostInfos.AddRange(al); } var ul = fl.Where(x => chargeInfo.FeeList.Any(y => y.Id == x.Id)).ToList(); ul.ForEach(x => { var ni = chargeInfo.FeeList.FirstOrDefault(y => y.Id == x.Id); x.Amount = ni.Amount; x.Memo = ni.Memo; x.Type = ni.Type; }); var bl = await Context.ReceiptInfos.Where(x => x.ChargeId == chargeInfo.ID).ToListAsync(); var bdl = bl.Where(x => !chargeInfo.BillList.Any(y => y.Id == x.Id)).ToList(); if (bdl.Count > 0) { Context.ReceiptInfos.RemoveRange(bdl); List <string> ids = bdl.Select(x => x.Id).Distinct().ToList(); //删除对应文件 var scopes = await Context.FileScopeInfo.Where(x => ids.Contains(x.ReceiptId)).ToListAsync(); if (scopes.Count > 0) { Context.FileScopeInfo.RemoveRange(scopes); ids = scopes.Select(x => x.FileGuid).Distinct().ToList(); var files = await Context.FileInfos.Where(x => ids.Contains(x.FileGuid)).ToListAsync(); if (files.Count > 0) { Context.FileInfos.RemoveRange(files); } } } var bal = chargeInfo.BillList.Where(x => !bl.Any(y => y.Id == x.Id)).ToList(); if (bal.Count > 0) { bal.ForEach(item => { item.CreateTime = DateTime.Now; item.CreateUser = user.Id; }); Context.ReceiptInfos.AddRange(bal); //新增 bal.ForEach(item => { if (item.FileScopes != null && item.FileScopes.Count > 0) { Context.FileScopeInfo.AddRange(item.FileScopes); item.FileScopes.ForEach(f => { if (f.FileList != null && f.FileList.Count > 0) { Context.FileInfos.AddRange(f.FileList); } }); } }); } var bul = bl.Where(x => chargeInfo.BillList.Any(y => y.Id == x.Id)).ToList(); bul.ForEach(x => { var ni = chargeInfo.BillList.FirstOrDefault(y => y.Id == x.Id); x.ReceiptMoney = ni.ReceiptMoney; x.Memo = ni.Memo; x.ReceiptNumber = ni.ReceiptNumber; }); List <String> ids2 = bul.Select(x => x.Id).Distinct().ToList(); if (ids2.Count > 0) { var newScopes = chargeInfo.BillList.Where(x => ids2.Contains(x.Id)).SelectMany(x => x.FileScopes).ToList(); // bul.SelectMany(x => x.FileScopes).ToList(); //old scopes var scopes = await Context.FileScopeInfo.Where(x => ids2.Contains(x.ReceiptId)).ToListAsync(); //需增加的scope var addList = newScopes.Where(x => !scopes.Any(y => y.ReceiptId == x.ReceiptId && y.FileGuid == x.FileGuid)).ToList(); if (addList.Count > 0) { Context.FileScopeInfo.AddRange(addList); } //需删除的scope var delList = scopes.Where(x => !newScopes.Any(y => y.ReceiptId == x.ReceiptId && y.FileGuid == x.FileGuid)).ToList(); if (delList.Count > 0) { Context.FileScopeInfo.AddRange(delList); } //文件列表更新 var newFiles = newScopes.SelectMany(x => x.FileList).ToList(); var fids = newFiles.Select(x => x.FileGuid).ToList(); var files = await Context.FileInfos.Where(x => fids.Contains(x.FileGuid)).ToListAsync(); //需新增的文件 var addFl = newFiles.Where(x => !files.Any(y => y.FileGuid == x.FileGuid && y.Type == x.Type && y.FileExt == x.FileExt)).ToList(); if (addFl.Count > 0) { addFl.ForEach(f => { f.CreateTime = DateTime.Now; f.CreateUser = user.Id; }); Context.FileInfos.AddRange(addFl); } //需删除的 var delFl = files.Where(x => !newFiles.Any(y => y.FileGuid == x.FileGuid && y.Type == x.Type && y.FileExt == x.FileExt)).ToList(); if (delFl.Count > 0) { delFl.ForEach(f => { f.IsDeleted = true; f.DeleteTime = DateTime.Now; f.DeleteUser = user.Id; }); } } ModifyInfo mi = new ModifyInfo() { Id = Guid.NewGuid().ToString("N").ToLower(), ChargeId = chargeInfo.ID, CreateTime = DateTime.Now, CreateUser = user.Id, Department = user.OrganizationId, RelativeId = chargeInfo.ChargeNo, Status = chargeInfo.Status, Type = chargeInfo.Status == 4 ? ModifyTypeEnum.Submit: ModifyTypeEnum.Modify, TypeMemo = chargeInfo.Status == 4 ? ModifyTypeConstans.Submit : ModifyTypeConstans.Modify }; Context.ModifyInfos.Add(mi); } await Context.SaveChangesAsync(); }
/// <summary> /// b.验证文件完整性,寻找对应的补丁信息 /// </summary> public void ValidateAndFindModifyInfo() { // 寻找对应文件版本与SHA1的修改信息 foreach (FileHexEditor editor in editors) // 多种文件 { // 通过SHA1和文件版本判断是否可以打补丁 根据不同结果返回不同的提示 ModifyInfo matchingSHA1Before = null, matchingSHA1After = null, matchingVersion = null; foreach (ModifyInfo modifyInfo in config.FileModifyInfos[editor.FileName]) // 多个版本信息 { if (modifyInfo.Name == editor.FileName) // 保险用的无用判断 { if (editor.FileSHA1 == modifyInfo.SHA1After) { matchingSHA1After = modifyInfo; } else if (editor.FileSHA1 == modifyInfo.SHA1Before) { matchingSHA1Before = modifyInfo; } if (editor.FileVersion == modifyInfo.Version) { matchingVersion = modifyInfo; } } } // 补丁前SHA1匹配上,肯定是正确的dll if (matchingSHA1Before != null) { editor.FileModifyInfo = matchingSHA1Before; editor.TargetChanges = matchingSHA1Before.Changes; continue; } // 补丁后SHA1匹配上,肯定已经打过补丁 if (matchingSHA1After != null) { throw new BusinessException("installed", $"你已经安装过此补丁!"); } // SHA1不匹配说明精准替换肯定不支持 if (matchingSHA1Before == null && matchingSHA1After == null) { // 多个版本范围,匹配出对应版本可以使用的特征 if (config.FileCommonModifyInfos != null) { editor.FileCommonModifyInfo = FindCommonModifyInfo(editor); } // 存在对应的特征时不报错 if (editor.FileCommonModifyInfo != null && editor.FileCommonModifyInfo.ReplacePatterns != null) { // 如果能顺利得到 TargetChanges 不报错则可以使用特征替换方式 editor.TargetChanges = ModifyFinder.FindChanges(editor.FilePath, editor.FileCommonModifyInfo.ReplacePatterns); continue; } else { // SHA1不匹配,连版本也不匹配,说明完全不支持 if (matchingVersion == null) { throw new BusinessException("not_support", $"不支持此版本:{editor.FileVersion}!"); } // SHA1不匹配,但是版本匹配,可能dll已经被其他补丁程序修改过 if (matchingVersion != null) { throw new BusinessException("maybe_modified", $"程序支持此版本:{editor.FileVersion}。但是文件校验不通过,请确认是否使用过其他补丁程序!"); } } } } }
public async Task <ModifyInfo> UpdateExamineStatus(string modifyId, ExamineStatusEnum status, CancellationToken cancellationToken = default(CancellationToken)) { var modify = await GetModifyAsync(a => a.Where(b => b.ID == modifyId)); if (modify != null) { switch (modify.Type) { case CreateHumanModifyType: { HumanInfo buildings = new HumanInfo() { Id = modify.Ext1, StaffStatus = StaffStatus.Entry }; Context.Attach(buildings); var entry = Context.Entry(buildings); entry.Property(x => x.StaffStatus).IsModified = true; } break; case BecomeHumanModifyType: { SocialInsurance responinfo = JsonHelper.ToObject <SocialInsurance>(modify.Ext2); await BecomeHuman(responinfo, modify.Ext1, cancellationToken); } break; case ChangeHumanModifyType: { ChangeInfo responinfo = JsonHelper.ToObject <ChangeInfo>(modify.Ext2); await ChangeHuman(responinfo, modify.Ext1, cancellationToken); } break; case LeaveHumanModifyType: { LeaveInfo responinfo = JsonHelper.ToObject <LeaveInfo>(modify.Ext2); await LeaveHuman(responinfo, modify.Ext1, cancellationToken); } break; default: break; } ///////////////////// ModifyInfo mbuildings = new ModifyInfo() { ID = modifyId, ExamineTime = DateTime.Now, ExamineStatus = status, }; Context.Attach(mbuildings); var mentry = Context.Entry(mbuildings); mentry.Property(x => x.ExamineStatus).IsModified = true; mentry.Property(x => x.ExamineTime).IsModified = true; await Context.SaveChangesAsync(cancellationToken); } return(modify); }