Beispiel #1
0
 /// <summary>
 /// Save a change the message status of a message to the database.
 /// </summary>
 /// <param name="message">Message to update</param>
 /// <param name="status">Status change</param>
 public void MarkMessage(Message message, MessageStatus status)
 {
     if (_dbConnection != null && message != null)
     {
         var lockTaken = false;
         try
         {
             lockTaken = SyncLock.Wait(TIMEOUT);
             if (!lockTaken)
             {
                 return;
             }
             MarkMessageNoLock(message, status);
         }
         catch (Exception ex)
         {
             Logger.Error(string.Format("Error setting status to {0}.", status.ToString()), ex);
         }
         finally
         {
             if (lockTaken)
             {
                 SyncLock.Release();
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Human-readable string version of the object.
        /// </summary>
        /// <returns>String.</returns>
        public override string ToString()
        {
            string ret = "---" + Environment.NewLine;

            ret += "  Preshared key     : " + (PresharedKey != null ? ByteArrayToHex(PresharedKey) : "null") + Environment.NewLine;
            ret += "  Status            : " + Status.ToString() + Environment.NewLine;
            ret += "  SyncRequest       : " + SyncRequest.ToString() + Environment.NewLine;
            ret += "  SyncResponse      : " + SyncResponse.ToString() + Environment.NewLine;
            ret += "  ExpirationUtc     : " + (Expiration != null ? Expiration.Value.ToString(_DateTimeFormat) : "null") + Environment.NewLine;
            ret += "  Conversation GUID : " + ConversationGuid + Environment.NewLine;

            if (Metadata != null)
            {
                ret += "  Metadata          : " + Metadata.Count + " entries" + Environment.NewLine;
            }

            if (Data != null)
            {
                ret += "  Data              : " + Data.Length + " bytes" + Environment.NewLine;
                if (Data.Length > 0)
                {
                    ret += Encoding.UTF8.GetString(Data);
                }
            }

            if (DataStream != null)
            {
                ret += "  DataStream        : present, " + ContentLength + " bytes" + Environment.NewLine;
            }

            return(ret);
        }
 private void SetupMessagePublisher_PublisherAsync(MessageStatus messageStatus)
 {
     Mock.Get(_mockMessagePublisher)
     .Setup(e => e.PublisherAsync <ContractNotification>(It.IsAny <ContractNotification>(), It.IsAny <IDictionary <string, string> >()))
     .Callback((ContractNotification n, IDictionary <string, string> properties) =>
     {
         properties.Count.Should().Be(1);
         properties.ContainsKey("Status").Should().BeTrue();
         properties["Status"].Should().BeEquivalentTo(messageStatus.ToString("G"));
     })
     .Returns(Task.CompletedTask)
     .Verifiable();
 }
        /// <summary>
        /// Initialize a tcp connection with server
        /// </summary>
        /// <param name="isWindows">the flag is true if the OS is windows</param>
        public void Initialize(bool isWindows)
        {
            //Reset variables
            this.messageId    = 0;
            this.lockSequence = 0;
            this.sessionId    = 0;

            //Initialize SMB2 SDK and connect to share
            this.smb2Client = new Smb2Client(timeout);

            bool      isIpv4   = this.ipVersion == IpVersion.Ipv6 ? false : true;
            IPAddress serverIp = FsaUtility.GetIpAddress(this.serverName, isIpv4);

            this.site.Log.Add(LogEntryKind.Debug, "Connect to server {0} over TCP.", serverIp.ToString());
            this.smb2Client.ConnectOverTCP(serverIp);

            MessageStatus status = MessageStatus.SUCCESS;

            status = this.Negotiate();
            if (status != MessageStatus.SUCCESS)
            {
                throw new InvalidOperationException("Negotiate failed:" + status.ToString());
            }

            status = this.SessionSetup();
            if (status != MessageStatus.SUCCESS)
            {
                throw new InvalidOperationException("session setup failed:" + status.ToString());
            }

            status = this.TreeConnect();
            if (status != MessageStatus.SUCCESS)
            {
                throw new InvalidOperationException("treeconeect failed:" + status.ToString());
            }
        }
Beispiel #5
0
        public static string ToApiString(this MessageStatus value)
        {
            switch (value)
            {
            case MessageStatus.Active:
                return(ACTIVE);

            case MessageStatus.DeletedByPublisher:
                return(DELETED_BY_PUBLISHER);

            case MessageStatus.DeletedByAnotherMember:
                return(DELETED_BY_ANOTHER_MEMBER);
            }

            return(value.ToString("G").ToLower());
        }
Beispiel #6
0
 public GetStatusResponseDto(string messageId, MessageStatus status)
 {
     MessageId = messageId;
     Status    = status.ToString();
 }
Beispiel #7
0
        /// <summary>
        /// Sends sms through primary sms service i.e Nexmo SMS Gateway.
        /// </summary>
        /// <param name="phoneNumber">A string containing the receiving phone number.</param>
        /// <param name="messageBody">A string containing the message body text.</param>
        /// <param name="enableBackupServiceSupport">A bool specifies whether backup service support is enabled or not.</param>
        public static void SendThroughPrimaryApi(string phoneNumber, string messageBody, bool enableBackupServiceSupport = false)
        {
            if (_nexmoApiKey == null)
            {
                _nexmoApiKey = ConfigurationManager.AppSettings[NeeoConstants.NexmoApiKey].ToString();
            }

            if (_nexmoApiSecret == null)
            {
                _nexmoApiSecret = ConfigurationManager.AppSettings[NeeoConstants.NexmoApiSecret].ToString();
            }

            NexmoClient   nexmoClient   = new NexmoClient(_nexmoApiKey, _nexmoApiSecret);
            NexmoResponse smsResponse   = nexmoClient.SendMessage(phoneNumber, NeeoConstants.AppName, messageBody);
            MessageStatus messageStatus = (MessageStatus)Convert.ToUInt16(smsResponse.Messages[0].Status);

            switch (messageStatus)
            {
            case MessageStatus.InvalidMessage:
                LogManager.CurrentInstance.ErrorLogger.LogError(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Nexmo - Phone # : " + phoneNumber + " Status : " + messageStatus.ToString() + ", Description : " + NexmoDictionaries.MessageStatusDescriptionDictionary[(short)messageStatus]);
                if (enableBackupServiceSupport)
                {
                    SendThroughSecondaryApi(phoneNumber, messageBody);
                }
                else
                {
                    throw new ApplicationException(CustomHttpStatusCode.InvalidNumber.ToString("D"));
                }
                break;

            case MessageStatus.Throttled:
            case MessageStatus.MissingParams:
            case MessageStatus.InvalidParams:
            case MessageStatus.InvalidCredentials:
            case MessageStatus.InternalError:
            case MessageStatus.NumberBarred:
            case MessageStatus.PartnerAccountBarred:
            case MessageStatus.PartnerQuotaExceeded:
            case MessageStatus.CommunicationFailed:
            case MessageStatus.InvalidSignature:
            case MessageStatus.InvalidSenderAddress:
                LogManager.CurrentInstance.ErrorLogger.LogError(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Nexmo - Phone # : " + phoneNumber + " Status : " + messageStatus.ToString() + ", Description : " + NexmoDictionaries.MessageStatusDescriptionDictionary[(short)messageStatus]);
                if (enableBackupServiceSupport)
                {
                    SendThroughSecondaryApi(phoneNumber, messageBody);
                }
                else
                {
                    throw new ApplicationException(CustomHttpStatusCode.SmsApiException.ToString("D"));
                }
                break;
            }
        }
Beispiel #8
0
        /// <summary>
        /// Sends SMS to the given number.
        /// </summary>
        /// <param name="phoneNumber">A string containing the phone number for sending SMS.</param>
        /// <param name="msgBody">A string containing message body text.</param>
        /// <param name="isUnicode">if true, message body contains unicode text; otherwise false.(Optional)</param>
        /// <returns>true if SMS is successfully sent; otherwise, false.</returns>
        public override void SendSms(string[] phoneNumber, string msgBody, bool isUnicode = false)
        {
            NexmoClient   nexmoClient   = new NexmoClient(_nexmoApiKey, _nexmoApiSecret);
            NexmoResponse smsResponse   = nexmoClient.SendMessage(phoneNumber[0], NeeoConstants.AppName, msgBody, isUnicode);
            MessageStatus messageStatus = (MessageStatus)Convert.ToUInt16(smsResponse.Messages[0].Status);

            switch (messageStatus)
            {
            case MessageStatus.InvalidMessage:
                LogManager.CurrentInstance.ErrorLogger.LogError(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Nexmo - Phone # : " + phoneNumber[0] + " Status : " + messageStatus.ToString() + ", Description : " + NexmoDictionaries.MessageStatusDescriptionDictionary[(short)messageStatus]);

                throw new ApplicationException(CustomHttpStatusCode.InvalidNumber.ToString("D"));
                break;

            case MessageStatus.Throttled:
            case MessageStatus.MissingParams:
            case MessageStatus.InvalidParams:
            case MessageStatus.InvalidCredentials:
            case MessageStatus.InternalError:
            case MessageStatus.NumberBarred:
            case MessageStatus.PartnerAccountBarred:
            case MessageStatus.PartnerQuotaExceeded:
            case MessageStatus.CommunicationFailed:
            case MessageStatus.InvalidSignature:
            case MessageStatus.InvalidSenderAddress:
                LogManager.CurrentInstance.ErrorLogger.LogError(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Nexmo - Phone # : " + phoneNumber[0] + " Status : " + messageStatus.ToString() + ", Description : " + NexmoDictionaries.MessageStatusDescriptionDictionary[(short)messageStatus]);

                throw new ApplicationException(CustomHttpStatusCode.SmsApiException.ToString("D"));
                break;
            }
        }
Beispiel #9
0
 protected void Output(MessageStatus status, string error, string msg = "")
 {
     this.Controls.Clear();
     base.Response.Write("{" + string.Format("\"status\":\"{0}\",\"error\":\"{1}\",\"message\":\"{2}\"", status.ToString(), error, msg) + "}");
     base.Response.End();
 }
Beispiel #10
0
 /// <summary>
 /// Update shown status.
 /// </summary>
 private void UpdateStatus(object sender, MessageStatus status)
 {
     _statusBar.Invoke(new MethodInvoker(() => _statusLabel.Text = status.ToString()));
 }
Beispiel #11
0
 public void SetMessageStatus(MessageBookmark bookmark, MessageStatus status, string subQueue = null)
 {
     var path = bookmark.Bookmark;
     var id = FileUtil.ToMessageId(path);
     if (!File.Exists(path))
         return;
     bookmark.Bookmark = FileUtil.MoveExtension(path, status.ToString());
     if (subQueue == null)
         _logger.DebugFormat("Changing message {0} status to {1} on {2}", id, status, _queueName);
     else
         _logger.DebugFormat("Changing message {0} status to {1} on queue '{2}' and set subqueue to '{3}'", id, status, _queueName, subQueue);
 }