示例#1
0
        public IActionResult Add(DTOSaveVersionInfo dto)
        {
            var result = new ReturnResponse();

            CheckVersionInfo(dto);
            using (var unitOfWork = new UnitOfWork(DbContext))
            {
                if (unitOfWork.VersionInfoRepository.IsExist(o => o.VersionNo == dto.VersionNo && !o.IsDelete))
                {
                    throw new CustomExecption("9999", $"已经存在版本号为{dto.VersionNo}的版本信息");
                }
                var model = new Prc_VersionInfo();
                model.ID              = Guid.NewGuid();
                model.VersionNo       = dto.VersionNo;
                model.PublishDate     = Convert.ToDateTime(dto.PublishDate).RemoveMilliSecond();
                model.IsPublish       = false;
                model.Context         = Encoding.UTF8.GetBytes(dto.Content);
                model.LastOperateUser = LoginUserInfo.CurrUser.LoginName;
                model.LastUpdateTime  = DateTime.Now.RemoveMilliSecond();
                model.IsDelete        = false;
                unitOfWork.VersionInfoRepository.Add(model);
                OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "新增版本【" + dto.VersionNo + "】");
                unitOfWork.SaveChanges();
            }

            return(Json(result));
        }
示例#2
0
        public ReturnResponse DeleteUpgradeBag(DTOUpgradeFileDelete dto)
        {
            string fileDirPath = Environment.CurrentDirectory + "/LocalFile/UpgradeBag/";

            Repository <Prc_VersionInfo> repository = new Repository <Prc_VersionInfo>(DbContext);
            Prc_VersionInfo versionInfo             = repository.Get(a => a.ID == dto.VersionId);

            try
            {
                NosService.DeleteFile("UpgradeBag/" + versionInfo.UpgradeBagName);
            }
            catch (Exception ex)
            {
                logger.Error("删除升级文件失败", ex);
            }

            versionInfo.IsPublish       = false;
            versionInfo.LastPublishTime = null;
            versionInfo.UpgradeBagName  = string.Empty;
            repository.Update(versionInfo);

            //取消该版本的所有预约
            Repository <Prc_UpgradeInfo> repositoryInfo = new Repository <Prc_UpgradeInfo>(DbContext);
            List <Prc_UpgradeInfo>       infos          = repositoryInfo.Search(a => !a.IsDelete && a.UpgradeStatus == Model.Enum.EnumUpgradeStatus.Reserved && a.TargetVersionID == versionInfo.ID);

            infos.ForEach(a =>
            {
                BllUpgrade.CancelReserve(a.ID);
            });

            OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "删除了版本【" + versionInfo.VersionNo + "】的更新包");
            DbContext.SaveChanges();

            return(new ReturnResponse());
        }
示例#3
0
        public IActionResult Del(Guid id)
        {
            using (var unitOfWork = new UnitOfWork(DbContext))
            {
                var model = unitOfWork.VersionInfoRepository.Get(o => o.ID == id && !o.IsDelete);
                if (model == null)
                {
                    throw new CustomExecption("9999", "获取版本信息失败");
                }
                model.IsDelete        = true;
                model.LastUpdateTime  = DateTime.Now.RemoveMilliSecond();
                model.LastPublishTime = DateTime.Now.RemoveMilliSecond();
                unitOfWork.VersionInfoRepository.Update(model);

                //取消该版本的所有预约
                Repository <Prc_UpgradeInfo> repositoryInfo = new Repository <Prc_UpgradeInfo>(DbContext);
                List <Prc_UpgradeInfo>       infos          = repositoryInfo.Search(a => !a.IsDelete && a.UpgradeStatus == Model.Enum.EnumUpgradeStatus.Reserved && a.TargetVersionID == model.ID);
                infos.ForEach(a =>
                {
                    BllUpgrade.CancelReserve(a.ID);
                });

                OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "删除版本【" + model.VersionNo + "】");
                DbContext.SaveChanges();
                unitOfWork.SaveChanges();
            }

            return(Json(new ReturnResponse()));
        }
示例#4
0
        /// <summary>
        /// 取消预约
        /// </summary>
        /// <param name="InfoId"></param>
        public void CancelReserve(Guid InfoId)
        {
            Repository <Prc_UpgradeInfo> repository = new Repository <Prc_UpgradeInfo>(DbContext);
            Prc_UpgradeInfo editInfo = repository.Get(a => a.ID == InfoId);

            editInfo.UpgradeStatus = EnumUpgradeStatus.Canceled;
            repository.Update(editInfo);
            OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "取消客户【" + editInfo.MallName + "】的升级预约");
            DbContext.SaveChanges();
        }
示例#5
0
        public IActionResult SetUpgradeBag(DTOUpgradeName dto)
        {
            //上传完成
            Repository <Prc_VersionInfo> repository = new Repository <Prc_VersionInfo>(DbContext);
            Prc_VersionInfo versionInfo             = repository.Get(a => a.ID == dto.VersionId);

            versionInfo.UpgradeBagName = dto.BagName;
            repository.Update(versionInfo);
            OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "上传了版本【" + versionInfo.VersionNo + "】的更新包");
            DbContext.SaveChanges();
            return(Json(new ReturnResponse()));
        }
