예제 #1
0
 public void TraceWithMsgShouldNotCallUnderlyingTraceWhenTraceIsDisabled()
 {
     underlyingLoggerMock.Setup(l => l.IsTraceEnabled).Returns(false);
     isTraceEnabledResolverMock.Setup(r => r.Value).Returns(underlyingLoggerMock.Object.IsTraceEnabled);
     logger.Trace("msg");
     underlyingLoggerMock.Verify(l => l.Trace(It.IsAny <string>()), Times.Never());
 }
예제 #2
0
파일: Director.cs 프로젝트: SomeZyla/TsGui
 //Navigate to the current page, and update the datacontext of the window
 private void UpdateWindow()
 {
     LoggerFacade.Trace("UpdateWindow called");
     this.ParentWindow.ContentArea.Navigate(this.CurrentPage.Page);
     this.ParentWindow.ContentArea.DataContext = this.CurrentPage;
     this.CurrentPage.Update();
 }
예제 #3
0
파일: Director.cs 프로젝트: SomeZyla/TsGui
        //Wrap a generic exception handler to get some useful information in the event of a
        //crash.
        public void Init(MainWindow ParentWindow, Arguments Arguments)
        {
            LoggerFacade.Trace("MainController initializing");
            this._envController  = new EnvironmentController(this);
            this._pages          = new List <TsPage>();
            this._linkinglibrary = new LinkingLibrary();
            this._grouplibrary   = new GroupLibrary();
            this._toggles        = new List <IToggleControl>();
            this._optionlibrary  = new OptionLibrary();
            this._authlibrary    = new AuthLibrary();
            this._args           = Arguments;
            this.ParentWindow    = ParentWindow;
            this.ParentWindow.MouseLeftButtonUp += this.OnWindowMouseUp;
            this.ParentWindow.LocationChanged   += this.OnWindowMoving;

            try { this.Startup(); }
            catch (TsGuiKnownException exc)
            {
                string msg = "Error message: " + exc.CustomMessage;
                this.CloseWithError("Application Startup Exception", msg);
                return;
            }
            catch (Exception exc)
            {
                string msg = "Error message: " + exc.Message + Environment.NewLine + exc.ToString();
                this.CloseWithError("Application Startup Exception", msg);
                return;
            }
        }
예제 #4
0
        public static XElement GetPrebuiltXElement(XElement OptionXml)
        {
            XAttribute xtype     = OptionXml.Attribute("Type");
            XAttribute xprebuilt = OptionXml.Attribute("Prebuilt");
            string     name      = OptionXml.Name.LocalName;

            if (xprebuilt == null)
            {
                LoggerFacade.Trace("No Prebuilt attribute set");
            }
            else
            {
                string prebuilttype = xprebuilt.Value.ToUpper();

                switch (prebuilttype)
                {
                case "DISKINDEX":
                    if (PrebuiltDiskIndex.IsSupported(xtype.Value))
                    {
                        return(PrebuiltDiskIndex.GetXml());
                    }
                    else
                    {
                        throw new TsGuiKnownException(string.Format("Prebuilt type {0} not supported on {1}", xprebuilt.Value, xtype.Value), null);
                    }

                case "POWERCONNECTED":
                    if (PrebuiltPowerConnected.IsSupported(xtype.Value))
                    {
                        return(PrebuiltPowerConnected.GetXml());
                    }
                    else
                    {
                        throw new TsGuiKnownException(string.Format("Prebuilt type {0} not supported on {1}", xprebuilt.Value, xtype.Value), null);
                    }

                case "WIFIDISCONNECTED":
                    if (PrebuiltPowerConnected.IsSupported(xtype.Value))
                    {
                        return(PrebuiltWifiDisconnected.GetXml());
                    }
                    else
                    {
                        throw new TsGuiKnownException(string.Format("Prebuilt type {0} not supported on {1}", xprebuilt.Value, xtype.Value), null);
                    }

                default:
                    break;
                }
            }

            return(null);
        }
예제 #5
0
 private bool CreateSccmObject()
 {
     try
     {
         this._sccmconnector   = new SccmConnector();
         this._outputconnector = this._sccmconnector;
         return(true);
     }
     catch
     {
         LoggerFacade.Trace("Couldn't create SCCM connector. Creating testing connector");
         this._outputconnector = new TestingConnector();
         return(false);
     }
 }
