Ejemplo n.º 1
0
        public void Register(ParticipantBase participant)
        {
            if (!participants.ContainsValue(participant))
            {
                participants[participant.Name] = participant;
            }

            participant.Chatroom = this;
        }
Ejemplo n.º 2
0
        public void Send(
            string from, string to, string message)
        {
            ParticipantBase participant = participants[to];

            if (participant != null)
            {
                participant.Receive(from, message);
            }
        }
Ejemplo n.º 3
0
        private void PrintParticipant(ParticipantBase aParticipant)
        {
            Console.WriteLine();
            Console.WriteLine(aParticipant.Name);

            // This foreach-loop uses the index operator to look up values in the SpellVector
            //Console.WriteLine("Original values in SpellVector");
            //foreach (SpellType sp in Spell.SpellTypeList.OrderBy(p => p.ToString()))
            //{
            //    Console.WriteLine($"{sp.ToString().PadRight(12)} -->   {aParticipant[sp]:F2}");
            //}

            // This foreach-loop iterates directly over the aParticipant object
            //Console.WriteLine("Modified values in SpellVector");
            //foreach (var pair in aParticipant.OrderBy(p => p.Item1.ToString()))
            //{
            //    Console.WriteLine($"{pair.Item1.ToString().PadRight(12)} -->   {pair.Item2:F2}");
            //}

            Console.WriteLine();
        }
        public Transaction GetById(int id)
        {
            DocumentsService            _documentsService = new DocumentsService();
            Transaction                 t = null;
            Dictionary <int, Milestone> milestoneDictionary = null;
            Dictionary <int, TaskBase>  taskDictionary      = null;
            Dictionary <int, Chat>      chatDictionary      = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Transactions_SelectById"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Id", id);
            }
                                    , map : delegate(IDataReader reader, short set)
            {
                switch (set)
                {
                case 0:
                    t = mapTransaction(reader);
                    break;

                case 1:
                    int transactionId = 0;
                    Milestone m       = MilestonesService.MapMilestone(reader, out transactionId);
                    if (t.Milestones == null)
                    {
                        t.Milestones = new List <Milestone>();
                    }
                    t.Milestones.Add(m);
                    if (milestoneDictionary == null)
                    {
                        milestoneDictionary = new Dictionary <int, Milestone>();
                    }
                    milestoneDictionary.Add(m.Id, m);
                    break;

                case 2:
                    int milestoneId           = 0;
                    TaskBase ta               = TasksService.MapTask(reader, out milestoneId);
                    Milestone parentMilestone = milestoneDictionary[milestoneId];
                    if (parentMilestone.Tasks == null)
                    {
                        parentMilestone.Tasks = new List <TaskBase>();
                    }
                    parentMilestone.Tasks.Add(ta);
                    if (taskDictionary == null)
                    {
                        taskDictionary = new Dictionary <int, TaskBase>();
                    }
                    taskDictionary.Add(ta.Id, ta);
                    break;

                case 3:
                    int taskId          = 0;
                    Document d          = _documentsService.MapDocument(reader, out taskId);
                    TaskBase parentTask = taskDictionary[taskId];
                    if (parentTask.Documents == null)
                    {
                        parentTask.Documents = new List <Document>();
                    }
                    parentTask.Documents.Add(d);
                    break;

                case 4:
                    ParticipantBase pb = _participantsService.MapParticipantBase(reader);
                    if (t.Participants == null)
                    {
                        t.Participants = new List <ParticipantBase>();
                    }
                    t.Participants.Add(pb);
                    break;

                case 5:
                    RoleBase rb = MapRoleBases(reader);
                    if (t.Roles == null)
                    {
                        t.Roles = new List <RoleBase>();
                    }
                    t.Roles.Add(rb);
                    break;

                case 6:
                    PendingDocument pd = PendingDocumentService.MapPendingDocument(reader);
                    if (t.PendingDocuments == null)
                    {
                        t.PendingDocuments = new List <PendingDocument>();
                    }
                    t.PendingDocuments.Add(pd);
                    break;

                case 7:
                    DocumentType dt = DocumentTypesService.MapDocumentType(reader);
                    if (t.DocumentTypes == null)
                    {
                        t.DocumentTypes = new List <DocumentType>();
                    }
                    t.DocumentTypes.Add(dt);
                    break;

                case 8:
                    int chatTaskId = 0;

                    Chat ch = ChatService.ChatMapper(reader, out chatTaskId);
                    TaskBase chatParentTask = taskDictionary[chatTaskId];
                    if (chatParentTask.Chats == null)
                    {
                        chatParentTask.Chats = new List <Chat>();
                    }
                    chatParentTask.Chats.Add(ch);

                    if (chatDictionary == null)
                    {
                        chatDictionary = new Dictionary <int, Chat>();
                    }
                    chatDictionary.Add(ch.Id, ch);
                    break;

                case 9:
                    int chatId = 0;

                    ChatMessage cm  = ChatService.MessageMapper(reader, out chatId);
                    Chat parentChat = chatDictionary[chatId];
                    if (parentChat.Message == null)
                    {
                        parentChat.Message = new List <ChatMessage>();
                    }
                    parentChat.Message.Add(cm);
                    break;

                case 10:
                    TransactionDetails listingDetails = MapTransactionDetails(reader);
                    t.ListingDetails = listingDetails;
                    break;

                case 11:
                    PersonBase buyer = MapBuyer(reader);
                    if (t.Buyers == null)
                    {
                        t.Buyers = new List <PersonBase>();
                    }
                    t.Buyers.Add(buyer);
                    break;

                case 12:
                    ListingAgentInfo listAgent = MapListingAgentInfo(reader);
                    t.ListingAgent             = listAgent;
                    break;
                }
            }
                                    );
            return(t);
        }