Exemplo n.º 1
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (AsJob.Expression != null)
            {
                targetCommand.AddParameter("AsJob", AsJob.Get(context));
            }

            if (DcomAuthentication.Expression != null)
            {
                targetCommand.AddParameter("DcomAuthentication", DcomAuthentication.Get(context));
            }

            if (WsmanAuthentication.Expression != null)
            {
                targetCommand.AddParameter("WsmanAuthentication", WsmanAuthentication.Get(context));
            }

            if (Protocol.Expression != null)
            {
                targetCommand.AddParameter("Protocol", Protocol.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (Impersonation.Expression != null)
            {
                targetCommand.AddParameter("Impersonation", Impersonation.Get(context));
            }

            if (ThrottleLimit.Expression != null)
            {
                targetCommand.AddParameter("ThrottleLimit", ThrottleLimit.Get(context));
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom))
            {
                targetCommand.AddParameter("ComputerName", PSComputerName.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Exemplo n.º 2
0
 private void Loop()
 {
     foreach (SharedParent parent in _parents)
     {
         _tableInfo = _impersonation.Get(parent.TableType);
         _queryBuild.Build(parent);
         TableSeed(parent);
         if (_tableInfo.UniqueColumns.Count > 0)
         {
             ApplyIndex(parent);
         }
         BulkCopy(parent);
     }
 }
Exemplo n.º 3
0
        private bool NeedSync(string dbf, string type, string currentPackage)
        {
            TableInfo info = _impersonation.Get(type);

            if (info.Ignore)
            {
                return(false);
            }
            if (_interaction.GetSyncInfo(dbf, currentPackage))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 4
0
        public void Build(SharedParent parent)
        {
            try
            {
                parent.SeedQueries = new List <Query>();
                TableInfo info = _impersonation.Get(parent.TableType);

                Create(info, parent);
                if (info.UniqueColumns.Count > 0)
                {
                    Index(info, parent);
                }
            } catch (Exception e)
            {
                _log.Accept(new Execution($"Failed to build query for {parent.TableType} " +
                                          $"problem: {e.Message}"));
                throw;
            }
        }
Exemplo n.º 5
0
 public void Process(ICollection <ExtractionModel> extractionModels)
 {
     if (extractionModels.Count == 0)
     {
         return;
     }
     foreach (ExtractionModel extractionModel in extractionModels)
     {
         TableInfo info = _impersonation.Get(extractionModel.TableType);
         try
         {
             FillShareds(extractionModel, info);
         }
         catch (ExtractionException e)
         {
             _log.Accept(new Execution($"{e.Message}"));
             throw;
         }
     }
 }
        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Get the host default values we should use if no explicit parameter was provided.
            var hostExtension = context.GetExtension <HostParameterDefaults>();
            Dictionary <string, object> parameterDefaults = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);

            if (hostExtension != null)
            {
                Dictionary <string, object> incomingArguments = hostExtension.Parameters;
                foreach (KeyValuePair <string, object> parameterDefault in incomingArguments)
                {
                    parameterDefaults[parameterDefault.Key] = parameterDefault.Value;
                }
            }


            if (DcomAuthentication.Expression != null)
            {
                targetCommand.AddParameter("DcomAuthentication", DcomAuthentication.Get(context));
            }

            if (Impersonation.Expression != null)
            {
                targetCommand.AddParameter("Impersonation", Impersonation.Get(context));
            }

            // See if the DCOM protocol is to be used
            bool usingDcom = false;

            if (Protocol.Expression != null)
            {
                string protocol = Protocol.Get(context);
                targetCommand.AddParameter("Protocol", protocol);
                if (string.Equals(protocol, "DCOM", StringComparison.OrdinalIgnoreCase))
                {
                    usingDcom = true;
                }
            }

            // Get the WSMan authentication mechanism to use. If no expression was specified,
            // and DCOM is not being used, get the default from the host.
            if (WsmanAuthentication.Expression != null)
            {
                targetCommand.AddParameter("WsmanAuthentication", WsmanAuthentication.Get(context));
            }
            else
            {
                if (!usingDcom)
                {
                    if (parameterDefaults.ContainsKey("PSAuthentication"))
                    {
                        string authString = parameterDefaults["PSAuthentication"].ToString();
                        // Note: the underlying cmdlet does support NegotiateWithImplicitCredential so it is expected
                        // that passing this in as-is will result in an (appropriate) error being emitted in that case.
                        targetCommand.AddParameter("WsmanAuthentication", authString);
                    }
                }
            }

            // Map PSComputerName to the underlying cmdlet name only if the computername is not empty
            string[] computerName = GetPSComputerName(context);
            if ((computerName != null) && (computerName.Length != 0))
            {
                targetCommand.AddParameter("ComputerName", computerName);
            }

            // Map PSCredential to credential. If no expression was provided, then use the default.
            if (PSCredential.Expression != null)
            {
                targetCommand.AddParameter("Credential", PSCredential.Get(context));
            }
            else
            {
                if (parameterDefaults.ContainsKey("PSCredential"))
                {
                    targetCommand.AddParameter("Credential", parameterDefaults["PSCredential"]);
                }
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (ThrottleLimit.Expression != null)
            {
                targetCommand.AddParameter("ThrottleLimit", ThrottleLimit.Get(context));
            }

            // Ignore the -Wait parameter in the self-restart case.
            if (!IsSelfRestart(context))
            {
                if (Wait.Expression != null)
                {
                    targetCommand.AddParameter("Wait", Wait.Get(context));
                }

                if (For.Expression != null)
                {
                    targetCommand.AddParameter("For", For.Get(context));
                }

                if (Delay.Expression != null)
                {
                    targetCommand.AddParameter("Delay", Delay.Get(context));
                }
            }

            if (Timeout.Expression != null)
            {
                targetCommand.AddParameter("Timeout", Timeout.Get(context));
            }

            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (NoEncryption.Expression != null)
            {
                targetCommand.AddParameter("NoEncryption", NoEncryption.Get(context));
            }

            if (CertificateCACheck.Expression != null)
            {
                targetCommand.AddParameter("CertificateCACheck", CertificateCACheck.Get(context));
            }

            if (CertificateCNCheck.Expression != null)
            {
                targetCommand.AddParameter("CertificateCNCheck", CertificateCNCheck.Get(context));
            }

            if (CertRevocationCheck.Expression != null)
            {
                targetCommand.AddParameter("CertRevocationCheck", CertRevocationCheck.Get(context));
            }

            if (EncodePortInServicePrincipalName.Expression != null)
            {
                targetCommand.AddParameter("EncodePortInServicePrincipalName", EncodePortInServicePrincipalName.Get(context));
            }

            if (Encoding.Expression != null)
            {
                targetCommand.AddParameter("Encoding", Encoding.Get(context));
            }

            if (HttpPrefix.Expression != null)
            {
                targetCommand.AddParameter("HttpPrefix", HttpPrefix.Get(context));
            }

            if (MaxEnvelopeSizeKB.Expression != null)
            {
                targetCommand.AddParameter("MaxEnvelopeSizeKB", MaxEnvelopeSizeKB.Get(context));
            }

            if (ProxyAuthentication.Expression != null)
            {
                targetCommand.AddParameter("ProxyAuthentication", ProxyAuthentication.Get(context));
            }

            if (ProxyCertificateThumbprint.Expression != null)
            {
                targetCommand.AddParameter("ProxyCertificateThumbprint", ProxyCertificateThumbprint.Get(context));
            }

            if (ProxyCredential.Expression != null)
            {
                targetCommand.AddParameter("ProxyCredential", ProxyCredential.Get(context));
            }

            if (ProxyType.Expression != null)
            {
                targetCommand.AddParameter("ProxyType", ProxyType.Get(context));
            }

            if (UseSsl.Expression != null)
            {
                targetCommand.AddParameter("UseSsl", UseSsl.Get(context));
            }

            if (Impersonation.Expression != null)
            {
                targetCommand.AddParameter("Impersonation", Impersonation.Get(context));
            }

            if (PacketIntegrity.Expression != null)
            {
                targetCommand.AddParameter("PacketIntegrity", PacketIntegrity.Get(context));
            }

            if (PacketPrivacy.Expression != null)
            {
                targetCommand.AddParameter("PacketPrivacy", PacketPrivacy.Get(context));
            }

            if (Protocol.Expression != null)
            {
                targetCommand.AddParameter("Protocol", Protocol.Get(context));
            }

            if (UICulture.Expression != null)
            {
                targetCommand.AddParameter("UICulture", UICulture.Get(context));
            }

            if (Culture.Expression != null)
            {
                targetCommand.AddParameter("Culture", Culture.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Exemplo n.º 8
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (InputObject.Expression != null)
            {
                targetCommand.AddParameter("InputObject", InputObject.Get(context));
            }

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (Class.Expression != null)
            {
                targetCommand.AddParameter("Class", Class.Get(context));
            }

            if (Arguments.Expression != null)
            {
                targetCommand.AddParameter("Arguments", Arguments.Get(context));
            }

            if (PutType.Expression != null)
            {
                targetCommand.AddParameter("PutType", PutType.Get(context));
            }

            if (AsJob.Expression != null)
            {
                targetCommand.AddParameter("AsJob", AsJob.Get(context));
            }

            if (Impersonation.Expression != null)
            {
                targetCommand.AddParameter("Impersonation", Impersonation.Get(context));
            }

            if (Authentication.Expression != null)
            {
                targetCommand.AddParameter("Authentication", Authentication.Get(context));
            }

            if (Locale.Expression != null)
            {
                targetCommand.AddParameter("Locale", Locale.Get(context));
            }

            if (EnableAllPrivileges.Expression != null)
            {
                targetCommand.AddParameter("EnableAllPrivileges", EnableAllPrivileges.Get(context));
            }

            if (Authority.Expression != null)
            {
                targetCommand.AddParameter("Authority", Authority.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (ThrottleLimit.Expression != null)
            {
                targetCommand.AddParameter("ThrottleLimit", ThrottleLimit.Get(context));
            }

            if (ComputerName.Expression != null)
            {
                targetCommand.AddParameter("ComputerName", ComputerName.Get(context));
            }

            if (Namespace.Expression != null)
            {
                targetCommand.AddParameter("Namespace", Namespace.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Exemplo n.º 9
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (AsJob.Expression != null)
            {
                targetCommand.AddParameter("AsJob", AsJob.Get(context));
            }

            if (DcomAuthentication.Expression != null)
            {
                targetCommand.AddParameter("DcomAuthentication", DcomAuthentication.Get(context));
            }

            if (WsmanAuthentication.Expression != null)
            {
                targetCommand.AddParameter("WsmanAuthentication", WsmanAuthentication.Get(context));
            }

            if (Protocol.Expression != null)
            {
                targetCommand.AddParameter("Protocol", Protocol.Get(context));
            }

            if (BufferSize.Expression != null)
            {
                targetCommand.AddParameter("BufferSize", BufferSize.Get(context));
            }

            if (ComputerName.Expression != null)
            {
                targetCommand.AddParameter("ComputerName", ComputerName.Get(context));
            }

            if (Count.Expression != null)
            {
                targetCommand.AddParameter("Count", Count.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (Source.Expression != null)
            {
                targetCommand.AddParameter("Source", Source.Get(context));
            }

            if (Impersonation.Expression != null)
            {
                targetCommand.AddParameter("Impersonation", Impersonation.Get(context));
            }

            if (ThrottleLimit.Expression != null)
            {
                targetCommand.AddParameter("ThrottleLimit", ThrottleLimit.Get(context));
            }

            if (TimeToLive.Expression != null)
            {
                targetCommand.AddParameter("TimeToLive", TimeToLive.Get(context));
            }

            if (Delay.Expression != null)
            {
                targetCommand.AddParameter("Delay", Delay.Get(context));
            }

            if (Quiet.Expression != null)
            {
                targetCommand.AddParameter("Quiet", Quiet.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }