Example #1
0
        public static string GetxCBLExceptionMailBody(int scenarioTypeId)
        {
            Stream stream;

            using (DataSet ds = new DataSet())
            {
                using (DataTable carrierInsauranceInfoData = DataAccess.XCBL.XCBLCommands.GetXcblExceptionInfo(scenarioTypeId))
                {
                    ds.Locale      = System.Globalization.CultureInfo.InvariantCulture;
                    ds.DataSetName = "xCBLExceptionDS";
                    ds.Tables.Add(carrierInsauranceInfoData);
                    ds.Tables[0].TableName = "ExceptionInfo";
                    if (carrierInsauranceInfoData != null && carrierInsauranceInfoData.Rows != null && carrierInsauranceInfoData.Rows.Count > 0)
                    {
                        stream = HtmlGenerator.GenerateHtmlFile(ds, AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"bin\StyleSheets\xCBLException.xslt", null);
                    }
                    else
                    {
                        stream = null;
                    }
                }
            }

            return(stream == null ? string.Empty : GetHtmlData(stream));
        }
Example #2
0
            public void CreatedExpectedFile()
            {
                HtmlGenerator generator = new HtmlGenerator();

                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "max peel"
                };
                puzzle.AddWordToClues("example");
                puzzle.PlaceLetters();
                generator.Puzzle = puzzle;

                const string TEST_PUZZLE_FILENAME = "test_puzzle.html";

                string actualHtml = generator.GenerateHtmlFile(TEST_PUZZLE_FILENAME);

                Assert.AreEqual(File.ReadAllText(@"data\puzzle.html"), actualHtml);
                FileAssert.AreEqual(@"data\puzzle.html", TEST_PUZZLE_FILENAME);
            }
Example #3
0
        private static Stream GenerateHtmlFile(SetCollection data, string rootName, string xsltFilePath, Dictionary <string, string> xsltArgumentsDictionary)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            using (DataSet ds = new DataSet(rootName))
            {
                ds.Locale = System.Globalization.CultureInfo.InvariantCulture;

                foreach (DictionaryEntry set in data)
                {
                    var table = ds.Tables.Add(set.Key.ToString());

                    foreach (IDictionary <string, object> item in (IList <dynamic>)set.Value)
                    {
                        if (table.Columns.Count == 0)
                        {
                            foreach (var prop in item)
                            {
                                table.Columns.Add(prop.Key, prop.Value.GetType() == typeof(DBNull) ? typeof(object) : prop.Value.GetType());
                            }
                        }

                        DataRow row = table.NewRow();

                        foreach (var prop in item)
                        {
                            row[prop.Key] = HtmlGenerator.CleanInvalidXmlChars(prop.Value.ToString());
                        }

                        table.Rows.Add(row);
                    }
                }

                return(HtmlGenerator.GenerateHtmlFile(ds, xsltFilePath, xsltArgumentsDictionary));
            }
        }
Example #4
0
            public void WithoutKey_CreatedExpectedFile()
            {
                HtmlGenerator generator = new HtmlGenerator();

                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "max peel"
                };
                puzzle.AddWordToClues("example");
                puzzle.PlaceLetters();
                generator.Puzzle = puzzle;

                // ReSharper disable StringLiteralTypo
                const string TEST_PUZZLE_FILENAME      = "test_puzzle_withoutkey.html";
                const string EXPECTED_RESULTS_FILENAME = @"data\puzzle_withoutkey.html";
                // ReSharper restore StringLiteralTypo

                string actualHtml = generator.GenerateHtmlFile(TEST_PUZZLE_FILENAME, false);


                Assert.AreEqual(File.ReadAllText(EXPECTED_RESULTS_FILENAME), actualHtml);
                FileAssert.AreEqual(EXPECTED_RESULTS_FILENAME, TEST_PUZZLE_FILENAME);
            }
Example #5
0
        internal static string GetEDIExceptionMailBody(int scenarioTypeId)
        {
            Stream stream;

            using (DataSet ds = new DataSet())
            {
                ds.Locale      = System.Globalization.CultureInfo.InvariantCulture;
                ds.DataSetName = "EDIExceptionDS";
                DataTable carrierInsauranceInfoData = DataAccess.XCBL.XCBLCommands.GetEDIExceptionInfo(scenarioTypeId);
                ds.Tables.Add(carrierInsauranceInfoData);
                ds.Tables[0].TableName = "ExceptionInfo";
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Dictionary <string, string> args = null;
                    if (scenarioTypeId == EventNotification.EDINoEDIReceived.ToInt())
                    {
                        args = new Dictionary <string, string>()
                        {
                            { "isOrderNumberAvailable", "false" }
                        }
                    }
                    ;
                    else
                    {
                        args = new Dictionary <string, string>()
                        {
                            { "isOrderNumberAvailable", "true" }
                        }
                    };

                    stream = HtmlGenerator.GenerateHtmlFile(ds, AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"bin\StyleSheets\EDIException.xslt", args);
                    return(GetHtmlData(stream));
                }

                return(string.Empty);
            }
        }