Esempio n. 1
0
        internal static BaseHistoryRecord Map(HistoryEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }

            switch (entity.Type)
            {
            case HistoryType.CashIn:
                return(Mapper.Map <Cashin>(entity));

            case HistoryType.CashOut:
                return(Mapper.Map <Cashout>(entity));

            case HistoryType.Trade:
                return(Mapper.Map <Trade>(entity));

            case HistoryType.OrderEvent:
                return(Mapper.Map <OrderEvent>(entity));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 2
0
        private void SetNode(HistoryEntity e)
        {
            switch (e.MainTabs)
            {
            case 0:
                docsUserControl1.DocsTreeList.FocusedNode = docsUserControl1.DocsTreeList.FindNodeByFieldValue("FunId", e.FunId);
                break;

            case 1:
                manufacturingUserControl1.DocsTreeList.FocusedNode = manufacturingUserControl1.DocsTreeList.FindNodeByFieldValue("FunId", e.FunId);
                break;

            case 2:
                whUserControl.WHTreeList.FocusedNode = whUserControl.WHTreeList.FindNodeByFieldValue("FunId", e.FunId);
                break;

            case 3:
                financesUserControl1.FinancesTreeList.FocusedNode = financesUserControl1.FinancesTreeList.FindNodeByFieldValue("FunId", e.FunId);
                break;

            case 5:
                DirUserControl.DirTreeList.FocusedNode = DirUserControl.DirTreeList.FindNodeByFieldValue("FunId", e.FunId);
                break;

            case 6:
                serviceUserControl1.DirTreeList.FocusedNode = serviceUserControl1.DirTreeList.FindNodeByFieldValue("FunId", e.FunId);
                break;
            }
        }
    public void WriteData(List <AppDataManager.DataDesc> data)
    {
        LocalDb _HistoryDB = new LocalDb("TextHistory");

        foreach (TextDataManager.TextDataDesc d in data)
        {
            string temp = "False";
            if (d.sentByPlayer)
            {
                temp = "True";
            }

            System.Data.IDataReader reader = _HistoryDB.getLatestID("TextHistory");
            int TempID = 0;
            while (reader.Read())
            {
                TempID = int.Parse(reader[0].ToString());
            }
            TempID += 1;

            HistoryEntity history = new HistoryEntity(TempID.ToString(), d.situationId.ToString(), temp, d.sender, d.message);
            _HistoryDB.appendTableFromBottom("TextHistory", history);
        }

        _HistoryDB.close();
    }
    public List <AppDataManager.DataDesc> GetHistoryUpdateSpeaker(string length, string sender)
    {
        LocalDb _HistoryDB = new LocalDb("TextHistory");

        //List<TextDataManager.TextDataDesc> FetchedData = new List<TextDataManager.TextDataDesc>();

        List <AppDataManager.DataDesc> FetchedData = new List <AppDataManager.DataDesc>();


        System.Data.IDataReader reader = _HistoryDB.getHistDataUpdate(int.Parse(length), sender);
        while (reader.Read())
        {
            HistoryEntity entity = new HistoryEntity(reader[0].ToString(),
                                                     reader[1].ToString(),
                                                     reader[2].ToString(),
                                                     reader[3].ToString(),
                                                     reader[4].ToString());

            FetchedData.Add(new TextDataManager.TextDataDesc(int.Parse(entity._id), entity._Speaker, entity._Content, entity._isPlayer, int.Parse(entity._sitID)));
        }

        _HistoryDB.close();

        return(FetchedData);
    }
Esempio n. 5
0
        public IList <HistoryEntity> GetItems()
        {
            IList <HistoryEntity> items = new List <HistoryEntity>();
            string           sqlSelect  = "SELECT * FROM " + DataAccess.TABLE_NAME_HISTORY;
            SQLiteDataReader dr         = SqliteHelper.ExecuteReader(DataAccess.ConnectionStringProfile, CommandType.Text, sqlSelect, null);

            while (dr.Read())
            {
                if (dr.IsDBNull(1))
                {
                    continue;
                }
                HistoryEntity item = new HistoryEntity();
                item.ID      = dr.GetInt32(0);
                item.Path    = dr.GetString(1);
                item.Name    = dr.GetString(2);
                item.Star    = dr.GetInt32(3);
                item.Comment = dr.GetString(4);
                string   strCategories = dr.GetString(5);
                string[] arrayCategory = strCategories.Split(new char[] { ';' });
                for (int i = 0; i < arrayCategory.Length; i++)
                {
                    if (string.IsNullOrEmpty(arrayCategory[i]))
                    {
                        continue;
                    }
                    item.CategoryIDs.Add(Convert.ToInt32(arrayCategory[i]));
                }
                item.IsDeleted = dr.GetInt32(6) == 1 ? true : false;
                item.LibraryID = dr.GetInt32(7);
                items.Add(item);
            }
            dr.Close();
            return(items);
        }
        public static UIHistoryEntity Create(HistoryEntity historyEntity)
        {
            if (historyEntity.IsNull())
            {
                throw new ArgumentNullException("Create UIHistoryEntity exception");
            }

            UIHistoryEntity uiHistoryEntity = new UIHistoryEntity()
            {
                ID        = historyEntity.ID,
                Path      = historyEntity.Path,
                Name      = historyEntity.Name,
                Star      = historyEntity.Star,
                Comment   = historyEntity.Comment,
                IsDeleted = historyEntity.IsDeleted,
                LibraryID = historyEntity.LibraryID
            };

            foreach (int cid in historyEntity.CategoryIDs)
            {
                uiHistoryEntity.CategoryIDs.Add(cid);
            }

            return(uiHistoryEntity);
        }
Esempio n. 7
0
        private void WriteToDBByScannedResult(IDictionary <LibraryItemEntity, IList <DirectoryInfo> > result)
        {
            IList <HistoryEntity> addHistoryList    = new List <HistoryEntity>();
            IList <HistoryEntity> removeHistoryList = new List <HistoryEntity>();
            IList <DirectoryInfo> scannedResult     = new List <DirectoryInfo>();

            foreach (KeyValuePair <LibraryItemEntity, IList <DirectoryInfo> > pair in result)
            {
                foreach (DirectoryInfo scannedItem in pair.Value)
                {
                    string         defaultCategoryName = scannedItem.Parent.Name;
                    CategoryEntity category            = Categories.FirstOrDefault(item => 0 == string.Compare(defaultCategoryName, item.Name, true));
                    if (category.IsNull())
                    {
                        category = new CategoryEntity()
                        {
                            ID = -1, Name = defaultCategoryName
                        };
                        if (1 == DBHelper.AddCategories(new List <CategoryEntity>()
                        {
                            category
                        }))
                        {
                            Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
                            {
                                categories.Add(category);
                            }));
                        }
                    }

                    HistoryEntity history = new HistoryEntity()
                    {
                        IsDeleted = false, Name = scannedItem.Name, Path = scannedItem.FullName, Comment = string.Empty, LibraryID = pair.Key.ID
                    };
                    if (!category.IsNull())
                    {
                        history.CategoryIDs.Add(category.ID);
                    }
                    if (Histories.FirstOrDefault(item => 0 == string.Compare(item.Path, history.Path, true)).IsNull())
                    {
                        addHistoryList.Add(history);
                    }

                    scannedResult.Add(scannedItem);
                }
            }
            DBHelper.AddHistoryItems(addHistoryList);

            foreach (HistoryEntity history in this.Histories)
            {
                //if (scannedResult.FirstOrDefault(item => 0 == string.Compare(item.FullName, history.Path, true)).IsNull())
                //    removeHistoryList.Add(history);
                if (!Directory.Exists(history.Path))
                {
                    removeHistoryList.Add(history);
                }
            }
            DBHelper.DeleteHistoryItems(removeHistoryList);
        }
 public bool Contains(HistoryEntity entityToCheck)
 {
     return(this.dbContext.TransactionHistory
            .Any(t => t.CustomerID == entityToCheck.CustomerID &&
                 t.SellerID == entityToCheck.SellerID &&
                 t.StockID == entityToCheck.StockID &&
                 t.StockAmount == entityToCheck.StockAmount &&
                 t.TransactionCost == entityToCheck.TransactionCost));
 }
