Пример #1
0
 public VariantVersionAppObject(VdbVariantVersionDef version)
 {
     m_version = version;
     VdbFile   = version.Version.Db.FileName;
     Variant   = IOTool.RelativePathTo(Path.GetDirectoryName(VdbFile), version.VariantFile.DiskPath);
     Version   = version.Version.Name;
 }
Пример #2
0
        public bool JobFileScheduled(string fullJobFile)
        {
            string relfile = IOTool.RelativePathTo(Core.JobsDirectory, fullJobFile);
            int    cnt     = Int32.Parse(JobPlanner.Instance.Connection.ExecuteScalar(String.Format("select count(*) from Job where JobFile='{0}'", relfile.Replace("'", "''"))).ToString());

            return(cnt > 0);
        }
Пример #3
0
        /// <summary>
        /// Emoji表情初始化
        /// </summary>
        /// <param name="isRefresh">是否强制刷新</param>
        /// <returns></returns>
        public async Task InitEmoji(bool isRefresh = false)
        {
            bool isInit = AppTool.GetBoolSetting(Settings.IsInitEmoji, false);

            if (!isInit || isRefresh)
            {
                var emojis = await _client.GetTotalEmojiAsync();

                if (emojis != null && emojis.Count > 0)
                {
                    var emo = new List <EmojiItem>();
                    foreach (var item in emojis)
                    {
                        emo = emo.Concat(item.emojis).ToList();
                    }
                    _emojis = emo;
                    AppTool.WriteLocalSetting(Settings.IsInitEmoji, "True");
                    await IOTool.SetLocalDataAsync("emoji.json", JsonConvert.SerializeObject(_emojis));
                }
            }
            else
            {
                var emojis = await IOTool.GetLocalDataAsync <List <EmojiItem> >("emoji.json");

                _emojis = emojis;
            }
        }
Пример #4
0
    ///// <summary>
    /////
    ///// </summary>
    ///// <param name="fileName">相对于 Application.streamingAssetsPath 的路径  (/Scene/Scene_1_1.json)</param>
    ///// <returns></returns>
    //public string LoadJson(string fileName) {
    //    string path = Application.streamingAssetsPath + fileName;
    //    if (!File.Exists(path)) {
    //        Debug.LogError("文件不存在:" + path);
    //    }

    //    //加载配置文件
    //    return File.ReadAllText(path);
    //}

    /// <summary>
    /// 加载场景
    /// </summary>
    /// <param name="sceneName">例如: Scene_1_1 酱紫 </param>
    public GameObject LoadScene(string sceneName)
    {
        string    json       = IOTool.LoadJson("Scene/" + sceneName + ".json");
        SceneConf conf_scene = JsonMapper.ToObject <SceneConf>(json);

        if (conf_scene == null)
        {
            Debug.LogError("Load Json ERROR!");
            return(null);
        }
        if (conf_scene.Bounds == null)
        {
            Debug.LogError("Load Json Bounds NULL!");
            LoadScene(conf_scene);
            return(null);
        }
        // 应该在外部工具存储的时候转为世界坐标存储
        GameObject scene  = LoadScene(conf_scene);
        Transform  parent = scene.transform.FindChild("Map/Bounds");

        foreach (var item in conf_scene.Bounds)
        {
            // 相对坐标转世界坐标
            _cur_scene_bounds.Add(parent.localToWorldMatrix.MultiplyPoint(item.GetPosition()));
        }
        return(scene);
    }
