Пример #1
0
        private static void CreateAccountSummary(object state)
        {
            AccountSummaryArgument accountSummaryArgument = (AccountSummaryArgument)state;
            Token  token = accountSummaryArgument.Token;
            string sql   = "EXEC P_RptAccountSummary @xmlAccounts=\'" + XmlTransform.Transform(accountSummaryArgument.AccountIds, ',', "Accounts", "Account", "ID") + "\',@tradeDayFrom=\'"
                           + accountSummaryArgument.FromDay + "\',@tradeDayTo=\'" + accountSummaryArgument.ToDay + "\',@language=\'" + accountSummaryArgument.Version + "\',@userID=\'" + accountSummaryArgument.Token.UserID.ToString() + "\', @skipNoTransactionAccount=0";

            try
            {
                DataSet dataSet = DataAccess.GetData(sql, SettingManager.Default.ConnectionString, LedgerReportTimeout);
                if (dataSet.Tables.Count > 0)
                {
                    string filepath = Path.Combine(SettingManager.Default.PhysicPath, accountSummaryArgument.Rdlc);
                    //this.Server.MapPath(accountSummaryArgument.Rdlc);
                    byte[]             reportContent      = PDFHelper.ExportPDF(filepath, dataSet.Tables[0]);
                    AsyncResultManager asyncResultManager = accountSummaryArgument.AsyncResultManager;
                    asyncResultManager.SetResult(accountSummaryArgument.AsyncResult, reportContent);
                    CommandManager.Default.AddCommand(new AsyncCommand(0, accountSummaryArgument.AsyncResult));
                }
            }
            catch (System.Exception ex)
            {
                CommandManager.Default.AddCommand(new AsyncCommand(0, accountSummaryArgument.AsyncResult, true, ex));
                _Logger.Error(ex);
            }
        }
Пример #2
0
        private static void CreateLedger(object state)
        {
            LedgerArgument ledgerArgument = (LedgerArgument)state;
            Token          token          = ledgerArgument.Token;
            string         sql            = "EXEC P_RptLedger @xmlAccounts=\'" + XmlTransform.Transform(ledgerArgument.IDs, ',', "Accounts", "Account", "ID") + "\',@tradeDayBegin=\'"
                                            + ledgerArgument.DateFrom + "\',@tradeDayTo=\'" + ledgerArgument.DateTo + "\',@language=\'" + ledgerArgument.Version + "\',@userID=\'" + ledgerArgument.Token.UserID.ToString() + "\'";

            try
            {
                DataSet dataSet = DataAccess.GetData(sql, SettingManager.Default.ConnectionString, LedgerReportTimeout);
                try
                {
                    TradingConsoleServer tradingConsoleServer = ledgerArgument.TradingConsoleServer;
                    tradingConsoleServer.SaveLedger(token, "", ledgerArgument.IDs);
                }
                catch
                {
                }

                if (dataSet.Tables.Count > 0)
                {
                    string             filepath           = Path.Combine(SettingManager.Default.PhysicPath, ledgerArgument.Rdlc); //this.Server.MapPath(ledgerArgument.Rdlc);
                    byte[]             reportContent      = PDFHelper.ExportPDF(filepath, dataSet.Tables[0]);
                    AsyncResultManager asyncResultManager = ledgerArgument.AsyncResultManager;
                    asyncResultManager.SetResult(ledgerArgument.AsyncResult, reportContent);
                    CommandManager.Default.AddCommand(new AsyncCommand(0, ledgerArgument.AsyncResult));
                }
            }
            catch (System.Exception ex)
            {
                CommandManager.Default.AddCommand(new AsyncCommand(0, ledgerArgument.AsyncResult, true, ex));
                _Logger.Error(ex);
            }
        }
Пример #3
0
        public void CreateAfterCompileContent_AllParams_ReturnsObjectList()
        {
            //Arrange
            var sut = new XmlTransform();

            //Act
            var destination = "destination";
            var actual      = sut.CreateAfterCompileContent("source", destination, "transform").ToList();

            //Assert
            actual.Should().HaveCount(4);
            actual.ElementAt(0).Should().BeOfType <XComment>();
            // content already covered in TransformXml tests
            actual.ElementAt(1).Should().BeOfType <XElement>().Which.Name.LocalName.Should().Be("TransformXml");
            actual.ElementAt(2).Should().BeOfType <XComment>();
            actual.ElementAt(3).Should().BeOfType <XElement>().Subject.Name.LocalName.Should().Be("ItemGroup");
            actual.ElementAt(3).Should().BeOfType <XElement>().Subject.Elements().ElementAt(0).Should()
            .HaveAttribute("Remove", "App.config")
            .And.Subject.Name.LocalName.Should().Be("AppConfigWithTargetPath");
            actual.ElementAt(3).Should().BeOfType <XElement>().Subject.Elements().ElementAt(1).Should()
            .HaveAttribute("Include", destination)
            .And.Subject.Name.LocalName.Should().Be("AppConfigWithTargetPath");

            actual.ElementAt(3).Should().BeOfType <XElement>()
            .Subject.Elements().ElementAt(1).Elements().ElementAt(0).Should()
            .HaveValue("$(TargetFileName).config")
            .And.Subject.Name.LocalName.Should().Be("TargetPath");
        }
Пример #4
0
        public XmlNode Create(XmlNode source)
        {
            string styleName = "Place.xslt";
            string filePath  = FileUtil.GetXmlStyleSheetPath(styleName);

            return(XmlTransform.Transform(source, filePath, null));
        }
Пример #5
0
        public static XmlElement ToXmlNode(Account account, Guid currencyID)
        {
            string           url         = System.AppDomain.CurrentDomain.BaseDirectory + "Stylesheet/AccountCurrency.xslt";
            XsltArgumentList xsltArgList = new XsltArgumentList();

            xsltArgList.AddParam("currencyID", "", currencyID);
            return((XmlElement)XmlTransform.Transform(ToXmlNode(account), url, xsltArgList));
        }
Пример #6
0
 internal XmlElement ToXmlNode(Guid currencyId)
 {
     lock (_mutex)
     {
         XsltArgumentList xsltArgList = new XsltArgumentList();
         xsltArgList.AddParam("currencyID", "", currencyId);
         return((XmlElement)XmlTransform.Transform(this.ToXmlNode(), Util.PathHelper.GetAccountCurrencyStylesheetPath(), xsltArgList));
     }
 }
Пример #7
0
        public void HasUsingTaskTransformXml_Null_ThrowsException()
        {
            //Arrange
            var sut = new XmlTransform();

            //Act
            Action action = () => sut.HasUsingTaskTransformXml(null);

            //Assert
            action.Should().Throw <ArgumentNullException>();
        }
Пример #8
0
        public void GetTarget_NullRoot_ThrowsException()
        {
            //Arrange
            var sut = new XmlTransform();

            //Act
            Action action = () => sut.GetTarget(null, string.Empty);

            //Assert
            action.Should().Throw <ArgumentNullException>();
        }
Пример #9
0
        public void GetTargetName_NullConfigName_ThrowsException()
        {
            //Arrange
            var sut = new XmlTransform();

            //Act
            Action action = () => sut.GetTargetName(null, AfterTargets.AfterBuild);

            //Assert
            action.Should().Throw <ArgumentNullException>();
        }
 public void Dispose(){
     XmlTransformInstance._baseUri = null;
     XmlTransformInstance._xmlResolver = null;
     XmlTransformInstance._bResolverSet = false;
     XmlTransformInstance._signedXml = null;
     XmlTransformInstance._reference = null;
     XmlTransformInstance._propagatedNamespaces = null;
     XmlTransformInstance._context = null;
     
     XmlTransformInstance = null;
 }
Пример #11
0
        public void GetTargetName_ValidConfigName_ReturnValue()
        {
            //Arrange
            var sut = new XmlTransform();

            //Act
            var actual = sut.GetTargetName("mock.config", AfterTargets.AfterBuild);

            //Assert
            actual.Should().Be("mock_config_AfterBuild");
        }
Пример #12
0
        public void HasUsingTaskTransformXml_TransformTask_ReturnsTrue()
        {
            //Arrange
            var root = XElement.Parse(@"<Project><UsingTask TaskName=""TransformXml""/></Project>");
            var sut  = new XmlTransform();

            //Act
            var actual = sut.HasUsingTaskTransformXml(root);

            //Assert
            actual.Should().BeTrue();
        }
Пример #13
0
        public void HasAfterBuildTargetTransformXml_NotEqualTransformXmlSource_ReturnsFalse()
        {
            //Arrange
            var root = XElement.Parse(@"<Project><Target Name=""AfterBuild""><TransformXml Source=""plainxml.config""/></Target></Project>");
            var sut  = new XmlTransform();

            //Act
            var actual = sut.HasAfterBuildTargetTransformXml(root, "mock.config");

            //Assert
            actual.Should().BeFalse();
        }
Пример #14
0
        public void GetTarget_EmptyName_ThrowsException()
        {
            //Arrange
            var root = XElement.Parse(@"<Project><Target Name=""mock_target""></Target></Project>");
            var sut  = new XmlTransform();

            //Act
            Action action = () => sut.GetTarget(root, string.Empty);

            //Assert
            action.Should().Throw <ArgumentNullException>();
        }
Пример #15
0
        public void HasAfterPublishTargetDeployedConfigDefenition_WithDeployedConfig_ReturnsTrue()
        {
            //Arrange
            var root = XElement.Parse(@"<Project><Target Name=""AfterPublish""><PropertyGroup><DeployedConfig/></PropertyGroup></Target></Project>");
            var sut  = new XmlTransform();

            //Act
            var actual = sut.HasAfterPublishTargetDeployedConfigDefenition(root);

            //Assert
            actual.Should().BeTrue();
        }
Пример #16
0
        public void HasTarget_TargetExist_ReturnsTrue()
        {
            //Arrange
            var root = XElement.Parse(@"<Project><Target Name=""mock_target""></Target></Project>");
            var sut  = new XmlTransform();

            //Act
            var actual = sut.HasTarget(root, "mock_target");

            //Assert
            actual.Should().BeTrue();
        }
Пример #17
0
        public void GetTarget_OneTarget_ReturnsValue()
        {
            //Arrange
            var root = XElement.Parse(@"<Project><Target Name=""mock_target""></Target></Project>");
            var sut  = new XmlTransform();

            //Act
            var actual = sut.GetTarget(root, "mock_target");

            //Assert
            actual.Should().NotBeNull();
        }
Пример #18
0
        public void HasAfterCompileTargetTransformXml_EqualTransformXmlSource_ReturnsTrue()
        {
            //Arrange
            var root = XElement.Parse(@"<Project><Target Name=""AfterCompile""><TransformXml Source=""mock.config""/></Target></Project>");
            var sut  = new XmlTransform();

            //Act
            var actual = sut.HasAfterCompileTargetTransformXml(root, "mock.config");

            //Assert
            actual.Should().BeTrue();
        }
Пример #19
0
        public void HasAfterPublishTarget_NoAfterPublishTarget_ReturnsFalse()
        {
            //Arrange
            var root = XElement.Parse(@"<Project></Project>");
            var sut  = new XmlTransform();

            //Act
            var actual = sut.HasAfterPublishTarget(root);

            //Assert
            actual.Should().BeFalse();
        }
Пример #20
0
        public void HasAfterPublishTarget_OneAfterPublishTarget_ReturnsTrue()
        {
            //Arrange
            var root = XElement.Parse(@"<Project><Target Name=""AfterPublish""></Target></Project>");
            var sut  = new XmlTransform();

            //Act
            var actual = sut.HasAfterPublishTarget(root);

            //Assert
            actual.Should().BeTrue();
        }
        public void FileToEntity_GivenBeerSmithFile_ParsesSuccessfully()
        {
            // Arrange

            FileStream fs = new FileStream(@"\brewsker\samplexml\recipes.xml", FileMode.Open);
            ITransform t = new XmlTransform(new DictionaryMapRepository());

            // Act
            var recipes = t.Transform<Contracts.RECIPES>(fs);

            // Assert
            Assert.IsTrue(recipes.Count > 0);
        }
