예제 #1
0
 public ExtractAssociation(IDatabaseAdapter src, IDatabaseAdapter dest, ITableConversionRules rules)
 {
     this.src = src;
     this.dest = dest;
     this.rules = rules;
     this.ExtractedAssociation = new ExtractedAssocation();
 }
예제 #2
0
 public ExtractColumn(IDatabaseAdapter src, IDatabaseAdapter dest, ITableConversionRules rules)
 {
     this.src = src;
     this.dest = dest;
     this.rules = rules;
     this.destGenerator = new SqlGenerator(dest);
     this.ForeignKeyResolver = new ForeignKeyResolver();
 }
예제 #3
0
 public ExtractColumn(IDatabaseAdapter src, IDatabaseAdapter dest, ITableConversionRules rules)
 {
     _src = src;
     _dest = dest;
     _rules = rules;
     _destGenerator = new SqlGenerator(_dest);
     _extractedColumns = new List<ExtractedColumn>();
 }
 public PepinoPhotographerService()
 {
     var containerBuilder = new ContainerBuilder();
     new ConfigureDatabaseWiring().Task(containerBuilder);
     new ConfigureAutomapperMappings().Task(containerBuilder);
     new ConfigurePhotographerDependencies().Task(containerBuilder);
     IContainer container = containerBuilder.Build();
     _photographer = container.Resolve<IPhotographer>();
     _database = container.Resolve<IDatabaseAdapter>();
 }
