public static Db.ViewCount ToEntity(ViewCount viewCount) { return viewCount == null ? null : new Db.ViewCount { PostId = viewCount.PostId, Id = viewCount.Id, UserId = viewCount.UserId }; }
public async Task AddUserRecipeView(string userId, int recipeId) { ViewCount viewCount = new ViewCount { UserId = userId, RecipeId = recipeId, }; await this.viewCountRepository.AddAsync(viewCount); await this.viewCountRepository.SaveChangesAsync(); }
public void ViewCount() { var statistics = new ViewCount { BrowserInfo = BrowserInfo.GetFullUserAgent(), CreationDate = DateTime.Now, Ip = IPAddress.IP, Url = ShortUrl, Title = Weburl.Title, UserAgent = BrowserInfo.GetFullUserAgent(), UserId = Weburl.UserId }; //增加一次访问记录 MongoHelper.Instance.Save(statistics, string.Format("VisitRecord_{0}", DateTime.Now.ToString("yyyy-MM-dd"))); #region /*(-_-)*/ 判断是否要增加有效访问记录以及积分记录/*(-_-)*/ var condition = Query.EQ("Url", ShortUrl); condition = Query.And(condition, Query.LT("CreationDate", DateTime.Now), Query.GTE("CreationDate", DateTime.Now.AddHours(-.5))); var count = MongoHelper.Instance.Count <ViewCount>(condition); if (count <= 0) { MongoHelper.Instance.Save(statistics); #region 增加积分记录 var integral = new Integral { UserId = Weburl.UserId, CalculatorSystem = Application.CalculatorSystem, IntegralType = IntegralType.效访问, ShortUrl = ShortUrl, CreationDate = DateTime.Now }; MongoHelper.Instance.Save(integral); #endregion #region 更新用户等级 var uu = new UserUpdate(Weburl.UserId); uu.UpdateUserLevel(); #endregion } #endregion }
public int GetCount(object refNoteID) { ViewCount.Clear(); int startRow = 0; int totalRows = 0; var filters = InitFilters(refNoteID, null); var list = ViewCount.Select(null, new [] { refNoteID }, null, new [] { typeof(CRActivity.createdDateTime).Name }, new[] { true }, filters.ToArray(), ref startRow, 0, ref totalRows); PXResult pxRes = (PXResult)list[0]; return(pxRes.RowCount.GetValueOrDefault(0)); }
private static int _count = 0; //считает подходящие сочетания static void Main(string[] args) { Stopwatch time = new Stopwatch(); time.Start(); Console.OutputEncoding = Encoding.UTF8; //даёт вывести символы крестушек/пикушек... CreateCards(); int[] fiveCards = new int[5]; //для ключей карт, вошедших в сочетание Rec(0, 0, ref fiveCards); time.Stop(); ViewCount.PrintInfo(time, _combinations, _count); }
public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound) { PropertyNotFound = false; FAQsController faqController; switch (strPropertyName.ToLower()) { case "question": return(PropertyAccess.FormatString(Question, strFormat)); case "answer": return(PropertyAccess.FormatString(Answer, strFormat)); case "user": UserInfo user = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(CreatedByUser)); return(PropertyAccess.FormatString(user.DisplayName, strFormat)); case "viewcount": return(ViewCount.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider)); case "vieworder": return(ViewOrder.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider)); case "categoryname": faqController = new FAQsController(); return(PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryName, strFormat)); case "categorydesc": faqController = new FAQsController(); return(PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryDescription, strFormat)); case "datecreated": return(CreatedDate.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider)); case "datemodified": return(DateModified.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider)); case "index": return(Index.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider)); default: PropertyNotFound = true; return(String.Empty); } }
// GET api/<controller>/5 public int Get(Guid id) { using (DatabaseContext context = Util.CreateContext()) { ViewCount count = (from c in context.ViewCounts.AsNoTracking() where c.Guid == id select c).FirstOrDefault(); if (count == null) { return(1); } //include current view as well as previous counts; return(count.Count + 1); } }
public IActionResult CityAndCountry(CityAndCountry cityAndCountry) { var Data = EFRepositoryPort.IncludeGet(i => i.City).ToList(); var Country = EFRepositoryCountries.Get(); ViewBag.Countries = EFRepositoryCountries.Get(); var DataCountry = new List <ViewCount>(); foreach (var i in Data) { string CountryName = Country.First(k => k.CountryId == i.City.CountryId).Name; var DataType = DataCountry.FirstOrDefault(l => l.typeOfPort == i.TypePort && l.Name == CountryName); if (DataType != null) { DataCountry.Remove(DataType); DataType.Coun++; DataCountry.Add(DataType); } else { DataType = new ViewCount() { Name = CountryName, Coun = 1, typeOfPort = i.TypePort, CountId = Guid.NewGuid(), ContryId = i.City.CountryId }; DataCountry.Add(DataType); } } if (cityAndCountry.CountryId != Guid.Empty) { DataCountry = DataCountry.Where(i => i.ContryId == cityAndCountry.CountryId).ToList(); } if (cityAndCountry.TypeOfPort != null) { DataCountry = DataCountry.Where(i => i.typeOfPort == cityAndCountry.TypeOfPort).ToList(); } return(View(DataCountry)); }
// POST api/<controller> public void Post(Guid id) { lock (lockObject) { using (DatabaseContext context = Util.CreateContext()) { ViewCount count = (from c in context.ViewCounts where c.Guid == id select c).FirstOrDefault(); if (count == null) { count = new ViewCount { Guid = id, Count = 0 }; context.ViewCounts.Add(count); } count.Count++; context.SaveChanges(); } } }
public int GetCount(object refNoteID) { ViewCount.Clear(); return((int)((PXResult)ViewCount.SelectSingle(refNoteID)).RowCount); }
public ActionResult Lamps(int?lampid) { ViewBag.Title = "Lamps"; string userIP = UtilityClass.GetIP(); string userZip = UtilityClass.GetZip(userIP); //instantiate DB from model LampBaeEntities1 db = new LampBaeEntities1(); //instantiate new list for lamp id's List <Listing> LampDBList = new List <Listing>(); //populate list from Listing LampDBList = (from p in db.Listings where p.ID != 0 || p.EndDate > DateTime.Now || //doesnt show lamps after its ended auction p.ReportCount > 0 //doesn't show lamps that have been reported/flagged select p).ToList(); //instantiate new list for ratings List <ViewCount> ViewCountList = (from p in db.ViewCounts where p.ViewID != 0 select p).ToList(); //declaring our listing object Listing listing = null; string ItemZipCode = ""; // if no lampid is provided, a random id will be generated and assigned to x if (lampid == null || lampid > LampDBList.Count || lampid < 0) { //instantiate new random object & create a new random int based on range of list count as max value Random r = new Random(); lampid = r.Next(1, LampDBList.Count()); listing = (from p in db.Listings where p.ID == lampid select p).Single(); ItemZipCode = listing.PostalCode; } else { //grabs a listing from list listing = (from p in db.Listings where p.ID == lampid select p).Single(); ItemZipCode = listing.PostalCode; } //handling for ebay listings vs user listings (the image url structure is different) if (listing.EbayItemNumber == null) { ViewData["ItemTitle"] = listing.Title; ViewData["Price"] = listing.Price; ViewData["viewItemURL"] = ("/Home/LinkImage?lampid=" + listing.ID); ViewData["ImageURL"] = Url.Content("~/Content/" + listing.Image); } else { ViewData["ItemTitle"] = listing.Title; ViewData["Price"] = listing.Price; ViewData["viewItemURL"] = listing.ItemSearchURL; ViewData["ImageURL"] = listing.Image; } //test if view record exists already ViewCount existingViewCount = null; try { existingViewCount = (from m in db.ViewCounts where m.ItemID == lampid && m.UserID == User.Identity.Name select m).Single(); } catch (Exception e) { Console.WriteLine("An error occurred: '{0}'", e); } // if a view record already exists, simply increment if (existingViewCount != null) { existingViewCount.ViewCount1 = existingViewCount.ViewCount1 + 1; db.SaveChanges(); } //if a view record doesn't already exist, create a new record and assign it a value of one else { ViewCount newviewcount = new ViewCount(); newviewcount.UserID = User.Identity.Name; newviewcount.ItemID = (int)lampid; newviewcount.ViewCount1 = 1; newviewcount.ViewDate = DateTime.Now; new ViewCount() { UserID = newviewcount.UserID, ItemID = (int)lampid, ViewCount1 = 1, ViewDate = DateTime.Now }; db.ViewCounts.Add(newviewcount); db.SaveChanges(); } string distance = UtilityClass.GetZipCodeDistance(userZip, ItemZipCode); ViewBag.Distance = distance; ViewData["CurrentLampID"] = listing.ID; ViewBag.UserZip = userZip; ViewBag.CurrentUser = User.Identity.Name; ViewBag.CurrentUserIP = userIP; return(View()); }