public void OnGet() { _logger.Log(LogLevel.Information, "Starting Object"); string SourcePath = Directory.GetCurrentDirectory() + "\\wwwroot\\Template\\" + "phieuluong.docx"; string DestinationPath = Directory.GetCurrentDirectory() + "\\wwwroot\\Template\\" + "result.docx"; string data = LogHelper.FileReadAllText(Directory.GetCurrentDirectory() + "\\" + "Data.json"); var a = new WordProcessing(SourcePath, DestinationPath, data); _logger.Log(LogLevel.Information, "End Object"); }
public void GetFileInfo_wordTextForTestDocx_helloThere_returned() { //arrange string path = Environment.CurrentDirectory + @"\word_text_for_test.docx"; string expected = "-hello there!"; //act string actual = WordProcessing.GetFileInfo(path); //assert Assert.AreEqual(expected, actual); }
public void GetFileInfo_textForTestTXT_NowYouSeeSharp_returned() { //arrange string path = @"text_for_test.txt"; string expected = "NowYouSeeSharp"; //act string actual = WordProcessing.GetFileInfo(path); //assert Assert.AreEqual(expected, actual); }
private void Choose_Key_Click(object sender, RoutedEventArgs e) { try { KeyText.Text = WordProcessing.GetFileInfo(FileProcessing.ChooseFile()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void CountOfOccurrencesTest() { var text = TestContext.DataRow["currentText"].ToString(); var wordProcessing = new WordProcessing(text); var oldSubstring = TestContext.DataRow["oldSubstring"].ToString(); var expected = Convert.ToInt32(TestContext.DataRow["countOfOccurrences"]); int result = wordProcessing.CountOfOccurrences(oldSubstring); Assert.AreEqual(expected, result); }
public void GetReplasedTextTest() { var text = TestContext.DataRow["currentText"].ToString(); var wordProcessing = new WordProcessing(text); var oldSubstring = TestContext.DataRow["oldSubstring"].ToString(); var newSubstring = TestContext.DataRow["newSubstring"].ToString(); var expected = TestContext.DataRow["replacedText"].ToString(); string result = wordProcessing.GetReplasedText(oldSubstring, newSubstring); Assert.AreEqual(expected, result); }
public void GetDigitalKey_ааАая_and_переворот_111132111132_returned() { //arrange string text = "переворот"; string key = "ааАая"; int[] expected = new int[9] { 0, 0, 0, 0, 32, 0, 0, 0, 0 }; //act int[] actual = WordProcessing.GetDigitalKey(key, text); //assert CollectionAssert.AreEqual(expected, actual); }
static void Main(string[] args) { var file = args.Length != 0 ? args[0] : "fullform_bm.txt"; var fullOrdListe = FileProcessing.ReadWords(file); var ordListe = WordProcessing.CheckLength(fullOrdListe); var funnetOrd = 0; while (funnetOrd < 200) { if (WordProcessing.FindWord(ordListe, fullOrdListe)) { funnetOrd++; } } }
/// <summary> /// 加浮水印 /// </summary> /// <param name="obj"></param> /// <returns></returns> private MemoryStream addWatermark(string filePath, MemoryStream fileIn, Dictionary <CMCustomStyleEnum, string> styles) { #region 讀取設定檔 string texts = (!String.IsNullOrEmpty(this.MarkText.Text))? "#" + this.MarkText.Text:"#123456"; string width = "300"; string heigth = "100"; string color = "#7B7B7B"; string font = "Microsoft JhengHei"; string fontSize = "30"; string rotate = "-30"; string opacity = "0.2"; string horizontalSpace = "0"; string verticalSpace = "0"; #endregion StringBuilder watermark = new StringBuilder(); MemoryStream fileStream = fileIn; var fileAry = filePath.Split('\\'); var fileName = fileAry[fileAry.Length - 1]; int i = 0; Dictionary <string, string> param = new Dictionary <string, string>(); foreach (var text in texts.Split(',')) { if (i != 0) { watermark.Append(Environment.NewLine); } foreach (var item in text.Split('|')) { var first = item.Substring(0, 1); var value = item.Substring(1); switch (first) { case "$": if (param.ContainsKey(value)) { watermark.Append(param[value]); } break; case "#": watermark.Append(value); break; default: break; } } i++; } string[] fileNames = fileName.Split('.'); string extension = fileNames[fileNames.Length - 1].ToLower(); WatermarkObj watermarkObj = new WatermarkObj(); watermarkObj.Color = color; watermarkObj.FontFamily = font; watermarkObj.RotateAngle = double.Parse(rotate); watermarkObj.WMStyle = GSS.FBU.CMAspose.DomainObject.DomainEnum.WatermarkStyleEnum.RepeatRotateAngle; watermarkObj.WatermarkHeight = double.Parse(heigth); watermarkObj.WatermarkWidth = double.Parse(width); watermarkObj.WatermarkHorizontalSpace = double.Parse(horizontalSpace); watermarkObj.WatermarkVerticalSpace = double.Parse(verticalSpace); watermarkObj.FontSize = int.Parse(fontSize); watermarkObj.Watermark = watermark.ToString(); watermarkObj.Opacity = double.Parse(opacity); //底層呼叫套印浮水印 switch (extension) { case "xls": case "xlsx": WatermarkObj.Excel excelArg = JsonConvert.DeserializeObject <WatermarkObj.Excel>(JsonConvert.SerializeObject(watermarkObj)); excelArg.SaveFormat = extension.Equals("xlsx") ? Aspose.Cells.SaveFormat.Xlsx : Aspose.Cells.SaveFormat.Excel97To2003; fileStream = new ExcelProcessing().AddWatermark(fileStream, excelArg, styles); break; case "doc": case "docx": WatermarkObj.Word wordArg = JsonConvert.DeserializeObject <WatermarkObj.Word>(JsonConvert.SerializeObject(watermarkObj)); wordArg.SaveFormat = extension.Equals("docx") ? Aspose.Words.SaveFormat.Docx : Aspose.Words.SaveFormat.Doc; fileStream = new WordProcessing().AddWatermark(fileStream, wordArg, styles); break; case "pdf": WatermarkObj.Pdf pdfArg = JsonConvert.DeserializeObject <WatermarkObj.Pdf>(JsonConvert.SerializeObject(watermarkObj)); fileStream = new PdfProcessing().AddWatermark(fileStream, pdfArg, styles); break; case "tiff": case "tif": case "png": case "gif": case "jpeg": case "jpg": case "xpm": WatermarkObj.Image imageArg = JsonConvert.DeserializeObject <WatermarkObj.Image>(JsonConvert.SerializeObject(watermarkObj)); imageArg.WMStyle = GSS.FBU.CMAspose.DomainObject.DomainEnum.WatermarkStyleEnum.FitPage; fileStream = new ImageProcessing().AddWatermark(fileStream, imageArg); break; default: break; } return(fileStream); }
public void Setup() { Words = new WordProcessing(); }
static void Main(string[] args) { WordProcessing Words = new WordProcessing(); string input = ""; int shiftAmt = 0; string pattern = ""; Console.WriteLine("What would you to do?"); Console.WriteLine("Option 1: Alternating Case"); Console.WriteLine("Option 2: Shifting Words"); Console.WriteLine("Option 3: Most Common Letter"); Console.WriteLine("Option 4: Amount of different Characters"); Console.WriteLine("Option 5: Find Letter Patterns"); int Choice = int.Parse(Console.ReadLine()); if (Choice == 1) { Console.WriteLine("Please Enter a Word to alternate case"); input = Console.ReadLine(); var Result = Words.AlternateCase(input); Console.WriteLine(Result); } else if (Choice == 2) { Console.WriteLine("Please Enter a Word"); input = Console.ReadLine(); Console.WriteLine("Please enter a number to shift your word"); shiftAmt = int.Parse(Console.ReadLine()); var Result = Words.ShiftWord(input, shiftAmt); Console.WriteLine(Result); } else if (Choice == 3) { Console.WriteLine("Please Enter a Word"); input = Console.ReadLine(); var Result = Words.MostCommonLetter(input); Console.WriteLine("Most common letter: " + Result); } else if (Choice == 4) { Console.WriteLine("Please Enter a Word"); input = Console.ReadLine(); var Result = Words.AmtOfDifferentChars(input); Console.WriteLine(Result); } else if (Choice == 5) { Console.WriteLine("Please Enter a Word"); input = Console.ReadLine(); Console.WriteLine("Please enter a pattern from your word"); pattern = Console.ReadLine(); var Result = Words.findPattern(input, pattern); Console.WriteLine(Result); } else { Console.WriteLine("Invalid input, closing application."); Console.ReadLine(); } }