예제 #5
0
        public SpellMechanic(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellMechanic.dbc");

                int boxIndex = 1;
                main.MechanicType.Items.Add("None");
                MechanicLookup t;
                t.ID            = 0;
                t.offset        = 0;
                t.stringHash    = "None".GetHashCode();
                t.comboBoxIndex = 0;
                Lookups.Add(t);

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var record = Body.RecordMaps[i];

                    uint offset = (uint)record["Name" + (window.GetLanguage() + 1)];
                    if (offset == 0)
                    {
                        continue;
                    }
                    string name = Reader.LookupStringOffset(offset);

                    MechanicLookup temp;
                    temp.ID            = (uint)record["ID"];
                    temp.offset        = offset;
                    temp.stringHash    = name.GetHashCode();
                    temp.comboBoxIndex = boxIndex;
                    Lookups.Add(temp);

                    main.MechanicType.Items.Add(name);

                    ++boxIndex;
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #6
0
        /// <summary>
        /// Initializes default objects required by the snapshot/reset routines
        /// </summary>
        /// <param name="adapter">The database adapter to use. It is responsible for handling all communications with the database</param>
        /// <param name="connectionString">Optional: Allows you to specify the connection string. Defaults to the last connection string found within the app/web.config file</param>
        /// <param name="tables">Optional: Allows you to specify which tables to take a snapshot of. Defaults to null which will force the library to use discovery mode. This will enumerate all non-system tables found within the specified database </param>
        /// <param name="tablePostFix">Optional: Allows you to specify a post fix for the cloned tables. An example: Users could be given the new Users_Snapshot when cloned if the tablePostFix variable was "_Snapshot"</param>
        public DbReverter(IDatabaseAdapter adapter, string connectionString = "", string[] tables = null, string tablePostFix = "")
        {
            if (adapter == null) throw new ArgumentNullException("adapter", "adapter can't be null");

            _adapter = adapter;

            _tables = tables;
            _postFix = (tablePostFix == "" ? DateTime.Now.Hour.ToString("00") + DateTime.Now.Minute.ToString("00") : tablePostFix);
            if(connectionString == "" && ConfigurationManager.ConnectionStrings.Count > 0){
                _connectionString = ConfigurationManager.ConnectionStrings[ConfigurationManager.ConnectionStrings.Count-1].ConnectionString;
            }
        }
예제 #7
0
        public static TableMapper Create(IDatabaseAdapter src, IDatabaseAdapter dest, string srcTableName)
        {
            ITableConversionRules rules;
            switch (srcTableName) {
                case "tblContacts":
                    rules = new AccountConversionRules();
                    break;
                default:
                    throw new Exception(String.Format("Unknown srcTableName {0}", srcTableName));
            }

            return new TableMapper(src, dest, rules);
        }
예제 #8
0
        public JsonResult GetUser(string val)
        {
            IDatabaseAdapter adapter = DatabaseAdapter.Instance();

            try
            {
                return(Json(adapter.GetUserById(new Guid(val))));
            }
            catch (System.Exception e)
            {
                throw new System.ArgumentException("Error, can not get user. " + e);
            }
        }
예제 #9
0
 public VisualKitListEntry(string key, uint visualId, DataRow kitRecord, IDatabaseAdapter adapter)
 {
     Orientation    = Orientation.Horizontal;
     ParentVisualId = visualId;
     KitName        = key;
     KitRecord      = kitRecord;
     _Adapter       = adapter;
     _Attachments   = WoWVersionManager.IsWotlkOrGreaterSelected ?
                      findAttachments(adapter) :
                      new List <VisualEffectListEntry>();
     _Effects = findAllEffects(adapter);
     buildSelf();
 }
예제 #10
0
        public JsonResult GetUserByDeviceId(string deviceId)
        {
            IDatabaseAdapter adapter = DatabaseAdapter.Instance();

            try
            {
                return(Json(adapter.GetUserByDeviceId(deviceId)));
            } catch (Exception e)
            {
                Console.Write("No user found");
                return(Json(Guid.Empty));
            }
        }
예제 #11
0
        public SpellRadius(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellRadius.dbc");

                int boxIndex = 1;
                main.RadiusIndex1.Items.Add("0 - 0");
                main.RadiusIndex2.Items.Add("0 - 0");
                main.RadiusIndex3.Items.Add("0 - 0");
                RadiusLookup t;
                t.ID            = 0;
                t.comboBoxIndex = 0;
                Lookups.Add(t);

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var record = Body.RecordMaps[i];

                    float radius        = (float)record["Radius"];
                    float maximumRadius = (float)record["MaximumRadius"];

                    RadiusLookup temp;
                    temp.ID            = (uint)record["ID"];
                    temp.comboBoxIndex = boxIndex;
                    Lookups.Add(temp);

                    // Some attempt to pad the label better
                    string label = $"{ String.Format("{0,-23}", $"{ radius } - { maximumRadius}") }\t(Radius - MaxRadius)";
                    main.RadiusIndex1.Items.Add(label);
                    main.RadiusIndex2.Items.Add(label);
                    main.RadiusIndex3.Items.Add(label);

                    ++boxIndex;
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #12
0
        public SpellRange(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellRange.dbc");

                int boxIndex = 0;
                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var record = Body.RecordMaps[i];

                    float MinimumRangeHostile = (float)record["MinimumRangeHostile"];
                    float MaximumRangeHostile = (float)record["MaximumRangeHostile"];
                    float MinimumRangeFriend  = (float)record["MinimumRangeFriend"];
                    float MaximumRangeFriend  = (float)record["MaximumRangeFriend"];

                    uint offset = (uint)record["Name" + (window.GetLanguage() + 1)];
                    if (offset == 0)
                    {
                        continue;
                    }
                    string name = Reader.LookupStringOffset(offset);

                    SpellRangeLookup temp;
                    temp.ID            = (uint)record["ID"];
                    temp.comboBoxIndex = boxIndex;
                    temp.RangeString   = MaximumRangeHostile > MaximumRangeFriend?MaximumRangeHostile.ToString() : MaximumRangeFriend.ToString();

                    Lookups.Add(temp);

                    main.Range.Items.Add($"{ name }\nHostile: { MinimumRangeHostile } - { MaximumRangeHostile }\t Friend: { MinimumRangeFriend } - { MaximumRangeFriend }");

                    boxIndex++;
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #13
0
        public DataRepository(IDatabaseAdapter databaseAdapter, IMapper mapper, ITagKindManager tagKindManager)
        {
            Database            = databaseAdapter;
            Mapper              = mapper;
            this.tagKindManager = tagKindManager;

            // Create data providers list to tract instances
            dataProviders = new List <WeakReference <ILazyDataProvider> >();

            // Load last saved clip
            IDbConnection        db         = Database.Connection;
            SqlExpression <Clip> expression = db.From <Clip>().OrderByDescending(clip => clip.Id);

            LastClipContent = db.Single(expression)?.Content;
        }
예제 #14
0
        public SpellRuneCost(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellRuneCost.dbc");

                int boxIndex = 1;
                main.RuneCost.Items.Add(0);
                SpellRuneCostLookup t;
                t.ID            = 0;
                t.comboBoxIndex = 0;
                Lookups.Add(t);

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var record = Body.RecordMaps[i];

                    uint id            = (uint)record["ID"];
                    uint runeCost1     = (uint)record["RuneCost1"];
                    uint runeCost2     = (uint)record["RuneCost2"];
                    uint runeCost3     = (uint)record["RuneCost3"];
                    uint runepowerGain = (uint)record["RunePowerGain"];

                    SpellRuneCostLookup temp;
                    temp.ID            = id;
                    temp.comboBoxIndex = boxIndex;
                    Lookups.Add(temp);

                    main.RuneCost.Items.Add($"Cost [{runeCost1}, {runeCost2}, {runeCost3}] Gain [{ runepowerGain }] ID [{ id }]");

                    ++boxIndex;
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #15
0
        public UserManager(IDatabaseAdapter databaseAdapter, ILogger <UserManager> logger)
        {
            _databaseAdapter = databaseAdapter;
            _logger          = logger;

            _users     = new ConcurrentDictionary <Guid, User>();
            _userNames = new ConcurrentDictionary <string, Guid>();

            _addUserActionHandler    = new AddUserActionHandler(this);
            _removeUserActionHandler = new RemoveUserActionHandler(this);
            _updateUserActionHandler = new UpdateUserActionHandler(this);

            InitializeUsers();

            _logger.LogInformation("UserManager initialized");
        }
예제 #16
0
        public static void InitializeConfig()
        {
            _logger = LogManager.GetCurrentClassLogger();
            IPublicAdapter publicAdapter = new PublicAdapter();

            _databaseAdapter = new DatabaseAdapter(publicAdapter);

            InitializeIndependentConstants();

            if (!Directory.Exists(_configFolderPath))
            {
                FileManager.SafeCreateDirectory(_configFolderPath);
            }

            if (!File.Exists(_configFilePath))
            {
                _isFirstLaunch = true;
                CreateDefaultConfig();
                _serverCertificatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                      CommonConstants.DefaultCertificatesFolderName,
                                                      CommonConstants.DefaultServerPfxCertificateName);
                string defaultCAPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                    CommonConstants.DefaultCertificatesFolderName,
                                                    CommonConstants.DefaultCACrtCertificateName);
                X509Certificate2 cert = new X509Certificate2(defaultCAPath);
                CertificatesProcessor.AddCertificateToTrustedRootCA(cert);
            }

            InitializeDependentConstants();

            if (!Directory.Exists(_caFolderPath))
            {
                FileManager.SafeCreateDirectory(_caFolderPath);
                CreateCertificateAuthority();
            }

            _logger.Info("Config initialized, config file created/exists");

            if (_isFirstLaunch)
            {
                FileManager.SafeCopy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, CommonConstants.DefaultCertificatesFolderName,
                                                  CommonConstants.DefaultClientCrtCertificateName), Path.Combine(_certificatesFolderPath,
                                                                                                                 CommonConstants.DefaultClientCrtCertificateName));

                _logger.Info("Added default client certificate to certificates folder");
            }
        }
