示例#1
0
        private static string UniqueIdsContainerPath()
        {
            string path = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder(), "uid.xml");

            if (!File.Exists(path))
            {
                CreateUniqueIdsContainer(path);
            }
            return(path);
        }
示例#2
0
        public static void Import(string res, string location, bool overwrite, Action <ImportedScenarioModel> onResult)
        {
            if (string.IsNullOrEmpty(res))
            {
                return;
            }

            var fileInfo = new FileInfo(res);

            if (fileInfo.Extension != ".zip")
            {
                return;
            }

            string repoPath = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder());

            if (location.Contains(repoPath))
            {
                location = location.Replace(repoPath, "");
            }

            location = location.Replace("\\", "/");
            TempFolderCreate();
            ZipFile.ExtractToDirectory(res, GetTempFolderPath(), true);

            tempIds.Clear();
            Thread.Sleep(1000);
            ImportHandler(0, "", GetTempFolderPath(), overwrite, location);

            foreach (DirectoryInfo dir in new DirectoryInfo(GetTempFolderPath()).GetDirectories())
            {
                string newLocation = dir.FullName.Replace("\\", "/")
                                     .Replace(GetTempFolderPath().Replace("\\", "/"), repoPath);
                MoveFolder(dir.FullName.Replace("\\", "/"), newLocation.Replace("\\", "/"));
            }

            ImportedScenarioModel model = new ImportedScenarioModel();

            model.scenarios_ids = new List <string[]>();

            //string json = "{ scenarios_ids: [ ";
            foreach (var i in tempIds)
            {
                string[] scenario = new string[2];
                scenario[0] = i.oldId;
                scenario[1] = i.newId;
                //json += string.Format("[\"{0}\",\"{1}\"],", i.oldId, i.newId);
                model.scenarios_ids.Add(scenario);
            }

            //json = json.Remove(json.Length - 1);
            //json += "]}";
            PathHelper.DeleteDirectory(GetTempFolderPath());
            onResult(model);
        }
示例#3
0
        public static void DeleteDirectory(string path)
        {
            string repoPath = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder());

            if (!Directory.Exists(path) && !Directory.Exists(Path.Combine(repoPath, path)))
            {
                return;
            }
            if (!Directory.Exists(path) && Directory.Exists(Path.Combine(repoPath, path)))
            {
                path = Path.Combine(repoPath, path);
            }

            string[] files = Directory.GetFiles(path);
            string[] dirs  = Directory.GetDirectories(path);

            foreach (string file in files)
            {
                File.SetAttributes(file, FileAttributes.Normal);
                File.Delete(file);
            }

            foreach (string dir in dirs)
            {
                DeleteDirectory(dir);
            }

            if (Directory.Exists(path))
            {
                try
                {
                    Directory.Delete(path);
                }
                catch (Exception ex)
                {
                }
            }
            else if (Directory.Exists(Path.Combine(repoPath, path)))
            {
                try
                {
                    Directory.Delete(Path.Combine(repoPath, path));
                }
                catch (Exception ex)
                {
                }
            }
        }
示例#4
0
        private static void GenerateXml(string path)
        {
            string repoPath     = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder());
            string pathToDir    = path;
            string relativePath = path.Replace(repoPath, "").Replace('\\', '/');

            string[] relativeParts = relativePath.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
            pathToCurrentFile = Path.Combine(path, relativeParts[relativeParts.Length - 1] + ".info");
            string title = JsonConvert.DeserializeObject <PublishedScenario>(File.ReadAllText(Path.Combine(path, relativeParts[relativeParts.Length - 1] + ".info"))).title;

            path = Path.Combine(path, "default", "pub_draft");
            string fileName = relativeParts[relativeParts.Length - 3] + "_" + relativeParts[relativeParts.Length - 2] + "_" + relativeParts[relativeParts.Length - 1] + ".xml";

            path = Path.Combine(path, fileName);
            GenerateXMLFromDirectory(Path.Combine(pathToDir, "default", "pub_in"), path, title);
            XSLTTransformation(path, path);
        }
