Esempio n. 1
0
        void Login()
        {
            AppVariable.Variable.Login            = mLogin.Text;
            AppVariable.Variable.Password         = mPass.Text;
            AppVariable.Variable.fireBaseClientID = FirebaseInstanceId.Instance.Token;

            mProgressDialog.SetMessage("Вход...");
            mProgressDialog.Show();

            Dictionary <string, Dictionary <string, string> > LoginData = new Dictionary <string, Dictionary <string, string> >();

            Dictionary <string, string> AppInfo = new Dictionary <string, string>();

            AppInfo.Add("AppVersion", AppVariable.Variable.version.ToString());
            AppInfo.Add("AppFirebaseClientID", AppVariable.Variable.fireBaseClientID);
            AppInfo.Add("DevVersionSDK", AppVariable.Variable.versionSDK);
            AppInfo.Add("DevModelName", AppVariable.Variable.modelName);
            LoginData.Add("AppInfo", AppInfo);

            Dictionary <string, string> Parameters = new Dictionary <string, string>();

            if (mSigninwithapin.Checked)
            {
                AppVariable.Variable.Password = "";
                Parameters.Add("pin", mPass.Text);
            }
            LoginData.Add("Parameters", Parameters);

            DataSetWS dataSetWS = new DataSetWS();

            dataSetWS.InitAppAsync(JsonConvert.SerializeObject(LoginData));
            dataSetWS.InitAppCompleted += DataSetWS_InitAppCompleted;
        }
        void Login()
        {
            AppVariable.Variable.Login    = mLogin.Text;
            AppVariable.Variable.Password = mPass.Text;

            //получение настроек для "продвинутых" пользователей   начало
            bool         isCurrentUserAdvanced    = false;
            WebClient    devopts_webclient        = new WebClient();
            string       devopts_DefaultUpdateURL = "http://1c.pozitivtelecom.ru:81/MobileApp";
            const string devoptsFile = "devopts.json";
            Uri          devopts_url = new Uri(devopts_DefaultUpdateURL + "/" + devoptsFile);

            try
            {
                string  stringResult     = devopts_webclient.DownloadString(devopts_url);
                JObject jsonResult       = JObject.Parse(stringResult);
                JArray  advancedUsersSet = (JArray)jsonResult["advancedUsersSet"];

                string advServerUrl = "";
                foreach (var advUser in advancedUsersSet)
                {
                    if (mLogin.Text == (string)advUser["UserName"])
                    {
                        isCurrentUserAdvanced = true;
                        if (advUser["ServerUrl"] != null)
                        {
                            advServerUrl = (string)advUser["ServerUrl"];
                        }
                        break;
                    }
                }


                AppVariable.Variable.WsURL = "http://1c.pozitivtelecom.ru/SkladPozitiv/ws/app.1cws";
                AppPreferences.Preferences.SetPreferences("WsURL", AppVariable.Variable.WsURL);
                if (isCurrentUserAdvanced)
                {
                    if (advServerUrl.Length > 0)
                    {
                        AppVariable.Variable.WsURL = advServerUrl;
                        AppPreferences.Preferences.SetPreferences("WsURL", advServerUrl);
                    }
                }
            }
            catch (Exception e)
            {
                clearPreferences();
                string problemPath = devopts_DefaultUpdateURL + "/" + devoptsFile;
                var    mAlert      = new AlertDialog.Builder(this)
                                     .SetTitle("Ошибка связи с сервером.")
                                     .SetMessage("Файл \"" + problemPath + "\" не доступен! Исключение: " + e.Message)
                                     .SetCancelable(true)
                                     .Show();
                Toast.MakeText(this, "Файл \"" + problemPath + "\" не доступен! Исключение: " + e.Message, ToastLength.Short);
                return;
            }
            //получение настроек для "продвинутых" пользователей   конец

            mProgressDialog.SetMessage("Вход...");
            mProgressDialog.Show();

            Dictionary <string, Dictionary <string, string> > LoginData = new Dictionary <string, Dictionary <string, string> >();

            Dictionary <string, string> AppInfo = new Dictionary <string, string>();

            AppInfo.Add("AppVersion", AppVariable.Variable.version.ToString());
            AppInfo.Add("DevVersionSDK", AppVariable.Variable.versionSDK);
            AppInfo.Add("DevModelName", AppVariable.Variable.modelName);
            LoginData.Add("AppInfo", AppInfo);

            Dictionary <string, string> Parameters = new Dictionary <string, string>();

            if (mSigninwithapin.Checked)
            {
                AppVariable.Variable.Password = "";
                Parameters.Add("pin", mPass.Text);
            }
            LoginData.Add("Parameters", Parameters);

            DataSetWS dataSetWS = new DataSetWS();

            dataSetWS.InitAppAsync(JsonConvert.SerializeObject(LoginData));
            dataSetWS.InitAppCompleted += DataSetWS_InitAppCompleted;
        }