示例#6
0
        /// <summary>
        /// 取消门店预约
        /// </summary>
        public ReturnResponse CancelBusinessReserve(DTOEditUpgradeInfoItem dto)
        {
            Repository <Prc_UpgradeInfoItem> repository = new Repository <Prc_UpgradeInfoItem>(DbContext);
            Prc_UpgradeInfoItem editItem = repository.Get(a => a.ID == dto.ID);

            editItem.UpgradeStatus = EnumUpgradeStatus.Canceled;
            repository.Update(editItem);
            OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "忽略门店【" + editItem.BusinessName + "】的升级预约");
            DbContext.SaveChanges();

            return(new ReturnResponse());
        }
示例#7
0
        /// <summary>
        /// 修改确认升级时间
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ReturnResponse EditConfirmUpgradeTime(DTOEditUpgradeInfo dto)
        {
            Repository <Prc_UpgradeInfo> repository = new Repository <Prc_UpgradeInfo>(DbContext);
            Prc_UpgradeInfo editInfo = repository.Get(a => a.ID == dto.ID);

            editInfo.ConfirmUpgradeTime = dto.ConfirmUpgradeTime;
            editInfo.Summary            = dto.Summary;
            repository.Update(editInfo);
            OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "确认客户【" + editInfo.MallName + "】的升级时间为【" + dto.ConfirmUpgradeTime + "】");
            DbContext.SaveChanges();


            return(new ReturnResponse());
        }
示例#8
0
        /// <summary>
        /// 开始升级
        /// </summary>
        /// <returns></returns>
        public ReturnResponse StartUpgrade(DTOEditUpgradeInfo dto)
        {
            //Repository<Prc_UpgradeInfoItem> repositoryItem = CreateRepository<Prc_UpgradeInfoItem>(access);
            Repository <Prc_UpgradeInfo> repositoryInfo = new Repository <Prc_UpgradeInfo>(DbContext);

            Prc_UpgradeInfo editInfo = repositoryInfo.Get(a => a.ID == dto.ID);

            editInfo.UpgradeStatus    = EnumUpgradeStatus.Upgrading;
            editInfo.StartUpgradeTime = DateTime.Now;
            repositoryInfo.Update(editInfo);
            OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "启动客户【" + editInfo.MallName + "】的升级");
            DbContext.SaveChanges();


            return(new ReturnResponse());
        }
示例#9
0
        public ReturnResponse UploadUpgradeBag(DTOUpgradeFileUpload dto)
        {
            try
            {
                string fileDirPath  = Environment.CurrentDirectory + "/LocalFile/UpgradeBag/";
                string fileFullName = fileDirPath + dto.FileName;
                if (!Directory.Exists(fileDirPath))
                {
                    Directory.CreateDirectory(fileDirPath);
                }
                if (dto.CurrPosition == 0 && System.IO.File.Exists(fileFullName))
                {
                    System.IO.File.Delete(fileFullName);
                }

                using (FileStream fs = new FileStream(fileFullName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write, dto.FileSize))
                {
                    fs.Position = dto.CurrPosition;
                    fs.Write(dto.FileBuffer.ToArray(), 0, dto.FileBuffer.Count);
                    if (fs.Length == dto.FileSize)
                    {
                        //上传完成
                        Repository <Prc_VersionInfo> repository = new Repository <Prc_VersionInfo>(DbContext);
                        Prc_VersionInfo versionInfo             = repository.Get(a => a.ID == dto.VersionId);
                        versionInfo.UpgradeBagName = dto.FileName;
                        repository.Update(versionInfo);
                        OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "上传了版本【" + versionInfo.VersionNo + "】的更新包");
                        DbContext.SaveChanges();
                    }
                }
                return(new ReturnResponse());
            }
            catch (Exception ex)
            {
                return(new ReturnResponse()
                {
                    ResponseStatus = new ResponseStatus()
                    {
                        ErrorCode = "999", Message = "上传失败:" + ex.Message
                    }
                });
            }
        }
示例#10
0
        public ReturnResponse DeleteUpgradeBag(DTOUpgradeFileDelete dto)
        {
            string fileDirPath = Environment.CurrentDirectory + "/LocalFile/UpgradeBag/";


            Repository <Prc_VersionInfo> repository = new Repository <Prc_VersionInfo>(DbContext);
            Prc_VersionInfo versionInfo             = repository.Get(a => a.ID == dto.VersionId);
            string          fileFullName            = fileDirPath + versionInfo.UpgradeBagName;
            string          bytesKey = "UpgradeBag_" + dto.VersionId.ToString().ToUpper();
            string          nameKey  = "UpgradeBagName_" + dto.VersionId.ToString().ToUpper();

            _cache.Remove(bytesKey);
            _cache.Remove(nameKey);
            if (System.IO.File.Exists(fileFullName))
            {
                System.IO.File.Delete(fileFullName);
            }
            versionInfo.IsPublish       = false;
            versionInfo.LastPublishTime = null;
            versionInfo.UpgradeBagName  = string.Empty;
            repository.Update(versionInfo);

            //取消该版本的所有预约
            Repository <Prc_UpgradeInfo> repositoryInfo = new Repository <Prc_UpgradeInfo>(DbContext);
            List <Prc_UpgradeInfo>       infos          = repositoryInfo.Search(a => !a.IsDelete && a.UpgradeStatus == Model.Enum.EnumUpgradeStatus.Reserved && a.TargetVersionID == versionInfo.ID);

            infos.ForEach(a =>
            {
                BllUpgrade.CancelReserve(a.ID);
            });

            OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "删除了版本【" + versionInfo.VersionNo + "】的更新包");
            DbContext.SaveChanges();

            return(new ReturnResponse());
        }