private void EndLogin(LoginResult loginResult, string errorMessage)
 {
     this.Dispatcher.BeginInvoke((Action<LoginResult>)delegate(LoginResult result)
     {
         try
         {
             if (result != null && result.Succeeded)
             {
                 App.MainFrameWindow.StatusBar.ShowStatusText("Login successful,Begin Initializing...");
                 this.SaveServerSettings();
                 this._LoginSuccssAction(result);
                 this.LoginButton.IsEnabled = true;
                 this.Close();
             }
             else
             {
                 this._HintMessage.ShowError(errorMessage);
                 this.LoginButton.IsEnabled = true;
             }
         }
         catch (Exception exception)
         {
             this._HintMessage.ShowError(exception.ToString());
             Logger.TraceEvent(TraceEventType.Error, "EndLogin exception\r\n{0}", exception);
         }
       }, loginResult
     );
 }
        public void HandleSuccessLogin(LoginResult result)
        {
            this.SourceConnectionStateControl.ItemsSource = VmQuotationManager.Instance.QuotationSources;
            foreach (string sourceName in result.SourceConnectionStates.Keys)
            {
                VmQuotationManager.Instance.QuotationSources.Single(s => s.Name == sourceName).ConnectionState = result.SourceConnectionStates[sourceName];
            }

            this._ExchangeConnectionStates.Clear();
            this.ExchangeConnectionStateControl.ItemsSource = this._ExchangeConnectionStates;
            foreach (string name in result.ExchangeConnectionStates.Keys)
            {
                this._ExchangeConnectionStates.Add(new ExchangeConnectionState() { ExchangeCode = name, ConnectionState = result.ExchangeConnectionStates[name] });
            }
        }
 private void EndLogin(LoginResult loginResult)
 {
     this.Dispatcher.BeginInvoke((Action<LoginResult>)delegate(LoginResult result)
     {
         if (result.Succeeded)
         {
             this._LoginSuccssAction(result);
             this.LoginButton.IsEnabled = true;
             this.Close();
         }
         else
         {
             this.HintMessage.Text = "Invalid user name or password.";
             this.LoginButton.IsEnabled = true;
         }
     }, loginResult
     );
 }
Пример #4
0
        private void HandleSuccessLogin(LoginResult result)
        {
            // initialize layout
            FunctionTree functionTree = ConsoleClient.Instance.GetFunctionTree();
            for (int i = 0; i < functionTree.Modules.Count; i++)
            {
                this._Modules.Add((int)functionTree.Modules[i].Type, functionTree.Modules[i]);
            }
            if (result.DockLayout !=null)
            {
                XDocument xdocument = XDocument.Parse(result.DockLayout);
                var panes = xdocument.Element("xamDockManager").Element("contentPanes").Elements("contentPane").Where(p => p.Attribute("name").Value != "FunctionTreePane");
                foreach (XElement pane in panes)
                {
                    int moduleType = MainWindowHelper.GetModuleType(pane.Attribute("name").Value);
                    if (this._Modules.ContainsKey(moduleType))
                    {
                        this.AddContentPane(moduleType);
                    }
                }
                this.DockManager.LoadLayout(result.DockLayout);
            }

            // initialize function tree
            Dictionary<ModuleCategoryType, TreeViewItem> typeTreeViewItems = new Dictionary<ModuleCategoryType, TreeViewItem>();
            foreach (Module module in this._Modules.Values)
            {
                TreeViewItem catalogNode;
                if (!typeTreeViewItems.TryGetValue(module.Category, out catalogNode))
                {
                    catalogNode = new TreeViewItem() { Header = functionTree.Categories.Single<Category>(c=>c.CategoryType == module.Category).CategoryDescription };
                    this.FunctionTree.Items.Add(catalogNode);
                    typeTreeViewItems.Add(module.Category, catalogNode);
                }
                TreeViewItem functionNode = new TreeViewItem() { Header = module.ModuleDescription, Tag = module.Type };
                functionNode.MouseDoubleClick += treeViewItem_MouseDoubleClick;
                catalogNode.Items.Add(functionNode);
            }
        }
