示例#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 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 (Delimiter.Expression != null)
            {
                targetCommand.AddParameter("Delimiter", Delimiter.Get(context));
            }

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

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

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


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
示例#2
0
        protected override void Execute(CodeActivityContext context)
        {
            var inputString = InputString.Get(context);
            var delimiter   = Delimiter.Get(context);

            var strArray = inputString.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

            // Declare DataTable object.
            var dt = new System.Data.DataTable();

            // Add columns to the DataTable
            dt.Columns.Add("LINENUMBER", typeof(String));
            dt.Columns.Add("PARTNUMBER", typeof(String));
            dt.Columns.Add("DESCRIPTION", typeof(String));
            dt.Columns.Add("ORDERQTY", typeof(String));
            dt.Columns.Add("UNITPRICE", typeof(String));

            // Add strings from string array to datatable
            foreach (string str in strArray)
            {
                var drow = dt.NewRow();   // Here you will get an actual instance of a DataRow

                var strArrayTemp = str.Split(new string[] { delimiter }, StringSplitOptions.None);

                drow[0] = strArrayTemp[0];
                drow[1] = strArrayTemp[1];
                drow[2] = strArrayTemp[2];
                drow[3] = strArrayTemp[3];
                drow[4] = strArrayTemp[4];

                dt.Rows.Add(drow);             // Don't forget to add the row to the DataTable.
            }

            dtOutput.Set(context, dt);
        }
        // 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 (Delimiter.Expression != null)
            {
                targetCommand.AddParameter("Delimiter", Delimiter.Get(context));
            }

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

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

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

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

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

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


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
示例#4
0
 protected override void Execute(NativeActivityContext context)
 {
     try
     {
         string    strFilePath         = FilePath.Get(context);
         string    strDelimiter        = Delimiter.Get(context);
         string    strDefaultTableName = DefaultTableName.Get(context);
         DataTable MyResultTable       = GetDataTabletFromCSVFile(strFilePath, strDefaultTableName, strDelimiter);
         if (MyResultTable != null)
         {
             ResultTable.Set(context, MyResultTable);
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Logger.LogData(ex.Message + " in activity CSV_Read", Logger.LogLevel.Error);
         if (!ContinueOnError)
         {
             context.Abort();
         }
     }
 }
示例#5
0
 protected override void Execute(NativeActivityContext context)
 {
     try
     {
         string    strFilePath  = FilePath.Get(context);
         string    strDelimiter = Delimiter.Get(context);
         DataTable dtDataTable  = TableToSave.Get(context);
         bool      result       = ExpoetToCSV(dtDataTable, strFilePath, strDelimiter);
         Result.Set(context, result);
         //if (MyResultTable != null)
         //{
         //    TableToSave.Set(context, MyResultTable);
         //}
     }
     catch (Exception ex)
     {
         Logger.Log.Logger.LogData(ex.Message + " in activity CSV_Write", Logger.LogLevel.Error);
         if (!ContinueOnError)
         {
             context.Abort();
         }
     }
 }
        // 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 (ReadCount.Expression != null)
            {
                targetCommand.AddParameter("ReadCount", ReadCount.Get(context));
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
示例#7
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 (InputObject.Expression != null)
            {
                targetCommand.AddParameter("InputObject", InputObject.Get(context));
            }

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

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

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

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

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

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

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

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

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


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