Beispiel #1
0
        public void TimedEvent(Object source, ElapsedEventArgs e)
        {
            // On every timer fire, try to extract a message from the queue
            //Console.Out.WriteLine("heartbeat");
            EmailMessage email = new EmailMessage();
            Object       o     = new Object();

            System.Type[] arrTypes = new System.Type[2];
            arrTypes[0]     = email.GetType();
            arrTypes[1]     = o.GetType();
            queue.Formatter = new XmlMessageFormatter(arrTypes);
            email           = ((EmailMessage)queue.Receive().Body);
            Console.Out.WriteLine("(" + DateTime.Now + ") Retrieved message from the queue dated " + email.Date);
            Console.Out.WriteLine("To: " + email.ToAddresses + " From: " + email.FromAddresses + "\n" + email.Message);
        }
Beispiel #2
0
        private string CreateXmlFromEmailMessage(EmailMessage emailMessage)
        {
            using (var stringWriter = new StringWriter())
            {
                var serializer = new XmlSerializer(emailMessage.GetType());
                var settings   = new XmlWriterSettings
                {
                    Encoding         = Encoding.UTF8,
                    Indent           = true,
                    ConformanceLevel = ConformanceLevel.Auto
                };

                using (var xmlWriter = XmlWriter.Create(stringWriter, settings))
                {
                    serializer.Serialize(xmlWriter, emailMessage);
                    return(stringWriter.ToString());
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="OpenBots.Service.API.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="accountName"></param>
        /// <param name="body"> (optional)</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task <ApiResponse <Object> > ApiV1EmailAccountNamePostAsyncWithHttpInfo(string accountName, EmailMessage body = null)
        {
            // verify the required parameter 'accountName' is set
            if (accountName == null)
            {
                throw new ApiException(400, "Missing required parameter 'accountName' when calling EmailApi->ApiV1EmailAccountNamePost");
            }

            var    localVarPath         = "/api/v1/Email/{accountName}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json-patch+json",
                "application/json",
                "text/json",
                "application/_*+json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
            };
            String localVarHttpHeaderAccept    = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (accountName != null)
            {
                localVarPathParams.Add("accountName", this.Configuration.ApiClient.ParameterToString(accountName));                      // path parameter
            }
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("ApiV1EmailAccountNamePost", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Object>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)),
                                            null));
        }