Exemplo n.º 1
0
        private void AddDevice(CpDeviceUpdate aDevice, int aIndex)
        {
            JsonObject info = new JsonObject();

            info.Add("Index", new JsonValueInt(aIndex));
            info.Add("MacAddress", new JsonValueString(aDevice.MacAddress));
            info.Add("Description", aDevice.Json);
            info.Add("Progress", new JsonValueUint(aDevice.Progress));
            info.Add("Message", new JsonValueString(aDevice.Message));
            info.Add("NewVersion", new JsonValueString(VersionSupport.SoftwareVersionPretty(aDevice.UpdateSoftwareVersion, true)));
            Send("UpdateableDeviceAdded", info);
        }
Exemplo n.º 2
0
        public static ApiVersionsResponse FromBytes(IRequestContext context, ArraySegment <byte> bytes)
        {
            using (var reader = new KafkaReader(bytes)) {
                var errorCode = (ErrorCode)reader.ReadInt16();

                var apiKeys = new VersionSupport[reader.ReadInt32()];
                for (var i = 0; i < apiKeys.Length; i++)
                {
                    var apiKey     = (ApiKey)reader.ReadInt16();
                    var minVersion = reader.ReadInt16();
                    var maxVersion = reader.ReadInt16();
                    apiKeys[i] = new VersionSupport(apiKey, minVersion, maxVersion);
                }
                return(new ApiVersionsResponse(errorCode, apiKeys));
            }
        }
Exemplo n.º 3
0
 public static IVersionSupport Dynamic(this VersionSupport versionSupport)
 {
     return(new DynamicVersionSupport(versionSupport));
 }
Exemplo n.º 4
0
 public static IVersionSupport MakeDynamic(this VersionSupport versionSupport)
 {
     return(new VersionSupport(versionSupport, isDynamic: true));
 }
Exemplo n.º 5
0
        public void GetInfo(string aModel, bool aIsProxy, string aSoftwareVersion, string[] aBoardNumber, out bool aAvailable, out string aVersion, out string aUrl, out string aVariant, out string aReleaseNotesHtml)
        {
            aAvailable        = false;
            aVersion          = null;
            aUrl              = null;
            aVariant          = null;
            aReleaseNotesHtml = null;

            Lock();
            if (!iUpdateCheckComplete)
            {
                Unlock();
                return;
            }
            Unlock();

            UpdateCheck.UpdateInfo updateInfo = null;
            if (aModel != null)
            {
                if (aIsProxy)
                {
                    iUpdateInfoProxy.TryGetValue(aModel, out updateInfo);
                }
                else
                {
                    iUpdateInfo.TryGetValue(aModel, out updateInfo);
                }
            }

            if (updateInfo != null && aSoftwareVersion != null)
            {
                if (aIsProxy)
                {
                    aAvailable = (VersionSupport.CompareProxyVersions(updateInfo.Version, aSoftwareVersion) > 0);
                }
                else
                {
                    aAvailable = (VersionSupport.CompareVersions(updateInfo.Version, aSoftwareVersion) > 0);
                }
                aVersion = updateInfo.Version;
                aUrl     = updateInfo.Url;
            }

            aVariant = GetDeviceVariant(aBoardNumber);

            if (aModel != null)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(iReleaseNotesXml);
                aReleaseNotesHtml = "<html><head><meta content=\"text/html; charset=ISO-8859-1\" http-equiv=\"content-type\"><title>Release Notes</title></head><style type=\"text/css\">body {color:#FFF;background:#000;}a {color:#2D8FBF;text-decoration:none;}a:active {color:#939393;text-decoration:none;}</style><body>";
                foreach (XmlNode n in document.SelectNodes("/rss/channel/item"))
                {
                    string title   = n["title"].InnerText;
                    string date    = n["pubDate"].InnerText;
                    string details = n["description"].InnerText.Replace("![CDATA[", "").Replace("]]", "");
                    string link    = n["link"] != null ? n["link"].InnerText : null;

                    if ((title.StartsWith("Linn DS") && (details.Contains(aModel + ",") || (details.Contains(aModel + ".")) || (details.Contains(aModel + " ")))) || (title.StartsWith(aModel + " ")))
                    {
                        aReleaseNotesHtml += "<h4>" + (link != null ? "<a href=\"" + link + "\">" : "") + title + (link != null ? "</a>" : "") + "</h4>" + details + date + "<br/><hr/>";
                    }
                }
                aReleaseNotesHtml += "</body></html>";
                aReleaseNotesHtml  = aReleaseNotesHtml.Replace("<br><br>", "<br>");
            }
        }