Exemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            webView = new UIWebView(View.Bounds);
            webView.ScalesPageToFit = false;

            if (meterSerialNumber == null)
            {
                showErrorMessage();
            }
            else
            {
                String body = "<html><body>Loading reports for <b>" + meterName + "...</b></body></html>";
                View.AddSubview(webView);
                showContentOnWebView(body);

                //var preferenceHandler = new PreferenceHandler();
                int userId = PreferenceHandler.GetUserDetails().UserId;
                if (userId != -1)
                {
                    getMeterReports(userId, meterSerialNumber);
                }
                else
                {
                    IOSUtil.ShowAlert("Invalid Email. Please Login Again !");
                }
            }
        }
Exemplo n.º 2
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AdminDashboard);
            CurrentConsumption = ConsumptionFor.Premises;
            receiver           = new MySampleBroadcastReceiver(this);


            if (!Utils.Utils.IsNetworkEnabled(this))
            {
                RunOnUiThread(() =>
                {
                    Utils.Utils.ShowDialog(this, "Internet not available.");
                });
                StartActivity(new Intent(Application.Context, typeof(LoginActivity)));
                Finish();
            }
            else
            {
                if (PreferenceHandler.GetToken() == string.Empty)
                {
                    await Utils.Utils.GetToken();
                }
                CreateDashboard();
                IsPlayServicesAvailable();
            }
        }
Exemplo n.º 3
0
        public async void GetClassRooms()
        {
            //PreferenceHandler prefHandler = new PreferenceHandler();
            UserDetails userDetail = PreferenceHandler.GetUserDetails();
            var         response   = await InvokeApi.Invoke(Constants.API_GET_CLASS_ROOMS + "/" + userDetail.UserId, string.Empty, HttpMethod.Get);

            if (response.StatusCode != 0)
            {
                InvokeOnMainThread(() =>
                {
                    CheckClassRoomsResponse(response);
                    loadingOverlay.Hide();
                });
            }
            //RestClient client = new RestClient(Constants.SERVER_BASE_URL);


            //var request = new RestRequest(Constants.API_GET_CLASS_ROOMS + "/" + userDetail.User_Id, Method.GET);
            //request.RequestFormat = DataFormat.Json;
            //client.ExecuteAsync(request, response =>
            //{
            //    Console.WriteLine(response);

            //});
        }
Exemplo n.º 4
0
        private void LogOutButton_TouchUpInside(object sender, EventArgs e)
        {
            // Added for showing loading screen
            var bounds = UIScreen.MainScreen.Bounds;

            // show the loading overlay on the UI thread using the correct orientation sizing
            loadingOverlay = new LoadingOverlay(bounds);
            View.Add(loadingOverlay);
            PreferenceHandler.setLoggedIn(false);
            PreferenceHandler.SetToken(string.Empty);
            PreferenceHandler.SetRefreshToken(string.Empty);
            PreferenceHandler.SaveUserDetails(new UserDetails()
            {
                Email     = string.Empty,
                FirstName = string.Empty,
                LastName  = string.Empty,
                RoleId    = 0,
                RoleType  = 0,
                UserId    = 0
            });
            Action ResetSession = () =>
            {
            };

            NSUrlSession.SharedSession.Reset(ResetSession);
            var ViewController = (ViewController)Storyboard.InstantiateViewController("ViewController");

            ViewController.NavigationItem.SetHidesBackButton(true, false);
            NavController.PushViewController(ViewController, true);
            SidebarController.MenuWidth = 0;
            SidebarController.CloseMenu();
            loadingOverlay.Hide();
            Logout(new LogoutModel(PreferenceHandler.GetUserDetails().Email));
        }
        public override async void OnPageStarted(WebView view, string url, Bitmap favicon)
        {
            base.OnPageStarted(view, url, favicon);
            layoutProgress            = view.FindViewById <LinearLayout>(Resource.Id.layout_progress);
            layoutProgress.Visibility = ViewStates.Visible;
            layoutProgress.Enabled    = true;
            //view.DispatchFinishTemporaryDetach();
            if (url.Contains("&code="))
            {
                string code = Common.FunGetValuefromQueryString(url, "code");
                PreferenceHandler.SetAccessCode(code);
                PreferenceHandler.setLoggedIn(true);

                string tokenURL = string.Format(B2CConfig.TokenURL, B2CConfig.Tenant, B2CPolicy.SignInPolicyId, B2CConfig.ClientId, PreferenceHandler.GetAccessCode());
                var    response = await InvokeApi.Authenticate(tokenURL, string.Empty, HttpMethod.Post);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    string strContent = await response.Content.ReadAsStringAsync();

                    var tokenNew = JsonConvert.DeserializeObject <AccessToken>(strContent);
                    PreferenceHandler.SetToken(tokenNew.id_token);
                    PreferenceHandler.SetRefreshToken(tokenNew.refresh_token);
                    layoutProgress.Visibility = ViewStates.Visible;
                    await GetUserDetails(view);
                }
            }
        }
Exemplo n.º 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationItem.SetLeftBarButtonItem(
                new UIBarButtonItem(UIImage.FromBundle("threelines.png")
                                    , UIBarButtonItemStyle.Plain
                                    , (sender, args) =>
            {
                SidebarController.ToggleMenu();
            }), true);


            //PreferenceHandler prefHandler = new PreferenceHandler();
            UserDetails userDetail = PreferenceHandler.GetUserDetails();

            if (PreferenceHandler.GetUserDetails().RoleId == (int)USER_ROLE.ADMIN)
            {
                btnBadge = new UIButton()
                {
                    Frame = new CGRect(0, 0, 25, 25),
                };
                btnBadge.SetBackgroundImage(UIImage.FromBundle("Notification_Icon.png"), UIControlState.Normal);
                btnBadge.SetTitleColor(UIColor.White, UIControlState.Normal);
                btnBadge.TouchUpInside              += BtnBadge_TouchUpInside;
                btnAlertsBadge                       = new BadgeBarButtonItem(btnBadge);
                btnAlertsBadge.BadgeValue            = UIApplication.SharedApplication.ApplicationIconBadgeNumber.ToString();
                btnAlertsBadge.Style                 = UIBarButtonItemStyle.Plain;
                btnAlertsBadge.ShouldHideBadgeAtZero = true;
                btnAlertsBadge.BadgeOriginX          = 10;
                NavigationItem.SetRightBarButtonItem(btnAlertsBadge, true);
            }
        }
Exemplo n.º 7
0
 private void CreateDashboard()
 {
     SetDrawer();
     if (PreferenceHandler.GetUserDetails().RoleId == (int)USER_ROLE.ADMIN)
     {
         try
         {
             if (Utils.Utils.CurrentStage == DemoStage.None && IsDemoMode)
             {
                 Utils.Utils.CurrentStage = DemoStage.Yesterday;
                 client = new MqttClient(Constants.MqttServer);
                 SubscribeMQTT(this);
             }
         }
         catch (Exception)
         {
         }
         GetConsumptionDetails(CurrentConsumption, 0);
         this.Title = "Dashboard";
     }
     else
     {
         //Show Student Fragment
         this.Title = "Feedback";
         var newFragment = new StudentFragment();
         var ft          = FragmentManager.BeginTransaction();
         ft.Add(Resource.Id.fragment_container, newFragment);
         ft.Commit();
         layoutProgress            = FindViewById <LinearLayout>(Resource.Id.layout_progress);
         layoutProgress.Visibility = ViewStates.Gone;
     }
 }
