Exemplo n.º 1
0
        public static string GetPhysicalPath(string fileStorageName, string fileExtension, string guid)
        {
            string fileID = guid;
            int    pathID = fileID.GuidSafeSub();

            return(FileManagementUtil.GetFullPath(fileStorageName, FilePathScheme.Physical, pathID, fileID, fileExtension));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据guid,尺寸获取单张图片,如果size为空,返回原图路径
        /// </summary>
        /// <param name="config"></param>
        /// <param name="guid"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static string GetHttpPath(string config, string guid, string size)
        {
            if (guid.Length < 8)
            {
                return("");
            }
            int    pathID   = guid.GuidSafeSub();
            string fullPath = FileManagementUtil.GetFullPath(config, FilePathScheme.Http, pathID, guid, "");

            string _str = FileUtil.ChangeFileNameAddSize(fullPath, size).Replace(@"http:\", "http://");

            return(_str.Replace("\\", "/"));
        }
Exemplo n.º 3
0
        public string GetHttp()
        {
            if (StorageConfigName.IsEmpty())
            {
                return(HttpPath);
            }
            if (PathID <= 0)
            {
                PathID = FileId.GuidSafeSub();
            }
            string str = FileManagementUtil.GetFullPath(StorageConfigName, FilePathScheme.Http, PathID, FileId, ExtName);

            Url = str.Replace(@"\", "/");
            return(Url);
        }
Exemplo n.º 4
0
        private void MoveKeyPathByIndex(int index, string newGuid, string storageName, bool isOnly = false)
        {
            ResourceInfo info = ResourceInfoList[index];

            if (!isOnly)
            {
                info.StorageConfigName = storageName;
            }
            string storage       = storageName;
            string fileExtension = info.ExtName;
            int    newPathID     = newGuid.GuidSafeSub();
            string newPath       = FileManagementUtil.GetFullPath(storage, FilePathScheme.Physical, newPathID, newGuid, fileExtension);

            newPath = new Uri(newPath).LocalPath;
            int    oldPathId = info.PathID;
            string oldFileId = info.FileId;
            string oldPath   = FileManagementUtil.GetFullPath(info.StorageConfigName, FilePathScheme.Physical, oldPathId, oldFileId, fileExtension);

            oldPath = new Uri(oldPath).LocalPath;
            if (oldPath != newPath)
            {
                MoveFile(oldPath, newPath);



                foreach (var cut in info.ExtendList)
                {
                    string _oldPathExt = Path.GetFileNameWithoutExtension(oldPath);
                    string _oldpath    = FileUtil.ChangeFileName(oldPath, "{0}_{1}".AkFormat(_oldPathExt, cut.Value));

                    string _newPathExt = Path.GetFileNameWithoutExtension(newPath);
                    string _newpath    = FileUtil.ChangeFileName(newPath, "{0}_{1}".AkFormat(_newPathExt, cut.Value));

                    MoveFile(_oldpath, _newpath);
                }

                //---------------改变了
                info.FileId       = newGuid;
                info.PathID       = newPathID;
                info.PhysicalPath = newPath;
                info.HttpPath     = FileManagementUtil.GetFullPath(info.StorageConfigName,
                                                                   FilePathScheme.Http, newPathID, newGuid, fileExtension);
            }
        }
Exemplo n.º 5
0
        public override BaseOptions Create()
        {
            //var options = base.Create();
            //var UploadType = base.Config.ControlType;
            //var options = base.Create() as BaseUploadOptions;
            //UploadConfig uploadC = new UploadConfig();
            //string UploadInfo = FileManagementUtil.getFileUploadInfo(UploadType.ToString());
            //uploadC.FileLength = System.Convert.ToInt64(UploadInfo.Split(' ')[0]);
            //uploadC.FileExtension = UploadInfo.Split(' ')[1];
            //uploadC.FilePath = UploadInfo.Split(' ')[2];
            //if (UploadType.ToString() == "ImageUpload")
            //{
            //    uploadC.ImageSizeHeight = System.Convert.ToInt32(UploadInfo.Split(' ')[3]);
            //    uploadC.ImageSizeWidth = System.Convert.ToInt32(UploadInfo.Split(' ')[4]);
            //}
            //options.Upload = this.Config.Upload;
            // options.Upload = uploadC;
            base.Create();
            if (this.Config.Upload != null && !this.Config.Upload.UploadName.IsEmpty())
            {
                var config = FileManagementUtil.GetFileUploadConfig(this.Config.Upload.UploadName);
                fBaseUploadOptions.FileSize          = config.MaxSize;
                fBaseUploadOptions.FileExtension     = config.Extensions;
                fBaseUploadOptions.StorageName       = this.Config.Upload.StorageName;
                fBaseUploadOptions.UploadName        = this.Config.Upload.UploadName;
                fBaseUploadOptions.ImageSizeHeight   = config.ImageSizeHeight;
                fBaseUploadOptions.ImageSizeWidth    = config.ImageSizeWidth;
                fBaseUploadOptions.HasDocumentCenter = this.Config.Upload.HasDocumentCenter;

                //if (fBaseUploadOptions is AtawImageDetailOptions)
                //{
                // var options = base.Create();
                if (this.Config.Upload != null && this.Config.Upload.StorageName != null)
                {
                    fBaseUploadOptions.StorageName = this.Config.Upload.StorageName;
                }
                if (!fBaseUploadOptions.StorageName.IsEmpty())
                {
                    DataTable dt = this.PageView.Data.Tables[this.FormView.TableName];
                    if (dt != null && dt.Columns.Contains(this.Config.Name))
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            string          _str    = row[this.Config.Name].ToString();
                            ResourceArrange arrange = _str.SafeJsonObject <ResourceArrange>();
                            if (arrange != null)
                            {
                                if (arrange.ResourceInfoList != null)
                                {
                                    foreach (ResourceInfo info in arrange.ResourceInfoList)
                                    {
                                        string _fid    = info.FileId;
                                        string _ext    = info.ExtName;
                                        int    _pathId = info.PathID;

                                        string _http = FileManagementUtil.GetFullPath(fBaseUploadOptions.StorageName, FilePathScheme.Http, _pathId, _fid, _ext);
                                        // string sConfig = this.fTextOptions.
                                        info.HttpPath = _http;
                                    }

                                    row[this.Config.Name] = AtawAppContext.Current.FastJson.ToJSON(arrange);
                                }
                            }
                        }
                    }
                }
                //}

                if (fBaseUploadOptions is SingleImageUploadOptions)
                {
                    var _op = (SingleImageUploadOptions)fBaseUploadOptions;
                    if (!config.ImageCutGroupName.IsEmpty())
                    {
                        var _list = FileManagementUtil.GetImageCutsByCutConfigName(config.ImageCutGroupName);

                        //var _cuts = FileManagementUtil.FileManagementConfig.ImageCutGroups;
                        //if (_cuts != null && _cuts.Count > 0)
                        //{
                        //    ImageCutGroup cut = _cuts.FirstOrDefault(a => a.Name == config.ImageCutName);
                        //    AtawDebug.Assert(cut != null && cut.ImageCutList.Count > 0, string.Format(ObjectUtil.SysCulture,
                        //        "名称为{0}的截图配置不存在,或者没有截图配置项", config.ImageCutName), this);
                        //var _cconfig = _list[0];
                        //_op.ImageSizeHeight = _cconfig.ImageSizeHeight;
                        //_op.ImageSizeWidth = _cconfig.ImageSizeWidth;
                        //如果ImageSizeHeight和ImageSizeWidth没有配置那么默认为0,如果为0那么将不限制你要裁剪的大小比例
                        if (config.ImageSizeHeight != null && !config.ImageSizeHeight.Equals("") && config.ImageSizeWidth != null && !config.ImageSizeWidth.Equals(""))
                        {
                            _op.ImageSizeHeight = config.ImageSizeHeight;
                            _op.ImageSizeWidth  = config.ImageSizeWidth;
                        }
                        else
                        {
                            _op.ImageSizeHeight = 0;
                            _op.ImageSizeWidth  = 0;
                        }

                        //}
                    }
                    // ((SingleImageUploadOptions)fBaseUploadOptions).ImageSizeHeight = config.ImageSizeHeight;
                    //((SingleImageUploadOptions)fBaseUploadOptions).ImageSizeWidth = config.ImageSizeWidth;
                    _op.IsCut = this.Config.Upload.IsCut;
                }
            }
            string colName   = this.Config.Name;
            string tableName = this.FormView.TableName;
            var    ds        = this.PageView.Data;

            //if (PageStyle == PageStyle.Detail || PageStyle == Core.PageStyle.List)
            //{
            //if (ds.Tables.Contains(tableName))
            //{
            //    foreach (DataRow row in ds.Tables[tableName].Rows)
            //    {
            //        string val = row[colName].ToString();
            //        if (!val.IsEmpty())
            //        {
            //            bool isError = false;
            //            ResourceInfo resourceInfo = null;
            //            try
            //            {
            //                resourceInfo = AtawAppContext.Current.FastJson.ToObject<ResourceInfo>(val);
            //            }
            //            catch
            //            {
            //                isError = true;
            //            }
            //            if (!isError)
            //            {
            //                string fileStorageName = this.Config.Upload.StorageName;
            //                string fullPath = FileManagementUtil.GetFullPath(fileStorageName, FilePathScheme.Http,
            //                    resourceInfo.PathID, resourceInfo.FileId, resourceInfo.ExtName);
            //                row[colName] = fullPath;
            //            }
            //        }
            //        //}
            //    }

            // }
            return(fBaseUploadOptions);
        }