Exemple #1
0
 public void SetReportMsgIdState(string msgid, string state)
 {
     try
     {
         if (msgid.Equals(SaveReportMsgId))
         {
             SaveReportState = state;
         }
         if (ReportMsgIdLst != null)
         {
             foreach (ReportMsgidStatus rms in ReportMsgIdLst)
             {
                 if (rms.Msgid.Equals(msgid))
                 {
                     rms.ReportState = state;
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         SMSLog.Error("SmsModel=>SetReportMsgIdState Exception:" + ex.Message);
     }
 }
Exemple #2
0
 public object Get(object key)
 {
     try
     {
         if (_cachedic.ContainsKey(key))
         {
             TimeoutCacheObject tco = (TimeoutCacheObject)_cachedic[key];
             if (tco != null)
             {
                 TimeSpan ts = DateTime.Now - tco.Timestamp;
                 if (ts.TotalSeconds > _totalSeconds)
                 {
                     object movobj = null;
                     _cachedic.TryRemove(key, out movobj);
                     return(tco.Obj);
                 }
                 else
                 {
                     return(tco.Obj);
                 }
             }
             else
             {
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         SMSLog.Debug("TimeoutCache:Get=>读取存数据异常:" + ex.Message);
     }
     return(null);
 }
Exemple #3
0
        public static string ClearSign(string str)
        {
            string re = str;

            try
            {
                int iStart = -1;
                int iEnd   = -1;
                iStart = str.IndexOf("【");
                iEnd   = str.IndexOf("】");
                if (iStart == 0 && iEnd > iStart)
                {
                    re = str.Substring(iEnd + 1); //去签名
                }
                iStart = re.LastIndexOf("【");
                iEnd   = re.LastIndexOf("】");
                if (iEnd == re.Length - 1 && iStart < iEnd)
                {
                    re = re.Substring(0, iStart); //去签名
                }
            }
            catch (Exception ex)
            {
                SMSLog.Debug("COMMON.ClearSign==>Exception:" + ex.Message);
            }

            return(re);
        }
Exemple #4
0
 public static void SendSMS(string msg)
 {
     try
     {
         HttpHelper hh  = new HttpHelper();
         string     url = "http://121.40.143.163:6666/sms.aspx?action=send&userid=71&account=szjiaying0515&password=szjiaying0515&mobile=15820455385,18988776279,18926046543,13682488577&content=" + hh.UrlEncoderUTF8(msg);
         string     re  = hh.Get(url, "GBK");
         SMSLog.Debug("SendSMS==>re=" + re + ",url=" + url);
     }
     catch (Exception)
     {
     }
 }
Exemple #5
0
 public void Del(object key)
 {
     try
     {
         //lock (_cachedic)
         // {
         if (_cachedic.ContainsKey(key))
         {
             object obj;
             _cachedic.TryRemove(key, out obj);
         }
         // }
     }
     catch (Exception ex)
     {
         SMSLog.Error("TimeoutCache:Add=>添加缓存数据异常:" + ex.Message);
     }
 }
Exemple #6
0
 public void Add(object key, object obj)
 {
     try
     {
         //lock (_cachedic)
         // {
         if (!_cachedic.ContainsKey(key))
         {
             TimeoutCacheObject tco = new TimeoutCacheObject(obj, DateTime.Now);
             _cachedic.TryAdd(key, tco);
         }
         // }
     }
     catch (Exception ex)
     {
         SMSLog.Error("TimeoutCache:Add=>添加缓存数据异常:" + ex.Message);
     }
 }
Exemple #7
0
        private void TCallback2(object obj)
        {
            SMSLog.Debug("TimeoutCache=====TCallback2======>开始清除缓存数据:" + DateTime.Now);

            try
            {
                int      c    = _cachedic.Keys.Count;
                object[] keys = new object[c];
                object[] vals = new object[c];
                _cachedic.Keys.CopyTo(keys, 0);
                _cachedic.Values.CopyTo(vals, 0);
                for (int i = 0; i < vals.Length; i++)
                {
                    try
                    {
                        TimeoutCacheObject tco = vals[i] as TimeoutCacheObject;
                        if (tco != null)
                        {
                            TimeSpan ts = DateTime.Now - tco.Timestamp;
                            if (ts.TotalSeconds > _totalSeconds)
                            {
                                if (_cachedic.ContainsKey(keys[i]))
                                {
                                    object movobj = null;
                                    _cachedic.TryRemove(keys[i], out movobj);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SMSLog.Error("TimeoutCache=TCallback2=>删除缓存数据异常:" + ex.Message);
                    }
                }
            }
            catch (Exception e)
            {
                SMSLog.Error("TimeoutCache=TCallback2=>删除缓存数据异常:" + e.Message);
            }

            SMSLog.Debug("TimeoutCache=====TCallback2======>结束清除缓存数据:" + DateTime.Now);
        }
Exemple #8
0
        /// <summary>
        /// 后置签名变签名前置
        /// </summary>
        /// <param name="str">内容</param>
        /// <returns></returns>
        public static string SignBefore(string str)
        {
            string re = str;

            try
            {
                int iStart = -1;
                int iEnd   = -1;
                iStart = str.LastIndexOf("【");
                iEnd   = str.LastIndexOf("】");
                re     = str.Substring(0, iStart);                        //去签名
                string sign = str.Substring(iStart, (iEnd - iStart) + 1); //签名
                re = sign + re;
            }
            catch (Exception ex)
            {
                SMSLog.Debug("COMMON.SignBefore==>Exception:" + ex.Message);
            }
            return(re);
        }
Exemple #9
0
        /// <summary>
        /// 前置签名变后置
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string SignAfter(string str)
        {
            string re = str;

            try
            {
                int iStart = -1;
                int iEnd   = -1;
                iStart = str.IndexOf("【");
                iEnd   = str.IndexOf("】");
                re     = str.Substring(iEnd + 1);         //去签名
                string sign = str.Substring(0, iEnd + 1); //签名
                re = re + sign;
            }
            catch (Exception ex)
            {
                SMSLog.Debug("COMMON.SignAfter==>Exception:" + ex.Message);
            }
            return(re);
        }
Exemple #10
0
 private void TCallback(object obj)
 {
     try
     {
         SMSLog.Debug("TimeoutCache===========>开始清除缓存数据:" + DateTime.Now);
         IDictionary <object, object> tcachedic = new Dictionary <object, object>();
         tcachedic = _cachedic;
         if (tcachedic != null)
         {
             foreach (object key in tcachedic.Keys)
             {
                 try
                 {
                     TimeoutCacheObject tco = (TimeoutCacheObject)tcachedic[key];
                     TimeSpan           ts  = DateTime.Now - tco.Timestamp;
                     if (ts.TotalSeconds > _totalSeconds)
                     {
                         if (_cachedic.ContainsKey(key))
                         {
                             object movobj = null;
                             _cachedic.TryRemove(key, out movobj);
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     SMSLog.Error("TimeoutCache==>删除缓存数据异常:" + ex.Message);
                 }
             }
             tcachedic.Clear();
         }
         SMSLog.Debug("TimeoutCache===========>结束清除缓存数据:" + DateTime.Now);
     }
     catch (Exception ex)
     {
         SMSLog.Error("TimeoutCache==>清除缓存数据异常:" + ex.Message);
     }
 }