示例#1
0
        private int AddPersonToList(string personid, QDChatLine chatline, direction direction)
        {
            int personindex = INDEXNOTFOUND;

            personindex = List.FindIndex(x => personid == x.id);
            if (personindex == INDEXNOTFOUND)       //new name ID added, it was not found in the list
            {
                QDChatPerson newperson = new QDChatPerson();
                newperson.id              = personid;
                newperson.name            = personid;
                newperson.count           = 1;
                newperson.firstAppearance = chatline.timestamp;
                newperson.lastAppearance  = newperson.firstAppearance;
                newperson.numberOfLines   = chatline.NumberOfLines;
                List.Add(newperson);
            }
            else
            {
                List[personindex].count++;
                if (List[personindex].firstAppearance > chatline.timestamp)
                {
                    List[personindex].firstAppearance = chatline.timestamp;
                }
                if (List[personindex].lastAppearance < chatline.timestamp)
                {
                    List[personindex].lastAppearance = chatline.timestamp;
                }
                List[personindex].numberOfLines += chatline.NumberOfLines;
            }
            return(personindex);
        }
示例#2
0
        public int ReadChat(List <QDChatLine> qdchatlist)
        {
            string        sql     = "select ZSENTDATE, ZTO, ZFROM, ZTEXT from ZQFMESSAGE";
            SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);

            try
            {
                SQLiteDataReader reader = command.ExecuteReader();
                Console.WriteLine("start");
                qdchatlist.Clear();
                this._entries = 0;
                while (reader.Read())
                {
                    QDChatLine chatentry = new QDChatLine();
                    chatentry.senderid   = reader["ZFROM"].ToString();
                    chatentry.receiverid = reader["ZTO"].ToString();
                    chatentry.chattext   = reader["ZTEXT"].ToString();
                    chatentry.timeoffset = reader.GetDouble(0);
                    chatentry.ConvertRawField();
                    qdchatlist.Add(chatentry);
                    this._entries++;

                    //               Console.WriteLine(" " + _entries + "date:" + chatentry.timestamp + "\tfrom: " + chatentry.sendername + "\t" + chatentry.chattext);
                }
                Console.WriteLine("sortieren anfang");
                qdchatlist.Sort(new QDChatComparer());
                Console.WriteLine("sortieren fertig");
                return(0);
            }
            catch (Exception)
            {
                qdchatlist.Clear();
            }
            return(-1);
        }