Exemplo n.º 8
0
        public ActionResult GetAllLikes(string term)
        {
            try
            {
                LoginHelper.CheckAccess(Session);
            }
            catch (Exception)
            {
                return(RedirectToAction("Login", "Login"));
            }

            ResponseEntity <ICollection <PreferenceEntity> > list;

            if (string.IsNullOrEmpty(term))
            {
                list = new PreferenceHandler().GetAll();
            }
            else
            {
                list = new PreferenceHandler().GetAllForTerm(term);
            }

            if (!list.CompletedRequest)
            {
                return(RedirectToAction("Index", "Error", new { errorMessage = list.ErrorMessage.Replace(' ', '-') }));
            }

            return(Content(JsonConvert.SerializeObject(list.Entity)));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.MeterReportView);

            localWebView = FindViewById <WebView>(Resource.Id.LocalWebView);
            localWebView.SetWebViewClient(new WebViewClient()); // stops request going to Web Browser
            localWebView.Settings.JavaScriptEnabled = true;

            String body = "<html><body>Loading reports...</body></html>";

            showContentOnWebView(body);

            int userId = PreferenceHandler.GetUserDetails().UserId;

            if (userId != -1)
            {
                bool isNetworkEnabled = Utils.Utils.IsNetworkEnabled(this);
                if (isNetworkEnabled)
                {
                    getReports(userId);
                }
                else
                {
                    Utils.Utils.ShowToast(this, "Please enable your internet connection !");
                }
            }
            else
            {
                Utils.Utils.ShowToast(this, "Invalid Email. Please Login Again !");
            }
        }
Exemplo n.º 10
0
    private void Start()
    {
        audioHandler      = GetComponentInChildren <AudioHandler>();
        dataHandler       = GetComponentInChildren <DataHandler>();
        objectHandler     = GetComponentInChildren <ObjectHandler>();
        errorHandler      = GetComponentInChildren <ErrorHandler>();
        networkHandler    = GetComponentInChildren <NetworkHandler>();
        preferenceHandler = GetComponentInChildren <PreferenceHandler>();
        languageHandler   = GetComponentInChildren <LanguageHandler>();

        screenHandler = GetComponentInChildren <ScreenHandler>();

        // Do the objectserching
        screenHandler.EnableAll();
        objectHandler.Initialize();
        languageHandler.Initialize();
        screenHandler.DisableAll();

        if (preferenceHandler.GetUsername() == "")
        {
            screenHandler.OpenPreferences();
        }
        else
        {
            screenHandler.OpenMainMenu();
        }
    }
