示例#1
0
        internal Participant_Id FindSelfParticapantId()
        {
            foreach (var conv in this.conversations)
            {
                Participant_Id selfId = conv?.conversation?.conversation?.self_conversation_state?.self_read_state?.participant_id;
                if (selfId.chat_id != null || selfId.gaia_id != null)
                {
                    return(selfId);
                }
            }

            return(null);
        }
示例#2
0
        private void GenerateConversationHTML(DirectoryInfo convDir, Conversation conv, IList <Current_Participant> otherParticipants,
                                              Dictionary <string, string> otherParticipantNamesAndIds, Participant_Id selfId, string selfName)
        {
            var sortedChatEvents = conv.events.ToList();

            sortedChatEvents.Sort();
            sortedChatEvents.Reverse();
            Console.WriteLine("");

            foreach (var chatEvent in sortedChatEvents)
            {
                DateTime eventDateTime = chatEvent.DateTime;
                bool     senderIsSelf  = false;

                var senderId   = chatEvent.sender_id.chat_id ?? chatEvent.sender_id.gaia_id;
                var senderName = string.Empty;
                if (selfId.chat_id == senderId || selfId.gaia_id == senderId)
                {
                    senderName   = selfName;
                    senderIsSelf = true;
                }
                else
                {
                    if (senderId != null && otherParticipantNamesAndIds.ContainsKey(senderId))
                    {
                        senderName = otherParticipantNamesAndIds[senderId] ?? senderId;
                    }
                    else
                    {
                        senderName = senderId;
                    }
                }

                if (chatEvent?.chat_message?.message_content?.segment != null && (chatEvent?.chat_message?.message_content?.segment.Length > 0))
                {
                    foreach (var segment in chatEvent?.chat_message?.message_content?.segment)
                    {
                        var fileName     = $"{eventDateTime.ToString("yyyy-MM")}.html";
                        var fullFilePath = $"{convDir}{Path.DirectorySeparatorChar}{fileName}";
                        if (segment?.type?.ToUpper() == "TEXT")
                        {
                            AppendToFile(fullFilePath, eventDateTime, segment.text, senderName, senderIsSelf);
                        }
                        else if (segment?.type?.ToUpper() == "LINK")
                        {
                            var html = $"<a href=\"{segment.text}\">Link</a>";
                            AppendToFile(fullFilePath, eventDateTime, html, senderName, senderIsSelf);
                        }
                        else if (segment?.type?.ToUpper() == "LINE_BREAK")
                        {
                            //TODO: segment?.type?.ToUpper() == "LINE_BREAK"
                            int i = 0;
                        }
                        else
                        {
                            int i = 0;
                        }
                    }
                }

                if (chatEvent?.chat_message?.message_content?.attachment != null && (chatEvent?.chat_message?.message_content?.attachment.Length > 0))
                {
                    foreach (var attachment in chatEvent?.chat_message?.message_content?.attachment)
                    {
                        var fileName     = $"{eventDateTime.ToString("yyyy-MM")}.html";
                        var fullFilePath = $"{convDir}{Path.DirectorySeparatorChar}{fileName}";
                        if (attachment?.embed_item?.type != null && attachment.embed_item.type.Length > 0 && attachment.embed_item.type[0].ToUpper() == "PLUS_PHOTO")
                        {
                            if (attachment?.embed_item?.plus_photo != null)
                            {
                                AppendToFile(fullFilePath, eventDateTime, attachment.embed_item.plus_photo, senderName, senderIsSelf);
                            }
                        }
                        else
                        {
                            int i = 0;
                        }
                    }
                }
            }
        }