Ejemplo n.º 1
0
        public static int LatestUpdate()
        {
            int StackReference = Stack.Add("Updater.LatestUpdate()");

            if (string.IsNullOrWhiteSpace(UpdaterDB))
            {
                UpdaterDB = LDDataBase.ConnectSQLite(GlobalStatic.UpdaterDBpath);
            }
            Primitive QueryItems = LDDataBase.Query(UpdaterDB, $"SELECT * FROM updates WHERE PRODUCTID = '{ GlobalStatic.ProductID }';", null, true);

            int.TryParse(QueryItems[1]["VERSION"], out int LatestVersion);
            Stack.Exit(StackReference);
            return(LatestVersion);
        }
Ejemplo n.º 2
0
        static string[] FetchLinks()
        {
            int StackPointer = Stack.Add("Updater.DownloadLinks");

            if (string.IsNullOrWhiteSpace(UpdaterDB))
            {
                UpdaterDB = LDDataBase.ConnectSQLite(GlobalStatic.UpdaterDBpath);
            }
            Primitive QueryItems = LDDataBase.Query(UpdaterDB, $"SELECT * FROM updates WHERE PRODUCTID = '{ GlobalStatic.ProductID }';", null, true);

            string[] Locations = new string[2];
            Locations[0] = QueryItems[1]["URL"];
            Locations[1] = QueryItems[1]["URL2"];
            Stack.Exit(StackPointer);
            return(Locations);
        }
Ejemplo n.º 3
0
        static Primitive Query(string DataBase, string SQL, string ListView, bool FetchRecords, string UserName, string Explanation) //Expand
        {
            int StackPointer = Stack.Add("Engines.Query()");

            _UTC_Start.Add(DateTime.UtcNow.ToString("hh:mm:ss tt"));
            Stopwatch QueryTime = Stopwatch.StartNew();

            if (SQL.StartsWith("."))
            {
                Emulator(DB_Info[DataBase].Engine, DataBase, SQL, UserName, ListView);
                Stack.Exit(StackPointer);
                return(null);
            }

            if (GlobalStatic.Transaction_Query == true)
            {
                TransactionRecord(UserName, DataBase, SQL, Type.Query, Explanation);
            }

            if (UseCache == false)
            {
                _CacheStatus.Add("Disabled");
            }
            else if (FetchRecords == false)
            {
                //The Cache can never be hit :(
                _CacheStatus.Add("NA");
            }

            Primitive QueryResults;

            if (UseCache == false && FetchRecords == true && string.IsNullOrWhiteSpace(ListView) == true && _Cache.ContainsKey(SQL) == true)
            {
                //Read data back from Cache
                _CacheStatus.Add("Hit!");
                QueryResults          = _Cache[SQL].Results;
                _Cache[SQL].LifeTime -= 1;
                if (_Cache[SQL].LifeTime <= 0)
                {
                    _Cache.Remove(SQL);
                }
            }
            else
            {
                //Data is not in Cache :(
                QueryResults = LDDataBase.Query(DataBase, SQL, ListView, FetchRecords);
                if (UseCache == true && FetchRecords == true && _Cache.ContainsKey(SQL) == false)
                {
                    CacheEntry cache = new CacheEntry
                    {
                        LifeTime = 10,
                        Results  = QueryResults
                    };
                    _Cache.Add(SQL, cache);
                    _CacheStatus.Add("Results added to cache");
                }
                else if (UseCache == true && _Cache.ContainsKey(SQL))
                {
                    _CacheStatus.Add("Error");
                }
            }

            _Type_Referer.Add(Type.Query);

            switch (Explanation)
            {
            case "SCHEMA-PRIVATE":
            case "SCHEMA":
                break;

            default:
                _Last_NonSchema_Query.Add(SQL);
                break;
            }

            _Last_Query.Add(SQL);
            _Timer.Add(QueryTime.ElapsedMilliseconds);
            _Explanation.Add(Explanation);
            _User.Add(UserName);
            Stack.Exit(StackPointer);
            return(QueryResults);
        }