public void GetTRICDebtsByPeriodFactory_Make()
        {
            int i_owner = 1032; // код поставщика, выдается администратором системы

            var xmlRoot = new XmlBuilder("Accounts");

            var accountElement = new XmlBuilder("Account");

            accountElement.AddAttribute("accountID", 11816105);
            string b_period = new DateTime(2004, 12, 1).ToString("dd.MM.yyyy");
            string e_period = new DateTime(2016, 10, 1).ToString("dd.MM.yyyy");

            accountElement.AddAttribute("b_period", b_period);
            accountElement.AddAttribute("e_period", e_period);

            xmlRoot.AddElement(accountElement.Build());

            string xmlAccounts = xmlRoot.Build().ToString();

            /* ИЛИ так:
             * string xmlAccounts = @"<Accounts>
             *          <Account accountID=""11816105"" b_period=""01.12.2014"" e_period=""01.10.2016"" />
             *  </Accounts>";
             */

            var response = this.factory.Make(new object[] { i_owner, xmlAccounts }, ticket);

            Assert.IsInstanceOfType(response, typeof(DataSet));
            Assert.AreEqual(1, response.Tables.Count);
            Assert.AreEqual(7, response.Tables[0].Columns.Count);
            Assert.IsTrue(response.Tables[0].Rows.Count > 0);

            int colNum = 0;

            string[] columns = columnNamesInResponse.Replace("[", "").Replace("]", "").Split(new char[] { ',' });

            response.Tables[0].Columns.Cast <DataColumn>().ToList()
            .ForEach(x =>
            {
                Assert.AreEqual(columns[colNum], x.ColumnName);
                colNum++;
            });

            IEnumerable <DataRow> rowsTop10 = response.Tables[0].Rows.Cast <DataRow>().Take(10);

            foreach (DataRow row in rowsTop10)
            {
                Assert.IsTrue((int)row["cod_pl"] > 0, "Лицевой счет не обнаружен");
                Assert.IsTrue((int)row["for_period"] > 0, "Код периода не обнаружен");

                decimal sumSaldo;
                bool    isDecimal = Decimal.TryParse(row["s_money"].ToString(), out sumSaldo);
                Assert.IsTrue(isDecimal, "Сумма задолженности не обнаружена");

                Assert.IsTrue(row["address"].ToString() != "", "Адрес не обнаружена");
                Assert.IsTrue(row["FIO"].ToString() != "", "Фамилия не обнаружена");
                Assert.IsTrue((int)row["i_house"] > 0, "Код дома не обнаружен");
                Assert.IsTrue(row["d_born"].ToString() != "", "Дата рождения не обнаружена");
            }
        }
예제 #2
0
    public static IEnumerable GetDebtsByPeriod(string accountID, DateTime b_period, DateTime e_period)
    {
        int i_owner = 1032; // код поставщика, выдаетс¤ администратором системы

        var    client = new ServiceIntegratorClient(new ServiceIntegrator(ServiceUrl.Url));
        string ticket = client.GetAuthorizationTicket(IdentityCredential.User, IdentityCredential.Password);

        var factory = new GetTRICDebtsByPeriodFactory(client);

        var xmlRoot = new XmlBuilder("Accounts");

        var accountElement = new XmlBuilder("Account");

        accountElement.AddAttribute("accountID", accountID);
        string b_period_str = b_period.ToString("dd.MM.yyyy");
        string e_period_str = e_period.ToString("dd.MM.yyyy");

        accountElement.AddAttribute("b_period", b_period_str);
        accountElement.AddAttribute("e_period", e_period_str);

        xmlRoot.AddElement(accountElement.Build());

        string xmlAccounts = xmlRoot.Build().ToString();

        var response = factory.Make(new object[] { i_owner, xmlAccounts }, ticket);

        return(response.Tables[0].Rows);
    }
예제 #3
0
        public void Build_with_Value()
        {
            string xml = @"<Root>value</Root>";

            builder = new XmlBuilder("Root");
            builder.AddValue("value");
            Assert.AreEqual(xml, builder.Build().ToString());
        }
예제 #4
0
        public void Build_with_Attrs()
        {
            string xml = @"<Options mode=""1"" isTest=""yes"" />";

            builder = new XmlBuilder("Options");
            builder.AddAttribute("mode", 1);
            builder.AddAttribute("isTest", "yes");

            Assert.AreEqual(xml, builder.Build().ToString());
        }
