protected async override void OnStart() { base.OnStart(); recentHistory = DBAccess.Database.RecentHistory.Result; if (recentHistory != null) { RecentProces = recentHistory.Process; RecentLocation = recentHistory.Location; RecentEntryType = recentHistory.EntryType; } else { recentHistory = new RecentHistory(); } BitmapFactory.Options options = new BitmapFactory.Options(); options.InSampleSize = 4; Bitmap bitmap = BitmapFactory.DecodeByteArray(bitopiApplication.User.EmpImage, 0, bitopiApplication.User.EmpImage.Length, options); ivUser.SetImageBitmap(bitmap); LoadCombo(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UserId"] != null) { RecentHistory.Visible = true; currentUserId.Text = Session["UserId"].ToString(); List <Item2> items = null; string conString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString; SqlConnection con = new SqlConnection(conString); SqlCommand com = new SqlCommand("SELECT TOP 20 i.ItemId, ItemName, ItemDesc, ContentType, Image, Category, i.CreatedOn, UserName, IsActive, i.UserId, 1 AS Preference, MAX(r.CreatedOn) FROM ExchangeDB..RecentHistory r JOIN ExchangeDB..Users u ON u.UserId = r.UserId JOIN ExchangeDB..Item i ON i.ItemId = r.ItemId WHERE r.UserId = @UserId AND i.IsActive = 1 GROUP BY i.ItemId, ItemName, ItemDesc, ContentType, Image, Category, i.CreatedOn, UserName, IsActive, i.UserId Order by MAX(r.CreatedOn) Desc", con); com.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(Session["UserId"]); con.Open(); var lDataAdapter = new SqlDataAdapter(com); var lDataSet = new DataSet(); lDataAdapter.Fill(lDataSet); if (lDataSet.Tables[0].Rows.Count == 0) { con.Close(); } else { items = lDataSet.Tables[0].AsEnumerable().Select(row => new Item2(row, Session["UserId"] == null ? 0 : Convert.ToInt32(Session["UserId"]))).ToList(); con.Close(); } RecentHistory.DataSource = items; RecentHistory.DataBind(); } } }
public int UpdateRecentHistory(RecentHistory recentHistory) { var history = base.GetEntity <RecentHistory>(MainDbPath, getrecentHistoryByDOCId, recentHistory.Email, recentHistory.ServiceCode, recentHistory.BookId, recentHistory.DocID); if (history != null) {//update lastReadDate recentHistory.RowId = history.RowId; return(base.Update <RecentHistory>(base.MainDbPath, recentHistory)); } return(base.Insert <RecentHistory>(base.MainDbPath, recentHistory)); }
public async void UpdateRecentHistoryTest() { IRecentHistoryAccess recentHistoryAccess = new RecentHistoryAccess(); List <Task> taskList = new List <Task>(); for (int i = 0; i < 500; i++) { Task <int> task = new Task <int>(() => { RecentHistory recentHistory = new RecentHistory { BookId = 1000, ColorPrimary = "ColorPrimary", Email = "*****@*****.**", DocID = "DocID", ServiceCode = "AU", DlBookTitle = "Family Law", LastReadDate = DateTime.Now, TOCTitle = "Judicature Modernisation Bill" }; return(recentHistoryAccess.UpdateRecentHistory(recentHistory)); }); task.Start(); taskList.Add(task); } try { await Task.WhenAll(taskList); Console.WriteLine("ds"); } catch (Exception) { throw; } //recentHistory.DlBookTitle = "DlBookTitle"; //recentHistoryAccess.UpdateRecentHistory(recentHistory); //var recentHistoryUpdated = recentHistoryAccess.GetRecentHistory(recentHistory.Email, recentHistory.CountryCode, 1000); //Assert.IsTrue(recentHistoryUpdated.FirstOrDefault().DlBookTitle == recentHistory.DlBookTitle); }
public int DeleteRecentHistory(RecentHistory recentHistory) { return(base.DeleteEntity(base.MainDbPath, recentHistory)); }