コード例 #1
0
        public async Task InitializeConnection(IWriteToOutput writeToOutput, StringBuilder content, string messageConnection1 = null, string messageConnection2 = null)
        {
            bool service1IsNull = this.Service1 == null;
            bool service2IsNull = this.Service2 == null;

            {
                var mess1 = messageConnection1;
                if (string.IsNullOrEmpty(mess1))
                {
                    mess1 = Properties.OutputStrings.ConnectingToCRM;
                }

                var mess2 = Connection1.GetConnectionDescription();

                if (service1IsNull)
                {
                    writeToOutput.WriteToOutput(null, mess1);
                    writeToOutput.WriteToOutput(null, mess2);

                    this.Service1 = await QuickConnection.ConnectAsync(Connection1);
                }

                var mess3 = string.Format(Properties.OutputStrings.CurrentServiceEndpointFormat1, this.Service1.CurrentServiceEndpoint);

                if (service1IsNull)
                {
                    writeToOutput.WriteToOutput(null, mess3);
                }

                if (content != null)
                {
                    content.AppendLine(mess1);
                    content.AppendLine(mess2);
                    content.AppendLine(mess3);
                }
            }

            if (service1IsNull)
            {
                writeToOutput.WriteToOutput(null, string.Empty);
            }

            if (content != null)
            {
                content.AppendLine();
            }

            {
                var mess1 = messageConnection2;
                if (string.IsNullOrEmpty(mess1))
                {
                    mess1 = Properties.OutputStrings.ConnectingToCRM;
                }
                var mess2 = Connection2.GetConnectionDescription();

                if (service2IsNull)
                {
                    writeToOutput.WriteToOutput(null, mess1);
                    writeToOutput.WriteToOutput(null, mess2);

                    this.Service2 = await QuickConnection.ConnectAsync(Connection2);
                }

                var mess3 = string.Format(Properties.OutputStrings.CurrentServiceEndpointFormat1, this.Service2.CurrentServiceEndpoint);

                if (service2IsNull)
                {
                    writeToOutput.WriteToOutput(null, mess3);
                }

                if (content != null)
                {
                    content.AppendLine(mess1);
                    content.AppendLine(mess2);
                    content.AppendLine(mess3);
                }
            }

            if (content != null)
            {
                content.AppendLine();
            }
        }
コード例 #2
0
 public void HandleConnectionTest(ConnectionData connectionData)
 {
     GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => QuickConnection.TestConnectAsync(conn, this, null));
 }