Exemplo n.º 1
0
 public void Execute(IActivityRequest request, IActivityResponse response)
 {
     inputString = request.Inputs["Input String"].AsString();
     try
     {
         response.PublishRange(getLines());
     }
     catch (Exception ex)
     {
         response.ReportErrorEvent("Failed to parse line", ex.ToString());
     }
 }
Exemplo n.º 2
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            List <ACLEntry> aclEntries = new List <ACLEntry>();
            FileAttributes  attr       = File.GetAttributes(request.Inputs[PATH].AsString());

            if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
            {
                DirectoryInfo dirInfo = new DirectoryInfo(request.Inputs[PATH].AsString());
                foreach (FileSystemAccessRule fsAccessRule in dirInfo.GetAccessControl().GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)))
                {
                    aclEntries.Add(new ACLEntry(fsAccessRule));
                }
            }
            else
            {
                FileInfo fileInfo = new FileInfo(request.Inputs[PATH].AsString());
                foreach (FileSystemAccessRule fsAccessRule in fileInfo.GetAccessControl().GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)))
                {
                    aclEntries.Add(new ACLEntry(fsAccessRule));
                }
            }
            response.PublishRange(aclEntries);
        }
Exemplo n.º 3
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            string FilePath  = request.Inputs["Excel File Path"].AsString();
            string SheetName = request.Inputs["Sheet Name"].AsString();

            if (SheetName == "")
            {
                SheetName = FieldValue_SheetName;
            }
            bool   HasHeaderRow = request.Inputs["Has Header Row"].AsBoolean();
            bool   ForceMixedDataAsText;
            string CSVDelimiter = request.Inputs["CSV Delimiter"].AsString();

            if (CSVDelimiter == "")
            {
                CSVDelimiter = FieldValue_CSVDelimiter;
            }
            if (request.Inputs["Force mixed data to be converted to text"].ToString() != "")
            {
                ForceMixedDataAsText = request.Inputs["Force mixed data to be converted to text"].AsBoolean();
            }
            else
            {
                ForceMixedDataAsText = true;
            }

            int TypeGuessRows;

            if (request.Inputs["TypeGuessRows"].ToString() != "")
            {
                TypeGuessRows = request.Inputs["TypeGuessRows"].AsInt16();
            }
            else
            {
                TypeGuessRows = 8;
            }
            string SemiColonReplacement = request.Inputs["; Replacement"].AsString();

            if (SemiColonReplacement == "")
            {
                SemiColonReplacement = "_";
            }

            //Read Filter Values
            string SelectFilter = "Select *";
            string WhereFilter  = "";

            foreach (IFilterCriteria filter in request.Filters)
            {
                switch (filter.Name)
                {
                case "Select filter":
                    switch (filter.Relation)
                    {
                    case Relation.EqualTo:
                        SelectFilter = filter.Value.AsString();
                        break;
                    }
                    break;

                case "Where filter":
                    switch (filter.Relation)
                    {
                    case Relation.EqualTo:
                        WhereFilter = filter.Value.AsString();
                        break;
                    }
                    break;
                }
            }
            if (SelectFilter == "")
            {
                SelectFilter = "Select *";
            }
            else if (SelectFilter.ToLower().StartsWith("select ") == false)
            {
                SelectFilter = "Select " + SelectFilter;
            }
            if (WhereFilter != "" && WhereFilter.ToLower().StartsWith("where ") == false)
            {
                WhereFilter = "Where " + WhereFilter;
            }

            System.Collections.IEnumerable FullLines = null;
            int             RowCount = 0;
            DataSet         ds       = null;
            OleDbConnection con      = null;

            ExcelObj = new Excel();
            Excel.ExcelFileType FileType = Excel.GetFileType(FilePath);

            try
            {
                con = ExcelObj.OpenExcelFile(FilePath, SheetName, FileType, HasHeaderRow, ForceMixedDataAsText, TypeGuessRows, CSVDelimiter);
                ds  = ExcelObj.ReadSheetFromExcel(FilePath, SheetName, FileType, ref con, SelectFilter, WhereFilter);
            }
            catch (System.Exception ex)
            {
                ExcelObj.CloseExcelFile(ref con);   //Ensure the excel file is closed before throwing the error.
                throw (ex);
            }
            ExcelObj.CloseExcelFile(ref con);


            if (ds.Tables.Count > 0)
            {
                RowCount  = ds.Tables[0].Rows.Count;
                FullLines = GetFullLines(ds, SemiColonReplacement);
            }

            response.Publish("Excel File Path", FilePath);
            response.Publish("Sheet Name", SheetName);
            response.Publish("Number of rows", RowCount);
            response.Publish("Has Header Row", HasHeaderRow);
            response.Publish("Force mixed data to be converted to text", ForceMixedDataAsText);
            response.Publish("TypeGuessRows", TypeGuessRows);
            response.Publish("CSV Delimiter", CSVDelimiter);
            response.Publish("; Replacement", SemiColonReplacement);
            response.Publish("Select filter", SelectFilter);
            response.Publish("Where filter", WhereFilter);

            if (FullLines != null)
            {
                response.PublishRange("Full line as string with fields separated by ;", FullLines);
            }
            else
            {
                response.Publish("Full line as string with fields separated by ;", "No data returned");
            }
        }
