private void AddNewPinsListofAddNewBoardWithNewPin(List <string> Messages) { try { ClGlobul.lstListOfNewUsers.Clear(); Dispatcher.Invoke((Action) delegate { foreach (string Message in Messages) { string NewMessages = Message.Replace("\0", "").Trim(); string[] arMessages = Regex.Split(NewMessages, ","); BaseLib.Pins pin = new BaseLib.Pins(); if (arMessages.Count() == 1) { pin.ImageUrl = arMessages[0]; } else if (arMessages.Count() == 2) { pin.ImageUrl = arMessages[0]; pin.Description = arMessages[1]; } else if (arMessages.Count() == 3) { pin.Board = arMessages[0]; pin.Description = arMessages[1]; pin.ImageUrl = (arMessages[2]).Trim(); } else if (arMessages.Count() == 4) { pin.Board = arMessages[0]; pin.Description = arMessages[1]; pin.ImageUrl = (arMessages[2]).Trim(); pin.Niche = (arMessages[3]).Trim(); } if (!string.IsNullOrEmpty(pin.ImageUrl)) { ClGlobul.lst_AddnewPinWithNewBoard.Add(pin); } } }); } catch (Exception ex) { GlobusLogHelper.log.Info("Error :" + ex.StackTrace); } }
private void AddNewPinsList(List<string> Messages) { try { ClGlobul.lstListOfNewUsers.Clear(); foreach (string Message in Messages) { string NewMessages = Message.Replace("\0", "").Trim(); string[] arMessages = Regex.Split(NewMessages, ","); BaseLib.Pins pin = new BaseLib.Pins(); if (arMessages.Count() == 1) { pin.ImageUrl = arMessages[0]; } else if (arMessages.Count() == 2) { pin.ImageUrl = arMessages[0]; pin.Description = arMessages[1]; } else if (arMessages.Count() == 3) { pin.ImageUrl = arMessages[0]; pin.Description = arMessages[1]; pin.Board = arMessages[2]; } else if (arMessages.Count() == 4) { pin.ImageUrl = arMessages[0]; pin.Description = arMessages[1]; pin.Board = arMessages[2]; pin.Email = arMessages[3]; } if (!string.IsNullOrEmpty(pin.ImageUrl)) { ClGlobul.lstListOfPins.Add(pin); } } } catch (Exception ex) { Console.Write (ex.Message); } }
public void ThreadRepinMethod(Pins pin, PinInterestUser objPinUser) { try { try { lstThreadsAddPinWithNewBoard.Add(Thread.CurrentThread); lstThreadsAddPinWithNewBoard.Distinct().ToList(); Thread.CurrentThread.IsBackground = true; } catch (Exception ex) { }; Board = Regex.Split(pin.Board, ":")[0]; if (!string.IsNullOrEmpty(Board)) { //Board = pin.Board; BoardNumber = objAddNewPinManager.GetBoardId(Board, ref objPinUser); if (string.IsNullOrEmpty(BoardNumber)) { GlobusLogHelper.log.Info(" => [ " + Board + " Not Found. Creating Board ]"); BoardNumber = CreateBoard_new(Board, "Other", ref objPinUser); BoardNumber = objAddNewPinManager.GetBoardId(Board, ref objPinUser); } } else { if (objPinUser.Boards.Count <= 0) { objAddNewPinManager.GetBoards(ref objPinUser); } if (objPinUser.Boards.Count > 0) { Random Boardrnd = new Random(); int BoardNum = 0; try { BoardNum = Boardrnd.Next(0, objPinUser.Boards.Count - 1); BoardNumber = objPinUser.Boards[BoardNum]; } catch (Exception ex) { //GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartNewPinCreationMultiThreaded() 1--> " + ex.Message, ApplicationData.ErrorLogFile); } } } ImageUrl = pin.ImageUrl; Desc = pin.Description; string Data = objAddNewPinManager.NewPin(BoardNumber, Desc, ImageUrl, ref objPinUser); if (Data.Equals("true")) { #region AccountReport string module = "AddPinWithNewBoard"; string status = "Added"; objqm.insertAccRePort(objPinUser.Username, module, "", Board, "", Desc, "", ImageUrl, status, "", "", DateTime.Now); objAddPinWithBoardDelegate(); #endregion //GlobusLogHelper.log.Info(" => [ Pin Added To " + Board + " From " + objPinUser.Username + " ]"); try { string CSV_Header = "Date" + "," + "UserName" + "," + "Board" + "," + "Description" + "," + "ImageUrl"; string CSV_Data = System.DateTime.Now.ToString() + "," + objPinUser.Username + "," + Board.Replace(",", " ").Replace("'", "") + "," + Desc.Replace(",", " ").Replace("'", "") + "," + ImageUrl.Replace(",", " ").Replace("'", ""); PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, Pinpath + "\\NewPin.csv"); } catch (Exception ex) { } } else { GlobusLogHelper.log.Info(" => [ Pin Not Added To " + Board + " From " + objPinUser.Username + " ]"); } } catch (Exception ex) { //GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartNewPinCreationMultiThreaded() 2 --> " + ex.Message, ApplicationData.ErrorLogFile); } finally { try { if (countThreadControllerAddPinWithNewBoard > Nothread_AddPinWithNewBoard) { lock (AddPinWithNewBoardObjThread) { Monitor.Pulse(AddPinWithNewBoardObjThread); } AddPinWithNewBoarddata_count--; } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error : " + ex.StackTrace); } countThreadControllerAddPinWithNewBoard--; GlobusLogHelper.log.Info(" => [ PROCESS COMPLETED " + " For " + objPinUser.Username + " ]"); GlobusLogHelper.log.Info("---------------------------------------------------------------------------------------------------------------------------"); } }
public void StartActionMultithreadAddPinWithNewBoard(ref PinInterestUser objPinUser12) { Pins obj = new Pins(); try { PinInterestUser objPinUser = (PinInterestUser)objPinUser12; try { lstThreadsAddPinWithNewBoard.Add(Thread.CurrentThread); lstThreadsAddPinWithNewBoard.Distinct().ToList(); Thread.CurrentThread.IsBackground = true; } catch (Exception ex) { }; //string strPin=string.Empty; //string[] arrPin = null; //foreach (string strPinList in ClGlobul.addNewPinWithBoard) //{ // strPin = strPinList.Replace("\0", "").Trim(); // arrPin = Regex.Split(strPin, ","); // if (arrPin.Count() != 4) // { // GlobusLogHelper.log.Info(" => [ Please upload correct file format ]"); // return; // } //} PinInterestUser objPinUseaddpin = objPinUser; UserPins = ClGlobul.lst_AddnewPinWithNewBoard.FindAll(P => P.Email == objPinUseaddpin.Username).ToList(); //GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Total Pins Count is " + UserPins.Count + " ]"); if (UserPins.Count == 0) { UserPins = ClGlobul.lst_AddnewPinWithNewBoard; } foreach (Pins pin in UserPins) { if (pin.Niche == objPinUser12.Niches) { Thread thread = new Thread(() => ThreadRepinMethod(pin, objPinUser)); thread.Start(); Thread.Sleep(ThreadDelay * 1000); } } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } }
private void AddNewPinsListofAddNewBoardWithNewPin(List<string> Messages) { try { ClGlobul.lstListOfNewUsers.Clear(); Dispatcher.Invoke((Action)delegate { foreach (string Message in Messages) { string NewMessages = Message.Replace("\0", "").Trim(); string[] arMessages = Regex.Split(NewMessages, ","); BaseLib.Pins pin = new BaseLib.Pins(); if (arMessages.Count() == 1) { pin.ImageUrl = arMessages[0]; } else if (arMessages.Count() == 2) { pin.ImageUrl = arMessages[0]; pin.Description = arMessages[1]; } else if (arMessages.Count() == 3) { pin.Board = arMessages[0]; pin.Description = arMessages[1]; pin.ImageUrl = (arMessages[2]).Trim(); } else if (arMessages.Count() == 4) { pin.Board = arMessages[0]; pin.Description = arMessages[1]; pin.ImageUrl = (arMessages[2]).Trim(); pin.Niche = (arMessages[3]).Trim(); } if (!string.IsNullOrEmpty(pin.ImageUrl)) { ClGlobul.lst_AddnewPinWithNewBoard.Add(pin); } } }); } catch (Exception ex) { GlobusLogHelper.log.Info("Error :" + ex.StackTrace); } }
public void StartActionMultithreadAddPinWithNewBoard(ref PinInterestUser objPinUser12) { Pins obj = new Pins(); try { PinInterestUser objPinUser = (PinInterestUser)objPinUser12; try { lstThreadsAddPinWithNewBoard.Add(Thread.CurrentThread); lstThreadsAddPinWithNewBoard.Distinct().ToList(); Thread.CurrentThread.IsBackground = true; } catch (Exception ex) { }; PinInterestUser objPinUseaddpin = objPinUser; UserPins = ClGlobul.lst_AddnewPinWithNewBoard.FindAll(P => P.Email == objPinUseaddpin.Username).ToList(); if (UserPins.Count == 0) { UserPins = ClGlobul.lst_AddnewPinWithNewBoard; } foreach (Pins pin in UserPins) { if (pin.Niche == objPinUser12.Niches) { Thread thread = new Thread(() => ThreadRepinMethod(pin, objPinUser)); thread.Start(); Thread.Sleep(ThreadDelay * 1000); } } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } }