Esempio n. 1
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     if (IsLoaded)
     {
         PART_Password.Focus();
     }
 }
Esempio n. 2
0
        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var item = ((System.Windows.Controls.ListBox)sender).SelectedValue;

            if (item != null)
            {
                PART_User.Text = item as string;
                CurrentPage    = 0;

                if (PART_Password != null)
                {
                    PART_Password.Focus();
                }
            }
        }
Esempio n. 3
0
        private void Вход_Click(object sender, RoutedEventArgs e)
        {
            //var factory = new System.ServiceModel.Web.WebChannelFactory<RosService.Configuration.IConfigurationChannel>(new Uri("http://itrf.ru:8080/RosService/Configuration/basic"));
            //var Proxy = factory.CreateChannel();
            //var user = Proxy.Авторизация("Техподдержка", "nfrcb", false, "ювтранс");
            //if (user != null)
            //{
            //}


            //var xml = System.Xml.Linq.XDocument.Parse(RosControl.Properties.Resources.country);
            //foreach (var item in xml.Descendants("Country"))
            //{
            //    var name = item.Element("Eng").Value.ToLower();
            //    if (!string.IsNullOrEmpty(name))
            //    {
            //        try
            //        {
            //            using (var web = new System.Net.WebClient())
            //            {
            //                web.DownloadFile(string.Format("http://flags.redpixart.com/img/{0}_preview.gif", name), string.Format("R:\\111\\{0}.gif", name));
            //            }
            //        }
            //        catch
            //        {
            //        }
            //    }
            //}


            //using (var client = new HyperСloud.Client("регистр@localhost"))
            //{
            //    //client.Set(254388, "GuidCode", Guid.NewGuid().ToString());
            //    //client.Set(254388, "GuidCode", Guid.NewGuid().ToString());
            //    //client.Set(254388, "GuidCode", Guid.NewGuid().ToString());
            //    //client.Set(254388, "GuidCode", Guid.NewGuid().ToString());
            //}
            //try
            //{
            //    using (var client = new HyperСloud.Files("азбука@crmapp.azb24.ru"))
            //    //using (var client = new HyperСloud.Files("росинфотех@itrf.ru"))
            //    {
            //        var file = File.ReadAllBytes("r:\\1.jpg");
            //        client.Set(1, "1.jpg", file);
            //    }

            //    //using (var client = new HyperСloud.Client("росинфотех"))
            //    //{
            //    //    var types = client.Get<string>(1, "НазваниеОбъекта");
            //    //    if (types != null)
            //    //    {
            //    //    }
            //    //}

            //    //using (var client = new HyperСloud.Config("росинфотех"))
            //    //{
            //    //    var types = client.GetTypes();
            //    //    if (types != null)
            //    //    {
            //    //    }
            //    //}
            //}
            //catch (Exception ex)
            //{
            //    if (ex != null)
            //    {
            //    }
            //}


            //RosService.Client.Host = Properties.Settings.Default.АдресСервера;
            RosService.Client.maxService = 1;
            RosService.Client.Host       = App.ServerName;

            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                try
                {
                    var mode = RosService.ClientMode.None;
                    if (Enum.TryParse <RosService.ClientMode>(Properties.Settings.Default.ТипСоединения, out mode))
                    {
                        RosService.Client.Mode = mode;
                    }


                    if (RosService.Client.Authorization(Пользователь, PART_Password.Password, true) &&
                        RosService.Client.User.id_node > 0)
                    {
                        using (RosService.Client client = new RosService.Client())
                        {
                            App.AppName = client.Архив.ПолучитьЗначение <string>("КорневойРаздел", "НазваниеОбъекта");
                        }

                        this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) delegate
                        {
                            try
                            {
                                #region Сохранить настройки после входа
                                if (Пользователь.Contains("@"))
                                {
                                    //Properties.Settings.Default.ИмяПользователя = string.Format("{0}\\{1}@{2}", RosService.Client.Domain, RosService.Client.UserName, RosService.Client.Host);
                                    App.UserName = string.Format("{0}\\{1}@{2}", RosService.Client.Domain, RosService.Client.UserName, RosService.Client.Host);
                                }
                                else
                                {
                                    //Properties.Settings.Default.ИмяПользователя = string.Format("{0}\\{1}", RosService.Client.Domain, RosService.Client.UserName);
                                    App.UserName = string.Format("{0}\\{1}", RosService.Client.Domain, RosService.Client.UserName);
                                }

                                var userName = App.UserName ?? string.Empty;
                                if (IsЗапомнить)
                                {
                                    Properties.Settings.Default.Пароль = PART_Password.Password;
                                }
                                var account = App.HistoryAccounts.FirstOrDefault(p => p.Login.ToLower().Equals(userName.ToLower()));
                                if (account == null)
                                {
                                    account = new App.HistoryAccount()
                                    {
                                        Login = userName, Версия = RosApplication.Properties.Settings.Default.Версия
                                    };
                                    App.HistoryAccounts.Add(account);
                                    App.SaveHistoryAccounts();
                                }
                                System.Threading.Tasks.Task.Factory.StartNew(() =>
                                {
                                    try
                                    {
                                        Properties.Settings.Default.Save();

                                        if (account != null)
                                        {
                                            //using (RosService.Client client = new RosService.Client())
                                            {
                                                //App.AppName = client.Архив.ПолучитьЗначение<string>("КорневойРаздел", "НазваниеОбъекта");
                                                if (!string.IsNullOrEmpty(App.AppName) && !"Предприятие".Equals(App.AppName) &&
                                                    account.Group != App.AppName)
                                                {
                                                    account.Group = App.AppName;
                                                    App.SaveHistoryAccounts();
                                                }
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                });
                                #endregion

                                //включить автоматическое продление сессии
                                App.SessionStart();

                                this.NavigationService.RemoveBackEntry();
                                this.NavigationService.Navigate(App.ГлавнаяФорма);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Ошибка авторизации", MessageBoxButton.OK);
                                PART_Password.Focus();
                                КнопкаВход.EndCallback();
                            }
                        });
                    }
                    //else if (RosService.Client.User.id_node == -1)
                    //{
                    //    //redirect to 5.0
                    //    RosService.Client.Shutdown();
                    //    this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate
                    //    {
                    //        if (PART_User.SelectedItem is App.HistoryAccount)
                    //        {
                    //            ((App.HistoryAccount)PART_User.SelectedItem).Версия = 5;
                    //            App.SaveHistoryAccounts(СписокПользователей);
                    //        }
                    //        else
                    //        {
                    //            Properties.Settings.Default.Версия = 5;
                    //        }

                    //        Вход_Click(sender, e);
                    //    });
                    //}
                    else
                    {
                        this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) delegate
                        {
                            КнопкаВход.EndCallback();
                        });
                    }
                }
                catch (Exception ex)
                {
                    this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) delegate
                    {
                        MessageBox.Show(ex.Message, "Ошибка авторизации", MessageBoxButton.OK);
                        КнопкаВход.EndCallback();
                    });
                }
            });
        }