Esempio n. 9
0
        public void getHistoryTest()
        {
            var userRepositoryMock = new UserRepositoryMock();
            var viewUser           = new ViewUser(userRepositoryMock);

            var returnObject = viewUser.getHistory(0);
            var expected     = new HistoryEntity(0, 0);

            Assert.AreEqual(expected.GetType(), returnObject.GetType());
        }
Esempio n. 10
0
        public bool CheckAccount(int accountId, int examId)
        {
            HistoryEntity history = _context.Histories.FirstOrDefault(c => c.AccountId == accountId && c.ExamId == examId);

            if (history == null)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 11
0
 public void Save(HistoryEntity entity)
 {
     try
     {
         service.Save(entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 12
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, HistoryEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ReturnObject updateHistory(int userId, HistoryEntity history)
        {
            if (_context.HistoryModel.Where(item => item.UserId == history.UserId).Count() < 1)
            {
                return(new ReturnObject(false, "History not found"));
            }
            var oldHistory = _context.HistoryModel.Where(item => item.UserId == history.UserId).FirstOrDefault();

            oldHistory.NumberOfPenalties = history.NumberOfPenalties;
            oldHistory.PlayedGames       = history.PlayedGames;
            return(new ReturnObject(true, "History updated"));
        }
Esempio n. 14
0
 public ReturnObject updateHistory(int userId, HistoryEntity history)
 {
     try
     {
         userRepository.updateHistory(userId, history);
         return(new ReturnObject(true, "History Updated."));
     }
     catch (Exception e)
     {
         return(new ReturnObject(false, e.Message));
     }
 }
        public async Task <int> AddLikeHistoryAsync(HistoryEntity data, Guid userId)
        {
            data.UserGuid = userId;
            var result   = _context.AddAsync(data);
            var affected = await _context.SaveChangesAsync();

            if (affected == 0)
            {
                throw new InvalidOperationException("Could not create History.");
            }

            return(result.Id);
        }
        public void Serializer()
        {
            HistoryEntity historyEntity = new HistoryEntity();

            XmlSerializer formatter = new XmlSerializer(typeof(List <HistoryCodingEntity>));

            using (FileStream fs = new FileStream("history.xml", FileMode.OpenOrCreate))
            {
                formatter.Serialize(fs, historyEntity.HistoryCodingEntity);
            }

            Decode();
        }
Esempio n. 17
0
        public async Task <bool> AddAsync(HistoryEntity historyEntity)
        {
            var dbHistoryEntity = await GetByUserIdAndMovieId(historyEntity.PartitionKey, historyEntity.RowKey);

            if (dbHistoryEntity != null)
            {
                return(await Task.FromResult(false));
            }
            var insertOperation = TableOperation.Insert(historyEntity);
            var table           = GetTable(TableName, _storageConnectionString);
            await table.ExecuteAsync(insertOperation);

            return(await Task.FromResult(true));
        }
Esempio n. 18
0
        private void WriteToHistory(TransactionInfo args, decimal fullPrice)
        {
            var entityToAdd = new HistoryEntity()
            {
                BuyerId          = args.BuyerId,
                SellerId         = args.SellerId,
                QuantityOfStocks = args.QuantityOfStocks,
                TypeOfStock      = args.TypeOfStock,
                FullPrice        = fullPrice
            };

            this.historyTableRepository.Add(entityToAdd);
            this.historyTableRepository.SaveChanges();
            logger.Info($"History record {entityToAdd.Id} of current transaction has been created");
        }
Esempio n. 19
0
        public void SaveHistory(BuyArguments args)
        {
            var stockInSaleHistory = new HistoryEntity()
            {
                CreateAt   = DateTime.Now,
                SellerID   = args.SellerID,
                CustomerID = args.CustomerID,
                StockID    = args.StockID,
                StockCount = args.StockCount,
                TotalPrice = args.StockCount * args.PricePerItem
            };

            this.historyTableRepository.Add(stockInSaleHistory);
            this.historyTableRepository.SaveChanges();
        }
Esempio n. 20
0
        public string createHistory(HistoryEntity historyEntity)
        {
            using (var scope = new TransactionScope())
            {
                Mapper.Initialize(x => x.CreateMap <HistoryEntity, history>());
                var history = Mapper.Map <HistoryEntity, history>(historyEntity);

                if (new DeliverSystem(history).deliver() == "haha")
                {
                    _uow.HistoryRepository.Insert(history);
                }
                _uow.Commit();
                scope.Complete();
                return("success");
            }
        }
Esempio n. 21
0
        public static async Task <int> Create(HistoryEntity history)
        {
            var query = "INSERT INTO history_view(student_id,work_id) values(@student_id,@work_id)";

            using var connection = DatabaseConnector.Connect();
            await connection.OpenAsync();

            using var command   = connection.CreateCommand();
            command.CommandText = query;

            command.Parameters.AddWithValue("@student_id", history.student_id);
            command.Parameters.AddWithValue("@work_id", history.work_id);
            //command.Parameters.AddWithValue("@view_time", history.view_time);
            await command.ExecuteNonQueryAsync();

            return((int)command.LastInsertedId);
        }
Esempio n. 22
0
        /// <summary>
        /// Adds entry into TransactionHistoryTable.
        /// </summary>
        /// <param name="tradeInfo">Instance with trade info.</param>
        private void AddEntryToTransactionHistoryTable(TradeInfo tradeInfo)
        {
            decimal stockCost        = this.stockTableRepository.GetCost(tradeInfo.Stock_ID);
            decimal transactionPrice = stockCost * tradeInfo.Amount;
            string  stockType        = this.stockTableRepository.GetType(tradeInfo.Stock_ID);

            HistoryEntity historyEntity = new HistoryEntity()
            {
                CustomerID      = tradeInfo.Customer_ID,
                StockAmount     = tradeInfo.Amount,
                StockID         = tradeInfo.Stock_ID,
                SellerID        = tradeInfo.Seller_ID,
                TransactionTime = DateTime.Now,
                TransactionCost = transactionPrice,
                StockType       = stockType
            };

            this.transactionHistoryTableRepository.Add(historyEntity);
            this.transactionHistoryTableRepository.SaveChanges();
        }
Esempio n. 23
0
        private IEnumerable <HistoryEntity> GetHistoryEntityBeforeSave()
        {
            ChangeTracker.DetectChanges();

            var historyEntities = new List <HistoryEntity>();

            foreach (var entry in ChangeTracker.Entries <IAuditable>())
            {
                if (entry.State == EntityState.Detached || entry.State == EntityState.Unchanged)
                {
                    continue;
                }
                else
                {
                    var historyEntity = new HistoryEntity();
                    var entityName    = entry.Entity.GetType().Name.Replace("Entity", "");

                    historyEntity.Action = entry.State switch
                    {
                        EntityState.Deleted => $"{nameof(EntityState.Deleted)} {entityName}",
                        EntityState.Added => $"{nameof(EntityState.Added)} {entityName}",
                        EntityState.Modified => $"{nameof(EntityState.Modified)} {entityName}",
                        _ => UNKNOWN,
                    };

                    historyEntity.CreatedAt   = DateTime.UtcNow;
                    historyEntity.FeatureName = GetFeatureNameFromEntry(entry);
                    historyEntity.ProductName = GetProductNameFromEntry(entry);
                    historyEntity.OldValues   = GetOldValues(entry);
                    historyEntity.NewValues   = GetNewValues(entry);

                    historyEntities.Add(historyEntity);
                }
            }

            return(historyEntities);
        }
        public async Task <IActionResult> AddLikeHistory(
            [FromBody] HistoryEntity form)
        {
            var userId = await _userService.GetUserIdAsync(User);

            if (userId == null)
            {
                return(Unauthorized());
            }

            var historyId = await _historyService.AddLikeHistoryAsync(
                form, (Guid)userId);

            if (historyId == 0)
            {
                return(BadRequest(new ApiError(
                                      "An error has ocurred inserting the history")));
            }

            return(Created(
                       "toBeImplemented",
                       new { historyId }
                       ));
        }
 public void Add(HistoryEntity historyEntity)
 {
     this.dbContext.TradeHistory.Add(historyEntity);
 }
Esempio n. 26
0
 public void Add(HistoryEntity entity)
 {
     dbContext.History.Add(entity);
 }
Esempio n. 27
0
 public HistoryModel mapToHistoryFrom(HistoryEntity history)
 {
     return(new HistoryModel(history.Id, history.PlayedGames, history.NumberOfPenalties, history.UserId));
 }
Esempio n. 28
0
 public ActionResult SaveForm(string keyValue, HistoryEntity entity)
 {
     historybll.SaveForm(keyValue, entity);
     return(Success("操作成功。"));
 }
Esempio n. 29
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (SessionManager.User != null)
            {
                if (!SessionManager.User.DoTest)
                {
                    Response.ClearContent();
                    Response.Write(@"
                        <html><head></head><body bgcolor='#cad7f7'>
                            <script>alert('对不起!您没有网络答卷的权限,可能您已经答过试卷');history.go(-1);</script>
                        </body></html>
                    ");
                    Response.End();
                    return;
                }
                UserEntity currentUser = SessionManager.User;
                currentUser.DoTest = false;
                currentUser.Save();

                HistoryEntity history = new HistoryEntity();
                history.HistoryStartTime = DateTime.Now;
                history.HistoryIp = SessionManager.ClientIp;
                history.HistoryUserId = currentUser.UserId;
                history.Save();
                currentHistoryId = history.HistoryId;

                //TempExamineCollection tempExamine = new TempExamineCollection();
                //tempExamine.SchemaName = string.Format("es_{0}_tmp", currentUser.UserId);
                //tempExamine.CreateSchemaHost();
            }
        }
Esempio n. 30
0
 /// <summary>
 /// 写入历史数据到磁盘
 /// </summary>
 /// <param name="file"></param>
 /// <param name="history"></param>
 /// <returns></returns>
 public static bool WriteHistoryToDisk(string file, HistoryEntity history)
 {
     return(WriteObjectToDisk(file, history));
 }
Esempio n. 31
0
            protected override ActionResult DoTask(string data)
            {
                string[] param = StringUtility.Split(data, "%27");
                int historyId = Convert.ToInt32(Request.QueryString["history"]);
                int score = 0;
                int singscore = 0;
                int multiscore = 0;
                int julgscore = 0;

                DefaultEntity defaultEntity = new DefaultEntity();
                defaultEntity.DefaultType = DefaultTypeEnum.SingleSelect;
                defaultEntity.Fill();
                singscore = defaultEntity.DefaultScore;

                defaultEntity.DefaultType = DefaultTypeEnum.MultiSelect;
                defaultEntity.Fill();
                multiscore = defaultEntity.DefaultScore;

                defaultEntity.DefaultType = DefaultTypeEnum.JudgeSelect;
                defaultEntity.Fill();
                julgscore = defaultEntity.DefaultScore;

                foreach (string val in param)
                {
                    string txt = (val ?? string.Empty).Trim();
                    if (string.IsNullOrEmpty(txt))
                        continue;
                    string[] idandanswer = StringUtility.Split(txt, "%22");
                    QuestionEntity entity = new QuestionEntity();
                    entity.QuestionId = Convert.ToInt32(Escape.JsUnEscape(idandanswer[0]));
                    entity.Fill();
                    int itemScore = 0;
                    if (entity.QuestionAnswer.Equals(Escape.JsUnEscape(idandanswer[1])))
                        itemScore = entity.QuestionScore;
                    if (itemScore == 0)
                    {
                        switch (entity.QuestionType)
                        {
                            case QuestionTypeEnum.SingleSelect:
                                itemScore = singscore;
                                break;
                            case QuestionTypeEnum.JudgeSelect:
                                itemScore = julgscore;
                                break;
                            case QuestionTypeEnum.MultiSelect:
                                itemScore = multiscore;
                                break;
                        }
                    }
                    score = score + itemScore;
                }
                HistoryEntity history = new HistoryEntity();
                history.HistoryId = historyId;
                history.Fill();
                history.HistoryEndTime = DateTime.Now;
                history.HistoryScore = score;
                history.Save();

                ActionResult result = new ActionResult();
                result.IsSuccess = true;
                StringBuilder response = new StringBuilder();
                response.Append(string.Format("TmpStr='{0}';", score));
                result.ResponseData = response.ToString();
                return result;
            }
 public async Task <ActionResult <APIReturnObject> > updateHistory(int userId, [FromBody] HistoryEntity history)
 {
     return(await Task.FromResult(_returnBridge.mapToAPIReturnObjectFrom(_userservice.updateHistory(userId, history))));
 }