Exemplo n.º 11
0
        public void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
        {
            RunOnUiThread(() =>
            {
                if (!string.IsNullOrEmpty(Encoding.UTF8.GetString(e.Message)))
                {
                    try
                    {
                        layoutProgress.Visibility = ViewStates.Visible;
                        int stage = Convert.ToInt32(JsonConvert.DeserializeObject <DemoState>(Encoding.UTF8.GetString(e.Message)).State);
                        Utils.Utils.CurrentStage = (DemoStage)stage;
                        if (PreferenceHandler.GetUserDetails().RoleId == (int)USER_ROLE.ADMIN)
                        {
                            StartActivity(new Intent(Application.Context, typeof(AdminDashboardActivity)));
                            Finish();
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            });

            //Utils.Utils.ShowDialog(this, CurrentStage.ToString());
        }
        private void PopulateModel(UserModel userModel, UserEntity user, UserProfileEntity userProfile)
        {
            userModel.Religions      = SelectListGenerator.GetSelectedReligions(userProfile);
            userModel.Statuses       = SelectListGenerator.GetSelectedStatuses(userProfile);
            userModel.Orientations   = SelectListGenerator.GetSelectedOrientations(userProfile);
            userModel.Genders        = SelectListGenerator.GetSelectedGenders(userProfile);
            userModel.Email          = user.UserEmail;
            userModel.UserName       = user.UserUsername;
            userModel.Description    = string.IsNullOrWhiteSpace(userProfile.UserProfileDescription) ? "" : userProfile.UserProfileDescription;
            userModel.Phone          = string.IsNullOrWhiteSpace(userProfile.UserProfilePhone) ? "" : userProfile.UserProfilePhone;
            userModel.Job            = string.IsNullOrWhiteSpace(userProfile.UserProfileJob) ? "" : userProfile.UserProfileJob;
            userModel.Name           = userProfile.UserProfileName;
            userModel.Surname        = userProfile.UserProfileSurname;
            userModel.ReligionId     = userProfile.ReligionId;
            userModel.StatusId       = userProfile.StatusId;
            userModel.OrientationId  = userProfile.OrientationId;
            userModel.GenderId       = userProfile.GenderId;
            userModel.Age            = AgeCalculator.GetDifferenceInYears(userProfile.UserProfileBirthday, DateTime.Now);
            userModel.Birthday       = userProfile.UserProfileBirthday;
            userModel.BirthdayString = DateFormatter.GetDate(userProfile.UserProfileBirthday);
            userModel.Starsign       = StarsignCalculator.GetStarsignName(userProfile.UserProfileBirthday);
            userModel.Motto          = string.IsNullOrWhiteSpace(userProfile.Motto) ? "" : userProfile.Motto;

            var prefHandler = new PreferenceHandler();

            userModel.LikesList    = prefHandler.GetAllForUserProfile(userProfile.UserProfileId, true).Entity.ToList();
            userModel.DislikesList = prefHandler.GetAllForUserProfile(userProfile.UserProfileId, false).Entity.ToList();
        }
Exemplo n.º 13
0
        private async void GetCurrentUserResponse(HttpResponseMessage responseUser)
        {
            if (responseUser != null && responseUser.StatusCode == System.Net.HttpStatusCode.OK && responseUser.Content != null)
            {
                string strContent = await responseUser.Content.ReadAsStringAsync();

                UserDetails user = JsonConvert.DeserializeObject <UserDetails>(strContent);
                PreferenceHandler.SaveUserDetails(user);
                CreateDashboard();
            }
        }
Exemplo n.º 14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //preferenceHandler = new PreferenceHandler();
            var menuController = (MyMenuController)Storyboard.InstantiateViewController("MyMenuController");

            // create a slideout navigation controller with the top navigation controller and the menu view controller
            NavController = new NavController();
            Boolean     IsLogged   = PreferenceHandler.IsLoggedIn();
            UserDetails userDetail = PreferenceHandler.GetUserDetails();

            if (string.IsNullOrEmpty(PreferenceHandler.GetDomainKey()))
            {
                var ConfigurationController = Storyboard.InstantiateViewController("ConfigurationController") as ConfigurationController;
                NavController.PushViewController(ConfigurationController, true);
            }
            else
            {
                InvokeApi.SetDomainUrl(PreferenceHandler.GetDomainKey());
                if (string.IsNullOrEmpty(PreferenceHandler.GetConfig()))
                {
                    var ConfigurationController = Storyboard.InstantiateViewController("ConfigurationController") as ConfigurationController;
                    NavController.PushViewController(ConfigurationController, true);
                }
                else
                {
                    var config = JsonConvert.DeserializeObject <B2CConfiguration>(PreferenceHandler.GetConfig());
                    B2CConfigManager.GetInstance().Initialize(config);
                    if (IsLogged)
                    {
                        if (userDetail.RoleId == 2)
                        {
                            var FeedbackViewController = Storyboard.InstantiateViewController("FeedbackViewController") as FeedbackViewController;
                            NavController.PushViewController(FeedbackViewController, false);
                        }
                        else
                        {
                            var MapViewController = (MapViewController)Storyboard.InstantiateViewController("MapViewController");
                            NavController.PushViewController(MapViewController, false);
                        }
                    }
                    else
                    {
                        var ViewController = (ViewController)Storyboard.InstantiateViewController("ViewController");
                        NavController.PushViewController(ViewController, false);
                    }
                }
            }
            SidebarController                = new SidebarNavigation.SidebarController(this, NavController, menuController);
            SidebarController.MenuWidth      = (IsLogged ? 250 : 0);
            SidebarController.ReopenOnRotate = false;
            SidebarController.MenuLocation   = SidebarNavigation.MenuLocations.Left;
        }
Exemplo n.º 15
0
        protected override void OnResume()
        {
            base.OnResume();

            Task startupWork = new Task(() =>
            {
                Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
                Task.Delay(3000);  // Simulate a bit of startup work.
                Log.Debug(TAG, "Working in the background - important stuff.");
            });

            startupWork.ContinueWith(async t =>
            {
                Log.Debug(TAG, "Work is finished.");


                if (string.IsNullOrEmpty(PreferenceHandler.GetDomainKey()))
                {
                    StartActivity(new Intent(Application.Context, typeof(ConfigActivity)));
                    Finish();
                }
                else
                {
                    InvokeApi.SetDomainUrl(PreferenceHandler.GetDomainKey());
                    if (string.IsNullOrEmpty(PreferenceHandler.GetConfig()))
                    {
                        StartActivity(new Intent(Application.Context, typeof(ConfigActivity)));
                        Finish();
                    }
                    else
                    {
                        var config = JsonConvert.DeserializeObject <B2CConfiguration>(PreferenceHandler.GetConfig());
                        B2CConfigManager.GetInstance().Initialize(config);
                        if (PreferenceHandler.IsLoggedIn())
                        {
                            await Utils.Utils.RefreshToken(this);
                            Intent intent = new Intent(Application.Context, typeof(AdminDashboardActivity));
                            intent.PutExtra(MainActivity.KEY_USER_ROLE, (int)Constants.USER_ROLE.ADMIN);
                            StartActivity(intent);
                            Finish();
                        }
                        else
                        {
                            StartActivity(new Intent(Application.Context, typeof(LoginActivity)));
                            Finish();
                        }
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            startupWork.Start();
        }
Exemplo n.º 16
0
        private void IncrementNotificationCount()
        {
            //PreferenceHandler prefs = new PreferenceHandler();
            int count = PreferenceHandler.getUnreadNotificationCount();

            PreferenceHandler.setUnreadNotificationCount(count + 1);

            Intent message = new Intent(Utils.Utils.ALERT_BROADCAST);

            //Android.Support.V4.Content.LocalBroadcastManager.GetInstance(this).SendBroadcast(message);

            SendBroadcast(message);
        }
Exemplo n.º 17
0
 private void Logout(LogoutModel logoutModel)
 {
     layoutProgress.Visibility = ViewStates.Visible;
     Log.Debug(TAG, "Local Logout Started");
     PreferenceHandler.setLoggedIn(false);
     PreferenceHandler.SetToken(string.Empty);
     PreferenceHandler.SetRefreshToken(string.Empty);
     PreferenceHandler.SaveUserDetails(new UserDetails());
     CookieManager.Instance.RemoveAllCookie();
     StartActivity(new Intent(Application.Context, typeof(LoginActivity)));
     Finish();
     layoutProgress.Visibility = ViewStates.Gone;
 }
        private async void GetCurrentUserResponse(HttpResponseMessage responseUser, WebView view)
        {
            if (responseUser != null && responseUser.StatusCode == System.Net.HttpStatusCode.OK && responseUser.Content != null)
            {
                string strContent = await responseUser.Content.ReadAsStringAsync();

                UserDetails user = JsonConvert.DeserializeObject <UserDetails>(strContent);
                PreferenceHandler.SaveUserDetails(user);
                Intent intent = new Intent(Application.Context, typeof(AdminDashboardActivity));
                intent.PutExtra(MainActivity.KEY_USER_ROLE, (int)Constants.USER_ROLE.STUDENT);
                view.Context.StartActivity(intent);
                layoutProgress.Visibility = ViewStates.Gone;
            }
        }
Exemplo n.º 19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Login_view);
            if (string.IsNullOrEmpty(PreferenceHandler.GetConfig()))
            {
                StartActivity(new Intent(Application.Context, typeof(ConfigActivity)));
                Finish();
            }

            buttonSignIn            = FindViewById <Button>(Resource.Id.SignInButton);
            buttonSignUp            = FindViewById <Button>(Resource.Id.SignUpButton);
            progressBar             = FindViewById <ProgressBar>(Resource.Id.progressBar);
            tvForgotPassword        = FindViewById <TextView>(Resource.Id.textViewForgotPassword);
            progressBar.Visibility  = ViewStates.Gone;
            tvForgotPassword.Click += delegate
            {
                Log.Debug(TAG, "ForgotPassword()");
                if (!Utils.Utils.IsNetworkEnabled(this))
                {
                    RunOnUiThread(() =>
                    {
                        Utils.Utils.ShowDialog(this, "Internet not available.");
                    });
                }
                else
                {
                    StartActivity(new Intent(Application.Context, typeof(ForgotPasswordActivity)));
                }
            };
            buttonSignIn.Click += delegate
            {
                Log.Debug(TAG, "Login()");
                if (!Utils.Utils.IsNetworkEnabled(this))
                {
                    RunOnUiThread(() =>
                    {
                        Utils.Utils.ShowDialog(this, "Internet not available.");
                    });
                }
                else
                {
                    Intent intent = new Intent(Application.Context, typeof(LoginNewActivity));
                    intent.PutExtra(LoginNewActivity.KEY_SHOW_PAGE, (int)SignInType.SIGN_IN);
                    StartActivity(intent);
                    Finish();
                }
            };
            buttonSignUp.Click += ButtonSignUp_Click;
        }
Exemplo n.º 20
0
 private void DashboardButton_TouchUpInside(object sender, EventArgs e)
 {
     if (PreferenceHandler.GetUserDetails().RoleId == 1)
     {
         var MapViewController = (MapViewController)Storyboard.InstantiateViewController("MapViewController");
         NavController.PushViewController(MapViewController, true);
     }
     else
     {
         FeedbackViewController FeedbackView = this.Storyboard.InstantiateViewController("FeedbackViewController") as FeedbackViewController;
         FeedbackView.NavigationItem.SetHidesBackButton(true, false);
         this.NavController.PushViewController(FeedbackView, true);
     }
     SidebarController.CloseMenu();
 }
Exemplo n.º 21
0
        private async void Acknowledge_TouchUpInside(object sender, EventArgs e)
        {
            var selectedRow = Acknowledge.Tag;
            var subView     = (UILabel)ContentView.Subviews[0];
            var superView   = Acknowledge.Superview;
            //var preferenceHandler = new PreferenceHandler();
            UserDetails           userDetails = PreferenceHandler.GetUserDetails();
            int                   userId      = userDetails.UserId;
            AlertAcknowledgeModel ackModel    = new AlertAcknowledgeModel();

            ackModel.Alert_Id        = Convert.ToInt32(subView.Text);
            ackModel.Acknowledged_By = userDetails.FirstName + " " + userDetails.LastName;

            var response = await InvokeApi.Invoke(Constants.API_ACKNOWLWDGE_ALERTS, JsonConvert.SerializeObject(ackModel), HttpMethod.Put, PreferenceHandler.GetToken());
        }
Exemplo n.º 22
0
        private async void GetCurrentUserResponse(HttpResponseMessage responseUser)
        {
            if (responseUser != null && responseUser.StatusCode == System.Net.HttpStatusCode.OK && responseUser.Content != null)
            {
                string strContent = await responseUser.Content.ReadAsStringAsync();

                UserDetails user = JsonConvert.DeserializeObject <UserDetails>(strContent);
                PreferenceHandler.SaveUserDetails(user);
                ShowDashboard(user);
            }
            else
            {
                IOSUtil.ShowMessage("User details not found", loadingOverlay, this);
            }
        }
Exemplo n.º 23
0
        private async void GetCurrentUserResponse(HttpResponseMessage responseUser)
        {
            if (responseUser != null && responseUser.StatusCode == System.Net.HttpStatusCode.OK && responseUser.Content != null)
            {
                string strContent = await responseUser.Content.ReadAsStringAsync();

                UserDetails user = JsonConvert.DeserializeObject <UserDetails>(strContent);
                // var preferenceHandler = new PreferenceHandler();
                PreferenceHandler.SaveUserDetails(user);
            }
            else
            {
                Utils.Utils.ShowToast(Application.Context, "User details not found!");
            }
        }
        private void SaveUserData(UserDetails userDetails)
        {
            //store data in preferences

            //PreferenceHandler preferenceHandler = new PreferenceHandler();
            PreferenceHandler.SaveUserDetails(userDetails);
            if (userDetails.RoleId == 2)
            {
                ShowClassRooms();
            }
            else
            {
                ShowMap();
            }
        }
Exemplo n.º 25
0
 protected override void OnResume()
 {
     base.OnResume();
     if (IsDemoMode)
     {
         RegisterReceiver(receiver, new IntentFilter(Utils.Utils.ALERT_BROADCAST_DEMO));
     }
     else
     {
         RegisterReceiver(receiver, new IntentFilter(Utils.Utils.ALERT_BROADCAST));
     }
     if (PreferenceHandler.GetUserDetails().RoleId == (int)Constants.USER_ROLE.ADMIN)
     {
         setNotificationCount();
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.NavigationController.NavigationBarHidden        = false;
            this.NavigationController.NavigationBar.TintColor    = UIColor.White;
            this.NavigationController.NavigationBar.BarTintColor = IOSUtil.PrimaryColor;
            this.NavigationController.NavigationBar.BarStyle     = UIBarStyle.BlackTranslucent;
            try
            {
                if (IOSUtil.CurrentStage == DemoStage.None && IsDemoMode)
                {
                    IOSUtil.CurrentStage = DemoStage.Yesterday;
                    client = new MqttClient(Constants.MqttServer);
                    SubscribeMQTT();
                }
            }
            catch (Exception e)
            {
            }
            userdetail = PreferenceHandler.GetUserDetails();
            lblHeader  = new UILabel()
            {
                Frame           = new CGRect(0, this.NavigationController.NavigationBar.Bounds.Bottom + 20, View.Bounds.Width, 40),
                Text            = "Premises",
                Font            = UIFont.FromName("Futura-Medium", 15f),
                TextColor       = UIColor.White,
                BackgroundColor = IOSUtil.PrimaryColor,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Lines           = 1,
                TextAlignment   = UITextAlignment.Center
            };

            btnBack = new UIButton()
            {
                Frame           = new CGRect(0, this.NavigationController.NavigationBar.Bounds.Bottom + 20, 80, 40),
                Font            = UIFont.FromName("Futura-Medium", 15f),
                BackgroundColor = IOSUtil.PrimaryColor,
            };
            btnBack.SetTitle("< BACK", UIControlState.Normal);
            btnBack.SetTitleColor(UIColor.White, UIControlState.Normal);
            btnBack.SetTitleShadowColor(IOSUtil.PrimaryColor, UIControlState.Normal);
            btnBack.TouchUpInside += BtnBack_TouchUpInside;
            btnBack.Hidden         = true;
            View.AddSubviews(lblHeader, btnBack);
            GetConsumptionDetails(CurrentConsumption, 0);
        }
Exemplo n.º 27
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            View.BackgroundColor = UIColor.FromRGB(0, 102, 153);
            NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(UIImage.FromBundle("a")
                                    , UIBarButtonItemStyle.Plain
                                    , (sender, args) =>
            {
                SidebarController.ToggleMenu();
            }), true);

            SelectedAnswer = -1;
            //prefHandler = new Utils.PreferenceHandler();
            userdetail = PreferenceHandler.GetUserDetails();
            GetQuestionView();
        }
Exemplo n.º 28
0
        private async void SubmitButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textConfigURL.Text))
            {
                Utils.Utils.ShowToast(this, "Enter Server Url.");
            }
            else
            {
                string domain = textConfigURL.Text;
                PreferenceHandler.SetDomainKey(domain);
                InvokeApi.SetDomainUrl(domain);
                ProgressDialog dialog = new ProgressDialog(this);
                dialog.SetTitle("Loading...");
                dialog.Show();
                var response = await InvokeApi.Invoke(Constants.API_GET_MOBILE_CONFIGURATION, string.Empty, HttpMethod.Get);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    string strContent = await response.Content.ReadAsStringAsync();

                    var config = JsonConvert.DeserializeObject <B2CConfiguration>(strContent);
                    dialog.Dismiss();
                    if (string.IsNullOrEmpty(config.B2cAuthorizeURL) || string.IsNullOrEmpty(config.B2cChangePasswordPolicy) || string.IsNullOrEmpty(config.B2cChangePasswordURL) || string.IsNullOrEmpty(config.B2cClientId) ||
                        string.IsNullOrEmpty(config.B2cClientSecret) || string.IsNullOrEmpty(config.B2cRedirectUrl) || string.IsNullOrEmpty(config.B2cSignInPolicy) || string.IsNullOrEmpty(config.B2cSignUpPolicy) ||
                        string.IsNullOrEmpty(config.B2cTenant) || string.IsNullOrEmpty(config.B2cTokenURL) || string.IsNullOrEmpty(config.B2cTokenURLIOS))
                    {
                        Utils.Utils.ShowToast(this, "Invalid Configuration details");
                    }
                    else
                    {
                        B2CConfigManager.GetInstance().Initialize(config);
                        PreferenceHandler.SetConfig(strContent);
                        Intent intent = new Intent(Application.Context, typeof(LoginActivity));
                        StartActivity(intent);
                        Finish();
                    }
                }
                else
                {
                    Utils.Utils.ShowToast(this, response.ReasonPhrase);
                    dialog.Dismiss();
                }
            }
        }
