Beispiel #1
0
        private void LoadLayout(XmlElement xml)
        {
            ClearPanels();
            foreach (XmlElement xi in xml.SelectNodes("Widget"))
            {
                try
                {
                    var item = new Item();
                    item.LoadProperties(xi);
                    var ctrl = item.Widget.GetControl();
                    item.Frame    = ctrl;
                    ctrl.ConnPack = ConnPack;
                    m_widgets.Add(item);
                    item.Widget.IsDesigning = EnabledDesign;
                }
                catch (Exception err)
                {
                    Errors.ReportSilent(err);
                }
            }
            var doc  = new XmlDocument();
            var layx = xml.FindElement("Layout");

            if (layx != null)
            {
                doc.AppendChild(doc.ImportNode(layx, true));
                var ms = new MemoryStream();
                doc.Save(ms);
                ms.Position = 0;
                dockPanel1.LoadFromXml(ms, GetContentFromPersistString);
            }
            OnChangedWidgetSet();
        }
Beispiel #2
0
        //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);
            }
        }
Beispiel #3
0
        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);
            }
        }