Esempio n. 1
0
 protected void lnk_Delete_Click(object sender, System.EventArgs e)
 {
     if (!base.IsAuthorizedOp(ActionType.Delete.ToString()))
     {
         base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền");
     }
     else
     {
         int            @int     = WebUtils.GetInt((sender as LinkButton).CommandArgument);
         FileUploadInfo dataById = SinGooCMS.BLL.FileUpload.GetDataById(@int);
         if (dataById == null)
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "没有找到文件,文件不存在或者已删除");
         }
         else if (SinGooCMS.BLL.FileUpload.DelBatAndFile(@int.ToString()))
         {
             this.BindData();
             PageBase.log.AddEvent(base.LoginAccount.AccountName, "删除上传文件[" + dataById.VirtualPath + "] thành công");
             base.ShowAjaxMsg(this.UpdatePanel1, "删除文件成功");
         }
         else
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "删除文件失败");
         }
     }
 }
Esempio n. 2
0
        public void FileUploadInfoInitsWithNoArgs()
        {
            var fileUploadInfo = new FileUploadInfo();

            Assert.NotNull(fileUploadInfo);
            Assert.IsType <FileUploadInfo>(fileUploadInfo);
        }
        private void DownloadOpen(string id, string name)
        {
            string tempFilePath = "";

            try
            {
                FileUploadInfo fileInfo = BLLFactory <FileUpload> .Instance.Download(id);

                if (fileInfo != null && fileInfo.FileData != null)
                {
                    string extension = fileInfo.FileExtend.ToLower();
                    string fileName  = fileInfo.FileName;

                    this.SendToBack();

                    FileUtil.OpenFileInProcess(fileName, fileInfo.FileData);

                    this.BringToFront();
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError("下载文件出现错误。具体如下:\r\n" + ex.Message);
            }
            finally
            {
                bool flag2 = File.Exists(tempFilePath);
                if (flag2)
                {
                    File.Delete(tempFilePath);
                }
            }
        }
        /// <summary>
        /// Creates a new audio track in Brightcove by uploading a file.
        /// </summary>
        /// <param name="audioTrack">The audio track to create</param>
        /// <param name="fileUploadInfo">Information for the file to be uploaded.</param>
        /// <returns>The numeric ID of the uploaded track</returns>
        public long CreateAudioTrack(BrightcoveAudioTrack audioTrack, FileUploadInfo fileUploadInfo)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("create_audiotrack",
                                                                         methodParams => methodParams.Add("audiotrack", audioTrack));

            return(RunFilePost <BrightcoveResultContainer <long> >(parms, fileUploadInfo).Result);
        }
Esempio n. 5
0
        /// <summary>
        /// 文件上传后调用自有业务
        /// <para>自有业务是指,数字档案上传,则存在数字档案的表</para>
        /// <para>工作流的业务,则执行工作流的业务</para>
        /// </summary>
        /// <param name="targetPath"></param>
        /// <returns>返回文件对象</returns>
        private FileUploadInfo OwnBusiness(string targetPath)
        {
            FileUploadInfo fileResult = new FileUploadInfo();
            var            pageType   = Request["pagetype"];

            switch (pageType.ToLower())
            {
            case "flow":      // 工作流
                fileResult = SaveFlowFileOrdinaryChunk(targetPath);
                break;

            case "rent_doc_detail":       // 数字档案
                fileResult = SaveFileOrdinaryChunk(targetPath);
                break;

            case "rent_press_detail":       // 欠租追缴
                fileResult = SavePressDetailFileOrdinaryChunk(targetPath);
                break;

            default:        // 其他(附件)
                fileResult = SaveAccessoryFileOrdinaryChunk(targetPath);
                break;
            }
            return(fileResult);
        }
Esempio n. 6
0
        /// <summary>
        /// 根据附件对象信息获取文件路径
        /// </summary>
        /// <param name="info">附件对象信息</param>
        /// <returns></returns>
        private string GetFilePath(FileUploadInfo info)
        {
            string filePath = BLLFactory <FileUpload> .Instance.GetFilePath(info);

            filePath = filePath.Replace("\\", "/");
            return(HttpUtility.UrlPathEncode(filePath));
        }
Esempio n. 7
0
        public List <FileUploadInfo> Query(string Email, bool isAccurate = false)
        {
            List <FileUploadInfo> userList = new List <FileUploadInfo>();
            DataSet ds = new DataSet();

            if (isAccurate)
            {
                string   cmdText   = "select * from UserInfo where email = @email";
                string[] paramList = { "@email" };
                object[] valueList = { Email };
                ds = db.FillDataSet(cmdText, paramList, valueList);
            }
            else
            {
                string   cmdText   = "select * from UserInfo where email like @email";
                string[] paramList = { "@email" };
                object[] valueList = { "%" + Email + "%" };
                ds = db.FillDataSet(cmdText, paramList, valueList);
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow        dr   = ds.Tables[0].Rows[i];
                FileUploadInfo user = new FileUploadInfo();
                userList.Add(user);
            }
            return(userList);
        }
Esempio n. 8
0
        /// <summary>
        /// 合并文件
        /// </summary>
        /// <returns></returns>
        public JsonResult MergeFiles(string md5, string filename)
        {
            try
            {
                //源数据文件夹
                string sourcePath = getFileMD5Folder();
                //合并后的文件路径
                string targetFilePath = sourcePath + Path.GetExtension(filename);
                // 目标文件不存在,则需要合并
                if (!System.IO.File.Exists(targetFilePath))
                {
                    if (!Directory.Exists(sourcePath))
                    {
                        return(Json(JResult.Error("未找到对应的文件片")));
                    }

                    MergeDiskFile(sourcePath, targetFilePath);
                }

                var vaild = VaildMergeFile(targetFilePath);
                if (!vaild.Result)
                {
                    return(Json(vaild));
                }
                DeleteFolder(sourcePath);
                FileUploadInfo fileResult = OwnBusiness(targetFilePath);
                return(Json(JResult.Success(fileResult)));
            }
            catch (Exception ex)
            {
                return(Json(JResult.Error(ex.Message)));
            }
        }
Esempio n. 9
0
        /////////////////////////////////////////////////////////////////////////////////
        // PUT /oss/{apiversion}/buckets/{bucketkey}/objects/{objectkey}
        //
        /////////////////////////////////////////////////////////////////////////////////
        public Task <ObjectDetailsResponse> UploadFileAsync(
            string bucketKey,
            FileUploadInfo fi)
        {
            string objectKey = Uri.EscapeDataString(fi.Key.Replace(" ", "_"));

            using (BinaryReader binaryReader = new BinaryReader(fi.InputStream))
            {
                RestRequest request = new RestRequest(
                    "oss/v1/buckets/" + bucketKey.ToLower() +
                    "/objects/" + objectKey,
                    Method.PUT);

                request.AddHeader("Authorization", "Bearer " + TokenResponse.AccessToken);

                request.AddParameter("Content-Type", "application/stream");
                request.AddParameter("Content-Length", fi.Length);

                byte[] fileData = binaryReader.ReadBytes((int)fi.Length);

                request.AddParameter("requestBody", fileData, ParameterType.RequestBody);

                request.Timeout = 1000 * 60 * 60; //1 hour timeout

                return(_restClient.ExecuteAsync
                       <ObjectDetailsResponse>(
                           request));
            }
        }
Esempio n. 10
0
        public ActionResult Edit(int?id)
        {
            var o = db.Set <Plugin>().Where(x => x.Id == id).FirstOrDefault();
            PluginCreateOrEditViewModel viewModel = null;

            if (o != null)
            {
                AddViewBag(o);
                viewModel = new PluginCreateOrEditViewModel()
                {
                    Name        = o.Name,
                    Description = o.Description
                };
                var files = new List <FileUploadInfo>();
                foreach (var f in o.Files)
                {
                    var image = db.Files.Where(x => x.Id == f.FileId).FirstOrDefault();
                    if (image != null && image.Length > 0)
                    {
                        var fileUploadInfo = new FileUploadInfo()
                        {
                            FileName  = image.Name,
                            Extension = "",
                            UID       = ""
                        };
                        files.Add(fileUploadInfo);
                    }
                }
                viewModel.Files = files;
            }
            return(Edit <Plugin>("CreateOrEdit", viewModel));
        }