Пример #22
0
        public void GetTarget_TwoSameNameTargets_ThrowsException()
        {
            //Arrange
            var root = XElement.Parse(@"<Project><Target Name=""mock_target""></Target><Target Name=""mock_target""></Target></Project>", LoadOptions.SetLineInfo);
            var sut  = new XmlTransform();

            //Act
            Action action = () => sut.GetTarget(root, "mock_target");

            //Assert
            action.Should().Throw <XmlSchemaValidationException>()
            .And.LineNumber.Should().BeGreaterThan(0);
        }
Пример #23
0
        public static string ToXmlString(ConditionalBranchManager cbm)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<ConditionalBranchManager>\r\n<DefaultChannel>" + XmlTransform.Xmlify(cbm.m_defaultChannel) + "</DefaultChannel>\r\n");
            foreach (BranchScenario bs in cbm.m_branchScenarios)
            {
                sb.Append("<BranchScenario>\r\n"
                          + "<Channel>" + XmlTransform.Xmlify(bs.Channel) + "</Channel>\r\n"
                          + "<Condition>" + XmlTransform.Xmlify(bs.Condition) + "</Condition>\r\n"
                          + "<TargetGuid>" + XmlConvert.ToString(bs.TargetGuid) + "</TargetGuid>\r\n"
                          + "<MasterGuid>" + XmlConvert.ToString(bs.MasterGuid) + "</MasterGuid>\r\n"
                          + "</BranchScenario>\r\n");
            }

            sb.Append("</ConditionalBranchManager>");

            return(sb.ToString());
        }
Пример #24
0
        public void CreateAfterPublishContent_AllParams_ReturnsObjectList()
        {
            //Arrange
            var sut = new XmlTransform();

            //Act
            var actual = sut.CreateAfterPublishContent().ToList();

            //Assert
            actual.ElementAt(0).Should().BeOfType <XElement>().Subject.Name.LocalName.Should().Be("PropertyGroup");
            actual.ElementAt(0).Should().BeOfType <XElement>().Subject.Elements().ElementAt(0)
            .Name.LocalName.Should().Be("DeployedConfig");
            actual.ElementAt(1).Should().BeOfType <XComment>();
            actual.ElementAt(2).Should().BeOfType <XElement>().Subject.Should()
            .HaveAttribute("Condition", "Exists('$(DeployedConfig)')")
            .And.HaveAttribute("SourceFiles", "$(IntermediateOutputPath)$(TargetFileName).config")
            .And.HaveAttribute("DestinationFiles", "$(DeployedConfig)")
            .And.Subject.Name.LocalName.Should().Be("Copy");
        }
Пример #25
0
        private Tuple <string, string> BuildAccountGroupXmlAndInstrumentGroupXml(Guid[] accountGroupIds, Guid[] instrumentGroupIDs)
        {
            string accountGroupIDsXml = null;

            string[] accountGroupIDsArray = new string[accountGroupIds.Length];
            //accountIDs.CopyTo(accountIDsArray, 0);
            for (int i = 0, count = accountGroupIds.Length; i < count; i++)
            {
                accountGroupIDsArray[i] = accountGroupIds[i].ToString();
            }
            accountGroupIDsXml = XmlTransform.Transform(accountGroupIDsArray, "AccountGroups", "AccountGroup", "ID");

            string[] instrumentGroupArray = new string[instrumentGroupIDs.Length];
            for (int i = 0; i < instrumentGroupIDs.Length; i++)
            {
                instrumentGroupArray[i] = instrumentGroupIDs[i].ToString();
            }
            string instrumentGroupXml = XmlTransform.Transform(instrumentGroupArray, "InstrumentGroups", "InstrumentGroup", "ID");

            return(Tuple.Create(accountGroupIDsXml, instrumentGroupXml));
        }
