Ejemplo n.º 1
0
        public async void Login(object param)
        {
            //var words = new[] { ",this", "   is   ", "a", "test", "Super, \"luxurious\" truck" };

            //System.Diagnostics.Debug.WriteLine(words.ToCsv(x => x, typeof(CsvAlwaysQuote<string>)));
            //System.Diagnostics.Debug.WriteLine(words.ToCsv(x => x, typeof(CsvRfc4180<string>)));
            //System.Diagnostics.Debug.WriteLine(words.ToCsv(x => x, typeof(CsvBare<string>)));
            //System.Diagnostics.Debug.WriteLine(words.ToCsv(x => x, typeof(CsvTrimAlwaysQuote<string>)));
            //System.Diagnostics.Debug.WriteLine(words.ToCsv(x => x, typeof(CsvTrimRfc4180<string>)));
            //System.Diagnostics.Debug.WriteLine(words.ToCsv(x => x, typeof(CsvTrimBare<string>)));

            //string str = "<ENVELOPE><COMPANYNAME.LIST><COMPANYNAME>Itlion</COMPANYNAME><COMPANYNAME>Itlion</COMPANYNAME><COMPANYNAME>Itlion</COMPANYNAME>" +
            //    "<COMPANYNAME>Itlion</COMPANYNAME></COMPANYNAME.LIST></ENVELOPE>";
            //ENVELOPE CompanyList = XmlHelper.Deserialize<ENVELOPE>(str);
            //System.Diagnostics.Debug.WriteLine(CompanyList.COMPANYNAME_LIST.COMPANYNAME.ToCsv(x => x, typeof(CsvTrimBare<string>)));

            if (this.UserNm == string.Empty || this.Password == string.Empty)
            {
                MessageBox.Show(MessageConstants.UserNamePasswordRequired, Application.Current.Resources["AppTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                //bool resa= ApiManager.getInstance().CHECKCONNECTED();
                GlobalSettings.UserName = this.UserNm;
                GlobalSettings.Password = this.Password;
                LoginResquestModel loginResquestModel      = new LoginResquestModel(this.UserNm, this.Password);
                ApiResponseWrapper <LoginResposeModel> res = await ApiManager.getInstance().Login(loginResquestModel);

                if (res == null || res.IsSuccessful == false)
                {
                    MessageBox.Show(MessageConstants.LoginFailureMessage("invalid credentials"), Application.Current.Resources["AppTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
                if (res.Data.status)
                {
                    if (param != null)
                    {
                        Window win = param as Window;
                        //TempMainContainerView tempMainContainerView = new TempMainContainerView();
                        TempTestView tempMainContainerView = new TempTestView();
                        tempMainContainerView.Owner = win;
                        win.Hide();
                        tempMainContainerView.ShowDialog();
                    }
                    //MessageBox.Show(MessageConstants.LoginSuccess, Application.Current.Resources["AppTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }