Ejemplo n.º 1
0
        public bool IsNewerThan(object obj)
        {
            VersionInformation other = obj as VersionInformation;

            if (other == null)
            {
                return(false);
            }
            if (this.major < other.major)
            {
                return(false);
            }
            if (this.major == other.major &&
                this.minor < other.minor)
            {
                return(false);
            }
            if (this.major == other.major &&
                this.minor == other.minor &&
                this.build < other.build)
            {
                return(false);
            }
            if (this.major == other.major &&
                this.minor == other.minor &&
                this.build == other.build &&
                this.rev <= other.rev)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool NewVersionExists()
        {
            string result = null;
            VersionInformation currentVersion = new VersionInformation() { Version = System.Reflection.AssemblyName.GetAssemblyName(System.Reflection.Assembly.GetExecutingAssembly().Location).Version.ToString() };
            string url = "http://version.excellentanalytics.com/?ver=" + currentVersion;

            WebResponse response = null;
            StreamReader reader = null;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                response = request.GetResponse();
                reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                result = reader.ReadToEnd();
            }
            catch (Exception ex)
            {
                // handle error
                //MessageBox.Show("Error fetching version information:" + Environment.NewLine + ex.Message,
                //                "Version check failed",
                //                MessageBoxButtons.OK,
                //                MessageBoxIcon.Error);
                if (reader != null)
                    reader.Close();
                if (response != null)
                    response.Close();
                return false;
            }

            if (reader != null)
                reader.Close();
            if (response != null)
                response.Close();

            try
            {
                System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
                verinfo = jss.Deserialize<VersionInformation>(result);
            }
            catch {
                //MessageBox.Show("Error parsing version information.", "Version check failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            // The version number is only displayed in the GUI in the published application.
            // When debugging in a test environment the version number is not displayed.
            //string currentVersion = "";
            //if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            //{
            //    System.Deployment.Application.ApplicationDeployment ad =
            //    System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
            //    currentVersion = ad.CurrentVersion.ToString();
            //    currentVersion.Replace(".", "");
            //}

            return verinfo.IsNewerThan(currentVersion);
        }
Ejemplo n.º 3
0
        public bool NewVersionExists()
        {
            string             result         = null;
            VersionInformation currentVersion = new VersionInformation()
            {
                Version = System.Reflection.AssemblyName.GetAssemblyName(System.Reflection.Assembly.GetExecutingAssembly().Location).Version.ToString()
            };
            string url = "http://version.excellentanalytics.com/?ver=" + currentVersion;

            WebResponse  response = null;
            StreamReader reader   = null;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                response       = request.GetResponse();
                reader         = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                result         = reader.ReadToEnd();
            }
            catch (Exception ex)
            {
                // handle error
                //MessageBox.Show("Error fetching version information:" + Environment.NewLine + ex.Message,
                //                "Version check failed",
                //                MessageBoxButtons.OK,
                //                MessageBoxIcon.Error);
                if (reader != null)
                {
                    reader.Close();
                }
                if (response != null)
                {
                    response.Close();
                }
                return(false);
            }

            if (reader != null)
            {
                reader.Close();
            }
            if (response != null)
            {
                response.Close();
            }

            try
            {
                System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
                verinfo = jss.Deserialize <VersionInformation>(result);
            }
            catch {
                //MessageBox.Show("Error parsing version information.", "Version check failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            // The version number is only displayed in the GUI in the published application.
            // When debugging in a test environment the version number is not displayed.
            //string currentVersion = "";
            //if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            //{
            //    System.Deployment.Application.ApplicationDeployment ad =
            //    System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
            //    currentVersion = ad.CurrentVersion.ToString();
            //    currentVersion.Replace(".", "");
            //}

            return(verinfo.IsNewerThan(currentVersion));
        }