Example #1
0
    public static void Exec(BuildTarget target)
    {
        Dictionary <string, string> dicPath = new Dictionary <string, string>();

        foreach (UnityEngine.Object o in Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets))
        {
            string filePath = AssetDatabase.GetAssetPath(o);
            if (Path.GetExtension(filePath) == ".txt")
            {
                string fileName      = Path.GetFileNameWithoutExtension(filePath);
                string assetFilePath = ToolCommon.GetAssetPath(filePath);

                if (!dicPath.ContainsKey(fileName))
                {
                    dicPath.Add(fileName, assetFilePath);
                }
            }
        }

        ConfigPathSet configPathSet = ConfigPathSet.GetConfig();
        string        boundlePath   = configPathSet.strBoundlePath;

        if (!CreateConfigAssetboundle.CheckPath(ref boundlePath))
        {
            return;
        }

        CreateConfigAssetboundle.InitTempLogs();
        CreateConfigAssetboundle.ExecutePath(boundlePath, target, dicPath);
    }
    //是否有不同的txt资源需要打包
    static bool GetDifffTxtPath(string srcPath, ref Dictionary <string, string> dicDiffPath)
    {
        List <string> diffList = new List <string>();

        ConfigPathSet configPathSet = ConfigPathSet.GetConfig();
        string        destPath      = configPathSet.projectTxtPath;

        if (!CheckPath(ref destPath))
        {
            return(false);
        }

        ImprotStaticDataResult importResult = ImportStaticData.ExecConfigPathSet(diffList, srcPath, destPath);

        if (importResult != ImprotStaticDataResult.Success)
        {
            Log("Log: ", "import static Txt failed!\n error code : " + importResult.ToString());
            Debug.Log("导入静态数据Txt失败!\n 错误代码 : " + importResult.ToString());
            return(false);
        }

        foreach (var path in diffList)
        {
            string fileName  = Path.GetFileNameWithoutExtension(path);
            string assetPath = ToolCommon.GetAssetPath(path);

            if (!dicDiffPath.ContainsKey(fileName))
            {
                dicDiffPath.Add(fileName, assetPath);
            }
        }

        return(true);
    }
        /// <summary>
        /// 查询空间标签
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public TagResultDto GetTags(GetTagsBucketParam request)
        {
            return(ToolCommon.GetResponse(() =>
            {
                new GetTagsBucketParamValidator().Validate(request).Check(HttpStatus.Err.Name);
                var zone = Core.Tools.GetZone(_aLiYunConfig, request.PersistentOps.Zone, () => ZoneEnum.HangZhou);
                var client = _aLiYunConfig.GetClient(zone);
                var bucket = Core.Tools.GetBucket(_aLiYunConfig, request.PersistentOps.Bucket);
                // 查看Bucket标签。
                var ret = client.GetBucketTagging(bucket);
                if (ret != null && ret.HttpStatusCode == HttpStatusCode.OK)
                {
                    return new TagResultDto(true,
                                            ret.Tags.Select(x => new KeyValuePair <string, string>(x.Key, x.Value)).ToList(), "success");
                }

                if (ret != null)
                {
                    return new TagResultDto(false, null,
                                            $"lose,RequestId:{ret.RequestId},HttpStatusCode:{ret.HttpStatusCode}");
                }

                return new TagResultDto(false, null, "lose");
            }, message => new TagResultDto(false, null, message)));
        }
    static void InitConfigFile()
    {
        ToolCommon.CreatePath(SingletonObject <GameConfig> .GetInst().ResourcePath);

        IOTempConfigFileInfo configFileInfo = new IOTempConfigFileInfo();

        IOHelper.SetData(DEFINE.IO_HELPER_TEMP_CONFIG_FILE_INFO, configFileInfo);
    }
    public static void InitTempLogs()
    {
        ToolCommon.CreatePath(SingletonObject <GameConfig> .GetInst().ResourcePath);

        //m_logList.Clear();
        IOTempConfigLogInfo configLogInfo = new IOTempConfigLogInfo();

        IOHelper.SetData(DEFINE.IO_HELPER_TEMP_CONFIG_LOG_INFO, configLogInfo);
    }
 /// <summary>
 /// 清除标签
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public OperateResultDto ClearTag(ClearTagBucketParam request)
 {
     return(ToolCommon.GetResponse(() =>
     {
         var zone = Core.Tools.GetZone(_aLiYunConfig, request.PersistentOps.Zone, () => ZoneEnum.HangZhou);
         var client = _aLiYunConfig.GetClient(zone);
         var bucket = Core.Tools.GetBucket(_aLiYunConfig, request.PersistentOps.Bucket);
         // 查看Bucket标签。
         client.DeleteBucketTagging(bucket);
         return new OperateResultDto(true, "success");
     }, message => new OperateResultDto(false, message)));
 }
 /// <summary>
 /// 清空防盗链规则
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public OperateResultDto ClearReferer(ClearRefererParam request)
 {
     return(ToolCommon.GetResponse(() =>
     {
         Check.TrueByString(request != null, $"{nameof(request)} is null", HttpStatus.Err.Name);
         var zone = Core.Tools.GetZone(_aLiYunConfig, request.PersistentOps.Zone, () => ZoneEnum.HangZhou);
         var client = _aLiYunConfig.GetClient(zone);
         var bucket = Core.Tools.GetBucket(_aLiYunConfig, request.PersistentOps.Bucket);
         client.SetBucketReferer(new SetBucketRefererRequest(bucket));
         return new OperateResultDto(true, "success");
     }, message => new OperateResultDto(false, message)));
 }
 /// <summary>
 /// 设置空间访问权限
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public OperateResultDto SetPermiss(SetPermissParam request)
 {
     return(ToolCommon.GetResponse(() =>
     {
         new SetPermissParamValidator().Validate(request).Check(HttpStatus.Err.Name);
         var zone = Core.Tools.GetZone(_aLiYunConfig, request.PersistentOps.Zone, () => ZoneEnum.HangZhou);
         var client = _aLiYunConfig.GetClient(zone);
         client.SetBucketAcl(Core.Tools.GetBucket(_aLiYunConfig, request.PersistentOps.Bucket),
                             Core.Tools.GetCannedAccessControl(request.Permiss));
         return new OperateResultDto(true, "success");
     }, message => new OperateResultDto(false, message)));
 }
 /// <summary>
 /// 设置防盗链
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public OperateResultDto SetReferer(SetRefererParam request)
 {
     return(ToolCommon.GetResponse(() =>
     {
         new SetRefererParamValidator().Validate(request).Check(HttpStatus.Err.Name);
         var zone = Core.Tools.GetZone(_aLiYunConfig, request.PersistentOps.Zone, () => ZoneEnum.HangZhou);
         var client = _aLiYunConfig.GetClient(zone);
         var bucket = Core.Tools.GetBucket(_aLiYunConfig, request.PersistentOps.Bucket);
         client.SetBucketReferer(new SetBucketRefererRequest(bucket, request.RefererList,
                                                             request.IsAllowNullReferer));
         return new OperateResultDto(true, "success");
     }, message => new OperateResultDto(false, message)));
 }
Example #10
0
 void OnGUI()
 {
     EditorGUILayout.BeginHorizontal();
     {
         if (GUILayout.Button("Read AssetBoundle To AssetBoundleRead Dir"))
         {
             ToolCommon.ClearDirectory("Assets/AssetBoundleRead/");
             ToolCommon.CreatePath("Assets/AssetBoundleRead/");
             LoadSelectedAssetBundle();
             AssetDatabase.SaveAssets();
             AssetDatabase.Refresh();
         }
     }
     EditorGUILayout.EndHorizontal();
 }
Example #11
0
        /// <summary>
        /// 判断空间是否存在
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public OperateResultDto Exist(ExistBucketParam request)
        {
            return(ToolCommon.GetResponse(_logger, () =>
            {
                Check.TrueByString(request != null, $"{nameof(request)} is null", HttpStatus.Err.Name);
                var zone = Core.Tools.GetZone(_aLiYunConfig, request.PersistentOps.Zone, () => ZoneEnum.HangZhou);
                var client = _aLiYunConfig.GetClient(zone);
                var bucket = Core.Tools.GetBucket(_aLiYunConfig, request.PersistentOps.Bucket);
                if (client.DoesBucketExist(bucket))
                {
                    return new OperateResultDto(true, "success");
                }

                return new OperateResultDto(false, "the bucket is not find");
            }, message => new OperateResultDto(false, message)));
        }
        /// <summary>
        /// 获取空间列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public BucketItemResultDto GetBucketList(GetBucketParam request)
        {
            return(ToolCommon.GetResponse(() =>
            {
                var zone = Core.Tools.GetZone(_aLiYunConfig, request.PersistentOps.Zone, () => ZoneEnum.HangZhou);
                var client = _aLiYunConfig.GetClient(zone);
                ListBucketsRequest listBucketsRequest = new ListBucketsRequest();
                if (request.PageSize != -1)
                {
                    listBucketsRequest.MaxKeys = request.PageSize;
                }

                if (request.TagFilters.Count > 0)
                {
                    var keyValue = request.TagFilters.FirstOrDefault();
                    listBucketsRequest.Tag = new Tag()
                    {
                        Key = keyValue.Key,
                        Value = keyValue.Value
                    };
                }

                if (!string.IsNullOrEmpty(request.Prefix))
                {
                    listBucketsRequest.Prefix = request.Prefix;
                }

                if (!string.IsNullOrEmpty(request.Marker))
                {
                    listBucketsRequest.Marker = request.Marker;
                }

                var ret = client.ListBuckets(listBucketsRequest);
                if (ret.HttpStatusCode == HttpStatusCode.OK)
                {
                    return new BucketItemResultDto(
                        ret.Buckets.Select(x =>
                                           new BucketItemResultDto.BucketItemDto((int?)Core.Tools.GetZoneByLocation(x.Location),
                                                                                 x.Name)).ToList(), ret.Prefix,
                        ret.IsTruncated,
                        ret.Marker, ret.NextMaker);
                }

                return new BucketItemResultDto(request.Prefix, request.Marker,
                                               $"lose RequestId:{ret.RequestId},HttpStatusCode:{ret.HttpStatusCode}");
            }, message => new BucketItemResultDto(request.Prefix, request.Marker, message)));
        }
        /// <summary>
        /// 创建空间
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public OperateResultDto Create(CreateBucketParam request)
        {
            return(ToolCommon.GetResponse(() =>
            {
                new CreateBucketParamValidator().Validate(request).Check(HttpStatus.Err.Name);
                var zone = Core.Tools.GetZone(_aLiYunConfig, request.Zone, () => ZoneEnum.HangZhou);
                var client = _aLiYunConfig.GetClient(zone);
                Bucket ret = request.StorageClass != null
                    ? client.CreateBucket(request.BucketName, Core.Tools.GetStorageClass(request.StorageClass))
                    : client.CreateBucket(request.BucketName);
                if (ret != null)
                {
                    return new OperateResultDto(true, "success");
                }

                return new OperateResultDto(false, "lose");
            }, message => new OperateResultDto(false, message)));
        }
        /// <summary>
        /// 得到防盗链配置
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public RefererResultDto GetReferer(GetRefererParam request)
        {
            return(ToolCommon.GetResponse(() =>
            {
                Check.TrueByString(request != null, $"{nameof(request)} is null", HttpStatus.Err.Name);
                var zone = Core.Tools.GetZone(_aLiYunConfig, request.PersistentOps.Zone, () => ZoneEnum.HangZhou);
                var client = _aLiYunConfig.GetClient(zone);
                var bucket = Core.Tools.GetBucket(_aLiYunConfig, request.PersistentOps.Bucket);
                var rc = client.GetBucketReferer(bucket);
                if (rc == null)
                {
                    return new RefererResultDto("the bucket is not find");
                }

                return new RefererResultDto(rc.AllowEmptyReferer,
                                            (rc.RefererList?.Referers ?? Array.Empty <string>()).ToList());
            }, message => new RefererResultDto(message)));
        }
    static void Log(string msgTag, string msg)
    {
        string save = System.DateTime.Now.ToString("HH:mm:ss ffff") + "  " + msgTag + msg;

        //m_logList.Add(save);

        //Debug.Log(save);

        ToolCommon.CreatePath(SingletonObject <GameConfig> .GetInst().ResourcePath);

        IOTempConfigLogInfo logFile = IOHelper.GetData <IOTempConfigLogInfo>(DEFINE.IO_HELPER_TEMP_CONFIG_LOG_INFO);

        if (logFile != null)
        {
            logFile.logList.Add(save);
        }
        IOHelper.SetData(DEFINE.IO_HELPER_TEMP_CONFIG_LOG_INFO, logFile);

        Debug.Log(save);
    }
 /// <summary>
 /// 设置标签
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public OperateResultDto SetTag(SetTagBucketParam request)
 {
     return(ToolCommon.GetResponse(() =>
     {
         new SetTagBucketParamValidator().Validate(request).Check(HttpStatus.Err.Name);
         var zone = Core.Tools.GetZone(_aLiYunConfig, request.PersistentOps.Zone, () => ZoneEnum.HangZhou);
         var client = _aLiYunConfig.GetClient(zone);
         var bucket = Core.Tools.GetBucket(_aLiYunConfig, request.PersistentOps.Bucket);
         var setRequest = new SetBucketTaggingRequest(bucket);
         request.Tags.ForEach(tag =>
         {
             setRequest.AddTag(new Tag()
             {
                 Key = tag.Key,
                 Value = tag.Value
             });
         });
         client.SetBucketTagging(setRequest);
         return new OperateResultDto(true, "success");
     }, message => new OperateResultDto(false, message)));
 }