//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);
            }
        }
        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);
        }
예제 #3
0
 public BuilderAndStrategy(IPCBuilder builder, IVentilator cooling)
 {
     objBuilder = builder;
     Ventil     = cooling;
 }