Esempio n. 11
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string text = WebUtils.GetQueryString("file");

            try
            {
                text = DEncryptUtils.DESDecode(text);
            }
            catch
            {
                text = string.Empty;
            }
            string text2 = base.Server.MapPath(text);

            if (System.IO.File.Exists(text2))
            {
                FileUploadInfo model = PageBase.dbo.GetModel <FileUploadInfo>(" select top 1 * from sys_FileUpload where VirtualPath='" + text + "' ");
                if (model != null)
                {
                    model.DownloadCount++;
                    FileUpload.Update(model);
                }
                ResponseUtils.ResponseFile(text2);
            }
            else
            {
                base.Response.Write(base.GetCaption("CMS_FileNotExist"));
                base.Response.End();
            }
        }
Esempio n. 12
0
        private FileUploadReturnInfo UploadFile(ImageInformation ii, ServerInfo si)
        {
            FileUploadInfo fui = new FileUploadInfo();

            fui.overwrite = true;
            fui.name      = ii.filename;
            fui.type      = Mimetypes.MimeType(ii.filename);

            BinaryReader br = new BinaryReader(File.Open(ii.fullpath, FileMode.Open));

            byte[] bytes = new byte[br.BaseStream.Length];
            br.Read(bytes, 0, (int)br.BaseStream.Length);
            br.Close();
            fui.bits = bytes;

            try
            {
                FileUploadReturnInfo retval = si.conn.UploadFile(0, si.username, si.password, fui);
                return(retval);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(null);
            }
        }
Esempio n. 13
0
        public List <FileUploadInfo> QueryFileUploadInfo(QueryConditionBase queryInfo)
        {
            int res = 0;
            List <FileUploadInfo> tempFileUploadInfoList = new List <FileUploadInfo>();

            String quserSql = GenerateQuerySql(queryInfo);

            MySqlConnectHelper mysqlCnn = MySqlConnectPoolHelper.getPool().getConnection();

            res = mysqlCnn.SelectDB(dbName);

            MySqlDataReader dataReader = mysqlCnn.ExecuteReader(CommandType.Text, quserSql, null);

            while (dataReader.Read())
            {
                FileUploadInfo tempFileUploadInfo = new FileUploadInfo();

                tempFileUploadInfo.ID       = (int)dataReader["ID"];
                tempFileUploadInfo.DateTime = (string)dataReader["DateTime"];
                tempFileUploadInfo.Content  = (string)dataReader["Content"];
                tempFileUploadInfo.UserName = (string)dataReader["UserName"];
                string tempDeviceList = (string)dataReader["FilePathList"];
                tempFileUploadInfo.FilePathList = tempDeviceList.Split(',');

                tempFileUploadInfoList.Add(tempFileUploadInfo);
            }

            dataReader.Close();
            MySqlConnectPoolHelper.getPool().closeConnection(mysqlCnn);
            mysqlCnn = null;

            return(tempFileUploadInfoList);
        }
Esempio n. 14
0
        private async Task <File> GetFileInfo(string message, FileUploadInfo uploadInfo)
        {
            var fileDto = new File();

            fileDto.Path = uploadInfo.FilePath;

            System.IO.MemoryStream readStream = null;
            try
            {
                readStream = await _storage.GetFile(uploadInfo.FilePath);

                fileDto.FileSize = readStream.Length;
                fileDto.IsValid  = FileIsDicom(readStream);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "ProcessMessage. Deserialization failed for file " + message);
            }
            finally
            {
                readStream.Close();
            }

            return(fileDto);
        }