Пример #5
0
        private void InitializeUI(LoginResult result)
        {
            FunctionTree functionTree = ConsoleClient.Instance.GetFunctionTree();
            for (int i = 0; i < functionTree.Modules.Count; i++)
            {
                this.AuthorizedModules.Add(functionTree.Modules[i].Type, functionTree.Modules[i]);
            }

            // initialize layout
            try
            {
                this._Layouts = new ObservableCollection<string>(result.LayoutNames);
                foreach (string layoutName in result.LayoutNames)
                {
                    XamMenuItem item = new XamMenuItem();
                    item.Header = layoutName;
                    item.Click += Layout_Click;
                    this.layout.Items.Add(item);
                }
                if (!string.IsNullOrEmpty(result.DockLayout))
                {
                    this._LayoutManager.LoadLayout(result.DockLayout, result.ContentLayout);
                }
            }
            catch (Exception exception)
            {
                Logger.AddEvent(TraceEventType.Error, "MainWindow.InitializeUI\r\n{0}", exception);
            }

            // initialize function tree
            Dictionary<ModuleCategoryType, TreeViewItem> typeTreeViewItems = new Dictionary<ModuleCategoryType, TreeViewItem>();
            foreach (Module module in this.AuthorizedModules.Values)
            {
                TreeViewItem catalogNode;
                if (!typeTreeViewItems.TryGetValue(module.Category, out catalogNode))
                {
                    catalogNode = new TreeViewItem() { Header = functionTree.Categories.Single<Category>(c => c.CategoryType == module.Category).CategoryDescription };
                    this.FunctionTree.Items.Add(catalogNode);
                    typeTreeViewItems.Add(module.Category, catalogNode);
                }

                string iconName = module.Type.ToString();
                TreeViewItem functionNode;
                if (!this._FunctionTreeItems.TryGetValue(iconName, out functionNode))
                {
                    functionNode = new TreeViewItem() { Tag = module.Type };
                    if (this.Resources.Contains(iconName))
                    {
                        StackPanel headerPanel;
                        headerPanel = new StackPanel() { Orientation = Orientation.Horizontal };
                        headerPanel.Children.Add((UIElement)this.Resources[iconName]);
                        headerPanel.Children.Add(new TextBlock() { Text = module.ModuleDescription, Margin = new Thickness(3, 0, 0, 0) });
                        functionNode.Header = headerPanel;
                    }
                    else
                    {
                        functionNode.Header = module.ModuleDescription;
                    }
                    this._FunctionTreeItems.Add(iconName, functionNode);
                }
                functionNode.MouseDoubleClick += treeViewItem_MouseDoubleClick;
                catalogNode.Items.Add(functionNode);
            }
        }
Пример #6
0
 private void HandleSuccessLogin(LoginResult result)
 {
     try
     {
         this.InitializeUI(result);
         VmQuotationManager.Instance.Initialize();
         this.StatusBar.HandleSuccessLogin(result);
         ConsoleClient.Instance.LoadSettingsParameters(this.LoadSettingsParametersCallback);
         ConsoleClient.Instance.GetInitializeData(this.GetInitializeDataCallback);
         this.AddQuotePriceFrm();
         this.AddTaskSchedulerNotifyFrm();
     }
     catch (Exception ex)
     {
         Logger.TraceEvent(System.Diagnostics.TraceEventType.Error, "HandleSuccessLogin.\r\n{0}", ex.ToString());
     }
 }
Пример #7
0
        public LoginResult Login(string userName, string password, string oldSessionId, Language language)
        {
            Guid userId = UserDataAccess.LoginIn(userName,password);
            LoginResult loginResult = new LoginResult();
            if (userId != Guid.Empty)
            {
                string sessionId = OperationContext.Current.SessionId;
                IClientProxy clientProxy = OperationContext.Current.GetCallbackChannel<IClientProxy>();
                this._Client = Manager.ClientManager.AddClient(oldSessionId, sessionId, userId, clientProxy, language);

                OperationContext.Current.Channel.Faulted += this._Client.Channel_Broken;
                OperationContext.Current.Channel.Closed += this._Client.Channel_Broken;
                loginResult.SessionId = sessionId;
            }
            return loginResult;
        }