Exemple #1
0
        public override void PublishUpdate(Project project, UpdateInfo newUpdate)
        {
            string updateVersion = VersionFormatter.ToString(newUpdate.version);

            AppInfo appInfo;
            string  appInfoFile = Path.Combine(targetFolder, "appinfo.json");

            if (!File.Exists(appInfoFile))
            {
                appInfo                 = new AppInfo();
                appInfo.appId           = project.AppID;
                appInfo.versions        = project.GetVersionNumbers();
                appInfo.downloadBaseDir = "versions";
                Directory.CreateDirectory(Path.Combine(targetFolder, "versions"));
                File.WriteAllText(appInfoFile, appInfo.ToJson());
            }
            else
            {
                appInfo = AppInfo.FromJson(File.ReadAllText(appInfoFile));
            }

            if (appInfo.versions.Contains(newUpdate.version))
            {
                throw new PublishingFailedException("Version " + updateVersion + " already exists.");
            }

            string versionsFolder        = Path.Combine(targetFolder, appInfo.downloadBaseDir);
            string newVersionFolder      = Path.Combine(versionsFolder, updateVersion);
            string newVersionFilesFolder = Path.Combine(newVersionFolder, "dl");

            if (Directory.Exists(newVersionFolder))
            {
                throw new PublishingFailedException("The destination folder for this version already exists!");
            }
            else
            {
                Directory.CreateDirectory(newVersionFilesFolder);
            }

            string infoFile = Path.Combine(newVersionFolder, "info.json");

            File.WriteAllText(infoFile, newUpdate.ToJson());

            CopyAllInFolder(project.ProjectFolder, newVersionFilesFolder);

            appInfo.versions = appInfo.versions.Concat(new double[] { newUpdate.version }).ToArray();
            File.WriteAllText(appInfoFile, appInfo.ToJson());
        }
Exemple #2
0
 static AppInfo[] ReadConfig()
 {
     return(Directory.GetFiles(Assembly.GetExecutingAssembly().Location.GetDirName(), "*.json")
            .Select(configFile =>
     {
         var info = AppInfo.FromJson(File.ReadAllText(configFile));
         info.ConfigName = configFile.GetFileName();
         if (info.Name == null)
         {
             info.Name = info.ConfigName;
         }
         return info;
     })
            .Where(x => x?.Name != null)
            .ToArray());
 }
Exemple #3
0
        private void loadProjectButton_Click(object sender, EventArgs e)
        {
            FolderSelectDialog folderDialog = new FolderSelectDialog();

            folderDialog.Title = "Select the updates folder containing the appinfo.json file";
            if (folderDialog.ShowDialog(this.Handle))
            {
                string appInfoFile = Path.Combine(folderDialog.FileName, "appinfo.json");
                if (!File.Exists(appInfoFile))
                {
                    MessageBox.Show("Could not load project folder: Folder does not contain appinfo.json", "Failed to load project", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                AppInfo info = AppInfo.FromJson(File.ReadAllText(appInfoFile));
                if (info == null)
                {
                    MessageBox.Show("Could not load project folder: Invalid appinfo.json", "Failed to load project", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                UpdateInfo[] updates = LoadUpdates(folderDialog.FileName, info);

                NewProjectDialog dialog = new NewProjectDialog();
                dialog.appIDTextBox.Text  = info.appId;
                dialog.newProject.Updates = updates.ToList();
                dialog.SetPublisher(typeof(LocalDiskPublisher)); //TODO: enable loading with different publisher types
                dialog.appIDTextBox.Enabled      = false;
                dialog.publisherComboBox.Enabled = false;
                LocalDiskPublisherGUI gui = (LocalDiskPublisherGUI)dialog.publisherSettings.Controls[0];
                gui.SetFolder(folderDialog.FileName);
                gui.SetFolderEditable(false);

                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Settings.Instance.Projects.Add(dialog.newProject);
                    Settings.Instance.Save();
                    SelectPage(OpenProject(dialog.newProject));
                }
            }
        }