예제 #6
0
        public AuthState Authenticate()
        {
            if (string.IsNullOrWhiteSpace(this.UsernameSource.Username) == true)
            {
                LoggerFacade.Warn("Cannot autheticate with empty username");
                this.SetState(AuthState.AccessDenied);
                return(AuthState.AccessDenied);
            }
            if (string.IsNullOrEmpty(this.PasswordSource.Password) == true)
            {
                LoggerFacade.Warn("Cannot autheticate with empty password");
                this.SetState(AuthState.AccessDenied);
                return(AuthState.AccessDenied);
            }

            LoggerFacade.Info("Authenticating user: "******" against domain " + this._domain);
            AuthState newstate;

            try
            {
                this.Context = new PrincipalContext(ContextType.Domain, this._domain, this.UsernameSource.Username, this.PasswordSource.Password);

                if (ActiveDirectoryMethods.IsUserMemberOfGroups(this.Context, this.UsernameSource.Username, this.RequiredGroups) == true)
                {
                    LoggerFacade.Info("Active Directory authorised");
                    newstate = AuthState.Authorised;
                }
                else
                {
                    LoggerFacade.Info("Active Directory not authorised");
                    newstate = AuthState.NotAuthorised;
                }
            }
            catch (Exception e)
            {
                LoggerFacade.Warn("Active Directory access denied");
                LoggerFacade.Trace(e.Message + Environment.NewLine + e.StackTrace);
                newstate = AuthState.AccessDenied;
            }

            this.SetState(newstate);
            return(newstate);
        }
예제 #7
0
 public void Hide()
 {
     LoggerFacade.Trace("SccmConnector hiding progress dialog");
     objTSProgUI?.CloseProgressDialog();
 }
예제 #8
0
파일: Director.cs 프로젝트: SomeZyla/TsGui
        private void Startup()
        {
            LoggerFacade.Debug("*TsGui startup started");
            this.StartupFinished = false;
            this._prodmode       = this._envController.Init();


            XElement xconfig = this.ReadConfigFile();

            if (xconfig == null)
            {
                return;
            }

            //this.LoadXml(x);
            try { this.LoadXml(xconfig); }
            catch (TsGuiKnownException e)
            {
                string msg = "Error loading config file" + Environment.NewLine + e.CustomMessage + Environment.NewLine + e.Message;
                this.CloseWithError("Error loading config file", msg);
                return;
            }

            this.PopulateHwOptions();

            //now init everything
            this._optionlibrary.InitialiseOptions();

            //if prodmode isn't true, the envcontroller couldn't connect to sccm
            //prompt the user if they want to continue. exit if not.
            if (this._prodmode == true)
            {
                this._envController.HideProgressUI();
            }
            else
            {
                if (this.PromptTestMode() != true)
                {
                    this.Cancel(); return;
                }
                if (this._livedata == true)
                {
                    this._showtestwindow = true;
                }
            }

            //subscribe to closing event
            this.ParentWindow.Closing += this.OnWindowClosing;

            if (this._pages.Count > 0)
            {
                LoggerFacade.Debug("Loading pages");
                this.CurrentPage = this._pages.First();
                //update group settings to all controls
                foreach (IToggleControl t in this._toggles)
                {
                    t.InitialiseToggle();
                }

                this.ParentWindow.DataContext = this.TsMainWindow;

                // Now show and close the ghost window to make sure WinPE honours the
                // windowstartuplocation
                LoggerFacade.Trace("Loading ghost window");
                GhostWindow ghost = new GhostWindow();
                ghost.Show();
                ghost.Close();

                this.UpdateWindow();
                this.ParentWindow.Visibility            = Visibility.Visible;
                this.ParentWindow.WindowStartupLocation = this.TsMainWindow.WindowLocation.StartupLocation;
                this.StartupFinished = true;
                if ((this._debug == true) || (this._showtestwindow == true))
                {
                    this._testingwindow = new TestingWindow(this);
                }
                GuiTimeout.Instance?.Start(this.OnTimeoutReached);
                LoggerFacade.Info("*TsGui startup finished");
            }
            else
            {
                //No pages, finish using only the NoUI options
                LoggerFacade.Info("*No pages configured. Finishing TsGui");
                this.Finish();
            }
        }
예제 #9
0
 public MainWindow(Arguments arguments)
 {
     InitializeComponent();
     LoggerFacade.Trace("MainWindow initialized");
 }