Esempio n. 15
0
        /// <summary>
        /// 根据附件ID,获取对应查看的视图URL。
        /// 一般规则如果是图片文件,返回视图URL地址'/FileUpload/ViewAttach';
        /// 如果是Office文件(word、PPT、Excel)等,可以通过微软的在线查看地址进行查看:'http://view.officeapps.live.com/op/view.aspx?src=',
        /// 也可以进行本地生成HTML文件查看。如果是其他文件,可以直接下载地址。
        /// </summary>
        /// <param name="id">附件的ID</param>
        /// <returns></returns>
        public ActionResult GetAttachViewUrl(string id)
        {
            string         viewUrl = "";
            FileUploadInfo info    = BLLFactory <FileUpload> .Instance.FindByID(id);

            if (info != null)
            {
                string ext      = info.FileExtend.Trim('.').ToLower();
                string filePath = GetFilePath(info);

                bool   officeInternetView = false;                                              //是否使用互联网在线预览
                string hostName           = HttpUtility.UrlPathEncode("http://www.iqidi.com/"); //可以配置一下,如果有必要

                if (ext == "xls" || ext == "xlsx" || ext == "doc" || ext == "docx" || ext == "ppt" || ext == "pptx")
                {
                    if (officeInternetView)
                    {
                        //返回一个微软在线浏览Office的地址,需要加上互联网域名或者公网IP地址
                        viewUrl = string.Format("http://view.officeapps.live.com/op/view.aspx?src={0}{1}", hostName, filePath);
                    }
                    else
                    {
                        #region 动态第一次生成文件
                        //检查本地Office文件是否存在,如不存在,先生成文件,然后返回路径供查看
                        string webPath          = string.Format("/GenerateFiles/Office/{0}.htm", info.ID);
                        string generateFilePath = Server.MapPath(webPath);
                        if (!FileUtil.FileIsExist(generateFilePath))
                        {
                            string templateFile = BLLFactory <FileUpload> .Instance.GetFilePath(info);

                            templateFile = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, templateFile.Replace("\\", "/"));

                            if (ext == "doc" || ext == "docx")
                            {
                                Aspose.Words.Document doc = new Aspose.Words.Document(templateFile);
                                doc.Save(generateFilePath, Aspose.Words.SaveFormat.Html);
                            }
                            else if (ext == "xls" || ext == "xlsx")
                            {
                                Workbook workbook = new Workbook(templateFile);
                                workbook.Save(generateFilePath, SaveFormat.Html);
                            }
                            else if (ext == "ppt" || ext == "pptx")
                            {
                                templateFile = templateFile.Replace("/", "\\");
                                PresentationEx pres = new PresentationEx(templateFile);
                                pres.Save(generateFilePath, Aspose.Slides.Export.SaveFormat.Html);
                            }
                        }
                        #endregion
                        viewUrl = webPath;
                    }
                }
                else
                {
                    viewUrl = filePath;
                }
            }
            return(Content(viewUrl));
        }
Esempio n. 16
0
        public ActionResult Edit(int?id)
        {
            var           o         = db.Set <ViewTemplate>().Where(x => x.Id == id).FirstOrDefault();
            ViewModelBase viewModel = null;

            if (o != null)
            {
                AddViewBag(o);
                viewModel = new ViewTemplateCreateOrEditViewModel()
                {
                    Name                = o.Name,
                    Description         = o.Description,
                    PageContentTypeId   = o.PageContentTypeId,
                    PageContentTypeName = o.PageContentType != null ? o.PageContentType.Name : string.Empty
                };
                var files = new List <FileUploadInfo>();
                foreach (var f in o.Files)
                {
                    var file = db.Files.Where(x => x.Id == f.FileId).FirstOrDefault();
                    if (file != null && file.Length > 0)
                    {
                        var fileUploadInfo = new FileUploadInfo()
                        {
                            FileName  = file.Name,
                            Extension = "",
                            UID       = ""
                        };
                        files.Add(fileUploadInfo);
                    }
                }
                ((ViewTemplateCreateOrEditViewModel)viewModel).Files = files;
            }
            return(Edit <ViewTemplate>("CreateOrEdit", viewModel));
        }
Esempio n. 17
0
        private async Task ProcessMessage(string message, CancellationToken token)
        {
            _logger.LogInformation("ProcessMessage. File received " + message);

            FileUploadInfo uploadInfo = null;

            try
            {
                uploadInfo = JsonConvert.DeserializeObject <FileUploadInfo>(message);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "ProcessMessage. Deserialization failed for file " + message);
            }

            File fileDto = await GetFileInfo(message, uploadInfo);

            _logger.LogInformation("ProcessMessage. File parsed " + message);

            using (var scope = _scopeFactory.CreateScope())
            {
                var context = scope.ServiceProvider.GetRequiredService <FileStorageContext>();
                context.Files.Add(fileDto);
                await context.SaveChangesAsync();
            }

            _logger.LogInformation("ProcessMessage. File info saved to database " + message);
        }