示例#5
0
        private static void OnFinishDrafting()
        {
            string pathToFile    = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder(), pathToCurrentFile);
            string pathToDefault = Path.Combine(pathToFile.Replace(Path.GetFileName(pathToFile), ""), "default");
            string projectsDir   = Path.Combine(pathToDefault, "projects");

            foreach (var file in Directory.GetFiles(projectsDir))
            {
                if (file.Contains(".vmb") && file.Contains(".vmp"))
                {
                    File.Delete(file);
                }
            }

            foreach (var dir in Directory.GetDirectories(projectsDir))
            {
                Directory.Delete(dir, true);
            }
        }
示例#6
0
        public static void ImportTopic(string res, string location, bool overwrite, Action <ImportedTopicModel> onResult)
        {
            if (string.IsNullOrEmpty(res))
            {
                return;
            }

            string repoPath = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder()).Replace("\\", "/");

            location = location.Replace("\\", "/");
            if (location.Contains(repoPath))
            {
                location = location.Replace(repoPath, "");
            }

            location = location.Replace("\\", "/");

            TempFolderCreate();
            var topicTempFoler = Path.Combine(GetTempFolderPath(), new FileInfo(res).Name + DateTime.Now.Millisecond);

            ZipFile.ExtractToDirectory(res, topicTempFoler, true);

            tempIds.Clear();

            ImportHandler(0, "", topicTempFoler, overwrite, location, true);
            List <string> directories = GetDirectories(new DirectoryInfo(topicTempFoler).FullName, "*", SearchOption.AllDirectories);

            foreach (string dir in directories)
            {
                if (dir.Contains("topics") || dir.Contains("default"))
                {
                    string newLocation = dir.Replace("\\", "/").Replace(topicTempFoler.Replace("\\", "/"), repoPath);
                    MoveFolder(dir.Replace("\\", "/"), newLocation.Replace("\\", "/"));
                }
            }

            PathHelper.DeleteDirectory(topicTempFoler);

            ImportedTopicModel model = new ImportedTopicModel();

            onResult(model);
        }
示例#7
0
        private static void DraftTopic(string topic, string path)
        {
            string     pathToFolder = Path.Combine(path, "default", "projects");
            TopicModel topicModel   = JsonConvert.DeserializeObject <TopicModel>(File.ReadAllText(topic));

            topicModel.localization = "default";
            string vmbFile = topicModel.vmpPath.Replace(".vmp", ".vmb");

            if (File.Exists(vmbFile))
            {
                string unzipFolder = Path.Combine(pathToFolder, topicModel.name.Replace(" ", "_"));
                if (Directory.Exists(unzipFolder))
                {
                    foreach (string f in Directory.GetFiles(unzipFolder))
                    {
                        File.Delete(f);
                    }
                }

                if (!string.IsNullOrEmpty(topicModel.pathToZip) && File.Exists(topicModel.pathToZip))
                {
                    topicModel.pathToZip = topicModel.pathToZip.Replace("data\\", UsersHelper.GetToolsFolder() + "\\");
                    topicModel.pathToZip = topicModel.pathToZip.Replace("data/", UsersHelper.GetToolsFolder() + "/");
                    string toolsDir = PathHelper.GetUserProcessingFolder();
                    string pathOne  = Path.Combine(toolsDir, "input/resourceFolder").Replace("\\", "/");
                    string pathTwo  = Path.Combine(toolsDir, "input").Replace("\\", "/");
                    File.Copy(topicModel.pathToZip, Path.Combine(pathOne, Path.GetFileName(topicModel.pathToZip)).Replace("\\", "/"), true);
                    File.Copy(topicModel.pathToZip, Path.Combine(pathTwo, Path.GetFileName(topicModel.pathToZip)).Replace("\\", "/"), true);
                }

                Unzip(vmbFile, unzipFolder);
                ConvertToX3D(unzipFolder, Path.Combine(path, "default", "pub_draft"), topicModel.name + new Random().Next(1000, 9999), topicModel.type == "info", topicModel);
            }

            if (!string.IsNullOrEmpty(topicModel.pathToZip) && File.Exists(topicModel.pathToZip))
            {
                string fileCopy = topicModel.pathToZip.Replace("pub_in", "pub_draft");
                File.Copy(topicModel.pathToZip, fileCopy, true);
                SVNManager.AddFile(fileCopy.Replace(Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder()) + "/", ""));
            }
        }
