예제 #1
0
        public NodePin <T> ChangePinType <T>(NodePin pin)
        {
            NodeEditor.Assertions.IsTrue(Pins.Contains(pin), string.Format("'{0}' does not contains pin '{1}'.", Name, pin.Name));

            if (Pins.Contains(pin))
            {
                var replacementPin = new NodePin <T>(pin.Name, pin.Index, this);
                Pins.Remove(pin);

                // Replace old pin with the new pin at the same index as the old pin.
                var targetList = pin.IsInput ? InputPins : OutputPins;
                targetList.Insert(targetList.IndexOf(pin), replacementPin);
                targetList.Remove(pin);

                Pins.Add(replacementPin);

                NodeEditor.Logger.Log <Node>("Swapped pin '{0}' of type '{1}' for type '{2}'", replacementPin.Name, pin.WrappedType, replacementPin.WrappedType);

                PinChanged.InvokeSafe(new NodePinChangedEvent(pin, replacementPin));

                return(replacementPin);
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Adds a pin
        /// </summary>
        /// <param name="pin">Pin</param>
        public void AddPin(IPin pin)
        {
            if (!Pins.Contains(pin))
            {
                Pins.Add(pin);
//				Pins = Pins.OrderBy (x => x.RealNumber).ThenBy (x => x.Type).ToList ();
                if (OnPinsUpdated != null)
                {
                    OnPinsUpdated.Invoke(this, new ControllerPinUpdateArgs(pin, UpdateOperation.Add));
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Adds a pin range.
 /// </summary>
 /// <param name="pins">Pins</param>
 public void AddPinRange(IPin[] pins)
 {
     for (int i = 0; i < pins.Length; i++)
     {
         if (!Pins.Contains(pins [i]) && pins [i] != null)
         {
             Pins.Add(pins [i]);
         }
     }
     if (OnPinsUpdated != null)
     {
         OnPinsUpdated.Invoke(this, new ControllerPinUpdateArgs(null, UpdateOperation.AddRange));
     }
 }
예제 #4
0
        private async void ShowPin(PinViewViewModel pin)
        {
            var newPin = (await _pinService.GetPinsAsync(App.CurrentUserId)).LastOrDefault(x => x.ID == pin.ID);
            var Pin    = newPin.ToPin();

            MapCameraPosition = new CameraPosition(Pin.Position, 5);
            if (!Pins.Contains(Pin))
            {
                Pins.Add(Pin);
                MessagingCenter.Subscribe <PinModalView>(this, Constants.MessagingCenter.DeletePin, (seconSender) =>
                {
                    Pins.Remove(Pin);
                    MessagingCenter.Unsubscribe <PinModalView>(this, Constants.MessagingCenter.DeletePin);
                });
            }

            await OnPinClickedCommand(Pin);
        }
        public void BoardMethod(string BoardName, string BoardUrl, ref PinInterestUser objPinInUser)
        {
            try
            {
                try
                {
                    lstThreadsBoards.Add(Thread.CurrentThread);
                    lstThreadsBoards.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                { };
                lock (this)
                {
                    string           BoardId      = string.Empty;
                    AddNewPinManager objaddnewPin = new AddNewPinManager();
                    RePinManager     objRepin     = new RePinManager();
                    try
                    {
                        boardinput.Add(Thread.CurrentThread);
                        boardinput.Distinct();
                        Thread.CurrentThread.IsBackground = true;
                    }
                    catch (Exception ex)
                    { };

                    if (string.IsNullOrEmpty(BoardName))
                    {
                        try
                        {
                            List <string> baordnames = GetAllBoardNames_new(ref objPinInUser);
                            BoardName = baordnames[RandomNumberGenerator.GenerateRandom(0, baordnames.Count - 1)];
                            BoardId   = objaddnewPin.GetBoardId(BoardName, ref objPinInUser);
                        }
                        catch (Exception ex)
                        { };
                    }
                    else
                    {
                        //testing

                        GlobusHttpHelper objHttp = new GlobusHttpHelper();

                        try
                        {
                            BoardId = objaddnewPin.GetBoardId_Board(BoardName, ref objPinInUser);
                        }
                        catch (Exception ex)
                        {
                            Console.Write(ex.Message);
                        }
                    }

                    if (string.IsNullOrEmpty(BoardId))
                    {
                        BoardId = objaddnewPin.GetBoardId(BoardName, ref objPinInUser);
                    }

                    int counter      = 0;
                    int RepinCounter = 0;
                    if (!BoardId.Contains("failure"))
                    {
                        if (!string.IsNullOrEmpty(BoardId))
                        {
                            if (PDGlobals.ValidateNumber(BoardId))
                            {
                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Adding Pins From Board :" + BoardUrl + " ]");

                                clsSettingDB  db      = new clsSettingDB();
                                List <string> lstPins = new List <string>();
                                lstPins = GetBoardPinsNew(BoardId, BoardUrl, 10, ref objPinInUser);
                                lstPins.Distinct();
                                List <string> lstOfRepin = new List <string>();
                                lstOfRepin.AddRange(lstPins);

                                string[] lstPinNo = null;
                                lstPinNo = lstPins.ToArray();
                                //getting lstPins length
                                int lenOFlstPins = lstOfRepin.Count;

                                foreach (string Pins in lstPinNo)
                                {
                                    if (MaxRePinCount > RepinCounter)
                                    {
                                        string Message = string.Empty;
                                        if (ClGlobul.lstBoardRepinMessage.Count > 0)
                                        {
                                            if (counter < ClGlobul.lstBoardRepinMessage.Count)
                                            {
                                                Message = ClGlobul.lstBoardRepinMessage[counter];
                                            }
                                            else
                                            {
                                                counter = 0;
                                                Message = ClGlobul.lstBoardRepinMessage[counter];
                                            }
                                        }

                                        bool IsReppined = false;
                                        if (!Pins.Contains("n"))
                                        {
                                            try
                                            {
                                                int index = lstOfRepin.Where(x => x == Pins).Select(x => lstOfRepin.IndexOf(x)).Single <int>();

                                                string NoOfPages = Convert.ToString(index / lenOFlstPins);

                                                IsReppined = objRepin.RepinwithMessage(Pins, Message, BoardId, NoOfPages, ref objPinInUser);
                                            }

                                            catch { }
                                            if (IsReppined)
                                            {
                                                //GlobusLogHelper.log.Info("[ => [ Repin Id : " + Pins + " ]");
                                                #region AccountReport

                                                string module = "Boards";
                                                string status = "Repined";
                                                Qm.insertAccRePort(objPinInUser.Username, module, "https://www.pinterest.com/pin/" + Pins, BoardName, "", "", "", "", status, "", "", DateTime.Now);
                                                objBoardDelegate();

                                                #endregion

                                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Repin Pin : " + Pins + " to Account : " + objPinInUser.Username + " In " + BoardName + " ]");
                                                try
                                                {
                                                    string CSV_Header = "Date" + "," + "UserName" + "," + "Message" + "," + "Pin" + "Board Id";
                                                    string CSV_Data   = System.DateTime.Now.ToString() + "," + objPinInUser.Username + "," + Message + "," + "https://www.pinterest.com/pin/" + Pins + "," + BoardId;

                                                    PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, Boardpath + "\\Board.csv");
                                                    RepinCounter++;
                                                }
                                                catch (Exception ex)
                                                {
                                                    Console.Write(ex.Message);
                                                }

                                                //kept here
                                                int delay = RandomNumberGenerator.GenerateRandom(minDelayBoards, maxDelayBoards);
                                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay for " + delay + " Seconds ]");
                                                Thread.Sleep(delay * 1000);
                                            }
                                            else
                                            {
                                            }

                                            counter++;
                                        }
                                    }
                                    else
                                    {
                                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED " + " For " + objPinInUser.Username + " In " + BoardName + "]");
                                        GlobusLogHelper.log.Info("-----------------------------------------------------------------------------");
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ]  => [ You already have a board with that name. " + objPinInUser.Username + " ]");
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }