Пример #1
0
        public Home()
        {
            InitializeComponent();
            ////Thread.Sleep(1000);

            Resources.Remove("PhoneAccentColor");
            Resources.Add("PhoneAccentColor", GetColorFromHex("#00b4f0"));
            ((SolidColorBrush)Resources["PhoneAccentBrush"]).Color = GetColorFromHex("#00b4f0");
            SystemTray.BackgroundColor = GetColorFromHex("#f5f5f5");
            ////ApplicationBarIconButton iconButton = new ApplicationBarIconButton();
            ////iconButton.IconUri = new Uri("/Assets/ic_action_overflow.png", UriKind.Relative);
            ////iconButton.Text = "button 1";
            ////ApplicationBar.Buttons.Add(iconButton);
            ApplicationBar.Mode = ApplicationBarMode.Minimized;
            loginRepository = new LoginRepository();
            this.Loaded += Home_Loaded;
        }
Пример #2
0
        /// <summary>
        /// Gets the authentication data.
        /// </summary>
        private async void GetAuthenticationData()
        {
            try
            {
                string filename = Path.Combine(folderPath, AuthenticationDataFile);

                Java.IO.File file = new Java.IO.File(filename);

                if (file.Exists())
                {
                    using (var streamReader = new StreamReader(filename))
                    {
                        string tokenContent = streamReader.ReadToEnd();
                        Token token = new Token { Value = tokenContent.Replace("\n", "") };

                        if (tokenContent != null)
                        {
                            LoginRepository loginRepository = new LoginRepository();
                            ApplicationData.User = await loginRepository.ValidateToken(token);

                            if (ApplicationData.User != null)
                            {
                                SetAuthenticationData(ApplicationData.User.Token, true);
                            }
                        }
                    }
                }

                else
                {
                    IsRedirectToLogin = true;
                }

                return;
            }
            catch (Exception e)
            {
                IsRedirectToLogin = true;
            }

            return;
        }