Exemplo n.º 29
0
        public ActionResult AddPreference(string name, int id, bool like)
        {
            try
            {
                LoginHelper.CheckAccess(Session);
            }
            catch (Exception)
            {
                return(RedirectToAction("Login", "Login"));
            }

            var handler = new PreferenceHandler();
            int prefId  = id;

            //new preference => add it to preferences table
            if (id == 0)
            {
                var entity = new PreferenceEntity
                {
                    Name = name.First().ToString().ToUpper() + name.Substring(1)
                };

                var prefResponse = handler.Add(entity);

                if (!prefResponse.CompletedRequest)
                {
                    return(RedirectToAction("Index", "Error", new { errorMessage = prefResponse.ErrorMessage.Replace(' ', '-') }));
                }

                prefId = prefResponse.Entity.Id;
            }

            //add to user's preferences
            int userProfileId = (int)Session["userProfileId"];
            var response      = handler.AddForUser(prefId, userProfileId, like);

            if (!response.CompletedRequest)
            {
                return(RedirectToAction("Index", "Error", new { errorMessage = response.ErrorMessage.Replace(' ', '-') }));
            }

            return(Content(prefId.ToString()));
        }
        public async Task GetRooms()
        {
            var bounds = UIScreen.MainScreen.Bounds;

            // show the loading overlay on the UI thread using the correct orientation sizing
            loadingOverlay = new LoadingOverlay(bounds);
            View.Add(loadingOverlay);
            UserDetails userDetail = PreferenceHandler.GetUserDetails();
            var         response   = await InvokeApi.Invoke(Constants.API_GET_ALL_ROOMS, string.Empty, HttpMethod.Get, PreferenceHandler.GetToken());

            if (response.StatusCode != 0)
            {
                InvokeOnMainThread(() =>
                {
                    CheckClassRoomsResponse(response);
                    loadingOverlay.Hide();
                });
            }
        }