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 !");
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
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 !");
                }
            }
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
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);

            //});
        }
Ejemplo 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;
     }
 }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
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();
 }
Ejemplo n.º 10
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());
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 13
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();
        }
        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();
                });
            }
        }
Ejemplo n.º 15
0
        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;

            meterName         = Intent.GetStringExtra(KEY_METER_NAME) ?? "Meter";
            meterSerialNumber = Intent.GetStringExtra(KEY_METER_SERIAL) ?? null;

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

                //var preferenceHandler = new PreferenceHandler();
                int userId = PreferenceHandler.GetUserDetails().UserId;
                if (userId != -1)
                {
                    bool isNetworkEnabled = Utils.Utils.IsNetworkEnabled(this);
                    if (isNetworkEnabled)
                    {
                        getMeterReports(userId, meterSerialNumber);
                    }
                    else
                    {
                        Utils.Utils.ShowToast(this, "Please enable your internet connection !");
                    }
                }
                else
                {
                    Utils.Utils.ShowToast(this, "Invalid User Id. Please Login Again !");
                }
            }
        }
        public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action <UNNotificationPresentationOptions> completionHandler)
        {
            // Do your magic to handle the notification data
            Console.WriteLine("WillPresentNotification gaurav 1 val");

            //PreferenceHandler prefsHandler = new PreferenceHandler();
            if (PreferenceHandler.IsLoggedIn())
            {
                int roleId = PreferenceHandler.GetUserDetails().RoleId;
                if (roleId == (int)EM_PORTABLE.Utils.Constants.USER_ROLE.ADMIN)
                {
                    BTProgressHUD.ForceiOS6LookAndFeel = true;
                    BTProgressHUD.ShowToast("New Alert Received !", true, 2000.0);
                }
            }
            //UIApplication.SharedApplication.ApplicationIconBadgeNumber++;
            //UserDetails userDT = prefsHandler.GetUserDetails();

            //UIApplication.SharedApplication.ApplicationIconBadgeNumber = UIApplication.SharedApplication.ApplicationIconBadgeNumber + 1;
        }
Ejemplo n.º 17
0
 public override bool OnCreateOptionsMenu(IMenu menu)
 {
     //optionsMenu = menu;
     MenuInflater.Inflate(Resource.Menu.main_menu, menu);
     if (PreferenceHandler.GetUserDetails().RoleId == (int)Constants.USER_ROLE.STUDENT)
     {
         menu.GetItem(0).SetVisible(false);
     }
     else
     {
         RelativeLayout alertItem = (RelativeLayout)(menu.FindItem(Resource.Id.alerts).ActionView);
         alertItem.Click += delegate
         {
             showAlerts();
         };
         notifCount = alertItem.FindViewById <TextView>(Resource.Id.notif_count);
         setNotificationCount();
     }
     return(base.OnPrepareOptionsMenu(menu));
 }
Ejemplo n.º 18
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.insights);

            textViewLoading            = FindViewById <TextView>(Resource.Id.textViewLoading);
            textViewLoading.Visibility = ViewStates.Gone;
            layoutProgress             = FindViewById <LinearLayout>(Resource.Id.layout_progress);
            layoutProgress.Visibility  = ViewStates.Visible;

            LayoutInsightData = FindViewById <LinearLayout>(Resource.Id.layout_insight_data);
            textViewConsumed  = FindViewById <TextView>(Resource.Id.tv_top_consumed);
            textViewExpected  = FindViewById <TextView>(Resource.Id.tv_top_expected);
            textViewOverused  = FindViewById <TextView>(Resource.Id.tv_top_overused);

            int userId = PreferenceHandler.GetUserDetails().UserId;

            if (userId != -1)
            {
                bool isNetworkEnabled = Utils.Utils.IsNetworkEnabled(this);
                if (isNetworkEnabled)
                {
                    ShowInsights(null);
                    GetInsights(userId);
                    GetRecommendationsList(userId);
                }
                else
                {
                    Utils.Utils.ShowToast(this, "Please enable your internet connection !");
                    layoutProgress.Visibility  = ViewStates.Gone;
                    textViewLoading.Visibility = ViewStates.Visible;
                }
            }
            else
            {
                Utils.Utils.ShowToast(this, "Invalid User Id. Please Login Again !");
                layoutProgress.Visibility  = ViewStates.Gone;
                textViewLoading.Visibility = ViewStates.Visible;
            }
        }
 public void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
 {
     InvokeOnMainThread(() =>
     {
         try
         {
             if (!string.IsNullOrEmpty(Encoding.UTF8.GetString(e.Message)))
             {
                 int stage            = Convert.ToInt32(JsonConvert.DeserializeObject <DemoState>(Encoding.UTF8.GetString(e.Message)).State);
                 IOSUtil.CurrentStage = (DemoStage)stage;
                 if (PreferenceHandler.GetUserDetails().RoleId == (int)USER_ROLE.ADMIN)
                 {
                     var MapViewController = (MapViewController)Storyboard.InstantiateViewController("MapViewController");
                     NavController.PushViewController(MapViewController, false);
                 }
                 SidebarController.CloseMenu();
             }
         }
         catch (Exception)
         {
         }
     });
 }
