示例#1
0
        /// <summary>
        /// 处理增值税业务中的证书
        /// </summary>
        /// <param name="vat"></param>
        private void CertificateFileHandel(ValueAddedTaxInfo vat)
        {
            string fileIdentity  = vat.CertificateFileName;
            string getConfigPath = AppSettingManager.GetSetting("Customer", "CertificateFilesPath");

            if (!string.IsNullOrEmpty(fileIdentity))
            {
                if (!fileIdentity.Contains(getConfigPath))
                {
                    string fileName = Path.GetFileName(Encoding.UTF8.GetString(Convert.FromBase64String(fileIdentity)));
                    vat.CertificateFileName = getConfigPath + "\\" + fileName;
                    if (!Path.IsPathRooted(getConfigPath))
                    {
                        //是相对路径:
                        getConfigPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, getConfigPath);
                    }
                    string getDestinationPath = Path.Combine(getConfigPath, fileName);
                    string getFolder          = Path.GetDirectoryName(getDestinationPath);
                    if (!Directory.Exists(getFolder))
                    {
                        Directory.CreateDirectory(getFolder);
                    }
                    //将上传的文件从临时文件夹剪切到目标文件夹:
                    FileUploadManager.MoveFile(fileIdentity, getDestinationPath);

                    FileUploadManager.DeleteFile(fileIdentity);
                }
            }
        }
        public ActionResult Index(HttpPostedFileBase file, MemberEditViewModel viewModel)
        {
            var member = db.tblmembers.Single(a => a.ID == viewModel.ID);

            member.BusinessRegNo = viewModel.BusinessRegNo;
            member.CompanyName   = viewModel.CompanyName;
            member.PICName       = viewModel.PICName;
            member.PICContact    = viewModel.PICContact;
            //member.PICEmail = viewModel.PICEmail;
            member.Address  = viewModel.Address;
            member.Postcode = viewModel.Postcode;
            member.State    = viewModel.State;
            member.Country  = viewModel.Country;
            //member.Active = viewModel.Active;

            if (file != null)
            {
                var fileName = FileUploadManager.UploadAndSave(file);
                member.ProfileImagePath = fileName;
            }

            db.SaveChanges();

            Util.SessionAccess = member;

            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// 删除一组套图
        /// </summary>
        /// <param name="fileIdentity"></param>
        public static void DeleteImages(string fileIdentity)
        {
            if (ImageList.Count == 0)
            {
                return;
            }
            var result = FileUploadManager.FileExists(fileIdentity);

            if (result)
            {
                return;
            }
            ImageList.ForEach(v =>
            {
                var folderPath = Path.Combine(FileUploadManager.BaseFolder, v.Key.ToString());
                if (!Directory.Exists(folderPath))
                {
                    return;
                }
                var filePath = Path.Combine(folderPath, fileIdentity);
                if (File.Exists(filePath))
                {
                    ThreadPool.QueueUserWorkItem(delegate
                    {
                        File.Delete(filePath);
                    });
                }
            });
        }
示例#4
0
        public ActionResult Save(int id, string title, string remark, string url)
        {
            FileUploadManager         fileUploadManager = new FileUploadManager();
            SimpleClient <fileupload> FileDb            = new SimpleClient <fileupload>(fileUploadManager.Db);

            try
            {
                var file = new fileupload()
                {
                    id          = id,
                    filename    = title,
                    filecontent = url,
                    filetype    = remark,
                };
                FileDb.Insert(file);
                return(Json(new
                {
                    Result = true
                }));
            }
            catch (Exception exception)
            {
                return(Json(new
                {
                    Result = true,
                    exception.Message
                }));
            }
        }
示例#5
0
        // GET: file
        public ActionResult Index()
        {
            FileUploadManager         fileUploadManager = new FileUploadManager();
            SimpleClient <fileupload> FileDb            = new SimpleClient <fileupload>(fileUploadManager.Db);

            return(View(FileDb.GetList()));
        }
        /// <summary>
        /// 生成标准图片
        /// </summary>
        /// <param name="fileIdentity"></param>
        /// <param name="newFileName"></param>
        public static void CreateStandardImages(string fileIdentity, string newFileName)
        {
            if (ImageList.Count == 0)
            {
                return;
            }
            var result = FileUploadManager.FileExists(fileIdentity);

            if (!result)
            {
                return;
            }
            var   filePath    = FileUploadManager.GetFilePhysicalFullPath(fileIdentity);
            Image uploadImage = Image.FromFile(filePath);

            //判断是否为标准图片
            if (!ImageUtility.CheckImagePixels(uploadImage))
            {
                uploadImage.Dispose();//后面的zoomauto会删除的,资源要提前释放
                //重命名文件
                var bytes     = FileUploadManager.GetFileData(fileIdentity);
                var imageHelp = new ImageUtility {
                    SavePath = filePath
                };
                imageHelp.ZoomAuto(bytes, 640, 480);
            }
        }
示例#7
0
        public void ValidExchangeMappingTest(Scope scope, Label label, Mode mode, ResourceId resource)
        {
            var fileHandler          = new FileUploadManager();
            var mappingHandler       = new MappingManager();
            var exchangeQueueHandler = new QueueManager();
            var requestMappingUpdate = new Dictionary <string, object>();
            var uploadResult         = fileHandler.FileUpload <UploadFileResponse>($"{CSVFiles.Data[$"{resource}"]}", System.Net.Http.HttpMethod.Post);

            requestMappingUpdate = mode == Mode.Import ? RequestValidExchangeMappingUpdate(ImportMappingIds.Data[$"{resource}"], label, scope, ImportContents[$"{resource}"]):
                                   RequestValidExchangeMappingUpdate(ExportMappingIds.Data[$"{resource}"], label, scope, ExportContents[$"{resource}"]);

            var mappingResult = mappingHandler.ExchangeMapping <object>(requestMappingUpdate, System.Net.Http.HttpMethod.Put);

            PrAssert.That(mappingResult, PrIs.SuccessfulResponse().And.HttpCode((int)System.Net.HttpStatusCode.NoContent));

            var queueRequest     = CreateQueueRequest(mode, resource, uploadResult.Result.FileId);
            var queueResult      = exchangeQueueHandler.Queue <int>(queueRequest, System.Net.Http.HttpMethod.Post);
            var hrbcQueueRequest = CreateHrbcQueueRequest(mode, queueResult.Result);

            var result = GetRequestQueueMapping(hrbcQueueRequest);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode((int)System.Net.HttpStatusCode.OK));
            PrAssert.That(result.Result.Status, PrIs.EqualTo("finished"));
            PrAssert.That(result.Result.Log.Failed, PrIs.Zero);
        }
 public DownloadController(IHostingEnvironment hostingEnvironment, ITaskInteractor taskInteractor, Settings settings, FileUploadManager fileManager)
 {
     this._hostingEnvironment = hostingEnvironment;
     this._taskInteractor     = taskInteractor;
     this._settings           = settings;
     this._fileManager        = fileManager;
 }
        public ActionResult UploadImages()
        {
            var finalFileNames = new List <string>();

            try
            {
                foreach (string fileName in Request.Files)
                {
                    var image       = Request.Files[fileName];
                    var newFileName = FileUploadManager.UploadAndSave(image);

                    finalFileNames.Add(newFileName);
                }

                return(new JsonResult
                {
                    Data = new { FileNames = finalFileNames }
                });
            }
            catch (Exception ex)
            {
                ex.Log();

                finalFileNames.ForEach(a => FileUploadManager.DeleteFile(a));

                return(new JsonResult
                {
                    Data = new { Error = ex.Message }
                });
            }
        }
示例#10
0
        public void Delete(Guid Id)
        {
            var itemFounds = FileUploadManager.GetById(Id);

            var filePost = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + itemFounds.sFileUrl);

            System.IO.File.Delete(filePost);
        }
示例#11
0
 public TaskController(ITaskInteractor interactor, IProjectInteractor projectInteractor,
                       FileUploadManager fileUpload, CacheManager cacheHelper, IMemoryCache cache)
 {
     this._interactor        = interactor;
     this._projectInteractor = projectInteractor;
     this._fileUpload        = fileUpload;
     this._cacheHelper       = cacheHelper;
     this._cache             = cache;
 }
示例#12
0
        /// <summary>
        /// 自动确认收款单
        /// </summary>
        /// <param name="fileIdentity">上传文件标识符</param>
        /// <param name="soOutFromDate">订单出库起始时间</param>
        /// <param name="soOutToDate">订单出库结束时间</param>
        /// <param name="successSysNoList">成功确认的订单系统编号列表</param>
        /// <param name="failedSysNoList">确认失败的订单系统编号列表,包括匹配失败的订单编号</param>
        /// <param name="submitConfirmCount">成功提交审核的订单数(仅仅是成功提交,不保证能审核成功)</param>
        /// <param name="failedMessage">失败信息</param>
        public virtual void AutoConfirm(string fileIdentity, DateTime?soOutFromDate, DateTime?soOutToDate,
                                        out List <int> successSysNoList, out List <int> failedSysNoList, out int submitConfirmCount, out string failedMessage)
        {
            FileStream fs        = FileUploadManager.OpenFile(fileIdentity);
            DataTable  dataTable = ProcessUploadFile(fs);

            if (dataTable.Rows.Count == 0)
            {
                // throw new ECCentral.BizEntity.BizException("上传记录格式不正确,请重新上传");
                throw new ECCentral.BizEntity.BizException(ResouceManager.GetMessageString("Invoice.SOIncome", "SOIncome_FormatError"));
            }
            if (dataTable.Rows.Count > 1000)
            {
                //throw new ECCentral.BizEntity.BizException("上传记录大于1000条,会造成系统不稳定,请减少记录重试");
                throw new ECCentral.BizEntity.BizException(ResouceManager.GetMessageString("Invoice.SOIncome", "SOIncome_UploadCountLimitError"));
            }

            List <int> soSysNoList = new List <int>();

            dataTable.AsEnumerable().Where(r => r["OrderSysNo"] != null && !string.IsNullOrEmpty(r["OrderSysNo"].ToString()))
            .ForEach(row =>
            {
                int soSysNo;
                if (int.TryParse(row["OrderSysNo"].ToString(), out soSysNo))
                {
                    soSysNoList.Add(soSysNo);
                }
            });

            DateTime?fromDateTime = null;
            DateTime?toDateTime   = null;

            if (!soOutFromDate.HasValue)
            {
                fromDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            }
            else
            {
                fromDateTime = soOutFromDate.Value;
            }
            if (soOutToDate.HasValue)
            {
                toDateTime = soOutToDate.Value.AddDays(1).AddSeconds(-1);
            }

            var normalSaleIncomeList = new List <SOIncomeInfo>();
            var masterSaleIncomeList = new List <SOIncomeInfo>();
            var errorMessage         = new StringBuilder();

            GetNeedConfirmSysNoList(soSysNoList, dataTable, fromDateTime, toDateTime, normalSaleIncomeList, masterSaleIncomeList, errorMessage);
            submitConfirmCount = normalSaleIncomeList.Count + masterSaleIncomeList.Count;
            ProcessAutoConfirm(normalSaleIncomeList, masterSaleIncomeList, dataTable, out successSysNoList, out failedSysNoList, errorMessage);

            failedMessage = errorMessage.ToString();
        }
示例#13
0
 //pass repair id
 public JsonResult GetFiles(Guid Id)
 {
     try
     {
         var itemFounds = FileUploadManager.GetByRepair(Id);
         return(Json(new { Result = "OK", Records = itemFounds }));
     }
     catch (Exception ex)
     {
         return(Json(new { Result = "ERROR", Message = ex.Message }));
     }
 }
示例#14
0
        public ActionResult Register(HttpPostedFileBase file, RegisterViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var exists = db.tblmembers.Any(a => a.Active && a.PICEmail == viewModel.Email);

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Invalid email.");
                return(View(viewModel));
            }

            var member = new tblmember()
            {
                PICName  = viewModel.Name,
                PICEmail = viewModel.Email,
                Roles    = "NU",
                Password = Util.GetMD5Hash(viewModel.Password),
                CreateDT = DateTime.Now,
                Language = "EN",
                Active   = true
            };

            if (file != null)
            {
                var fileName = FileUploadManager.UploadAndSave(file);
                member.ProfileImagePath = fileName;
            }

            db.tblmembers.Add(member);
            db.SaveChanges();

            var emailBody = string.Format(@"Hi {0}, <br /><br />
                    Thanks for Subscribing to the EZ Go Holiday Website ! You’re joining an amazing community of folks who love nerding out about travelling. <br /><br />
                    As you wait for the next issue, check out some of our most popular posts. They’re a great place to get started. <br /><br />
                    Website: http://www.ezgoholiday.com <br />
                    Username: {1} <br />
                    Password: {2} <br /><br />

                    Have an awesome day! <br />
                    EZ Go Holiday Management",
                                          viewModel.Name, viewModel.Email, viewModel.Password);

            Util.SendEmail("Welcome to EZ Go Holiday!", emailBody, viewModel.Email, "", "");

            Util.SessionAccess = member;
            FormsAuthentication.SetAuthCookie(viewModel.Email, false);

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Edit(int id, string errorMessage = "")
        {
            var package   = db.lnkmemberposts.Single(a => a.ID == id);
            var viewModel = new PackageEditViewModel
            {
                ID                 = package.ID,
                Title              = package.Title,
                Description        = package.Description,
                Price              = package.Price,
                CategoryID         = package.CategoryID,
                Categories         = GetList(ListType.Category),
                ThumbnailImagePath = package.ThumbnailImagePath,
                Days               = package.Days,
                Nights             = package.Nights,
                StartDT            = package.StartDT,
                EndDT              = package.EndDT,
                Active             = package.Active,
                ErrorMessage       = errorMessage
            };

            var selectedActivities =
                db.lnkmemberpostpackageactivities.Where(a => a.MemberPostID == id && a.Active).Select(a => a.PackageActivityID).ToArray();

            viewModel.Activities = GetPackageActivities(selectedActivities);

            var selectedCountryIDs =
                db.lnkmemberpostcountries.Where(a => a.MemberPostID == id && a.Active).Select(a => a.CountryID).ToArray();
            var countries = GetList(ListType.Country, defaultItem: false);

            countries.ForEach(a => a.Selected = selectedCountryIDs.Any(b => b == int.Parse(a.Value)));

            viewModel.Countries = countries;

            var detailImageNames =
                db.lnkmemberpostimages.Where(a => a.Active && a.MemberPostID == id).Select(a => a.ImagePath).ToArray();

            viewModel.DetailImageNames = string.Join(",", detailImageNames);
            viewModel.MockFiles        = new List <PackageEditMockFile>();

            foreach (var imageName in detailImageNames)
            {
                var mockFile = new PackageEditMockFile
                {
                    name = imageName,
                    size = FileUploadManager.GetFileSize(imageName)
                };
                viewModel.MockFiles.Add(mockFile);
            }

            return(View(viewModel));
        }
