Example #1
0
        public void UpdateDetails(IBaseDB baseDB, articleContent content, ICollection <articleComment> comments)
        {
            var articleContent = baseDB.Table <articleContent>().FirstOrDefault(x => x.id == content.id);

            if (articleContent == null)
            {
                baseDB.Set <articleContent>().Add(content);
            }
            else
            {
                baseDB.Entry <articleContent>(content).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            }

            foreach (var item in comments)
            {
                var articleComment = baseDB.Table <articleComment>().FirstOrDefault(x => x.id == item.id);
                if (articleComment == null)
                {
                    baseDB.Set <articleComment>().Add(articleComment);
                }
                else
                {
                    baseDB.Entry <articleComment>(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                }
            }
        }
        private string name;      //backing fields for Name

        #endregion

        #region Constructors

        /// <summary>
        /// Constructor - used when you don't already have base information
        /// </summary>
        /// <param name="id">The unique ID for the base</param>
        /// <param name="database">An object that provides a method to update/retrieve information from the database</param>
        public Base(int id)
        {
            //assign fields
            ID            = id;
            this.database = Tools.BaseLoctionDB;

            //retrieve info from the database
            database.GetBaseInfo(id, out officeNo, out name, out address);
        }
        /// <summary>
        /// Constructor - used when you already have base information
        /// </summary>
        /// <param name="id"></param>
        /// <param name="officeNo"></param>
        /// <param name="address"></param>
        /// <param name="name"></param>
        public Base(int id, string officeNo, Address address, string name)
        {
            //assign fields
            ID            = id;
            this.officeNo = officeNo;
            this.address  = address;
            this.name     = name;

            //create the database object
            string dbName   = Properties.Settings.Default.DatabaseName;
            string ip       = Properties.Settings.Default.ServerIP;
            string username = Properties.Settings.Default.Username;
            string password = Properties.Settings.Default.Password;

            this.database = new MySqlBaseLocationConnector(dbName, ip, username, password);
        }
Example #4
0
        private void CreateCheckPoint()
        {
            // Do not use compare
            Dictionary <byte[], byte[]> batch = new Dictionary <byte[], byte[]>();

            foreach (RevokingDBWithCaching db in this.databases)
            {
                ISnapshot head = db.GetHead();
                if (Snapshot.IsRoot(head))
                {
                    return;
                }

                string    db_name = db.DBName;
                ISnapshot next    = head.GetRoot();
                for (int i = 0; i < this.flush_count; ++i)
                {
                    next = next.GetNext();
                    Snapshot snapshot = (Snapshot)next;
                    IBaseDB <Common.Key, Common.Value> key_value_db = snapshot.DB;
                    foreach (KeyValuePair <Common.Key, Common.Value> pair in key_value_db)
                    {
                        byte[] name = SimpleEncode(db_name);
                        byte[] key  = new byte[name.Length + pair.Key.Data.Length];
                        Array.Copy(name, 0, key, 0, name.Length);
                        Array.Copy(pair.Key.Data, 0, key, name.Length, pair.Key.Data.Length);
                        batch.Add(key, pair.Value.Encode());
                    }
                }
            }

            // TODO : temp 계속 저장만 하는지 확인해야봐야함
            CheckTempStore.Instance.DBSource.UpdateByBatch(batch, new WriteOptions()
            {
                Sync = Args.Instance.Storage.Sync
            });
        }
Example #5
0
 public EFCoreUnitOfWork(IBaseDB context)
 {
     this.context = context;
 }
Example #6
0
 public Trie(IBaseDB <byte[], BytesCapsule> cache, byte[] root)
 {
     this.cache = cache;
     SetRoot(root);
 }
Example #7
0
 public Trie(IBaseDB <byte[], BytesCapsule> cache) : this(cache, null)
 {
 }
Example #8
0
 public void LoadDetails(IBaseDB baseDB, articleInfo articleinfo)
 {
     articleinfo.article_content  = baseDB.Table <articleContent>().FirstOrDefault(x => x.article_info_id == articleinfo.id);
     articleinfo.article_comments = baseDB.Table <articleComment>().Where(x => x.article_info_id == articleinfo.id).ToList();
 }
Example #9
0
 public ArticleInfoRepository(IBaseDB baseDB, IMapper mapper)
 {
     _baseDB = baseDB;
     _mapper = mapper;
 }