예제 #17
0
        public SpellCastTimes(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellCastTimes.dbc");

                int boxIndex = 0;

                SpellCastTimeLookup t;
                t.ID            = 0;
                t.comboBoxIndex = 0;
                Lookups.Add(t);

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var record = Body.RecordMaps[i];

                    Label castTime = new Label();
                    castTime.Content = record["CastingTime"].ToString() + "\t";
                    castTime.ToolTip = "CastTime\t\t" + record["CastingTime"] + "\n" +
                                       "PerLevel\t\t" + record["CastingTimePerLevel"] + "\n" +
                                       "MinimumCastingTime\t" + record["MinimumCastingTime"] + "\n";

                    SpellCastTimeLookup temp;
                    temp.ID            = (uint)record["ID"];
                    temp.comboBoxIndex = boxIndex;
                    Lookups.Add(temp);

                    main.CastTime.Items.Add(castTime);
                    boxIndex++;
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #18
0
        public ItemClass(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/ItemClass.dbc");

                Lookups = new List <ItemClassLookup>();

                int boxIndex = 1;
                window.EquippedItemClass.Items.Add("None");
                ItemClassLookup noneLookup;
                noneLookup.ID            = -1;
                noneLookup.comboBoxIndex = 0;
                Lookups.Add(noneLookup);

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var  record = Body.RecordMaps[i];
                    int  locale = window.GetLanguage() + 1;
                    uint offset = (uint)record["Name" + locale];
                    if (offset == 0)
                    {
                        continue;
                    }
                    ItemClassLookup temp;
                    temp.ID            = int.Parse(record["ID"].ToString());
                    temp.comboBoxIndex = boxIndex;
                    window.EquippedItemClass.Items.Add(Reader.LookupStringOffset(offset));
                    Lookups.Add(temp);
                    boxIndex++;
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
        public SpellDescriptionVariables(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellDescriptionVariables.dbc");

                int boxIndex = 1;
                main.SpellDescriptionVariables.Items.Add(0);
                SpellDescriptionVariablesLookup t;
                t.ID            = 0;
                t.comboBoxIndex = 0;
                Lookups.Add(t);

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var    record      = Body.RecordMaps[i];
                    uint   id          = (uint)record["ID"];
                    uint   offset      = (uint)record["Formula"];
                    string description = offset == 0 ? "" : Reader.LookupStringOffset(offset);

                    SpellDescriptionVariablesLookup temp;
                    temp.ID            = id;
                    temp.comboBoxIndex = boxIndex;
                    Lookups.Add(temp);
                    Label label = new Label();
                    label.Content = id + ": " + (description.Length <= 30 ? description : (description.Substring(0, 29) + "..."));
                    label.ToolTip = id + ": " + description;
                    main.SpellDescriptionVariables.Items.Add(label);

                    boxIndex++;
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #20
0
 /**
  * Returns the number of rows in the database for the given binding/table name.
  *
  * Returns -1 if an exception is raised, most likely because the table does not exist.
  *
  * A better way to query for the table existing would be to query the performance_schema,
  * but this requires more permissions for a MySQL user.
  */
 public int GetNumRowsInTable(IDatabaseAdapter adapter)
 {
     try
     {
         var table = adapter.Query("SELECT COUNT(*) FROM " + Name);
         if (table.Rows.Count == 1)
         {
             return(int.Parse(table.Rows[0][0].ToString()));
         }
         return(0);
     }
     catch (Exception e)
     {
         Console.WriteLine("WARNING: ImportExportWindow triggered: " + e.Message);
         return(-1);
     }
 }
 public MonitoringCore(IDatabaseAdapter databaseAdapter, IUserManager userManager, IBarSensorsStorage barsStorage,
                       IProductManager productManager, IConfigurationProvider configurationProvider, IValuesCache valuesVCache,
                       IConverter converter, ILogger <MonitoringCore> logger)
 {
     _logger          = logger;
     _databaseAdapter = databaseAdapter;
     _barsStorage     = barsStorage;
     _barsStorage.IncompleteBarOutdated += BarsStorage_IncompleteBarOutdated;
     _certificateManager    = new CertificateManager();
     _userManager           = userManager;
     _queueManager          = new MonitoringQueueManager();
     _productManager        = productManager;
     _configurationProvider = configurationProvider;
     _valuesCache           = valuesVCache;
     _converter             = converter;
     FillValuesCache();
     _logger.LogInformation("Monitoring core initialized");
 }
예제 #22
0
        /// <summary>
        /// 初始化
        /// </summary>
        public void InitData(SqlDBAdapterDataType _sqlType)
        {
            SqlType = _sqlType;
            if (SqlType == SqlDBAdapterDataType.Mysql)
            {
#if UNITY_EDITOR
                databaseAdapter = new HKDatabaseMySqlAdapter();
#endif
            }
            else if (SqlType == SqlDBAdapterDataType.Sqlite)
            {
                databaseAdapter = new HKDatabaseSqliteAdapter();
            }

            if (null != databaseAdapter)
            {
                databaseAdapter.InitData();
            }
        }
예제 #23
0
        public SpellCategory(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellCategory.dbc");

                int boxIndex = 1;
                main.Category.Items.Add(0);
                SpellCategoryLookup t;
                t.ID            = 0;
                t.comboBoxIndex = 0;
                Lookups.Add(t);

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var  record = Body.RecordMaps[i];
                    uint id     = (uint)record["ID"];

                    SpellCategoryLookup temp;
                    temp.ID            = id;
                    temp.comboBoxIndex = boxIndex;
                    Lookups.Add(temp);
                    main.Category.Items.Add(id);

                    boxIndex++;
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #24
0
        /** Costruttore */
        public DbUtil(UserConfigLumen cfg)
        {
            _userConfig = cfg;

            if (cfg.motoreDatabase == MotoreDatabase.SqLite)
            {
                this._databaseAdapter = new SqLiteDatabaseAdapter(cfg);
            }
            else if (cfg.motoreDatabase == MotoreDatabase.MySQL)
            {
                this._databaseAdapter = new MySqlDatabaseAdapter(cfg);
            }
            else
            {
                throw new NotImplementedException("motore database non gestito: " + cfg.motoreDatabase);
            }

            // Inizializzo alcuni aspetti della connection string
            this._databaseAdapter.init();
        }
예제 #25
0
        void FillTables()
        {
            //OleDbDatabaseAdapter inputDatabase = new OleDbDatabaseAdapter();
            string           infilename    = Session["InputFileName"].ToString();
            IDatabaseAdapter inputDatabase = DatabaseAdapterFactory.CreateReader(Path.GetExtension(infilename), CheckBoxEditMode.Checked);

            inputDatabase.FileName = infilename;

            string[] tables = inputDatabase.GetTables();

            CheckBoxListTables.Items.Clear();
            foreach (string tablename in tables)
            {
                CheckBoxListTables.Items.Add(tablename);
            }

            if (CheckBoxListTables.Items.Count == 1)
            {
                CheckBoxListTables.Items[0].Selected = true;
            }
        }
예제 #26
0
        private List <VisualEffectListEntry> findAttachments(IDatabaseAdapter adapter)
        {
            var attachments   = new List <VisualEffectListEntry>();
            var attachResults = adapter.Query("SELECT * FROM spellvisualkitmodelattach WHERE ParentSpellVisualKitId = " + KitRecord["ID"]);

            if (attachResults == null || attachResults.Rows.Count == 0)
            {
                return(attachments);
            }
            foreach (DataRow attachRecord in attachResults.Rows)
            {
                var effectResults = adapter.Query("SELECT * FROM spellvisualeffectname WHERE ID = " + attachRecord["SpellVisualEffectNameId"]);
                if (effectResults == null || effectResults.Rows.Count == 0)
                {
                    continue;
                }
                var effectRecord = effectResults.Rows[0];
                var parentId     = uint.Parse(KitRecord[0].ToString());
                attachments.Add(new VisualEffectListEntry(parentId, ParentVisualId, effectRecord, attachRecord, adapter));
            }
            return(attachments);
        }
예제 #27
0
        public SpellDuration(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellDuration.dbc");

                int boxIndex = 1;
                main.Duration.Items.Add(0);
                SpellDurationLookup t;
                t.ID            = 0;
                t.comboBoxIndex = 0;
                Lookups.Add(t);

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var record = Body.RecordMaps[i];

                    SpellDurationLookup temp;
                    temp.ID            = (uint)record["ID"];
                    temp.comboBoxIndex = boxIndex;
                    Lookups.Add(temp);

                    Label label = new Label();
                    label.Content = $"{ record["BaseDuration"] }ms BaseDuration, { record["PerLevel"] } BaseDuration, { record["MaximumDuration"] }ms MaximumDuration, { temp.ID } ID";
                    main.Duration.Items.Add(label);

                    ++boxIndex;
                }
                Reader.CleanStringsMap();
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #28
0
        public SpellIconDBC(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellIcon.dbc");

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var  record = Body.RecordMaps[i];
                    uint offset = (uint)record["Name"];
                    if (offset == 0)
                    {
                        continue;
                    }
                    string name = Reader.LookupStringOffset(offset);
                    uint   id   = (uint)record["ID"];

                    Icon_DBC_Lookup lookup;
                    lookup.ID     = id;
                    lookup.Offset = offset;
                    lookup.Name   = name;
                    Lookups.Add(lookup);
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                main.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #29
0
        private List <VisualEffectListEntry> findAllEffects(IDatabaseAdapter adapter)
        {
            var effectList = new List <VisualEffectListEntry>();

            foreach (var key in WoWVersionManager.GetInstance().LookupKeyResource().EffectColumnKeys)
            {
                var effectIdStr = KitRecord[key].ToString();
                var success     = uint.TryParse(effectIdStr, out var effectId);
                if (!success || effectId == 0)
                {
                    continue;
                }
                var effectResults = adapter.Query("SELECT * FROM spellvisualeffectname WHERE ID = " + effectId);
                if (effectResults == null || effectResults.Rows.Count == 0)
                {
                    continue;
                }
                var effectRecord = effectResults.Rows[0];
                var parentId     = uint.Parse(KitRecord[0].ToString());
                effectList.Add(new VisualEffectListEntry(key, parentId, ParentVisualId, effectRecord, adapter));
            }
            return(effectList);
        }
예제 #30
0
        public Task ExportToDbc(IDatabaseAdapter adapter, MainWindow.UpdateProgressFunc updateProgress, string IdKey, string bindingName)
        {
            return(Task.Run(() =>
            {
                var binding = BindingManager.GetInstance().FindBinding(bindingName);
                if (binding == null)
                {
                    throw new Exception("Binding not found: " + bindingName);
                }
                var body = new DBCBodyToSerialize();

                var orderClause = "";
                if (binding.OrderOutput)
                {
                    orderClause = binding.Fields.FirstOrDefault(f => f.Name.Equals(IdKey)) != null ? $" ORDER BY `{IdKey}`" : "";
                }

                body.Records = LoadRecords(adapter, bindingName, orderClause, updateProgress);
                var numRows = body.Records.Count();
                if (numRows == 0)
                {
                    throw new Exception("No rows to export");
                }

                Header = new DBCHeader
                {
                    FieldCount = (uint)binding.Fields.Count(),
                    // Magic is always 'WDBC' https://wowdev.wiki/DBC
                    Magic = 1128416343,
                    RecordCount = (uint)numRows,
                    RecordSize = (uint)binding.CalcRecordSize(),
                    StringBlockSize = body.GenerateStringOffsetsMap(binding)
                };

                SaveDbcFile(updateProgress, body, binding);
            }));
        }
예제 #31
0
        public Task ExportToDbc(IDatabaseAdapter adapter, MainWindow.UpdateProgressFunc updateProgress, string IdKey, string bindingName)
        {
            return(Task.Run(() =>
            {
                var binding = BindingManager.GetInstance().FindBinding(bindingName);
                if (binding == null)
                {
                    throw new Exception("Binding not found: " + bindingName);
                }

                var orderClause = binding.Fields.FirstOrDefault(f => f.Name.Equals(IdKey)) != null ? $" ORDER BY `{IdKey}`" : "";
                var rows = adapter.Query(string.Format($"SELECT * FROM `{bindingName}`{orderClause}")).Rows;
                uint numRows = uint.Parse(rows.Count.ToString());
                if (numRows == 0)
                {
                    throw new Exception("No rows to export");
                }

                Header = new DBCHeader();
                Header.FieldCount = (uint)binding.Fields.Count();
                // Magic is always 'WDBC' https://wowdev.wiki/DBC
                Header.Magic = 1128416343;
                Header.RecordCount = numRows;
                Header.RecordSize = (uint)binding.CalcRecordSize();
                Header.StringBlockSize = 0;

                var body = new DBCBodyToSerialize();
                body.Records = new List <Dictionary <string, object> >((int)Header.RecordCount);
                for (int i = 0; i < numRows; ++i)
                {
                    body.Records.Add(ConvertDataRowToDictionary(rows[i]));
                }
                Header.StringBlockSize = body.GenerateStringOffsetsMap(binding);
                SaveDbcFile(updateProgress, body, binding);
            }));
        }
예제 #32
0
 public StoreAdoNetRepository(IDatabaseAdapter databaseAdapter, ILogger <IStoreAdoNetRepository> logger)
 {
     this.databaseAdapter = databaseAdapter;
     this.logger          = logger;
 }
예제 #33
0
 public TableMapper(IDatabaseAdapter src, IDatabaseAdapter dest, ITableConversionRules rules)
 {
     this.src = src;
     this.dest = dest;
     this.rules = rules;
 }
 public SiteContextAdapter(SiteContext siteContext, IDatabaseAdapter databaseAdapter)
 {
     _siteContext = siteContext;
     _databaseAdapter = databaseAdapter;
 }
예제 #35
0
        /// <summary>
        /// Use as Set Up method for all Database tests
        /// </summary>
        public DatabaseAdapterFixture()
        {
            IPublicAdapter publicAdapter = new PublicAdapter();

            DatabaseAdapter = new DatabaseAdapter(publicAdapter);
        }
 public XmlConversionGenerator(IDatabaseAdapter adapter)
 {
     this.adapter = adapter;
 }
예제 #37
0
 public MusicStore(IDatabaseAdapter adapter)
 {
     _adapter = adapter;
 }
 public DataModel(IDatabaseAdapter dataBase)
 {
     m_DataBase = dataBase;
 }
예제 #39
0
        public SpellDifficulty(MainWindow window, IDatabaseAdapter adapter)
        {
            main         = window;
            this.adapter = adapter;

            try
            {
                ReadDBCFile("DBC/SpellDifficulty.dbc");

                int boxIndex = 1;
                main.Difficulty.Items.Add(0);
                SpellDifficultyLookup t;
                t.ID            = 0;
                t.comboBoxIndex = 0;
                Lookups.Add(t);

                for (uint i = 0; i < Header.RecordCount; ++i)
                {
                    var record = Body.RecordMaps[i];

                    /*
                     * Seems to point to other spells, for example:
                     * Id: 6
                     * Normal10Men: 50864 = Omar's Seal of Approval, You have Omar's 10 Man Normal Seal of Approval!
                     * Normal25Men: 69848 = Omar's Seal of Approval, You have Omar's 25 Man Normal Seal of Approval!
                     * Heroic10Men: 69849 = Omar's Seal of Approval, You have Omar's 10 Man Heroic Seal of Approval!
                     * Heroic25Men: 69850 = Omar's Seal of Approval, You have Omar's 25 Man Heroic Seal of Approval!
                     */
                    uint id = (uint)record["ID"];

                    SpellDifficultyLookup temp;
                    temp.ID            = id;
                    temp.comboBoxIndex = boxIndex;
                    Lookups.Add(temp);

                    Label  label   = new Label();
                    string content = id + ": ";


                    string tooltip = "";
                    for (int diffIndex = 1; diffIndex <= 4; ++diffIndex)
                    {
                        var difficulty = record["Difficulties" + diffIndex].ToString();
                        content += difficulty + ", ";
                        tooltip += "[" + difficulty + "] ";
                        var rows = adapter.Query(string.Format("SELECT * FROM `{0}` WHERE `ID` = '{1}' LIMIT 1", "spell", difficulty)).Rows;
                        if (rows.Count > 0)
                        {
                            var    row            = rows[0];
                            string selectedLocale = "";
                            for (int locale = 0; locale < 8; ++locale)
                            {
                                var name = row["SpellName" + locale].ToString();
                                if (name.Length > 0)
                                {
                                    selectedLocale = name;
                                    break;
                                }
                            }
                            tooltip += selectedLocale;
                        }
                        tooltip += "\n";
                    }
                    label.Content = content.Substring(0, content.Length - 2);
                    label.ToolTip = tooltip;

                    main.Difficulty.Items.Add(label);

                    boxIndex++;
                }
                Reader.CleanStringsMap();
                // In this DBC we don't actually need to keep the DBC data now that
                // we have extracted the lookup tables. Nulling it out may help with
                // memory consumption.
                Reader = null;
                Body   = null;
            }
            catch (Exception ex)
            {
                window.HandleErrorMessage(ex.Message);
                return;
            }
        }
예제 #40
0
 public SqlGenerator(IDatabaseAdapter adapter)
     : this(adapter.DbConnection)
 {
 }
 public void Clone(IDatabaseAdapter outDatabase)
 {
     throw new NotImplementedException();
 }
예제 #42
0
 public ISqlGenerator GetSqlGenerator(IDatabaseAdapter adapter)
 {
     return new SqlGenerator(adapter);
 }