public static bool GetLicense(string name, string email, string product) { var desc = ApiDescriptor.GetInstance(); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(desc.RequestLicense); req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; req.Method = "POST"; Dictionary <string, string> pars = new Dictionary <string, string>(); FeedbackTool.FillStdParams(pars, false); pars["NAME"] = name; pars["EMAIL"] = email; pars["PRODUCT"] = product; string pars_enc = StringTool.UrlEncode(pars, Encoding.UTF8); byte[] data = Encoding.UTF8.GetBytes(pars_enc); req.ContentLength = data.Length; using (Stream fw = req.GetRequestStream()) { fw.Write(data, 0, data.Length); } using (var resp = req.GetResponse()) { using (Stream fr = resp.GetResponseStream()) { using (StreamReader reader = new StreamReader(fr)) { string licdata = reader.ReadToEnd(); if (LicenseTool.LoadLicenseFromString(licdata) == null) { return(false); } using (var fw = new StreamWriter(Path.Combine(Framework.LicensesDirectory, Guid.NewGuid().ToString()))) { fw.Write(licdata); return(true); } } } } }
public static bool Send(string subject, string body, bool sendanswer, string email) { var desc = ApiDescriptor.GetInstance(); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(desc.SendFeedback); req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; req.Method = "POST"; Dictionary <string, string> pars = new Dictionary <string, string>(); //if (CheckAutoUpdate.UpdateID != null) pars["PROGRAMUPDATE"] = CheckAutoUpdate.UpdateID.ToString(); FeedbackTool.FillStdParams(pars, false); pars["SUBJECT"] = subject; pars["BODY"] = body; pars["SENDANSWER"] = sendanswer ? "1" : "0"; pars["EMAIL"] = email; string pars_enc = StringTool.UrlEncode(pars, Encoding.UTF8); byte[] data = Encoding.UTF8.GetBytes(pars_enc); req.ContentLength = data.Length; using (Stream fw = req.GetRequestStream()) { fw.Write(data, 0, data.Length); } using (var resp = req.GetResponse()) { using (Stream fr = resp.GetResponseStream()) { using (StreamReader reader = new StreamReader(fr)) { var doc = new XmlDocument(); doc.Load(reader); string state = doc.DocumentElement.GetAttribute("state"); return(state == "ok"); } } } }
//public static void DoSendUsage() //{ // foreach (string file in Directory.GetFiles(Core.UsageDirectory)) // { // if (GlobalSettings.Pages.General.AllowUploadUsageStats) // { // UploadUsageFile(file); // } // File.Delete(file); // } //} //public static void UploadUsageFile(string file) //{ // using (StreamReader sr = new StreamReader(file)) // { // UploadUsageData(sr.ReadToEnd()); // } //} //public static void UploadUsageData(string usageData) //{ // try // { // var desc = ApiDescriptor.GetInstance(); // HttpWebRequest req = (HttpWebRequest)WebRequest.Create(desc.SendUsage); // req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; // req.Method = "POST"; // Dictionary<string, string> pars = new Dictionary<string, string>(); // pars["DATA"] = usageData; // FeedbackTool.FillStdParams(pars); // string pars_enc = StringTool.UrlEncode(pars, Encoding.UTF8); // byte[] data = Encoding.UTF8.GetBytes(pars_enc); // req.ContentLength = data.Length; // using (Stream fw = req.GetRequestStream()) // { // fw.Write(data, 0, data.Length); // } // using (var resp = req.GetResponse()) // { // using (Stream fr = resp.GetResponseStream()) // { // using (StreamReader reader = new StreamReader(fr)) // { // string line = reader.ReadToEnd(); // Logging.Debug("Read result from datadmin feedback:" + line); // } // } // } // } // catch (Exception err) // { // Errors.ReportSilent(err); // } //} private static void DoSendUsage() { try { var desc = ApiDescriptor.GetInstance(); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(desc.SendUsage); req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; req.Method = "POST"; Dictionary <string, string> pars = new Dictionary <string, string>(); FeedbackTool.FillStdParams(pars, true); string pars_enc = StringTool.UrlEncode(pars, Encoding.UTF8); byte[] data = Encoding.UTF8.GetBytes(pars_enc); req.ContentLength = data.Length; using (Stream fw = req.GetRequestStream()) { fw.Write(data, 0, data.Length); } using (var resp = req.GetResponse()) { using (Stream fr = resp.GetResponseStream()) { using (StreamReader reader = new StreamReader(fr)) { string line = reader.ReadToEnd(); Logging.Debug("Read result from datadmin feedback:" + line); } } } } catch (Exception err) { Errors.ReportSilent(err); } }
private static void DoSendError(Exception error, List <LogMessageRecord> logHistory, Bitmap screenshot) { try { var desc = ApiDescriptor.GetInstance(); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(desc.SendError); req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; req.Method = "POST"; XmlDocument doc = XmlTool.CreateDocument("Error"); XmlElement xml = doc.DocumentElement; xml.SetAttribute("version", VersionInfo.VERSION); xml.AddChild("Message").InnerText = error.Message; xml.AddChild("Type").InnerText = error.GetType().FullName; xml.AddChild("StackTrace").InnerText = error.StackTrace; //xml.AddChild("DataTree").InnerText = GetDataTree(); Exception se = error; while (se != null) { XmlTool.SaveParameters(xml, se.Data); se = se.InnerException; } xml.AddChild("Text").InnerText = error.ToString(); //if (logHistory != null && CheckAutoUpdate.SendErrorLogs) Logging.SaveLogs(logHistory, xml.AddChild("LogHistory")); Dictionary <string, string> pars = new Dictionary <string, string>(); StringWriter sw = new StringWriter(); doc.Save(sw); pars["DATA"] = sw.ToString(); //if (screenshot != null && CheckAutoUpdate.SendErrorScreenshots) pars["SCREENSHOT"] = SerializeScreenshot(screenshot); //if (CheckAutoUpdate.UpdateID != null) pars["PROGRAMUPDATE"] = CheckAutoUpdate.UpdateID.ToString(); FeedbackTool.FillStdParams(pars, true); string pars_enc = StringTool.UrlEncode(pars, Encoding.UTF8); byte[] data = Encoding.UTF8.GetBytes(pars_enc); req.ContentLength = data.Length; using (Stream fw = req.GetRequestStream()) { fw.Write(data, 0, data.Length); } using (var resp = req.GetResponse()) { using (Stream fr = resp.GetResponseStream()) { using (StreamReader reader = new StreamReader(fr)) { string line = reader.ReadToEnd(); Logging.Debug("Read result from datadmin feedback:" + line); } } } } catch (Exception err) { Errors.ReportSilent(err, false); } }
private static void DoRunCheckThreadCore() { var desc = ApiDescriptor.GetInstance(); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(desc.GetUpdate); req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; req.Method = "POST"; Dictionary <string, string> pars = new Dictionary <string, string>(); FeedbackTool.FillStdParams(pars, true); if (m_checked) { pars["REPEATED"] = "1"; } string pars_enc = StringTool.UrlEncode(pars, Encoding.UTF8); byte[] data = Encoding.UTF8.GetBytes(pars_enc); req.ContentLength = data.Length; req.Timeout = 5000; using (Stream requestStream = req.GetRequestStream()) { requestStream.Write(data, 0, data.Length); } using (WebResponse resp = req.GetResponse()) { XmlDocument doc = new XmlDocument(); using (Stream fr = resp.GetResponseStream()) { doc.Load(fr); } string version = doc.SelectSingleNode("/update/version").InnerText; string url = doc.SelectSingleNode("/update/url").InnerText; //try { UpdateID = Int32.Parse(doc.SelectSingleNode("/update/updateid").InnerText); } //catch { } DateTime updatedat; try { updatedat = DateTime.ParseExact(doc.SelectSingleNode("/update/updatedat").InnerText, "s", CultureInfo.InvariantCulture); } catch { updatedat = DateTime.UtcNow; } //try { SendErrorLogs = doc.SelectSingleNode("/update/errorlogs").InnerText == "1"; } //catch { SendErrorLogs = true; } //try { ScreenshotWidth = Int32.Parse(doc.SelectSingleNode("/update/screenshots").InnerText); } //catch { ScreenshotWidth = 0; } if (VersionInfo.AllowAutoUpdate && CompareVersions(version, VersionInfo.VERSION) > 0) { if (Framework.Instance.GetCheckNewVersion() == CheckNewVersions.CheckOnly) { //MainWindow.Instance.RunInMainWindow(delegate() { StdDialog.ShowInfo(Texts.Get("s_new_version_available$version", "version", version)); }); Framework.MainWindow.SendVersionInfo(Texts.Get("s_new_version_available$version", "version", version), null); } if (Framework.Instance.GetCheckNewVersion() == CheckNewVersions.CheckAndDownload) { if (File.Exists(VersionFile) && File.Exists(InstallExeFile)) { string downloadedVersion = IOTool.LoadTextFile(VersionFile).Trim(); if (CompareVersions(version, downloadedVersion) > 0) { File.Delete(VersionFile); File.Delete(InstallExeFile); } else { Logging.Debug("Version allready downloaded"); return; } } Framework.MainWindow.SendVersionInfo(Texts.Get("s_downloading_version$version", "version", version), null); WebRequest req2 = WebRequest.Create(url); using (WebResponse resp2 = req2.GetResponse()) { using (Stream fr = resp2.GetResponseStream()) { using (FileStream fw = new FileStream(InstallExeFile, FileMode.Create)) { IOTool.CopyStream(fr, fw); } } } using (StreamWriter fw = new StreamWriter(VersionFile)) fw.Write(version); using (StreamWriter fw = new StreamWriter(InstallTimestampFile)) fw.Write(updatedat.ToString("s")); Framework.MainWindow.SendVersionInfo(Texts.Get("s_new_version_downloaded$version", "version", version), version); } } else { if (VersionInfo.AllowAutoUpdate) { Framework.MainWindow.SendVersionInfo(Texts.Get("s_you_have_current_version"), null); } } } }
private static void OpenSupportUrl(string path, string addpars) { string url = String.Format("http://www.datadmin.{0}?name={1}&email={2}&version={3}&osversion={4}&edition={5}", path, HttpUtility.UrlEncode(LicenseTool.RegisteredToUser1()), HttpUtility.UrlEncode(LicenseTool.RegEmail1()), HttpUtility.UrlEncode(VersionInfo.VERSION), HttpUtility.UrlEncode(FeedbackTool.OSVersion()), HttpUtility.UrlEncode(LicenseTool.EditionText())); if (addpars != null) { url += addpars; } System.Diagnostics.Process.Start(url); }