public int GetMinutesRemaining(bool untilStart) { TimeSpan ts = untilStart ? StartTime.Subtract(DateTime.Now) : ExpireTime.Subtract(DateTime.Now); int days = ts.Days, hours = ts.Hours, mins = ts.Minutes; return((days * 1440) + (hours * 60) + ts.Minutes); }
//[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.Synchronized)] public static void PlaceNewSingleOrder(string _clOrderID, string _clientID, string _securityCode, int _quantity, double _price, string _custodyCode, char _orderSide, char _orderType, string currencyCode, string exDestination, char _timeInForce, string groupID, char handleInst, DateTime expiration, bool hasAON, int minQty) { QuickFix44.NewOrderSingle order = new QuickFix44.NewOrderSingle(); #region Order Details QuickFix.OrderQty orderQty = new QuickFix.OrderQty(_quantity); order.setField(orderQty); QuickFix.Symbol symbol = new QuickFix.Symbol(_securityCode); order.setField(symbol); QuickFix.SecurityID secID = new QuickFix.SecurityID(_securityCode); order.setField(secID); QuickFix.Side side = new QuickFix.Side(_orderSide); order.setField(side); QuickFix.OrdType ordType = new QuickFix.OrdType(_orderType); order.setField(ordType); QuickFix.Price price = new QuickFix.Price(_price); order.setField(price); Currency currency = new Currency(currencyCode); order.setField(currency); Account acc = new Account(_clientID); order.setField(acc); //QuickFix.ClearingFirm custody = new ClearingFirm(_custodyCode);order.setField(custody); QuickFix.PartyID custody = new PartyID(_custodyCode); order.setField(custody); //QuickFix.PartyRole pr = new PartyRole(PartyRole.CUSTODIAN); order.setField(pr); //QuickFix.NoPartyIDs npid = new NoPartyIDs(1); order.setField(npid); //QuickFix.PartyIDSource pid = new PartyIDSource(PartyIDSource.PROPRIETARY); order.setField(pid); TimeInForce tif = new TimeInForce(_timeInForce); order.setField(tif); IDSource ids = new IDSource("4"); order.setField(ids); TransactTime tt = new TransactTime(DateTime.Now); order.setField(tt); //SenderSubID ss = new SenderSubID("05095a"); order.setField(ss); if (_timeInForce == QuickFix.TimeInForce.GOOD_TILL_DATE) { ExpireDate ed = new ExpireDate(expiration.ToString("yyyyMMdd")); order.setField(ed); //ExpireTime et = new ExpireTime(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour + 4, 0, 0)); order.setField(et); ExpireTime et = new ExpireTime(expiration); order.setField(et); } if (hasAON) { order.setField(new ExecInst(ExecInst.ALL_OR_NONE.ToString())); order.setField(new MinQty(minQty)); } #endregion Order Details #region Fix Order Message IDs QuickFix.ClOrdID clOrdID = new QuickFix.ClOrdID(string.Format("{0}{1}", _wcfMsgPrefix, _clOrderID)); order.setField(clOrdID); #endregion Fix Order Message IDs #region Reporting //QuickFix.HandlInst handlInst = new QuickFix.HandlInst(QuickFix.HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION); order.setField(handlInst); QuickFix.HandlInst handlInst = new QuickFix.HandlInst(handleInst); order.setField(handlInst); #endregion Reporting #region Exchange ExDestination exd = new ExDestination(exDestination); order.setField(exd); TradingSessionID tradSession = new TradingSessionID(groupID); order.setField(tradSession); #endregion Exchange Session.sendToTarget(order, _sessionID); }
public static void ReplaceOrder(OrderID orderID, ClOrdID clOrdID, decimal price, OrdType ordType, TimeInForce timeInForce, Symbol symbol, OrderQty orderQty, Side side, ExpireTime expireTime, Account account, decimal?slippage) { QuickFix44.OrderCancelReplaceRequest message = new QuickFix44.OrderCancelReplaceRequest( new OrigClOrdID(clOrdID.getValue()), clOrdID, side, new TransactTime(DateTime.UtcNow), ordType); message.set(orderID); message.set(new Price((double)price)); message.set(timeInForce); message.set(symbol); message.set(orderQty); if (expireTime != null) { message.set(expireTime); } if (account != null) { message.set(account); } if (slippage.HasValue) { message.setDouble(7011, (double)slippage.Value); } Credential dukascopyCredential = CredentialFactory.GetCredential(Counterpart.Dukascopy); Session.sendToTarget(message, dukascopyCredential.TradingSenderCompID, dukascopyCredential.TradingTargetCompID); }
public Uri Create(RequestContext requestContext) { Ensure.ToBeTrue(ExpireTime > DateTime.UtcNow); Ensure.ToBeTrue(HttpMethod == HttpMethod.Get || HttpMethod == HttpMethod.Put, "不支持的http method"); //只支持这两种 var method = HttpMethod.ToString().ToUpperInvariant(); var expire = ((long)ExpireTime.Subtract(EpicTime).TotalSeconds).ToString(); //UNIX 时间戳 // 要额外签名的数据 var headers = new Dictionary <string, string>(); if (UserMetadata != null) { foreach (var pair in UserMetadata) { headers.Add(OssHeaders.OssUserMetaPrefix + pair.Key, pair.Value); } } var canonicalHeaders = SignatureHelper.ComputeCanonicalizedOSSHeaders(headers); //? 以STS获得的AccessKeyId和AccessKeySecret发送时,是否考虑SecurityToken的处理? // var parameters = new Dictionary <string, string>(); if (requestContext.OssCredential.UseToken) { parameters.Add(RequestParameters.SECURITY_TOKEN, requestContext.OssCredential.SecurityToken); } ResponseHeaderOverrides?.Populate(parameters); var canonicalResource = SignatureHelper.BuildCanonicalizedResource(Bucket, ObjectKey, parameters); //var canonicalResource = "/" + (Bucket ?? "") + ((ObjectKey != null ? "/" + ObjectKey : "")); //签名 var sign = SignatureHelper.HmacSha1Sign(requestContext.OssCredential.AccessKeySecret, method, ContentMd5, ContentType, expire, canonicalHeaders, canonicalResource); // URL 参数 var urlParams = new Dictionary <string, string>(); urlParams.Add(RequestParameters.EXPIRES, expire); urlParams.Add(RequestParameters.OSS_ACCESS_KEY_ID, requestContext.OssCredential.AccessKeyId); urlParams.Add(RequestParameters.SIGNATURE, sign); foreach (var pair in parameters) { urlParams.Add(pair.Key, pair.Value); } var queryString = HttpUtils.CombineQueryString(urlParams); // 生成最终的URI var uriString = Bucket.GetObjectUrl(ObjectKey) + "?" + queryString; return(new Uri(uriString)); }
public void MergeFrom(AuthorizedCertificate other) { if (other == null) { return; } if (other.Name.Length != 0) { Name = other.Name; } if (other.Id.Length != 0) { Id = other.Id; } if (other.DisplayName.Length != 0) { DisplayName = other.DisplayName; } domainNames_.Add(other.domainNames_); if (other.expireTime_ != null) { if (expireTime_ == null) { ExpireTime = new global::Google.Protobuf.WellKnownTypes.Timestamp(); } ExpireTime.MergeFrom(other.ExpireTime); } if (other.certificateRawData_ != null) { if (certificateRawData_ == null) { CertificateRawData = new global::Google.Cloud.AppEngine.V1.CertificateRawData(); } CertificateRawData.MergeFrom(other.CertificateRawData); } if (other.managedCertificate_ != null) { if (managedCertificate_ == null) { ManagedCertificate = new global::Google.Cloud.AppEngine.V1.ManagedCertificate(); } ManagedCertificate.MergeFrom(other.ManagedCertificate); } visibleDomainMappings_.Add(other.visibleDomainMappings_); if (other.DomainMappingsCount != 0) { DomainMappingsCount = other.DomainMappingsCount; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
internal async Task <string> BuildAsync(string userKey, string devKey) { string date = (ExpireTime.GetType().GetField(ExpireTime.ToString()) .GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[])[0].Description; string requestData = $"api_option=paste&" + $"api_user_key={userKey}&" + $"api_paste_private={(int)Visibility}&" + $"api_paste_name={WebUtility.UrlEncode(Title)}&" + $"api_paste_expire_date={date}&" + $"api_paste_format={Format}&" + $"api_dev_key={devKey}&" + $"api_paste_code={WebUtility.UrlEncode(Text)}"; return(await Task.FromResult(requestData)); }
public DateTime GetLastSeen() { // calculating back from expire time, so we don't need an additional field. // might result in wrong values if doing CheckingType() for example, so don't use for important timing stuff if (ExpireTime != DateTime.MinValue) { switch (m_byType) { case 2: return(ExpireTime.AddHours(-1)); case 1: return(ExpireTime.AddHours(-1.5)); case 0: return(ExpireTime.AddHours(-2)); } } return(DateTime.MinValue); }
public LoginInfo(MafUser user, string psw, bool isRememberMe) : this() { if (user == null) { throw new SecurityException("用户名不存在"); } if (user.Password != psw) { throw new SecurityException("密码错误"); } UserName = user.Name; IsAnonymous = typeof(MafAnonymousUser) == user.GetType(); ExpireTime = isRememberMe ? ExpireTime.AddYears(100) : ExpireTime.AddDays(1); }
public override int GetHashCode() { int hash = 1; if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (expireTime_ != null) { hash ^= ExpireTime.GetHashCode(); } if (DataFormat != 0) { hash ^= DataFormat.GetHashCode(); } if (schemaCase_ == SchemaOneofCase.AvroSchema) { hash ^= AvroSchema.GetHashCode(); } if (schemaCase_ == SchemaOneofCase.ArrowSchema) { hash ^= ArrowSchema.GetHashCode(); } if (Table.Length != 0) { hash ^= Table.GetHashCode(); } if (tableModifiers_ != null) { hash ^= TableModifiers.GetHashCode(); } if (readOptions_ != null) { hash ^= ReadOptions.GetHashCode(); } hash ^= streams_.GetHashCode(); hash ^= (int)schemaCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (DisplayName.Length != 0) { hash ^= DisplayName.GetHashCode(); } hash ^= domainNames_.GetHashCode(); if (expireTime_ != null) { hash ^= ExpireTime.GetHashCode(); } if (certificateRawData_ != null) { hash ^= CertificateRawData.GetHashCode(); } if (managedCertificate_ != null) { hash ^= ManagedCertificate.GetHashCode(); } hash ^= visibleDomainMappings_.GetHashCode(); if (DomainMappingsCount != 0) { hash ^= DomainMappingsCount.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void MergeFrom(ReadSession other) { if (other == null) { return; } if (other.Name.Length != 0) { Name = other.Name; } if (other.expireTime_ != null) { if (expireTime_ == null) { ExpireTime = new global::Google.Protobuf.WellKnownTypes.Timestamp(); } ExpireTime.MergeFrom(other.ExpireTime); } if (other.DataFormat != 0) { DataFormat = other.DataFormat; } if (other.Table.Length != 0) { Table = other.Table; } if (other.tableModifiers_ != null) { if (tableModifiers_ == null) { TableModifiers = new global::Google.Cloud.BigQuery.Storage.V1.ReadSession.Types.TableModifiers(); } TableModifiers.MergeFrom(other.TableModifiers); } if (other.readOptions_ != null) { if (readOptions_ == null) { ReadOptions = new global::Google.Cloud.BigQuery.Storage.V1.ReadSession.Types.TableReadOptions(); } ReadOptions.MergeFrom(other.ReadOptions); } streams_.Add(other.streams_); switch (other.SchemaCase) { case SchemaOneofCase.AvroSchema: if (AvroSchema == null) { AvroSchema = new global::Google.Cloud.BigQuery.Storage.V1.AvroSchema(); } AvroSchema.MergeFrom(other.AvroSchema); break; case SchemaOneofCase.ArrowSchema: if (ArrowSchema == null) { ArrowSchema = new global::Google.Cloud.BigQuery.Storage.V1.ArrowSchema(); } ArrowSchema.MergeFrom(other.ArrowSchema); break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public override string ToString() { string format = string.Format("{0}|{1}|{2}|{3}|{4}", UserId, Account, Password, RoleId, ExpireTime.ToString("yyyy-MM-dd HH:mm:ss")); byte[] bytes = Encoding.UTF8.GetBytes(HttpUtility.UrlEncode(format)); for (int i = 0; i < bytes.Length; i++) { bytes[i] = Convert.ToByte((255 - Convert.ToUInt16(bytes[i])) ^ KEY); } return(Convert.ToBase64String(bytes)); }
public bool HasExpired() { // shorten the expire date by 1 minutes return(DateTimeOffset.UtcNow > ExpireTime.AddMinutes(-2)); }
public TimeSpan GetTimeRemaining(bool untilStart) { return(untilStart ? StartTime.Subtract(DateTime.Now) : ExpireTime.Subtract(DateTime.Now)); }
/// <summary> /// 将当前租期续约一段时间 /// </summary> /// <param name="timeSpan">续约时间</param> /// <returns>返回续约后的到期时间</returns> /// <exception cref="Exception">当前缓存已经处于死亡状态</exception> public DateTime Renew(TimeSpan timeSpan) { if (IsDead) { throw new Exception("Cannot execute renew operation on a dead container."); } ExpireTime = (ExpireTime == DateTime.MaxValue ? DateTime.Now.Add(timeSpan) : ExpireTime.Add(timeSpan)); lock (_lockObj) { //renew all. foreach (ICacheStub <V> stub in _caches.Values) { stub.GetLease().Renew(timeSpan); } return(ExpireTime); } }