예제 #1
0
        public void SendMessage(MessageDTO messageDTO)
        {
            Message message = Convertation.ToMessageDAL(messageDTO);

            message.Sender = Convertation.ToUserDAL(messageDTO.Sender);
            _service.SendMesage(message);
        }
예제 #2
0
 public virtual void UpdateConvertation(Convertation _item)
 {
     if (_item == null)
     {
         throw new ArgumentNullException("Convertation");
     }
     _convertationRepository.Update(_item);
 }
        static void Main(string[] args)
        {
            Convertation convertationObj = new Convertation();
            PathFinder   pathFinderObj   = new PathFinder();

            bool loopIsActive = true;

            Console.WriteLine("Hello, this program was created to find maximum sums of path from top to bottom of the two triangles");
            Console.WriteLine("Please, choose a triangle for which you want to find the maximum sum of the path. \n");

            do
            {
                Console.WriteLine("Press 1 to choose 'simple_triangle'.");
                Console.WriteLine("Press 2 to choose 'triangle'.");
                Console.WriteLine("Press 0 to exit.\n");

                switch (Console.ReadKey().KeyChar)
                {
                case '1':
                {
                    Console.WriteLine("\n");
                    int result = pathFinderObj.MaxSumPathToEnd(convertationObj.ConvertFileToJaggedArray("simple_triangle"));
                    Console.WriteLine("Maximum sum of path for 'simple_triangle' is: " + result + "\n");
                    Console.WriteLine("Thank you for your time, good luck! \nPress any key to exit");
                    Console.ReadKey();
                    loopIsActive = false;
                    break;
                }

                case '2':
                {
                    Console.WriteLine("\n");
                    int result = pathFinderObj.MaxSumPathToEnd(convertationObj.ConvertFileToJaggedArray("triangle"));
                    Console.WriteLine("\nMaximum sum of path for 'triangle' is: " + result + "\n");
                    Console.WriteLine("Thank you for your time, good luck! \nPress any key to exit");
                    Console.ReadKey();
                    loopIsActive = false;
                    break;
                }

                case '0':
                {
                    Console.WriteLine("\n");
                    Console.WriteLine("Thank you for your time, good luck!");
                    System.Threading.Thread.Sleep(3000);
                    loopIsActive = false;
                    break;
                }

                default:
                {
                    Console.WriteLine("\n");
                    Console.WriteLine("Sorry but you entered wrong data, please try again\n");
                    break;
                }
                }
            }while (loopIsActive);
        }
예제 #4
0
        /// <summary>
        /// Compares lhs and rhs.
        /// </summary>
        /// <param name="lhs">The LHS.</param>
        /// <param name="rhs">The RHS.</param>
        public int Compare(int lhs, int rhs)
        {
            int lhsCount = CountingTheNumberOfCharactersInTheString.Counting(
                Convertation.ConvertationIntToAnother(lhs, NumberSystem), CharSymbol);
            int rhsCount = CountingTheNumberOfCharactersInTheString.Counting(
                Convertation.ConvertationIntToAnother(rhs, NumberSystem), CharSymbol);

            return(lhsCount - rhsCount);
        }
