static void Main(string[] args) { string dir = string.Empty; if (args.Length == 0) { dir = "/Users/sdhaksh5/trunk/Application/Loader/Loader.Shell/"; Console.WriteLine("Enter directory path"); } dir = args[0].Trim(); if (!Directory.Exists(dir)) { Console.WriteLine("Directory does't exist"); } var fileSources = FileSources.New() .Add(dir, "*.sql"); var result = FiFiRunner.New() .FixEncoding(Encoding.UTF8) .FixInvalidCharacters() .FixLineEndings(LineEndingMode.Windows) .ForFiles(fileSources) .Run(); var failures = result.Failures(); Console.WriteLine(result.ConsoleResult); }
public void Upload(FileSources fileSources) { if (fileSources.Count() > 0) { utility = new TransferUtility(client); foreach (var source in fileSources) { parallelTasks.Add(Task.Factory.StartNew(() => StartUpload(source))); } } Task.WaitAll(parallelTasks.ToArray()); }
private void button1_Click(object sender, EventArgs e) { CurrentFileSource = FileSources.ManualInput; try { DownloadAndProcess(); } finally { EnableForm(true); } }
private void RandomImageTextFileCore() { // not really random - works through the file sequentially Invoke((MethodInvoker) delegate() { textBox1.Text = TextFileCache[0]; }); TextFileCache.RemoveAt(0); CurrentFileSource = FileSources.TextFile; RandomCurrentIndex = 0; try { DownloadAndProcess(); } finally { EnableForm(true); } }
private void RandomImageCategoryCore() { if (RandomBlacklist.Count >= RandomImageCache.Count) { ErrorHandler(Localization.GetString("RandomCacheEmpty1") + "\n\n" + Localization.GetString("RandomCacheEmpty2") + "\n\n" + Localization.GetString("RandomCacheEmpty3")); RandomImageCache.Clear(); return; } int randIndex; do { randIndex = rand.Next(RandomImageCache.Count); } while (RandomBlacklist.Contains(randIndex)); Invoke((MethodInvoker) delegate() { textBox1.Text = RandomImageCache[randIndex]; }); RandomImageCache.RemoveAt(randIndex); CurrentFileSource = FileSources.Category; RandomCurrentIndex = randIndex; try { DownloadAndProcess(); } finally { EnableForm(true); } }
// Source selection // ================ private void optOther_CheckedChanged(object sender, EventArgs e) { if (!optOther.Checked) return; frmRandomSource form = new frmRandomSource(); if (!String.IsNullOrEmpty(Settings.SourceTextFile)) { form.optTextFile.Checked = true; form.txtFileName.Text = Settings.SourceTextFile; } else if (!String.IsNullOrEmpty(Settings.SourceCategory)) form.txtCategory.Text = Settings.SourceCategory; if (form.ShowDialog(this) == DialogResult.Cancel) { switch (LocalWikiData.DefaultCategory) { case "1": optCategory1.Checked = true; SourceTag = LocalWikiData.Category1; break; case "2": optCategory2.Checked = true; SourceTag = LocalWikiData.Category2; break; case "3": optCategory3.Checked = true; SourceTag = LocalWikiData.Category3; break; } RandomFileSource = FileSources.Category; return; } if (form.optTextFile.Checked) { RandomFileSource = FileSources.TextFile; Settings.CurrentSourceOption = "TextFile"; SourceTag = Settings.SourceTextFile = form.txtFileName.Text; Settings.SourceCategory = ""; TextFileCache.Clear(); } else { RandomFileSource = FileSources.Category; Settings.CurrentSourceOption = "CustomCategory"; SourceTag = Settings.SourceCategory = form.txtCategory.Text.Substring( form.txtCategory.Text.ToLower(CultureInfo.InvariantCulture).StartsWith("category:", StringComparison.InvariantCulture) ? "category:".Length : 0); Settings.SourceTextFile = ""; RandomImageCache.Clear(); } Settings.WriteSettings(); btnRandomFile.Text = RandomFileSource == FileSources.TextFile ? Localization.GetString("NextFileInList_Button") : Localization.GetString("RandomFile_Button"); }
private void optCopyFoo_CheckedChanged(object sender, EventArgs e) { RandomImageCache.Clear(); RandomContinue = null; RandomBlacklist = new List<int>(); if (optCategory1.Checked) { RandomFileSource = FileSources.Category; Settings.CurrentSourceOption = "Category1"; SourceTag = LocalWikiData.Category1; } else if (optCategory2.Checked) { RandomFileSource = FileSources.Category; Settings.CurrentSourceOption = "Category2"; SourceTag = LocalWikiData.Category2; } else if (optCategory3.Checked) { RandomFileSource = FileSources.Category; Settings.CurrentSourceOption = "Category3"; SourceTag = LocalWikiData.Category3; } else { // do nothing - "other source" is handled elsewhere } btnRandomFile.Text = RandomFileSource == FileSources.TextFile ? Localization.GetString("NextFileInList_Button") : Localization.GetString("RandomFile_Button"); }
void InitSettings() { chkDeleteAfter.Text = Settings.LocalSysop ? Localization.GetString("DeleteLocalFile_Label") : Localization.GetString("TagLocalFileWithNowCommons_Label"); if (Settings.LocalDomain == "en.wikipedia" && Localization.GetString("LanguageCode") == "en") { lnkLocalFile.Text = "View file page on &English Wikipedia"; lblLocalFileDesc.Text = "File description page on English Wiki&pedia"; } else { lnkLocalFile.Text = Localization.GetString("ViewFilePageOnLocalWiki_Hyperlink_Format", Settings.LocalDomain); lblLocalFileDesc.Text = Localization.GetString("FilePageOnLocalWiki_TextBox_Format", Settings.LocalDomain); } if (Settings.CommonsDomain == Settings.DefaultCommonsDomain) { lnkCommonsFile.Text = Localization.GetString("ViewFilePageOnWikimediaCommons_Hyperlink"); lblCommonsFileDesc.Text = Localization.GetString("FilePageOnCommons_TextBox"); lblNormName.Text = Localization.GetString("NewFilenameOnCommons_TextBox"); } else { lnkCommonsFile.Text = Localization.GetString("ViewFilePageOnLocalWiki_Hyperlink_Format", Settings.CommonsDomain); lblCommonsFileDesc.Text = Localization.GetString("FilePageOnLocalWiki_TextBox_Format", Settings.CommonsDomain); lblNormName.Text = Localization.GetString("NewFilenameOnTarget_TextBox", Settings.CommonsDomain); } // local wiki data if (Settings.LocalWikiData != "") { LocalWikiData.LoadWikiData(Settings.LocalWikiData); } else if (Settings.LocalWikiDataHosted != "" && Settings.LocalWikiDataHosted.IndexOf("|") != -1 && Settings.LocalWikiDataHosted.IndexOf("|") == Settings.LocalWikiDataHosted.LastIndexOf("|")) { if (!LocalWikiData.LoadWikiDataHosted(Settings.LocalWikiDataHosted.Substring(Settings.LocalWikiDataHosted.IndexOf("|") + 1))) LocalWikiData.LoadWikiData(Properties.Resources.en_wikipedia); } else { LocalWikiData.LoadWikiData(Properties.Resources.en_wikipedia); } optCategory1.Text = LocalWikiData.CategoryNamespace + ":" + LocalWikiData.Category1; optCategory2.Visible = LocalWikiData.Category2 != ""; optCategory2.Text = LocalWikiData.CategoryNamespace + ":" + LocalWikiData.Category2; optCategory3.Visible = LocalWikiData.Category3 != ""; optCategory3.Text = LocalWikiData.CategoryNamespace + ":" + LocalWikiData.Category3; string source = Settings.CurrentSourceOption.ToLower(); if (!source.StartsWith("category")) source = "category" + LocalWikiData.DefaultCategory; switch (source) { case "category2": if (!optCategory2.Visible) goto case "category1"; optCategory2.Checked = true; SourceTag = LocalWikiData.Category2; break; case "category3": if (!optCategory3.Visible) goto case "category2"; optCategory3.Checked = true; SourceTag = LocalWikiData.Category3; break; case "category1": default: optCategory1.Checked = true; SourceTag = LocalWikiData.Category1; break; } RandomFileSource = FileSources.Category; RandomImageCache.Clear(); }
void InitSettings() { chkDeleteAfter.Text = Settings.LocalSysop ? Localization.GetString("DeleteLocalFile_Label") : Localization.GetString("TagLocalFileWithNowCommons_Label"); if (Settings.LocalDomain == "en.wikipedia" && Localization.GetString("LanguageCode") == "en") { lnkLocalFile.Text = "View file page on &English Wikipedia"; lblLocalFileDesc.Text = "File description page on English Wiki&pedia"; } else { lnkLocalFile.Text = Localization.GetString("ViewFilePageOnLocalWiki_Hyperlink_Format", Settings.LocalDomain); lblLocalFileDesc.Text = Localization.GetString("FilePageOnLocalWiki_TextBox_Format", Settings.LocalDomain); } // local wiki data LocalWikiData.LoadWikiData((Settings.LocalWikiData == "" ? Properties.Resources.en_wikipedia : Settings.LocalWikiData) .Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)); optCategory1.Text = LocalWikiData.CategoryNamespace + ":" + LocalWikiData.Category1; optCategory2.Visible = LocalWikiData.Category2 != ""; optCategory2.Text = LocalWikiData.CategoryNamespace + ":" + LocalWikiData.Category2; optCategory3.Visible = LocalWikiData.Category3 != ""; optCategory3.Text = LocalWikiData.CategoryNamespace + ":" + LocalWikiData.Category3; string source = Settings.CurrentSourceOption.ToLower(); if (!source.StartsWith("category")) source = "category" + LocalWikiData.DefaultCategory; switch (source) { case "category2": if (!optCategory2.Visible) goto case "category1"; optCategory2.Checked = true; SourceTag = LocalWikiData.Category2; break; case "category3": if (!optCategory3.Visible) goto case "category2"; optCategory3.Checked = true; SourceTag = LocalWikiData.Category3; break; case "category1": default: optCategory1.Checked = true; SourceTag = LocalWikiData.Category1; break; } RandomFileSource = FileSources.Category; }