Esempio n. 1
0
        public static bool IsUpdateAvailable()
        {
            Version ourBuild  = VersionUtil.GetBuildVersion();
            Version lastBuild = GetLastReleasedVersion().BuildNumber;

            return(ourBuild.CompareTo(lastBuild) < 0);
        }
Esempio n. 2
0
 public WebServiceVersion GetVersion()
 {
     return(new WebServiceVersion()
     {
         Version = VersionUtil.GetVersionName(),
         Build = VersionUtil.GetBuildVersion().ToString(),
         ApiVersion = API_VERSION,
     });
 }
Esempio n. 3
0
 public List <WebBackendProvider> GetAllAsBackendProvider()
 {
     return(items.Values
            .Select(x => new WebBackendProvider()
     {
         Name = (string)x.Metadata["Name"],
         Id = (int)x.Metadata["Id"],
         Version = VersionUtil.GetBuildVersion(x.Value.GetType().Assembly).ToString()
     })
            .ToList());
 }
Esempio n. 4
0
        public ImageCache()
        {
            path = Path.Combine(Installation.GetCacheDirectory(), "imagecache");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string versionFile = Path.Combine(path, "written-by.txt");
            string version     = VersionUtil.GetBuildVersion().ToString();

            if (!File.Exists(versionFile) || File.ReadAllText(versionFile).Trim() != version)
            {
                Log.Info("Deleting invalid imagecache - probably written by an older MPExtended version, nothing to worry about.");
                EmptyCache();
                File.WriteAllText(versionFile, version);
            }
        }
Esempio n. 5
0
        private MvcHtmlString CreateScript(string resolvedPath, int position)
        {
            if (!assets.ContainsKey(resolvedPath))
            {
                var        uri     = resolvedPath + "?v=" + VersionUtil.GetBuildVersion().GetHashCode().ToString();
                TagBuilder builder = new TagBuilder("script");
                builder.MergeAttribute("type", "text/javascript");
                builder.MergeAttribute("src", uri);

                assets.Add(resolvedPath, new ReferencedAsset()
                {
                    AssetType = AssetType.Script,
                    Tag       = builder.ToString(TagRenderMode.Normal),
                    Position  = position
                });
            }

            // return an empty string so that we can use @Html.Assets().AddScript()
            return(MvcHtmlString.Create(String.Empty));
        }
Esempio n. 6
0
        private MvcHtmlString CreateStylesheet(string resolvedPath, int position)
        {
            if (!assets.ContainsKey(resolvedPath))
            {
                var        uri     = resolvedPath + "?v=" + VersionUtil.GetBuildVersion().GetHashCode().ToString();
                TagBuilder builder = new TagBuilder("link");
                builder.MergeAttribute("rel", "stylesheet");
                builder.MergeAttribute("type", "text/css");
                builder.MergeAttribute("href", uri);

                assets.Add(resolvedPath, new ReferencedAsset()
                {
                    AssetType = AssetType.Stylesheet,
                    Tag       = builder.ToString(TagRenderMode.SelfClosing),
                    Position  = position
                });
            }

            // return an empty string so that we can just use @Html.Assets().AddStylesheet()
            return(MvcHtmlString.Create(String.Empty));
        }
Esempio n. 7
0
        private static List <ReleasedVersion> GetReleases()
        {
            if (versionInfoCache != null)
            {
                return(versionInfoCache);
            }

            string data;

            try
            {
                string updateUrl = String.Format(UPDATE_URL, VersionUtil.GetBuildVersion().ToString());
                Log.Debug("Downloading update information from {0}", updateUrl);
                using (WebClient client = new WebClient())
                {
                    data = client.DownloadString(updateUrl);
                }
            }
            catch (Exception ex)
            {
                Log.Info("Failed to download update information", ex);
                return(null);
            }

            // get lines
            string[] lines = data.Replace("\r", "").Split('\n').Select(x => x.Trim()).Where(x => x.Length > 0 && x.Substring(0, 1) != "#").ToArray();
            versionInfoCache = new List <ReleasedVersion>();
            foreach (string line in lines)
            {
                string[] items = line.Split(' ').Select(x => x.Trim()).ToArray();
                versionInfoCache.Add(new ReleasedVersion()
                {
                    BuildNumber = new Version(items[0]),
                    Version     = items[1],
                    ReleaseDate = DateTime.Parse(items[2])
                });
            }

            return(versionInfoCache);
        }