示例#16
0
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                var fileName = FileUploadManager.UploadSingleFile(UploadFileModel.File, _hostEnvironment);

                var text = FileDataExtractor.Extract(_hostEnvironment.WebRootPath + "\\uploads\\" + fileName);

                FileIndexingManager.AddToIndex(_hostEnvironment, UploadFileModel.Title, text, fileName);

                Message = $"Document had been uploaded successfully.";
            }
            return(Page());
        }
示例#17
0
        string GetTemplateUrl(DataFeedTemplate template, string fileName)
        {
            string path = Path.Combine(
                AppDomain.CurrentDomain.SetupInformation.ApplicationBase
                , AppSettingHelper.Get("DataFeedFilesTemplatePath")
                );

            template.LoadWorkbook(path);
            template.InitWorkbook();

            byte[] buf = template.GetBytes();

            return(FileUploadManager.UploadFileAndGetUrl(fileName, buf));
        }
        public Attachment MapCreate(AttachViewModel attachViewModel)
        {
            FileUploadManager fileUploadManager = new FileUploadManager(attachViewModel.Attachment);
            var        fileByteArray            = fileUploadManager.GetByteArray();
            Attachment attachment = new Attachment()
            {
                FileContent = fileByteArray,
                FileName    = attachViewModel.Attachment.FileName,
                TableName   = attachViewModel.TableName,
                TableId     = Guid.Parse(attachViewModel.Id),
                MimeType    = attachViewModel.Attachment.ContentType
            };

            return(attachment);
        }
