Beispiel #1
0
        private void GetLatestVersion(HttpContext context, string currentversion, bool isDebug)
        {
            context.Response.ContentType = "text/plain";
            string result = string.Empty;

            if (string.IsNullOrEmpty(currentversion))
            {
                result = isDebug ? "Unknown current version" : string.Empty;
            }
            else
            {
                string localFile = context.Server.MapPath("~/Versions/doemd-versions.xml");
                if (File.Exists(localFile))
                {
                    try
                    {
                        VersionNumber currentVersionNumber = new VersionNumber(currentversion);

                        ProductVersionsDto allProductVersions  = GetAllProductVersions(localFile);
                        ProductVersionDto  foundProductVersion =
                            (from productVersion in allProductVersions
                             let versionNumber = new VersionNumber(productVersion.Version)
                                                 where versionNumber.CompareTo(currentVersionNumber) == 1
                                                 orderby versionNumber descending
                                                 select productVersion).FirstOrDefault();

                        if (foundProductVersion == null)
                        {
                            result = isDebug ? "Current version is actual latest version." : string.Empty;
                        }
                        else
                        {
                            result = foundProductVersion.ToXml();
                            context.Response.ContentType = "text/xml";
                        }
                    }
                    catch (Exception e)
                    {
                        result = isDebug ? string.Format("Error: {0}", e.Message) : string.Empty;
                    }
                }
                else
                {
                    result = isDebug ? "Error processing request #003" : string.Empty;
                }
            }

            context.Response.Write(result);
        }