Esempio n. 18
0
        protected void Button6_Click(object sender, EventArgs e)
        {
            FileUploadInfo lbg = new FileUploadInfo(this.booklib.Text, this.libphone.Text);

            lbg = bll.selectlib(lbg);
            string type    = DropDownList2.SelectedValue.ToString();
            string picpath = this.FileUpload4.PostedFile.FileName;

            UpBook          lg = new UpBook(this.bookName.Text, this.author.Text, this.intrduce.Text, type, this.maxcount.Text, this.usablecount.Text, lbg.path, picpath);
            OperationResult bp = bll.Registbook(lg);

            this.Image3.ImageUrl = "~/UploadPic/" + FileUpload4.FileName;


            if (bp.ToString() == "exist")
            {
                this.booktishi.Text = "记录已存在";
            }
            else if (bp.ToString() == "success")
            {
                string          user = Session["user"].ToString();
                string          text = user.ToString() + "上传图书信息:" + this.bookName.Text;
                daysInfo        da   = new daysInfo(user, DateTime.Now.ToLocalTime().ToString(), text);
                commentBll      bal  = new commentBll();
                OperationResult ob   = bal.Registday(da);
                this.booktishi.Text = "成功.";
                this.FileUpload4.SaveAs(Server.MapPath("~/UploadPic/") + FileUpload4.FileName);
            }
            else
            {
                this.booktishi.Text = "意外";
            }
        }
