예제 #1
0
        public bool UpdateManifestNeed(bool reccomended)
        {
            lock (Manifest)
            {
                Int64 refreshInterval = 10;                 // Minutes

                int refreshManifest = GetInt("advanced.manifest.refresh");
                if (refreshManifest < 0)
                {
                    if ((Manifest != null) && (Manifest.Attributes["next_update"] != null))
                    {
                        refreshInterval = Conversions.ToInt64(Manifest.Attributes["next_update"].Value);
                    }
                }
                else
                {
                    refreshInterval = refreshManifest;
                }

                if (refreshInterval == 0)
                {
                    return(false);
                }

                if (m_lastManifestTimeTry + 60 * refreshInterval < Utils.UnixTimeStamp())
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        public static Int64 XmlGetAttributeInt64(XmlNode node, string name, Int64 def)
        {
            XmlNode nodeAttr = node.Attributes[name];

            if (nodeAttr == null)
            {
                return(def);
            }
            else
            {
                return(Conversions.ToInt64(nodeAttr.Value));
            }
        }
예제 #3
0
 public static void FormatBytesEx(Int64 bytes, ref Int64 number, ref string unit)
 {
     if (bytes <= 0)
     {
         number = 0;
         unit   = "B";
     }
     else
     {
         string[] suf   = { "B", "KB", "MB", "GB", "TB", "PB" };
         int      place = Conversions.ToInt32(Math.Floor(Math.Log(bytes, 1000)));
         double   num   = Math.Round(bytes / Math.Pow(1000, place), 1);
         number = Conversions.ToInt64(num);
         unit   = suf[place];
     }
 }
예제 #4
0
        public bool UpdateManifestNeed(bool reccomended)
        {
            lock (Manifest)
            {
                // 2.8
                Int64 timestampNext   = 0;
                int   refreshManifest = GetInt("advanced.manifest.refresh");
                if (Manifest == null)
                {
                    return(true);
                }
                else if (Manifest.Attributes["next"] == null)
                {
                    return(true);
                }
                else if (refreshManifest < 0)
                {
                    // Server reccomended
                    timestampNext = Conversions.ToInt64(Manifest.Attributes["next"].Value);
                }
                else if (refreshManifest == 0)
                {
                    // Never
                    return(false);
                }
                else
                {
                    timestampNext = Conversions.ToInt64(Manifest.Attributes["time"].Value) + refreshManifest * 60;
                }

                if ((Conversions.ToDateTime(timestampNext) < DateTime.UtcNow) && (reccomended))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #5
0
 public Int64 GetInt64(string name)
 {
     return(Conversions.ToInt64(Get(name)));
 }