示例#1
0
        /// <summary>
        /// Permet d'attacher un fichier à un bundle
        /// </summary>
        /// <param name="date"></param>
        /// <param name="filePath"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public StdResult<BundleFile> AttachFileToBundle(DateTime date, string filePath, BundleFileType type)
        {
            if(!File.Exists(filePath))
                throw new CollecteException("Le fichier indiqué n'existe pas.");

            switch (type)
            {
                case BundleFileType.CsvIn:
                case BundleFileType.CsvOut:
                if (new FileInfo(filePath).Extension != ".csv")
                    throw new CollecteException("Le fichier n'a pas la bonne extension.");
                break;
                case BundleFileType.XmlTrade:
                if (new FileInfo(filePath).Extension != ".xml")
                    throw new CollecteException("Le fichier n'a pas la bonne extension.");
                break;
            }

            BundleFile bFile = new BundleFile
            {
                //Bundle = resultBundle.ReturnObject,
                CreationDate = DateTime.Now,
                FileName = (new FileInfo(filePath)).Name,
                Type = type
            };

            BundleFileDataService bfDal = new BundleFileDataService();
            StdResult<BundleFile> resultFileBundle = bfDal.Create(bFile, date);
            //dal.Update(resultBundle.ReturnObject);
            return resultFileBundle;
        }
示例#2
0
        /// <summary>
        /// 取得本地上传用的输入文件地址.
        /// </summary>
        /// <returns>上传用的输入文件地址.</returns>
        /// <param name="iBundleId">Bundle ID.</param>
        /// <param name="iFileType">文件类型.</param>
        /// <param name="iIsScene">场景标志位.</param>
        private static string GetLocalBundleFilePath(
            string iBundleId, BundleFileType iFileType, bool iIsScene)
        {
            var fileName = GetLocalBundleFileName(iBundleId, iFileType);

            return
                ($"{(iIsScene ? GetInstance().BundlesOutputDirOfScene : GetInstance().BundlesOutputDirOfNormal)}/{fileName}");
        }
示例#3
0
        /// <summary>
        /// 创建UploadItem.
        /// </summary>
        /// <returns>UploadItem.</returns>
        /// <param name="iTargetId">目标ID.</param>
        /// <param name="iBundleType">Bundle类型.</param>
        /// <param name="iFileType">文件类型.</param>
        private BundlesResultItem CreateBundleItem(
            string iTargetId, BundleType iBundleType,
            BundleFileType iFileType)
        {
            var objRet = new BundlesResultItem
            {
                no         = GetBundleNo(),
                id         = iTargetId,
                bundleType = iBundleType,
                fileType   = iFileType,
                uploaded   = false
            };

            Targets.Add(objRet);
            return(objRet);
        }
示例#4
0
        /// <summary>
        /// 添加对象.
        /// </summary>
        /// <param name="iTarget">对象.</param>
        /// <param name="iFileType">上传文件类型.</param>
        /// <param name="iHashCode">HashCode(Unity3d打包生成).</param>
        public void AddTarget(
            BundleMap iTarget, BundleFileType iFileType, string iHashCode = null)
        {
            if (iTarget == null)
            {
                return;
            }
            BundlesResultItem item;
            var filePath = GetLocalBundleFilePath(
                iTarget.id, iFileType, (BundleType.Scene == iTarget.type));
            string checkCode = null;

            string dataSize = null;

            if (false == string.IsNullOrEmpty(filePath) &&
                File.Exists(filePath))
            {
                checkCode = CheckMode.Unity3dHash128 == CheckMode ? iHashCode : UtilsTools.GetMd5ByFilePath(filePath);
                var fileInfo = new FileInfo(filePath);
                dataSize = fileInfo.Length.ToString();
            }
            else
            {
                this.Warning("AddTarget()::Target File is not exist!!!(ProjectName:{0})", filePath);
            }

            var exist = IsTargetExist(iTarget.id, iFileType, out item);

            if (false == exist)
            {
                item           = CreateBundleItem(iTarget.id, iTarget.type, iFileType);
                item.checkCode = checkCode;
                item.dataSize  = dataSize;
            }
            else
            {
                if (false == string.IsNullOrEmpty(checkCode) &&
                    false == checkCode.Equals(item.checkCode))
                {
                    item.checkCode = checkCode;
                    item.dataSize  = dataSize;
                    item.uploaded  = false;
                }
            }
            UtilsAsset.SetAssetDirty(this);
        }
示例#5
0
        /// <summary>
        /// 判断目标是否存在.
        /// </summary>
        /// <returns><c>true</c>,存在, <c>false</c> 不存在.</returns>
        /// <param name="iTargetId">目标ID.</param>
        /// <param name="iFileType">文件类型.</param>
        /// <param name="iTarget">目标信息.</param>
        private bool IsTargetExist(string iTargetId, BundleFileType iFileType, out BundlesResultItem iTarget)
        {
            iTarget = null;

            var targets = Targets
                          .Where(iO => iTargetId.Equals(iO.id) &&
                                 iFileType == iO.fileType)
                          .OrderBy(iO => iO.no)
                          .ToArray();

            if (targets.Length <= 0)
            {
                return(false);
            }
            if (1 != targets.Length)
            {
                this.Warning("isTargetExist()::There is duplicate id exist in upload list!!!(Bundle ID:{0})", iTargetId);
            }
            iTarget = targets [0];
            return(true);
        }
示例#6
0
        /// <summary>
        /// 取得本地上传用的输入文件名.
        /// </summary>
        /// <returns>上传用的输入文件名.</returns>
        /// <param name="iBundleId">Bundle ID.</param>
        /// <param name="iFileType">文件类型.</param>
        public static string GetLocalBundleFileName(
            string iBundleId, BundleFileType iFileType)
        {
            var fileName = iBundleId;

            switch (iFileType)
            {
            case BundleFileType.Bundle:
            {
                var fileSuffix = GetInstance().FileSuffix;
                if (string.IsNullOrEmpty(fileSuffix) == false)
                {
                    fileName = $"{fileName}.{fileSuffix}";
                }
            }
            break;

            case BundleFileType.NormalManifest:
            {
                var fileSuffix = GetInstance().FileSuffix;
                if (string.IsNullOrEmpty(fileSuffix) == false)
                {
                    fileName = $"{fileName}.{fileSuffix}";
                }
                fileName = $"{fileName}.manifest";
            }
            break;

            case BundleFileType.MainManifest:
                break;

            default:
            {
            }
            break;
            }
            return(fileName);
        }