示例#1
0
 internal OkPneuTire ChoseRightTire(OkPneuTire tire1, OkPneuTire tire2)
 {
     if (tire1.ExternalStore > 0 && tire2.ExternalStore == 0)
     {
         return tire1;
     }
     else if (tire1.ExternalStore == 0 && tire2.ExternalStore > 0)
     {
         return tire2;
     }
     else if (tire1.ExternalStore == 0 && tire2.ExternalStore == 0)
     {
         if (tire1.ExternalStoreCZ > 0 && tire2.ExternalStoreCZ == 0)
         {
             return tire1;
         }
         else if (tire1.ExternalStoreCZ == 0 && tire2.ExternalStoreCZ > 0)
         {
             return tire2;
         }
         else
         {
             if (tire1.ExternalStoreEU > 0 && tire2.ExternalStoreEU == 0)
             {
                 return tire1;
             }
             else if (tire1.ExternalStoreEU == 0 && tire2.ExternalStoreEU > 0)
             {
                 return tire2;
             }
             else
             {
                 return tire1;
             }
         }
     }
     else return tire1;
 }
示例#2
0
        internal void ParseFileUpdateDB()
        {
            form.buttonDownload.Enabled = false;
            form.button1.Enabled = false;
            OpenFile of = new OpenFile("vo.xml");
            List<OkPneuTire> lt = of.OpenXml();

            Dictionary<string, OkPneuTire> DictData = new Dictionary<string, OkPneuTire>();
            OkPneuTire MatchTire = new OkPneuTire();
            foreach (var i in lt)
            {

                if (i.EAN.Length > 14) i.EAN = i.EAN.Substring(0, 13);
                if (i.Manufacturer.Length > 10) i.Manufacturer = i.Manufacturer.Substring(0, 9);
                if (i.code.Length > 15) i.code = i.code.Substring(0, 14);
                if (i.Name.Length > 50) i.Name = i.Name.Substring(0, 49);
                if (i.Description.Length > 2000) i.Description = i.Description.Substring(0, 1999);
                i.ImageURL = i.ImageURL.Trim();
                if (i.ImageURL.Length > 200) i.ImageURL = i.ImageURL.Substring(0, 199);
                if (i.EAN == "" || i.EAN == null) continue;

                if (DictData.TryGetValue(i.EAN, out MatchTire))
                {
                    DictData.Remove(i.EAN);
                    MatchTire = ChoseRightTire(i, MatchTire);
                    DictData.Add(MatchTire.EAN, MatchTire);
                }
                else
                {
                    DictData.Add(i.EAN, i);
                }
            }
            UpdateDB(DictData.Values.ToList());
            form.buttonDownload.Enabled = true;
            form.button1.Enabled = true;
        }