Esempio n. 1
0
        public void ExecuteStoredProcedureExample()
        {
            #region Examples

            // Stored procedure returns a scalar value.
            int      intResult  = _database.ExecuteStoredProcedure <int>("ProcedureName");
            DateTime dateResult = _database.ExecuteStoredProcedure <DateTime>("ProcedureName");

            // Stored procedure sets the value of output parameter.
            var parameters = new CommandParameterCollection();
            parameters.Add("@param1", 10);
            parameters.Add("@param2", DateTime.Now);
            parameters.Add("@outputParam", null, DbType.String, ParameterDirection.Output);

            _database.ExecuteStoredProcedure <string>("ProcedureName", parameters);

            Console.WriteLine(parameters["@outputParam"].Value);

            // Stored procedure returns complex object.
            Person person = _database.ExecuteStoredProcedure <Person>("ProcedureName");

            // Stored procedure returns list of complex objects.
            IEnumerable <Person> persons = _database.ExecuteStoredProcedure <IEnumerable <Person> >("ProcedureName");
            #endregion
        }
Esempio n. 2
0
 internal void AddParameters(Collection <CommandParameter> parameters)
 {
     if (parameters == null)
     {
         return;
     }
     foreach (var param in parameters)
     {
         Parameters.Add(param);
     }
 }
 private static void AddStartParametersFromCollection(Dictionary <string, object> collection, CommandParameterCollection allParams)
 {
     if (collection == null || collection.Count <= 0)
     {
         return;
     }
     foreach (var param in collection.Select(o => new CommandParameter(o.Key, o.Value)))
     {
         allParams.Add(param);
     }
 }
Esempio n. 4
0
        private void DeserializeInvocationInfo(SerializationInfo info)
        {
            string str  = info.GetString("InvocationInfo_Command");
            string str1 = info.GetString("InvocationInfo_Name");
            string str2 = info.GetString("InvocationInfo_ModuleName");
            string str3 = info.GetString("InvocationInfo_AdapterTypeName");
            Dictionary <string, object> strs = new Dictionary <string, object>();
            string str4 = info.GetString("InvocationParam_ScriptBlock");

            if (str4 != null)
            {
                strs.Add("ScriptBlock", ScriptBlock.Create(str4));
            }
            string str5 = info.GetString("InvocationParam_FilePath");

            if (!string.IsNullOrEmpty(str5))
            {
                strs.Add("FilePath", str5);
            }
            str4 = info.GetString("InvocationParam_InitScript");
            if (!string.IsNullOrEmpty(str4))
            {
                strs.Add("InitializationScript", ScriptBlock.Create(str4));
            }
            bool flag = info.GetBoolean("InvocationParam_RunAs32");

            strs.Add("RunAs32", flag);
            AuthenticationMechanism value = (AuthenticationMechanism)info.GetValue("InvocationParam_Authentication", typeof(AuthenticationMechanism));

            strs.Add("Authentication", value);
            object[] objArray = (object[])info.GetValue("InvocationParam_ArgList", typeof(object[]));
            if (objArray != null)
            {
                strs.Add("ArgumentList", objArray);
            }
            JobDefinition jobDefinition = new JobDefinition(null, str, str1);

            jobDefinition.ModuleName = str2;
            jobDefinition.JobSourceAdapterTypeName = str3;
            CommandParameterCollection commandParameterCollection = new CommandParameterCollection();

            foreach (KeyValuePair <string, object> keyValuePair in strs)
            {
                CommandParameter commandParameter = new CommandParameter(keyValuePair.Key, keyValuePair.Value);
                commandParameterCollection.Add(commandParameter);
            }
            base.Definition = jobDefinition;
            base.Name       = str1;
            base.Command    = str;
            base.Parameters.Add(commandParameterCollection);
        }
Esempio n. 5
0
        private static CommandParameterCollection ConvertDictionaryToParameterCollection(IEnumerable <KeyValuePair <string, object> > parameters)
        {
            if (parameters == null)
            {
                return(null);
            }
            CommandParameterCollection parameters2 = new CommandParameterCollection();

            foreach (CommandParameter parameter in from param in parameters select new CommandParameter(param.Key, param.Value))
            {
                parameters2.Add(parameter);
            }
            return(parameters2);
        }
Esempio n. 6
0
        /// <summary>
        /// Utility function to turn a dictionary of name/value pairs into a parameter collection
        /// </summary>
        /// <param name="parameters">The dictionary to convert</param>
        /// <returns>The converted collection</returns>
        private static CommandParameterCollection ConvertDictionaryToParameterCollection(IEnumerable <KeyValuePair <string, object> > parameters)
        {
            if (parameters == null)
            {
                return(null);
            }
            CommandParameterCollection paramCollection = new CommandParameterCollection();

            foreach (CommandParameter paramItem in
                     parameters.Select(param => new CommandParameter(param.Key, param.Value)))
            {
                paramCollection.Add(paramItem);
            }
            return(paramCollection);
        }
Esempio n. 7
0
        private static void AddParameter(string parameterName, List <Token> parameterTokens, CommandParameterCollection parameters)
        {
            if (string.IsNullOrWhiteSpace(parameterName))
            {
                return;
            }
            if (parameterTokens == null || parameterTokens.Count == 0)
            {
                parameters.Add(new CommandParameter(parameterName));
                return;
            }
            int    i   = 0;
            object obj = null;

            i = CmdletValidator.GetParameterValue(parameterTokens, i, out obj);
            if (obj != null && i >= parameterTokens.Count)
            {
                parameters.Add(new CommandParameter(parameterName, obj));
                return;
            }
            List <object> list = new List <object>();

            if (obj != null)
            {
                list.Add(obj);
            }
            while (i < parameterTokens.Count)
            {
                i = CmdletValidator.GetParameterValue(parameterTokens, i, out obj);
                if (obj != null)
                {
                    list.Add(obj);
                }
            }
            parameters.Add(new CommandParameter(parameterName, list.ToArray()));
        }