Ejemplo n.º 20
0
        public override void OnMessageReceived(RemoteMessage message)
        {
            try
            {
                Log.Debug(TAG, "From: " + message.From);
                Log.Debug(TAG, "Notification Message Body: " + message.GetNotification().Body);

                //var preferenceHandler = new PreferenceHandler();
                bool isLoggedIn = PreferenceHandler.IsLoggedIn();
                if (isLoggedIn)
                {
                    int roleId = PreferenceHandler.GetUserDetails().RoleId;
                    if (roleId == (int)EM_PORTABLE.Utils.Constants.USER_ROLE.ADMIN)
                    {
                        SendNotification(message.GetNotification().Body);
                        IncrementNotificationCount();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Debug(TAG, e.Message);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

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

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

            View.AddSubview(webView);
            showContentOnWebView(body);

            //var preferenceHandler = new PreferenceHandler();
            int userId = PreferenceHandler.GetUserDetails().UserId;

            if (userId != -1)
            {
                getReports();
            }
            else
            {
                IOSUtil.ShowAlert("Invalid Email. Please Login Again !");
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AlertsView);

            textViewLoading            = FindViewById <TextView>(Resource.Id.textViewLoading);
            textViewLoading.Visibility = ViewStates.Gone;
            layoutProgress             = FindViewById <LinearLayout>(Resource.Id.layout_progress);
            layoutProgress.Visibility  = ViewStates.Visible;

            int userId = PreferenceHandler.GetUserDetails().UserId;

            if (userId != -1)
            {
                bool isNetworkEnabled = Utils.Utils.IsNetworkEnabled(this);
                if (isNetworkEnabled)
                {
                    GetAlertList(userId);
                }
                else
                {
                    Utils.Utils.ShowToast(this, "Please enable your internet connection !");
                    layoutProgress.Visibility  = ViewStates.Gone;
                    textViewLoading.Visibility = ViewStates.Visible;
                }
            }
            else
            {
                Utils.Utils.ShowToast(this, "Invalid User Id. Please Login Again !");
                layoutProgress.Visibility  = ViewStates.Gone;
                textViewLoading.Visibility = ViewStates.Visible;
            }

            ResetNotificationCount();
        }
Ejemplo n.º 23
0
        public async void CreateDashboard()
        {
            //var preferenceHandler = new PreferenceHandler();
            //string code = preferenceHandler.GetAccessCode();
            //string tokenURL = string.Format(B2CConfig.TokenURL, B2CConfig.Tenant, B2CPolicy.SignInPolicyId, B2CConfig.Grant_type, B2CConfig.ClientSecret, B2CConfig.ClientId, code);
            //var response = await InvokeApi.Authenticate(tokenURL, string.Empty, HttpMethod.Post);
            //if (response.StatusCode == System.Net.HttpStatusCode.OK)
            //{
            //    string strContent = await response.Content.ReadAsStringAsync();
            //    var token = JsonConvert.DeserializeObject<AccessToken>(strContent);

            //    // string strRefreshToken = "access&refresh_token=AwABAAAAvPM1KaPlrEqdFSBzjqfTGBCmLdgfSTLEMPGYuNHSUYBrq...&redirect_uri=urn:ietf:wg:oauth:2.0:oob";
            //    string strRefreshToken = "https://login.microsoftonline.com/csub2c.onmicrosoft.com/oauth2/v2.0/token?p=b2c_1_b2csignin&grant_type=refresh_token&client_id=3bdf8223-746c-42a2-ba5e-0322bfd9ff76&scope=3bdf8223-746c-42a2-ba5e-0322bfd9ff76" + " " + "offline_access&refresh_token=" + token.id_token + "&redirect_uri=urn:ietf:wg:oauth:2.0:oob";
            //    var res = await InvokeApi.Authenticate(strRefreshToken, string.Empty, HttpMethod.Post);

            //    string strRefreshToken1 = "https://login.microsoftonline.com/csub2c.onmicrosoft.com/oauth2/v2.0/token?p=b2c_1_b2csignin&grant_type=refresh_token&client_id=3bdf8223-746c-42a2-ba5e-0322bfd9ff76&scope=3bdf8223-746c-42a2-ba5e-0322bfd9ff76" + " " + "offline_access&refresh_token=" + code + "&redirect_uri=urn:ietf:wg:oauth:2.0:oob";
            //    var res1 = await InvokeApi.Authenticate(strRefreshToken1, string.Empty, HttpMethod.Post);

            //    preferenceHandler.SetToken(token.id_token);
            var responseUser = await InvokeApi.Invoke(Constants.API_GET_CURRENTUSER, string.Empty, HttpMethod.Get, PreferenceHandler.GetToken());

            if (responseUser.StatusCode != 0)
            {
                GetCurrentUserResponse(responseUser);
            }
            UserDetails user = PreferenceHandler.GetUserDetails();

            if (user.RoleId == (int)Constants.USER_ROLE.ADMIN)
            {
                bool isNetworkEnabled = Utils.Utils.IsNetworkEnabled(this);

                LayoutInsightData = FindViewById <LinearLayout>(Resource.Id.layout_insight_data);
                textViewConsumed  = FindViewById <TextView>(Resource.Id.tv_top_consumed);
                textViewExpected  = FindViewById <TextView>(Resource.Id.tv_top_expected);
                textViewOverused  = FindViewById <TextView>(Resource.Id.tv_top_overused);
                textViewInsights  = FindViewById <TextView>(Resource.Id.tv_insights);

                textViewInsights.Click += delegate
                {
                    // Show insights(Recommendations) Activity
                    Intent intent = new Intent(Application.Context, typeof(InsightsActivity));
                    StartActivity(intent);
                };

                if (!isNetworkEnabled)
                {
                    Utils.Utils.ShowToast(this, "Please enable your internet connection !");
                    //ShowToast("Please enable your internet connection !");
                }
                ////Show Map Fragment
                //GoogleMapOptions mapOptions = new GoogleMapOptions()
                //.InvokeMapType(GoogleMap.MapTypeNormal)
                //.InvokeZoomControlsEnabled(false)
                //.InvokeCompassEnabled(true);

                //_myMapFragment = MapFragment.NewInstance(mapOptions);
                //FragmentTransaction tx = FragmentManager.BeginTransaction();
                //tx.Add(Resource.Id.fragment_container, _myMapFragment, "map");
                //tx.Commit();

                //_myMapFragment.GetMapAsync(this);

                //var preferenceHandler = new PreferenceHandler();
                int userId = PreferenceHandler.GetUserDetails().UserId;
                if (userId != -1)
                {
                    if (isNetworkEnabled)
                    {
                        GetMeterDetails(userId);
                        GetMonthlyConsumptionDetails(userId);
                        ShowInsights(null);
                        GetInsights(userId);
                    }
                    else
                    {
                        Utils.Utils.ShowToast(this, "Please enable your internet connection !");
                    }
                }
                else
                {
                    Utils.Utils.ShowToast(this, "Invalid User Id. Please Login Again !");
                }
            }
            else
            {
                //Show Student Fragment

                var newFragment = new StudentFragment();
                var ft          = FragmentManager.BeginTransaction();
                ft.Add(Resource.Id.fragment_container, newFragment);
                ft.Commit();
                HideInsights();
            }
            // }
        }
Ejemplo n.º 24
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.student_dashboard, container, false);

            view.SetBackgroundColor(Utils.Utils.PrimaryColor);
            textViewInfo            = view.FindViewById <TextView>(Resource.Id.textViewInfo);
            layoutProgress          = view.FindViewById <LinearLayout>(Resource.Id.layout_progress);
            layoutSelectClassroom   = view.FindViewById <LinearLayout>(Resource.Id.layout_select_classroom);
            layoutSelectTemperature = view.FindViewById <LinearLayout>(Resource.Id.layout_select_temperature);
            layoutSubmit            = view.FindViewById <LinearLayout>(Resource.Id.layout_submit);

            textViewQuestion            = view.FindViewById <TextView>(Resource.Id.textViewQuestion);
            textViewQuestionDescription = view.FindViewById <TextView>(Resource.Id.textViewQuestionDescription);
            textViewProgressMessage     = view.FindViewById <TextView>(Resource.Id.textView_progressMessage);
            textViewSelectedClass       = view.FindViewById <TextView>(Resource.Id.textView_selectedClass);
            textViewTooHot  = view.FindViewById <TextView>(Resource.Id.textView_tooHot);
            textViewHot     = view.FindViewById <TextView>(Resource.Id.textView_hot);
            textViewNormal  = view.FindViewById <TextView>(Resource.Id.textView_feelingNormal);
            textViewCold    = view.FindViewById <TextView>(Resource.Id.textView_cold);
            textViewTooCold = view.FindViewById <TextView>(Resource.Id.textView_tooCold);
            buttonNext      = view.FindViewById <ImageView>(Resource.Id.buttonNext);
            buttonBack      = view.FindViewById <ImageView>(Resource.Id.buttonBack);
            buttonSubmit    = view.FindViewById <ImageView>(Resource.Id.buttonSubmit);
            buttonDone      = view.FindViewById <Button>(Resource.Id.buttonDone);

            textViewTooHot.Alpha  = 0.5f;
            textViewHot.Alpha     = 0.5f;
            textViewNormal.Alpha  = 0.5f;
            textViewCold.Alpha    = 0.5f;
            textViewTooCold.Alpha = 0.5f;

            try
            {
                if (Utils.Utils.CurrentStage == DemoStage.None && Constants.IsDemoMode)
                {
                    Utils.Utils.CurrentStage = DemoStage.Yesterday;
                    client = new MqttClient(Constants.MqttServer);
                    SubscribeMQTT();
                }
            }
            catch (Exception)
            {
            }


            textViewTooHot.Click += delegate
            {
                selectedAnswer   = "Too Hot";
                selectedAnswerId = (int)textViewTooHot.Tag;

                textViewTooHot.Alpha  = 1f;
                textViewHot.Alpha     = 0.5f;
                textViewNormal.Alpha  = 0.5f;
                textViewCold.Alpha    = 0.5f;
                textViewTooCold.Alpha = 0.5f;

                layoutSelectTemperature.SetBackgroundColor(Utils.Utils.VeryHot);
                view.SetBackgroundColor(Utils.Utils.VeryHot);
            };
            textViewHot.Click += delegate
            {
                selectedAnswer   = "Hot";
                selectedAnswerId = (int)textViewHot.Tag;

                textViewTooHot.Alpha  = 0.5f;
                textViewHot.Alpha     = 1.0f;
                textViewNormal.Alpha  = 0.5f;
                textViewCold.Alpha    = 0.5f;
                textViewTooCold.Alpha = 0.5f;

                layoutSelectTemperature.SetBackgroundColor(Utils.Utils.Hot);
                view.SetBackgroundColor(Utils.Utils.Hot);
            };
            textViewNormal.Click += delegate
            {
                selectedAnswer   = "Feeling Normal";
                selectedAnswerId = (int)textViewNormal.Tag;

                textViewTooHot.Alpha  = 0.5f;
                textViewHot.Alpha     = 0.5f;
                textViewNormal.Alpha  = 1f;
                textViewCold.Alpha    = 0.5f;
                textViewTooCold.Alpha = 0.5f;

                layoutSelectTemperature.SetBackgroundColor(Utils.Utils.Normal);
                view.SetBackgroundColor(Utils.Utils.Normal);
            };
            textViewCold.Click += delegate
            {
                selectedAnswer   = "Cold";
                selectedAnswerId = (int)textViewCold.Tag;

                textViewTooHot.Alpha  = 0.5f;
                textViewHot.Alpha     = 0.5f;
                textViewNormal.Alpha  = 0.5f;
                textViewCold.Alpha    = 1f;
                textViewTooCold.Alpha = 0.5f;

                layoutSelectTemperature.SetBackgroundColor(Utils.Utils.Cold);
                view.SetBackgroundColor(Utils.Utils.Cold);
            };
            textViewTooCold.Click += delegate
            {
                selectedAnswer   = "Too Cold";
                selectedAnswerId = (int)textViewTooCold.Tag;

                textViewTooHot.Alpha  = 0.5f;
                textViewHot.Alpha     = 0.5f;
                textViewNormal.Alpha  = 0.5f;
                textViewCold.Alpha    = 0.5f;
                textViewTooCold.Alpha = 1f;

                layoutSelectTemperature.SetBackgroundColor(Utils.Utils.VeryCold);
                view.SetBackgroundColor(Utils.Utils.VeryCold);
            };
            buttonNext.Click += delegate
            {
                Log.Debug(TAG, "Next button click");
                if (selectedClass != null)
                {
                    showLayoutSelectTemperature();
                    ShowTemperatureQuestion();
                }
                else
                {
                    Utils.Utils.ShowToast(this.Context, "Please select a Room");
                }
            };
            buttonBack.Click += delegate
            {
                Log.Debug(TAG, "Back button click");
                ResetFeedback(view);
                showLayoutSelectClass();
            };
            buttonSubmit.Click += delegate
            {
                Log.Debug(TAG, "Submit button click");
                if (selectedAnswer != null)
                {
                    SelectedRoom = textViewSelectedClass.Text;
                    showLayoutSubmit();
                    submitFeedback(userId);
                    ResetFeedback(view);
                }
                else
                {
                    Utils.Utils.ShowToast(this.Context, "Please select an option");
                }
            };
            buttonDone.Click += delegate
            {
                Log.Debug(TAG, "Done button click");
                selectedClass              = null;
                selectedRoomId             = -1;
                textViewSelectedClass.Text = "";
                selectedAnswer             = null;
                showLayoutSelectClass();
            };

            showLayoutProgress("Loading...");
            mRecyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);

            userId = PreferenceHandler.GetUserDetails().UserId;
            if (userId != -1)
            {
                bool isNetworkEnabled = Utils.Utils.IsNetworkEnabled(this.Activity);
                if (isNetworkEnabled)
                {
                    getRoomList();
                }
                else
                {
                    Utils.Utils.ShowToast(this.Context, "Please enable your internet connection !");
                    showLayoutInfo();
                }
            }
            else
            {
                Utils.Utils.ShowToast(this.Context, "Invalid User Id. Please Login Again !");
                showLayoutInfo();
            }

            return(view);
        }