Пример #5
0
        public override void LoadDatabase(IDatabaseSource dst)
        {
            MySqlStoredConnection sconn = MySqlSettings.CheckMySqlSource(dst);
            MySqlSettings         cfg   = GlobalSettings.Pages.PageByName("mysql_client") as MySqlSettings;

            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = cfg.GetToolPath("mysql");
            StringBuilder pars = new StringBuilder();

            pars.AppendFormat("--user={0} ", sconn.Login);
            pars.AppendFormat("--password={0} ", sconn.Password);
            pars.AppendFormat("--host={0} ", sconn.DataSource);
            pars.AppendFormat("--port={0} ", sconn.Port);

            pars.Append("--verbose ");
            pars.Append(dst.DatabaseName ?? sconn.ExplicitDatabaseName);
            pars.Append(" ");

            p.StartInfo.Arguments             = pars.ToString();
            p.StartInfo.UseShellExecute       = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardError = true;
            Logging.Debug("Running mysql " + pars.ToString());
            p.Start();
            Thread thr = new Thread(() => ReadFromErrStream(p));

            thr.Start();
            using (FileStream fr = new FileInfo(Filename).OpenRead())
            {
                IOTool.CopyStream(fr, p.StandardInput.BaseStream);
            }
            p.StandardInput.Close();
            p.WaitForExit();
            thr.Join();
        }
    public static RecordTable GetData(string RecordName)
    {
        if (s_RecordCache.ContainsKey(RecordName))
        {
            return(s_RecordCache[RecordName]);
        }

        RecordTable record = null;

        string dataJson = "";

        string fullPath = Utility.Path.GetCombinePath(UnityUtility.Path.PersistentDataPath, Constant.DevicePlatform.GetCurDevicePlatformPath(), c_directoryName, RecordName + "." + c_expandName);

        if (File.Exists(fullPath))
        {
            dataJson = IOTool.ReadStringByFile(fullPath);
        }

        if (dataJson == "")
        {
            record = new RecordTable();
        }
        else
        {
            record = RecordTable.Analysis(dataJson);
        }

        s_RecordCache.Add(RecordName, record);

        return(record);
    }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as AppBarButton;

            btn.IsEnabled = false;
            if (_imageFlipView != null)
            {
                var item = _imageFlipView.SelectedItem as ImageDynamic.Picture;
                if (item != null)
                {
                    try
                    {
                        var file = await IOTool.GetSaveFileAsync(".png", "保存的图片.png", "PNG 图片");

                        if (file != null)
                        {
                            var stream = await BiliTool.GetStreamFromWebAsync(item.img_src);

                            using (var fileStream = await file.OpenStreamForWriteAsync())
                            {
                                await stream.CopyToAsync(fileStream);
                            }
                            new TipPopup("下载完成").ShowMessage();
                        }
                    }
                    catch (Exception)
                    {
                        new TipPopup("下载图片失败").ShowMessage();
                    }
                }
            }
            btn.IsEnabled = true;
        }
Пример #8
0
        public void RefreshJobs()
        {
            lsvJobs.Items.Clear();
            int index = 0;

            foreach (string file in Directory.GetFiles(Core.JobsDirectory, "*.djb", SearchOption.AllDirectories))
            {
                var job = Job.LoadFromFile(file);
                var rec = new JobWithFile {
                    Job = job, File = IOTool.RelativePathTo(Core.JobsDirectory, file), FullFile = file
                };
                m_loadedJobs.Add(rec);
                var item = lsvJobs.Items.Add(rec.File);
                item.SubItems.Add(job.GetAllElementaryCommands().Count().ToString());
                item.SubItems.Add(job.GetAllReportConfigs().CreateDelimitedText(";"));
                item.Tag = rec;
                if (index == 0)
                {
                    item.Selected       = item.Focused = true;
                    lsvJobs.FocusedItem = item;
                }
                if (JobPlanner.Instance.Connection.JobFileScheduled(file))
                {
                    item.ImageIndex = m_imgCache.GetImageIndex(CoreIcons.clock);
                }
                index++;
            }
            FillCommands();
        }
Пример #9
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            args.Cancel            = true;
            PrimaryButtonText      = "下载中";
            IsPrimaryButtonEnabled = false;
            try
            {
                var file = await IOTool.GetSaveFileAsync(".png", "保存的图片.png", "PNG 图片");

                if (file != null)
                {
                    var stream = await BiliTool.GetStreamFromWebAsync(_source);

                    using (var fileStream = await file.OpenStreamForWriteAsync())
                    {
                        await stream.CopyToAsync(fileStream);
                    }
                    new TipPopup("下载完成").ShowMessage();
                }
            }
            catch (Exception)
            {
                new TipPopup("下载图片失败").ShowMessage();
            }
            PrimaryButtonText      = "另存为";
            IsPrimaryButtonEnabled = true;
        }
Пример #10
0
    public void WriteCamera9Conf(object _data)
    {
        var json = JsonUtility.ToJson(_data);

        Debug.Log(json);
        IOTool.CreateFileString(Application.dataPath + cPath, json);
    }
Пример #11
0
    public void ReadCamera9Conf()
    {
        var temps = IOTool.LoadFileString(Application.dataPath + cPath);
        var data  = JsonUtility.FromJson <AllData>(temps);

        Debug.Log(data.datas.Count);
    }