Esempio n. 19
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            if (Session["user"] != null)
            {
                bool fileVaild = false;
                if (this.FileUpload1.HasFile)
                {
                    string   fileExtension = System.IO.Path.GetExtension(this.FileUpload1.FileName).ToLower();
                    string[] restrict      = { ".gif", ".jpg", ".jpeg", ".png", ".txt" };
                    for (int i = 0; i < restrict.Length; i++)
                    {
                        if (fileExtension == restrict[i])
                        {
                            fileVaild = true;
                        }
                    }

                    if (fileVaild == true)
                    {
                        try
                        {
                            this.Image1.ImageUrl = "~/UploadPic/" + FileUpload1.FileName;


                            string path = this.FileUpload1.PostedFile.FileName;


                            FileUploadInfo info = new FileUploadInfo(this.libname.Text, this.lobintr.Text, this.libphone.Text, this.lobpro.Text, this.lobcty.Text, this.adree.Text, path);


                            OperationResult op = bll.Registlib(info);
                            if (op.ToString() == "exist")
                            {
                                this.Label4.Text = "记录已存在";
                            }
                            else if (op.ToString() == "success")
                            {
                                this.Label4.Text = "成功";
                                string          user = Session["user"].ToString();
                                string          text = user.ToString() + "上传图书馆信息:" + this.libname.Text;
                                daysInfo        da   = new daysInfo(user, DateTime.Now.ToLocalTime().ToString(), text);
                                commentBll      bal  = new commentBll();
                                OperationResult ob   = bal.Registday(da);


                                this.FileUpload1.SaveAs(Server.MapPath("~/UploadPic/") + FileUpload1.FileName);
                            }
                            else
                            {
                                this.Label4.Text = "意外";
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// 根据附件对象信息获取文件路径
        /// </summary>
        /// <param name="info">附件对象信息</param>
        /// <returns></returns>
        private string GetFilePath(FileUploadInfo info)
        {
            var filePath = PathCombine(info.BasePath, info.SavePath.Replace('\\', '/'));

            //string filePath = BLLFactory<FileUpload>.Instance.GetFilePath(info);
            filePath = filePath.Replace("\\", "/");
            return(HttpUtility.UrlPathEncode(filePath));
        }
Esempio n. 21
0
        public int Update(FileUploadInfo user)
        {
            string cmdText = "update UserInfo set pwd=@pwd,realName=@realName where userName=@userName";

            string[] paramList  = { "@email", "@password", "@userName" };
            object[] valuesList = {};
            return(db.ExecuteNoneQuery(cmdText, paramList, valuesList));
        }
Esempio n. 22
0
        public int Addlib(FileUploadInfo user)
        {
            string cmdText = "insert into T_Library(libName,introduce,phone,province,city,address,isDelete,path) values(@libName,@introduce,@phone,@province,@city,@address,@isDelete,@path)";

            string[] paramList = { "@libName", "@introduce", "@phone", "@province", "@city", "@address", "@isDelete", "path" };
            object[] valueList = { user.name, user.intrduce, user.phone, user.province, user.city, user.adreess, 0, user.path };
            return(db.ExecuteNoneQuery(cmdText, paramList, valueList));
        }
Esempio n. 23
0
        public int Add(FileUploadInfo user)
        {
            string cmdText = "insert into T_Path(path,type) values(@path,@type)";

            string[] paramList = { "@path", "@type" };
            object[] valueList = { user.path, user.type };
            return(db.ExecuteNoneQuery(cmdText, paramList, valueList));
        }
Esempio n. 24
0
 /// <summary>
 /// Creates a new <see cref="FileInfoCard"/> instance and initializes it from a <see cref="FileUploadInfo"/> object.
 /// </summary>
 /// <param name="fileUploadInfo">File upload info</param>
 /// <returns>A new instance of the <see cref="FileInfoCard"/> class</returns>
 public static FileInfoCard FromFileUploadInfo(FileUploadInfo fileUploadInfo)
 {
     return(new FileInfoCard
     {
         Name = fileUploadInfo.Name,
         ContentUrl = fileUploadInfo.ContentUrl,
         FileType = fileUploadInfo.FileType,
         UniqueId = fileUploadInfo.UniqueId,
     });
 }
Esempio n. 25
0
        /// <summary>
        /// 上传图书馆信息
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public OperationResult Registlib(FileUploadInfo file)
        {
            int mun = dao.Addlib(file);

            if (mun == 1)
            {
                return(OperationResult.success);
            }
            return(OperationResult.failure);
        }
Esempio n. 26
0
        public void uploadToDb(FileUploadInfo fileInfo)
        {
            var uploadFile = new UploadFile()
            {
                Serial      = fileInfo.serial,
                DataContent = fileInfo.Stream
            };

            uploadRepo.Add(uploadFile);
        }
Esempio n. 27
0
        //信息表单保存按钮
        public void InfoFormSubmit_Click(object sender, EventArgs e)
        {
            //logo
            long hidLogoFileID = 0;

            try { hidLogoFileID = long.Parse(hidInfoFormLogoFileID.Value); } catch { }
            FileUploadInfo logoUploadInfo = null;

            if (inpInfoFormLogo.PostedFile.ContentLength > 0)
            {
                logoUploadInfo = Ziri.BLL.SYS.DOC.Upload(inpInfoFormLogo.PostedFile, MapPath("/DOC/upload/"), out string Message);
                if (Message != null)
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "InfoFormSaveMessage"
                                                            , string.Format("<script> document.getElementById('btnListInfoFormModal').click(); swal('{0}', '', '{1}'); </script>", Message, AlertType.error));
                    return;
                }
            }

            //banner
            long hidBannerFileID = 0;

            try { hidBannerFileID = long.Parse(hidInfoFormBannerFileID.Value); } catch { }
            FileUploadInfo bannerUploadInfo = null;

            if (inpInfoFormBanner.PostedFile.ContentLength > 0)
            {
                bannerUploadInfo = Ziri.BLL.SYS.DOC.Upload(inpInfoFormBanner.PostedFile, MapPath("/DOC/upload/"), out string Message);
                if (Message != null)
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "InfoFormSaveMessage"
                                                            , string.Format("<script> document.getElementById('btnListInfoFormModal').click(); swal('{0}', '', '{1}'); </script>", Message, AlertType.error));
                    return;
                }
            }

            //post data
            var BrandInfo = new Ziri.MDL.BrandInfo
            {
                ID           = long.Parse(hidInfoFormBrandID.Value),
                Name         = inpInfoFormBrandName.Text,
                Title        = inpInfoFormBrandTitle.Text,
                LogoFileID   = logoUploadInfo == null ? hidLogoFileID : logoUploadInfo.FileInfo.ID,
                BannerFileID = bannerUploadInfo == null ? hidBannerFileID : bannerUploadInfo.FileInfo.ID,
            };

            BrandInfo = Ziri.BLL.ITEM.Brand.BrandInfoUpload(BrandInfo, out AlertMessage alertMessage);
            if (alertMessage == null)
            {
                ListBind();
            }
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "InfoFormMessage", alertMessage == null
                ? string.Format("<script> swal('保存完成,品牌编号[{0}]。', '', '{1}'); </script>", BrandInfo.ID, AlertType.success)
                : string.Format("<script> document.getElementById('btnListInfoFormModal').click(); swal('{0}', '', '{1}'); </script>", alertMessage.Message, alertMessage.Type));
        }