Esempio n. 8
0
 private static void AddStartParametersFromCollection(Dictionary <string, object> collection, CommandParameterCollection allParams)
 {
     if (collection == null || collection.Count <= 0)
     {
         return;
     }
     else
     {
         Dictionary <string, object> strs = collection;
         foreach (CommandParameter commandParameter in strs.Select <KeyValuePair <string, object>, CommandParameter>((KeyValuePair <string, object> o) => new CommandParameter(o.Key, o.Value)))
         {
             allParams.Add(commandParameter);
         }
         return;
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Utility function to turn a dictionary of name/value pairs into a parameter collection
 /// </summary>
 /// <param name="parameters">The dictionary to convert</param>
 /// <returns>The converted collection</returns>
 private static CommandParameterCollection ConvertDictionaryToParameterCollection(IEnumerable<KeyValuePair<string, object>> parameters)
 {
     if (parameters == null)
         return null;
     CommandParameterCollection paramCollection = new CommandParameterCollection();
     foreach (CommandParameter paramItem in
         parameters.Select(param => new CommandParameter(param.Key, param.Value)))
     {
         paramCollection.Add(paramItem);
     }
     return paramCollection;
 }
        private IEnumerable <Job2> CreateJobsFromWorkflows(IEnumerable <Job2> workflowJobs, bool returnParents)
        {
            // Jobs in this collection correspond to the ContainerParentJob objects. PSWorkflowJob objects
            // are children of these.
            var reconstructedParentJobs = new Dictionary <Guid, Job2>();
            var jobs = new List <Job2>();

            if (workflowJobs == null)
            {
                return(jobs);
            }

            // If a workflow instance has incomplete metadata, we do not create the job for it.
            foreach (var job in workflowJobs)
            {
                var wfjob = job as PSWorkflowJob;
                Debug.Assert(wfjob != null, "Job supplied must be of type PSWorkflowJob");
                PSWorkflowInstance instance = wfjob.PSWorkflowInstance;
                Dbg.Assert(instance != null, "PSWorkflowInstance should be reconstructed before attempting to rehydrate job");

                if (!instance.JobStateRetrieved || instance.PSWorkflowContext.JobMetadata == null || instance.PSWorkflowContext.JobMetadata.Count == 0)
                {
                    continue;
                }

                object data;
                string name, command;
                Guid   instanceId;
                if (!GetJobInfoFromMetadata(instance, out command, out name, out instanceId))
                {
                    continue;
                }

                if (!instance.PSWorkflowContext.JobMetadata.TryGetValue(Constants.JobMetadataParentInstanceId, out data))
                {
                    continue;
                }
                var parentInstanceId = (Guid)data;

                // If the parent job is needed, find or create it now so that the ID is sequentially lower.
                if (returnParents && !reconstructedParentJobs.ContainsKey(parentInstanceId))
                {
                    if (!instance.PSWorkflowContext.JobMetadata.TryGetValue(Constants.JobMetadataParentName, out data))
                    {
                        continue;
                    }
                    var parentName = (string)data;

                    if (!instance.PSWorkflowContext.JobMetadata.TryGetValue(Constants.JobMetadataParentCommand, out data))
                    {
                        continue;
                    }
                    var parentCommand = (string)data;

                    JobIdentifier      parentId  = RetrieveJobIdForReuse(parentInstanceId);
                    ContainerParentJob parentJob = parentId != null
                                                       ? new ContainerParentJob(parentCommand, parentName, parentId, AdapterTypeName)
                                                       : new ContainerParentJob(parentCommand, parentName, parentInstanceId, AdapterTypeName);

                    // update job metadata with new parent session Id--needed for filtering.
                    // The pid in the metadata has already been updated at this point.
                    Dbg.Assert(
                        instance.PSWorkflowContext.JobMetadata.ContainsKey(Constants.JobMetadataParentSessionId),
                        "Job Metadata for instance incomplete.");
                    if (instance.PSWorkflowContext.JobMetadata.ContainsKey(Constants.JobMetadataParentSessionId))
                    {
                        instance.PSWorkflowContext.JobMetadata[Constants.JobMetadataParentSessionId] = parentJob.Id;
                    }

                    reconstructedParentJobs.Add(parentInstanceId, parentJob);
                }

                // update job metadata with new session Id--needed for filtering.
                Dbg.Assert(instance.PSWorkflowContext.JobMetadata.ContainsKey(Constants.JobMetadataSessionId), "Job Metadata for instance incomplete.");
                Dbg.Assert(instance.PSWorkflowContext.JobMetadata.ContainsKey(Constants.JobMetadataPid), "Job Metadata for instance incomplete.");
                if (instance.PSWorkflowContext.JobMetadata.ContainsKey(Constants.JobMetadataSessionId))
                {
                    instance.PSWorkflowContext.JobMetadata[Constants.JobMetadataSessionId] = job.Id;
                }
                if (instance.PSWorkflowContext.JobMetadata.ContainsKey(Constants.JobMetadataPid))
                {
                    instance.PSWorkflowContext.JobMetadata[Constants.JobMetadataPid] = Process.GetCurrentProcess().Id;
                }

                job.StartParameters = new List <CommandParameterCollection>();
                CommandParameterCollection commandParameterCollection = new CommandParameterCollection();
                AddStartParametersFromCollection(instance.PSWorkflowContext.WorkflowParameters, commandParameterCollection);
                AddStartParametersFromCollection(instance.PSWorkflowContext.PSWorkflowCommonParameters, commandParameterCollection);

                bool takesPSPrivateMetadata;
                if (instance.PSWorkflowContext.JobMetadata.ContainsKey(Constants.WorkflowTakesPrivateMetadata))
                {
                    takesPSPrivateMetadata = (bool)instance.PSWorkflowContext.JobMetadata[Constants.WorkflowTakesPrivateMetadata];
                }
                else
                {
                    DynamicActivity da = instance.PSWorkflowDefinition != null ? instance.PSWorkflowDefinition.Workflow as DynamicActivity : null;
                    takesPSPrivateMetadata = da != null && da.Properties.Contains(Constants.PrivateMetadata);
                }

                // If there is Private Metadata and it is not included in the "Input" collection, add it now.
                if (instance.PSWorkflowContext.PrivateMetadata != null &&
                    instance.PSWorkflowContext.PrivateMetadata.Count > 0 &&
                    !takesPSPrivateMetadata)
                {
                    Hashtable privateMetadata = new Hashtable();
                    foreach (var pair in instance.PSWorkflowContext.PrivateMetadata)
                    {
                        privateMetadata.Add(pair.Key, pair.Value);
                    }
                    commandParameterCollection.Add(new CommandParameter(Constants.PrivateMetadata, privateMetadata));
                }
                job.StartParameters.Add(commandParameterCollection);

                if (returnParents)
                {
                    ((ContainerParentJob)reconstructedParentJobs[parentInstanceId]).AddChildJob(job);
                }
                else
                {
                    jobs.Add(job);
                }

                if (!wfjob.WorkflowInstanceLoaded)
                {
                    // RestoreFromWorkflowInstance sets the job state. Because we've used AddChildJob, the parent's state will be
                    // updated automatically.
                    wfjob.RestoreFromWorkflowInstance(instance);
                }
            }

            if (returnParents)
            {
                jobs.AddRange(reconstructedParentJobs.Values);
            }

            return(jobs);
        }
Esempio n. 11
0
        private void DeserializeInvocationInfo(SerializationInfo info)
        {
            string command = info.GetString("InvocationInfo_Command");
            string name = info.GetString("InvocationInfo_Name");
            string moduleName = info.GetString("InvocationInfo_ModuleName");
            string adapterTypeName = info.GetString("InvocationInfo_AdapterTypeName");

            //
            // Parameters
            Dictionary<string, object> parameters = new Dictionary<string, object>();

            // ScriptBlock
            string script = info.GetString("InvocationParam_ScriptBlock");
            if (script != null)
            {
                parameters.Add(ScriptBlockParameter, ScriptBlock.Create(script));
            }

            // FilePath
            string filePath = info.GetString("InvocationParam_FilePath");
            if (!string.IsNullOrEmpty(filePath))
            {
                parameters.Add(FilePathParameter, filePath);
            }

            // InitializationScript
            script = info.GetString("InvocationParam_InitScript");
            if (!string.IsNullOrEmpty(script))
            {
                parameters.Add(InitializationScriptParameter, ScriptBlock.Create(script));
            }

            // RunAs32
            bool runAs32 = info.GetBoolean("InvocationParam_RunAs32");
            parameters.Add(RunAs32Parameter, runAs32);

            // Authentication
            AuthenticationMechanism authentication = (AuthenticationMechanism)info.GetValue("InvocationParam_Authentication",
                typeof(AuthenticationMechanism));
            parameters.Add(AuthenticationParameter, authentication);

            // ArgumentList
            object[] argList = (object[])info.GetValue("InvocationParam_ArgList", typeof(object[]));
            if (argList != null)
            {
                parameters.Add(ArgumentListParameter, argList);
            }

            JobDefinition jobDefinition = new JobDefinition(null, command, name);
            jobDefinition.ModuleName = moduleName;
            jobDefinition.JobSourceAdapterTypeName = adapterTypeName;

            // Convert to JobInvocationParameter collection
            CommandParameterCollection paramCollection = new CommandParameterCollection();
            foreach (KeyValuePair<string, object> param in parameters)
            {
                CommandParameter paramItem = new CommandParameter(param.Key, param.Value);
                paramCollection.Add(paramItem);
            }

            this.Definition = jobDefinition;
            this.Name = name;
            this.Command = command;
            this.Parameters.Add(paramCollection);
        }
Esempio n. 12
0
        private void CreateChildJob(JobInvocationInfo specification, Activity activity, ContainerParentJob newJob, CommandParameterCollection commandParameterCollection, Dictionary<string, object> parameterDictionary, string computerName, string[] computerNames)
        {
            if (!string.IsNullOrEmpty(computerName))
            {
                string[] childTargetComputerList = { computerName };

                // Set the target computer for this child job...
                parameterDictionary[Constants.ComputerName] = childTargetComputerList;
            }

            var childSpecification = new JobInvocationInfo(specification.Definition, parameterDictionary);

            // Job objects will be disposed of on parent job removal.
            var childJob = new PSWorkflowJob(_runtime, childSpecification);
            childJob.JobMetadata = CreateJobMetadata(childJob, newJob.InstanceId, newJob.Id, newJob.Name, newJob.Command, computerNames);

            // Remove the parameter from the collection...
            for (int index = 0; index < commandParameterCollection.Count; index++)
            {
                if (string.Equals(commandParameterCollection[index].Name, Constants.ComputerName, StringComparison.OrdinalIgnoreCase))
                {
                    commandParameterCollection.RemoveAt(index);
                    break;
                }
            }

            if (!string.IsNullOrEmpty(computerName))
            {
                var computerNameParameter = new CommandParameter(Constants.ComputerName, computerName);
                commandParameterCollection.Add(computerNameParameter);
            }

            this.AddJob(childJob);
            childJob.LoadWorkflow(commandParameterCollection, activity, null);
            newJob.AddChildJob(childJob);
            StructuredTracer.ChildWorkflowJobAddition(childJob.InstanceId, newJob.InstanceId);
            Tracer.TraceJob(childJob);
            StructuredTracer.WorkflowJobCreated(newJob.InstanceId, childJob.InstanceId, childJob.WorkflowGuid);
        }
Esempio n. 13
0
		private void CreateChildJob(JobInvocationInfo specification, Activity activity, ContainerParentJob newJob, CommandParameterCollection commandParameterCollection, Dictionary<string, object> parameterDictionary, string computerName, string[] computerNames)
		{
			if (!string.IsNullOrEmpty(computerName))
			{
				string[] strArrays = new string[1];
				strArrays[0] = computerName;
				string[] strArrays1 = strArrays;
				parameterDictionary["PSComputerName"] = strArrays1;
			}
			JobInvocationInfo jobInvocationInfo = new JobInvocationInfo(specification.Definition, parameterDictionary);
			PSWorkflowJob pSWorkflowJob = new PSWorkflowJob(this._runtime, jobInvocationInfo);
			pSWorkflowJob.JobMetadata = PSWorkflowJobManager.CreateJobMetadata(pSWorkflowJob, newJob.InstanceId, newJob.Id, newJob.Name, newJob.Command, computerNames);
			int num = 0;
			while (num < commandParameterCollection.Count)
			{
				if (!string.Equals(commandParameterCollection[num].Name, "PSComputerName", StringComparison.OrdinalIgnoreCase))
				{
					num++;
				}
				else
				{
					commandParameterCollection.RemoveAt(num);
					break;
				}
			}
			if (!string.IsNullOrEmpty(computerName))
			{
				CommandParameter commandParameter = new CommandParameter("PSComputerName", computerName);
				commandParameterCollection.Add(commandParameter);
			}
			this.AddJob(pSWorkflowJob);
			pSWorkflowJob.LoadWorkflow(commandParameterCollection, activity, null);
			newJob.AddChildJob(pSWorkflowJob);
			PSWorkflowJobManager.StructuredTracer.ChildWorkflowJobAddition(pSWorkflowJob.InstanceId, newJob.InstanceId);
			PSWorkflowJobManager.Tracer.TraceJob(pSWorkflowJob);
			PSWorkflowJobManager.StructuredTracer.WorkflowJobCreated(newJob.InstanceId, pSWorkflowJob.InstanceId, pSWorkflowJob.WorkflowGuid);
		}
Esempio n. 14
0
        private IEnumerable <Job2> CreateJobsFromWorkflows(IEnumerable <Job2> workflowJobs, bool returnParents)
        {
            object                  obj  = null;
            string                  str  = null;
            string                  str1 = null;
            Guid                    guid;
            bool                    item;
            DynamicActivity         workflow;
            bool                    flag;
            ContainerParentJob      containerParentJob;
            Dictionary <Guid, Job2> guids = new Dictionary <Guid, Job2>();
            List <Job2>             job2s = new List <Job2>();

            if (workflowJobs != null)
            {
                foreach (Job2 workflowJob in workflowJobs)
                {
                    PSWorkflowJob      pSWorkflowJob      = workflowJob as PSWorkflowJob;
                    PSWorkflowInstance pSWorkflowInstance = pSWorkflowJob.PSWorkflowInstance;
                    if (!pSWorkflowInstance.JobStateRetrieved || pSWorkflowInstance.PSWorkflowContext.JobMetadata == null || pSWorkflowInstance.PSWorkflowContext.JobMetadata.Count == 0 || !WorkflowJobSourceAdapter.GetJobInfoFromMetadata(pSWorkflowInstance, out str1, out str, out guid) || !pSWorkflowInstance.PSWorkflowContext.JobMetadata.TryGetValue("ParentInstanceId", out obj))
                    {
                        continue;
                    }
                    Guid guid1 = (Guid)obj;
                    if (returnParents && !guids.ContainsKey(guid1))
                    {
                        if (!pSWorkflowInstance.PSWorkflowContext.JobMetadata.TryGetValue("ParentName", out obj))
                        {
                            continue;
                        }
                        string str2 = (string)obj;
                        if (!pSWorkflowInstance.PSWorkflowContext.JobMetadata.TryGetValue("ParentCommand", out obj))
                        {
                            continue;
                        }
                        string        str3          = (string)obj;
                        JobIdentifier jobIdentifier = base.RetrieveJobIdForReuse(guid1);
                        if (jobIdentifier != null)
                        {
                            containerParentJob = new ContainerParentJob(str3, str2, jobIdentifier, "PSWorkflowJob");
                        }
                        else
                        {
                            containerParentJob = new ContainerParentJob(str3, str2, guid1, "PSWorkflowJob");
                        }
                        ContainerParentJob containerParentJob1 = containerParentJob;
                        if (pSWorkflowInstance.PSWorkflowContext.JobMetadata.ContainsKey("ParentSessionId"))
                        {
                            pSWorkflowInstance.PSWorkflowContext.JobMetadata["ParentSessionId"] = containerParentJob1.Id;
                        }
                        guids.Add(guid1, containerParentJob1);
                    }
                    if (pSWorkflowInstance.PSWorkflowContext.JobMetadata.ContainsKey("Id"))
                    {
                        pSWorkflowInstance.PSWorkflowContext.JobMetadata["Id"] = workflowJob.Id;
                    }
                    if (pSWorkflowInstance.PSWorkflowContext.JobMetadata.ContainsKey("ProcessId"))
                    {
                        pSWorkflowInstance.PSWorkflowContext.JobMetadata["ProcessId"] = Process.GetCurrentProcess().Id;
                    }
                    workflowJob.StartParameters = new List <CommandParameterCollection>();
                    CommandParameterCollection commandParameterCollection = new CommandParameterCollection();
                    WorkflowJobSourceAdapter.AddStartParametersFromCollection(pSWorkflowInstance.PSWorkflowContext.WorkflowParameters, commandParameterCollection);
                    WorkflowJobSourceAdapter.AddStartParametersFromCollection(pSWorkflowInstance.PSWorkflowContext.PSWorkflowCommonParameters, commandParameterCollection);
                    if (!pSWorkflowInstance.PSWorkflowContext.JobMetadata.ContainsKey("WorkflowTakesPrivateMetadata"))
                    {
                        if (pSWorkflowInstance.PSWorkflowDefinition != null)
                        {
                            workflow = pSWorkflowInstance.PSWorkflowDefinition.Workflow as DynamicActivity;
                        }
                        else
                        {
                            workflow = null;
                        }
                        DynamicActivity dynamicActivity = workflow;
                        if (dynamicActivity == null)
                        {
                            flag = false;
                        }
                        else
                        {
                            flag = dynamicActivity.Properties.Contains("PSPrivateMetadata");
                        }
                        item = flag;
                    }
                    else
                    {
                        item = (bool)pSWorkflowInstance.PSWorkflowContext.JobMetadata["WorkflowTakesPrivateMetadata"];
                    }
                    if (pSWorkflowInstance.PSWorkflowContext.PrivateMetadata != null && pSWorkflowInstance.PSWorkflowContext.PrivateMetadata.Count > 0 && !item)
                    {
                        Hashtable hashtables = new Hashtable();
                        foreach (KeyValuePair <string, object> privateMetadatum in pSWorkflowInstance.PSWorkflowContext.PrivateMetadata)
                        {
                            hashtables.Add(privateMetadatum.Key, privateMetadatum.Value);
                        }
                        commandParameterCollection.Add(new CommandParameter("PSPrivateMetadata", hashtables));
                    }
                    workflowJob.StartParameters.Add(commandParameterCollection);
                    if (!returnParents)
                    {
                        job2s.Add(workflowJob);
                    }
                    else
                    {
                        ((ContainerParentJob)guids[guid1]).AddChildJob(workflowJob);
                    }
                    if (pSWorkflowJob.WorkflowInstanceLoaded)
                    {
                        continue;
                    }
                    pSWorkflowJob.RestoreFromWorkflowInstance(pSWorkflowInstance);
                }
                if (returnParents)
                {
                    foreach (Job2 value in guids.Values)
                    {
                        PSSQMAPI.InitiateWorkflowStateDataTracking(value);
                    }
                    job2s.AddRange(guids.Values);
                }
                return(job2s);
            }
            else
            {
                return(job2s);
            }
        }
Esempio n. 15
0
 private static CommandParameterCollection ConvertDictionaryToParameterCollection(IEnumerable<KeyValuePair<string, object>> parameters)
 {
     if (parameters == null)
     {
         return null;
     }
     CommandParameterCollection parameters2 = new CommandParameterCollection();
     foreach (CommandParameter parameter in from param in parameters select new CommandParameter(param.Key, param.Value))
     {
         parameters2.Add(parameter);
     }
     return parameters2;
 }
Esempio n. 16
0
		private void DeserializeInvocationInfo(SerializationInfo info)
		{
			string str = info.GetString("InvocationInfo_Command");
			string str1 = info.GetString("InvocationInfo_Name");
			string str2 = info.GetString("InvocationInfo_ModuleName");
			string str3 = info.GetString("InvocationInfo_AdapterTypeName");
			Dictionary<string, object> strs = new Dictionary<string, object>();
			string str4 = info.GetString("InvocationParam_ScriptBlock");
			if (str4 != null)
			{
				strs.Add("ScriptBlock", ScriptBlock.Create(str4));
			}
			string str5 = info.GetString("InvocationParam_FilePath");
			if (!string.IsNullOrEmpty(str5))
			{
				strs.Add("FilePath", str5);
			}
			str4 = info.GetString("InvocationParam_InitScript");
			if (!string.IsNullOrEmpty(str4))
			{
				strs.Add("InitializationScript", ScriptBlock.Create(str4));
			}
			bool flag = info.GetBoolean("InvocationParam_RunAs32");
			strs.Add("RunAs32", flag);
			AuthenticationMechanism value = (AuthenticationMechanism)info.GetValue("InvocationParam_Authentication", typeof(AuthenticationMechanism));
			strs.Add("Authentication", value);
			object[] objArray = (object[])info.GetValue("InvocationParam_ArgList", typeof(object[]));
			if (objArray != null)
			{
				strs.Add("ArgumentList", objArray);
			}
			JobDefinition jobDefinition = new JobDefinition(null, str, str1);
			jobDefinition.ModuleName = str2;
			jobDefinition.JobSourceAdapterTypeName = str3;
			CommandParameterCollection commandParameterCollection = new CommandParameterCollection();
			foreach (KeyValuePair<string, object> keyValuePair in strs)
			{
				CommandParameter commandParameter = new CommandParameter(keyValuePair.Key, keyValuePair.Value);
				commandParameterCollection.Add(commandParameter);
			}
			base.Definition = jobDefinition;
			base.Name = str1;
			base.Command = str;
			base.Parameters.Add(commandParameterCollection);
		}