Пример #1
0
        internal static ITestLinkExtra ConnectTestLink(
            TLSConnectCmdletBase cmdlet,
            ITestLinkExtra testLinkObject)
        {
            try {

                cmdlet.WriteVerbose(cmdlet, "testing the availability of TestLink");
                testLinkObject.SayHello();

                cmdlet.WriteVerbose(cmdlet, "testing the api key");
                testLinkObject.checkDevKey(cmdlet.ApiKey);

                TLAddinData.CurrentTestLinkConnection =
                    testLinkObject;
                return testLinkObject;

            }
            catch (UriFormatException eUriFormat) {
                cmdlet.WriteVerbose(cmdlet, "Wrong Uri: " + eUriFormat.Message);
                return null;
            }
            catch (TestLinkException eTestLinkNative) {
                cmdlet.WriteVerbose(cmdlet, "Wrong Apikey: " + eTestLinkNative.Message);
                return null;
            }
            catch (Exception eTestLInk) {
                cmdlet.WriteVerbose(cmdlet, "Something went wrong: " + eTestLInk.Message);
                return null;
            }
        }
Пример #2
0
        //        public TLHelper()
        //        {
        //        }
        public static void ConnectTLServer(
            TLSConnectCmdletBase cmdlet)
        {
            string server = cmdlet.Server;

            if (null != server && string.Empty != server) {

                string connectionString =
                    "http://" +
                    server +
                    "/testlink/lib/api/xmlrpc.php";

                cmdlet.WriteVerbose(cmdlet, "Trying to connect to " + connectionString);

                string apikey = cmdlet.ApiKey;

                if (null != apikey && string.Empty != apikey) {

                    TLHelper.ConnectTestLink(
                        cmdlet,
                        (new TestLink(apikey, connectionString)));

                    if (null == TLAddinData.CurrentTestLinkConnection) {
                        cmdlet.WriteError(
                            cmdlet,
                            "Unable to connect to " +
                            "server " +
                            cmdlet.Server +
                            ".",
                            "UnableToConnect",
                            ErrorCategory.InvalidResult,
                            true);
                    }

                    cmdlet.WriteObject(cmdlet, TLAddinData.CurrentTestLinkConnection);

                } else {

                    cmdlet.WriteVerbose(cmdlet, "Wrong parameter: Apikey");
                    cmdlet.WriteError(
                        cmdlet,
                        "The Apikey parameter is wrong.",
                        "WrongParameterApikey",
                        ErrorCategory.InvalidArgument,
                        true);
                }

            } else {

                cmdlet.WriteVerbose(cmdlet, "Wrong parameter: Server");
                cmdlet.WriteError(
                    cmdlet,
                    "The Server parameter is wrong.",
                    "WrongParameterServer",
                    ErrorCategory.InvalidArgument,
                    true);
            }
        }