Ejemplo n.º 25
0
        public void GenerateMenu()
        {
            userdetail = PreferenceHandler.GetUserDetails();

            double profileRadius     = 100;
            double profileViewHeight = 230;

            UIView viewProfile = new UIView(new CGRect(0, 0, View.Bounds.Width, profileViewHeight));

            viewProfile.BackgroundColor = IOSUtil.PrimaryColor;

            UIImageView imgProfile = new UIImageView()
            {
                Frame = new CGRect(125 - (profileRadius / 2), 40, profileRadius, profileRadius),
                Image = UIImage.FromBundle("logo.png"),
            };

            imgProfile.ClipsToBounds      = true;
            imgProfile.Layer.CornerRadius = (float)profileRadius / 2;
            imgProfile.Layer.BorderColor  = UIColor.Clear.CGColor;
            imgProfile.Layer.BorderWidth  = 2;



            UILabel lblProfileName = new UILabel()
            {
                Frame           = new CGRect(0, 140, 260, 50),
                Font            = UIFont.FromName("Futura-Medium", 20f),
                BackgroundColor = UIColor.Clear,
                TextAlignment   = UITextAlignment.Center,
                Text            = userdetail.FirstName + " " + userdetail.LastName,
                TextColor       = UIColor.White,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Lines           = 3,
            };

            UIButton LogOutButton = new UIButton()
            {
                Font            = UIFont.FromName("Futura-Medium", 14f),
                BackgroundColor = UIColor.Clear,
                Frame           = new CGRect(60, 190, 130, 25)
            };

            LogOutButton.SetTitle("Logout", UIControlState.Normal);
            LogOutButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            LogOutButton.SetTitleColor(UIColor.White, UIControlState.Selected);
            LogOutButton.Layer.BorderColor  = UIColor.White.CGColor;
            LogOutButton.Layer.BorderWidth  = 1f;
            LogOutButton.Layer.CornerRadius = 13;
            viewProfile.AddSubviews(lblProfileName, imgProfile, LogOutButton);



            UIButton DashboardButton = new UIButton()
            {
                Frame           = new CGRect(0, profileViewHeight, 250, 40),
                Font            = UIFont.FromName("Futura-Medium", 14f),
                BackgroundColor = UIColor.Clear,
            };

            DashboardButton.SetTitle("DASHBOARD", UIControlState.Normal);
            DashboardButton.SetTitleColor(UIColor.DarkTextColor, UIControlState.Normal);
            DashboardButton.SetTitleColor(IOSUtil.PrimaryColor, UIControlState.Selected);
            DashboardButton.BackgroundColor   = UIColor.LightTextColor;
            DashboardButton.VerticalAlignment = UIControlContentVerticalAlignment.Center;

            UIButton AlertsButton = new UIButton()
            {
                Font            = UIFont.FromName("Futura-Medium", 14f),
                BackgroundColor = UIColor.Clear
            };

            AlertsButton.SetTitle("ALERTS", UIControlState.Normal);
            AlertsButton.SetTitleColor(UIColor.DarkTextColor, UIControlState.Normal);
            AlertsButton.SetTitleColor(IOSUtil.PrimaryColor, UIControlState.Selected);

            UIButton InsightsButton = new UIButton()
            {
                Font            = UIFont.FromName("Futura-Medium", 14f),
                BackgroundColor = UIColor.Clear
            };

            InsightsButton.SetTitle("INSIGHTS", UIControlState.Normal);
            InsightsButton.SetTitleColor(UIColor.DarkTextColor, UIControlState.Normal);
            InsightsButton.SetTitleColor(IOSUtil.PrimaryColor, UIControlState.Selected);


            UIButton ChangePasswordButton = new UIButton()
            {
                Font            = UIFont.FromName("Futura-Medium", 14f),
                BackgroundColor = UIColor.Clear
            };

            ChangePasswordButton.SetTitle("CHANGE PASSWORD", UIControlState.Normal);
            ChangePasswordButton.SetTitleColor(UIColor.DarkTextColor, UIControlState.Normal);
            ChangePasswordButton.SetTitleColor(IOSUtil.PrimaryColor, UIControlState.Selected);



            InsightsButton.TouchUpInside       += InsightsButton_TouchUpInside;
            ChangePasswordButton.TouchUpInside += ChangePasswordButton_TouchUpInside;
            LogOutButton.TouchUpInside         += LogOutButton_TouchUpInside;
            DashboardButton.TouchUpInside      += DashboardButton_TouchUpInside;
            AlertsButton.TouchUpInside         += AlertsButton_TouchUpInside;


            UIView seperator = new UIView()
            {
                Frame           = new CGRect(0, 41, viewProfile.Bounds.Width, 1),
                BackgroundColor = UIColor.LightGray
            };
            UIView seperatorAlerts = new UIView()
            {
                Frame           = new CGRect(0, 41, viewProfile.Bounds.Width, 1),
                BackgroundColor = UIColor.LightGray
            };
            UIView seperatorPassword = new UIView()
            {
                Frame           = new CGRect(0, 41, viewProfile.Bounds.Width, 1),
                BackgroundColor = UIColor.LightGray
            };
            UIView seperatorInsights = new UIView()
            {
                Frame           = new CGRect(0, 41, viewProfile.Bounds.Width, 1),
                BackgroundColor = UIColor.LightGray
            };

            DashboardButton.InsertSubview(seperator, 1);
            ChangePasswordButton.InsertSubview(seperatorPassword, 1);
            AlertsButton.InsertSubview(seperatorAlerts, 1);
            InsightsButton.InsertSubview(seperatorInsights, 1);

            if (userdetail.RoleId == 2)
            {
                ChangePasswordButton.Frame = new CGRect(0, profileViewHeight + 40, 250, 40);
                View.AddSubviews(viewProfile, DashboardButton, ChangePasswordButton, LogOutButton);
            }
            else
            {
                AlertsButton.Frame         = new CGRect(0, profileViewHeight + 40, 250, 40);
                InsightsButton.Frame       = new CGRect(0, profileViewHeight + 80, 250, 40);
                ChangePasswordButton.Frame = new CGRect(0, profileViewHeight + 120, 250, 40);
                View.AddSubviews(viewProfile, DashboardButton, ChangePasswordButton, AlertsButton, InsightsButton);
            }
        }
 public AlertsViewController(IntPtr handle) : base(handle)
 {
     //this.prefHandler = new PreferenceHandler();
     User = PreferenceHandler.GetUserDetails();
 }