示例#19
0
        public ActionResult getfiles(string id)
        {
            FileUploadManager         fileUploadManager = new FileUploadManager();
            SimpleClient <fileupload> FileDb            = new SimpleClient <fileupload>(fileUploadManager.Db);

            if (id == null)
            {
                List <fileupload> list = FileDb.GetList();
                return(Json(new { code = "0", msg = "", count = list.Count, data = list }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                List <fileupload> list = fileUploadManager.Db.Ado.SqlQuery <fileupload>("select * from fileupload where id like @id", new SugarParameter("@id", id + ""));
                return(Json(new { code = "0", msg = "", count = list.Count, data = list }, JsonRequestBehavior.AllowGet));
            }
        }
示例#20
0
        public static void OriginalImageSaveByDFIS(string fileIdentity, string destFileName)
        {
            if (string.IsNullOrWhiteSpace(fileIdentity) || string.IsNullOrWhiteSpace(destFileName))
            {
                return;
            }
            var result = FileUploadManager.FileExists(fileIdentity);

            if (result)
            {
                var filePath = FileUploadManager.GetFilePhysicalFullPath(fileIdentity);
                CreateStandardImages(fileIdentity, destFileName);

                HttpUploader.UploadFile(UploadURL, FileGroup, "Original", filePath, destFileName, "", UserName, UploadMethod.Update);
            }
        }
示例#21
0
        public void ImportPostIncome(string fileIdentity, string companyCode, ref List <PostIncomeInfo> successList, ref List <ImportPostIncome> faultList, ref string message)
        {
            if (FileUploadManager.FileExists(fileIdentity))
            {
                string destinationPath = string.Empty;
                MoveFile(fileIdentity, ref destinationPath);

                DataSet ds = ConvertExcel2DataSet(destinationPath);

                BatachCreate(ds.Tables[0], companyCode, ref successList, ref faultList, ref message);
            }
            else
            {
                throw new BizException(ResouceManager.GetMessageString(InvoiceConst.ResourceTitle.PostIncome, "PostIncome_NoFile"));
            }
        }
示例#22
0
        private void MoveFile(string fileIdentity, out string destinationPath)
        {
            string configPath = AppSettingManager.GetSetting("Invoice", "InvoiceReportFilesPath");

            if (!Path.IsPathRooted(configPath))
            {
                configPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, configPath);
            }
            destinationPath = Path.Combine(configPath, fileIdentity);
            string folder = Path.GetDirectoryName(destinationPath);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            FileUploadManager.MoveFile(fileIdentity, destinationPath);
        }
示例#23
0
        /// <summary>
        /// 原始图片保存
        /// </summary>
        /// <param name="fileIdentity"></param>
        /// <param name="destFileName"></param>
        public static void OriginalImageSave(string fileIdentity, string destFileName)
        {
            if (string.IsNullOrWhiteSpace(fileIdentity) || string.IsNullOrWhiteSpace(destFileName))
            {
                return;
            }
            var result = FileUploadManager.FileExists(fileIdentity);

            if (result)
            {
                var filePath = FileUploadManager.GetFilePhysicalFullPath(fileIdentity);
                CreateStandardImages(fileIdentity, destFileName);

                var fileExtensionName = FileUploadManager.GetFileExtensionName(fileIdentity);
                var savePath          = FilePathHelp.GetFileSavePath(fileExtensionName.ToLower());
                OriginalImageSave(fileIdentity, destFileName, savePath);
            }
        }
示例#24
0
        public ActionResult UploadImg()
        {
            var result = new BaoYangResultEntity <Dictionary <string, string> >()
            {
                Status = false
            };

            if (Request.Files.Count <= 0)
            {
                result.Msg = "未找到上传文件";
                return(Json(result));
            }
            var imgDic  = new Dictionary <string, string>();
            var imgType = new[] { "JPG", "PNG", "GIF", "BMP" };

            foreach (var key in Request.Files.AllKeys)
            {
                Stream             stream;
                HttpPostedFileBase file = Request.Files[key];
                if (file == null || file.InputStream.Length <= 0)
                {
                    result.Msg = $"文件没有包含任何数据{file.FileName}";
                    continue;
                }
                var imgName = file.FileName.Split('.');
                if (imgName.Length < 2 || !imgType.Contains(imgName.Last().ToUpper()))
                {
                    result.Msg = $"图片验证失败{file.FileName}";
                    continue;
                }
                byte[] fileByte = new byte[file.InputStream.Length];
                stream = file.InputStream;
                stream.Read(fileByte, 0, fileByte.Length);
                var manager       = new FileUploadManager();
                var serviceResult = manager.UploadImg(fileByte);
                if (!imgDic.ContainsKey(file.FileName))
                {
                    imgDic.Add(file.FileName, $"https://img1.tuhu.org{serviceResult}");
                }
            }
            result.Status = true;
            result.Data   = imgDic;
            return(Json(result));
        }
示例#25
0
        public ActionResult Create(HttpPostedFileBase file, BlogCreateViewModel viewModel)
        {
            if (!ModelState.IsValid || file == null)
            {
                if (file == null)
                {
                    ModelState.AddModelError("", "Thumbnail is required.");
                }

                viewModel.Categories = GetList(ListType.Category);
                return(View(viewModel));
            }

            var blog = new trnblog()
            {
                Body       = viewModel.Body,
                CreateDT   = DateTime.Now,
                CategoryID = viewModel.CategoryID,
                Language   = lang,
                MemberID   = Util.SessionAccess.ID,
                PublishDT  = DateTime.Now,
                Title      = viewModel.Title,
                Active     = true
            };

            if (file != null)
            {
                var fileName = FileUploadManager.UploadAndSave(file);
                blog.ThumbnailImagePath = fileName;
            }

            db.trnblogs.Add(blog);
            db.SaveChanges();

            var emailBody = string.Format(@"Hi EZ Management, <br /><br />
                    New blog <b>{0}</b> has been created. <br /><br />
                    
                    http://www.ezgoholiday.com/EN/Blog/Details/{1}",
                                          viewModel.Title, blog.ID);

            Util.SendEmail(viewModel.Title, emailBody, Properties.Settings.Default.EmailFrom, "", "");

            return(RedirectToAction("Index"));
        }
示例#26
0
        /// <summary>
        /// 生成一组套图
        /// </summary>
        /// <param name="fileIdentity"></param>
        /// <param name="newFileName"></param>
        public static void CreateImages(string fileIdentity, string newFileName)
        {
            if (ImageList.Count == 0)
            {
                return;
            }
            var result = FileUploadManager.FileExists(fileIdentity);

            if (!result)
            {
                return;
            }
            var bytes = FileUploadManager.GetFileData(fileIdentity);

            ImageList.ForEach(v => ThreadPool.QueueUserWorkItem(
                                  delegate
            {
                var imgageHelp = new ImageUtility();
                imgageHelp.ZoomAuto(bytes, (int)v.Value.Width, (int)v.Value.Height, true);
            }));
        }
示例#27
0
        public string MoveVendorFileAttachments(string fileIdentity)
        {
            string getConfigPath = AppSettingManager.GetSetting("PO", "VendorAttachmentFilesPath");

            if (!Path.IsPathRooted(getConfigPath))
            {
                //是相对路径:
                getConfigPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, getConfigPath);
            }
            string fileName           = Guid.NewGuid().ToString() + FileUploadManager.GetFileExtensionName(fileIdentity);
            string getDestinationPath = Path.Combine(getConfigPath, fileName);
            string getFolder          = Path.GetDirectoryName(getDestinationPath);

            if (!Directory.Exists(getFolder))
            {
                Directory.CreateDirectory(getFolder);
            }
            //将上传的文件从临时文件夹剪切到目标文件夹:
            FileUploadManager.MoveFile(fileIdentity, getDestinationPath);
            return(fileName);
        }
