Beispiel #1
0
        public string ToMangledContactString()
        {
            int secondsRemaining = Convert.ToInt32(ExpiryTime.Subtract(DateTime.UtcNow).TotalSeconds % Int32.MaxValue);

            return("<" + m_mangledContactURI.ToString() + ">;" + SIPContactHeader.EXPIRES_PARAMETER_KEY + "=" +
                   secondsRemaining);
        }
Beispiel #2
0
 internal Hashgraph.Extensions.FeeSchedule ToFeeSchedule()
 {
     return(new Hashgraph.Extensions.FeeSchedule
     {
         Expires = ExpiryTime.ToDateTime(),
         Data = TransactionFeeSchedule.ToDictionary(fee => fee.HederaFunctionality.ToString(), fee => JsonFormatter.Default.Format(fee.FeeData))
     });
 }
Beispiel #3
0
 public override int GetHashCode() =>
 ExpiryTime.GetHashCode() ^
 Identifier.GetHashCode() ^
 IPRange.GetHashCode() ^
 Permissions.GetHashCode() ^
 Protocol.GetHashCode() ^
 QueueName.GetHashCode() ^
 StartTime.GetHashCode() ^
 Version.GetHashCode();
Beispiel #4
0
 public override int GetHashCode() =>
 ExpiryTime.GetHashCode() ^
 IPRange.GetHashCode() ^
 (Permissions?.GetHashCode() ?? 0) ^
 Protocol.GetHashCode() ^
 (ResourceTypes?.GetHashCode() ?? 0) ^
 (Services?.GetHashCode() ?? 0) ^
 StartTime.GetHashCode() ^
 (Version?.GetHashCode() ?? 0);
Beispiel #5
0
 internal Hashgraph.Extensions.FeeSchedule ToFeeSchedule()
 {
     return(new Hashgraph.Extensions.FeeSchedule
     {
         Expires = ExpiryTime.ToDateTime(),
         Data = TransactionFeeSchedule.ToDictionary(
             fee => fee.HederaFunctionality.ToString(),
             fee => fee.Fees?.Select(item => JsonFormatter.Default.Format(item)).ToArray() ?? Array.Empty <string>())
     });
 }
        static TimeSpan?GetExpiryTime(ExpiryTime expiry)
        {
            TimeSpan?timeSpan = null;

            if (expiry != ExpiryTime.None)
            {
                timeSpan = TimeSpan.FromMinutes((int)expiry);
            }
            return(timeSpan);
        }
 public override int GetHashCode() =>
 BlobName.GetHashCode() ^
 CacheControl.GetHashCode() ^
 BlobContainerName.GetHashCode() ^
 ContentDisposition.GetHashCode() ^
 ContentEncoding.GetHashCode() ^
 ContentLanguage.GetHashCode() ^
 ContentType.GetHashCode() ^
 ExpiryTime.GetHashCode() ^
 Identifier.GetHashCode() ^
 IPRange.GetHashCode() ^
 Permissions.GetHashCode() ^
 Protocol.GetHashCode() ^
 StartTime.GetHashCode() ^
 Version.GetHashCode();
        static CacheObject <T> GetInsert <T>(string key, Func <T> getFunction, ExpiryTime expiry) where T : class
        {
            var value = GetValue(key);

            if (value.IsNullOrEmpty || value == RedisValue.Null)
            {
                var dbValue = getFunction();
                SetValue(key, dbValue, expiry);
                return(GetCacheObject(dbValue, false));
            }
            else
            {
                return(GetCacheObject(JsonConvert.DeserializeObject <T>(value), true));
            }
        }
 public XElement Serialize()
 {
     return(new XElement(UblNames.Cac + nameof(ExternalReference),
                         URI.Serialize(nameof(URI)),
                         DocumentHash.Serialize(nameof(DocumentHash)),
                         HashAlgorithmMethod.Serialize(nameof(HashAlgorithmMethod)),
                         ExpiryDate.Serialize(nameof(ExpiryDate)),
                         ExpiryTime.Serialize(nameof(ExpiryTime)),
                         MimeCode.Serialize(nameof(MimeCode)),
                         FormatCode.Serialize(nameof(FormatCode)),
                         EncodingCode.Serialize(nameof(EncodingCode)),
                         CharacterSetCode.Serialize(nameof(CharacterSetCode)),
                         FileName.Serialize(nameof(FileName)),
                         Description.Serialize(nameof(Description))
                         ));
 }
