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() != "", "Дата рождения не обнаружена");
            }
        }
Esempio n. 2
0
        public static void Main()
        {
            string xml = XmlBuilder.Create()
                         .Customer._b_
                         .Name("Ivaylo", new { id = "unikat", change = "clickni" })
                         .Phone("0888-888-888")
                         .Address._b_
                         .Street("In da gethou", new { @class = "css bate" })
                         .City("Kjustendja Baby")
                         .Zip("Rar")
                         ._d_
                         ._d_
                         .Build();

            // prints
            // <Customer>
            //     <Name id="unikat" change="clickni">Ivaylo</Name>
            //     <Phone>0888-888-888</Phone>
            //     <Address>
            //         <Street class="css bate">In da gethou</Street>
            //         <City>Kjustendja Baby</City>
            //         <Zip>Rar</Zip>
            //     </Address>
            // </Customer>

            Console.WriteLine(xml);
        }
Esempio n. 3
0
        public override void Ouput(System.Web.HttpContext context)
        {
            string toUserName   = dataAdapter.TryGetValue <string>("fromusername", string.Empty);
            string fromUserName = dataAdapter.TryGetValue <string>("tousername", string.Empty);

            string content = string.Empty;

            if (string.IsNullOrEmpty(Content))
            {
                Bee.WeiXin.InvokeContext invokeContext = Bee.WeiXin.InvokeContextManager.Instance.CurrentContext(toUserName);

                string invokeContextString = string.Join(",", (from item in invokeContext.MessageStack select item.Command).ToArray());

                content = string.Format("{0}\r\n{1}", dataAdapter.ToString(), invokeContextString);
            }
            else
            {
                content = Content;
            }

            XmlBuilder builder = XmlBuilder.New.tag("xml");


            builder = builder.tag("ToUserName").include(toUserName, true).endTag();
            builder = builder.tag("FromUserName").include(fromUserName, true).end;
            builder = builder.tag("MsgType").include("text", true).end;
            builder = builder.tag("CreateTime").include(DateTimeUtil.GetWeixinDateTime(DateTime.Now).ToString(), true).end;
            builder = builder.tag("Content").include(content, true).end;

            builder = builder.end;

            Bee.Logging.Logger.Debug(builder.ToString());

            context.Response.Write(builder.ToString());
        }
Esempio n. 4
0
        public override void Ouput(System.Web.HttpContext context)
        {
            string toUserName   = dataAdapter.TryGetValue <string>("fromusername", string.Empty);
            string fromUserName = dataAdapter.TryGetValue <string>("tousername", string.Empty);

            XmlBuilder builder = XmlBuilder.New.tag("xml");

            builder = builder.tag("ToUserName").include(toUserName, true).end;
            builder = builder.tag("FromUserName").include(fromUserName, true).end;
            builder = builder.tag("MsgType").include("news", true).end;
            builder = builder.tag("CreateTime").include(DateTimeUtil.GetWeixinDateTime(DateTime.Now).ToString(), true).end;
            builder = builder.tag("ArticleCount").include(list.Count.ToString(), true).end;

            builder = builder.tag("Articles");

            foreach (Article item in list)
            {
                builder = builder.tag("item")
                          .tag("Title").include(item.Title, true).end
                          .tag("Description").include(item.Description, true).end
                          .tag("PicUrl").include(item.PicUrl, true).end
                          .tag("Url").include(item.Url, true).end
                          .end;
            }

            builder = builder.end;

            builder = builder.end;

            context.Response.Write(builder.ToString());
        }
Esempio n. 5
0
        public override void Ouput(System.Web.HttpContext context)
        {
            string toUserName   = dataAdapter.TryGetValue <string>("fromusername", string.Empty);
            string fromUserName = dataAdapter.TryGetValue <string>("tousername", string.Empty);

            XmlBuilder builder = XmlBuilder.New.tag("xml");

            builder = builder.tag("ToUserName").include(toUserName, true).end;
            builder = builder.tag("FromUserName").include(fromUserName, true).end;
            builder = builder.tag("MsgType").include("music", true).end;
            builder = builder.tag("CreateTime").include(DateTimeUtil.GetWeixinDateTime(DateTime.Now).ToString(), true).end;

            if (Music != null)
            {
                builder = builder.tag("Music")
                          .tag("Title").include(Music.Title, true).end
                          .tag("Description").include(Music.Description, true).end
                          .tag("MusicUrl").include(Music.MusicUrl, true).end
                          .tag("HQMusicUrl").include(Music.HQMusicUrl, true).end
                          .end;
            }


            builder = builder.end;

            context.Response.Write(builder.ToString());
        }
