public static V1Instance GetV1Instance() { string V1Instance = ConfigurationManager.AppSettings["V1Instance"]; string V1Login = ConfigurationManager.AppSettings["V1InstanceUsername"]; string V1Password = ConfigurationManager.AppSettings["V1InstancePassword"]; string proxyServerUri = ConfigurationManager.AppSettings["proxyServerUri"]; string defaultRole = ConfigurationManager.AppSettings["V1UserDefaultRole"]; string useIntegratedAuth = ConfigurationManager.AppSettings["IntegratedAuth"]; if(!V1Instance.EndsWith("/")) V1Instance += "/"; try { IAPIConnector metaConnector; IAPIConnector dataConnector; bool useIntegrated = useIntegratedAuth.Equals("true"); logger.Info("Attaching to VersionOne at: " + V1Instance); if (!string.IsNullOrEmpty(proxyServerUri)) { ProxyProvider proxyProvider = GetProxyProvider(); metaConnector = new V1APIConnector(V1Instance + @"meta.v1/", null, null, false, proxyProvider); dataConnector = new V1APIConnector(V1Instance + @"rest-1.v1/", V1Login, V1Password, useIntegrated, proxyProvider); } else { metaConnector = new V1APIConnector(V1Instance + @"meta.v1/"); dataConnector = new V1APIConnector(V1Instance + @"rest-1.v1/", V1Login, V1Password, useIntegrated); } IMetaModel metaModel = new MetaModel(metaConnector); IServices services = new Services(metaModel, dataConnector); return new V1Instance(services, metaModel, defaultRole); } catch(Exception ex) { logger.Error(ex.Message); throw ex; } }
//Constructor: Initializes the V1 instance connection. public VersionOneClient(IntegrationConfiguration Config, Logger Logger) { _logger = Logger; _config = Config; _V1_META_URL = Config.V1Connection.Url + "/meta.v1/"; _V1_DATA_URL = Config.V1Connection.Url + "/rest-1.v1/"; V1APIConnector metaConnector = new V1APIConnector(_V1_META_URL); V1APIConnector dataConnector; //Set V1 connection based on authentication type. if (_config.V1Connection.UseWindowsAuthentication == true) { _logger.Debug("-> Connecting with Windows Authentication."); //If username is not specified, try to connect using domain credentials. if (String.IsNullOrEmpty(_config.V1Connection.Username)) { _logger.Debug("-> Connecting with default Windows domain account: {0}\\{1}", Environment.UserDomainName, Environment.UserName); dataConnector = new V1APIConnector(_V1_DATA_URL); } else { _logger.Debug("-> Connecting with specified Windows domain account: {0}", _config.V1Connection.Username); dataConnector = new V1APIConnector(_V1_DATA_URL, _config.V1Connection.Username, _config.V1Connection.Password, true); } } else { _logger.Debug("-> Connecting with V1 account credentials: {0}", _config.V1Connection.Username); dataConnector = new V1APIConnector(_V1_DATA_URL, _config.V1Connection.Username, _config.V1Connection.Password); } _v1Meta = new MetaModel(metaConnector); _v1Data = new Services(_v1Meta, dataConnector); }
public IServices CreateServices(string baseUrl, string userName, string password, bool integratedAuth = false) { var dataConnector = new V1APIConnector(baseUrl + "/rest-1.v1/", userName, password, integratedAuth); var metaConnector = new V1APIConnector(baseUrl + "/meta.v1/"); _metaModel = new MetaModel(metaConnector); var services = new Services(_metaModel, dataConnector); return services; }
private V1APIConnector PopulateHeaders(V1APIConnector connector) { IDictionary <string, string> dict = connector.CustomHttpHeaders; foreach (KeyValuePair <string, string> pair in customHttpHeaders) { dict.Add(pair.Key, pair.Value); } return(connector); }
public IV1Configuration LoadV1Configuration() { if (VersionOneSettings == null) { throw new InvalidOperationException("Connection is needed for configuration loading."); } var path = VersionOneSettings.Path; var integrated = VersionOneSettings.Integrated; var proxy = GetProxy(VersionOneSettings.ProxySettings); var apiConnector = new V1APIConnector(path + ConfigUrlSuffix, null, null, integrated, proxy); apiConnector.SetUpstreamUserAgent("VersionOne.Client.VisualStudio/9.0.0"); return new V1Configuration(apiConnector); }
public void Connect(VersionOneSettings settings) { var path = settings.Path; var username = settings.Username; var password = settings.Password; var integrated = settings.Integrated; var proxy = GetProxy(settings.ProxySettings); VersionOneSettings = settings; var metaConnector = new V1APIConnector(path + MetaUrlSuffix, username, password, integrated, proxy); MetaModel = new MetaModel(metaConnector); var localizerConnector = new V1APIConnector(path + LocalizerUrlSuffix, username, password, integrated, proxy); Localizer = new Localizer(localizerConnector); var dataConnector = new V1APIConnector(path + DataUrlSuffix, username, password, integrated, proxy); Services = new Services(MetaModel, dataConnector); V1Configuration = LoadV1Configuration(); }
/// <summary> /// Create connection to V1 server. /// </summary> /// <param name="settings">Connection settings</param> public void Connect(VersionOneSettings settings) { var url = settings.ApplicationUrl; var username = settings.Username; var password = settings.Password; var integrated = settings.IntegratedAuth; var proxy = GetProxy(settings.ProxySettings); try { var metaConnector = new V1APIConnector(url + MetaUrlSuffix, username, password, integrated, proxy); metaModel = new MetaModel(metaConnector); var dataConnector = new V1APIConnector(url + DataUrlSuffix, username, password, integrated, proxy); services = new Services(metaModel, dataConnector); IsConnected = true; ListPropertyValues = new Dictionary<string, IList<ListValue>>(); } catch (Exception) { IsConnected = false; } }
public void Connect(VersionOneSettings settings) { var path = settings.Path; var username = settings.Username; var password = settings.Password; var integrated = settings.Integrated; var proxy = GetProxy(settings.ProxySettings); VersionOneSettings = settings; if (VersionOneSettings.OAuth2) { var storage = OAuth2Client.Storage.JsonFileStorage.Default; var metaConnector = new V1OAuth2APIConnector(path + MetaUrlSuffix, storage, proxy); MetaModel = new MetaModel(metaConnector); var localizerConnector = new V1OAuth2APIConnector(path + LocalizerUrlSuffix, storage, proxy); Localizer = new Localizer(localizerConnector); var dataConnector = new V1OAuth2APIConnector(path + DataUrlSuffix, storage, proxy); Services = new Services(MetaModel, dataConnector); } else { var metaConnector = new V1APIConnector(path + MetaUrlSuffix, username, password, integrated, proxy); MetaModel = new MetaModel(metaConnector); var localizerConnector = new V1APIConnector(path + LocalizerUrlSuffix, username, password, integrated, proxy); Localizer = new Localizer(localizerConnector); var dataConnector = new V1APIConnector(path + DataUrlSuffix, username, password, integrated, proxy); Services = new Services(MetaModel, dataConnector); } V1Configuration = LoadV1Configuration(); }
//Verifies the connection to the V1 source instance. private static void VerifyV1TargetConnection() { try { _targetMetaConnector = new V1APIConnector(_config.V1TargetConnection.Url + "/meta.v1/"); if (_config.V1TargetConnection.AuthenticationType == "standard") { _targetDataConnector = new V1APIConnector(_config.V1TargetConnection.Url + "/rest-1.v1/", _config.V1TargetConnection.Username, _config.V1TargetConnection.Password, false); _targetImageConnector = new V1APIConnector(_config.V1TargetConnection.Url + "/attachment.img/", _config.V1TargetConnection.Username, _config.V1TargetConnection.Password, false); } else if (_config.V1TargetConnection.AuthenticationType == "windows") { _logger.Info("Connecting with user {0}.", System.Security.Principal.WindowsIdentity.GetCurrent().Name); _targetDataConnector = new V1APIConnector(_config.V1TargetConnection.Url + "/rest-1.v1/", null, null, true); _targetImageConnector = new V1APIConnector(_config.V1TargetConnection.Url + "/attachment.img/", null, null, true); } else if (_config.V1TargetConnection.AuthenticationType == "oauth") { throw new Exception("OAuth authentication is not supported -- yet."); } else { throw new Exception("Unable to determine the V1TargetConnection authentication type in the config file. Value used must be standard|windows|oauth."); } _targetMetaAPI = new MetaModel(_targetMetaConnector); _targetDataAPI = new Services(_targetMetaAPI, _targetDataConnector); IAssetType assetType = _targetMetaAPI.GetAssetType("Member"); Query query = new Query(assetType); IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Username"); query.Selection.Add(nameAttribute); FilterTerm idFilter = new FilterTerm(nameAttribute); idFilter.Equal(_config.V1TargetConnection.Username); query.Filter = idFilter; QueryResult result = _targetDataAPI.Retrieve(query); if (result.TotalAvaliable > 0) { _logger.Info("-> Connection to V1 target instance \"{0}\" verified.", _config.V1TargetConnection.Url); _logger.Info("-> V1 target instance version: {0}.", _targetMetaAPI.Version.ToString()); MigrationStats.WriteStat(_sqlConn, "Target API Version", _targetMetaAPI.Version.ToString()); } else { throw new Exception(String.Format("Unable to validate connection to {0} with username {1}. You may not have permission to access this instance.", _config.V1TargetConnection.Url, _config.V1TargetConnection.Username)); } } catch (Exception ex) { _logger.Error("-> Unable to connect to V1 source instance \"{0}\".", _config.V1TargetConnection.Url); throw ex; } }
public ExportAttachments(SqlConnection sqlConn, MetaModel MetaAPI, Services DataAPI, V1APIConnector ImageConnector, MigrationConfiguration Configurations) : base(sqlConn, MetaAPI, DataAPI, Configurations) { _imageConnector = ImageConnector; }
public void TestFixtureSetUp() { IAPIConnector metaConnector = new V1APIConnector(V1Url + MetaUrl, Username, Password); IAPIConnector serviceConnector = new V1APIConnector(V1Url + DataUrl, Username, Password); MetaModel = new MetaModel(metaConnector); Services = new Services(MetaModel, serviceConnector); var doc = new XmlDocument(); doc.LoadXml(string.Format(@"<Settings> <APIVersion>7.2.0.0</APIVersion> <ApplicationUrl>{0}</ApplicationUrl> <Username>{1}</Username> <Password>{2}</Password> <IntegratedAuth>false</IntegratedAuth> <ProxySettings disabled='1'> <Uri>http://proxyhost:3128</Uri> <UserName>username</UserName> <Password>password</Password> <Domain>domain</Domain> </ProxySettings> </Settings>", V1Url, Username, Password)); var loggerMock = MockRepository.Stub<ILogger>(); V1Processor = new VersionOneProcessor(doc["Settings"], loggerMock); V1Processor.AddProperty(Workitem.NumberProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Entity.NameProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Workitem.DescriptionProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Workitem.PriorityProperty, VersionOneProcessor.PrimaryWorkitemType, true); V1Processor.AddProperty(Entity.StatusProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Workitem.EstimateProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Workitem.AssetTypeProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Workitem.ParentNameProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Workitem.TeamNameProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Workitem.SprintNameProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Workitem.OrderProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Workitem.ReferenceProperty, VersionOneProcessor.PrimaryWorkitemType, false); V1Processor.AddProperty(Entity.NameProperty, VersionOneProcessor.StoryType, false); V1Processor.AddProperty(CustomFieldName, VersionOneProcessor.FeatureGroupType, false); V1Processor.AddProperty(CustomTypeName, string.Empty, true); V1Processor.AddProperty(Entity.NameProperty, VersionOneProcessor.FeatureGroupType, false); V1Processor.AddProperty(Workitem.ReferenceProperty, VersionOneProcessor.FeatureGroupType, false); V1Processor.AddProperty(VersionOneProcessor.OwnersAttribute, VersionOneProcessor.FeatureGroupType, false); V1Processor.AddProperty(FieldInfo.NameProperty, VersionOneProcessor.AttributeDefinitionType, false); V1Processor.AddProperty(FieldInfo.AssetTypeProperty, VersionOneProcessor.AttributeDefinitionType, false); V1Processor.AddProperty(FieldInfo.AttributeTypeProperty, VersionOneProcessor.AttributeDefinitionType, false); V1Processor.AddProperty(FieldInfo.IsReadOnlyProperty, VersionOneProcessor.AttributeDefinitionType, false); V1Processor.AddProperty(FieldInfo.IsRequiredProperty, VersionOneProcessor.AttributeDefinitionType, false); V1Processor.AddListProperty(CustomFieldName, VersionOneProcessor.FeatureGroupType); V1Processor.AddProperty(Entity.NameProperty, VersionOneProcessor.LinkType, false); V1Processor.AddProperty(Link.UrlProperty, VersionOneProcessor.LinkType, false); V1Processor.AddProperty(Link.OnMenuProperty, VersionOneProcessor.LinkType, false); V1Processor.AddProperty(Entity.NameProperty, VersionOneProcessor.MemberType, false); V1Processor.AddProperty(Member.EmailProperty, VersionOneProcessor.MemberType, false); //V1Processor.AddProperty(Member.DefaultRoleNameProperty, VersionOneProcessor.MemberType, false); Assert.IsTrue(V1Processor.ValidateConnection(), "Connection is not valid"); }
private V1APIConnector PrepareConnector(string url) { var connector = new V1APIConnector(url, username, password, integratedAuth, proxyProvider); return(PopulateHeaders(connector)); }
private static void Run() { V1APIConnector dataConnector = new V1APIConnector(_v1Url + DATA_API, _v1Username, _v1Password); V1APIConnector metaConnector = new V1APIConnector(_v1Url + META_API); MetaModel = new MetaModel(metaConnector); Services = new Services(MetaModel, dataConnector); //Check if we need to add TeamRooms. if (ConfigurationManager.AppSettings["UseTeamRoom"] == "true") _useTeamRoom = true; Utils.Logger.Info("Verifying configuration..."); VerifyConfiguration(); Project.HideFutureStatus(); if (_isCatalyst == false) Team.SaveTeams(Team.GetAllTeams()); //Use for loop to create multiple project sets based on config value. Each project set contains 40 distinct projects. for (int i = 0; i < _v1ProjectSetCount; i++) { Utils.Logger.Info("Creating projects..."); IList<Project> projects = Project.GetProjects(i); Utils.Logger.Info("Saving projects..."); Project.SaveProjects(projects, "Scope:0", null, null, _isUltimate, _isCatalyst, _isEnteprisePlus, _useTeamRoom); Utils.Logger.Info("Training data saved. Rolling back dates."); RollDatesBackOneDay(); Utils.Logger.Info("Dates rolled back. Saving second day of data."); SaveSecondDay(projects); Utils.Logger.Info("Second day of data saved. Rolling back dates."); RollDatesBackOneDay(); Utils.Logger.Info("Dates rolled back. Saving third day of data."); SaveThirdDay(projects); Utils.Logger.Info("Third day of data saved. Rolling back dates."); RollDatesBackOneDay(); Utils.Logger.Info("Dates rolled back. Saving fourth day of data."); SaveFourthDay(projects); Utils.Logger.Info("Fourth day of data saved. Rolling back dates."); RollDatesBackOneDay(); Utils.Logger.Info("Dates rolled back. Saving fifth day of data."); SaveFifthDay(projects); Utils.Logger.Info("Fifth day of data saved. Rolling back dates."); RollDatesBackOneDay(); Utils.Logger.Info("Dates rolled back. Saving sixth day of data."); SaveSixthDay(projects); Utils.Logger.Info("Sixth day of data saved. Rolling back dates."); RollDatesBackOneDay(); Utils.Logger.Info("Dates rolled back. Saving seventh day of data."); SaveSeventhDay(projects); Utils.Logger.Info("Seventh day of data saved."); ProcessClientSpecificData(projects); Utils.Logger.Info("Training data generation completed."); } }
private V1APIConnector PopulateHeaders(V1APIConnector connector) { IDictionary<string, string> dict = connector.CustomHttpHeaders; foreach(KeyValuePair<string, string> pair in customHttpHeaders) { dict.Add(pair.Key, pair.Value); } return connector; }
private V1APIConnector PrepareConnector(string url) { var connector = new V1APIConnector(url, username, password, integratedAuth, proxyProvider); return PopulateHeaders(connector); }