public void SynchS_DownloadDetail() { var user = FormulaHelper.GetUserInfo(); var entities = FormulaHelper.GetEntities <DocConstEntities>(); var list = this.T_Download_FileInfo.ToList(); foreach (var item in list) { S_DownloadDetail entity = new S_DownloadDetail(); entity.ID = FormulaHelper.CreateGuid(); entity.Name = item.FileName; entity.FileID = item.FileID; entity.CreateUserID = this.CreateUserID; entity.CreateUserName = this.CreateUserName; entity.SpaceID = item.SpaceID; entity.DownloadID = this.ID; entity.UserDeptID = user.UserOrgID; entity.UserDeptName = user.UserOrgName; entity.CreateDate = DateTime.Now; entity.ConfigID = item.ConfigID; entity.DownloadState = ItemState.Finish.ToString(); entity.DownloadExpireDate = DateTime.Now.AddDays(7); entity.PassDate = this.PassDate; entity.Attachments = item.Attachments; entities.Set <S_DownloadDetail>().Add(entity); AddBorrowLog(item); } }
protected override void OnFlowEnd(T_D_DownloadApply entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { var carIds = entity.T_D_DownloadApply_DetailInfo.Select(a => a.CarInfoID).ToArray(); var carItems = this.BusinessEntities.Set <S_CarInfo>().Where(a => carIds.Contains(a.ID)); foreach (var item in entity.T_D_DownloadApply_DetailInfo.ToList()) { var carItem = carItems.FirstOrDefault(a => a.ID == item.CarInfoID); carItem.State = ItemState.Finish.ToString(); #region 创建S_DownloadDetail int downloadExpireDate = 7; var DocDownloadExpireDays = System.Configuration.ConfigurationManager.AppSettings["DocDownloadExpireDays"]; if (!string.IsNullOrEmpty(DocDownloadExpireDays)) { downloadExpireDate = Convert.ToInt32(DocDownloadExpireDays); } S_DownloadDetail downloadDetail = new S_DownloadDetail { ID = FormulaHelper.CreateGuid(), DownloadID = entity.ID, Name = item.Name, Code = item.Code, SpaceID = carItem.SpaceID, ConfigID = carItem.ConfigID, FileID = carItem.FileID, CreateUserID = entity.ApplyUser, CreateUserName = entity.ApplyUserName, CreateDate = DateTime.Now, UserDeptID = entity.ApplyDept, UserDeptName = entity.ApplyDeptName, PassDate = DateTime.Now, DownloadState = ItemState.Finish.ToString(), DownloadExpireDate = Convert.ToDateTime(DateTime.Now.AddDays(downloadExpireDate).ToShortDateString() + " 23:59:59") }; this.BusinessEntities.Set <S_DownloadDetail>().Add(downloadDetail); #endregion S_FileInfo file = new S_FileInfo(carItem.FileID, FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(carItem.SpaceID))); InventoryFO.CreateNewInventoryLedger(file, "", InventoryType.DownLoad); } this.BusinessEntities.SaveChanges(); }