예제 #5
0
        public void TestBuild_NoAlgorithms_NoInputs_NoException()
        {
            XmlBuilder b = new XmlBuilder(new DudProcess());

            b.Build();

            Assert.IsNotNull(b.Xml);
            var descendant = b.Xml.Descendants("test").FirstOrDefault();

            Assert.IsNotNull(descendant);
            Assert.IsFalse(descendant.DescendantNodes().Any());
        }
        public void GetTRICLivingsFactory_Make()
        {
            // 1 - по регистрации, 2 - по владельцу, 3 - совмещенный
            int typeSolidarityReg = 3;

            var xmlRoot = new XmlBuilder("Accounts");

            var accountElement = new XmlBuilder("Account");

            accountElement.AddAttribute("accountID", 1191582);
            int b_period = new DateTime(2004, 1, 1).DateToMonth();
            int e_period = new DateTime(2017, 12, 1).DateToMonth();

            accountElement.AddAttribute("b_period", b_period);
            accountElement.AddAttribute("e_period", e_period);

            xmlRoot.AddElement(accountElement.Build());

            string xmlAccounts = xmlRoot.Build().ToString();

            var response = this.factory.Make(new object[] { xmlAccounts, typeSolidarityReg }, ticket);

            Assert.IsInstanceOfType(response, typeof(DataSet));
            Assert.AreEqual(1, response.Tables.Count);
            Assert.AreEqual(9, response.Tables[0].Columns.Count);
            Assert.IsTrue(response.Tables[0].Rows.Count > 0);

            int colNum = 0;

            string[] columns = columnNamesInResponse.Replace("[", "").Replace("]", "").Split(new char[] { ',' });

            response.Tables[0].Columns.Cast <DataColumn>().ToList()
            .ForEach(x =>
            {
                Assert.AreEqual(columns[colNum], x.ColumnName);
                colNum++;
            });

            IEnumerable <DataRow> rowsTop10 = response.Tables[0].Rows.Cast <DataRow>().Take(10);

            foreach (DataRow row in rowsTop10)
            {
                Assert.IsTrue((int)row["cod_pl"] > 0, "Лицевой счет не обнаружен");
                Assert.IsTrue((int)row["i_people"] > 0, "Код жильца не обнаружен");
                Assert.IsTrue(row["FIO"].ToString() != "", "Фамилия не обнаружена");
                Assert.IsTrue(row["d_born"].ToString() != "", "Дата рождения не обнаружена");
                Assert.IsTrue(row["isMain"].ToString() != "", "Ответственный квартиросъемщик указан");
                Assert.IsTrue(row["PlaceBorn"].ToString() != "", "Место рождения не указано");
                Assert.IsTrue(row["b_period"].ToString() != "", "Дата начала не указана");
                Assert.IsFalse(row["e_period"].ToString() != "", "Дата окончания не пуста");
            }
        }
            private void ExerciseXmlBuilder(Differences diff)
            {
                Assert.IsNotNull(diff);

                using (var stream = new MemoryStream())
                    using (var writer = new StreamWriter(stream))
                    {
                        var builder = new XmlBuilder();
                        builder.Build(writer, diff);

                        Assert.IsTrue(writer.BaseStream.Length > 0);
                    }
            }
예제 #8
0
        public void Build_with_AddElement()
        {
            string xml = @"<Accounts>
  <Account account=""1"" />
</Accounts>";

            builder = new XmlBuilder("Accounts");

            builder2 = new XmlBuilder("Account");
            builder2.AddAttribute("account", 1);

            builder.AddElement(builder2.Build());

            Assert.AreEqual(xml, builder.Build().ToString());
        }
예제 #9
0
        public void TestBuild_OneAlgorithm_NoInputs()
        {
            IBuilderProcess     builder = new JobBuilderProcess();
            XmlBuilder          b       = new XmlBuilder(builder);
            AlgorithmDefinition d       = new AlgorithmDefinition("test",
                                                                  new[] { new Property("TestProperty", typeof(double))
                                                                          {
                                                                              Value = 1d
                                                                          } });

            b.Algorithms.Add(d);
            b.Build();
            var algorithms = b.Xml.Descendants("algorithm");

            Assert.AreEqual(1, algorithms.Count());
            Assert.AreEqual(1, algorithms.Descendants("property").Count());
        }
예제 #10
0
        /// <summary>
        /// Encapsulates the state of a pipeline into Xml for later restoration.
        /// </summary>
        /// <param name="processes">The set of processes within the pipeline to
        /// persist into Xml.</param>
        /// <returns>An <see cref="XDocument"/> describing the pipeline.</returns>
        public XDocument SavePipeline(Client.PipelineDefinition processes)
        {
            if (processes == null)
            {
                return(null);
            }

            PipelinePersistanceProcess process = new PipelinePersistanceProcess(_repo.ToDictionary());
            XmlBuilder builder = new XmlBuilder(process);

            foreach (AlgorithmDefinition def in processes)
            {
                builder.Algorithms.Add(def);
            }

            builder.Build();
            return(builder.Xml);
        }
