Exemple #1
0
        public CaseModel Func_DirectoryFileInfo()
        {
            return(new CaseModel()
            {
                NameSign = @"文件夹文件遍历",
                ExeEvent = () => {
                    return true;

                    string abspath = @"D:\auto\circleoffriends";

                    DirectoryInfo dir = new DirectoryInfo(abspath);

                    // 最新的三条
                    DirectoryInfo[] sondir = PathHelp.UpToDateDirectorys(dir, 2, 3);

                    foreach (DirectoryInfo info in sondir)
                    {
                        Console.WriteLine("Directory name: {0}, create time: {1}", info.Name, info.CreationTime);

                        FileInfo[] fis = PathHelp.PatternFileInfo(info, @".*\.(jpg|png|gif)");
                        foreach (FileInfo fi in fis)
                        {
                            Console.WriteLine("  File name: {0}, create time: {1}", fi.Name, fi.CreationTime);
                        }

                        Console.WriteLine(string.Empty);
                    }

                    return true;
                },
            });
        }
Exemple #2
0
    public void GoLoad()
    {
        string assetPath = PathHelp.GetDownLoadPath() + PathHelp.unZip + CombinSuffixName(mAssetName);

        Debug.Log("加载assetbundle---" + assetPath);
        mAssetBundle = AssetBundle.LoadFromFile(assetPath);
        if (mAssetBundle != null)
        {
            isLoaded = true;
            if (mAssetBundle.isStreamedSceneAssetBundle)
            {
                mAsset = mAssetBundle.mainAsset;
            }
            else
            {
                mAsset = mAssetBundle.LoadAsset(mAssetName);
                mAssetBundle.Unload(false);
                mAssetBundle = null;
            }
        }
        else
        {
            Debug.Log("未发现assetbundle---" + assetPath);
        }
    }
Exemple #3
0
        /// <summary>
        /// 重新创建绝对文件路径
        /// </summary>
        public void ReCreateAbsFilePath()
        {
            string rel_directory = GetPathFolder();
            string rel_filename  = GetFileName();

            this.AbsFilePath = PathHelp.CreateUseFilePath(rel_directory, rel_filename);
        }
    /// <summary>
    /// 获得更新的资源 打包
    /// </summary>
    /// <param name="assetPath">资源路径</param>
    public static string GetUpdateRes(string assetPath, List <string> updatelist)
    {
        string dir       = "androidRes";//manifest文件
        string UpdateRes = Path.Combine(PathHelp.GetExportPath(), "UpdateRes");

        if (Directory.Exists(UpdateRes))
        {
            Directory.Delete(UpdateRes, true);
        }
        Directory.CreateDirectory(UpdateRes);
        string[] assetsName = Directory.GetFiles(assetPath);
        foreach (var item in assetsName)
        {
            string tempFile = item.Substring(item.LastIndexOf("\\") + 1);
            if (tempFile.Contains(dir))
            {
                File.Copy(item, Path.Combine(UpdateRes, tempFile));
                continue;
            }
            foreach (var name in updatelist)
            {
                if (tempFile.Contains(name.ToLower()))
                {
                    File.Copy(item, Path.Combine(UpdateRes, tempFile));
                }
            }
        }
        updatelist.ForEach(o => Debug.Log("资源更新---" + o));
        return(UpdateRes);
    }
Exemple #5
0
    private void SaveVesionToLocal(HTTPResponse response)
    {
        string savePath = PathHelp.GetDownLoadPath();

        if (!Directory.Exists(savePath))
        {
            Directory.CreateDirectory(savePath);
        }
        version_Path = Path.Combine(savePath, version);
        Debug.Log("版本号获得成功--" + response.DataAsText);
        bool isUpdate = VersionController.ReadLocalVersion(response.DataAsText, version_Path);

        if (isUpdate)//需要更新
        {
            RequestVersionList();
        }
        else
        {
            Debug.Log("已是最新版本不需更新");
            if (finish != null)
            {
                finish();
            }
        }
    }
