//public Configurator(string pcServerURL, string pcUserName, string pcPassword, string domain, string project,
        //    string testID, string autoTestInstance, string testInstanceID, string pcPostRunAction,
        //    string proxyURL, string proxyUserName, string proxyPassword,
        //    string trending, string trendReportID, string timeslotDurationHours, string timeslotDurationMinutes,
        //    string useSLAStatus, string useVUDs, string workDirectory = "", string logFileName = "", string description = "")
        //{
        //    _pcServerAndPort = pcServerURL.Trim().Replace("https://", "").Replace("http://", "");
        //    _pcServername = (_pcServerAndPort.LastIndexOf(':') == -1) ? _pcServerAndPort : _pcServerAndPort.Substring(0, (_pcServerAndPort.LastIndexOf(':')));
        //    _webProtocol = pcServerURL.Trim().StartsWith("https") ? "https" : "http";
        //    _pcUserName = pcUserName;
        //    _pcPassword = pcPassword;
        //    _domain = domain;
        //    _project = project;
        //    _testID = testID;
        //    _autoTestInstance = autoTestInstance;
        //    _testInstanceID = (autoTestInstance.ToLower() == "false" && testInstanceID != "Enter Test Instance ID") ? testInstanceID : "";
        //    _pcPostRunAction = pcPostRunAction;
        //    _proxyURL = proxyURL;
        //    _proxyUserName = proxyUserName;
        //    _proxyPassword = proxyPassword;
        //    _trending = trending;
        //    _trendReportID = (trending == "UseTrendReportID" && trendReportID != "Enter Trend Report ID") ? trendReportID : "";
        //    _timeslotDurationHours = timeslotDurationHours;
        //    _timeslotDurationMinutes = String.IsNullOrWhiteSpace(timeslotDurationMinutes) ? "30" : timeslotDurationMinutes;
        //    _useSLAStatus = useSLAStatus;
        //    _useVUDs = useVUDs;
        //    if (!string.IsNullOrWhiteSpace(workDirectory))
        //        _workDirectory = workDirectory;
        //    else
        //    {
        //        Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
        //        _workDirectory = string.Format(_workDirectory, unixTimestamp.ToString());
        //    }
        //    if (!string.IsNullOrWhiteSpace(logFileName))
        //        _logFileName = logFileName;
        //    var _description = description;

        //    _pcBuilder = new PCBuilder(_pcServerAndPort, _pcServername, _pcUserName, _pcPassword, _domain,
        //        _project, _testID, _autoTestInstance.ToLower() == "true", _testInstanceID, _timeslotDurationHours, _timeslotDurationMinutes,
        //        _pcPostRunAction, _useVUDs.ToLower() == "true", _useSLAStatus.ToLower() == "true", _description,
        //        _trending, _trendReportID, _webProtocol == "https",
        //        _proxyURL, _proxyUserName, _proxyPassword, _workDirectory, _logFileName);

        //    _pcRestProxy = new PCRestProxy(_webProtocol, _pcServerAndPort, domain, project, proxyURL, proxyUserName, proxyPassword);
        //}

        public static string Perform(string pcServerURL, string pcUserName, string pcPassword, string domain, string project,
                                     string testID, string autoTestInstance, string testInstanceID, string pcPostRunAction,
                                     string proxyURL, string proxyUserName, string proxyPassword,
                                     string trending, string trendReportID, string timeslotDurationHours, string timeslotDurationMinutes,
                                     string useSLAStatus, string useVUDs, string workDirectory = "", string logFileName = "", string description = "")
        {
            _pcServerAndPort         = pcServerURL.Trim().Replace("https://", "").Replace("http://", "");
            _pcServername            = (_pcServerAndPort.LastIndexOf(':') == -1) ? _pcServerAndPort : _pcServerAndPort.Substring(0, (_pcServerAndPort.LastIndexOf(':')));
            _webProtocol             = pcServerURL.Trim().StartsWith("https") ? "https" : "http";
            _pcUserName              = pcUserName;
            _pcPassword              = pcPassword;
            _domain                  = domain;
            _project                 = project;
            _testID                  = testID;
            _autoTestInstance        = autoTestInstance;
            _testInstanceID          = (autoTestInstance.ToLower() == "false" && testInstanceID != "Enter Test Instance ID") ? testInstanceID : "";
            _pcPostRunAction         = pcPostRunAction;
            _proxyURL                = proxyURL;
            _proxyUserName           = proxyUserName;
            _proxyPassword           = proxyPassword;
            _trending                = (string.IsNullOrWhiteSpace(trending) || (pcPostRunAction.Equals("DoNotCollate")))? "DoNotTrend" : trending;
            _trendReportID           = (_trending == "UseTrendReportID" && trendReportID != "Enter Trend Report ID") ? trendReportID : "";
            _timeslotDurationHours   = timeslotDurationHours;
            _timeslotDurationMinutes = String.IsNullOrWhiteSpace(timeslotDurationMinutes) ? "30" : timeslotDurationMinutes;
            _useSLAStatus            = useSLAStatus;
            _useVUDs                 = useVUDs;
            if (!string.IsNullOrWhiteSpace(workDirectory))
            {
                _workDirectory = workDirectory;
            }
            else
            {
                Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                _workDirectory = string.Format(_workDirectory, unixTimestamp.ToString());
            }
            if (!string.IsNullOrWhiteSpace(logFileName))
            {
                _logFileName = logFileName;
            }
            var _description = description;

            string message = "";

            ValidateInputFieldsSupposedToBePositiveInteger(ref message);
            if (string.IsNullOrEmpty(message))
            {
                _pcBuilder = new PCBuilder(_pcServerAndPort, _pcServername, _pcUserName, _pcPassword, _domain,
                                           _project, _testID, _autoTestInstance.ToLower() == "true", _testInstanceID, _timeslotDurationHours, _timeslotDurationMinutes,
                                           _pcPostRunAction, _useVUDs.ToLower() == "true", _useSLAStatus.ToLower() == "true", _description,
                                           _trending, _trendReportID, _webProtocol == "https",
                                           _proxyURL, _proxyUserName, _proxyPassword, _workDirectory, _logFileName);
                _pcRestProxy = new PCRestProxy(_webProtocol, _pcServerAndPort, domain, project, proxyURL, proxyUserName, proxyPassword);
                Perform();
                return(Path.Combine(_workDirectory, _logFileName));
            }
            else
            {
                throw new Exception(message);
            }
        }