示例#8
0
        private static void X3DTrans(string copyTo)
        {
            string basePath = AppContext.BaseDirectory.Replace("\\", "/");

            string binaryToolsPath    = PathHelper.GetToolsPath();
            string userProcessingPath = PathHelper.GetUserProcessingFolder();

            string command = "cd \"" + userProcessingPath + "\" & \"" + binaryToolsPath + "/PublishEngineExecute.exe\" \"" + userProcessingPath + "/input\" \"" + userProcessingPath + "/input/resourceFolder\" -p XmlCompass -f";

            ProcessStartInfo processInfo;
            Action           onFinish = () =>
            {
                string   pathToFile = "";
                string[] files      = Directory.GetFiles(Path.Combine(userProcessingPath, "input/resourceFolder"));

                foreach (string fileName in files)
                {
                    if (fileName.ToLower().Contains("x3d") || fileName.ToLower().Contains("zip") || fileName.ToLower().Contains("rar"))
                    {
                        string copyFile = Path.Combine(copyTo.Replace(Path.GetFileName(copyTo), ""), Path.GetFileName(fileName));
                        File.Copy(fileName, copyFile, true);
                        string repoPath = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder());
                        SVNManager.AddFile(copyFile.Replace(repoPath + "/", ""));
                        pathToFile = copyFile;
                        if (fileName.ToLower().Contains("x3d"))
                        {
                            _logger.LogInformation($"Processing X3D file: '{fileName}'");

                            DirectoryInfo    dInfo      = new DirectoryInfo(binaryToolsPath);
                            string           newDPath   = dInfo.FullName.Replace("\\", "/");
                            string           x3dCommand = "cd \"" + PathHelper.GetUserProcessingFolder() + "\" & \"" + newDPath + "/remgeom.bat\" \"" + copyFile + "\" \"" + newDPath + "\"";
                            ProcessStartInfo processBat = new ProcessStartInfo("cmd.exe", "/C " + x3dCommand);

                            processBat.CreateNoWindow         = true;
                            processBat.UseShellExecute        = false;
                            processBat.RedirectStandardOutput = true;
                            processBat.RedirectStandardError  = true;
                            processBat.WorkingDirectory       = newDPath;

                            var    processB = Process.Start(processBat);
                            string outputt  = processB.StandardOutput.ReadToEnd();
                            string errors   = processB.StandardError.ReadToEnd();

                            if (!string.IsNullOrEmpty(errors))
                            {
                                _logger.LogError($"Error while performing X3D transformation: '{errors}' Command: {x3dCommand}");
                            }

                            processB.WaitForExit();
                        }
                    }
                }

                foreach (string s in Directory.GetFiles(Path.Combine(userProcessingPath, "input")))
                {
                    if (s.ToLower().Contains(".xml"))
                    {
                        string ditaText = File.ReadAllText(s);

                        File.WriteAllText(s, ditaText);
                        File.Copy(s, CopyTo, true);
                    }
                }

                OnFinishDrafting();

                onResultAction("");
            };

            processInfo = new ProcessStartInfo("cmd.exe", "/C " + command);
            processInfo.CreateNoWindow         = true;
            processInfo.UseShellExecute        = false;
            processInfo.RedirectStandardOutput = true;
            processInfo.RedirectStandardError  = true;

            var    process = Process.Start(processInfo);
            string output  = process.StandardOutput.ReadToEnd();
            string errorss = process.StandardError.ReadToEnd();

            if (!string.IsNullOrEmpty(errorss))
            {
                _logger.LogError($"Error '{errorss}' while executing command: {command} ");
            }

            process.WaitForExit();

            command = "cd \"" + userProcessingPath + "\" & \"" + binaryToolsPath + "/PublishEngineExecute.exe\" \"" + userProcessingPath + "/input\" \"" + userProcessingPath + "/input/resourceFolder\" -p Cortona –f";

            processInfo = new ProcessStartInfo("cmd.exe", "/C " + command);
            processInfo.CreateNoWindow         = false;
            processInfo.UseShellExecute        = false;
            processInfo.RedirectStandardOutput = true;
            processInfo.RedirectStandardError  = true;

            process = Process.Start(processInfo);
            output  = process.StandardOutput.ReadToEnd();
            errorss = process.StandardError.ReadToEnd();
            if (!string.IsNullOrEmpty(errorss))
            {
                _logger.LogError($"Error '{errorss}' while executing command: {command} ");
            }

            process.WaitForExit();
            onFinish();
        }