Ejemplo n.º 27
0
 public InsightsViewController(IntPtr handle) : base(handle)
 {
     //prefHandler = new PreferenceHandler();
     userdetail = PreferenceHandler.GetUserDetails();
 }
Ejemplo n.º 28
0
        private void SetDrawer()
        {
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            bool isLoggedIn = PreferenceHandler.IsLoggedIn();

            if (isLoggedIn)
            {
                int roleId = PreferenceHandler.GetUserDetails().RoleId;
                if (roleId == (int)EM_PORTABLE.Utils.Constants.USER_ROLE.STUDENT)
                {
                    IMenu nav_Menu = navigationView.Menu;
                    nav_Menu.FindItem(Resource.Id.nav_dashboard).SetVisible(false);
                    nav_Menu.FindItem(Resource.Id.nav_insights).SetVisible(false);
                    nav_Menu.FindItem(Resource.Id.nav_alerts).SetVisible(false);
                }
            }

            TextView textViewUserName =
                navigationView.GetHeaderView(0).FindViewById <TextView>(
                    Resource.Id.textViewUserName);
            UserDetails user = PreferenceHandler.GetUserDetails();

            textViewUserName.Text = user.FirstName + " " + user.LastName;

            TextView textViewLogout =
                navigationView.GetHeaderView(0).FindViewById <TextView>(
                    Resource.Id.tv_logout);

            textViewLogout.Click += delegate
            {
                Logout(new LogoutModel(PreferenceHandler.GetUserDetails().Email));
            };

            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);
                //react to click here and swap fragments or navigate
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_dashboard:
                    break;

                case Resource.Id.nav_alerts:
                    showAlerts();
                    break;

                case Resource.Id.nav_insights:
                    Intent intent = new Intent(Application.Context, typeof(InsightsActivity));
                    StartActivity(intent);
                    break;

                case Resource.Id.nav_change_password:
                    StartActivity(new Intent(Application.Context, typeof(ChangePasswordActivity)));
                    break;
                }

                drawerLayout.CloseDrawers();
            };

            //if (optionsMenu != null)
            //{
            //    MenuInflater.Inflate(Resource.Menu.main_menu, optionsMenu);

            //    if (PreferenceHandler.GetUserDetails().RoleId == (int)Constants.USER_ROLE.STUDENT)
            //    {
            //        optionsMenu.GetItem(0).SetVisible(false);
            //    }
            //    else
            //    {
            //        RelativeLayout alertItem = (RelativeLayout)(optionsMenu.FindItem(Resource.Id.alerts).ActionView);
            //        alertItem.Click += delegate
            //        {
            //            showAlerts();
            //        };
            //        notifCount = alertItem.FindViewById<TextView>(Resource.Id.notif_count);
            //        setNotificationCount();
            //    }
            //}
        }