Esempio n. 6
0
        public static object Run(string[] args)
        {
            // TODO later, we'll make it so this is easy to extend.  for now, we just support generating nuspec files
            if (args[0] != "nuspec")
            {
                return(string.Format("Unknown template: {0}", args[0]));
            }

            var dirname     = Path.GetFileName(Directory.GetCurrentDirectory());
            var filename    = dirname + ".nuspec";
            var path        = Path.Combine(Directory.GetCurrentDirectory(), filename);
            var now         = Feed.Format(DateTime.Now);
            var version     = "1.0.0.0";
            var description = "";
            var author      = "me";
            var xml         = new XmlBuilder();

            xml.StartElement("package").
            StartElement("metadata").
            WriteElement("id", dirname).
            WriteElement("version", version).
            WriteElement("description", description).
            StartElement("authors").
            WriteElement("author", author).
            EndElement().
            WriteElement("created", now).
            WriteElement("modified", now).
            EndElement().
            EndElement();

            Util.WriteFile(path, xml.ToString());
            return(string.Format("Generated {0}", filename));
        }
        public string ToXml(object entity)
        {
            XmlBuilder builder = new XmlBuilder();

            builder.tag(typeof(T).Name);
            foreach (PropertySchema property in GetPropertyList())
            {
                string xmlValue      = string.Empty;
                object propertyValue = GetPropertyValue(entity, property.Name);
                if (propertyValue != null)
                {
                    TypeCode typeCode = Type.GetTypeCode(property.PropertyType);
                    if (property.PropertyType.IsArray)
                    {
                        xmlValue = propertyValue.ToString();
                    }
                    else if (typeCode == TypeCode.Object && !property.PropertyType.IsValueType)
                    {
                        IEntityProxy entityProxy = EntityProxyManager.Instance.GetEntityProxyFromType(property.PropertyType);
                        xmlValue = entityProxy.ToXml(propertyValue);
                    }
                    else
                    {
                        xmlValue = propertyValue.ToString();
                    }
                }

                builder = builder.newline.tab.tag(property.Name).text(xmlValue, true).end;
            }
            builder = builder.newline.end;

            return(builder.ToString());
        }
Esempio n. 8
0
        private void RefreshItem()
        {
            MapItem m = null;

            if (nItemId > -1)
            {
                m = sm.All[nItemId];
                XmlBuilder.WriteField(Response, this.cmbParent.ClientID, m.Parent.ID.ToString() + "#" + m.Parent.Items.Count.ToString());
                XmlBuilder.WriteField(Response, this.cmbIndex.ClientID, m.Index.ToString());
                XmlBuilder.WriteField(Response, this.cmbType.ClientID, m._type.ToString());
                XmlBuilder.WriteField(Response, this.txtPath.ClientID, m._path);
                XmlBuilder.WriteField(Response, this.chkShow.ClientID, m._hidden ? "0" : "1");
                XmlBuilder.WriteField(Response, this.hIndex.ClientID, m.Index.ToString());
                if (m._type == MapItemType.Page)
                {
                    PageInfo pi = new PageInfo(m._path);
                    XmlBuilder.WriteField(Response, this.chkSecure1.ClientID, pi.IsSecure ? "0" : "1");
                    XmlBuilder.WriteField(Response, this.chkSecure2.ClientID, pi.IsSecure ? "1" : "0");
                    XmlBuilder.WriteField(Response, this.cmbTemplate.ClientID, pi.Template);
                    XmlBuilder.WriteField(Response, this.txtCodeFile.ClientID, pi.CodeFile);
                    XmlBuilder.WriteField(Response, this.cmbPart.ClientID, pi.SecurityPart.ToString());
                    XmlBuilder.WriteField(Response, this.chkDeleted.ClientID, pi.Deleted ? "1" : "0");
                }
            }
            else if (nItemId == -1)
            {
                m = sm;
            }
            else
            {
                return;
            }
            XmlBuilder.WriteField(Response, this.txtUrl.ClientID, m._url);
            XmlBuilder.WriteField(Response, this.txtText.ClientID, m._text);
        }
Esempio n. 9
0
        private void CodeRefresh()
        {
            if (sPagePath == "")
            {
                return;
            }
            PageInfo pi = new PageInfo(sPagePath);

            XmlBuilder.WriteField(Response, this.txtCodePath.ClientID, pi.CodeFile);
            if (pi.CodeFile.Length > 0)
            {
                StreamReader sr = null;
                try
                {
                    sr = new StreamReader(Request.MapPath(Keys.ServerRoot + Keys.UrlPathDelimiter + pi.CodeFile), Encoding.Default);
                    XmlBuilder.WriteField(Response, this.txtCodeBody.ClientID, sr.ReadToEnd());
                }
                catch (Exception ex)
                {
                    Config.ReportError(ex);
                }
                finally
                {
                    if (sr != null)
                    {
                        sr.Close();
                    }
                }
            }
            else
            {
                XmlBuilder.WriteField(Response, this.txtCodeBody.ClientID, "");
            }
        }
