예제 #1
0
        public bool InitializeConfigTable()
        {
            if (!_bIsInitialized)
            {
                return(false);
            }

            try
            {
                logger.Debug("Initializing the config table");
                _tblConfigTable = _dbDatabase.GetTable <DBConfiguration>(Constants.DATABASE_CONFIGSHEET);
                if (null == _tblConfigTable)
                {
                    logger.Info("Config table does not exist. Creating it.");
                    _tblConfigTable = _dbDatabase.CreateTable <DBConfiguration>(Constants.DATABASE_CONFIGSHEET);
                }
                logger.Debug("Checking the configuration row");
                IList <IRow <DBConfiguration> > rows = _tblConfigTable.FindAll();
                if (null == rows || rows.Count == 0)
                {
                    logger.Debug("Configuration row not found. Creating it.");
                    _tblConfigTable.Add(new DBConfiguration(BaseConfiguration.Default));
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error while trying to initialize the config table: {0}", ex.Message);
                _tblConfigTable = null;
                return(false);
            }

            return(true);
        }
예제 #2
0
 public void setup()
 {
     foreach (var r in table.FindAll())
     {
         r.Delete();
     }
     table.Add(e1);
     table.Add(e2);
 }
예제 #3
0
 public void FixtureSetup()
 {
     Console.WriteLine("Connecting");
     var client = new DatabaseClient("*****@*****.**", "password");
     const string dbName = "IntegrationTests";
     Console.WriteLine("Opening or creating database");
     db = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName);
     const string tableName = "IntegrationTests";
     Console.WriteLine("Opening or creating table");
     table = db.GetTable<IntegrationEntity>(tableName) ?? db.CreateTable<IntegrationEntity>(tableName);
     foreach (var r in table.FindAll())
         r.Delete();
     table.Add(e1);
     table.Add(e2);
 }
예제 #4
0
        public void StoreActivity(ActivityLogEntry entry)
        {
            if (null == _tblActivityLogTable)
            {
                return;
            }

            _tblActivityLogTable.Add(entry);
        }
        public void SetupSpecificTest()
        {
            // prepare a table to have an existing table

            ISchema schema = _Database.NewSchema();

            schema.AddField <int>("Id");
            schema.AddField <string>("Firstname");
            schema.AddField <string>("Secondname");
            schema.AddField <string>("Lastname");
            schema.AddField <bool>("IsMarried");

            ITable table = _Database.NewTable(schema);

            table.Add(new object[] { 3, "Steve", "Patrik", "Lawrence", false });
            table.Add(new object[] { 9, "Sivlia", null, "Dagustina", true });

            _Database.CreateTable(@"\StatementTest\TableAddToExisting", table);
        }
예제 #6
0
        public static Row Put(this ITable table, object obj)
        {
            var columns = obj.GetType().GetProperties().ToDictionary(
                x =>
                x.Name.ToNamePreservation(),
                x => x);
            var values = columns.Keys.Select(x =>
                                             JsonConvert.SerializeObject(columns[x]
                                                                         .GetValue(obj)));

            return(table.Add(values));
        }
 private static void CommonParse(NDataReader dr, ITable table, NDataGenericLoader.DataCtor ctor)
 {
     if (!dr.BeginSection("[Table]"))
     {
         return;
     }
     foreach (NDataReader.Row data in dr)
     {
         ISetRow setRow = ctor();
         setRow.SetData(data);
         table.Add(setRow);
     }
 }
예제 #8
0
        public static Row Put <T>(this ITable table, T obj) where T : DataModel
        {
            var type    = typeof(T);
            var columns = type.GetProperties().ToDictionary(
                x =>
                x.Name.ToNamePreservation(),
                x => x);
            var values = columns.Keys.Select(x =>
                                             JsonConvert.SerializeObject(columns.Values.FirstOrDefault(y =>
                                                                                                       y.Name.ToNamePreservation() == x)
                                                                         .GetValue(obj)));
            var ret = table.Add(values);

            obj.Row = ret;
            return(ret);
        }