示例#28
0
        public ActionResult Edit(HttpPostedFileBase file, BlogEditViewModel viewModel)
        {
            var blog = db.trnblogs.Single(a => a.ID == viewModel.ID);

            if (!ModelState.IsValid)
            {
                viewModel.ThumbnailImagePath =
                    string.IsNullOrEmpty(blog.ThumbnailImagePath) ?
                    "" : Path.Combine(Settings.Default.ImageUploadPath, blog.ThumbnailImagePath);
                viewModel.Categories = GetList(ListType.Category);
                return(View(viewModel));
            }

            blog.CategoryID = viewModel.CategoryID;
            blog.Title      = viewModel.Title;
            blog.Body       = viewModel.Body;
            blog.UpdateDT   = DateTime.Now;
            blog.Active     = viewModel.Active;

            if (file != null)
            {
                var fileName = FileUploadManager.UploadAndSave(file);
                blog.ThumbnailImagePath = fileName;
            }

            db.SaveChanges();

            var emailBody = string.Format(@"Hi EZ Management, <br /><br />
                    Blog <b>{0}</b> has been updated. <br /><br />
                    
                    http://www.ezgoholiday.com/EN/Blog/Details/{1}",
                                          viewModel.Title, blog.ID);

            Util.SendEmail(viewModel.Title, emailBody, Properties.Settings.Default.EmailFrom, "", "");

            return(RedirectToAction("Index"));
        }