Пример #3
0
        private async void Login_Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                {
                    progressMask.Show();

                    LoginRepository loginRepository = new LoginRepository();

                    UserCredential userCredential = new UserCredential();
                    userCredential.Username = txtUserName.Text; ////"decurtis\\sourabh.rathore";
                    userCredential.Password = txtPassword.Password; ////"yellow*99";
                    userCredential.DeviceId = Windows.Phone.System.Analytics.HostInformation.PublisherHostId;
                    ApplicationData.User = await loginRepository.Validate(userCredential);
                    ////progress.Dismiss();
                    if (ApplicationData.User != null)
                    {
                        ApplicationData.User.LoginName = userCredential.Username;
                        SetAuthenticationData(ApplicationData.User.Token, chkRememberMe.IsChecked.HasValue ? chkRememberMe.IsChecked.Value : false);
                        NavigationService.Navigate(new Uri("/Home.xaml", UriKind.Relative));
                    }
                    else
                    {
                        txtPassword.Password = string.Empty;
                        ShowMessageBox("Insight", AppResources.ErrorLoginMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                ////AlertMessage(GetString(Resource.String.Error), ex.Message.ToString());
                ////ResetControl();
            }
            finally
            {
                progressMask.Hide();
            }
        }
Пример #4
0
        /// <summary>
        /// Handles the Click event of the loginButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private async void loginButton_Click(object sender, EventArgs e)
        {
            var progress = ProgressDialog.Show(this, GetString(Resource.String.Insight), GetString(Resource.String.PleaseWait), true);
            try
            {
                if (!IsNetworkAvailable())
                {
                    return;
                }

                LoginRepository loginRepository = new LoginRepository();

                UserCredential userCredential = new UserCredential();
                userCredential.Username = txtUserName.Text;
                userCredential.Password = txtPassword.Text;
                userCredential.DeviceId = Android.Provider.Settings.Secure.GetString(this.ContentResolver, Android.Provider.Settings.Secure.AndroidId);

                ApplicationData.User = await loginRepository.Validate(userCredential);

                if (ApplicationData.User != null)
                {
                    ApplicationData.User.LoginName = userCredential.Username;
                    SetAuthenticationData(ApplicationData.User.Token, chkRememberMe.Checked);
                }
                else
                {
                    txtPassword.Text = string.Empty;
                    AlertMessage(GetString(Resource.String.Error), GetString(Resource.String.ErrorLoginMessage));
                }
            }
            catch (HttpClientException ex)
            {
                if (ex.StatusCode == System.Net.HttpStatusCode.RequestTimeout)
                {
                    AlertMessage(GetString(Resource.String.Error), "Request time out.");
                }
                else
                {
                    AlertMessage(GetString(Resource.String.Error), GetString(Resource.String.ErrorLoginMessage));
                    txtPassword.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                AlertMessage(GetString(Resource.String.Error), ex.Message.ToString());
                ResetControl();
            }
            finally
            {
                progress.Dismiss();
            }
        }
Пример #5
0
 private void SetReleaseCount()
 {
     using (var loginRepository = new LoginRepository())
     {
         var releases = ApplicationData.UserDashboard.ProjectReleases;
         if (releases != null)
         {
             lblAllReleaseCount.Text = loginRepository.GetDashboardReleaseCount(AllReleasesShort, releases);
             lblProdReleaseCount.Text = loginRepository.GetDashboardReleaseCount(ProductionShort, releases);
             lblUATReleaseCount.Text = loginRepository.GetDashboardReleaseCount(UATShort, releases);
             lblInternalReleaseCount.Text = loginRepository.GetDashboardReleaseCount(InternalShort, releases);
         }
     }
 }
Пример #6
0
        private async Task GetAuthenticationData()
        {
            try
            {
                var tokenByte = this.ReadTokenFromFile();
                var tokenContent = Encoding.UTF8.GetString(tokenByte, 0, tokenByte.Length);

                if (!string.IsNullOrEmpty(tokenContent))
                {
                    Token token = new Token { Value = tokenContent.Replace("\n", "") };
                    LoginRepository loginRepository = new LoginRepository();
                    ApplicationData.User = await loginRepository.ValidateToken(token);

                    if (ApplicationData.User != null)
                    {
                        SetAuthenticationData(ApplicationData.User.Token, true);
                    }
                }
                else
                {
                    IsRedirectToLogin = true;
                }

                return;
            }
            catch (Exception e)
            {
                IsRedirectToLogin = true;
            }

            return;
        }
Пример #7
0
        public Home()
        {
            InitializeComponent();

            Resources.Remove("PhoneAccentColor");
            Resources.Add("PhoneAccentColor", ApplicationData.GetColorFromHex("#00b4f0"));
            ((SolidColorBrush)Resources["PhoneAccentBrush"]).Color = ApplicationData.GetColorFromHex("#00b4f0");
            SystemTray.BackgroundColor = ApplicationData.GetColorFromHex("#f5f5f5");
            ApplicationBar.Mode = ApplicationBarMode.Minimized;
            loginRepository = new LoginRepository();
            this.Loaded += Home_Loaded;
        }
Пример #8
0
        /// <summary>
        /// Fills the dashboard controls.
        /// </summary>
        /// <returns></returns>
        private async Task FillDashboardControls()
        {
            using (var loginRepository = new LoginRepository())
            {
                if (!ApplicationData.IsRedirectedFromLogin)
                {
                    ApplicationData.UserDashboard = await loginRepository.GetDashboard(ApplicationData.User.UserId.ToString(), ApplicationData.User.Token);
                }

                ApplicationData.IsRedirectedFromLogin = false;
                if (ApplicationData.UserDashboard != null)
                {
                    SetReleaseCount();
                    var hourCount = ApplicationData.UserDashboard.TotalTimesheetHours - (int)ApplicationData.UserDashboard.TotalTimesheetHours != 0 ? ApplicationData.UserDashboard.TotalTimesheetHours : (int)ApplicationData.UserDashboard.TotalTimesheetHours;
                    leaveBalance.Text = ApplicationData.UserDashboard.LeaveBalance.ToString();
                    txtLeaveLeft.Text = string.Format(LeaveLeft, ApplicationData.UserDashboard.LeaveBalance > 1 ? "s" : string.Empty);

                    txtHoursCount.Text = hourCount.ToString();
                    ApplicationData.TaskHours = hourCount;
                    txtHoursLogged.Text = string.Format(HourLogged, hourCount > 1 ? "s" : string.Empty);
                }
            }
        }