public void WriteWithObject() { //Arrange var source = new MemorySource <MyTextRow>(); source.DataAsList.Add(new MyTextRow() { Text = "Line 1" }); source.DataAsList.Add(new MyTextRow() { Text = "Line 2" }); source.DataAsList.Add(new MyTextRow() { Text = "Line 3" }); //Act TextDestination <MyTextRow> dest = new TextDestination <MyTextRow>("res/TextDestination/TestFile.txt" , tr => tr.Text); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.True(File.Exists("res/TextDestination/TestFile.txt")); Assert.Equal(File.ReadAllText("res/TextDestination/ToBeTestFile.txt"), File.ReadAllText("res/TextDestination/TestFile.txt")); }
private bool HasValidTextUploader(bool bHasValidFileUploader) { foreach (ToolStripMenuItem tsmi in tsddbDestText.DropDownItems) { TextDestination ut = (TextDestination)tsmi.Tag; switch (ut) { case TextDestination.FileUploader: tsmi.Enabled = bHasValidFileUploader; if (!tsmi.Enabled) { tsmi.Checked = false; } break; } } foreach (ToolStripMenuItem tsmi in tsddbDestText.DropDownItems) { if (!tsmi.Enabled) { tsmi.Checked = false; // if not enabled then we don't need it checked either issue 604 } } foreach (ToolStripMenuItem tsmi in tsddbDestText.DropDownItems) { if (tsmi.Enabled && tsmi.Checked) { return(true); } } return(false); }
private void SetDefaultSettings() { if (Program.DefaultTaskSettings != null) { TaskSettings defaultTaskSettings = Program.DefaultTaskSettings.Copy(); if (UseDefaultAfterCaptureJob) { AfterCaptureJob = defaultTaskSettings.AfterCaptureJob; } if (UseDefaultAfterUploadJob) { AfterUploadJob = defaultTaskSettings.AfterUploadJob; } if (UseDefaultDestinations) { ImageDestination = defaultTaskSettings.ImageDestination; TextDestination = defaultTaskSettings.TextDestination; FileDestination = defaultTaskSettings.FileDestination; URLShortenerDestination = defaultTaskSettings.URLShortenerDestination; SocialNetworkingServiceDestination = defaultTaskSettings.SocialNetworkingServiceDestination; } if (UseDefaultGeneralSettings) { GeneralSettings = defaultTaskSettings.GeneralSettings; } if (UseDefaultImageSettings) { ImageSettings = defaultTaskSettings.ImageSettings; } if (UseDefaultCaptureSettings) { CaptureSettings = defaultTaskSettings.CaptureSettings; } if (UseDefaultUploadSettings) { UploadSettings = defaultTaskSettings.UploadSettings; } if (UseDefaultActions) { ExternalPrograms = defaultTaskSettings.ExternalPrograms; } if (UseDefaultIndexerSettings) { IndexerSettings = defaultTaskSettings.IndexerSettings; } if (UseDefaultAdvancedSettings) { AdvancedSettings = defaultTaskSettings.AdvancedSettings; } } }
public static bool Validate(TextDestination destination, UploadersConfig config) { if (destination == TextDestination.FileUploader) { return(true); } return(UploaderFactory.TextUploaderServices[destination].CheckConfig(config)); }
private void UpdateConfigOutputs() { Config.DestConfig.Outputs.Clear(); if (chkClipboard.Checked) { Config.DestConfig.Outputs.Add(OutputEnum.Clipboard); } if (chkSaveFile.Checked) { Config.DestConfig.Outputs.Add(OutputEnum.LocalDisk); } if (chkUpload.Checked) { Config.DestConfig.Outputs.Add(OutputEnum.RemoteHost); } if (chkPrinter.Checked) { Config.DestConfig.Outputs.Add(OutputEnum.Printer); } Config.DestConfig.FileUploaders.Clear(); foreach (CheckBox chk in flpFileUploaders.Controls) { FileDestination ut = (FileDestination)chk.Tag; if (chk.Checked) { Config.DestConfig.FileUploaders.Add(ut); } } Config.DestConfig.ImageUploaders.Clear(); foreach (CheckBox chk in flpImageUploaders.Controls) { ImageDestination ut = (ImageDestination)chk.Tag; if (chk.Checked) { Config.DestConfig.ImageUploaders.Add(ut); } } Config.DestConfig.TextUploaders.Clear(); foreach (CheckBox chk in flpTextUploaders.Controls) { TextDestination ut = (TextDestination)chk.Tag; if (chk.Checked) { Config.DestConfig.TextUploaders.Add(ut); } } if (!string.IsNullOrEmpty(txtFileNameWithoutExt.Text) && !string.IsNullOrEmpty(txtSaveFolder.Text)) { string ext = Path.GetExtension(Task.Info.LocalFilePath); Task.Info.LocalFilePath = Path.Combine(txtSaveFolder.Text, txtFileNameWithoutExt.Text) + ext; } }
public bool IsValid(TextDestination destination) { switch (destination) { case TextDestination.CustomTextUploader: return(CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomTextUploaderSelected)); } return(true); }
public object Clone() { DTDataDestination obj = new DTDataDestination(); obj.SetOwner(_owner); obj.DestinationType = DestinationType; obj._db = (DTDest)DatabaseDestination.Clone(); obj._text = (DTDestTextFile)TextDestination.Clone(); return(obj); }
public bool IsActive(TextDestination ut) { switch (ut) { case TextDestination.FileUploader: return(Enum.GetValues(typeof(FileDestination)).Cast <FileDestination>().Any(fu => IsActive(fu))); default: return(true); } }
public string ReceiveData(DataTable tblSrc, bool bSilent) { if (DestinationType == EnumDataDestination.Database) { return(DatabaseDestination.ReceiveData(tblSrc, bSilent)); } else if (DestinationType == EnumDataDestination.TextFile) { return(TextDestination.ReceiveData(tblSrc, bSilent)); } return(string.Format(CultureInfo.InvariantCulture, "Unsupported destination {0}", DestinationType)); }
/* Data flow * * JsonSource --> RowTransformation --> Lookup --> Multicast --> DbDestination ("orders" table) * (Order data) | | * CsvSource <---- --------> TextDestination ("order_data.log") * ("customer.csv") */ static void Main(string[] args) { //Preparation RecreateTargetTable(); //Step 1 - creating the components var source = new JsonSource <OrderRow>("https://www.etlbox.net/demo/api/orders", ResourceType.Http); var rowTransformation = new RowTransformation <OrderRow>(); rowTransformation.TransformationFunc = row => { row.Quantity = int.Parse(row.Description.Split(":").ElementAt(1)); return(row); }; var lookup = new LookupTransformation <OrderRow, ExpandoObject>(); lookup.Source = new CsvSource("files/customer.csv"); lookup.MatchColumns = new[] { new MatchColumn() { LookupSourcePropertyName = "Id", InputPropertyName = "CustomerId" } }; lookup.RetrieveColumns = new[] { new RetrieveColumn() { LookupSourcePropertyName = "Name", InputPropertyName = "CustomerName" } }; var multicast = new Multicast <OrderRow>(); var dbDest = new DbDestination <OrderRow>(sqlConnMan, "orders"); var textDest = new TextDestination <OrderRow>("files/order_data.log"); textDest.WriteLineFunc = row => { return($"{row.OrderNumber}\t{row.CustomerName}\t{row.Quantity}"); }; //Step2 - linking components source.LinkTo(rowTransformation); rowTransformation.LinkTo(lookup); lookup.LinkTo(multicast); multicast.LinkTo(dbDest); multicast.LinkTo(textDest, row => row.CustomerName == "Clark Kent", row => row.CustomerName != "Clark Kent"); //Step3 - executing the network Network.Execute(source); //Shortcut for Network.ExecuteAsync(source).Wait(); }
public bool IsValid(TextDestination destination) { TextUploaderService service = UploaderFactory.GetTextUploaderServiceByEnum(destination); if (service != null) { return(service.CheckConfig(this)); } switch (destination) { case TextDestination.CustomTextUploader: return(CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomTextUploaderSelected)); } return(true); }
public void WriteWithArray() { //Arrange var source = new MemorySource <string[]>(); source.DataAsList.Add(new string[] { "Line 1" }); source.DataAsList.Add(new string[] { "Line 2" }); source.DataAsList.Add(new string[] { "Line 3" }); //Act TextDestination <string[]> dest = new TextDestination <string[]>("res/TextDestination/TestFileArray.txt" , tr => tr[0]); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.True(File.Exists("res/TextDestination/TestFileArray.txt")); Assert.Equal(File.ReadAllText("res/TextDestination/ToBeTestFile.txt"), File.ReadAllText("res/TextDestination/TestFileArray.txt")); }
public void WriteWithDynamicObject() { //Arrange var source = new MemorySource(); dynamic n1 = new ExpandoObject(); n1.Text = "Line 1"; source.DataAsList.Add(n1); dynamic n2 = new ExpandoObject(); n2.Text = "Line 2"; source.DataAsList.Add(n2); dynamic n3 = new ExpandoObject(); n3.Text = "Line 3"; source.DataAsList.Add(n3); //Act TextDestination dest = new TextDestination("res/TextDestination/TestFileDynamic.txt" , tr => { dynamic r = tr as ExpandoObject; return(r.Text); }); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.True(File.Exists("res/TextDestination/TestFileDynamic.txt")); Assert.Equal(File.ReadAllText("res/TextDestination/ToBeTestFile.txt"), File.ReadAllText("res/TextDestination/TestFileDynamic.txt")); }
public static TextUploaderService GetTextUploaderService(TextDestination enumValue) { return(textUploaderServices.First(x => x.EnumValue == enumValue)); }
private void SetDefaultSettings() { if (Program.DefaultTaskSettings != null) { TaskSettings defaultTaskSettings = Program.DefaultTaskSettings.Copy(); if (UseDefaultAfterCaptureJob) { AfterCaptureJob = defaultTaskSettings.AfterCaptureJob; } if (UseDefaultAfterUploadJob) { AfterUploadJob = defaultTaskSettings.AfterUploadJob; } if (UseDefaultDestinations) { ImageDestination = defaultTaskSettings.ImageDestination; ImageFileDestination = defaultTaskSettings.ImageFileDestination; TextDestination = defaultTaskSettings.TextDestination; TextFileDestination = defaultTaskSettings.TextFileDestination; FileDestination = defaultTaskSettings.FileDestination; URLShortenerDestination = defaultTaskSettings.URLShortenerDestination; URLSharingServiceDestination = defaultTaskSettings.URLSharingServiceDestination; } if (UseDefaultGeneralSettings) { GeneralSettings = defaultTaskSettings.GeneralSettings; } if (UseDefaultImageSettings) { ImageSettings = defaultTaskSettings.ImageSettings; } if (UseDefaultCaptureSettings) { CaptureSettings = defaultTaskSettings.CaptureSettings; } if (UseDefaultUploadSettings) { UploadSettings = defaultTaskSettings.UploadSettings; } if (UseDefaultActions) { ExternalPrograms = defaultTaskSettings.ExternalPrograms; } if (UseDefaultToolsSettings) { ToolsSettings = defaultTaskSettings.ToolsSettings; } if (UseDefaultAdvancedSettings) { AdvancedSettings = defaultTaskSettings.AdvancedSettings; } } }
private void UploadText(TextDestination textUploaderType) { TextUploader textUploader = null; switch (textUploaderType) { case TextDestination.Pastebin: textUploader = new PastebinUploader(Engine.ConfigUI.ApiKeysConfig.PastebinKey, Engine.ConfigUploaders.PastebinSettings); break; case TextDestination.PastebinCA: textUploader = new PastebinCaUploader(Engine.ConfigUI.ApiKeysConfig.PastebinCaKey); break; case TextDestination.Paste2: textUploader = new Paste2Uploader(); break; case TextDestination.Slexy: textUploader = new SlexyUploader(); break; case TextDestination.FileUploader: UploadFile(); break; } if (textUploader != null) { DestinationName = textUploaderType.GetDescription(); DebugHelper.WriteLine("Uploading to " + DestinationName); string url = string.Empty; if (!string.IsNullOrEmpty(TempText)) { url = textUploader.UploadText(TempText); } else { url = textUploader.UploadTextFile(Info.LocalFilePath); } var ur_remote_text = new UploadResult { LocalFilePath = Info.LocalFilePath, Host = textUploaderType.GetDescription(), URL = url }; AddUploadResult(ur_remote_text); Errors = textUploader.Errors; } }