示例#2
0
        private void btnAuthenticate_Click(object sender, EventArgs e)
        {
            pcRestProxy = new PCRestProxy(
                cmbWebProtocol.Text,
                txtPCServerAndPort.Text,
                txtDomain.Text,
                txtProject.Text,
                txtProxyUrl.Text,
                txtProxyUser.Text,
                txtProxyPassword.Text
                );

            bool authenticated = pcRestProxy.Authenticate(txtPCUserName.Text, txtPCPassword.Text);

            if (authenticated)
            {
                btnAuthenticate.Text      = "Authenticated";
                btnAuthenticate.BackColor = Color.Green;
            }
            else
            {
                btnAuthenticate.Text      = "Authentication failed";
                btnAuthenticate.BackColor = Color.Red;
            }
        }
        public Configurator(string pcServerURL, string useTokenForAuthentication, string pcUserName, string pcPassword, string domain, string project,
                            string testID, string autoTestInstance, string testInstanceID, string pcPostRunAction,
                            string proxyURL, string proxyUserName, string proxyPassword,
                            string trending, string trendReportID, string timeslotDurationHours, string timeslotDurationMinutes,
                            string useSLAStatus, string useVUDs, string workDirectory = "", string logFileName = "", string description = "",
                            string timeslotRepeat = "DoNotRepeat", string timeslotRepeatDelay = "5", string timeslotRepeatAttempts      = "3")
        {
            _pcServerAndPort           = pcServerURL.Trim().Replace("https://", "").Replace("http://", "");
            _useTokenForAuthentication = useTokenForAuthentication;
            _pcServername            = (_pcServerAndPort.LastIndexOf(':') == -1) ? _pcServerAndPort : _pcServerAndPort.Substring(0, (_pcServerAndPort.LastIndexOf(':')));
            _webProtocol             = pcServerURL.Trim().StartsWith("https") ? "https" : "http";
            _pcUserName              = pcUserName;
            _pcPassword              = pcPassword;
            _domain                  = domain;
            _project                 = project;
            _testID                  = testID;
            _autoTestInstance        = autoTestInstance;
            _testInstanceID          = (autoTestInstance.ToLower() == "false" && testInstanceID != "Enter Test Instance ID") ? testInstanceID : "";
            _pcPostRunAction         = pcPostRunAction;
            _proxyURL                = proxyURL;
            _proxyUserName           = proxyUserName;
            _proxyPassword           = proxyPassword;
            _trending                = trending;
            _trendReportID           = (trending == "UseTrendReportID" && trendReportID != "Enter Trend Report ID") ? trendReportID : "";
            _timeslotDurationHours   = timeslotDurationHours;
            _timeslotDurationMinutes = String.IsNullOrWhiteSpace(timeslotDurationMinutes) ? "30" : timeslotDurationMinutes;
            _useSLAStatus            = useSLAStatus;
            _useVUDs                 = useVUDs;

            if (!string.IsNullOrWhiteSpace(workDirectory))
            {
                _workDirectory = workDirectory;
            }
            else
            {
                Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                _workDirectory = string.Format(_workDirectory, unixTimestamp.ToString());
            }
            if (!string.IsNullOrWhiteSpace(logFileName))
            {
                _logFileName = logFileName;
            }
            var _description = description;

            int intTimeslotRepeatDelay;
            int intTimeslotRepeatAttempts;

            _timeslotRepeat         = "RepeatWithParameters".Equals(timeslotRepeat)? timeslotRepeat: "DoNotRepeat";
            _timeslotRepeatDelay    = int.TryParse(timeslotRepeatDelay, out intTimeslotRepeatDelay) && intTimeslotRepeatDelay > 1 ? timeslotRepeatDelay : "1";
            _timeslotRepeatAttempts = int.TryParse(timeslotRepeatAttempts, out intTimeslotRepeatAttempts) && intTimeslotRepeatAttempts > 2 ? timeslotRepeatAttempts : "2";

            _pcBuilder = new PCBuilder(_pcServerAndPort, _pcServername, _useTokenForAuthentication.ToLower() == "true", _pcUserName, _pcPassword, _domain,
                                       _project, _testID, _autoTestInstance.ToLower() == "true", _testInstanceID, _timeslotDurationHours, _timeslotDurationMinutes,
                                       _pcPostRunAction, _useVUDs.ToLower() == "true", _useSLAStatus.ToLower() == "true", _description,
                                       _trending, _trendReportID, _webProtocol == "https",
                                       _proxyURL, _proxyUserName, _proxyPassword, _workDirectory, _logFileName, _timeslotRepeat, _timeslotRepeatDelay, _timeslotRepeatAttempts);

            _pcRestProxy = new PCRestProxy(_webProtocol, _pcServerAndPort, domain, project, proxyURL, proxyUserName, proxyPassword);
        }
