예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dir = FileDirectoryHelper.GetTempDirectory();

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            rauImage.TargetFolder = dir;
            //Insert
            if (DataItem is GridInsertionObject)
            {
                //Set customer to a new Customer object
                customer = new Customer();
                //Show the Insert Button
                btnInsert.Visible = true;
            }
            //Update
            else if (DataItem != null && DataItem.GetType() == typeof(Customer))
            {
                //Set customer to the dataitem cast as a Customer object being passed in from the grid
                customer = DataItem as Customer;
                //Show Update Button
                btnUpdate.Visible = true;
                //Set the Agreement Type selcted value to what the customers agreement type is
                rcbAgreementType.SelectedValue = customer.CustomerAgreementTypeID.ToString();
            }
        }
예제 #2
0
        public SearchFileResult SearchFiles(FileSearcherQuery query)
        {
            _foundFiles.Clear();
            if (string.IsNullOrEmpty(query.SearchString))
            {
                throw new ArgumentNullException("SearchString");
            }
            if (!Directory.Exists(query.TargetDirectory))
            {
                throw new DirectoryNotFoundException(string.Format("Directory {0} was not found", query.TargetDirectory));
            }
            _isCanceled = false;
            var files      = FileDirectoryHelper.GetAllFilesInDirectoryAndSubDirectories(query.TargetDirectory).ToArray();
            var totalCount = files.Count();

            for (var i = 0; i < totalCount; i++)
            {
                if (_isCanceled)
                {
                    break;
                }
                Progress = (int)Math.Round((decimal)i * 100 / totalCount);
                var fileName = files[i];
                if (IsFileContains(fileName, query.SearchString))
                {
                    _foundFiles.Add(new FileInfo(fileName));
                }
            }
            return(new SearchFileResult {
                Files = _foundFiles
            });
        }
예제 #3
0
        public ActionResult Image()
        {
            List <string> url = new List <string>();

            for (int i = 0; i < Request.Files.Count; i++)
            {
                var    _upfile  = Request.Files[i];//文件上传流
                string FileName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(_upfile.FileName);
                //保存路径
                string path = "/Upload/Image/";
                //分级目录
                string childPath = DateTime.Now.ToString("yyyyMM") + "/";
                //创建目录
                FileDirectoryHelper.CreateDirectory(Server.MapPath(path + childPath));
                //保存图片
                string file = string.Format("{0}{1}{2}", path, childPath, FileName);
                _upfile.SaveAs(Server.MapPath(file));
                url.Add(file);
            }
            if (url.Any())
            {
                return(Json(new TipMessage()
                {
                    Status = true, MsgText = "上传成功", Url = string.Join("$", url)
                }, JsonRequestBehavior.DenyGet));
            }
            return(Json(new TipMessage()
            {
                Status = false, MsgText = "没有要上传的文件"
            }, JsonRequestBehavior.DenyGet));
        }