예제 #9
0
        private void AddRecordAsRow(ITable table, IRecord record)
        {
            object[] row = new object[table.Schema.Fields.Count];

            // loop threw all table fields and try to get the value from the record
            for (int i = 0; i < table.Schema.Fields.Count; i++)
            {
                string fieldName = table.Schema.Fields[i].Name;

                if (record.DoesFieldExists(fieldName) && record.Data.ContainsKey(fieldName))
                {
                    row[i] = record.Data[fieldName].Value;
                }
            }

            table.Add(row);
        }
예제 #10
0
 /// <summary>
 /// Adds a row to a table with the given values.
 /// </summary>
 /// <param name="table">the target table</param>
 /// <param name="values">the values to add</param>
 /// <returns></returns>
 public static Row Add(this ITable table, params string[] values)
 {
     return(table.Add(values));
 }
예제 #11
0
 public void setup()
 {
     table.Clear();
     table.Add(e1);
     table.Add(e2);
 }
예제 #12
0
 public Result?Add(Number number)
 {
     return(table.Add(number));
 }
예제 #13
0
        public static void AddNewLocalizationKey()
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                Debug.LogWarning("No internet connection - cannot add new localization key!");
                return;
            }

            CheckAndUpdateCurrentDatabaseSource(() => {
                CommandPaletteArgumentWindow.Show("Set Localization Key", (localizationKey) => {
                    CultureInfo masterCulture = EditorLocalizationConfiguration.GetMasterCulture();
                    CommandPaletteArgumentWindow.Show(string.Format("Set {0} Text", masterCulture.EnglishName), (masterText) => {
                        ITable <GLocalizationMasterRowData> localizationMasterTable = currentDatabaseSource_.LoadLocalizationMasterTable();
                        if (localizationMasterTable == null)
                        {
                            return;
                        }

                        ITable <GLocalizationRowData> localizationEntryTable = currentDatabaseSource_.LoadLocalizationEntriesTable();
                        if (localizationEntryTable == null)
                        {
                            return;
                        }

                        GoogleTranslate translation = GoogleTranslateSource.FindAndCreate();
                        if (translation == null)
                        {
                            return;
                        }

                        bool existingKey = localizationMasterTable.FindAll().Any(r => r.Element.Key == localizationKey);
                        if (existingKey)
                        {
                            Debug.LogWarning("Found existing row for localization key: " + localizationKey + " cannot adding as new!");
                            return;
                        }

                        var rowData = new GLocalizationMasterRowData();
                        rowData.Key = localizationKey;
                        localizationMasterTable.Add(rowData);

                        // NOTE (darren): we don't delete pre-existing entries in case of data loss
                        bool duplicateKey = localizationEntryTable.FindAll().Any(r => r.Element.Key == localizationKey);
                        if (duplicateKey)
                        {
                            Debug.LogWarning("Found pre-existing rows for localization key: " + localizationKey + ", please verify that they are correct - will not be deleted!");
                        }

                        foreach (var supportedCulture in EditorLocalizationConfiguration.GetSupportedCultures())
                        {
                            bool isMasterText = supportedCulture.Equals(masterCulture);
                            string translatedText;
                            if (isMasterText)
                            {
                                translatedText = masterText;
                            }
                            else
                            {
                                translatedText = translation.Translate(masterText, masterCulture.TwoLetterISOLanguageName, supportedCulture.TwoLetterISOLanguageName);
                            }

                            var entryRowData           = new GLocalizationRowData();
                            entryRowData.Key           = localizationKey;
                            entryRowData.LanguageCode  = supportedCulture.Name;
                            entryRowData.LocalizedText = translatedText;
                            entryRowData.SetNeedsUpdating(!isMasterText);
                            localizationEntryTable.Add(entryRowData);
                        }

                        // Cache bundled localization tables after new row
                        LocalizationOfflineCache.CacheBundledLocalizationTables();
                        // Rebake fonts after new translations
                        TMPLocalization.DownloadAndBakeAllUsedLocalizationCharactersIntoFonts();
                        Debug.Log("Finished adding new key: " + localizationKey + " to: " + currentDatabaseSource_.TableKey + "!");
                    });
                });
            });
        }