Esempio n. 10
0
        public static void testCORSCOnfig()
        {
            CORSConfiguration corsConfig = new CORSConfiguration();

            corsConfig.corsRules = new List <CORSConfiguration.CORSRule>();
            for (int i = 0; i < 3; i++)
            {
                CORSConfiguration.CORSRule corsRule = new CORSConfiguration.CORSRule();
                corsRule.id            = (i + 1).ToString();
                corsRule.allowedOrigin = "http://www.cloud.tencent.com";
                corsRule.maxAgeSeconds = 5000;

                corsRule.allowedMethods = new List <string>();
                corsRule.allowedMethods.Add("PUT");
                corsRule.allowedMethods.Add("GET");
                corsRule.allowedMethods.Add("DELETE");

                corsRule.allowedHeaders = new List <string>();
                corsRule.allowedHeaders.Add("Host");
                corsRule.allowedHeaders.Add("Authorizition");
                corsRule.allowedHeaders.Add("Content-Length");

                corsRule.exposeHeaders = new List <string>();
                corsRule.exposeHeaders.Add("X-COS-Meta1");
                corsRule.exposeHeaders.Add("X-COS-Meta2");
                corsRule.exposeHeaders.Add("X-COS-Meta2");
                corsConfig.corsRules.Add(corsRule);
            }
            Console.WriteLine(XmlBuilder.BuildCORSConfigXML(corsConfig));
        }
Esempio n. 11
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);
    }
        public void TestOneNodeTree()
        {
            string     expectedResult = "<orders></orders>";
            XmlBuilder builder        = new XmlBuilder("orders");

            Assert.Equal(builder.ToString(), expectedResult);
        }
Esempio n. 13
0
        private void TemplateRefresh()
        {
            if (sPagePath == "")
            {
                return;
            }
            PageInfo pi = new PageInfo(sPagePath);

            if (pi.Template.Length > 0)
            {
                XmlBuilder.WriteField(Response, this.txtTemplatePath.ClientID, pi.Template);
                StreamReader sr = null;
                try
                {
                    sr = new StreamReader(Request.MapPath(Keys.ServerRoot + Keys.UrlPathDelimiter + pi.Template), Encoding.Default);
                    XmlBuilder.WriteField(Response, this.txtTemplateBody.ClientID, sr.ReadToEnd());
                }
                finally
                {
                    if (sr != null)
                    {
                        sr.Close();
                    }
                }
            }
            else
            {
                XmlBuilder.WriteField(Response, this.txtTemplatePath.ClientID, "");
                XmlBuilder.WriteField(Response, this.txtTemplateBody.ClientID, "");
            }
        }
Esempio n. 14
0
        public void AppendProcessingInstructionEmptyContent()
        {
            XmlBuilder xmlBuilder = new XmlBuilder();

            xmlBuilder.AppendProcessingInstruction("xml", string.Empty);

            Assert.AreEqual("<?xml?>", xmlBuilder.ToString());
        }
Esempio n. 15
0
        public void AppendProcessingInstruction()
        {
            XmlBuilder xmlBuilder = new XmlBuilder();

            xmlBuilder.AppendProcessingInstruction("xml", "version=\"1.0\"");

            Assert.AreEqual("<?xml version=\"1.0\"?>", xmlBuilder.ToString());
        }
Esempio n. 16
0
        public void AppendElementEmptyText()
        {
            XmlBuilder xmlBuilder = new XmlBuilder();

            xmlBuilder.AppendElement("tag", string.Empty);

            Assert.AreEqual("<tag></tag>", xmlBuilder.ToString());
        }
Esempio n. 17
0
        public void AppendElementNullText()
        {
            XmlBuilder xmlBuilder = new XmlBuilder();

            xmlBuilder.AppendElement("tag", null);

            Assert.AreEqual("<tag />", xmlBuilder.ToString());
        }
Esempio n. 18
0
        public void AppendElement()
        {
            XmlBuilder xmlBuilder = new XmlBuilder();

            xmlBuilder.AppendElement("tag", "inner text");

            Assert.AreEqual("<tag>inner text</tag>", xmlBuilder.ToString());
        }
Esempio n. 19
0
        public void TestConstructor_ValidProcess()
        {
            XmlBuilder b = new XmlBuilder(new DudProcess());

            Assert.AreEqual(0, b.Algorithms.Count);
            Assert.AreEqual(0, b.Inputs.Count);
            Assert.IsNull(b.Xml);
        }
Esempio n. 20
0
        public void AppendCommentEmptyText()
        {
            XmlBuilder xmlBuilder = new XmlBuilder();

            xmlBuilder.AppendComment(null);

            Assert.AreEqual("<!--  -->", xmlBuilder.ToString());
        }