Beispiel #10
0
        private void btnNewOrder_Click(object sender, EventArgs e)
        {
            try
            {
                OptionType optType;
                Enum.TryParse <OptionType>(cmbOptionType.SelectedValue.ToString(), out optType);
                OrderType ordType;
                Enum.TryParse <OrderType>(cmbOrderType.SelectedValue.ToString(), out ordType);
                Symbol option = cmbSymbol.SelectedItem as Symbol;

                ExpiryTime expTime = cmbExpiry.SelectedItem as ExpiryTime;

                var orderRequest = new OrderPlaceRequest();
                orderRequest.Investment = Convert.ToInt32(txtAmount.Text);

                orderRequest.Symbol     = option;
                orderRequest.OptionID   = assets.Where(x => x.Symbol.Name == option.Name).FirstOrDefault <Asset>().ID;
                orderRequest.OptionType = optType;
                orderRequest.OrderType  = ordType;
                long timestamp = expTime.ExpiryTimestamps;

                if (optType == OptionType.Express)
                {
                    orderRequest.OptionType = OptionType.Express;
                    short expirationTerm = 0;
                    Int16.TryParse(cmbShortTermExpiry.SelectedItem.ToString(), out expirationTerm);
                    orderRequest.ExpressExpiryInSeconds = expirationTerm;
                }
                else
                {
                    orderRequest.ExpiryTimestamp = timestamp;
                    AppendToLog(TimestampToDateTime(orderRequest.ExpiryTimestamp).ToString());
                    AppendToLog(TimestampToDateTime(orderRequest.ExpiryTimestamp).ToUniversalTime().ToString());
                }
                orderRequest.CurrentMarketPrice = Convert.ToDouble(txtCurPrice.Text);
                //AppendToLog(TimestampToDateTime(orderRequest.ExpiryTimestamp).ToString());
                //AppendToLog(TimestampToDateTime(orderRequest.ExpiryTimestamp).ToUniversalTime().ToString());
                //AppendToLog(GetCurrentTimestamp().ToString());
                //AppendToLog(GetCurrentDateTime(GetCurrentTimestamp()).ToString());
                Send(orderRequest);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public string ToXMLNoParent()
        {
            string contactURIStr        = (m_contactURI != null) ? m_contactURI.ToString() : null;
            string mangledContactURIStr = (m_mangledContactURI != null) ? m_mangledContactURI.ToString() : null;

            string registrarBindingXML =
                "   <id>" + Id + "</id>" + m_newLine +
                "   <sipaccountid>" + SIPAccountId + "</sipaccountid>" + m_newLine +
                "   <sipaccountname>" + SIPAccountName + "</sipaccountname>" + m_newLine +
                "   <owner>" + Owner + "</owner>" + m_newLine +
                "   <adminmemberid>" + AdminMemberId + "</adminmemberid>" + m_newLine +
                "   <contacturi>" + contactURIStr + "</contacturi>" + m_newLine +
                "   <mangledcontacturi>" + mangledContactURIStr + "</mangledcontacturi>" + m_newLine +
                "   <expiry>" + Expiry + "</expiry>" + m_newLine +
                "   <useragent>" + SafeXML.MakeSafeXML(UserAgent) + "</useragent>" + m_newLine +
                "   <remotesipsocket>" + RemoteSIPSocket + "</remotesipsocket>" + m_newLine +
                "   <proxysipsocket>" + ProxySIPSocket + "</proxysipsocket>" + m_newLine +
                "   <registrarsipsocket>" + RegistrarSIPSocket + "</registrarsipsocket>" + m_newLine +
                "   <lastupdate>" + m_lastUpdate.ToString("o") + "</lastupdate>" + m_newLine +
                "   <expirytime>" + ExpiryTime.ToString("o") + "</expirytime>" + m_newLine;

            return(registrarBindingXML);
        }
Beispiel #12
0
        public override void ExecuteCmdlet()
        {
            try
            {
                LocalResourceIdentifier identifier = new LocalResourceIdentifier(AuthorizationRuleId);
                string resourceUri = string.Empty, strPolicyName = string.Empty, sakey = string.Empty;

                PSListKeysAttributes listkeys;
                if (identifier.ParentResource1 != null)
                {
                    listkeys = Client.GetEventHubListKeys(identifier.ResourceGroupName, identifier.ParentResource, identifier.ParentResource1, identifier.ResourceName);
                }
                else
                {
                    listkeys = Client.GetNamespaceListKeys(identifier.ResourceGroupName, identifier.ParentResource, identifier.ResourceName);
                }

                string[] connectionstring = KeyType == "Primary" ? listkeys.PrimaryConnectionString.Split(';') : listkeys.SecondaryConnectionString.Split(';');

                switch (connectionstring.Length)
                {
                case 4:
                {
                    resourceUri   = connectionstring[0].Replace("Endpoint=sb://", "") + connectionstring[3].Replace("EntityPath=", "");
                    strPolicyName = connectionstring[1].Replace("SharedAccessKeyName=", "");
                    sakey         = connectionstring[2].Replace("SharedAccessKey=", "");
                    break;
                }

                case 3:
                {
                    resourceUri   = connectionstring[0].Replace("Endpoint=sb://", "");
                    strPolicyName = connectionstring[1].Replace("SharedAccessKeyName=", "");
                    sakey         = connectionstring[2].Replace("SharedAccessKey=", "");
                    break;
                }

                default:
                {
                    break;
                }
                }

                string     stringToSign = StartTime.HasValue ? StartTime.ToString() + "\n" + System.Web.HttpUtility.UrlEncode(resourceUri) + "\n" + ExpiryTime.ToString() : System.Web.HttpUtility.UrlEncode(resourceUri) + "\n" + ExpiryTime.ToString();
                HMACSHA256 hmac         = new HMACSHA256(System.Text.Encoding.UTF8.GetBytes(sakey));
                var        signature    = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(stringToSign)));
                string     sasToken     = String.Format(CultureInfo.InvariantCulture, "SharedAccessSignature sr={0}&sig={1}&se={2}&skn={3}", HttpUtility.UrlEncode(resourceUri), HttpUtility.UrlEncode(signature), ExpiryTime, KeyType);
                PSSharedAccessSignatureAttributes psSastoken = new PSSharedAccessSignatureAttributes(sasToken);
                WriteObject(psSastoken, true);
            }
            catch (Management.EventHub.Models.ErrorResponseException ex)
            {
                WriteError(Eventhub.EventHubsClient.WriteErrorforBadrequest(ex));
            }
        }
        public static async Task <CacheObject <T> > GetInsertAsync <T>(Expression <Func <Task <T> > > getFunction, string applicationName, ExpiryTime expiry) where T : class
        {
            var key = RedisKeysGenerator.GenerateKey(getFunction, applicationName);

            return(await GetInsert(key, getFunction.Compile(), expiry).ConfigureAwait(false));
        }
 internal static object GetInsert(Func <object> p, ExpiryTime day)
 {
     throw new NotImplementedException();
 }
        public static CacheObject <T> GetInsert <T>(Expression <Func <T> > getFunction, ExpiryTime expiry) where T : class
        {
            var key = RedisKeysGenerator.GenerateKey(getFunction);

            return(GetInsert(key, getFunction.Compile(), expiry));
        }
 static void SetValue <T>(string key, T value, ExpiryTime expiry) where T : class
 {
     SetValue(key, value, GetExpiryTime(expiry));
 }