Exemple #6
0
        public CaseModel Func_ToString()
        {
            return(new CaseModel()
            {
                NameSign = @"转为字符串",
                ExeEvent = () => {
                    StackTrace st_def = new StackTrace();
                    StackTrace st_true = new StackTrace(true);
                    string[] strs = new string[] {
                        string.Format("默认: {0}", st_def.FrameCount),
                        st_def.ToString(),
                        "\n",
                        string.Format("开启文件名、行号、列号:", st_true.FrameCount),
                        st_true.ToString(),
                    };

                    string path = PathHelp.CreateUseFilePath(directory, @"Func_ToString.txt");
                    this.ClearAndWriteFile(path, ConvertTool.ToString(strs, "\n"));
                    return true;
                },
                SonCases = new CaseModel[] {
                    Func_StackFrame(),
                },
            });
        }
Exemple #7
0
 /// <summary>
 /// 刷新文件路径
 /// </summary>
 internal void RefreshPath()
 {
     if (File.Exists(this.Path))
     {
         this.Path = PathHelp.AutomaticFileName(this.Path);
     }
 }
Exemple #8
0
        /* ================================== ~华丽的间隔线~ ================================== */

        public string GetSiteNamePathFolder(string root)
        {
            if (CheckData.IsStringNull(root))
            {
                return(string.Format("/{0}", this.SelfSiteName));
            }
            return(string.Format("/{0}/{1}", PathHelp.ToPathSymbol(root), PathHelp.ToPathSymbol(this.SelfSiteName)));
        }
Exemple #9
0
        /// <summary>
        /// 构造函数: 初始化 ini 配置文件对象,
        /// </summary>
        public AbsShineUponIni()
        {
            string rel_folder    = GetPathFolder();
            string rel_filename  = GetFileName();
            string abs_file_path = PathHelp.CreateUseFilePath(rel_folder, rel_filename);

            this.ini = new IniFile(abs_file_path);
        }
Exemple #10
0
 public void SetSiteName(Model.WebSite modelsite)
 {
     if (CheckData.IsObjectNull(modelsite))
     {
         return;
     }
     this.SelfSiteName = PathHelp.ToPathSymbol(modelsite.Name);
     this.ReCreateAbsFilePath();
 }
        public string Get_AbsFilePath()
        {
            TestModel defmodel      = new TestModel();
            string    rel_directory = defmodel.GetPathFolder();
            string    rel_filename  = string.Format("{0}.ytsdb", defmodel.GetFileName());
            string    abs_file_path = PathHelp.CreateUseFilePath(rel_directory, rel_filename);

            return(abs_file_path);
        }
    /// <summary>
    /// 更新版本号
    /// </summary>
    /// <param name="zipPath">打包资源压缩路径</param>
    /// <returns>打包资源存储路径</returns>
    private static string WriteVersionToLocal(out string zipPath, out string zipContent)
    {
        zipPath    = string.Empty;
        zipContent = string.Empty;
        string exportPath = PathHelp.GetExportPath();
        string assetPath  = Path.Combine(exportPath, "androidRes");
        string version    = Path.Combine(exportPath, "version.txt");

        if (Directory.Exists(assetPath))
        {
            Directory.Delete(assetPath, true);
        }
        Directory.CreateDirectory(assetPath);
        if (File.Exists(version))
        {
            string   _ver = File.ReadAllText(version);
            string[] vers = _ver.Split('.');
            if (vers.Length > 1)
            {
                if (vers[2] == "9")
                {
                    vers[2] = "0";
                    if (Convert.ToInt32(vers[1]) < 9)
                    {
                        vers[1] = (Convert.ToInt32(vers[1]) + 1).ToString();
                    }
                    else
                    {
                        vers[1] = "0";
                        if (Convert.ToInt32(vers[0]) < 9)
                        {
                            vers[0] = (Convert.ToInt32(vers[0]) + 1).ToString();
                        }
                    }
                }
                else
                {
                    vers[2] = (Convert.ToInt32(vers[2]) + 1).ToString();
                }
                zipContent = string.Join(".", vers);
                zipPath    = Path.Combine(exportPath, zipContent + ".zip");
                File.WriteAllText(version, zipContent);
            }
            else
            {
                Debug.LogError("版本号格式错误");
            }
        }
        else
        {
            zipContent = "1.0.0";
            File.WriteAllText(version, zipContent);
            zipPath = Path.Combine(exportPath, zipContent + ".zip");
        }
        return(assetPath);
    }
    private float _currentAnimTime = 0f;        // die vergangene Zeit der Animation

    // Use this for initialization
    void Start()
    {
        _helper        = GameObject.Find("boardGameManager").GetComponent <PathHelp>();
        _listCount     = _helper.GetCorrectTilesCount();
        _totalAnimTime = _listCount * _helper.GetDisplayAnimTime();

        LoadingText.text    = "initialising ...";
        ProgressText.text   = "";
        PercentageText.text = "0.00";
    }
