private Collection <Web.GithubJsonItem> GetBranches(Web.GithubClient ghc, String Owner, String Repository) { lblStatus.Text = "Getting branches, please wait..."; Application.DoEvents(); Collection <Web.GithubJsonItem> rtn = null; rtn = ghc.GetBranches(Owner, Repository); lblRateLimit.Text = ghc.RateLimitRemaining.ToString(); return(rtn); }
private bool InitialDownload() { bool rtn = true; string err = ""; System.Collections.Specialized.StringCollection mods = Properties.Settings.Default.Modules; System.Collections.Specialized.StringCollection newmods = new System.Collections.Specialized.StringCollection(); if (mods != null && mods.Count > 0) { foreach (string mod in mods) { String[] modparts = mod.Split('|'); if (modparts != null && modparts.Length >= 3 && modparts.Length <= 4) { try { Web.GithubClient ghc = new Web.GithubClient(); String location = modparts[1]; String[] locparts = location.Split('/'); if (locparts != null && locparts.Length == 2) { String RepoOwner = locparts[0]; String Repository = modparts[0]; String branch = modparts[2]; ghc.GetArchive(RepoOwner, Repository, branch, Properties.Settings.Default.ModulePath); ghc.GetLastModified(RepoOwner, Repository, branch, ""); newmods.Add(mod + ghc.LastModified); if (ghc.Errors.Count > 0) { rtn = rtn && false; err += String.Join(Environment.NewLine, ghc.Errors.ToArray()); } if (new DirectoryInfo(Properties.Settings.Default.ScriptPath).GetFiles("*", SearchOption.AllDirectories).Count() > 0) { if (MessageBox.Show(Strings.StringValue.ConfirmScriptDelete, "Existing Scripts", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { ghc.GetPSFScripts(Properties.Settings.Default.ScriptPath); } } else { ghc.GetPSFScripts(Properties.Settings.Default.ScriptPath); } if (ghc.Errors.Count > 0) { rtn = rtn && false; err += String.Join(Environment.NewLine, ghc.Errors.ToArray()); } } else { rtn = rtn && false; err += "Invalid location in module."; } ghc = null; } catch (Exception e) { MessageBox.Show(e.Message); } } } if (newmods.Count == mods.Count) { Properties.Settings.Default["Modules"] = newmods; Properties.Settings.Default["LastModuleCheck"] = DateTime.Now.ToString(); Properties.Settings.Default.Save(); Properties.Settings.Default.Reload(); } } if (!rtn) { Errors[(int)Steps.Check_Settings] = err; } return(rtn); }
private void btnCheckUpdates_Click(object sender, EventArgs e) { if (lvwModules.SelectedItems.Count > 0) { ListViewItem itm = lvwModules.SelectedItems[0]; Properties.Settings.Default["LastModuleCheck"] = DateTime.Now.ToString(); Properties.Settings.Default.Save(); Properties.Settings.Default.Reload(); string err = ""; Web.GithubClient ghc = new Web.GithubClient(); try { String location = itm.SubItems[1].Text; String[] locparts = location.Split('/'); if (locparts != null && locparts.Length == 2) { String RepoOwner = locparts[0]; String Repository = itm.Text; String branch = itm.SubItems[2].Text; String lastmodified = itm.SubItems[3].Text; String repolastmodified = ghc.GetLastModified(RepoOwner, Repository, branch, lastmodified); if (lastmodified != repolastmodified) { if (MessageBox.Show(String.Format(StringValue.ModuleUpdateAvailable, repolastmodified), "Update Available", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { Interface.frmRepository frm = new frmRepository(); frm.Text = "Update Module"; frm.Url = Path.Combine(StringValue.GithubURL, itm.SubItems[1].Text); frm.Branch = itm.SubItems[2].Text; frm.DoUpdate = true; if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!restart) { restart = frm.Restart; } AddModule(frm.RepositoryName, frm.LocationName, frm.Branch, frm.LastModified); SaveModules(); } frm.Dispose(); frm = null; if (restart) { lblRestartRequired.Visible = true; } } } else { MessageBox.Show(StringValue.ModuleUptoDate); } if (ghc.Errors.Count > 0) { err += String.Join(Environment.NewLine, ghc.Errors.ToArray()); } } else { err += "Invalid location in module."; } } catch (Exception ex) { MessageBox.Show(ex.Message); } ghc = null; if (restart) { lblRestartRequired.Visible = true; } } }
private bool InitialDownload() { bool rtn = true; string err = ""; System.Collections.Specialized.StringCollection mods = Properties.Settings.Default.Modules; System.Collections.Specialized.StringCollection newmods = new System.Collections.Specialized.StringCollection(); if (mods != null && mods.Count > 0) { foreach (string mod in mods) { String[] modparts = mod.Split('|'); if (modparts != null && modparts.Length >= 3 && modparts.Length <= 4) { try { Web.GithubClient ghc = new Web.GithubClient(); String location = modparts[1]; String[] locparts = location.Split('/'); if (locparts != null && locparts.Length == 2) { String RepoOwner = locparts[0]; String Repository = modparts[0]; String branch = modparts[2]; ghc.GetArchive(RepoOwner, Repository, branch, Properties.Settings.Default.ModulePath); ghc.GetLastModified(RepoOwner, Repository, branch, ""); newmods.Add(mod + ghc.LastModified); if (ghc.Errors.Count > 0) { rtn = rtn && false; err += String.Join(Environment.NewLine, ghc.Errors.ToArray()); } if (new DirectoryInfo(Properties.Settings.Default.ScriptPath).GetFiles("*", SearchOption.AllDirectories).Count() > 0) { if (MessageBox.Show(Strings.StringValue.ConfirmScriptDelete, "Existing Scripts", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { ghc.GetPSFScripts(Properties.Settings.Default.ScriptPath); } } else { ghc.GetPSFScripts(Properties.Settings.Default.ScriptPath); } if (ghc.Errors.Count > 0) { rtn = rtn && false; err += String.Join(Environment.NewLine, ghc.Errors.ToArray()); } } else { rtn = rtn && false; err += "Invalid location in module."; } ghc = null; } catch (Exception e) { MessageBox.Show(e.Message); } } } if (newmods.Count == mods.Count) { Properties.Settings.Default["Modules"] = newmods; Properties.Settings.Default["LastModuleCheck"] = DateTime.Now.ToString(); Properties.Settings.Default.Save(); Properties.Settings.Default.Reload(); } } if (!rtn) { Errors[(int)Steps.Check_Settings] = err; } return rtn; }