using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace HH.YiDaSyncNC.Models
{
    class XMD_SyncServiceModel
    {
        public class DataModel
        {
            public string pk_group { get; set; }
            public string pk_org { get; set; }
            public string code { get; set; }
            public string name { get; set; }
            public string pk_marbasclass { get; set; }
            public string pk_measdoc { get; set; }
            public string pk_mattaxes { get; set; }
            public string materialspec { get; set; }
            public string materialtype { get; set; }
            public string pk_brand { get; set; }
            public string enablestate { get; set; }
        }

        public class ImportXml
        {
            /// <summary>
            /// 模板头部份
            /// </summary>
            /// <returns></returns>
            public static XElement TemplateHeade()
            {

                return new XElement(new XElement("ufinterface", new object[]
                {
                new XAttribute("sender","dingding"),
                new XAttribute("roottag",""),
                new XAttribute("replace","Y"),
                new XAttribute("isexchange","Y"),
                new XAttribute("groupcode","0"),
                new XAttribute("filename",""),
                new XAttribute("billtype","material"),
                new XAttribute("proc","add"),
                new XAttribute("account","develop")
                }));
            }

            /// <summary>
            /// 组建表头xml
            /// </summary>
            /// <param name="item">表头参数</param>
            /// <returns></returns>
            public static XElement Header(DataModel item, string id)
            {
                return new XElement("bill", new object[]
                {
                "",
                new XAttribute("id",id),
                new XElement("billhead", new object[]
                {
                    new XElement("pk_group",item.pk_group),
                    new XElement("pk_org",item.pk_org),
                    //new XElement("pk_source",item.pk_source),
                    new XElement("code",item.code),
                    new XElement("name",item.name),
                    new XElement("pk_marbasclass",item.pk_marbasclass),
                    new XElement("pk_measdoc",item.pk_measdoc),
                    new XElement("pk_mattaxes",item.pk_mattaxes),
                    new XElement("materialspec",item.materialspec),
                    new XElement("materialtype",item.materialtype),
                    new XElement("pk_brand",item.pk_brand),
                    new XElement("productfamily","N"),
                    new XElement("intolerance","0"),
                    new XElement("outtolerance","0"),
                    new XElement("outcloselowerlimit","0"),
                    new XElement("enablestate",item.enablestate),
                    //new XElement("materialconvert",new object[]{ }),
                    //new XElement("materialtaxtype",new object[]{ }),
                }),
                });
            }
        }
    }
}
