本文整理汇总了C#中IEnvironmentModel.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# IEnvironmentModel.Connect方法的具体用法?C# IEnvironmentModel.Connect怎么用?C# IEnvironmentModel.Connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnvironmentModel
的用法示例。
在下文中一共展示了IEnvironmentModel.Connect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deploy
/// <summary>
/// Deploys the <see cref="IResourceModel" />'s represented by the given DTO.
/// </summary>
/// <param name="deployDto">The DTO to be deployed.</param>
/// <param name="environmentModel">The environment model to be queried.</param>
public void Deploy(IDeployDto deployDto, IEnvironmentModel environmentModel)
{
if(deployDto == null || deployDto.ResourceModels == null || environmentModel == null || environmentModel.ResourceRepository == null)
{
return;
}
if(!environmentModel.IsConnected)
{
environmentModel.Connect();
}
if(environmentModel.IsConnected)
{
foreach(var resourceModel in deployDto.ResourceModels)
{
environmentModel.ResourceRepository.DeployResource(resourceModel);
}
}
}
示例2: LookupEnvironments
/// <summary>
/// Lookups the environments.
/// <remarks>
/// If <paramref name="environmentGuids"/> is <code>null</code> or empty then this returns all <see cref="enSourceType.Dev2Server"/> sources.
/// </remarks>
/// </summary>
/// <param name="defaultEnvironment">The default environment.</param>
/// <param name="environmentGuids">The environment guids to be queried; may be null.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">defaultEnvironment</exception>
public IList<IEnvironmentModel> LookupEnvironments(IEnvironmentModel defaultEnvironment, IList<string> environmentGuids = null)
{
if (defaultEnvironment == null)
{
throw new ArgumentNullException("defaultEnvironment");
}
var result = new List<IEnvironmentModel>();
try
{
defaultEnvironment.Connect();
}
// ReSharper disable EmptyGeneralCatchClause
catch (Exception err)
// ReSharper restore EmptyGeneralCatchClause
{
Dev2Logger.Log.Info((err));
//Swallow exception for localhost connection
}
if (!defaultEnvironment.IsConnected)
{
return result;
}
var hasEnvironmentGuids = environmentGuids != null;
if (hasEnvironmentGuids)
{
var servers = defaultEnvironment.ResourceRepository.FindResourcesByID(defaultEnvironment, environmentGuids, ResourceType.Source);
foreach (var env in servers)
{
var payload = env.WorkflowXaml;
if (payload != null)
{
#region Parse connection string values
// Let this use of strings go, payload should be under the LOH size limit if 85k bytes ;)
XElement xe = XElement.Parse(payload.ToString());
var conStr = xe.AttributeSafe("ConnectionString");
Dictionary<string, string> connectionParams = ParseConnectionString(conStr);
string tmp;
if (!connectionParams.TryGetValue("AppServerUri", out tmp))
{
continue;
}
Uri appServerUri;
try
{
appServerUri = new Uri(tmp);
}
catch
{
continue;
}
if (!connectionParams.TryGetValue("WebServerPort", out tmp))
{
continue;
}
int webServerPort;
if (!int.TryParse(tmp, out webServerPort))
{
continue;
}
if (!connectionParams.TryGetValue("AuthenticationType", out tmp))
{
tmp = "";
}
AuthenticationType authenticationType;
if (!Enum.TryParse(tmp, true, out authenticationType))
{
authenticationType = AuthenticationType.Windows;
}
string userName;
connectionParams.TryGetValue("UserName", out userName);
string password;
connectionParams.TryGetValue("Password", out password);
#endregion
var environment = CreateEnvironmentModel(env.ID, appServerUri, authenticationType, userName, password, env.DisplayName);
result.Add(environment);
}
}
}
else
{
//.........这里部分代码省略.........
示例3: EnsureEnvironmentConnected
static void EnsureEnvironmentConnected(IEnvironmentModel environmentModel)
{
var i = 0;
while(!environmentModel.IsConnected)
{
environmentModel.Connect();
Thread.Sleep(1000);
i++;
if (i == 30)
{
Assert.Fail("Server {0} did not connect within 30 secs{1}", environmentModel.DisplayName,DateTime.Now);
}
}
}
示例4: ShowDialog
public static bool ShowDialog(IEnvironmentModel environment, ResourceType resourceType, string resourcePath, string cateogy, string resourceId = null, string srcId = null, string resourceName = null)
{
const int ServiceDialogHeight = 582;
const int ServiceDialogWidth = 941;
bool? isSuccessful = true;
if(environment == null)
{
throw new ArgumentNullException("environment");
}
// Silly people not checking for nulls on properties that warper other properties?! ;)
if(environment.Connection == null)
{
if(!environment.IsConnected)
{
environment.Connect();
}
// server must not be up, just do nothing ;)
if(!environment.IsConnected)
{
return false;
}
// else we managed to connect ;)
}
if(environment.Connection != null)
{
var workspaceId = GlobalConstants.ServerWorkspaceID;
string pageName;
WebsiteCallbackHandler pageHandler;
double width;
double height;
string leftTitle = string.Empty;
string rightTitle = environment.Name + " (" + environment.Connection.AppServerUri + ")";
switch(resourceType)
{
case ResourceType.Server:
pageName = "sources/server";
pageHandler = new ConnectCallbackHandler();
if(!String.IsNullOrEmpty(resourceId) && !String.IsNullOrEmpty(resourceName))
{
leftTitle = "Edit - " + resourceName;
}
else
{
leftTitle = "New Server";
}
width = 704;
height = 520;
break;
case ResourceType.ServerSource:
pageName = "sources/server";
pageHandler = new ConnectCallbackHandler();
if(!String.IsNullOrEmpty(resourceId) && !String.IsNullOrEmpty(resourceName))
{
leftTitle = "Edit - " + resourceName;
}
else
{
leftTitle = "New Server";
}
width = 704;
height = 520;
break;
case ResourceType.DbService:
pageName = "services/dbservice";
pageHandler = new DbServiceCallbackHandler();
width = ServiceDialogWidth;
height = ServiceDialogHeight;
break;
case ResourceType.DbSource:
pageName = "sources/dbsource";
srcId = resourceId;
pageHandler = new SourceCallbackHandler();
width = 704;
height = 517;
if(!String.IsNullOrEmpty(resourceId) && !String.IsNullOrEmpty(resourceName))
{
leftTitle = "Edit - " + resourceName;
}
else
{
leftTitle = "New Datbase Source";
}
break;
case ResourceType.PluginService:
pageName = "services/pluginservice";
pageHandler = new ServiceCallbackHandler();
width = ServiceDialogWidth;
height = ServiceDialogHeight;
break;
//.........这里部分代码省略.........