Exemplo n.º 4
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            string _moduleName = string.Empty;
            string _cmdletName = string.Empty;
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            foreach (string input in request.Inputs.Names)
            {
                string _parameter = string.Empty;
                string _type      = string.Empty;
                string _value     = string.Empty;
                switch (input)
                {
                case ("Module Name"):
                    _moduleName = request.Inputs[input].AsString();
                    break;

                case ("Cmdlet Name"):
                    _cmdletName = request.Inputs[input].AsString();
                    break;

                case ("ParameterSet"):
                    break;

                default:
                    parseInputFieldName(input, out _type, out _parameter);
                    switch (_type)
                    {
                    case ("String"):
                        _value = request.Inputs[input].AsString();
                        break;

                    case ("Int32"):
                    case ("UInt32"):
                        _value = Convert.ToString(request.Inputs[input].AsInt32());
                        break;

                    case ("SwitchParameter"):
                        _value = Convert.ToString(request.Inputs[input].AsString());
                        break;

                    case ("ActionPreference"):
                        _value = Convert.ToString(request.Inputs[input].AsString());
                        break;

                    default:
                        _value = request.Inputs[input].AsString();
                        break;
                    }
                    parameters.Add(_parameter, _value);
                    break;
                }
            }
            CreateAndOpenRunspace();

            StringBuilder psScript = new StringBuilder(string.Format("import-module {0}; {1}", _moduleName, _cmdletName));

            foreach (string key in parameters.Keys)
            {
                psScript.Append(string.Format(" -{0} {1}", key, parameters[key]));
            }

            Collection <PSObject> objCol = RunPowerShellScript(psScript.ToString());

            response.Publish("Cmdlet Name", _cmdletName);
            response.Publish("Module Name", _moduleName);

            if (objCol.Count == 1)
            {
                response.PublishRange(parseResults(objCol[0]));
            }

            CloseRunspace();
        }
Exemplo n.º 5
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName        = settings.UserName;
            password        = settings.Password;
            domain          = settings.Domain;
            serviceURL      = settings.ServiceUrl;
            exchangeVersion = settings.ExchangeVersion;

            emailID      = request.Inputs["Email ID"].AsString();
            SaveLocation = request.Inputs["Save Location"].AsString();

            numberOfExportedEmails = 0;

            string alternateMailbox = string.Empty;

            if (request.Inputs.Contains("Alternate Mailbox"))
            {
                alternateMailbox = request.Inputs["Alternate Mailbox"].AsString();
            }

            ExchangeService service = new ExchangeService();

            switch (exchangeVersion)
            {
            case "Exchange2007_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                break;

            case "Exchange2010":
                service = new ExchangeService(ExchangeVersion.Exchange2010);
                break;

            case "Exchange2010_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
                break;

            default:
                service = new ExchangeService();
                break;
            }

            service.Credentials = new WebCredentials(userName, password, domain);
            String AccountUrl = userName + "@" + domain;

            if (serviceURL.Equals("Autodiscover"))
            {
                service.AutodiscoverUrl(AccountUrl, (a) => { return(true); });
            }
            else
            {
                service.Url = new Uri(serviceURL);
            }

            if (!alternateMailbox.Equals(String.Empty))
            {
                service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, alternateMailbox);
            }

            PropertySet  propSet = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent, EmailMessageSchema.IsRead);
            EmailMessage message = EmailMessage.Bind(service, emailID, propSet);

            response.PublishRange(exportEmail(message));
            response.Publish("Number of Exported Emails", numberOfExportedEmails);
        }
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            IPHostEntry host = Dns.GetHostEntry(request.Inputs["Host Name"].AsString());

            response.PublishRange("IP Address", host.AddressList);
        }