コード例 #1
0
        private static void AggregateInfos(Gesat_Company company)
        {
            Dictionary <string, string> dictionary1 = new Dictionary <string, string>();

            foreach (string info in company.HeaderInfos)
            {
                if (!dictionary1.ContainsKey(info))
                {
                    dictionary1.Add(info, null);
                }
                else
                {
                    Trace.WriteLine($"warning duplicate info \"{info}\"");
                }
            }
            //Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
            //foreach (string info in company.DetailInfos)
            //{
            //    if (!dictionary1.ContainsKey(info))
            //    {
            //        if (!dictionary2.ContainsKey(info))
            //            dictionary2.Add(info, null);
            //        else
            //            Trace.WriteLine($"warning duplicate info \"{info}\"");
            //    }
            //}
            company.HeaderInfos = dictionary1.Keys.ToArray();
            //company.DetailInfos = dictionary2.Keys.ToArray();
        }
コード例 #2
0
        public static Gesat_Company AggregateCompanyData(Gesat_Header_v2 header, Gesat_Detail_v2 detail)
        {
            Gesat_Company company = new Gesat_Company();

            company.LoadFromWebDate = header.LoadFromWebDate;
            company.UrlDetail       = header.UrlDetail;
            company.HeaderName      = header.Name;
            company.HeaderType      = header.Type;
            company.HeaderLocation  = header.Location;
            company.HeaderPhone     = header.Phone;
            company.HeaderInfos     = header.Infos;

            if (detail != null)
            {
                company.DetailName     = detail.Name;
                company.DetailType     = detail.Type;
                company.DetailLocation = detail.Location;
                company.DetailPhone    = detail.Phone;
                //company.DetailInfos = detail.Infos;

                company.City        = detail.City;
                company.Department  = detail.Department;
                company.Description = detail.Description;
                company.Address     = detail.Address;
                company.Fax         = detail.Fax;
                company.Email       = detail.Email;
                company.WebSite     = detail.WebSite;
                company.Activities  = detail.Activities;
            }

            return(company);
        }
コード例 #3
0
 public static void AggregateDuplicateData(Gesat_Company company)
 {
     AggregateDuplicateData(ref company.HeaderName, ref company.DetailName);
     AggregateDuplicateData(ref company.HeaderType, ref company.DetailType);
     AggregateDuplicateData(ref company.HeaderLocation, ref company.DetailLocation);
     AggregateDuplicateData(ref company.HeaderPhone, ref company.DetailPhone);
     AggregateInfos(company);
 }
コード例 #4
0
        public void ExportXml(IEnumerable <HeaderDetail <Gesat_Header_v2, Gesat_Detail_v2> > headerDetails)
        {
            Trace.WriteLine("export Gesat");
            Trace.WriteLine($"   file        \"{_xmlFile}\"");
            Trace.WriteLine($"   file detail \"{_detailXmlFile}\"");
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Encoding = Encoding.UTF8;
            settings.Indent   = true;

            zfile.CreateFileDirectory(_xmlFile);
            zfile.CreateFileDirectory(_detailXmlFile);

            //Unea_Company_DuplicateExists duplicate = new Unea_Company_DuplicateExists();
            //Unea_CompanyUniqueValues uniqueValues = new Unea_CompanyUniqueValues();
            using (XmlWriter xw = XmlWriter.Create(_xmlFile, settings), xwDetail = XmlWriter.Create(_detailXmlFile, settings))
            {
                xw.WriteStartElement("Gesat");
                xwDetail.WriteStartElement("Gesat");

                foreach (HeaderDetail <Gesat_Header_v2, Gesat_Detail_v2> headerDetail in headerDetails)
                {
                    Gesat_Company company = GesatData.AggregateCompanyData(headerDetail.Header, headerDetail.Detail);
                    GesatData.AggregateDuplicateData(company);
                    ExportXml_Company(xw, company, false);
                    ExportXml_Company(xwDetail, company, true);
                    //UneaData.GetCompany_Duplicate(company, duplicate);
                    //UneaData.AddUniqueValues(uniqueValues, company);
                }

                xw.WriteEndElement();
                xwDetail.WriteEndElement();
            }

            //Export_Duplicate(duplicate);
            //ExportUniqueValues(uniqueValues);
        }
コード例 #5
0
        public static void ExportXml_Company(XmlWriter xw, Gesat_Company company, bool detail)
        {
            IEnumerator <string> headerInfos = null;
            //IEnumerator<string> detailInfos = null;
            IEnumerator <string> activities = null;

            if (detail)
            {
                headerInfos = ((IEnumerable <string>)company.HeaderInfos).GetEnumerator();
                //detailInfos = ((IEnumerable<string>)company.DetailInfos).GetEnumerator();
                if (company.Activities != null)
                {
                    activities = ((IEnumerable <string>)company.Activities).GetEnumerator();
                }
            }

            xw.WriteStartElement("Company");
            xw.zWriteElementText("société", company.HeaderName);
            xw.zWriteElementText("société2", company.DetailName);
            xw.zWriteElementText("type", company.HeaderType);
            xw.zWriteElementText("type2", company.DetailType);
            if (detail)
            {
                if (headerInfos.MoveNext())
                {
                    xw.zWriteElementText("info", headerInfos.Current);
                }
                //if (detailInfos.MoveNext())
                //    xw.zWriteElementText("info", detailInfos.Current);
                if (activities != null && activities.MoveNext())
                {
                    xw.zWriteElementText("activité", activities.Current);
                }
            }
            xw.zWriteElementText("ville", company.City);
            xw.zWriteElementText("département", company.Department);
            xw.zWriteElementText("tel", company.HeaderPhone);
            xw.zWriteElementText("tel2", company.DetailPhone);
            xw.zWriteElementText("fax", company.Fax);
            xw.zWriteElementText("email", company.Email);
            xw.zWriteElementText("site", company.WebSite);
            xw.zWriteElementText("description", company.Description);
            xw.zWriteElementText("emplacement", company.HeaderLocation);
            xw.zWriteElementText("emplacement2", company.DetailLocation);
            xw.zWriteElementText("adresse", company.Address);
            xw.zWriteElementText("load_date", string.Format("{0:dd/MM/yyyy HH:mm}", company.LoadFromWebDate));
            xw.zWriteElementText("url", company.UrlDetail);
            xw.WriteEndElement();

            while (detail)
            {
                bool headerInfo = headerInfos.MoveNext();
                //bool detailInfo = detailInfos.MoveNext();
                bool activity = activities != null && activities.MoveNext();
                if (!headerInfo && !activity)
                {
                    break;
                }
                xw.WriteStartElement("Company");
                if (headerInfo)
                {
                    xw.zWriteElementText("info", headerInfos.Current);
                }
                //if (detailInfo)
                //    xw.zWriteElementText("info", detailInfos.Current);
                if (activity)
                {
                    xw.zWriteElementText("activité", activities.Current);
                }
                xw.WriteEndElement();
            }
        }