public static int Insert(UserLogsModel model) { try { using (DataContentDataContext dc = new DataContentDataContext()) { User_Log newItem = new User_Log(); newItem.ID = model.ID; newItem.Functions = model.Functions; newItem.ItemID = model.ItemID; newItem.UserID = model.UserID; newItem.UserName = model.UserName; newItem.Creater = model.Creater; newItem.CreateDate = model.CreateDate; dc.User_Logs.InsertOnSubmit(newItem); dc.SubmitChanges(); } return 1; } catch (Exception) { return 0; } }
public CreateActivityViewModel(List <User> userQuery, User_Log userLog, ObservableCollection <Activity_Category> categories, Activity act, Location loc, Location origLoc, int pickerCatIndex) { this.ButtonText = "Select Location"; this.ButtonColor = "Red"; this.userQuery = userQuery; this.userLog = userLog; this.Categories = categories; this.ActivityName = act.Name; this.StartDay = act.Start_Act_Datetime; this.FinishDay = act.End_Act_Datetime; this.StartHour = act.Start_Act_Datetime.TimeOfDay; this.FinishHour = act.End_Act_Datetime.TimeOfDay; this.Description = act.Description; this.IsService = act.IsService; //Console.WriteLine("***TEST: "+pickerCatIndex.ToString()); this.PickerCatIndex = pickerCatIndex; PickerIndex(); this.loc = loc; //Location this.origLoc = origLoc; getPlacename(); if (this.loc != null) { this.IsVisible = true; this.ButtonColor = "Green"; this.ButtonText = "Modify Location"; } instance = this; }
public ActionResult DeleteConfirmed(int id) { User_Log user_Log = db.User_Log.Find(id); db.User_Log.Remove(user_Log); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,User_Id,LoginDate,ProductID")] User_Log user_Log) { if (ModelState.IsValid) { db.Entry(user_Log).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductID = new SelectList(db.Products, "Id", "Name", user_Log.ProductID); ViewBag.User_Id = new SelectList(db.Users, "Id", "Name", user_Log.User_Id); return(View(user_Log)); }
public static User_Log userLogTypesAsync(string userId, string logTypeId) { int len = RandomId.length.Next(5, 10); User_Log user = new User_Log { Id = RandomId.RandomString(len), LogDateTime = DateTime.Today, User_LogType_Id_FK1 = logTypeId, User_Id_FK2 = userId }; return(user); }
// GET: User_Log/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User_Log user_Log = db.User_Log.Find(id); if (user_Log == null) { return(HttpNotFound()); } return(View(user_Log)); }
public CreateActivityViewModel(List <User> userQuery, User_Log userLog, ObservableCollection <Activity_Category> categories) { instance = this; this.ButtonText = "Select Location"; this.ButtonColor = "Red"; this.StartDay = DateTime.Today; this.FinishDay = DateTime.Today; this.StartHour = DateTime.Now.TimeOfDay; this.FinishHour = DateTime.Now.TimeOfDay; this.TodayNow = DateTime.Now; this.userQuery = userQuery; this.userLog = userLog; this.Categories = categories; }
// GET: User_Log/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User_Log user_Log = db.User_Log.Find(id); if (user_Log == null) { return(HttpNotFound()); } ViewBag.ProductID = new SelectList(db.Products, "Id", "Name", user_Log.ProductID); ViewBag.User_Id = new SelectList(db.Users, "Id", "Name", user_Log.User_Id); return(View(user_Log)); }
public LocationViewModel(List <User> userQuery, User_Log userLog, ObservableCollection <Activity_Category> categories, Activity act, int pickerCatIndex) { instance = this; this.Locationtxt = ""; this.SavePinEnabled = false; this.MovePinAllowed = false; this.MovePinButtonText = "Allow Move Pin"; this.userQuery = userQuery; this.userLog = userLog; this.categories = categories; this.activity = act; this.pickerCatIndex = pickerCatIndex; LoadSafeLocation(); }
private async void fillEquipment() { int len = RandomId.length.Next(5, 10); equipment = new User_Equipment { Id = RandomId.RandomString(len), Phone_Model_Num = CrossDeviceInfo.Current.Platform.ToString(), Phone_Name = CrossDeviceInfo.Current.DeviceName, Phone_Version = CrossDeviceInfo.Current.Version, User_Id_FK = userQuery[0].Id }; try { await App.MobileService.GetTable <User_Equipment>().InsertAsync(equipment); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok"); } userLog = new User_Log { Id = RandomId.RandomString(len), LogDateTime = DateTime.Today, User_LogType_Id_FK1 = logType, User_Equipment_code = equipment.Id, User_Id_FK2 = userQuery[0].Id }; try { await App.MobileService.GetTable <User_Log>().InsertAsync(userLog); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok"); } }
partial void DeleteUser_Log(User_Log instance);
private async void CreateActivity() { CheckConnectionInternet.checkConnectivity(); //if ((this.StartDay.Date + this.StartHour) < DateTime.Now) //{ // await Application.Current.MainPage.DisplayAlert( // "Message", // "Past date is not allowed.", // "Ok"); // return; //} //if (this.StartDay.Date + this.StartHour > this.FinishDay.Date + this.FinishHour) //{ // await Application.Current.MainPage.DisplayAlert( // "Message", // "The Start Date is greater than Finish Date", // "Ok"); // this.FinishDay = this.StartDay; // this.FinishHour = this.StartHour; // return; //} ValidateDatetime(); if (string.IsNullOrEmpty(this.ActivityName)) { await Application.Current.MainPage.DisplayAlert( "Error", "You must enter an Activity Name.", "Accept"); return; } if (string.IsNullOrEmpty(this.Description)) { await Application.Current.MainPage.DisplayAlert( "Error", "You must enter a description.", "Accept"); return; } if (SelectedCategory == null) { await Application.Current.MainPage.DisplayAlert( "Error", "You must select a Category.", "Accept"); return; } if (loc == null) { await Application.Current.MainPage.DisplayAlert( "Error", "You must select a Location.", "Accept"); return; } if ((this.StartDay.Date + this.StartHour) < DateTime.Now) { await Application.Current.MainPage.DisplayAlert( "Message", "Past date is not allowed.", "Ok"); this.StartHour = DateTime.Now.TimeOfDay; return; } string[] addrSplit = this.Placename.Split(','); for (int i = 0; i < addrSplit.Length; i++) { addrSplit[i] = addrSplit[i].Trim(); } int len = RandomId.length.Next(5, 10); Activity_Location activity_location = new Activity_Location() { Id = RandomId.RandomString(len), Nameplace = addrSplit[0], City = addrSplit.Length == 5 ? addrSplit[2] : addrSplit[1], State = "PR",//Cambiarlo luego con IF dinamico Country = addrSplit.Length == 5 ? addrSplit[4] : addrSplit[3], ZipCode = addrSplit.Length == 5 ? addrSplit[3] : addrSplit[2], IsSecure = false, Latitude = (decimal)this.loc.Latitude, Longitude = (decimal)this.loc.Longitude, CreatorOriginalPinLatitude = (decimal)this.origLoc.Latitude, CreatorOriginalPinLongitude = (decimal)this.origLoc.Longitude }; try { //find duplicate var query = await App.MobileService.GetTable <Activity_Location>().Where( p => p.Nameplace == activity_location.Nameplace && p.City == activity_location.City && p.ZipCode == activity_location.ZipCode ).ToListAsync(); if (query.Count == 0) { await App.MobileService.GetTable <Activity_Location>().InsertAsync(activity_location); } else { var location = query?.FirstOrDefault(); activity_location.Id = location.Id; } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok"); } Activity activity = new Activity() { Id = RandomId.RandomString(len), Name = this.ActivityName, Created_Date = DateTime.Now, IsPrivate = false,//todo Start_Act_Datetime = this.StartDay.Date + this.StartHour, End_Act_Datetime = this.FinishDay.Date + this.FinishHour, Description = this.Description.TrimEnd().TrimStart(), Status = 1,//check IsService = this.IsService, Activity_Cat_Code = SelectedCategory.Id, Activity_Loc_Id = activity_location.Id }; //ctivity history Activity_History activityHistory = new Activity_History() { Id = RandomId.RandomString(len), Activity_Code_Id = activity.Id, Name = this.ActivityName, Created_Date = DateTime.Now, IsPrivate = false,//todo Start_Act_Date = this.StartDay.Date + this.StartHour, End_Act_Date = this.FinishDay.Date + this.FinishHour, Description = this.Description, Status = 1,//check IsService = this.IsService, Activity_Cat_code = SelectedCategory.Id, Activity_Loc_Id_FK = activity_location.Id }; userCreating = User_LogType.userLogTypesAsync(userQuery[0].Id, usLog); User_Entered entry = new User_Entered() { Id = RandomId.RandomString(len), Status = "in", IsCreator = true, User_Log_Id_FK1 = userCreating.Id, Activity_Code_FK2 = activityHistory.Activity_Code_Id }; Entered_History entryHistory = new Entered_History() { Id = entry.Id, Status = "in", IsCreator = true, Activity_Code_FK2 = activityHistory.Activity_Code_Id, UserJoin = userQuery[0].Id, UserCreator = userQuery[0].Id }; try { await App.MobileService.GetTable <Activity>().InsertAsync(activity); await App.MobileService.GetTable <Activity_History>().InsertAsync(activityHistory); await App.MobileService.GetTable <User_Log>().InsertAsync(userCreating); await App.MobileService.GetTable <User_Entered>().InsertAsync(entry); await App.MobileService.GetTable <Entered_History>().InsertAsync(entryHistory); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok"); } MainViewModel.GetInstance().Activity_Child = new ActivityViewModel(userQuery, entry); await Application.Current.MainPage.Navigation.PushAsync(new ActivityPage()); }
//public ObservableCollection<Activity_Location> ActivityLocation { get; private set; } private async void Quit() { bool isNotEntered = true; List <User_Log> userLogged; User_Log current = null; int userQuit = 0; var queue = await App.MobileService.GetTable <User_Entered>().Where(p => p.Activity_Code_FK2 == selectedActivity.Id).ToListAsync(); var userStr = await App.MobileService.GetTable <Entered_History>().Where(p => p.Activity_Code_FK2 == selectedActivity.Id).ToListAsync(); if (queue.Count > 0) { for (int i = 0; i < queue.Count; i++) { userLogged = await App.MobileService.GetTable <User_Log>().Where(p => p.Id == queue[i].User_Log_Id_FK1 && (p.User_LogType_Id_FK1 == "4" || p.User_LogType_Id_FK1 == "3")).ToListAsync(); if (userLogged[0].User_Id_FK2.Equals(userJoining[0].Id)) { userQuit = i; current = new User_Log { Id = userLogged[0].Id, LogDateTime = DateTime.Now, User_Id_FK2 = userLogged[0].User_Id_FK2, Activity_code = selectedActivity.Id, User_Equipment_code = userLogged[0].User_Equipment_code, User_LogType_Id_FK1 = "5" // quit activity }; isNotEntered = false; } } } if (!isNotEntered) { Entered_History entered = null; try { if (!queue[userQuit].IsCreator) { await App.MobileService.GetTable <User_Log>().UpdateAsync(current); entered = new Entered_History { Id = queue[userQuit].Id, Activity_Code_FK2 = queue[userQuit].Activity_Code_FK2, Status = "Aborting", IsCreator = queue[userQuit].IsCreator, UserJoin = userJoining[0].Id, UserCreator = userCreatorActivity[0].Id, }; await App.MobileService.GetTable <Entered_History>().UpdateAsync(entered); await App.MobileService.GetTable <User_Entered>().DeleteAsync(queue[userQuit]); entered = null; await Application.Current.MainPage.DisplayAlert("Success", " You are now out of the activity", "Ok"); getFileUserEntry(); } else { await App.MobileService.GetTable <User_Log>().UpdateAsync(current); if (queue.Count > 1) { for (int i = 0; i < queue.Count; i++) { entered = new Entered_History { Id = queue[i].Id, Activity_Code_FK2 = queue[i].Activity_Code_FK2, Status = "Out", IsCreator = queue[i].IsCreator, UserJoin = userStr[i].UserJoin, UserCreator = userCreatorActivity[0].Id, }; await App.MobileService.GetTable <Entered_History>().UpdateAsync(entered); await App.MobileService.GetTable <User_Entered>().DeleteAsync(queue[i]); entered = null; } } else { entered = new Entered_History { Id = queue[0].Id, Activity_Code_FK2 = queue[0].Activity_Code_FK2, Status = "Out", IsCreator = queue[0].IsCreator, UserJoin = userJoining[0].Id, UserCreator = userCreatorActivity[0].Id, }; await App.MobileService.GetTable <Entered_History>().UpdateAsync(entered); await App.MobileService.GetTable <User_Entered>().DeleteAsync(queue[0]); entered = null; } await App.MobileService.GetTable <Activity>().DeleteAsync(selectedActivity); await Application.Current.MainPage.DisplayAlert("Success", " You are deleted the activity", "Ok"); MainViewModel.GetInstance().Activity_Child = new ActivityViewModel(userCreatorActivity); await Application.Current.MainPage.Navigation.PushAsync(new ActivityPage()); } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok"); return; } } else { await Application.Current.MainPage.DisplayAlert("Error", "You are not on the lobby", "Ok"); return; } getFileUserEntry(); }
private async void Join() { var queue = await App.MobileService.GetTable <User_Entered>().Where(p => p.Activity_Code_FK2 == selectedActivity.Id && !p.IsCreator).ToListAsync(); if (queue.Count > 0) { for (int i = 0; i < queue.Count; i++) { var userLogged = await App.MobileService.GetTable <User_Log>().Where(p => p.Id == queue[i].User_Log_Id_FK1 && p.User_LogType_Id_FK1 == "4").ToListAsync(); if (userLogged[0].User_Id_FK2.Equals(userJoining[0].Id)) { await Application.Current.MainPage.DisplayAlert( "Error", "You are in the lobby", "Accept"); return; } } } int len = RandomId.length.Next(5, 10); var userLog = new User_Log { Id = RandomId.RandomString(len), LogDateTime = DateTime.Today, User_LogType_Id_FK1 = logtypeJoin, User_Equipment_code = equipment.Id, Activity_code = selectedActivity.Id, User_Id_FK2 = userJoining[0].Id }; User_Entered entry = new User_Entered() { Id = RandomId.RandomString(len), Status = "in", IsCreator = false, User_Log_Id_FK1 = userLog.Id, Activity_Code_FK2 = selectedActivity.Id }; Entered_History entryHistory = new Entered_History() { Id = entry.Id, Status = "in", IsCreator = false, Activity_Code_FK2 = selectedActivity.Id, UserJoin = userJoining[0].Id, UserCreator = userCreatorActivity[0].Id }; if (userJoining[0].Id.Equals(userCreatorActivity[0].Id)) { await Application.Current.MainPage.DisplayAlert( "Error", "You are the Creator!!", "Accept"); return; } try { await App.MobileService.GetTable <User_Log>().InsertAsync(userLog); await App.MobileService.GetTable <User_Entered>().InsertAsync(entry); await App.MobileService.GetTable <Entered_History>().InsertAsync(entryHistory); getFileUserEntry(); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok"); return; } await Application.Current.MainPage.DisplayAlert("Success", " You are now on the queue", "Ok"); }
public static void Info(object msg) { User_Log.Info(msg); }
public static void Error(Exception ex) { User_Log.Error(ex.Message, ex); }
public static void Error(object msg, Exception ex) { User_Log.Error(msg, ex); }
///// <summary> ///// Bank User Logger ///// </summary> ///// <param name="msg"></param> //public static void BankUserError(object msg) //{ // BankUser_Log.Error(msg); //} //public static void BankUserError(object msg, Exception ex) //{ // BankUser_Log.Error(msg, ex); //} //public static void BankUserError(Exception ex) //{ // BankUser_Log.Error(ex.Message, ex); //} //public static void BankUserInfo(object msg) //{ // BankUser_Log.Error(msg); //} /// <summary> /// User Logger /// </summary> /// <param name="msg"></param> public static void Error(object msg) { User_Log.Error(msg); }
public MenuViewModel(List <User> userQuery, User_Log userLog) { this.user = userQuery; NickName = userQuery[0].Nickname; }
partial void UpdateUser_Log(User_Log instance);
partial void InsertUser_Log(User_Log instance);