示例#29
0
        public ActionResult Add(Guid communityId, [FromForm] ConsumptionApiModel consumptionApiModel)
        {
            try
            {
                // Guid id = Guid.Parse(attachViewModel.Id);
                FileUploadManager fileUploadManager = new FileUploadManager(consumptionApiModel.Attachment);
                string            fileName          = fileUploadManager.FileName;

                var outputFilePath = FileUploadManager.GetTempFolderPath(Guid.NewGuid().ToString() + ".xlsx");
                var byteArray      = fileUploadManager.GetByteArray();
                var consumption    = _consumptionMapper.Map(consumptionApiModel);
                consumption.Id = Guid.NewGuid();

                ServiceFactory    serviceFactory      = new ServiceFactory(this._faciTechDbContext, this._contactId);
                ConsumptionImport communityOnboarding = new ConsumptionImport(serviceFactory, communityId, outputFilePath);
                consumption.CommunityId = communityId;
                var isValid = communityOnboarding.Import(consumption, byteArray);

                FileManager fileManager = new FileManager(outputFilePath);
                var         outputFile  = new Attachment()
                {
                    FileName    = fileName,
                    FileContent = fileManager.GetByteArray(),
                    TableName   = "Consumption",
                    TableId     = consumption.Id,
                    MimeType    = consumptionApiModel.Attachment.ContentType
                };

                _attachmentService.Create(outputFile, true);
                fileUploadManager.DeleteFile();
                return(Ok(new ApiResponse(new { Id = consumption.Id, IsAllValid = isValid, FileName = fileName }, ApiStatus.Success)));
            }
            catch (Exception ex)
            {
                return(new UnknownErrorResult(ex, base._errorEnabled));
            }
        }
示例#30
0
        /// <summary>
        /// 保存视频文件
        /// </summary>
        /// <param name="fileIdentity"></param>
        /// <param name="destFileName"></param>
        public static void Save(string fileIdentity, string destFileName)
        {
            if (string.IsNullOrWhiteSpace(fileIdentity) || string.IsNullOrWhiteSpace(destFileName))
            {
                return;
            }
            var result = FileUploadManager.FileExists(fileIdentity);

            if (result)
            {
                var fileExtensionName = FileUploadManager.GetFileExtensionName(fileIdentity).ToUpper();
                var filePath          = FileUploadManager.GetFilePhysicalFullPath(fileIdentity);
                if (Image360FileExtensionName.Contains(fileExtensionName))
                {
                    if (destFileName.IndexOf(".") == -1)
                    {
                        destFileName = destFileName + "." + fileExtensionName;
                    }
                    var savePath = FilePathHelp.GetFileSavePath(fileExtensionName.ToLower());
                    savePath += FilePathHelp.GetSubFolderName(destFileName);
                    foreach (string localPath in LocalPathList)
                    {
                        string path = localPath + savePath.Replace("/", "\\");

                        //判断文件夹是否存在
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }
                        destFileName = path + destFileName;
                        //FLV文件重命名操作,不进行DFIS处理
                        File.Copy(filePath, destFileName, true);
                    }
                }
            }
        }