public bool Insert_Pin(DataLoad data) { bool result = false; try { MoneyDataContext db = new MoneyDataContext(); Pinterest pin = new Pinterest { Old_Id = data.OldId, Board = data.Board, Backlink = data.Backlink, Note = data.Note, Image_Url = data.Image_Url, Type = data.Type, Is_Pin = 0, Created_Date = DateTime.Now }; db.Pinterests.InsertOnSubmit(pin); db.SubmitChanges(); result = true; } catch (Exception ex) { } return(result); }
public DataLoad ImportDataToDataLoad(Pinterest pinterest, int type) { DataLoad data = new DataLoad(); data.Id = pinterest.Id; data.Backlink = pinterest.Backlink; data.Board = pinterest.Board; data.Image_Url = pinterest.Image_Url; data.Note = pinterest.Note; data.Type = type; return(data); }
private void Parse_Data(dynamic data, string board) { Query query = new Query(); foreach (var pin in data) { var exits = query.Find_Pin_By_Id(pin["id"].ToString()); if (exits == null) { DataLoad load = new DataLoad(); load.OldId = pin["id"].ToString(); load.Board = board; load.Image_Url = pin["image"]["original"]["url"].ToString(); load.Note = pin["note"].ToString(); load.Type = 2; load.Backlink = "https://www.besttshirtusa.com/" + board; query.Insert_Pin(load); } } }
public void PinToPinterest() { Query query = new Query(); var products = query.Get_Type_Image_Is_Not_Pin().ToArray(); var images = query.Get_Type_Image_Is_Not_Pin().ToArray(); List <DataLoad> datas = new List <DataLoad>(); DataLoad call = new DataLoad(); for (int i = 0; i < 980; i++) { if (images.Count() >= i) { datas.Add(call.ImportDataToDataLoad(images[i], 2)); } else if (products.Count() >= i) { datas.Add(call.ImportDataToDataLoad(products[i], 1)); } else { break; } } if (datas != null) { foreach (var data in datas) { PinHub hub = new PinHub(); var jsonPost = hub.Pin(data.Board, data.Note, data.Image_Url, data.Backlink, data.Type); if (jsonPost != null) { JObject jsonObj = new JObject(JObject.Parse(jsonPost)); query.Update_Pin(data.Id, jsonObj["data"]["id"].ToString()); } } } }