示例#4
0
 private void Test_Load(object sender, EventArgs e)
 {
     pcRestProxy = new PCRestProxy(
         cmbWebProtocol.Text,
         txtPCServerAndPort.Text,
         txtDomain.Text,
         txtProject.Text,
         txtProxyUrl.Text,
         txtProxyUser.Text,
         txtProxyPassword.Text
         );
     _authenticated = pcRestProxy.Authenticate(txtPCUserName.Text, txtPCPassword.Text);
 }
        public static bool TestConnection(string pcServerURL, string pcUserName, string pcPassword, string proxyURL, string proxyUserName, string proxyPassword)
        {
            _webProtocol     = pcServerURL.Trim().StartsWith("https") ? "https" : "http";
            _pcServerAndPort = pcServerURL.Trim().Replace("https://", "").Replace("http://", "");
            _pcUserName      = pcUserName;
            _pcPassword      = pcPassword;
            _proxyURL        = proxyURL;
            _proxyUserName   = proxyUserName;
            _proxyPassword   = proxyPassword;

            _pcRestProxy = new PCRestProxy(_webProtocol, _pcServerAndPort, "", "", proxyURL, proxyUserName, proxyPassword);

            return(_pcRestProxy.Authenticate(_pcUserName, _pcPassword));
        }
示例#6
0
 private void btnStartRun_Click(object sender, EventArgs e)
 {
     pcRestProxy = new PCRestProxy(
         cmbWebProtocol.Text,
         txtPCServerAndPort.Text,
         txtDomain.Text,
         txtProject.Text,
         txtProxyUrl.Text,
         txtProxyUser.Text,
         txtProxyPassword.Text
         );
     PC.Plugins.Common.PCEntities.PCRunResponse pcRunResponse = pcRestProxy.StartRun(
         int.Parse(txtPCUserName.Text),
         int.Parse(txtPCPassword.Text),
         new PC.Plugins.Common.PCEntities.PCTimeslotDuration(10),
         PC.Plugins.Common.Constants.PCConstants.PostRunActions.DoNotCollate.ToString(),
         false
         );
 }
示例#7
0
        /// <summary>
        /// constructor defining the different parameters of PCClient
        /// </summary>
        /// <param name="pcModel">IPCModel object</param>
        /// <param name="fileLog">FileLog object already defined</param>
        /// <param name="maxUnlockWait">How long to wait for the reports.zip file to be downloaded (in secondfs). Optional (default 200 seconds)</param>
        public PCClient(IPCModel pcModel, FileLog fileLog, int maxUnlockWait = 200)
        {
            try
            {
                //defining log file
                if (fileLog == null)
                {
                    Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                    _logFullFileName = Path.Combine(string.Format(_workDirectory, unixTimestamp.ToString()), _logFileName);
                    _fileLog         = new FileLog(_logFullFileName);
                }
                else
                {
                    _fileLog = fileLog;
                }

                if (_maxUnlockWait < maxUnlockWait)
                {
                    _maxUnlockWait = maxUnlockWait;
                }

                _fileLog.Write(LogMessageType.Debug, String.Format("PC.Plugins.Automation PCModel has started\n"));

                _pcModel = pcModel;

                if (!string.IsNullOrEmpty(_pcModel.ProxyOutURL))
                {
                    fileLog.Write(LogMessageType.Info, "Using proxy: " + _pcModel.ProxyOutURL);
                }
                _pcRestProxy = new PCRestProxy(_pcModel.isHTTPSProtocol(), _pcModel.PCServerAndPort, _pcModel.Domain, _pcModel.Project, _pcModel.ProxyOutURL, _pcModel.ProxyOutUser, _pcModel.ProxyOutPassword);
            }
            catch (Exception e)
            {
                fileLog.Write(LogMessageType.Error, e.Message);
            }
        }