示例#9
0
        private static void XSLTTransformation(string fromFolder, string copyTo)
        {
            string        path = PathHelper.GetUserProcessingFolder();
            DirectoryInfo dir  = new DirectoryInfo(path);

            path = dir.FullName.Replace("\\", "/");
            string aPath = Path.Combine(path, "xslt/a.xml").Replace("\\", "/");

            if (!Directory.Exists(Path.GetDirectoryName(aPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(aPath));
            }

            File.Copy(fromFolder, Path.Combine(path, "xslt/a.xml"), true);
            File.Copy(Path.Combine(path, "xslt/a.xml"), Path.Combine(path, "input/1_1.xml"), true);
            string command = "";

            var xsltConfigFileName = Path.Combine(path, "xslt.config");

            if (!File.Exists(xsltConfigFileName))
            {
                File.WriteAllText(xsltConfigFileName, JsonConvert.SerializeObject(new XsltConfigModel {
                    port = 9000, ticket = "ytrewq654321", url = "http://127.0.0.1"
                }));
            }

            string configContent = File.ReadAllText(xsltConfigFileName);

            var xspConfigFilePath = Path.Combine(path, "xsp.config");

            if (!File.Exists(xspConfigFilePath))
            {
                File.WriteAllText(xspConfigFilePath, JsonConvert.SerializeObject(new XSPConfigModel {
                    port = 0
                }));
            }
            string          xspContent = File.ReadAllText(Path.Combine(path, "xsp.config"));
            XsltConfigModel config     = JsonConvert.DeserializeObject <XsltConfigModel>(configContent);
            XsltConfigModel xspConfig  = JsonConvert.DeserializeObject <XsltConfigModel>(xspContent);
            string          fileNameWithoutExtension = Path.GetFileNameWithoutExtension(copyTo.Replace("\\", "/"));
            string          parameters = "id=" + fileNameWithoutExtension + " server_host={SERVER}:{PORT} ticket=" + config.ticket;

            CopyTo = copyTo;
            Action onFinish = () =>
            {
                foreach (string s in Directory.GetFiles(path))
                {
                    if (s.ToLower().Contains("b.xml"))
                    {
                        string textToReplace = File.ReadAllText(s);
                        while (textToReplace.Contains("res://res://"))
                        {
                            textToReplace = textToReplace.Replace("res://res://", "res://");
                        }
                        textToReplace = textToReplace.Replace("/document", "/viewer/document");
                        textToReplace = textToReplace.Replace(config.ticket, "{TICKET}");
                        File.WriteAllText(copyTo, textToReplace);
                        File.Copy(copyTo, Path.Combine(path, "input/1_1.xml"), true);
                        string repoPath = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder());
                        SVNManager.AddFile(copyTo.Replace(repoPath + "/", ""));
                    }
                }

                X3DTrans(copyTo);
            };

            Thread th = new Thread(new ThreadStart(() =>
            {
                command = "cd \"" + path + "\" & java -jar \"" + PathHelper.GetToolsPath() + "/saxon9he.jar\" \"" + path + "/xslt/a.xml\" \"" + PathHelper.GetToolsPath() + "/xslt/c.xsl\" " + parameters + " > \"" + path + "/b.xml\"";
                ProcessStartInfo processInfo;
                processInfo = new ProcessStartInfo("cmd.exe", "/C " + command);

                processInfo.CreateNoWindow         = true;
                processInfo.UseShellExecute        = false;
                processInfo.RedirectStandardOutput = true;
                processInfo.RedirectStandardError  = true;

                var process    = Process.Start(processInfo);
                string outputt = process.StandardOutput.ReadToEnd();
                string errors  = process.StandardError.ReadToEnd();

                if (!string.IsNullOrEmpty(errors))
                {
                    _logger.LogError($"Error executing command: \"{command}\". Message: '{errors}'");
                }

                process.WaitForExit();
                onFinish();
            }));

            th.Start();
        }