Пример #12
0
 private void ChangedWinId()
 {
     WinId = null;
     if (m_file != null && m_file.DataDiskPath != null)
     {
         WinId = IOTool.NormalizePath(m_file.DataDiskPath) + "#chart";
     }
 }
Пример #13
0
    /// <summary>
    /// 解压数据,放在永久性存储文件夹下
    /// </summary>
    static void CreateFile(byte[] data)
    {
        Debug.Log("下载完毕,准备写文件到: " + IOPath.Instance.NowPlatformPath + _UpdateFilePaths[_NowLoadIndex]);
        IOTool.CreateFileBytes(IOPath.Instance.NowPlatformPath + _UpdateFilePaths[_NowLoadIndex], data);

        ++_NowLoadIndex;
        Debug.Log("下载进度-> " + _NowLoadIndex + "/" + _UpdateFilePaths.Count);
        DoUpdateFile();     //循环下载
    }
Пример #14
0
        public override void RunDirectCopy(IDatabaseSource source, DatabaseCopyOptions copyOpts)
        {
            MySqlStoredConnection sconn = MySqlSettings.CheckMySqlSource(source);
            MySqlSettings         cfg   = GlobalSettings.Pages.PageByName("mysql_client") as MySqlSettings;

            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = cfg.GetToolPath("mysqldump");
            StringBuilder pars = new StringBuilder();

            pars.AppendFormat("--user={0} ", sconn.Login);
            pars.AppendFormat("--password={0} ", sconn.Password);
            pars.AppendFormat("--host={0} ", sconn.DataSource);
            pars.AppendFormat("--port={0} ", sconn.Port);
            pars.Append("--routines ");
            if (IncludeDropStatement)
            {
                pars.Append("--add-drop-table ");
            }
            else
            {
                pars.Append("--skip-add-drop-table ");
            }

            pars.Append("--verbose ");
            pars.Append(source.DatabaseName ?? sconn.ExplicitDatabaseName);
            pars.Append(" ");

            if (copyOpts.CopyMembers.TableFilter != null)
            {
                pars.Append("--tables ");
                foreach (NameWithSchema table in copyOpts.CopyMembers.TableFilter)
                {
                    pars.Append(table.Name + " ");
                }
            }

            p.StartInfo.Arguments              = pars.ToString();
            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError  = true;
            Logging.Debug("Running mysqldump " + pars.ToString());
            p.Start();
            Thread thr = new Thread(() => ReadFromErrStream(p));

            thr.Start();
            //Console.Write(p.StandardOutput.ReadToEnd());
            using (FileStream fw = new FileStream(GetWorkingFileName(), FileMode.Create))
            {
                IOTool.CopyStream(p.StandardOutput.BaseStream, fw);
            }
            p.WaitForExit();
            thr.Join();
            FinalizeFileName();
        }
Пример #15
0
        internal static string RelativeFile(this ITreeNode node)
        {
            var jnode = node as JobTreeNode;

            if (jnode != null)
            {
                string file    = jnode.FileSystemPath;
                string relfile = IOTool.RelativePathTo(Core.JobsDirectory, file);
                return(relfile);
            }
            return(null);
        }
