public override int GetHashCode() { int hash = 1; if (Tag.Length != 0) { hash ^= Tag.GetHashCode(); } if (senderSettings_ != null) { hash ^= SenderSettings.GetHashCode(); } if (proxySettings_ != null) { hash ^= ProxySettings.GetHashCode(); } if (Expire != 0L) { hash ^= Expire.GetHashCode(); } if (Comment.Length != 0) { hash ^= Comment.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/*****************************************************************************************************************/ /// <summary>Stores the DB cookie.</summary> public void Store() { if (string.IsNullOrEmpty(Session)) { throw new Exception("Empty Session ID"); } if (string.IsNullOrEmpty(Identifier)) { throw new Exception("Empty Identifier"); } if (string.IsNullOrEmpty(Value)) { throw new Exception("Empty value"); } //delete old value if exists Delete(false); string sql = string.Format("INSERT INTO cookie (session, identifier, value, expire, creation_date) VALUES ({0},{1},{2},{3},{4});", StringUtils.EscapeSql(Session), StringUtils.EscapeSql(Identifier), StringUtils.EscapeSql(Value), Expire.Equals(DateTime.MinValue) ? StringUtils.EscapeSql(DateTime.UtcNow.AddDays(1).ToString(@"yyyy\-MM\-dd\THH\:mm\:ss")) : StringUtils.EscapeSql(Expire.ToString(@"yyyy\-MM\-dd\THH\:mm\:ss")), StringUtils.EscapeSql(DateTime.UtcNow.ToString(@"yyyy\-MM\-dd\THH\:mm\:ss")) ); Context.Execute(sql); Console.WriteLine(sql); }
// 设置当前应用程序指定CacheKey的Cache值 public void SetCache(string CacheKey, object objObject, int secondsSpan = 0, Expire expireType = Expire.Defalut) { if (objObject == null) { return; } CacheKey = GetFinalKey(CacheKey); int cueSeconds = secondsSpan > 0 ? secondsSpan : GetExpireTime(expireType); if (cueSeconds < 0) { RemoveCache(CacheKey); } #if NET else if (cueSeconds > 0) { // objCache.Insert(CacheKey, objObject, null, DateTime.MaxValue, TimeSpan.FromSeconds(cueSeconds));//相对过期 objCache.Insert(CacheKey, objObject, null, DateTime.Now.AddSeconds(cueSeconds), TimeSpan.Zero);//绝对过期 } else if (cueSeconds == 0) { objCache.Insert(CacheKey, objObject); } #else if (CacheKey != null) { secondsSpan = secondsSpan == 0 ? Int32.MaxValue : secondsSpan; cache.Set(CacheKey, objObject, new MemoryCacheEntryOptions { AbsoluteExpiration = DateTime.Now.AddSeconds(secondsSpan) }); } #endif }
public int CompareTo(object obj_other) { if (obj_other is CacheItem other) { return(Expire.CompareTo(other.Expire)); } return(1); }
public void DeleteExpire(Expire expire) { if (expire == null) { throw new ArgumentNullException(nameof(expire)); } _context.Expires.Remove(expire); }
public ActionResult DeleteConfirmed(int id) { Expire expire = db.Expires.Find(id); db.Expires.Remove(expire); db.SaveChanges(); return(RedirectToAction("Index")); }
public void CreateExpire(Expire expire) { if (expire == null) { throw new ArgumentNullException(nameof(expire)); } _context.Expires.Add(expire); }
public override String ToString() { return($"Gazda: {Hostname}\n" + $"Cím: {Address}\n" + $"Kutya: {DogName}\n" + $"Chip: {ChipID}\n" + $"Dátum: {Date.ToString("yyyy.MMM.dd.")}\n" + $"Lejár: {Expire.ToString("yyyy.MMM.dd.")}\n" + $"Első oltás: {(First ? "Igen" : "Nem")}"); }
public ActionResult Edit([Bind(Include = "Id,Date,From,To,Every,Name")] Expire expire) { if (ModelState.IsValid) { db.Entry(expire).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(expire)); }
public ActionResult Create([Bind(Include = "Id,Date,From,To,Every,Name")] Expire expire) { if (ModelState.IsValid) { db.Expires.Add(expire); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(expire)); }
/// <summary> /// Two DnsResourceDataStartOfAuthority are equal iff their main name server, responsible mailbox, serial, refresh, retry, expire /// and minimum TTL fields are equal. /// </summary> public bool Equals(DnsResourceDataStartOfAuthority other) { return(other != null && MainNameServer.Equals(other.MainNameServer) && ResponsibleMailbox.Equals(other.ResponsibleMailbox) && Serial.Equals(other.Serial) && Refresh.Equals(other.Refresh) && Retry.Equals(other.Retry) && Expire.Equals(other.Expire) && MinimumTtl.Equals(other.MinimumTtl)); }
public override string ToString() { return(string.Format("primary name server = {0}\nresponsible mail addr = {1}\nserial = {2}\nrefresh = {3}\nretry = {4}\nexpire = {5}\ndefault TTL = {6}", PrimaryNameServer, ResponsibleMailAddress, Serial.ToString(), Refresh.ToString(), Retry.ToString(), Expire.ToString(), DefaultTtl.ToString())); }
public void Set(string key, string value, int expireInSeconds) { Set(key: key, value: Encoding.UTF8.GetBytes(value)); Check.If <ArgumentException>(() => expireInSeconds < 0); using (var command = new Expire(host: _host, port: _port)) { const int perSecond = 1000; command.Execute(key: key, timeInSeconds: expireInSeconds * perSecond); } }
public override string ToString() { if (Key != null && Expire != null) { return($"{ID}, {Key.ToString()}, {Expire.ToString("dd-MMM-yyyy HH:mm:ss.ffff K")}"); } else { return($"{ID}, null, null"); } }
public int CompareTo(CacheItem other) { if (ReferenceEquals(this, other)) { return(0); } if (other is null) { return(1); } return(Expire.CompareTo(other.Expire)); }
public Boolean Read(HttpCookie cookie, String key) { UserName = cookie["u"]; Password = cookie["p"]; Time = (cookie["t"] + "").ToInt().ToDateTime(); Expire = (cookie["e"] + "").ToInt().ToDateTime(); Sign = cookie["s"]; var str = $"u={UserName}&p={Password}&t={Time.ToInt()}&e={Expire.ToInt()}&k={key}"; return(str.MD5() == Sign); }
//向缓存中写数据(键不存在则添加,键存在则覆盖) public void SetCache(string key, object value, int seconds = 0, Expire expireType = Expire.Defalut) { key = GetFinalKey(key); manager.Put(key, value); // manager.AddOrUpdate(key, value, v => value); int sec = (seconds != 0 ? seconds : GetExpireTime(expireType)); if (sec <= 0) { sec = (int)Expire.Defalut; } manager.Expire(key, TimeSpan.FromSeconds(sec)); //设置某个键的过期时间 }
// GET: Expires/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Expire expire = db.Expires.Find(id); if (expire == null) { return(HttpNotFound()); } return(View(expire)); }
public override int GetHashCode() { var hashCode = 1152426255; hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(PrimaryNameServer); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ResponsibleMailAddress); hashCode = hashCode * -1521134295 + Serial.GetHashCode(); hashCode = hashCode * -1521134295 + Refresh.GetHashCode(); hashCode = hashCode * -1521134295 + Retry.GetHashCode(); hashCode = hashCode * -1521134295 + Expire.GetHashCode(); hashCode = hashCode * -1521134295 + DefaultTtl.GetHashCode(); return(hashCode); }
public Boolean Read(IRequestCookieCollection cookie, String cookieKey, String key) { var cookies = cookie[cookieKey]; var cookieDic = cookies.SplitAsDictionary("=", "&"); UserName = cookieDic["u"]; Password = cookieDic["p"]; Time = (cookieDic["t"] + "").ToInt().ToDateTime(); Expire = (cookieDic["e"] + "").ToInt().ToDateTime(); Sign = cookieDic["s"]; var str = $"u={UserName}&p={Password}&t={Time.ToInt()}&e={Expire.ToInt()}&k={key}"; return(str.MD5() == Sign); }
public void Write(IResponseCookies cookie, String cookieKey, String key) { var cookieOptions = new CookieOptions { HttpOnly = true, Expires = Expire }; var str = $"u={UserName}&p={Password}&t={Time.ToInt()}&e={Expire.ToInt()}&k={key}"; Sign = str.MD5(); str = str + "&s=" + Sign; cookie.Append(cookieKey, str, cookieOptions); }
public ActionResult <ExpireReadDto> CreateExpire(ExpireCreateDto expireCreateDto) { var model = new Expire() { ExpirationDate = expireCreateDto.ExpirationDate.Date, IdUser = _repository.GetUserById(expireCreateDto.UserId), IdItem = _repository.GetItemById(expireCreateDto.IdItem), IdStorage = _repository.GetStorageById(expireCreateDto.IdStorage), }; _repository.CreateExpire(model); _repository.SaveChanges(); var readDto = _mapper.Map <ExpireReadDto>(model); return(CreatedAtRoute(nameof(GetExpireById), new { Id = readDto.ExpireId }, readDto)); }
public override bool IsValid() { if (string.IsNullOrEmpty(Number)) { throw new DocumentInvalidNumberException(); } var now = DateTime.Now; if (Issue.CompareTo(now) > 0) { throw new DocumentIssueDateException(); } if (Expire.CompareTo(now) < 0) { throw new DocumentExpiredException(); } return(true); }
public byte[] GetQueryBuffer() { var keyAsBytes = UTF8Encoding.Default.GetBytes(Key); if (keyAsBytes.Length > ushort.MaxValue) { throw new ArgumentException("The key is too long for the memcache binary protocol : " + Key); } var requestHeader = new MemcacheRequestHeader(RequestOpcode) { KeyLength = (ushort)keyAsBytes.Length, ExtraLength = 2 * sizeof(uint), TotalBodyLength = (uint)(2 * sizeof(uint) + keyAsBytes.Length + (Message == null ? 0 : Message.Length)), Opaque = RequestId, }; var buffer = new byte[MemcacheRequestHeader.SIZE + requestHeader.TotalBodyLength]; requestHeader.ToData(buffer, 0); buffer.CopyFrom(MemcacheRequestHeader.SIZE, Flags); uint expire; if (Expire.CompareTo(TimeSpan.FromDays(30)) < 0) { expire = (uint)Expire.TotalSeconds; } else { expire = (uint)(DateTime.UtcNow.Add(Expire) - Epock).TotalSeconds; } buffer.CopyFrom(MemcacheRequestHeader.SIZE + sizeof(uint), expire); keyAsBytes.CopyTo(buffer, MemcacheRequestHeader.SIZE + requestHeader.ExtraLength); if (Message != null) { Message.CopyTo(buffer, MemcacheRequestHeader.SIZE + requestHeader.ExtraLength + keyAsBytes.Length); } return(buffer); }
/// <summary> /// 应用该规则 /// </summary> /// <param name="context">HttpContext</param> public void Apply(HttpContext context) { var req = context.Request; var key = GenKey.GenKey(req); var info = Store.Query(key); if (info != null) { info.Key = key; } if (req.RawUrl.Contains(REFRESH) || req.Headers[REFRESHHEADER] == "1" || Expire.IsExpire(req, info)) { var reqInfo = ToRequestInfo(req); reqInfo.Key = key; System.Threading.ThreadPool.QueueUserWorkItem(ThreadStart, reqInfo); } else { ResponceCache(context, key, info); } }
public void Write(HttpCookie cookie, String key) { //cookie.HttpOnly = true; cookie["u"] = UserName; cookie["p"] = Password; var dt = Time; cookie["t"] = dt.ToInt() + ""; var exp = Expire; cookie.Expires = exp; cookie["e"] = exp.ToInt() + ""; var str = $"u={UserName}&p={Password}&t={Time.ToInt()}&e={Expire.ToInt()}&k={key}"; Sign = str.MD5(); cookie["s"] = Sign; }
public void UpdateExpire(Expire expire) { // Nothing }
protected override TimeSpan CalculateDelay(NativeActivityContext context) => Expire.Get(context) + (Delay.Get(context) ?? context.GetActivityContext().Parameters.DefaultTimeoutDelay) - DateTime.UtcNow;
//获取过期时间 internal int GetExpireTime(Expire expireType) { int second = (int)expireType; return(second); }
public string GetOrderString() { var order = new StringBuilder(); var error = new StringBuilder(); var confirmMsg = string.Empty; var orderDescription = string.Empty; if (TDANET.client == null || string.IsNullOrEmpty(TDANET.client.AssociatedAccountId)) { error.AppendLine("Error: No logged accound ID found. Please check if logged in."); return(error.ToString()); } string legIdStr = (LegId > 0) ? LegId.ToString() : string.Empty; order.AppendFormat("~symbol{0}={1}", legIdStr, Symbol); order.AppendFormat("~action{0}={1}", legIdStr, Action.ToString("g")); order.AppendFormat("~ordtype{0}={1}", legIdStr, OrderType.ToString("g")); order.AppendFormat("~quantity{0}={1}", legIdStr, Quantity.ToString()); if (Quantity <= 0) { error.AppendLine("Order Error : Quantity must be greater than 0."); } switch (OrderType) { case EquityOrderTypes.market: #region Market if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.moc) { error.AppendLine("Market Order Error : Expire must be day or moc."); } Routing = EquityOrderRoutings.auto; SpInstruction = EquityOrderSpecialInstructions.none; order.AppendFormat("~spinstructions{0}={1}", legIdStr, SpInstruction.ToString("g")); confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nShares: {2:N0}", this.OrderType, this.Action, this.Quantity); break; #endregion case EquityOrderTypes.limit: #region Limit if (Price <= 0) { error.AppendLine("Limit Order Error: Price must be a valid value."); } else { order.AppendFormat("~price{0}={1}", legIdStr, Price); } if (Expire == EquityOrderExpires.day) { if (SpInstruction != EquityOrderSpecialInstructions.none && SpInstruction != EquityOrderSpecialInstructions.aon && SpInstruction != EquityOrderSpecialInstructions.fok) { error.AppendLine("Limit Order Error: SpInstruction must be none, aon, fok."); } } else if (Expire == EquityOrderExpires.day_ext && Expire == EquityOrderExpires.gtc_ext && Expire == EquityOrderExpires.am && Expire == EquityOrderExpires.pm) { if (SpInstruction != EquityOrderSpecialInstructions.none) { error.AppendLine("Limit Order Error : SpInstruction must be none."); } } else if (Expire == EquityOrderExpires.gtc) { if (SpInstruction != EquityOrderSpecialInstructions.none && SpInstruction != EquityOrderSpecialInstructions.aon && SpInstruction != EquityOrderSpecialInstructions.dnr && SpInstruction != EquityOrderSpecialInstructions.aon_dnr) { error.AppendLine("Limit Order Error : SpInstruction must be none, aon, dnr, aon_dnr."); } } else { order.AppendFormat("~spinstructions{0}={1}", legIdStr, SpInstruction.ToString("g")); } if (this.Action == EquityOrderActions.buy) { orderDescription = string.Format("The {0} order will be executed when the price <= {1}", this.Action.ToString().ToUpper(), this.Price); } else if (this.Action == EquityOrderActions.sell) { orderDescription = string.Format("The {0} order will be executed when the price >= {1}", this.Action.ToString().ToUpper(), this.Price); } confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nLimit: {2:$0.00##}, Shares: {3:N0}\r\n\r\nEstimated Total: {4:C2}\r\n\r\n{5}", this.OrderType, this.Action, this.Price, this.Quantity, this.Price * this.Quantity, orderDescription); break; #endregion case EquityOrderTypes.stop_limit: #region Stop Limit if (Price <= 0 || ActPrice <= 0) { error.AppendLine("Stop Limit Order Error : Price or ActPrice must be a valid value."); } else { order.AppendFormat("~price{0}={1}", legIdStr, Price); order.AppendFormat("~actprice{0}={1}", legIdStr, ActPrice); } if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.gtc) { error.AppendLine("Stop Limit Order Error : Expire must be day or gtc."); } else if (Expire != EquityOrderExpires.day && SpInstruction != EquityOrderSpecialInstructions.none) { error.AppendLine("Stop Limit Order Error : SpInstruction must be none."); } else { order.AppendFormat("~spinstructions{0}={1}", legIdStr, SpInstruction.ToString("g")); } if (this.Action == EquityOrderActions.buy) { orderDescription = string.Format("The {0} order will be executed when the stop price >= {2} and then the limt price <= {1}", this.Action.ToString().ToUpper(), this.Price, this.ActPrice); } else if (this.Action == EquityOrderActions.sell) { orderDescription = string.Format("The {0} order will be executed when the stop price <= {2} and then the limit price >= {1}", this.Action.ToString().ToUpper(), this.Price, this.ActPrice); } confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nLimit: {2:$0.00##}, Stop: {3:$0.00##}, Shares: {4:N0}\r\n\r\nEstimated Total: {5:C2}\r\n\r\n{6}", this.OrderType, this.Action, this.Price, this.ActPrice, this.Quantity, this.Price * this.Quantity, orderDescription); break; #endregion case EquityOrderTypes.stop_market: #region Stop Market if (ActPrice <= 0) { error.AppendLine("Stop Market Order Error : ActPrice must be a valid value."); } else { order.AppendFormat("~actprice{0}={1}", legIdStr, ActPrice); } if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.gtc) { error.AppendLine("Stop Market Order Error : Expire must be day or gtc."); } if (this.Action == EquityOrderActions.buy) { orderDescription = string.Format("The {0} order will be executed when the market price >= {1}", this.Action.ToString().ToUpper(), this.ActPrice); } else if (this.Action == EquityOrderActions.sell) { orderDescription = string.Format("The {0} order will be executed when the market price <= {1}", this.Action.ToString().ToUpper(), this.ActPrice); } confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nStop: {2:$0.00##}, Shares: {3:N0}\r\n\r\nEstimated Total: {4:C2}\r\n\r\n{5}", this.OrderType, this.Action, this.ActPrice, this.Quantity, this.ActPrice * this.Quantity, orderDescription); break; #endregion case EquityOrderTypes.tstoppercent: #region TsTopPercent if (TsParam < 1 || TsParam > 99) { error.AppendLine("TsTopPercent Order Error : TsParam must be a whole number 1 and 99: 5 means 5 percent (%)."); } else { order.AppendFormat("~tsparam{0}={1}", legIdStr, TsParam); } if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.gtc) { error.AppendLine("TsTopPercent Order Error : Expire must be day or gtc."); } confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nTsTopPercent: {2:P2}", this.OrderType, this.Action, Convert.ToDouble(this.ActPrice) / 100.0d); break; #endregion case EquityOrderTypes.tstopdollar: #region TsTopDollar if (TsParam <= 0) { error.AppendLine("TsTopPercent Order Error : TsParam must be greater than 0 and a decimal value (#.##)."); } else { order.AppendFormat("~tsparam{0}={1}", legIdStr, TsParam); } if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.gtc) { error.AppendLine("TsTopPercent Order Error : Expire must be day or gtc."); } confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nTsTopDollar: {2:$0.00##}", this.OrderType, this.Action, this.ActPrice); break; #endregion default: error.AppendLine("Invalid Order Type."); break; } order.AppendFormat("~expire{0}={1}", legIdStr, Expire.ToString("g")); if (ConditionalyOrderType == ConditionalOrderTypes.single) { order.AppendFormat("~routing{0}={1}", legIdStr, Routing.ToString("g") + "~"); } string errorString = error.ToString(); if (string.IsNullOrEmpty(errorString)) { this.ConfirmMessage = confirmMsg; string orderString = order.ToString(); return(orderString.Replace("~~", "~")); } else { Error = errorString; return(errorString); } }