Exemple #14
0
 /// <summary>
 /// 检查DownloadTask是否正确(不包括TaskID)
 /// </summary>
 /// <returns></returns>
 public static bool Check(DownloadTask downloadTask)
 {
     if (NetWorkHelp.CanConnection(downloadTask.Url) == true &&
         PathHelp.IsRightForRegex(downloadTask.Path))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #15
0
 // Use this for initialization
 void Awake()
 {
     tempPath = Path.Combine(PathHelp.GetDownLoadPath(), "TempRes.temp");
     if (File.Exists(tempPath))
     {
         File.Delete(tempPath);
     }
     httpImpl = new BestHttpImpl();
     httpImpl.SetHttpParams();
     httpImpl.AddHead("content-type", "application/json");
     PlayerPrefs.SetInt("DownloadProgress", 0);
 }
    //获得Mainfest
    private void GetMainfest()
    {
        string mainPath = PathHelp.GetDownLoadPath() + PathHelp.unZip + mMainfestName;

        Debug.Log("加载mainfest---" + mainPath);
        mMainfestBundle = AssetBundle.LoadFromFile(mainPath);
        if (mMainfestBundle != null)
        {
            mainfest = mMainfestBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            mMainfestBundle.Unload(false);
            mMainfestBundle = null;
        }
    }
Exemple #17
0
 /// <summary>
 /// 清除并写入文件内容, 并在控制台报告文件路径
 /// </summary>
 /// <param name="abs_file_path">文件绝对路径</param>
 /// <param name="content">写入内容</param>
 public void ClearAndWriteFile(string abs_file_path, string content)
 {
     abs_file_path = ConvertTool.ToString(abs_file_path);
     if (!PathHelp.IsAbsolute(abs_file_path))
     {
         Console.WriteLine("需要写入的文件名称错误: {0}", abs_file_path);
         return;
     }
     content = ConvertTool.ToString(content);
     File.Delete(abs_file_path);
     File.AppendAllText(abs_file_path, content);
     Console.WriteLine("清空并写入文件: {0}", abs_file_path);
 }
Exemple #18
0
        /// <summary>
        /// 获取模型数据-文件路径-目标
        /// </summary>
        /// <returns>文件绝对路径</returns>
        public string GetFilePath_Target(Model.URLReWriter model)
        {
            if (CheckData.IsObjectNull(model))
            {
                return(string.Empty);
            }
            // 需要指定生成路径文件夹目录
            Model.URLReWriterConfig curl = GlobalSystemService.GetInstance().Config.Get <Model.URLReWriterConfig>();
            string directory             = this.SelfDAL.GetSiteNamePathFolder(curl.RootPage);
            string path = PathHelp.CreateUseFilePath(directory, model.Target);

            return(path);
        }
Exemple #19
0
        private ILogger CreateGlobalLoggerForService(string instanceName)
        {
            Constraint.MustNotBeNull(Configuration, "Configuration");

            var logFilePath = Configuration.GetStringValue(GlobalSettings.Keys.LogFilePath);

            // ReSharper disable once AssignNullToNotNullAttribute
            logFilePath = string.Format(logFilePath, string.Format(".{0}", instanceName));
            logFilePath = PathHelp.RootPathIfRelative(logFilePath, AppDomain.CurrentDomain.BaseDirectory);
            return(Log4NetLogger.GetLogger(ExeAppSettings.FilePath,
                                           Appenders.Trace(),
                                           Appenders.ColouredConsole(),
                                           Appenders.EventLog(EventLogSource),
                                           Appenders.RollingFile(logFilePath, true)));
        }
            public void Calc(DirectoryInfo olddir, FileInfo file)
            {
                string oldpath = PathHelp.CreateUseFilePath(olddir.FullName, file.Name);
                int    rate    = 60;

                byte[] imgcontent = CanUseImg(file, out rate);
                string newpath    = PathHelp.CreateUseFilePath(olddir.FullName.Replace("imgs", "imgs_c"), file.Name);

                if (File.Exists(newpath))
                {
                    File.Delete(newpath);
                }
                SaveImg(imgcontent, newpath);
                PrintInfo(new FileInfo(oldpath), new FileInfo(newpath), rate);
            }
            public bool Method()
            {
                const string oldpath = @"D:\ZRQDownloads\imgs";

                DirectoryInfo[] sondirs = PathHelp.AllSonDirectorys(new DirectoryInfo(oldpath));
                foreach (DirectoryInfo dirinfo in sondirs)
                {
                    FileInfo[] fis = PathHelp.PatternFileInfo(dirinfo, @".*\.(jpg|png|gif)");
                    foreach (FileInfo file in fis)
                    {
                        Calc(dirinfo, file);
                    }
                }
                return(false);
            }
Exemple #22
0
        /// <summary>
        /// 重写 URL 路径
        /// </summary>
        /// <param name="uri">用户原始请求信息</param>
        /// <returns>重定向路径, 如果为空则不处理</returns>
        private string ReWriteURLPath(Uri uri)
        {
            BLL.WebSite bllsite   = new BLL.WebSite();
            string      site_name = bllsite.MatchSiteName(uri.AbsolutePath);

            Model.WebSite modelsite = bllsite.GetModel(site_name);
            if (CheckData.IsObjectNull(modelsite))
            {
                return(string.Empty);
            }

            BLL.URLReWriter   bllurl   = new BLL.URLReWriter(modelsite);
            Model.URLReWriter modelurl = bllurl.GetItem_RequestURI(uri.AbsolutePath);

            if (CheckData.IsObjectNull(modelurl))
            {
                string resource_file     = bllurl.GetResourceFilePath(uri.AbsolutePath, bllsite);
                string abs_resource_file = PathHelp.ToAbsolute(resource_file);
                if (File.Exists(abs_resource_file))
                {
                    return(resource_file);
                }

                // 当得到的对象 为空的时候,证明没有此数据内容,当然也就不用生成了
                return(string.Empty);
            }

            FileInfo FItemp = new FileInfo(bllurl.GetFilePath_Templet(modelurl));

            if (!FItemp.Exists)
            {
                // 模板文件都不存在的话,就不用生成了
                return(string.Empty);
            }

            SystemConfig sys_config = GlobalSystemService.GetInstance().Config.Get <SystemConfig>();
            FileInfo     FItarget   = new FileInfo(bllurl.GetFilePath_Target(modelurl));

            if (sys_config.Is_DeBug || !FItarget.Exists || FItemp.LastWriteTime > FItarget.LastWriteTime)
            {
                // 生成模板
                HtmlToAspx        hta = new HtmlToAspx();
                HtmlToAspx.Params par = hta.ParamsMerge(modelurl, FItemp, FItarget);
                hta.Generate(par);
            }

            return(bllurl.HTTPRedirectPath(uri, modelurl));
        }
            public ToRangeList()
            {
                this.NameSign = @"获取列表范围";
                this.ExeEvent = () => {
                    int      sumcount = ToRangeListItem.DataSumCount;
                    string[] source   = new string[sumcount];
                    for (int i = 0; i < source.Length; i++)
                    {
                        source[i] = string.Format("第{0}项", i);
                    }

                    // auto 规则测试
                    VerifyIList <string, string> verify = new VerifyIList <string, string>(CalcWayEnum.DoubleCycle);
                    foreach (ToRangeListItem item in ToRangeListItem.ResultAnswer())
                    {
                        verify.Answer = item.result;
                        verify.Source = ConvertTool.ToRangePage(source, item.index, item.count);
                        if (!verify.Calc())
                        {
                            Console.WriteLine("Error: sum: {0}  index: {1}  count: {2}  result: {3}", source.Length, item.index, item.count, JSON.Serializer(item.result));
                        }
                    }
                    Console.WriteLine("自动化程序测试结果成功!");

                    // old 生成结果数据
                    string absfile = PathHelp.CreateUseFilePath(@"/auto/tools/Test_ConvertTool", @"Func_ToRangeList.txt");
                    File.Delete(absfile);
                    using (FileStream fileshream = new FileStream(absfile, FileMode.OpenOrCreate)) {
                        using (StreamWriter writer = new StreamWriter(fileshream, YTS.Tools.Const.Format.FILE_ENCODING)) {
                            for (int count = 9; count <= 11; count++)
                            {
                                for (int index = -1; index < 11; index++)
                                {
                                    string[] result = ConvertTool.ToRangePage(source, index, count);
                                    writer.WriteLine("sum: {0}  index: {1}  count: {2}  result: {3}", source.Length, index, count, JSON.Serializer(result));
                                }
                                writer.WriteLine();
                            }
                            writer.Flush();
                        }
                    }
                    Console.WriteLine("生成结果数据: {0}", absfile);
                    return(true);
                };
            }
    /// <summary>
    /// 向版本列表写入数据
    /// </summary>
    /// <param name="zipConent">版本号</param>
    /// <param name="zipSize">资源大小</param>
    private static void WriteVersionListToLocal(string zipConent, long zipSize)
    {
        string exportPath      = PathHelp.GetExportPath();
        string versionListPath = Path.Combine(exportPath, "versionList.txt");
        string vv = string.Empty;

        if (File.Exists(versionListPath))
        {
            vv = File.ReadAllText(versionListPath);
        }
        StringBuilder str = new StringBuilder(vv);

        str.AppendLine();
        str.Append(zipConent);
        str.Append("-");
        str.Append(zipSize);
        File.WriteAllText(versionListPath, str.ToString());
    }
Exemple #25
0
        public CaseModel Func_ASCII_Special()
        {
            return(new CaseModel()
            {
                NameSign = @"特别字符",
                ExeEvent = () => {
                    StringBuilder str = new StringBuilder();
                    foreach (char c in CommonData.ASCII_Special())
                    {
                        str.AppendFormat("{{ @\"{0}\", @\"{1}\" }},\n", c, RandomData.GetString(CommonData.ASCII_UpperEnglish(), 5));
                    }
                    string path = PathHelp.CreateUseFilePath(@"/auto/Tools/Test_CommonData", @"Func_ASCII_Special.txt");
                    this.ClearAndWriteFile(path, str.ToString());

                    Dictionary <string, string> dic = FileNameFormat_Dictionary();
                    return true;
                },
            });
        }
Exemple #26
0
        public CaseModel Func_XmlSerializer()
        {
            return(new CaseModel()
            {
                NameSign = @"序列化",
                ExeEvent = () => {
                    Person[] list = new Person[99];
                    for (int i = 0; i < list.Length; i++)
                    {
                        list[i] = new Person()
                        {
                            Bill = new Customer()
                            {
                                Surname = RandomData.GetString(43),
                                Title = RandomData.GetString(31),
                            },
                        };
                    }

                    string absfile = PathHelp.CreateUseFilePath("/auto/XML/XmlSerializer", "testmodel.xml");
                    XmlWriterSettings settings = new XmlWriterSettings()
                    {
                        CheckCharacters = true,
                        CloseOutput = true,
                        ConformanceLevel = ConformanceLevel.Document,
                        Encoding = YTS.Tools.Const.Format.FILE_ENCODING,
                        Indent = true,
                        IndentChars = @"    ",
                        NamespaceHandling = NamespaceHandling.Default,
                        NewLineOnAttributes = false,
                        NewLineHandling = NewLineHandling.Replace,
                        OmitXmlDeclaration = false,
                    };

                    using (XmlWriter writer = XmlWriter.Create(absfile, settings)) {
                        XmlSerializer xmlser = new XmlSerializer(typeof(Person[]));
                        xmlser.Serialize(writer, list);
                    }
                    return true;
                },
            });
        }
        public CaseModel Func_Compression()
        {
            return(new CaseModel()
            {
                NameSign = @"压缩计算",
                ExeEvent = () => {
                    const string oldpath = @"D:\ZRQDownloads\imgs";
                    if (!Directory.Exists(oldpath))
                    {
                        Console.WriteLine("停止执行, 路径不存在: {0}", oldpath);
                        return true;
                    }

                    ImageHandler handler = new ImageHandler();
                    const int maxwidth = 1200;
                    const int maxheight = 1200;
                    handler.SetMaxSize(maxwidth, maxheight);
                    const long maxbytelength = 2 * 1024 * 1024;
                    handler.SetMaxByteLength(maxbytelength);

                    DirectoryInfo[] sondirs = PathHelp.AllSonDirectorys(new DirectoryInfo(oldpath));
                    foreach (DirectoryInfo dirinfo in sondirs)
                    {
                        FileInfo[] fis = PathHelp.PatternFileInfo(dirinfo, @".*\.(jpg|png|gif)");
                        foreach (FileInfo file in fis)
                        {
                            byte[] imgvalues = handler.Calc(file);
                            if (CheckData.IsSizeEmpty(imgvalues))
                            {
                                Console.WriteLine("压缩图片失败, 结果为空!");
                                Console.WriteLine("FileInfo.FullName: {0}", file.FullName);
                                return false;
                            }
                            string newdirpath = file.DirectoryName.Replace("imgs", "imgs_c");
                            string newfilepath = PathHelp.CreateUseFilePath(newdirpath, file.Name);
                            handler.SaveImg(imgvalues, newfilepath);
                        }
                    }
                    return true;
                },
            });
        }
Exemple #28
0
        public override void Load()
        {
            string path = PathHelp.GetFullPaltformPath(mStrPath, false);

            if (System.IO.File.Exists(path))
            {
                System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Open);
                if (stream != null)
                {
                    byte[] content = new byte[stream.Length];
                    stream.Read(content, 0, (int)stream.Length);

                    IsLoaded = true;

                    string strData = CommonTool.BytesToUtf8(content);
                    ParseData(strData);
                    stream.Close();
                }
            }
        }