示例#10
0
 public static string GetRepoPath()
 {
     return(Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder()).Replace("\\", "/"));
 }
示例#11
0
        private static void ImportHandler(int deep, string parent, string path, bool overwrite, string destination, bool checkIndex = false)
        {
            foreach (DirectoryInfo folder in new DirectoryInfo(path).GetDirectories())
            {
                string dirName  = folder.Name;
                string infoPath = Path.Combine(path, dirName, dirName + ".info");

                if (File.Exists(infoPath))
                {
                    string[] nameSplit = dirName.Split('.');
                    string   oldId     = dirName.Split('.')[0];
                    string   newId;
                    if (overwrite || deep < 2)
                    {
                        newId = oldId;
                    }
                    else
                    {
                        newId = PathHelper.GenerateId(10);
                    }
                    if (nameSplit.Length < 2)
                    {
                        newId = PathHelper.GenerateId(10) + ".Folder" + random.Next(1000, 10000);
                    }

                    bool   copyInfo   = true;
                    string newDirName = dirName.Replace(oldId, newId);
                    if (!string.IsNullOrEmpty(destination))
                    {
                        string[] dest = destination.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                        if (dest.Length > 0)
                        {
                            newDirName  = dest[0];
                            newId       = dest[0].Split('.')[0];
                            destination = destination.Replace(dest[0], "");
                            copyInfo    = false;
                        }
                    }

                    if (deep == 2)
                    {
                        tempIds.Add(new IdContainer(oldId, newId));
                    }

                    if (dirName != newDirName)
                    {
                        Directory.Move(Path.Combine(path, dirName), Path.Combine(path, newDirName));
                        infoPath = Path.Combine(path, newDirName, dirName + ".info");
                        if (copyInfo)
                        {
                            if (File.Exists(Path.Combine(path, newDirName, newDirName + ".info")))
                            {
                                File.Delete(Path.Combine(path, newDirName, newDirName + ".info"));
                            }
                            File.Move(infoPath, Path.Combine(path, newDirName, newDirName + ".info"));
                        }
                        else
                        {
                            File.Delete(infoPath);
                        }
                    }
                    ImportHandler(deep + 1, Path.Combine(parent, newDirName), folder.FullName.Replace(dirName, newDirName), overwrite, destination, checkIndex);
                }

                if (dirName == "topics")
                {
                    FileInfo[] folderFiles = folder.GetFiles();
                    int        filesCount  = 0;
                    if (checkIndex)
                    {
                        string repoPath    = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder()).Replace("\\", "/");
                        string newLocation = Path.Combine(repoPath, parent).Replace("\\", "/") + "/topics";

                        if (!Directory.Exists(newLocation))
                        {
                            Directory.CreateDirectory(newLocation);
                        }

                        filesCount = Directory.GetFiles(newLocation, "*", SearchOption.AllDirectories).Length;
                    }
                    int indexId = 0;
                    foreach (FileInfo t in folderFiles)
                    {
                        TopicModel    topic    = JsonConvert.DeserializeObject <TopicModel>(File.ReadAllText(t.FullName));
                        OldTopicModel oldTopic = JsonConvert.DeserializeObject <OldTopicModel>(File.ReadAllText(t.FullName));
                        if (!string.IsNullOrEmpty(oldTopic.pathToZip))
                        {
                            topic.localization = "default";
                            topic.pathToZip    = oldTopic.pathToZip;
                            //Debug.Log("Old import");
                        }
                        if (!string.IsNullOrEmpty(oldTopic.vmpPath))
                        {
                            topic.localization = "default";
                            topic.vmpPath      = oldTopic.vmpPath;
                            //Debug.Log("Old import");
                        }

                        if (string.IsNullOrEmpty(topic.unique_id))
                        {
                            topic.unique_id = PathHelper.GenerateId(6);
                        }

                        if (checkIndex)
                        {
                            topic.index = filesCount;
                        }

                        string oldTopicName = t.Name;
                        string newTopicName = "topic" + PathHelper.GenerateIntId(8) + ".info";

                        topic.localization = "default";
                        string locPath  = Path.Combine(Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder()), parent, "default");
                        string tempPath = Path.Combine(t.Directory.Parent.FullName, "default");

                        if (!string.IsNullOrEmpty(topic.pathToZip))
                        {
                            string oldZipName = new FileInfo(topic.pathToZip).Name;
                            string newZipName = "zip" + PathHelper.GenerateIntId(8) + ".zip";
                            if (File.Exists(Path.Combine(tempPath, "pub_in", oldZipName)))
                            {
                                if (File.Exists(Path.Combine(tempPath, "pub_in", newZipName)))
                                {
                                    File.Delete(Path.Combine(tempPath, "pub_in", newZipName));
                                }
                                File.Move(Path.Combine(tempPath, "pub_in", oldZipName), Path.Combine(tempPath, "pub_in", newZipName));
                            }
                            topic.pathToZip        = Path.Combine(locPath, "pub_in", newZipName);
                            topic.pathToZip        = topic.pathToZip.Replace("\\", "/");
                            topic.pathToZipDEFAULT = Path.Combine(locPath, "pub_in", newZipName);
                            topic.pathToZipDEFAULT = topic.pathToZip.Replace("\\", "/");
                        }
                        if (!string.IsNullOrEmpty(topic.vmpPath))
                        {
                            string oldVmpName = new FileInfo(topic.vmpPath).Name;
                            string newVmpName = "obj" + PathHelper.GenerateIntId(8) + ".vmp";
                            if (File.Exists(Path.Combine(tempPath, "projects", oldVmpName)))
                            {
                                if (File.Exists(Path.Combine(tempPath, "projects", newVmpName)))
                                {
                                    File.Delete(Path.Combine(tempPath, "projects", newVmpName));
                                }
                                File.Move(Path.Combine(tempPath, "projects", oldVmpName), Path.Combine(tempPath, "projects", newVmpName));
                            }
                            if (File.Exists(Path.Combine(tempPath, "projects", oldVmpName.Replace(".vmp", ".vmb"))))
                            {
                                if (File.Exists(Path.Combine(tempPath, "projects", newVmpName.Replace(".vmp", ".vmb"))))
                                {
                                    File.Delete(Path.Combine(tempPath, "projects", newVmpName.Replace(".vmp", ".vmb")));
                                }
                                File.Move(Path.Combine(tempPath, "projects", oldVmpName.Replace(".vmp", ".vmb")), Path.Combine(tempPath, "projects", newVmpName.Replace(".vmp", ".vmb")));
                            }
                            topic.vmpPath        = Path.Combine(locPath, "projects", newVmpName);
                            topic.vmpPath        = topic.vmpPath.Replace("\\", "/");
                            topic.vmpPathDEFAULT = Path.Combine(locPath, "projects", newVmpName);
                            topic.vmpPathDEFAULT = topic.vmpPath.Replace("\\", "/");
                        }

                        topic.isOpened = 0;

                        //change path to zip and vmp
                        File.WriteAllText(t.FullName, JsonConvert.SerializeObject(topic));
                        //topic.index = folderFiles.Length;
                        if (File.Exists(t.FullName.Replace(oldTopicName, newTopicName)))
                        {
                            File.Delete(t.FullName.Replace(oldTopicName, newTopicName));
                        }
                        Thread.Sleep(100);
                        File.Move(t.FullName, t.FullName.Replace(oldTopicName, newTopicName));
                    }

                    if (!checkIndex)
                    {
                        List <TopicModel> topicModels = new List <TopicModel>();

                        foreach (FileInfo t in folder.GetFiles())
                        {
                            TopicModel topic = JsonConvert.DeserializeObject <TopicModel>(File.ReadAllText(t.FullName));
                            topic.infoPath = t.FullName;
                            topicModels.Add(topic);
                        }

                        topicModels = topicModels.OrderBy(t => t.index).ToList();
                        for (int i = 0; i < topicModels.Count; i++)
                        {
                            if (topicModels[i].index != i)
                            {
                                topicModels[i].index = i;
                                File.WriteAllText(topicModels[i].infoPath, JsonConvert.SerializeObject(topicModels[i]));
                            }
                        }
                    }
                }
            }
        }
示例#12
0
 private static string GetTempFolderPath()
 {
     return(Path.Combine(Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder()), "temp_export"));
 }