Пример #26
0
        private XmlNode GetAlertRisk()
        {
            XmlDocument xmlDoc    = new XmlDocument();
            XmlElement  alertNode = xmlDoc.CreateElement("Alert");

            xmlDoc.AppendChild(alertNode);

            XmlElement accountNode = (XmlElement)xmlDoc.ImportNode(_account.ToXmlNode(), true);

            alertNode.AppendChild(accountNode);

            accountNode.SetAttribute("AlertTime", XmlConvert.ToString(_account.AlertTime, DateTimeFormat.Xml));
            XmlElement transNode = xmlDoc.CreateElement("Transactions");

            foreach (Transaction tran in _account.Transactions)
            {
                transNode.AppendChild(xmlDoc.ImportNode(tran.ToXml().ToXmlNode(), true));
            }
            accountNode.AppendChild(transNode);

            string url = PathHelper.GetAlertRiskStylesheetPath();

            return(XmlTransform.Transform(alertNode, url, null));
        }
Пример #27
0
        public void MaskXmlInvalidCharactersMasks0Char()
        {
            string c = "\u0000";

            Assert.AreEqual("?", XmlTransform.MaskInvalidCharacters(c, "?"));
        }
Пример #28
0
        public void MaskXmlInvalidCharactersAllowsJapaneseCharacters()
        {
            string kome = "\u203B";

            Assert.AreEqual(kome, XmlTransform.MaskInvalidCharacters(kome, "?"));
        }
Пример #29
0
        private static void CreateStatement(object state)
        {
            StatementArg statementArg = (StatementArg)state;
            Token        token        = statementArg.Token;
            string       sql          = string.Empty;

            if (statementArg.Rdlc.ToLower().Contains("statement_mc"))
            {
                sql = "EXEC P_RptStatement_RC2 ";
            }
            else
            {
                switch (statementArg.StatementReportType)
                {
                case 0:
                    sql = "EXEC P_RptStatement_RC2 ";
                    break;

                case 1:
                    sql = "EXEC P_RptStatement2_RC2 ";
                    break;

                case 2:
                    sql = "EXEC P_RptStatement4_RC2 ";
                    break;

                case 3:
                    sql = "EXEC P_RptStatement5_RC2 ";
                    break;
                }
            }
            sql += "@xmlAccounts=" + "\'" + XmlTransform.Transform(statementArg.IDs, ',', "Accounts", "Account", "ID")
                   + "\',@tradeDayBegin=\'" + statementArg.DayBegin + "\',@tradeDayTo=\'" + statementArg.DayTo + "\',@language=\'" + statementArg.Version + "\',@userID=\'" + statementArg.Token.UserID.ToString() + "\'";
            try
            {
                DataSet dataSet = DataAccess.GetData(sql, SettingManager.Default.ConnectionString, StatementReportTimeout);
                try
                {
                    TradingConsoleServer tradingConsoleServer = statementArg.TradingConsoleServer;
                    tradingConsoleServer.SaveStatement(token, "", statementArg.IDs);
                }
                catch
                {
                }
                if (dataSet.Tables.Count > 0)
                {
                    string filepath = Path.Combine(SettingManager.Default.PhysicPath, statementArg.Rdlc); // this.Server.MapPath(statementArg.Rdlc);
                    Console.WriteLine(filepath);
                    if (statementArg.Rdlc.ToLower().Contains("statement_mc") && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0)
                    {
                        if (!(bool)dataSet.Tables[0].Rows[0]["IsMultiCurrency"])
                        {
                            filepath = filepath.ToLower().Replace("rptStatement_mc.rdlc", "RptStatement.rdlc");
                        }
                    }
                    byte[]             reportContent      = PDFHelper.ExportPDF(filepath, dataSet.Tables[0]);
                    AsyncResultManager asyncResultManager = statementArg.AsyncResultManager;
                    asyncResultManager.SetResult(statementArg.AsyncResult, reportContent);
                    CommandManager.Default.AddCommand(new AsyncCommand(0, statementArg.AsyncResult));
                }
            }
            catch (System.Exception ex)
            {
                CommandManager.Default.AddCommand(new AsyncCommand(0, statementArg.AsyncResult, true, ex));
                _Logger.Error(ex);
            }
        }
Пример #30
0
        private static XmlNode TransformCommon(XmlNode source, string styleName)
        {
            var path = GetStylePath(styleName);

            return(XmlTransform.Transform(source, path, null));
        }
 public TransformFixture(XmlElement element){
     XmlTransformInstance = new XmlTransform(element);
 }