Esempio n. 21
0
        public void Build_with_Value()
        {
            string xml = @"<Root>value</Root>";

            builder = new XmlBuilder("Root");
            builder.AddValue("value");
            Assert.AreEqual(xml, builder.Build().ToString());
        }
Esempio n. 22
0
 private void RefreshParents()
 {
     XmlBuilder.WriteListItem(Response, "-1#" + sm.Items.Count.ToString(), sm._text);
     foreach (MapItem m in sm.All)
     {
         XmlBuilder.WriteListItem(Response, m.ID.ToString() + "#" + m.Items.Count.ToString(), new string('\"', m.Level + 1).Replace("\"", "` ") + m._text);
     }
 }
Esempio n. 23
0
        public void AppendComment()
        {
            XmlBuilder xmlBuilder = new XmlBuilder();

            xmlBuilder.AppendComment("Comment");

            Assert.AreEqual("<!-- Comment -->", xmlBuilder.ToString());
        }
Esempio n. 24
0
        public void AppendStartTag2()
        {
            XmlBuilder xmlBuilder = new XmlBuilder();

            xmlBuilder.AppendStartTag("ns", "tag");

            Assert.AreEqual("<ns:tag>", xmlBuilder.ToString());
        }
Esempio n. 25
0
        public void AppendEndTag()
        {
            XmlBuilder xmlBuilder = new XmlBuilder();

            xmlBuilder.AppendStartTag("tag");
            xmlBuilder.AppendEndTag();

            Assert.AreEqual("<tag></tag>", xmlBuilder.ToString());
        }
Esempio n. 26
0
        public void BuildCORSConfigXMLTest()
        {
            CORSConfiguration corsConfiguration = null;         // TODO: Initialize to an appropriate value
            string            expected          = string.Empty; // TODO: Initialize to an appropriate value
            string            actual;

            actual = XmlBuilder.BuildCORSConfigXML(corsConfiguration);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        public void TestAddBelowTree()
        {
            string     expectedResult = "<orders><order><item></item></order></orders>";
            XmlBuilder builder        = new XmlBuilder("orders");

            builder.AddBelow("order");
            builder.AddBelow("item");

            Assert.Equal(builder.ToString(), expectedResult);
        }
Esempio n. 28
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());
        }
Esempio n. 29
0
        private void ItemRefresh()
        {
            if (Request.QueryString["id"] == null)
            {
                return;
            }
            list.ReadItem(Int32.Parse(Request.QueryString["id"]));
            StringBuilder sb = new StringBuilder();

            XmlBuilder.AppendField(sb, "field_" + FIELD_PARENT_ID, list.Data.Rows[0][FIELD_LEVEL].ToString() + "#" + list.Data.Rows[0][FIELD_PARENT_ID].ToString());
            foreach (DataColumn col in list.Data.Columns)
            {
                if (col.ColumnName != FIELD_PARENT_ID &&
                    col.ColumnName != FIELD_LEVEL)
                {
                    string val = list.Data.Rows[0][col].ToString();
                    if (col.ExtendedProperties.ContainsKey("inputtype"))
                    {
                        if (val != string.Empty)
                        {
                            switch (col.ExtendedProperties["inputtype"].ToString())
                            {
                            case "date":
                                val = Convert.ToDateTime(list.Data.Rows[0][col]).ToString("yyyy-MM-dd");
                                break;

                            case "time":
                                val = Convert.ToDateTime(list.Data.Rows[0][col]).ToLongTimeString();
                                break;

                            case "datetime":
                                val = Convert.ToDateTime(list.Data.Rows[0][col]).ToString(CultureInfo.InvariantCulture);
                                break;

                            case "file":
                                if (restrictedUser)
                                {
                                    if (val.StartsWith(ui.LoginName + "/"))
                                    {
                                        val = val.Substring((ui.LoginName + "/").Length);
                                    }
                                }
                                break;
                            }
                            if (col.DataType == typeof(double))
                            {
                                val = Convert.ToDouble(list.Data.Rows[0][col]).ToString(CultureInfo.InvariantCulture);
                            }
                        }
                    }
                    XmlBuilder.AppendField(sb, "field_" + col.ColumnName, val);
                }
            }
            Response.Write(sb);
        }
        public void TestAddBelowWithAttributeToTree()
        {
            string     expectedResult = "<orders><order number='1234' quantity='20'></order></orders>";
            XmlBuilder builder        = new XmlBuilder("orders");

            builder.AddBelow("order");
            builder.AddAttribute("number", "1234");
            builder.AddAttribute("quantity", "20");

            Assert.Equal(builder.ToString(), expectedResult);
        }