Ejemplo n.º 29
0
        private void SetDrawer()
        {
            //var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            //SetSupportActionBar(toolbar);

            //Enable support action bar to display hamburger
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            // var preferenceHandler = new PreferenceHandler();
            bool isLoggedIn = PreferenceHandler.IsLoggedIn();

            if (isLoggedIn)
            {
                int roleId = PreferenceHandler.GetUserDetails().RoleId;
                if (roleId == (int)EM_PORTABLE.Utils.Constants.USER_ROLE.STUDENT)
                {
                    IMenu nav_Menu = navigationView.Menu;
                    nav_Menu.FindItem(Resource.Id.nav_dashboard).SetVisible(false);
                    //nav_Menu.FindItem(Resource.Id.nav_reports).SetVisible(false);
                    nav_Menu.FindItem(Resource.Id.nav_insights).SetVisible(false);
                    nav_Menu.FindItem(Resource.Id.nav_alerts).SetVisible(false);
                }
            }

            TextView textViewUserName =
                navigationView.GetHeaderView(0).FindViewById <TextView>(
                    Resource.Id.textViewUserName);
            //PreferenceHandler pref = new PreferenceHandler();
            UserDetails user = PreferenceHandler.GetUserDetails();

            textViewUserName.Text = user.FirstName + " " + user.LastName;

            TextView textViewLogout =
                navigationView.GetHeaderView(0).FindViewById <TextView>(
                    Resource.Id.tv_logout);

            textViewLogout.Click += delegate
            {
                Logout(new LogoutModel(PreferenceHandler.GetUserDetails().Email));
            };

            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);

                //react to click here and swap fragments or navigate
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_dashboard:
                    break;

                //case Resource.Id.nav_reports:
                //    StartActivity(new Intent(Application.Context, typeof(GlobalReportsActivity)));
                //    break;
                case Resource.Id.nav_alerts:
                    showAlerts();
                    break;

                case Resource.Id.nav_insights:
                    Intent intent = new Intent(Application.Context, typeof(InsightsActivity));
                    StartActivity(intent);
                    break;

                case Resource.Id.nav_change_password:
                    StartActivity(new Intent(Application.Context, typeof(ChangePasswordActivity)));
                    break;
                }

                drawerLayout.CloseDrawers();
            };
        }
 public ForgotPasswordController(IntPtr handle) : base(handle)
 {
     //this.prefHandler = new PreferenceHandler();
     User = PreferenceHandler.GetUserDetails();
 }