Пример #1
0
        internal void AddSessionToCache(CimSession cimSession, XOperationContextBase context, CmdletOperationBase cmdlet)
        {
            string str;

            DebugHelper.WriteLogEx();
            CimNewSession.CimTestCimSessionContext cimTestCimSessionContext = context as CimNewSession.CimTestCimSessionContext;
            uint   num  = this.sessionState.GenerateSessionId();
            string name = cimTestCimSessionContext.CimSessionWrapper.Name;

            if (name != null)
            {
                str = name;
            }
            else
            {
                object[] cimSessionClassName = new object[2];
                cimSessionClassName[0] = CimSessionState.CimSessionClassName;
                cimSessionClassName[1] = num;
                str = string.Format(CultureInfo.CurrentUICulture, "{0}{1}", cimSessionClassName);
            }
            string     str1        = str;
            CimSession cimSession1 = cimTestCimSessionContext.Proxy.Detach();
            PSObject   cache       = this.sessionState.AddObjectToCache(cimSession1, num, cimSession1.InstanceId, str1, cimTestCimSessionContext.CimSessionWrapper.ComputerName, cimTestCimSessionContext.Proxy.Protocol);

            cmdlet.WriteObject(cache, null);
        }
Пример #2
0
        internal void NewCimSession(NewCimSessionCommand cmdlet, CimSessionOptions sessionOptions, CimCredential credential)
        {
            string localhostComputerName;

            DebugHelper.WriteLogEx();
            IEnumerable <string> computerNames = ConstValue.GetComputerNames(cmdlet.ComputerName);

            foreach (string computerName in computerNames)
            {
                if (sessionOptions == null)
                {
                    DebugHelper.WriteLog("Create CimSessionOption due to NewCimSessionCommand has null sessionoption", 1);
                    sessionOptions = CimSessionProxy.CreateCimSessionOption(computerName, cmdlet.OperationTimeoutSec, credential);
                }
                CimSessionProxy cimSessionProxyTestConnection = new CimSessionProxyTestConnection(computerName, sessionOptions);
                if (computerName == ConstValue.NullComputerName)
                {
                    localhostComputerName = ConstValue.LocalhostComputerName;
                }
                else
                {
                    localhostComputerName = computerName;
                }
                string            str = localhostComputerName;
                CimSessionWrapper cimSessionWrapper = new CimSessionWrapper(0, Guid.Empty, cmdlet.Name, str, cimSessionProxyTestConnection.CimSession, cimSessionProxyTestConnection.Protocol);
                CimNewSession.CimTestCimSessionContext cimTestCimSessionContext = new CimNewSession.CimTestCimSessionContext(cimSessionProxyTestConnection, cimSessionWrapper);
                cimSessionProxyTestConnection.ContextObject = cimTestCimSessionContext;
                SwitchParameter skipTestConnection = cmdlet.SkipTestConnection;
                if (!skipTestConnection.IsPresent)
                {
                    this.cimTestSession.TestCimSession(computerName, cimSessionProxyTestConnection);
                }
                else
                {
                    this.AddSessionToCache(cimSessionProxyTestConnection.CimSession, cimTestCimSessionContext, new CmdletOperationBase(cmdlet));
                }
            }
        }
Пример #3
0
		internal void NewCimSession(NewCimSessionCommand cmdlet, CimSessionOptions sessionOptions, CimCredential credential)
		{
			string localhostComputerName;
			DebugHelper.WriteLogEx();
			IEnumerable<string> computerNames = ConstValue.GetComputerNames(cmdlet.ComputerName);
			foreach (string computerName in computerNames)
			{
				if (sessionOptions == null)
				{
					DebugHelper.WriteLog("Create CimSessionOption due to NewCimSessionCommand has null sessionoption", 1);
					sessionOptions = CimSessionProxy.CreateCimSessionOption(computerName, cmdlet.OperationTimeoutSec, credential);
				}
				CimSessionProxy cimSessionProxyTestConnection = new CimSessionProxyTestConnection(computerName, sessionOptions);
				if (computerName == ConstValue.NullComputerName)
				{
					localhostComputerName = ConstValue.LocalhostComputerName;
				}
				else
				{
					localhostComputerName = computerName;
				}
				string str = localhostComputerName;
				CimSessionWrapper cimSessionWrapper = new CimSessionWrapper(0, Guid.Empty, cmdlet.Name, str, cimSessionProxyTestConnection.CimSession, cimSessionProxyTestConnection.Protocol);
				CimNewSession.CimTestCimSessionContext cimTestCimSessionContext = new CimNewSession.CimTestCimSessionContext(cimSessionProxyTestConnection, cimSessionWrapper);
				cimSessionProxyTestConnection.ContextObject = cimTestCimSessionContext;
				SwitchParameter skipTestConnection = cmdlet.SkipTestConnection;
				if (!skipTestConnection.IsPresent)
				{
					this.cimTestSession.TestCimSession(computerName, cimSessionProxyTestConnection);
				}
				else
				{
					this.AddSessionToCache(cimSessionProxyTestConnection.CimSession, cimTestCimSessionContext, new CmdletOperationBase(cmdlet));
				}
			}
		}