Ejemplo n.º 1
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
#if FEDITION
                WindowSkin.Palette.CurrentSkin = WindowSkin.WindowsSkins.Black;
#endif
#if STANDARD
                WindowSkin.Palette.CurrentSkin = WindowSkin.WindowsSkins.MiddleBlue;
#endif
#if DEBUG
                WindowSkin.Palette.CurrentSkin = WindowSkin.WindowsSkins.Green;
#endif
                string DBT = ConfigurationManager.AppSettings["DatabaseType"];
                DatabaseManager.CreateCurrentDb(ConfigurationManager.AppSettings["ConnectionString"]);

                string lang = Settings.Language;
                Localizator.Dictionary.CreateDictionary(lang);
                WindowSkin.MessageBox.STR_ABORT  = Localizator.Dictionary.GetString("ABORT");
                WindowSkin.MessageBox.STR_CANCEL = Localizator.Dictionary.GetString("CANCEL");
                WindowSkin.MessageBox.STR_IGNORE = Localizator.Dictionary.GetString("IGNORE");
                WindowSkin.MessageBox.STR_NO     = Localizator.Dictionary.GetString("NO");
                WindowSkin.MessageBox.STR_OK     = Localizator.Dictionary.GetString("OK");
                WindowSkin.MessageBox.STR_RETRY  = Localizator.Dictionary.GetString("RETRY");
                WindowSkin.MessageBox.STR_YES    = Localizator.Dictionary.GetString("YES");

                WindowSkin.MessageBox.STR_CAPTION = Localizator.Dictionary.GetString("MESSAGE");

                Updater.DatabaseUpdater.TryUpdateDatabase();
                fMain mainForm = new fMain();
                CheckUpdate.CheckLastVersion(Utils.Utils.GetLastBuildDate(), mainForm);
                //CheckUpdate.CheckLastVersion(new DateTime(2009,12,12), mainForm);
                Application.Run(mainForm);
            }
            catch (Exception ex)
            {
                ErrorViewer.ErrorView.Show(ex);
            }
        }
Ejemplo n.º 2
0
        public static void CheckLastVersion(DateTime currentBuildDate, fMain mainForm)
        {
            Thread t = new Thread(delegate() { GetLastUpdate(currentBuildDate.ToString("yyyyMMdd"), mainForm); });

            t.Start();
        }
Ejemplo n.º 3
0
        private static string Edition = TA.Corel.EditionManager.Edition.ToString();// "FED_EDITION";
        private static void GetLastUpdate(string currentVersion, fMain mainForm)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                // used on each read operation
                byte[] buf = new byte[8192];
                // prepare the web page we will be asking for
                string url = UrlToXml + "?app_guid=" + LicenseManager.SoftwareGuid.ToString();
                url = url + "&exp_date=" + LicenseManager.LicenseExpireDate;
                url = url + "&email=" + LicenseManager.EMail;
                url = url + "&instance_guid=" + LicenseManager.InstanceGuid;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method            = "GET";
                request.ProtocolVersion   = HttpVersion.Version11;
                request.AllowAutoRedirect = false;
                HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
                request.CachePolicy = noCachePolicy;
                request.Accept      = "*/*";
                request.Timeout     = 15000;
                request.UserAgent   = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";
                request.Headers.Add("Accept-Language", "en-us");
                request.KeepAlive = true;
                // execute the request
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                // we will read data via the response stream
                Stream resStream  = response.GetResponseStream();
                string tempString = null;
                int    count      = 0;
                do
                {
                    // fill the buffer with data
                    count = resStream.Read(buf, 0, buf.Length);
                    // make sure we read some data
                    if (count != 0)
                    {
                        // translate from bytes to ASCII text
                        tempString = Encoding.ASCII.GetString(buf, 0, count);
                        // continue building the string
                        sb.Append(tempString);
                    }
                }while (count > 0); // any more data to read?
                string       result   = sb.ToString();
                const string ROOT_TAG = @"</LAST_BUILD_DATE>";
                int          last     = result.LastIndexOf(ROOT_TAG);
                string       xml_text = sb.ToString();
                int          index    = xml_text.IndexOf(ROOT_TAG);
                if (index < 0)
                {
                    return;
                }
                index    = index + ROOT_TAG.Length;
                xml_text = xml_text.Substring(0, index);
#if !DEBUG
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.InnerXml = xml_text;
                XmlNodeList editionDate = xmlDoc.GetElementsByTagName(Edition);
                if (editionDate != null)
                {
                    string lastUpdate = editionDate[0].Attributes["date"].Value;
                    if (lastUpdate.CompareTo(currentVersion) > 0)
                    {
                        mainForm.ShowDownloadPanel();

                        /*fCheckUpdate form = new fCheckUpdate();
                         * form.ShowDialog();*/
                    }
                }
#endif
            }
            catch (Exception)
            {
            }
        }