Ejemplo n.º 1
0
        /// <summary>
        /// 对比文件
        /// </summary>
        /// <param name="localBookmarks"></param>
        public static bool ContrastBookmarks(List <MyBookmarks> localBookmarks)
        {
            if (localBookmarks == null)
            {
                return(false);
            }
            string datajsPath = System.Environment.CurrentDirectory + @"\old_data.js";
            string datajs     = StringConvert.FileRead(datajsPath);

            datajs = datajs.Substring((datajs.IndexOf("=") + 1));
            BookmarksType bookmarksType = (BookmarksType)StringConvert.JsonToList <BookmarksType>(datajs);
            //List<MyBookmarks> onlineBookmarks = bookmarksType.Info;
            bool rel = false;

            foreach (MyBookmarks item in localBookmarks)
            {
                if (!bookmarksType.Info.Any(a => a.Url == item.Url))
                {
                    bookmarksType.Info.Add(item);
                    rel = true;
                }
            }
            if (rel)
            {
                SaveDataJs(localBookmarks);
            }
            return(rel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取Chrome浏览器书签对象
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public ChromeBookmarks GetChromeBookmarksData(string filePath)
        {
            string str             = StringConvert.FileRead(filePath);
            object chromeBookmarks = StringConvert.JsonToList <ChromeBookmarks>(str);

            if (chromeBookmarks != null)
            {
                return((ChromeBookmarks)chromeBookmarks);
            }
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 将文件保存成data.js文件
        /// </summary>
        /// <param name="localBookmarks">本地书签文件数据</param>
        public static void SaveDataJs(List <MyBookmarks> localBookmarks)
        {
            string dataPath   = System.Environment.CurrentDirectory + @"\data.json";
            string datajsPath = System.Environment.CurrentDirectory + @"\data.js";

            if (BookmarksData.SaveMyBookmarksToJsonFile(localBookmarks, dataPath))
            {
                string cont = "var InfoData =" + StringConvert.FileRead(dataPath);
                StringConvert.FileWrite(datajsPath, cont);
            }
        }
Ejemplo n.º 4
0
 public static void LoadConfig()
 {
     //string path = System.Environment.CurrentDirectory + @"\config.json";
     if (File.Exists(FilePath))
     {
         _configData = (ConfigModel)StringConvert.JsonToList <ConfigModel>(StringConvert.FileRead(FilePath));
     }
     else
     {
         _configData = new ConfigModel();
     }
 }