Пример #1
0
        public void SaveGroupChat(ChatMessage chat)
        {
            string group = chat.Target;

            if (!Cache.TryGetValue(new KXTUCCacheKey(group, ""), out KXTUCCacheFile value))
            {
                // Cann`t find opened file object
                try
                {
                    value = new KXTUCCacheFile(RootDirectory + "\\Groups\\" + group + ".kxtchat", Notify, KXTUCCacheFile.GroupType);;
                }
                catch
                {
                    return;
                }
                if (!Cache.TryAdd(new KXTUCCacheKey(group, ""), value))
                {
                    return;
                }
            }
            try
            {
                value.Save(chat);
            }
            catch
            {
                Cache.TryRemove(new KXTUCCacheKey(group, ""), out _);
            }
        }
Пример #2
0
 public ChatPackage[] ReadGroupChat(string group, Guid request_id)
 {
     if (!Cache.TryGetValue(new KXTUCCacheKey(group, ""), out KXTUCCacheFile value))
     {
         // Cann`t find opened file object
         if (!DBReader.GetRelation(group, "", out string relation_id))
         {
             return(null);
         }
         try
         {
             value = new KXTUCCacheFile(RootDirectory + "\\Groups\\" + relation_id + ".kxtchat", Notify);
         }
         catch
         {
             return(null);
         }
         if (!Cache.TryAdd(new KXTUCCacheKey(group, ""), value))
         {
             return(null);
         }
     }
     try
     {
         value.Read(request_id, out ChatPackage[] packages);
         return(packages);
     }
     catch
     {
         Cache.TryRemove(new KXTUCCacheKey(group, ""), out _);
         return(null);
     }
 }
Пример #3
0
 public void SaveFriendChat(ChatMessage chat)
 {
     if (!Cache.TryGetValue(new KXTUCCacheKey(chat.Sender, chat.Target), out KXTUCCacheFile value))
     {
         // Cann`t find opened file object
         if (!DBReader.GetRelation(chat.Sender, chat.Target, out string relation_id))
         {
             return;
         }
         try
         {
             value = new KXTUCCacheFile(RootDirectory + "\\Relations\\" + relation_id + ".kxtchat", Notify);
         }
         catch
         {
             return;
         }
         if (!Cache.TryAdd(new KXTUCCacheKey(chat.Sender, chat.Target), value))
         {
             return;
         }
     }
     try
     {
         value.Save(chat);
     }
     catch
     {
         Cache.TryRemove(new KXTUCCacheKey(chat.Sender, chat.Target), out _);
     }
 }