Exemple #29
0
 /// <summary>
 /// 保存下载的数据到本地
 /// </summary>
 /// <param name="response"></param>
 private void SaveZipToLocal(HTTPResponse response)
 {
     ProcessFragments(response.GetStreamedFragments());
     if (response.IsStreamingFinished)
     {
         Debug.Log("zip资源获得成功");
         string newPath = PathHelp.GetDownLoadPath() + "data.zip";
         if (File.Exists(tempPath))
         {
             if (File.Exists(newPath))
             {
                 File.Delete(newPath);
             }
             File.Move(tempPath, newPath);
             File.Delete(tempPath);
         }
         Zip.UnZip(newPath, PathHelp.GetDownLoadPath() + PathHelp.unZip);
         Debug.Log("解压完成");
         RequestZipNext();
     }
 }
Exemple #30
0
        /// <summary>
        /// 第一个事件执行
        /// </summary>
        private void BeginRequest(object sender, EventArgs e)
        {
            HttpContext context = ((HttpApplication)sender).Context;

            // 获得请求页面路径页面(含目录)
            string request_path = context.Request.Path.ToLower();

            if (request_path == @"/")
            {
                context.Response.Redirect(@"index.aspx");
                return;
            }

            // 检查请求的文件是否存在 如:存在,跳出,没必要做任何处理
            string request_absfilepath = PathHelp.ToAbsolute(request_path);

            request_absfilepath = ConvertTool.ToString(request_absfilepath);
            if (File.Exists(request_absfilepath))
            {
                return;
            }

            // 执行生成执行页面内容
            string redirect_path = ReWriteURLPath(context.Request.Url);

            if (!CheckData.IsStringNull(redirect_path))
            {
                SystemLog log = new SystemLog()
                {
                    Type     = SystemLog.LogType.Record,
                    Position = @"YTS.Web.UI.HttpModule.BeginRequest",
                    Message  = string.Format("new redirect path: {0}", redirect_path),
                };
                log.Write();

                // HTTP请求重写路径
                context.RewritePath(redirect_path);
            }
        }