//protected override bool OnBackButtonPressedAsync() //{ // this.Navigation.PopAsync(); // return base.OnBackButtonPressed(); //} private async void UploadEvent_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(Event_Name.Text) || string.IsNullOrEmpty(Event_Description.Text) || string.IsNullOrEmpty(Event_Link.Text) || string.IsNullOrEmpty(Event_Contact.Text) || string.IsNullOrEmpty(Event_Date.ToString()) || string.IsNullOrEmpty(Event_Place.Text)) { await DisplayAlert("Empty Field", "Please Fill The Fields", "Ok"); return; } MyActivityIndicator.IsVisible = true; insertEvent.event_name = Event_Name.Text; insertEvent.event_description = Event_Description.Text; insertEvent.event_link = Event_Link.Text; insertEvent.event_cordinator_number = Event_Contact.Text.Split(',').ToList(); insertEvent.event_date = Event_Date.Date.ToString("MM d, yyyy"); insertEvent.event_location = Event_Place.Text; insertEvent.event_organizer = LoggedInUser.userID; insertEvent.event_status = "OPEN"; if (string.IsNullOrEmpty(IssueID)) { insertEvent.event_issue_id = ""; } else { insertEvent.event_issue_id = IssueID; } try { this.newEventResponse = await aPIService.InsertNewEvent(Constants.mongoDBBName, Constants.mongoDBCollectionEvents, Constants.mongoDBKey, insertEvent); MyActivityIndicator.IsVisible = false; if (!string.IsNullOrEmpty(this.newEventResponse._id.oid)) { await DisplayAlert("Success", "Successsfully Inserted The Record.", "ok"); await this.Navigation.PopAsync(); } else { await DisplayAlert("Failure", "Failed To Insert The Record.", "ok"); } } catch (Exception apiException) { this.newEventResponse = null; MongoCache.WriteOfflineEvent(insertEvent); await DisplayAlert("Failure", "Failed To Insert The Record. Will Try again when the internet is back.", "ok"); await this.Navigation.PopAsync(); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (MongoCache.CacheValid()) { base.OnActionExecuting(filterContext); } else { filterContext.Result = new RedirectResult("/Home/CacheExpire/"); } }
private async void UploadIssue_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(stream) || string.IsNullOrEmpty(area_issue.Text) || string.IsNullOrEmpty(area_issue.Text) || string.IsNullOrEmpty(Comments.Text)) { await DisplayAlert("Empty Field", "Please Fill The Fields", "Ok"); return; } insertIssues.adder = LoggedInUser.userID; insertIssues.additional_comments = Comments.Text; insertIssues.address = area_issue.Text; insertIssues.event_id = "NONE"; insertIssues.photo = stream; insertIssues.rating = rating.SelectedItem.ToString(); insertIssues.status = "OPEN"; insertIssues.status_changed_by = "NONE"; MyActivityIndicator.IsVisible = true; try { newRecordResponse = await aPIService.InsertNewIssue(Constants.mongoDBBName, Constants.mongoDBCollectionIssues, Constants.mongoDBKey, insertIssues); MyActivityIndicator.IsVisible = false; if (!string.IsNullOrEmpty(newRecordResponse._id.oid)) { await DisplayAlert("Success", "Successsfully Inserted The Record.", "ok"); await this.Navigation.PopAsync(); } else { await DisplayAlert("Failure", "Failed To Insert The Record.", "ok"); } } catch (ApiException apiException) { this.newRecordResponse = null; MongoCache.WriteOfflineIssue(insertIssues); await DisplayAlert("Failure", "Failed To Insert The Record. Will Try again when the internet is back.", "ok"); await this.Navigation.PopAsync(); } }
private async void Logout_Clicked(object sender, EventArgs e) { bool isOkClicked = await DisplayAlert("Logout", "Do You Want To Logout?", "Yes", "Cancel"); if (isOkClicked) { bool isLoggedOut = MongoCache.Logout(); if (isLoggedOut) { await Navigation.PushAsync(new MainPage()); } else { await DisplayAlert("Failed", "Failed To Log Out", "Ok"); } } else { return; } }
public App() { InitializeComponent(); appSetting = MongoCache.ReadUserLogin(); // We need the user to sign in again after every 3 days. if (appSetting != null) { DateTime creationDate = appSetting.creationDate; double passedDays = DateTime.Now.Subtract(creationDate).TotalDays; if (passedDays > 3) { appSetting.isSignedIn = false; if (Application.Current.Properties.ContainsKey(Constants.mongoDBCollectionUsers)) { Application.Current.Properties[Constants.mongoDBCollectionUsers] = null; } } } if (appSetting == null || !appSetting.isSignedIn) { MainPage = new NavigationPage(new MainPage()) { BarBackgroundColor = Color.Black, BarTextColor = Color.White }; } else if (appSetting.isSignedIn) { MainPage = new NavigationPage(new Dashboard()) { BarBackgroundColor = Color.Black, BarTextColor = Color.White }; } }
public ActionResult ShowInfo(uint id, int type) { var model = new ShowInfoModel { ID = id, Type = type }; //获取描述 if (type == (int)MongoTreeNodeType.Server) { var server = MongoCache.GetMongoObject(id) as MongoServerModel; model.Title = server.FullInfo; } else if (type == (int)MongoTreeNodeType.Database) { var database = MongoCache.GetMongoObject(id) as MongoDatabaseModel; model.Title = database.FullInfo; } else if (type == (int)MongoTreeNodeType.Collection) { var table = MongoCache.GetMongoObject(id) as MongoCollectionModel; model.Title = table.FullInfo; var tblFilter = MongoCache.GetTreeNodes().Single(node => node.PID == id && node.Type == MongoTreeNodeType.TableFiller); model.TblFillerID = tblFilter.ID; var idxFilter = MongoCache.GetTreeNodes().Single(node => node.PID == id && node.Type == MongoTreeNodeType.IndexFiller); model.IdxFillerID = idxFilter.ID; } //获取数据 var mongo = MongoInfoFactory.Create(id, type); model.JsonData = JsonConvert.SerializeObject(mongo.GetInfo()); return(View(model)); }
public JsonResult GetServerDetail() { var nodes = MongoCache.GetTreeNodes().ToList(); return(Json(new { Success = true, Message = "获取数据库对象成功", Result = nodes })); }
protected override async void OnStart() { // Handle when your app starts issuesToBeUploaded = MongoCache.ReadOfflineIssue(); eventsToBeUploaded = MongoCache.ReadOfflineEvent(); if (issuesToBeUploaded != null) { newRecordResponse = new NewRecordResponse(); aPIService = RestService.For <IAPIService>(Constants.mongoDBBaseUrl); int currentIssue = 0; if (issuesToBeUploaded.Count > 0) { try { foreach (var issue in issuesToBeUploaded) { newRecordResponse = await aPIService.InsertNewIssue(Constants.mongoDBBName, Constants.mongoDBCollectionIssues, Constants.mongoDBKey, issue); if (!string.IsNullOrEmpty(newRecordResponse._id.oid)) { // This is Success. /* * First, we get the issue list from application settings and then we iterate over each and every saved instance. * Now, when we have success, we remove that item, so that it doesn't appear again in the list. * Now, we need to increment the issue count. */ issuesToBeUploaded.RemoveAt(currentIssue); currentIssue++; } else { // This is Failure. Console.WriteLine("Failure Occurred. Moving To Next One."); } } foreach (var item in issuesToBeUploaded) { MongoCache.WriteOfflineIssue(item); } } catch (Exception ex) { // Move On. Console.WriteLine("Error While Uploading Issue Backlog : " + ex.Message); } } } // Issue Uploaded if (eventsToBeUploaded != null) { newEventResponse = new Event(); aPIService = RestService.For <IAPIService>(Constants.mongoDBBaseUrl); int currentEvent = 0; if (eventsToBeUploaded.Count > 0) { try { foreach (var eventVal in eventsToBeUploaded) { newEventResponse = await aPIService.InsertNewEvent(Constants.mongoDBBName, Constants.mongoDBCollectionEvents, Constants.mongoDBKey, eventVal); if (!string.IsNullOrEmpty(newEventResponse._id.oid)) { // This is Success. /* * First, we get the event list from application settings and then we iterate over each and every saved instance. * Now, when we have success, we remove that item, so that it doesn't appear again in the list. * Now, we need to increment the issue count. */ eventsToBeUploaded.RemoveAt(currentEvent); currentEvent++; } else { // This is Failure. Console.WriteLine("Failure Occurred. Moving To Next One."); } } foreach (var item in eventsToBeUploaded) { MongoCache.WriteOfflineEvent(item); } } catch (Exception ex) { // Move On. Console.WriteLine("Error While Uploading Event Backlog : " + ex.Message); } } } // Event Uploaded }
public ActionResult Index() { MongoCache.Clear(); return(View()); }