Пример #16
0
        public void ScheduleJobDialog(string fullJobFile)
        {
            string relfile = IOTool.RelativePathTo(Core.JobsDirectory, fullJobFile);
            int    cnt     = Int32.Parse(ExecuteScalar(String.Format("select count(*) from Job where JobFile='{0}'", relfile.Replace("'", "''"))).ToString());

            if (cnt == 0)
            {
                ExecuteNonQuery(String.Format("insert into Job (JobFile, CreatedAt) values ('{0}', '{1}')", relfile.Replace("'", "''"), DateTime.Now.ToString("s")));
            }
            int id = Int32.Parse(ExecuteScalar(String.Format("select id from Job where JobFile='{0}'", relfile.Replace("'", "''"))).ToString());

            ScheduleForm.Run(this, id);
        }
    public static bool GetIsExistConfig(string ConfigName)
    {
        string dataJson = IOTool.ReadStringByResource(GetGameConfigFileRelPath(ConfigName));

        if (dataJson == "")
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Пример #18
0
        /// <summary>
        /// 获取分区
        /// </summary>
        /// <returns></returns>
        public async Task GetRegionsAsync()
        {
            RegionCollection.Clear();
            var regions = await _client.GetRegionIndexAsync();

            if (regions != null)
            {
                await IOTool.SetLocalDataAsync("region.json", JsonConvert.SerializeObject(regions.Where(p => p.children != null).ToList()));
            }
            else
            {
                regions = await IOTool.GetLocalDataAsync <List <RegionContainer> >("region.json");
            }
            regions.Where(p => p.children != null).ToList().ForEach(p => RegionCollection.Add(p));
        }
Пример #19
0
        public static bool FindOpenedFile(string filename)
        {
            if (filename == null)
            {
                return(false);
            }
            string winid = IOTool.NormalizePath(filename) + "#chart";

            if (MainWindow.Instance.HasContent(winid))
            {
                MainWindow.Instance.ActivateContent(winid);
                return(true);
            }
            return(false);
        }
Пример #20
0
    /// <summary>
    /// 对比版本
    /// </summary>
    static void CheckVersion()
    {
        //根据版本号,判断当前应该热更还是更新整包
        var myV  = Application.version.Split('.');
        var nowV = mNowVersion.Split('.');

        if (myV[0] != nowV[0])      //大版本有变化,更新完整包
        {
        }
        else if (myV[1] != nowV[1])     //小版本不同,更新热更包
        {
            //检测本机版本文件和下载版本文件的区别
            mVersionPath = string.Concat(IOPath.Instance.NowPlatformPath, IOPath.Instance.NowPlatformName, "_", cVersion);
            string oldStr = "";
            if (IOTool.CheckHaveFile(mVersionPath))
            {
                oldStr = IOTool.LoadFileString(mVersionPath);
            }
            List <string> add;
            List <string> del;
            List <string> diff;
            VersionComparisonTool.Comparison(oldStr, mVersion, out add, out del, out diff);
            //删除所有旧文件
            for (int i = 0; i < del.Count; i++)
            {
                var dPath = IOPath.Instance.NowPlatformPath + del[i];
                if (IOTool.CheckHaveFile(dPath))    //可能被删除过
                {
                    IOTool.DeleteFile(dPath);
                }
            }
            //下载文件
            var list = add.Concat(diff).ToList();
            if (list.Count > 0)
            {
                DoUpdateFiles(list);
            }
            else
            {
                if (mUpdateFinishCb != null)
                {
                    mUpdateFinishCb();
                }
            }
        }
    }
Пример #21
0
 /// <summary>
 /// 下载更新文件
 /// </summary>
 static void DoUpdateFile()
 {
     if (_NowLoadIndex < _UpdateFilePaths.Count)
     {
         Debug.Log("文件下载地址 " + _UpdateFilePaths.Count + "       " + mDownloadPath + _UpdateFilePaths[_NowLoadIndex]);
         var _request = new HTTPRequest(new Uri(mDownloadPath + _UpdateFilePaths[_NowLoadIndex]), OnUpdateOver);
         _request.Send();
     }
     else
     {
         //所有文件更新完毕
         Debug.Log("所有文件更新完毕 " + mVersionPath);
         //保存版本文件
         IOTool.CreateFileString(mVersionPath, mVersion);
         if (mUpdateFinishCb != null)
         {
             mUpdateFinishCb();
         }
     }
 }
    public static Dictionary <string, SingleField> GetData(string ConfigName)
    {
        if (s_configCache.ContainsKey(ConfigName))
        {
            return(s_configCache[ConfigName]);
        }

        string dataJson = IOTool.ReadStringByResource(GetGameConfigFileRelPath(ConfigName));

        if (dataJson == "")
        {
            throw new Exception("ConfigManager.GetData() not find " + ConfigName);
        }
        else
        {
            Dictionary <string, SingleField> config = JsonTool.Json2Dictionary <SingleField>(dataJson);

            s_configCache.Add(ConfigName, config);
            return(config);
        }
    }
Пример #23
0
 public void SaveToXml(XmlElement xml)
 {
     if (m_title != null)
     {
         xml.SetAttribute("title", m_title);
     }
     foreach (var child in m_children)
     {
         var x = xml.AddChild("Node");
         child.SaveToXml(x);
     }
     foreach (var page in Pages)
     {
         var x = xml.AddChild("Page");
         page.SaveToXml(x);
     }
     if (m_icon != null)
     {
         xml.AddChild("Icon").InnerText = IOTool.ImageToText(m_icon);
     }
 }
Пример #24
0
 /// <summary>
 /// 开始导出对应文件
 /// </summary>
 void DoOutputFile(ExcelOutputData data)
 {
     if (data.IsNeedCS)
     {
         if (string.IsNullOrEmpty(CSharpOutputPath))
         {
             EditorUtility.DisplayDialog("提示", "当前C#脚本导出路径不存在", "确定");
             return;
         }
         else
         {
             if (!Directory.Exists(CSharpOutputPath))
             {
                 Directory.CreateDirectory(CSharpOutputPath);
             }
             string _code = GetCSCode();
             IOTool.CreateFileString(CSharpOutputPath + "/" + _TableName + ".cs", _code);
         }
     }
     if (data.IsNeedLua)
     {
         if (string.IsNullOrEmpty(LuaOutputPath))
         {
             EditorUtility.DisplayDialog("提示", "当前Lua脚本导出路径不存在", "确定");
             return;
         }
         else
         {
             if (!Directory.Exists(LuaOutputPath))
             {
                 Directory.CreateDirectory(LuaOutputPath);
             }
             string _code = GetLuaCode();
             IOTool.CreateFileString(LuaOutputPath + "/" + _TableName + ".lua", _code);
         }
     }
     ClearData();    //一组数据导出后,清除临时数据
 }
Пример #25
0
 public void LoadFromXml(XmlElement xml)
 {
     if (xml.HasAttribute("title"))
     {
         m_title = xml.GetAttribute("title");
     }
     foreach (XmlElement chx in xml.SelectNodes("Node"))
     {
         var node = new AppTreeTplNode(this);
         node.LoadFromXml(chx);
         m_children.Add(node);
     }
     foreach (XmlElement chx in xml.SelectNodes("Page"))
     {
         var pg = new AppPage();
         pg.LoadFromXml(chx);
         Pages.Add(pg);
     }
     if (xml.FindElement("Icon") != null)
     {
         m_icon = IOTool.ImageFromText(xml.FindElement("Icon").InnerText);
     }
 }
Пример #26
0
 public override bool SaveAs()
 {
     if (!Directory.Exists(Core.ChartsDirectory))
     {
         Directory.CreateDirectory(Core.ChartsDirectory);
     }
     saveFileDialog1.InitialDirectory = Core.ChartsDirectory;
     saveFileDialog1.CustomPlaces.Add(Core.ChartsDirectory);
     if (saveFileDialog1.ShowDialogEx() == DialogResult.OK)
     {
         m_file = new DiskFile(saveFileDialog1.FileName);
         ChangedWinId();
         Save();
         UpdateTitle();
         m_modified = false;
         if (!IOTool.RelativePathTo(Core.ScriptsDirectory, saveFileDialog1.FileName).StartsWith(".."))
         {
             HTree.CallRefreshRoot();
         }
         return(true);
     }
     return(false);
 }
    public static void SaveData(string RecordName, RecordTable data)
    {
#if !UNITY_WEBGL
        IOTool.WriteStringByFile(Utility.Path.GetCombinePath(UnityUtility.Path.PersistentDataPath, Constant.DevicePlatform.GetCurDevicePlatformPath(), c_directoryName, RecordName + "." + c_expandName), RecordTable.Serialize(data));
#endif
    }
Пример #28
0
 //---------------Lua使用-----------------
 #region Lua使用
 public byte[] GetTableData(string name)
 {
     return(IOTool.LoadFileBytes(string.Concat(TablePath, name)));
 }
Пример #29
0
 protected void ReadHeader(string data)
 {
     byte[] b = Encoding.ASCII.GetBytes(data);
     ReadBuffer4();
     TestError();
     if (!ArrayTool.EqualsArrays(m_buf4, b))
     {
         Logging.Error("Bad content of PHP Tunnel:" + Encoding.ASCII.GetString(IOTool.ReadToEnd(m_fr)));
         throw new StreamFormatError(String.Format("Invalid PHP - Tunnel format, expected {0}, found {1}", data, Encoding.ASCII.GetString(m_buf4)));
     }
 }
Пример #30
0
 public VersionAppObject(VersionDef version)
 {
     m_version = version;
     VdbFile   = IOTool.RelativePathTo(Core.DataDirectory, m_version.Db.FileName);
     Version   = m_version.Name;
 }