Esempio n. 28
0
        private void QueueFileUpload(PatchAsset asset, FileCompressionMode compress)
        {
            var info = new FileUploadInfo()
            {
                Asset    = asset,
                Compress = compress
            };

            lock (_uploadQueue)
                _uploadQueue.Enqueue(info);
        }
Esempio n. 29
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            if (this.listView1.CheckedItems.Count == 0)
            {
                MessageDxUtil.ShowTips("请勾选下载的文件!");
                return;
            }
            StringBuilder sb = new StringBuilder();

            string path = FileDialogHelper.OpenDir();

            if (!string.IsNullOrEmpty(path))
            {
                DirectoryUtil.AssertDirExist(Path.GetDirectoryName(path));

                #region  载保存图片
                bool hasError = false;

                foreach (ListViewItem item in this.listView1.CheckedItems)
                {
                    if (item != null && item.Tag != null)
                    {
                        string id = item.Tag.ToString();

                        try
                        {
                            FileUploadInfo fileInfo = BLLFactory <FileUpload> .Instance.Download(id);

                            if (fileInfo != null && fileInfo.FileData != null)
                            {
                                string filePath = Path.Combine(path, fileInfo.FileName);
                                FileUtil.CreateFile(filePath, fileInfo.FileData);
                            }
                        }
                        catch (Exception ex)
                        {
                            hasError = true;
                            sb.Append(ex.Message + "\r\n");
                            LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmAttachmentGroupView));
                        }
                    }
                }
                #endregion

                if (hasError)
                {
                    MessageDxUtil.ShowError(sb.ToString());
                }
                else
                {
                    System.Diagnostics.Process.Start(path);
                }
            }
        }
Esempio n. 30
0
        public ActionResult Upload(HttpPostedFileBase fileData, string guid, string folder)
        {
            CommonResult result = new CommonResult();

            if (fileData != null)
            {
                try
                {
                    ControllerContext.HttpContext.Request.ContentEncoding  = Encoding.GetEncoding("UTF-8");
                    ControllerContext.HttpContext.Response.ContentEncoding = Encoding.GetEncoding("UTF-8");
                    ControllerContext.HttpContext.Response.Charset         = "UTF-8";

                    // 文件上传后的保存路径
                    string filePath = Server.MapPath("~/UploadFiles/");
                    DirectoryUtil.AssertDirExist(filePath);

                    string fileName      = Path.GetFileName(fileData.FileName);       //原始文件名称
                    string fileExtension = Path.GetExtension(fileName);               //文件扩展名
                    string saveName      = Guid.NewGuid().ToString() + fileExtension; //保存文件名称

                    FileUploadInfo info = new FileUploadInfo();
                    info.FileData = ReadFileBytes(fileData);
                    if (info.FileData != null)
                    {
                        info.FileSize = info.FileData.Length;
                    }
                    info.Category       = folder;
                    info.FileName       = fileName;
                    info.FileExtend     = fileExtension;
                    info.AttachmentGUID = guid;
                    info.AddTime        = DateTime.Now;
                    info.Editor         = CurrentUser.Name;//登录人
                    //info.Owner_ID = OwerId;//所属主表记录ID

                    result = BLLFactory <FileUpload> .Instance.Upload(info);

                    if (!result.Success)
                    {
                        LogTextHelper.Error("上传文件失败:" + result.ErrorMessage);
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorMessage = ex.Message;
                    LogTextHelper.Error(ex);
                }
            }
            else
            {
                result.ErrorMessage = "fileData对象为空";
            }

            return(ToJsonContent(result));
        }
Esempio n. 31
0
        private FileUploadReturnInfo UploadFile(ImageInformation ii, ServerInfo si)
        {
            FileUploadInfo fui = new FileUploadInfo();
            fui.overwrite = true;
            fui.name = ii.filename;
            fui.type = Mimetypes.MimeType(ii.filename);

            BinaryReader br = new BinaryReader(File.Open(ii.fullpath, FileMode.Open));
            byte[] bytes = new byte[br.BaseStream.Length];
            br.Read(bytes, 0, (int)br.BaseStream.Length);
            br.Close();
            fui.bits = bytes;

            try
            {
                FileUploadReturnInfo retval = si.conn.UploadFile(0, si.username, si.password, fui);
                return retval;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return null;
            }
        }