예제 #11
0
    public static IEnumerable GetLivings(string accountID, int b_period, int e_period)
    {
        var    client = new ServiceIntegratorClient(new ServiceIntegrator(ServiceUrl.Url));
        string ticket = client.GetAuthorizationTicket(IdentityCredential.User, IdentityCredential.Password);

        var factory = new GetTRICLivingsFactory(client);

        var xmlRoot = new XmlBuilder("Accounts");

        var accountElement = new XmlBuilder("Account");

        accountElement.AddAttribute("accountID", accountID);
        accountElement.AddAttribute("b_period", b_period);
        accountElement.AddAttribute("e_period", e_period);

        xmlRoot.AddElement(accountElement.Build());

        string xmlAccounts = xmlRoot.Build().ToString();

        var response = factory.Make(new object[] { xmlAccounts, 3 }, ticket);

        return(response.Tables[0].Rows);
    }
        public void GetTRICDebtsByServicesFactory_Make()
        {
            int i_owner = 1032; // код поставщика, выдается администратором системы

            var xmlRoot = new XmlBuilder("Accounts");

            var accountElement = new XmlBuilder("Account");

            accountElement.AddAttribute("i_lschet", 11789150);
            string b_period = new DateTime(2012, 10, 1).ToString("dd.MM.yyyy");
            string e_period = new DateTime(2017, 1, 31).ToString("dd.MM.yyyy");

            accountElement.AddAttribute("b_period", b_period);
            accountElement.AddAttribute("e_period", e_period);

            xmlRoot.AddElement(accountElement.Build());

            string xmlAccounts = xmlRoot.Build().ToString();

            /* ИЛИ так:
             * string xmlAccounts = @"<Accounts>
             *          <Account accountID=""11816105"" b_period=""01.12.2014"" e_period=""01.10.2016"" />
             *  </Accounts>";
             */

            var response = this.factory.Make(new object[] { i_owner, xmlAccounts }, ticket);

            Assert.IsInstanceOfType(response, typeof(DataSet));
            Assert.AreEqual(1, response.Tables.Count);
            Assert.AreEqual(18, response.Tables[0].Columns.Count);
            Assert.IsTrue(response.Tables[0].Rows.Count > 0);

            int colNum = 0;

            string[] columns = columnNamesInResponse.Replace("[", "").Replace("]", "").Split(new char[] { ',' });

            response.Tables[0].Columns.Cast <DataColumn>().ToList()
            .ForEach(x =>
            {
                Assert.AreEqual(columns[colNum], x.ColumnName);
                colNum++;
            });

            IEnumerable <DataRow> rowsTop10 = response.Tables[0].Rows.Cast <DataRow>().Take(10);

            foreach (DataRow row in rowsTop10)
            {
                Assert.IsTrue((int)row["i_lschet"] > 0, "Лицевой счет не обнаружен");
                Assert.IsTrue(row["period"].ToString() != "", "Период не обнаружен");

                Assert.IsTrue(IsDecimal(row, "sum_nach_11"), "Сумма начислено за отопление не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_odn_11"), "Сумма начислено отопление на ОДН не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_opl_11"), "Сумма оплат за отопление не обнаружена");

                Assert.IsTrue(IsDecimal(row, "sum_nach_8"), "Сумма начислено за ГВС не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_odn_8"), "Сумма начислено ГВС на ОДН не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_opl_8"), "Сумма оплат за ГВС не обнаружена");

                Assert.IsTrue(IsDecimal(row, "sum_nach_10"), "Сумма начислено за ХВС не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_odn_10"), "Сумма начислено ХВС на ОДН не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_opl_10"), "Сумма оплат за ХВС не обнаружена");

                Assert.IsTrue(IsDecimal(row, "sum_nach_9"), "Сумма начислено за канализование не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_odn_9"), "Сумма начислено канализование на ОДН не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_opl_9"), "Сумма оплат за канализование не обнаружена");

                Assert.IsTrue(IsDecimal(row, "sum_total_nach"), "Сумма итого начислено не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_total_opl"), "Сумма итого оплачено не обнаружена");
                Assert.IsTrue(IsDecimal(row, "sum_total"), "Сумма итого задолженность не обнаружена");
            }
        }
예제 #13
0
        public void TestBuild_NoAlgorithms_NoInputs_Exception()
        {
            XmlBuilder b = new XmlBuilder(new ExceptionProcess());

            b.Build();
        }
예제 #14
0
 public void Build_with_isNull()
 {
     builder = new XmlBuilder(null);
     Assert.AreEqual("<root />", builder.Build().ToString());
 }
예제 #15
0
 public void Build_with_Empty()
 {
     builder = new XmlBuilder("");
     Assert.AreEqual("<root />", builder.Build().ToString());
 }
예제 #16
0
 public void Build_without_Attrs()
 {
     builder = new XmlBuilder("root");
     Assert.AreEqual("<root />", builder.Build().ToString());
 }