Ejemplo n.º 1
0
        public int Update(object obj)
        {
            Type          type  = obj.GetType();
            AbstractTable table = GetTable(type);

            return(table.Update(obj));
        }
Ejemplo n.º 2
0
        public int Insert(object obj)
        {
            Type          type  = obj.GetType();
            AbstractTable table = GetTable(type);

            return(table.Insert(obj));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Gets the id of an item that already exists in the database.
        /// </summary>
        /// <typeparam name="T">The type of the BaseModel we're looking for.</typeparam>
        /// <param name="table">The table to use to create the SQL statements.</param>
        /// <param name="name">The name of the item to look for.</param>
        /// <param name="dataAccess">The access to the database.</param>
        /// <returns></returns>
        private static async Task <int> GetExistingId <T>(AbstractTable <T> table, string name, IDataAccess dataAccess) where T : BaseModel
        {
            var parameters = new List <SQLiteParameter>();

            using (var cursor = await dataAccess.ExecuteQueryWithParametersAsync(table.GetIdFromNameSql(new IdentifyingInfo(name: name), ref parameters), parameters))
            {
                if (!Cursor.IsNullOrEmpty(cursor))
                {
                    return(cursor.GetInt(0));
                }

                return(-1);
            }
        }
Ejemplo n.º 4
0
        private void Generate(List <ExcelMap> excelMapList, int type)
        {
            SharedData.AREATYPE = type;

            //过滤数据,建立视图
            foreach (ExcelMap f in excelMapList)
            {
                if ((f.TableListIndex == -1) || (f.FileName() == ""))
                {
                    continue;
                }
                int k = 0;
                k = f.TableListIndex;
                string tableName = f.GetTaleName();
                CreateView(tableName, k);
                SharedData.tableListInDB[k].IsExisted = true;
            }
            //Environment.Exit(0);

            //把所在省和设备类型列表写入数据库中
            SharedData.WriteProvincesToDB();
            SharedData.WriteDeviceTypesToDB();
            int res = SharedData.WriteBaseTypesToDB();

            if (res == -1)
            {
                return;
            }

            //初始化job list
            InitDataCompileJobList();

            for (int i = 0; i < dataCompileJobList.Count; i++)
            {
                AbstractTable tbl = dataCompileJobList[i];
                try
                {
                    tbl.RunJob();
                }
                catch (System.Exception ex)
                {
                    Log.RecordLog("RunJob():\n" + ex.ToString());
                }
            }
            //生成插页
            CreateBlankPageFile();

            //合并word文件
            FileMerge();
        }
Ejemplo n.º 5
0
        public virtual bool RemoveTable(AbstractTable table)
        {
            if (table == null)
            {
                throw new ArgumentNullException(nameof(table));
            }

            if (!_tables.Remove(table))
            {
                return(false);
            }

            TableRemoved(this, table);

            return(true);
        }
Ejemplo n.º 6
0
        public virtual void AddTable(AbstractTable table)
        {
            if (table == null)
            {
                throw new ArgumentNullException(nameof(table));
            }

            if (_tables.Contains(table))
            {
                throw new ArgumentException("Table already contained in tables list.", nameof(table));
            }

            _tables.Add(table);

            TableAdded(this, table);
        }
Ejemplo n.º 7
0
        public IList GetAll(Type type)
        {
            AbstractTable table = GetTable(type);

            return(table.GetAll());
        }
Ejemplo n.º 8
0
 public StatisticsController(IDataAccess dataAccess)
 {
     _dataAccess = dataAccess;
     _albumTable = new AlbumTable();
     _genreTable = new GenreTable();
 }