/// <summary> /// To call when the user click on an update button /// </summary> public static void CheckForUpdate() { if (!Utils.IsSpamming("updates", 1000)) { UserCommunication.Notify("Now checking for updates, you will be notified when it's done", MessageImg.MsgInfo, "Update", "Update check", 5); Task.Factory.StartNew(() => { CheckForUpdate(false); }); } }
/// <summary> /// To call when the user click on an update button /// </summary> public void CheckForUpdate() { if (!Utils.IsSpamming(UpdatedSoftName + "update", 3000)) { UserCommunication.NotifyUnique("Update" + UpdatedSoftName, "Checking for a new release from " + Updater.GitHubReleaseApi.ToHtmlLink("github.com", true) + ".<br>You will be notified when it's done.", MessageImg.MsgInfo, UpdatedSoftName + " updater", "Checking for updates...", null, 5); Task.Factory.StartNew(() => { CheckForUpdate(true); }); } }
/// <summary> /// Sends an comment to a given GITHUB issue url /// </summary> /// <param name="message"></param> /// <param name="url"></param> public static bool SendComment(string message, string url) { // https://api.github.com/repos/jcaillon/3p/issues/1/comments // handle spam (10s min between 2 posts) if (Utils.IsSpamming("SendComment", 10000)) { return(false); } var wb = new WebServiceJson(WebServiceJson.WebRequestMethod.Post, url); wb.OnInitHttpWebRequest += request => { request.Proxy = Config.Instance.GetWebClientProxy(); request.UserAgent = "3pUser"; request.Headers.Add("Authorization", "Basic " + Config.GitHubToken); }; wb.AddToReq("body", message); wb.OnRequestEnded += json => { UserCommunication.Notify((json.ResponseException != null ? json.ResponseException.ToString() : "") + "\r\n" + json.StatusCodeResponse + ":" + (json.StatusDescriptionResponse ?? "") + "\r\n" + (json.JsonResponse ?? "")); }; wb.Execute(); return(false); }
/// <summary> /// Sends an comment to a given GITHUB issue url /// </summary> /// <param name="message"></param> /// <param name="url"></param> public static bool SendComment(string message, string url) { // https://api.github.com/repos/jcaillon/3p/issues/1/comments // handle spam (10s min between 2 posts) if (Utils.IsSpamming("SendComment", 10000)) { return(false); } var wb = new WebServiceJson(WebServiceJson.WebRequestMethod.Post, url); // Convert.ToBase64String(Encoding.ASCII.GetBytes("user:mdp")); wb.OnInitHttpWebRequest += request => request.Headers.Add("Authorization", "Basic " + Config._3PUserCredentials); wb.AddToReq("body", "### " + Environment.UserName + " (" + Environment.MachineName + ") ###\r\n" + "#### 3P version : " + AssemblyInfo.Version + ", Notepad++ version : " + Npp.GetNppVersion + " ####\r\n" + message ); wb.Execute(); return(false); }