Exemplo n.º 1
0
        /// <summary>
        /// Configures the mail account used for sending
        /// </summary>
        public static void GetMailSettings(IRaspRequest request)
        {
            // Read the settings from the console
            Console.WriteLine("\nPlease configure the mail account used for sending");
            Console.WriteLine("----------------------------------------------------");
            string server = "ebconnect.dk";

            Console.Write("\tMail server: " + server);
            string serverInput = Console.ReadLine();

            if (!string.IsNullOrEmpty(serverInput))
            {
                server = serverInput;
            }

            string account = "ebDispatcher_out";

            Console.Write("\tAccount name: " + account);
            string accountInput = Console.ReadLine();

            if (!string.IsNullOrEmpty(accountInput))
            {
                account = accountInput;
            }

            string password = "******";

            Console.Write("\tPassword: "******"@" + server;

            Console.WriteLine("\tThe address '" + replyAddress + "' will be used");
            // Configure the mail accounts in the dynamic configuration file
            // This code uses the same server address and account info for sending and receiving
            EmailTransportUserConfig mailConfig = ConfigurationHandler.GetConfigurationSection <EmailTransportUserConfig>();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            while (true)
            {
                try {
                    GUI.MenuChoice mode = GUI.DisplayMenu();

                    // Let the user select an XML document to send
                    XmlDocument xdoc = GUI.LoadXmlDocument();
                    Response    response;

                    // Create the OIOSI message object to send, and add the mandatory MessageIdentifier header
                    OiosiMessage message = new OiosiMessage(xdoc);



                    // If the user would like to set proxy config programatically
                    if (mode == GUI.MenuChoice.Custom)
                    {
                        #region 1 - Programatically configured Request

                        // Let the user select a remote endpoint to which the document will be sent
                        Uri endpoint = GUI.GetEndpointAddress();

                        // Let the user select credentials
                        Console.WriteLine("\nPlease configure the certificate used for sending\n----------------------------------------------------");
                        X509Certificate2 clientCert = GUI.GetCertificate();
                        Console.WriteLine("\nPlease configure the certificate used by the remote endpoint\n-------------------------------------------------------------------------");
                        X509Certificate2 serverCert  = GUI.GetCertificate();
                        Credentials      credentials = new Credentials(new OcesX509Certificate(clientCert), new OcesX509Certificate(serverCert));

                        // Create the Request object
                        request = new RaspRequest(new Request(endpoint, credentials));

                        // Let the user configure his mail account
                        if (endpoint.Scheme == "mailto")
                        {
                            GUI.GetMailSettings(request);
                        }

                        // Use the OIOSI library class Request to send the document
                        Console.WriteLine("Starting to send...");

                        request.GetResponse(message, Guid.NewGuid().ToString(), out response);

                        #endregion
                    }

                    // The user would like to use the proxy settings in app.config
                    else
                    {
                        #region 2 - Request configured in App.Config

                        // Use the OIOSI library class Request to send the document
                        Console.WriteLine("Starting to send...");
                        request = new RaspRequest(new Request("OiosiHttpEndpoint"));
                        request.GetResponse(message, Guid.NewGuid().ToString(), out response);

                        #endregion
                    }

                    // Print out the reply
                    GUI.PrintResponse(response);
                }
                catch (Exception e) {
                    GUI.PrintException(e);
                }


                // Ask the user if he wants to send again
                if (!GUI.AskIfRestart())
                {
                    break;
                }

                Console.WriteLine("\n");
            }
        }
Exemplo n.º 3
0
        public bool SendDocument()
        {
            // Test logging
            ILogger loggger = LoggerFactory.Create();

            loggger.Info("Logging works.");

            bool result = false;

            try
            {
                // define the RaspConfigurationFile to use
                switch (this.uddiType)
                {
                case UddiType.Production:
                {
                    ConfigurationManager.AppSettings["RaspConfigurationFile"] = "RaspConfiguration.Live.xml";
                    Console.WriteLine("Sending the document through production uddi.");
                    break;
                }

                ////case UddiType.Test:
                ////    {
                ////        ConfigurationManager.AppSettings["RaspConfigurationFile"] = "RaspConfiguration.Test.xml";
                ////        Console.WriteLine("Sending the document through test uddi.");
                ////        break;
                ////    }

                default:
                {
                    throw new NotImplementedException("The uddiType '" + this.uddiType.ToString() + "' not regonized.");
                }
                }

                //CacheConfig v = ConfigurationHandler.GetConfigurationSection<CacheConfig>();

                // Load the document
                XmlDocument xdoc     = new XmlDocument();
                FileInfo    fileInfo = new FileInfo(this.xmlDocumentUrl);

                if (fileInfo.Exists == false)
                {
                    Console.WriteLine("Error - The file does not exist");
                    Console.WriteLine(fileInfo.FullName);
                    // this.Exit();
                    result = false;
                }
                else
                {
                    Console.WriteLine("Start sending the document.");
                    Console.WriteLine(fileInfo.FullName);

                    xdoc.Load(fileInfo.FullName);

                    // Create the OIOSI message object to send, and add the mandatory
                    // MessageIdentifier header
                    OiosiMessage message = new OiosiMessage(xdoc);

                    // Prepare the request

                    Preparation preparation = new Preparation();

                    IRaspRequest request = preparation.PrepareRequest(message, this.uddiType);

                    // Let the user configure his mail account
                    if (request.RequestUri.Scheme == "mailto")
                    {
                        throw new NotImplementedException("Mail sending not implemented - no longer part of RASP.");
                        //GUI.GetMailSettings(request);
                    }

                    // Use the OIOSI library class Request to send the document
                    Console.WriteLine("Starting to send...");
                    Response response;

                    request.GetResponse(message, Guid.NewGuid().ToString(), out response);

                    // Print out the reply
                    GUI.PrintResponse(response);

                    result = true;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
            }

            return(result);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            // Print title
            Console.Title           = "  OIOSI Extended Request Test Application  ";
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.BackgroundColor = ConsoleColor.DarkGray;
            Console.WriteLine("  OIOSI Extended Request Test Application  ");
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine();
            Console.WriteLine("Select if the test or the live NemHandel Infrastruktur should be used:");
            Console.Write(" Type 'Live' to use the live system: ");
            string answer = Console.ReadLine();

            if (string.IsNullOrEmpty(answer))
            {
                ConfigurationDocument.ConfigFilePath = "RaspConfiguration.Live.xml";
            }
            else
            {
                if (string.Equals("Live", answer, StringComparison.OrdinalIgnoreCase))
                {
                    ConfigurationDocument.ConfigFilePath = "RaspConfiguration.Live.xml";
                }
                else
                {
                    throw new NotImplementedException();
                }
                ////else
                ////{
                ////    ConfigurationDocument.ConfigFilePath = "RaspConfiguration.Test.xml";
                ////}
            }

            while (true)
            {
                try
                {
                    // Print title
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.BackgroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine("  OIOSI Extended Request Test Application  ");
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.WriteLine();

                    if (string.Equals("Live", answer, StringComparison.OrdinalIgnoreCase))
                    {
                        Console.Write("The '");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write("Live/Productiv");
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write("' NemHandel infrastruktur is used.");
                    }
                    else
                    {
                        Console.Write("The '");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write("Test");
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write("' NemHandel infrastruktur is used.");
                    }

                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine();
                    Console.WriteLine();
                    // Let the user select an XML document to send
                    XmlDocument xdoc = GUI.LoadXmlDocument();

                    // Create the OIOSI message object to send, and add the mandatory MessageIdentifier header
                    OiosiMessage message = new OiosiMessage(xdoc);

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine();
                    Console.WriteLine("File identified - Start preparing");
                    Console.ForegroundColor = ConsoleColor.White;

                    // Prepare the request
                    request = Preparation.PrepareRequest(message);

                    if (request != null)
                    {
                        // Let the user configure his mail account

                        if (request.RequestUri.Scheme == "mailto")
                        {
                            GUI.GetMailSettings(request);
                        }

                        // Use the OIOSI library class Request to send the document
                        Console.WriteLine("Starting to send...");
                        Response response;
                        request.GetResponse(message, Guid.NewGuid().ToString(), out response);

                        // Print out the reply
                        GUI.PrintResponse(response);
                    }
                }
                catch (Exception e) {
                    GUI.PrintException(e);
                }


                // Ask the user if he wants to send again
                if (!GUI.AskIfRestart())
                {
                    break;
                }

                Console.WriteLine("\n");
            }
        }