예제 #5
0
        public ActionResult WindowsChat(string messger)
        {
            if (!string.IsNullOrWhiteSpace(messger))
            {
                //var sessioncustomer = _workContext.CurrentCustomer.Id;
                var msg = new Messenger();
                msg.Text     = messger;
                msg.TimeSent = DateTime.Now;
                msg.IsAgents = false;
                msg.IsView   = false;
                if (Session["convertation"] == null)
                {
                    var conver = new Convertation();
                    conver.NgayTao             = DateTime.Now;
                    Session["convertation"]    = Guid.NewGuid();
                    conver.SessionConvertation = Session["convertation"].ToString();
                    if (_workContext.CurrentCustomer.IsRegistered())
                    {
                        conver.CustomerId = _workContext.CurrentCustomer.Id;
                    }

                    _chatService.InsertConvertation(conver);
                    msg.ConvertationId = conver.Id;
                }
                else
                {
                    var _convertation = _chatService.GetConvertationBySessionCustomer(Session["convertation"].ToString());
                    if (_convertation == null)
                    {
                        var conver = new Convertation();
                        conver.NgayTao             = DateTime.Now;
                        Session["convertation"]    = Guid.NewGuid();
                        conver.SessionConvertation = Session["convertation"].ToString();
                        if (_workContext.CurrentCustomer.IsRegistered())
                        {
                            conver.CustomerId = _workContext.CurrentCustomer.Id;
                        }
                        _chatService.InsertConvertation(conver);
                        msg.ConvertationId = conver.Id;
                    }
                    else
                    {
                        msg.ConvertationId = _convertation.Id;
                    }
                }


                _chatService.InsertMessenger(msg);
                return(Json("ok"));
            }
            return(Json("rong"));
        }
예제 #6
0
 public void ReceiveMessage(Message message)
 {
     if (CourentUser.ParticipantDTO.Select(p => p.RoomDTO.Id == message.Room.Id).Any()) // переробить умову
     {
         i++;
         MessageDTO messageDTO = Convertation.ToMessageDTO(message);
         messageDTO.Sender = Convertation.ToUserDTO(message.Sender);
         Messages.Add(messageDTO);
         //Messages.RemoveAt(0);
     }
     else
     {
         i = 50;
     }
 }
예제 #7
0
        private bool SetHeightToGain_IfConflict(KeyValuePair <int, Point3D> umvFutureLocation,
                                                Rectangle restrZone, Point3D planePoint)
        {
            var umv      = field.Aircrafts[AircraftType.Umv][umvFutureLocation.Key];
            var minDistX = Math.Min(Math.Abs(umvFutureLocation.Value.X - restrZone.Left),
                                    Math.Abs(umvFutureLocation.Value.X - restrZone.Right));

            if (restrZone.Contains(new Point(umvFutureLocation.Value.X, umvFutureLocation.Value.Y)))
            {
                umv.SetHeightToGain(AircraftOptions.UmvTracksGainHeight[umv.TrackId]);
                return(true);
            }
            if (Convertation.ConvertPixelsToMeters(
                    GetDistanceBetween(umvFutureLocation.Value, planePoint)) < AircraftOptions.ConflictDistance)
            {
                umv.SetHeightToGain(AircraftOptions.UmvTracksGainHeight[umv.TrackId]);
                return(true);
            }
            return(false);
        }
예제 #8
0
 public void ReceiveUser(User userDAL)
 {
     if (userDAL != null)
     {
         CourentUser = Convertation.ToUserDTO(userDAL);
         CourentUser.ParticipantDTO = new List <ParticipantDTO>();
         foreach (var item in userDAL.Participant)
         {
             CourentUser.ParticipantDTO.Add(Convertation.ToParticipantDTO(item));
             CourentUser.ParticipantDTO.Last().RoomDTO = Convertation.ToRoomDTO(item.Room);
             CourentUser.ParticipantDTO.Last().RoomDTO.Messages = new List <MessageDTO>();
             foreach (var item2 in item.Room.Messages)
             {
                 CourentUser.ParticipantDTO.Last().RoomDTO.Messages.Add(Convertation.ToMessageDTO(item2));
                 CourentUser.ParticipantDTO.Last().RoomDTO.Messages.Last().Sender = Convertation.ToUserDTO(item2.Sender);
             }
         }
         ;
     }
     else
     {
         CourentUser = null;
     }
 }
예제 #9
0
 public bool AddUser(UserDTO user)
 {
     return(_service.AddUser(Convertation.ToUserDAL(user)));
 }
예제 #10
0
 public string Convertation_Int(int digit, int numberSystem)
 => Convertation.ConvertationIntToAnother(digit, numberSystem);