Esempio n. 8
0
        public void Generate()
        {
            // header
            Output.WriteLine(
                "<p>This page contains the API documentation for this MPExtended service, as automatically generated on {0} for version {1} (build {2}). " +
                "Please do not edit, as your changes will be overwritten.</p>",
                DateTime.Now.ToString("dd MMM yyy HH:mm", System.Globalization.CultureInfo.InvariantCulture),
                VersionUtil.GetVersion(Assembly),
                VersionUtil.GetBuildVersion(Assembly));

            UserStream.WriteLine("Generating documentation for assembly {0}", Assembly.GetName().Name);

            // get all items
            IEnumerable <DocGenItem> typesToDocument = new List <DocGenItem>();

            if (JsonAPI != null)
            {
                typesToDocument = JsonAPI.GetMethods().Select(x => new DocGenItem()
                {
                    URLPrefix = "/json",
                    Reflected = x,
                    Name      = x.Name,
                    Order     = GenerateSortOrder(x.Name)
                });
            }
            if (StreamAPI != null)
            {
                typesToDocument = typesToDocument.Union(StreamAPI.GetMethods().Select(x => new DocGenItem()
                {
                    URLPrefix = "/stream",
                    Reflected = x,
                    Name      = x.Name,
                    Order     = GenerateSortOrder(x.Name)
                }));
            }
            if (Enumerations != null)
            {
                typesToDocument = typesToDocument.Union(Enumerations.Select(x => new DocGenItem()
                {
                    URLPrefix = "",
                    Reflected = x,
                    Name      = x.Name,
                    Order     = GenerateSortOrder(x.Name),
                }));
            }

            // sort all types
            typesToDocument = typesToDocument
                              .OrderBy(x => x.Order)
                              .ThenBy(x => x.Name);

            // print navigation
            int lastOrder = -1;

            UserStream.WriteLine("=> Generating documentation header");
            Output.WriteLine("<h3>Navigation</h3>");
            foreach (var item in typesToDocument)
            {
                if (lastOrder != item.Order)
                {
                    if (lastOrder != -1)
                    {
                        Output.WriteLine("</ul>");
                    }
                    Output.WriteLine("<h4>{0}</h4><ul>", GetHeadings()[item.Order]);
                    lastOrder = item.Order;
                }
                Output.WriteLine("<li><a href=\"#{0}\">{0}</a></li>", item.Name);
            }
            Output.WriteLine("</ul>");

            // generate all documentation
            lastOrder = -1;
            foreach (var item in typesToDocument)
            {
                if (lastOrder != item.Order)
                {
                    Output.WriteLine(String.Format("<h3>{0}</h3>", GetHeadings()[item.Order]));
                    lastOrder = item.Order;
                }

                if (item.Reflected is MethodInfo)
                {
                    GenerateMethodDocumentation(item.Reflected as MethodInfo, item.URLPrefix);
                }
                else if (item.Reflected is Type)
                {
                    GenerateEnumDocumentation(item.Reflected as Type);
                }
            }
            UserStream.WriteLine("=> Done");

            Output.Flush();
            Output.Close();
        }
Esempio n. 9
0
 public bool Open()
 {
     try
     {
         Log.Debug("Opening MPExtended ServiceHost version {0} (build {1})", VersionUtil.GetVersionName(), VersionUtil.GetBuildVersion());
         wcf.Start(Installation.GetInstalledServices().Where(x => x.HostAsWCF).ToList());
         ThreadManager.Start("Zeroconf", delegate()
         {
             zeroconf.PublishServices(Installation.GetInstalledServices());
         });
         Log.Debug("Opened MPExtended ServiceHost");
         return(true);
     }
     catch (Exception ex)
     {
         Log.Error("Failed to open MPExtended ServiceHost", ex);
         return(false);
     }
 }