Beispiel #1
0
        public async Task DeleteExpiredMsgs(long id, MsgTypes msgType)
        {
            string key         = KeyGenHelper.GenUserKey(id, "MsgIds", msgType.ToString());
            var    deletedKeys = await _redis.DeleteZsetReturnValueRangeAsync
                                     (key, 0, (DateTime.Now - TimeSpan.FromDays(30)).ToTimeStamp());

            await _redis.DeleteHashValuesAsync(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString()), deletedKeys);
        }
Beispiel #2
0
        public string GetMessage(MsgTypes type)
        {
            switch (type)
            {
            case (MsgTypes.GenericError):
                return("We just encountered an error while processing your request. We've notified the support team about this. Please try again later.");

            default:
                return(type.ToString());
            }
        }
 public static ViewResult ViewMessage(this Controller controller, string msg, MsgTypes type)
 {
     controller.TempData[type.ToString()] = msg;
     return(controller.View());
 }
        internal void initialize(Connection connection)
        {
            this.connection          = connection;
            connection.DroppedEvent += onConnectionDropped;
            connection.setHeaderReceivedCallback(onHeaderReceived);

            IDictionary dict = new Hashtable();

            dict["service"]    = name;
            dict["md5sum"]     = IRosService.generate((SrvTypes)Enum.Parse(typeof(SrvTypes), RequestType.ToString().Replace("__Request", "").Replace("__Response", ""))).MD5Sum();
            dict["callerid"]   = this_node.Name;
            dict["persistent"] = persistent ? "1" : "0";
            if (header_values != null)
            {
                foreach (object o in header_values.Keys)
                {
                    dict[o] = header_values[o];
                }
            }
            connection.writeHeader(dict, onHeaderWritten);
        }
Beispiel #5
0
        public async Task DeleteMsg(long id, MsgTypes msgType, string msgId)
        {
            await _redis.DeleteHashValueAsync(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString()), msgId);

            await _redis.DeleteZsetValueAsync(KeyGenHelper.GenUserKey(id, "MsgIds", msgType.ToString()), msgId);
        }
Beispiel #6
0
 public Task <Dictionary <string, UserMsgInfo> > GetAllMsg(long id, MsgTypes msgType)
 {
     return(_redis.GetHashAllAsync <string, UserMsgInfo>(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString())));
 }
Beispiel #7
0
 public Task SetMsgInfo(long id, MsgTypes msgType, UserMsgInfo info)
 {
     return(_redis.AddHashValueAsync(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString()), info.MsgId, info));
 }
Beispiel #8
0
 public Task AddMsgInfo(long id, MsgTypes msgType, UserMsgInfo info)
 {
     return(Task.WhenAll(_redis.AddZsetValueAsync(KeyGenHelper.GenUserKey(id, "MsgIds", msgType.ToString()),
                                                  info.MsgId, DateTime.Now.ToTimeStamp(), TimeSpan.FromDays(30)),
                         _redis.AddHashValueAsync(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString()),
                                                  info.MsgId, info, TimeSpan.FromDays(30)), DeleteExpiredMsgs(id, msgType)));
 }
Beispiel #9
0
 public Task <UserMsgInfo> GetMsgInfo(long id, MsgTypes msgType, string msgId)
 {
     return(_redis.GetHashValueAsync <UserMsgInfo>(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString()), msgId));
 }
Beispiel #10
0
 public Task <List <string> > GetAllMsgIds(long id, MsgTypes msgType)
 {
     return(_redis.GetZsetAllKeyAsync(KeyGenHelper.GenUserKey(id, "MsgIds", msgType.ToString())));
 }