/// <summary> /// Set an item into recent history storage. /// </summary> /// <param name="historyType">The type of history.</param> /// <param name="values">The values necessary for loading the object as a dictionary of key value pairs.</param> /// <param name="displayName">The object's display name.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="values"/> is <c>null</c> or empty.</exception> /// <exception cref="ArgumentNullException">Thrown if <paramref name="displayName"/> is <c>null</c> or empty.</exception> public void Set(HistoryType historyType, IDictionary <string, object> values, string displayName) { if (values == null || !values.Any()) { throw new ArgumentNullException("values"); } if (string.IsNullOrEmpty(displayName)) { throw new ArgumentNullException("displayName"); } var key = new KeyModel("History").Add(historyType); values.ForEach(v => key.Add(v.Key.ToLower()).Add(v.Value)); var model = new HistoryModel { HistoryType = historyType, Values = values, DisplayName = displayName, DateAccessed = UserService.DateTime, IsPinned = false, Username = UserService.Username }; UserService.Session.Set(key, model); }
/// <summary> /// 聊天历史记录 /// </summary> /// <returns></returns> public ActionResult ChatHistory(string employeeID) { HistoryModel model = new HistoryModel(); model.EmployeeID = employeeID; return(View(model)); }
private void InsertHistory(HistoryModel model) { _connection.AddRange(model.Records); _connection.AddRange(model.Details); var max = model.Records.Max(f => f.CreateTime); var newRecordID = model.Records.Single().RecordID; var tableName = model.Records.First().Table; var pointer = _connection.HistoryPointers .Where(f => f.TableName == tableName) .FirstOrDefault(); if (pointer == null) { pointer = new HistoryPointer() { TableName = tableName, RecordId = newRecordID }; _connection.HistoryPointers.Add(pointer); } else { pointer.RecordId = newRecordID; } _connection.SaveChanges(); }
public ActionResult Index() { object result; HistoryModelList modelList = new HistoryModelList(); var model = new HistoryModel(); var dataSource = Sitecore.Context.Item; if (dataSource.TemplateID == Templates.Page.ID) { var hackathonItems = dataSource.GetChildren().ToList().Find(x => x.TemplateID.ToString() == Templates.Hackathon.Folder.ToString()).GetChildren(); foreach (Item item in hackathonItems) { if (item != null) { var itemData = item.Fields[Templates.Hackathon.Fields.HackathonData].Value; var data = Sitecore.Context.Database?.GetItem(itemData); model.SetData(data); modelList.ListHistoryMode.Add(model); } } } else { result = dataSource; } return(View("History", model)); }
// GET: Vendor public ActionResult VendorView(HistoryModel model) { DatabaseClass ctx = new DatabaseClass(); int v = int.Parse(Session["VID"].ToString()); //To view the data from database string vnm = (from k in ctx.Logins where k.Uid == v select k.UserName).FirstOrDefault().ToString(); string vname = vnm.ToString(); var req = ctx.Products.Where(i => i.VendorUid == v).Select(i => i); List <HistoryModel> mod = new List <HistoryModel>(); foreach (var i in req) { HistoryModel m = new HistoryModel(); m.VendorName = vname; m.quantity = i.MilkQuantity; m.fat = (from k in ctx.PriceMaintains where k.PriceId == i.FatPercentId select k.FatPercent).FirstOrDefault().ToString(); m.date = i.Date; m.timing = i.Time; m.Price = i.Price; mod.Add(m); } return(View(mod)); }
public List <HistoryModel> GetHistory(List <HistoryModel> _history) { DBCon(); string query = "SELECT BRSTN, ChequeName, MAX(CAST(EndingSerial as DECIMAL(18,0)))EndingSerial FROM captive_database.master_database_" + Main.activeB + " WHERE ChequeName <>'' GROUP BY BRSTN, ChequeName"; // MySqlConnection conn = new MySqlConnection(myConnect); //conn.Open(); MySqlCommand cmd = new MySqlCommand(query, myConnect); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { HistoryModel history = new HistoryModel(); history.BRSTN = !reader.IsDBNull(0) ? reader.GetString(0) : ""; history.ChequeName = !reader.IsDBNull(1) ? reader.GetString(1) : ""; history.MaxEnding = !reader.IsDBNull(2) ? reader.GetInt64(2) : 0; _history.Add(history); } // RemoveDuplicatePreEncoded(); DBClosed(); return(_history); }
public void UpdateHistoryAbscense(HistoryModel model) { using (var connection = new SqlConnection(connectionString)) { var sql = @"INSERT INTO History(StaffID, HistoryDate, HistoryAction, ApplicationType, DateModified, Status, HistoryWho, JobTitle,Destination) VALUES(@StaffID, @HistoryDate, @HistoryAction, @ApplicationType, @DateModified, @Status, @HistoryWho, (Select top JobTitle from Position t2 Join PositionAssign t1 on @StaffID = t1.StaffID Where t2.MPLID=t1.MPLID ), (Select top 1 Destination from Position t2 Join PositionAssign t1 on @StaffID = t1.StaffID Where t2.MPLID=t1.MPLID ))"; try { { connection.Execute(sql, new { model.StaffID, model.HistoryDate, model.HistoryAction, model.ApplicationType, model.DateModified, model.Status, model.HistoryWho, model.MPLID, }); } } catch (Exception e) { Console.Write(e); throw; } } }
public int CreateHistory(HistoryModel history) { //History objHistory = new History(); history.IsActive = true; history.CreatedDate = DateTime.Now.Date; history.UpdatedDate = DateTime.Now.Date; using (PhysioDevEntities db = new PhysioDevEntities()) { try { History obj = new History(); history.CopyProperties(obj); db.Histories.Add(obj); db.SaveChanges(); return(1); } catch (Exception ex) { return(0); throw ex; } } }
public IActionResult Post([FromBody] HistoryModel model) { var history = ModelFactory.Map(model); DataService.AddHistory(history); return(Ok(ModelFactory.Map(history, Url))); }
public IActionResult Search(int?page, HistoryModel dt, string typePage, string sortBy) { switch (typePage.ToUpper()) { case "UNPAID": var PartialUnPaid = PageUnPaid(page, dt, sortBy); return(PartialUnPaid); case "PENDING": var PartialPending = PagePending(page, dt, sortBy); return(PartialPending); case "PAID": var PartialPaid = PagePaid(page, dt, sortBy); return(PartialPaid); case "ORDER COMPLETE": var PartialComplete = PageComplete(page, dt, sortBy); return(PartialComplete); default: var PartialAll = PageAll(page, dt, sortBy); return(PartialAll); } //var response = Helper.RestAPI.SendGetRequest("api/Transaction/GetAllTrans?Today=" + dt.Today.ToShortDateString() + "&FromDate=" + dt.Day.ToShortDateString()); //var result = Helper.HelperCommon.DeserializeObject<SearchTransactionsModel>(response.Content); //if (result == null) //{ // return PartialView("~/Views/History/IndexPartial.cshtml", null); //} //return PartialView("~/Views/History/IndexPartial.cshtml", result); }
public IActionResult PageAll(int?page, HistoryModel dt, string sortBy) { var response = Helper.RestAPI.SendGetRequest($"api/Transaction/GetPageTrans?page={page?.ToString()}&Today={dt.Today.ToShortDateString()}&FromDate={ dt.Day.ToShortDateString()}&sortBy={sortBy}&type=ALL"); var result = Helper.HelperCommon.DeserializeObject <PageModel <TransactionModel> >(response.Content); return(PartialView("~/Views/History/_Search.cshtml", result)); }
public async Task <IActionResult> PutHistoryModel([FromRoute] long id, [FromBody] HistoryModel historyModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != historyModel.HistoryId) { return(BadRequest()); } _context.Entry(historyModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HistoryModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <DeletePositionAssignResult> DeletePositionAssign([FromBody] DeletePositionAssignModel2 model) { UserModel UserName = _userRepo.GetUser(); var res = await _positionAssignRepo.DeletePositionAssign(model.Id, model.StartDate, model.StaffID); var History = new HistoryModel(); // Add to History all actions of relevancy { History.StaffID = model.StaffID; History.MPLID = model.Id; History.HistoryDate = DateTime.UtcNow; History.HistoryAction = "Placement Removed"; History.HistoryLocation = "Some Destínation"; History.ApplicationType = "Assign"; History.DateModified = DateTime.UtcNow; History.Status = "Received"; History.HistoryWho = UserName.UserName; // History.HistoryWho = System.Security.Principal.WindowsIdentity.GetCurrent().Name; }; _historyRepo.UpdateHistory(History); return(res); }
public async Task <IActionResult> UpdatePositionAssign([FromBody] UpdatePositionAssignModel assignation) { var result = await _positionAssignRepo.UpdateAssign(assignation); UserModel UserName = _userRepo.GetUser(); if (result.Ok) { var History = new HistoryModel(); // Add to History all actions of relevancy { History.StaffID = assignation.StaffID; History.MPLID = assignation.MPLID; History.HistoryDate = DateTime.UtcNow; History.HistoryAction = "Updated Placement"; History.HistoryLocation = "Some Destínation"; History.ApplicationType = "Assign"; History.DateModified = DateTime.UtcNow; History.Status = "Received"; History.StartDate = assignation.StartDate; History.Accepted = assignation.Accept; History.EndDate = assignation.EndDate; History.HistoryWho = UserName.UserName; // History.HistoryWho = System.Security.Principal.WindowsIdentity.GetCurrent().Name; }; _historyRepo.UpdateHistory(History); } return(Ok(result)); }
public static int WorkHistoriesADD(HistoryModel temp) { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); string comdText = "dbo.WorkHistoriesADD"; SqlCommand cmd = new SqlCommand(comdText, conn); cmd.CommandType = CommandType.StoredProcedure; SqlCommandBuilder.DeriveParameters(cmd); cmd.Parameters[1].Value = temp.workData; cmd.Parameters[2].Value = temp.stateNumber; cmd.Parameters[3].Value = temp.brand; cmd.Parameters[4].Value = temp.model; cmd.Parameters[5].Value = temp.intermediateMileage; cmd.Parameters[6].Value = temp.carID; cmd.Parameters[7].Value = DBNull.Value; cmd.ExecuteNonQuery(); return(Convert.ToInt32(cmd.Parameters[7].Value)); } }
public ActionResult AggregateReport(HistoryModel model) { ViewBag.Tab = "history"; ViewBag.Submenu = 2; ViewBag.DisplayName = CacheManager.Current.CurrentUser.DisplayName; return(View(model)); }
/// <summary> /// ajax请求设备的历史轨迹 /// </summary> /// <param name="deviceId"></param> /// <param name="start"></param> /// <param name="end"></param> /// <returns></returns> public JsonResult AjaxGetHistory(int deviceId, DateTime start, DateTime end) { Device d = DeviceLogic.GetDeviceById(deviceId); if (d == null) { return(Json(new BaseResult { State = State.NotFind, Message = "未找到该设备" })); } HistoryModel model = DeviceData.GetHistory(d.APIDeviceId ?? 0, start, end, CacheHelper.GetToken(d.UserId)); if (model.State == 0 || model.State == 10) { model.Items.ForEach(p => { p.Time = Convert.ToDateTime(p.Time).AddHours(8).ToString("yyyy-MM-dd HH:mm:ss"); }); return(Json(new { State = State.Success, data = model.Items })); } else { return(Json(new BaseResult { State = State.Falid, Message = model.Message })); } }
public async void RemoveInventory(HistoryModel inventory) { HistoricalSession historicalSession; DataManager dataManager = DataManager.Instance; _inventory.Remove(inventory); inventory.IsUsed = true; // Update cloud historicalSession = new HistoricalSession() { Id = inventory.Id, Type = (byte)inventory.SessionType, SessionStart = inventory.StartTime.ToUniversalTime(), SessionEnd = inventory.EndTime.ToUniversalTime(), LeftBreastStart = inventory.LeftBreastStartTime.ToUniversalTime(), LeftBreastEnd = inventory.LeftBreastEndTime.ToUniversalTime(), RightBreastStart = inventory.RightBreastStartTime.ToUniversalTime(), RightBreastEnd = inventory.RightBreastEndTime.ToUniversalTime(), LeftBreastVolume = inventory.LeftBreastMilkVolume, RightBreastVolume = inventory.RightBreastMilkVolume, TotalVolume = inventory.TotalMilkVolume, Expires = inventory.ExpirationTime.ToUniversalTime(), Available = inventory.IsUsed ? (byte)0 : (byte)1, Preferred = inventory.IsPreferred ? (byte)1 : (byte)0, Notes = inventory.Description, StorageType = (byte)inventory.Storage, ChildId = inventory.ChildID }; await dataManager.AddHistoricalSession(historicalSession); }
private void gvRecent_DoubleClick(object sender, EventArgs e) { try { GridView gridView = sender as GridView; if (null == gridView) { return; } // 选中项目 HistoryModel selectModel = gridView.GetFocusedRow() as HistoryModel; if (null == selectModel) { return; } else { if (null != LoadProjectEvent) { LoadProjectEvent(selectModel.FilePath); } } } catch (Exception ex) { throw ex; } }
public ActionResult ViewHistoryNew(HistoryModel model) { DatabaseClass ctx = new DatabaseClass(); int v = int.Parse(Session["VendId"].ToString()); ViewBag.msg = "History viewed"; //To view the data from database string vnm = (from k in ctx.Logins where k.Uid == v select k.UserName).FirstOrDefault().ToString(); string vname = vnm.ToString(); var req = from i in ctx.Products where i.VendorUid == v select i; List <HistoryModel> mod = new List <HistoryModel>(); foreach (var i in req) { HistoryModel dv = new HistoryModel(); dv.VendorName = vname; dv.quantity = i.MilkQuantity; dv.fat = (from k in ctx.PriceMaintains where k.PriceId == i.FatPercentId select k.FatPercent).FirstOrDefault().ToString(); //dv.fatid = i.FatPercentId; dv.timing = i.Time; dv.date = i.Date; dv.Price = i.Price; mod.Add(dv); } return(View(mod)); }
public IActionResult Index(Advertisement advertisementModel, HistoryModel historyModel) { if (historyModel.startDate.Year == 1) { historyModel.startDate = DateTime.Now.AddDays(-1); historyModel.endDate = DateTime.Now; } using (SqlConnection conn = new SqlConnection(configuration.GetConnectionString("DevConnection"))) { conn.Open(); historyModel.histories = conn.Query <History>($@"SELECT HISTORY.*,AD.AD_TITLE FROM AD_HISTORY HISTORY INNER JOIN ADVERTISEMENT AD ON AD.ID=HISTORY.AD_ID WHERE AD.ID='{advertisementModel.ID}' AND HISTORY.CHECK_DATE BETWEEN @startDate AND @endDate", historyModel).ToList(); } if (historyModel.histories.Count > 0) { ViewData["Title"] = historyModel.histories.First().AD_TITLE; } else { ViewData["Title"] = "No Data"; } return(View(historyModel)); }
public async Task <bool> Logout(Guid token) { UserModel user = await _context.Users.FirstOrDefaultAsync(x => x.Token == token && x.IsActive); if (user != null) { user.IsLoggedIn = false; HistoryModel historyRow = new HistoryModel() { Description = "USER_LOGGED_OUT", UserData = user.Name + " " + user.Surname }; _context.Users.Update(user); _context.History.Add(historyRow); await _context.SaveChangesAsync(); return(true); } else { NullReferenceException ex = new NullReferenceException(); ex.Data.Add("message", "USER_NOT_FOUND"); throw ex; } }
/// <inheritdoc/> public async Task <HistoryModel> InsertHistoryModel(HistoryModel historyModel) { const string restUrl = "https://teststorageserver.azurewebsites.net/api/history"; var uri = new Uri(restUrl); var jsonContent = JsonConvert.SerializeObject(historyModel, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var request = new HttpRequestMessage(HttpMethod.Post, uri) { Content = new StringContent(jsonContent, Encoding.UTF8, "application/json") }; var response = await HttpClient.SendAsync(request); if (!response.IsSuccessStatusCode) { var errorContent = await response.Content.ReadAsStringAsync(); throw new ManagerException((JsonConvert.DeserializeObject <BadRequestModel>(errorContent)).Message); } var responseContent = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <HistoryModel>(responseContent)); }
public async Task SetAccountUnactive(Guid token, string password) { UserModel user = await _context.Users.FirstOrDefaultAsync(x => x.Token == token && x.IsActive); if (user != null) { if (user.Password != password) { InvalidOperationException ex = new InvalidOperationException(); ex.Data.Add("message", "PASSWORD_INCORRECT"); throw ex; } user.IsActive = false; HistoryModel historyRow = new HistoryModel() { Description = "USER_DELETED_ACCOUNT", UserData = user.Name + " " + user.Surname }; _context.Users.Update(user); _context.History.Add(historyRow); await _context.SaveChangesAsync(); } else { NullReferenceException ex = new NullReferenceException(); ex.Data.Add("message", "USER_NOT_FOUND"); throw ex; } }
public ActionResult Comments(int bid) { DatabaseClass ctx = new DatabaseClass(); //To view the data from database // add one model to view data ViewBag.PID = int.Parse(Session["ProjId"].ToString()); ViewBag.RID = int.Parse(Session["RoleId"].ToString()); var req = from i in ctx.CommentDetail where i.BugId == bid select i; List <HistoryModel> model = new List <HistoryModel>(); foreach (var i in req) { HistoryModel dv = new HistoryModel(); dv.BugId = i.BugId; dv.CommentId = i.CommentId; dv.CommentedBy = i.CommentedBy; dv.Comments = i.Comments; dv.CommentedDate = i.CommentDate; model.Add(dv); ctx.SaveChanges(); } ViewBag.bugid = bid; return(View(model)); }
public void History_contains_history() { List <Deposit> deposits = ObjectCreator.Deposists().ToList(); List <Withdraw> withdraws = ObjectCreator.Withdraws().ToList(); List <Transaction> transactions = ObjectCreator.Transactions().ToList(); HistoryModel history = new HistoryModel { Deposits = deposits, Withdraws = withdraws, Transactions = transactions }; bool called = false; var Repo = Mock.Create <BankRepo>(); Mock.Arrange(() => Repo.History(1)).DoInstead(() => { called = true; }).Returns(history); HomeController controller = new HomeController(Repo); ViewResult viewResult = (ViewResult)controller.History(1); var model = viewResult.Model; Assert.IsTrue(called); Assert.IsNotNull(model); }
public void UpdateHistoryModel_ShouldThrow() { var historyElement = new HistoryModel() { Id = 1, UserId = 10, TargetId = 11, Status = StatusConstants.TargetNotHuntedHistory }; var fakeHistoryList = new List <HistoryModel>() { historyElement }.AsQueryable(); var fakeDbSetHistoryElements = UnitTestsUtil.SetupFakeDbSet(fakeHistoryList.AsQueryable()); var fakeDbContext = A.Fake <DatabaseContext>(); A.CallTo(() => fakeDbContext.History).Returns(fakeDbSetHistoryElements); var fakeDbContextGeneration = A.Fake <IDatabaseContextGeneration>(); A.CallTo(() => fakeDbContextGeneration.BuildDatabaseContext()).Returns(fakeDbContext); var historyModelHelper = new HistoryModelHelper(fakeDbContextGeneration); //Act and assert Assert.Throws <ManagerException>(() => historyModelHelper.UpdateHistoryModel(500, 300), StorageErrorMessages.UserDoesNotExistError); }
public void AddEntry(HistoryModel model) { if (model != null) { _dbContext.historyModels.Add(model); _dbContext.SaveChanges(); } }
public HistoryPage() { InitializeComponent(); _model = new HistoryModel(Navigation); BindingContext = _model; _model.RedrawPlayers += OnRedrawPlayers; }
public async Task <ActionResult <SentRecipe> > savePrepare([FromBody] HistoryModel historyModel) { // System.Console.WriteLine(body); System.Console.WriteLine("id: " + historyModel.recipeId + " sub: " + historyModel.sub); SentRecipe recipe = await this.iLogicKitchen.SaveRecipePrepare(historyModel); return(recipe); }
public HistoryView(HistoryModel historyModel) { InitializeComponent(); HistoryModel = historyModel; DataContext = HistoryModel; // TODO: This OptionsStore stuff can be made better! if (HistoryModel.OptionsStore != null) { PreviewRow.Height = !HistoryModel.OptionsStore.IsSchemeHistoryPreviewVisible ? new GridLength(0) : new GridLength(100); } }