108 lines
3.4 KiB
C#
108 lines
3.4 KiB
C#
/**
|
|
* 精准裂变
|
|
* 肖俊
|
|
* 2018-3-13
|
|
*/
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
using AllBase;
|
|
using Work.Api;
|
|
using Work.CollectClass;
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace Work
|
|
{
|
|
public class IdFessionTaobao
|
|
{
|
|
public static List<ProductUploadBase> UploadList = new List<ProductUploadBase>();
|
|
public static List<ProductCollectBase> ProductTemp = new List<ProductCollectBase>();
|
|
public static List<ProductCollectBase> ProductAllTemp = new List<ProductCollectBase>();
|
|
public string Name, FileName = "temp/taobao.tjm";
|
|
public static bool Running = false, GroupUp = false, NeedSave = false;
|
|
public static int ThreadCount = 2, ShopCut = 0, SingleShopIdCount = 1;
|
|
public static Dictionary<string, int> ShopAndProductId = new Dictionary<string, int>();
|
|
public static ConcurrentQueue<SaveServerParm> ConcurrentQueueHtmlSaveServer = new ConcurrentQueue<SaveServerParm>();
|
|
public static ConcurrentQueue<TaobaoMobileCollect> ConcurrentQueueHtmlCollectioneServer = new ConcurrentQueue<TaobaoMobileCollect>();
|
|
public IdFessionTaobao(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 存储到服务器
|
|
/// </summary>
|
|
public static void SaveHtmlToSereve()
|
|
{
|
|
try
|
|
{
|
|
while (true)
|
|
{
|
|
int AgainCount = 0;
|
|
if (ConcurrentQueueHtmlSaveServer.Count > 0)
|
|
{
|
|
SaveServerParm ssp = null;
|
|
if (!ConcurrentQueueHtmlSaveServer.TryDequeue(out ssp))
|
|
{
|
|
continue;
|
|
}
|
|
Again:
|
|
bool bo = ServerTemp.Set(ssp.SaveType, ssp.ProuctId, ssp.SaveHtml);
|
|
if (bo == false)
|
|
{
|
|
AgainCount++;
|
|
if (AgainCount >= 3)//重试第三次直接跳出
|
|
{
|
|
continue;
|
|
}
|
|
Thread.Sleep(new Random().Next(5000, 10000));
|
|
goto Again;
|
|
}
|
|
AgainCount = 0;
|
|
}
|
|
Thread.Sleep(50);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogSave.Add("SaveHtmlToSereve " + ex.ToString());
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class ProductUploadBase
|
|
{
|
|
public long id = 0;
|
|
public string url = "";
|
|
//1:淘宝 2:拼多多 3:阿里巴巴
|
|
public int site_id = 0;
|
|
public int count = 0;
|
|
public int deleteMainImg = 0;
|
|
public string main_keyword = "";
|
|
public string name = "";
|
|
public string image = "";
|
|
public string desc_keyword = "";
|
|
public string shop_name = "";
|
|
}
|
|
public class SaveServerParm
|
|
{
|
|
/// <summary>
|
|
/// 2 拼多多或淘宝 3 阿里巴巴
|
|
/// </summary>
|
|
public int SaveType { get; set; }
|
|
//Id
|
|
public string ProuctId { get; set; }
|
|
/// <summary>
|
|
/// html
|
|
/// </summary>
|
|
public string SaveHtml { get; set; }
|
|
}
|
|
}
|