public static void Compare(string fielName, string targeFileName, string toFileName) { ReadPlatFormWebPageValue flatform = new ReadPlatFormWebPageValue(); BaseReadWebPage res = new BaseReadWebPage(); BaseReadWebPage target = new BaseReadWebPage(); target.ReadBaseItemInfo(targeFileName, true); res.ReadBaseItemInfo(fielName, true); foreach (BaseItemInfo item in target.ShopAllItems.Values) { bool isEixst = false; foreach (BaseItemInfo platformItem in res.ShopAllItems.Values) { bool isSame = false; if (!string.IsNullOrEmpty(item.ID) && !string.IsNullOrEmpty(platformItem.ID)) { if (item.ID.Trim() == platformItem.ID.Trim()) { isSame = true; } } if (isSame || (item.Name == platformItem.Name && item.Created == platformItem.Created)) { if (IsSameFormat(platformItem.Format, item.Format, platformItem.Name, item.Name)) { isEixst = true; CompareTKPrice(platformItem, item, toFileName); //ComparePlatformAndTKPrice(platformItem, item, toFileName); } } } //if (!isEixst) //{ // List<BaseItemInfo> seachItems = flatform.SeachInfoByID(item.ID); // Dictionary<string, BaseItemInfo> saveInfos = new Dictionary<string, BaseItemInfo>(); // foreach (BaseItemInfo info in seachItems) // { // string key = info.Name + info.Format + info.Created; // if (!res.ShopAllItems.ContainsKey(key)) // { // if (item.ID == info.ID || (item.Name == info.Name && item.Created == info.Created)) // { // if (IsSameFormat(info.Format, item.Format, info.Name, item.Name)) // { // isEixst = true; // ComparePlatformAndTKPrice(info, item, toFileName); // } // } // res.ShopAllItems.Add(key, info); // saveInfos.Add(key, info); // } // else if (res.ShopAllItems[key].ShopSelaPrice > info.ShopSelaPrice) // { // if (item.ID == info.ID || (item.Name == info.Name && item.Created == info.Created)) // { // if (IsSameFormat(info.Format, item.Format, info.Name, item.Name)) // { // isEixst = true; // ComparePlatformAndTKPrice(info, item, toFileName); // } // } // res.ShopAllItems[key] = info; // saveInfos[key] = info; // } // } // foreach (BaseItemInfo saveInfo in saveInfos.Values) // { // WriteCSV(fielName, saveInfo); // } //} if (!isEixst) { WriteCSV(toFileName + "/NotEixst" + ticks + ".csv", item); } } }
public void Compare(string pFileName, string sFileName, string createDir, bool isload = false) { ReadPlatFormWebPageValue flatform = new ReadPlatFormWebPageValue(); BaseReadWebPage platform = new BaseReadWebPage(); BaseReadWebPage shop = new BaseReadWebPage(); if (!string.IsNullOrEmpty(pFileName)) { platform.ReadBaseItemInfo(pFileName, true); } shop.ReadBaseItemInfo(sFileName, true); foreach (BaseItemInfo item in shop.ShopAllItems.Values) { bool isEixst = false; string itemName = item.Name; if (item.Name.Contains("】")) { int itemNameIndex = item.Name.LastIndexOf("】") + 1; itemName = item.Name.Substring(itemNameIndex, item.Name.Length - itemNameIndex); } if (itemName.Contains("(")) { int itemNameIndex = itemName.IndexOf('('); itemName = itemName.Substring(0, itemNameIndex); } foreach (BaseItemInfo platformItem in platform.ShopAllItems.Values) { bool isSame = false; if (!string.IsNullOrEmpty(item.ID) && !string.IsNullOrEmpty(platformItem.ID)) { if (item.ID.Trim() == platformItem.ID.Trim()) { isSame = true; } } if (isSame || (itemName == platformItem.Name && item.Created == platformItem.Created)) { if (CommonFun.IsSameFormat(platformItem.Format, item.Format, platformItem.Name, item.Name)) { isEixst = true; if (ComparePrice(platformItem, item)) { break; } } } } if (!isEixst && isload) { List <BaseItemInfo> seachItems = flatform.SeachInfoByID(item.ID); Dictionary <string, BaseItemInfo> saveInfos = new Dictionary <string, BaseItemInfo>(); foreach (BaseItemInfo info in seachItems) { string key = info.Name + info.Format + info.Created; if (!platform.ShopAllItems.ContainsKey(key)) { if (item.ID == info.ID || (itemName == info.Name && item.Created == info.Created)) { if (CommonFun.IsSameFormat(info.Format, item.Format, info.Name, item.Name)) { isEixst = true; ComparePrice(info, item); } } platform.ShopAllItems.Add(key, info); saveInfos.Add(key, info); } else if (platform.ShopAllItems[key].ShopSelaPrice > info.ShopSelaPrice) { if (item.ID == info.ID || (itemName == info.Name && item.Created == info.Created)) { if (CommonFun.IsSameFormat(info.Format, item.Format, info.Name, item.Name)) { isEixst = true; ComparePrice(info, item); } } platform.ShopAllItems[key] = info; saveInfos[key] = info; } } foreach (BaseItemInfo saveInfo in saveInfos.Values) { string name = string.IsNullOrEmpty(pFileName) ? "Platform/Platform" + ticks + ".csv" : pFileName; CommonFun.WriteCSV(name, saveInfo); } } if (!isEixst) { CommonFun.WriteCSV(createDir + "/NotIsEixst" + ticks + ".csv", item); } } }