static void Main(string[] args) { DbContext = new UowData(); crowler = new CrowlingService(DbContext); classifier = new ClasifyService(DbContext); // classifier.TrainModel(); //var news = DbContext.NewsItems.All().ToList(); //for (int i = 0; i < news.Count; i++) //{ // var item = news[i]; // item.CleanContent = BaseHelper.ScrubHtml(item.Content); // DbContext.NewsItems.Update(item); // Console.WriteLine(i); //} // DbContext.SaveChanges(); // UpdateCategories(); Crow(); }
public void Execute(IJobExecutionContext context) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; JobDataMap dataMap = context.JobDetail.JobDataMap; ExternalData statistics = (ExternalData)dataMap["data"]; DataManager dataManager = (DataManager)dataMap["dataManager"]; UowData data = (UowData)dataMap["dbContext"]; List <string> stats = new List <string>(); List <string> statsPointsPerGame = new List <string>(); List <string> statsForm = new List <string>(); for (int i = 1; i <= PAGE_COUNT; i++) { stats.AddRange(statistics.GetBasicStats(i)); statsPointsPerGame.AddRange(statistics.GetStatsByPointsPerGame(i)); statsForm.AddRange(statistics.GetStatsByForm(i)); } dataManager.UpdateBasicData(stats); dataManager.UpdatePointsPerGameData(statsPointsPerGame); dataManager.UpdatePlayersForm(statsForm); List <string> statsLeagueTable = statistics.GetStandings(); dataManager.UpdateStandings(statsLeagueTable); DateTime currentDate = DateTime.Now; var currentGameweek = data.Gameweeks.All() .FirstOrDefault(g => g.StartDate <= currentDate && currentDate <= g.EndDate); List <string> fixtures = statistics.GetGameweek(currentGameweek.Id); dataManager.UpdateFixtures(fixtures); }
public static FaceState GetFaceStateById(int faceStateId) { using (UowData db = new UowData()) { return db.FaceStates.GetById(faceStateId); } }
public static bool AddFriendshipRequest(int fromUserUserId, string toUserUserName) { using (UowData db = new UowData()) { User fromUser = UsersData.GetUserByUserId(fromUserUserId); User toUser = UsersData.GetUserByUserName(toUserUserName); if (fromUser == null || toUser == null) { return false; } Friendship friendship = db.Friendships.All().Where(f => f.IsActive && (f.FromUserUserId == fromUser.UserId && f.ToUserUserId == toUser.UserId) || (f.FromUserUserId == toUser.UserId && f.ToUserUserId == fromUser.UserId)).FirstOrDefault(); FriendshipRequest friendshipRequest = db.FriendshipRequests.All().Where(fr => fr.IsActive && (fr.FromUserUserId == fromUser.UserId && fr.ToUserUserId == toUser.UserId) || (fr.FromUserUserId == toUser.UserId && fr.ToUserUserId == fromUser.UserId)).FirstOrDefault(); if (friendship == null && friendshipRequest == null) { FriendshipRequest newFriendshipRequest = new FriendshipRequest(fromUser, toUser); db.FriendshipRequests.Add(newFriendshipRequest); db.SaveChanges(); return true; } else { return false; } } }
public static List<ChatMessage> GetAllChatMessages() { using (UowData db = new UowData()) { IQueryable<ChatMessage> allChatMessages = db.ChatMessages.All(); return allChatMessages.ToList(); } }
public ActionResult Index() { UowData uowData = new UowData(); var userId = User.Identity.GetUserId(); var tweets = uowData.Tweets.All().Where(t => t.AuthorId == userId); return View(tweets); }
public static List<Face> GetAllFaces() { using (UowData db = new UowData()) { IQueryable<Face> allFaces = db.Faces.All(); return allFaces.ToList(); } }
public static List<User> GetAllUsers() { using (UowData db = new UowData()) { IQueryable<User> allUsers = db.Users.All(); return allUsers.ToList(); } }
public static User GetUserByUserId(int userId) { using (UowData db = new UowData()) { User user = db.Users.All().Where(u => u.UserId == userId).FirstOrDefault(); return user; } }
public static User GetUserByUserName(string userName) { using (UowData db = new UowData()) { User user = db.Users.All().Where(u => u.UserName == userName).FirstOrDefault(); return user; } }
public void GetTraceLogMessageRepositoryTest() { //arrange IUowData uow = new UowData(); IRepository<TraceLogMessage, int> traceLogMessageRepository = new GenericRepository<TraceLogMessage, int>(new ApplicationDbContext()); //act var uowRepository = uow.TraceLogMessages; //assert Assert.AreEqual(traceLogMessageRepository.GetType(), uowRepository.GetType()); }
public void GetUloadResultRepositoryTest() { //arrange IUowData uow = new UowData(); IRepository<UploadResult, int> uploadResultRepository = new GenericRepository<UploadResult, int>(new ApplicationDbContext()); //act var uowRepository = uow.UploadResults; //assert Assert.AreEqual(uploadResultRepository.GetType(), uowRepository.GetType()); }
public void GetRoleRepositoryTest() { //arrange IUowData uow = new UowData(); IRepository<RoleIntPk, int> roleRepository = new GenericRepository<RoleIntPk, int>(new ApplicationDbContext()); //act var uowRepository = uow.Roles; //assert Assert.AreEqual(roleRepository.GetType(), uowRepository.GetType()); }
public void GetUserRepositoryTest() { //arrange IUowData uow = new UowData(); IRepository<ApplicationUser, int> userRepository = new GenericRepository<ApplicationUser, int>(new ApplicationDbContext()); //act var uowRepository = uow.Users; //assert Assert.AreEqual(userRepository.GetType(), uowRepository.GetType()); }
public static void AddNewRegisteredUser(RegisterModel registerModel) { using (UowData db = new UowData()) { User newUser = new User(registerModel); db.Users.Add(newUser); db.SaveChanges(); } }
public static void AddChatMessage(User user, string message) { using (UowData db = new UowData()) { ChatMessage newChatMessage = new ChatMessage(user, message); db.ChatMessages.Add(newChatMessage); db.SaveChanges(); } }
public static List<FaceState> GetAllActiveFaceStates() { using (UowData db = new UowData()) { IQueryable<FaceState> allActiveFaceStates = from f in db.FaceStates.All() where f.IsActive select f; return allActiveFaceStates.ToList(); } }
public void GetFileRepositoryTest() { //arrange using (IUowData uow = new UowData()) { IRepository<FileDescription, int> fileRopository = new FileDescriptionRepository(new ApplicationDbContext()); //act var uowRepository = uow.FileDescriptions; //assert Assert.AreEqual(fileRopository.GetType(), uowRepository.GetType()); } }
public static List<User> GetAllUsersButMe(int userId) { using (UowData db = new UowData()) { IQueryable<User> allUsers = from u in db.Users.All() where u.UserId != userId select u; return allUsers.ToList(); } }
public static List<Friendship> GetMyFriendships(int userId) { using (UowData db = new UowData()) { IQueryable<Friendship> friendship = from f in db.Friendships.All() where (f.FromUserUserId == userId || f.ToUserUserId == userId) && f.IsActive select f; return friendship.ToList(); } }
public ActionResult SearchByTag(string tag) { UowData uowData = new UowData(); var key = "SearchByTag-" + tag; if (this.HttpContext.Cache[key] == null) { var tweets = uowData.Tweets.All().Where(t => t.Tags.Any(ta => ta.Text.ToLower().Contains(tag.ToLower()))).ToList(); this.HttpContext.Cache.Add(key, tweets, null, DateTime.Now.AddMinutes(15), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); } return PartialView("_SearchResults", this.HttpContext.Cache[key]); }
public ActionResult RecipeHitCounter(int recipeID) { IUowData db = new UowData(); var oldRecipe = from rec in db.Recipes.All() where rec.RecipeID == recipeID select rec; Recipe newRecipe = oldRecipe.FirstOrDefault(); newRecipe.NumberOfHits = newRecipe.NumberOfHits + 1; db.Recipes.Update(newRecipe); int result = db.SaveChanges(); return(RedirectToAction("Details", recipeID)); }
public static void Initialize(int facesCount) { using (UowData db = new UowData()) { if (db.Faces.All().Count() == 0) { Face face; for (int i = 0; i < facesCount; i++) { face = new Face(); db.Faces.Add(face); } db.SaveChanges(); } } }
public static void Main() { UowData data = new UowData(); var findSales = data.Sales.All(); foreach (var sale in findSales) { XmlExport report = new XmlExport(); Console.WriteLine((DateTime)sale.Date); report.Export((DateTime)sale.Date, sale.ProductId.ToString(), (double)sale.UnitPrice); } }
public static void UpendToMsSQL () { UowData sqlData = new UowData(); MongoUow mongoData = new MongoUow(); //var measure = new Measure { MeasureName = "Spas" }; var collections = mongoData.Measurs.GetAll(); using (sqlData) { foreach (var item in collections) { string name = item.MeasureName; int measureId = item.MeasureId; Console.WriteLine("Name is : {0} Id is : {1}", name, measureId); var sqlMeasure = new Measure { MeasureName = name }; sqlData.Measures.Add(sqlMeasure); sqlData.SaveChanges(); } } }
public static List<User> GetFaceOwners(int faceId) { using (UowData db = new UowData()) { IQueryable<User> owners = from f in db.FaceStates.All() where f.FaceId == faceId && f.IsActive select f.Owner; return owners.ToList(); } }
public BooksLibrarySystemPage(UowData uow) { this.data = uow; }
public static bool RentFace(int userId, int faceId, int state) { using (UowData db = new UowData()) { IQueryable<FaceState> faceStates = from f in db.FaceStates.All() where f.Face.FaceId == faceId && f.IsActive && f.Owner.UserId == userId select f; if (faceStates.Count() == 0) { FaceState newFaceState = new FaceState(db.Faces.GetById(faceId), db.Users.GetById(userId)); newFaceState.IsActive = true; newFaceState.State = state; db.FaceStates.Add(newFaceState); db.SaveChanges(); return true; } else { return false; } } }
private void AddSaveDataSQL(DateTime date, double ProductId, double UnitPrice) { var data = new UowData(); Sale exelSales = new Sale(); exelSales.ProductId = (int)ProductId; exelSales.UnitPrice = (decimal)UnitPrice; exelSales.Date = date; data.Sales.Add(exelSales); data.SaveChanges(); }
public static bool LeaveFace(int userId, int faceId) { using (UowData db = new UowData()) { IQueryable<FaceState> faceStates = from f in db.FaceStates.All() where f.FaceId == faceId && f.IsActive && f.Owner.UserId == userId select f; if (faceStates.Count() > 0) { foreach (var faceState in faceStates) { faceState.LeaveDateTime = DateTime.Now; faceState.IsActive = false; } db.SaveChanges(); return true; } else { return false; } } }
public static bool UpdateFaceState(int userId, int faceId, int type, string purpose) { using (UowData db = new UowData()) { FaceState faceState = db.FaceStates.All().Where(f => f.FaceId == faceId && f.IsActive && f.OwnerUserId == userId).FirstOrDefault(); if (faceState != null) { FaceState newFaceState = new FaceState(faceState); newFaceState.Type = type; newFaceState.Purpose = purpose; faceState.IsActive = false; faceState.LeaveDateTime = DateTime.Now; db.FaceStates.Add(newFaceState); db.SaveChanges(); return true; } else { return false; } } }
protected IUowData GetUowDataInstance() { UowData db = new UowData(); return(db); }
public static List<FaceState> GetFacesByUserId(int userId) { using (UowData db = new UowData()) { IQueryable<FaceState> faceStates = from f in db.FaceStates.All() where f.Owner.UserId == userId && f.IsActive select f; return faceStates.ToList(); } }