void GetDependenciesForWorkflowService(XElement xml) { var loadXml = xml.Descendants("XamlDefinition").ToList(); if(loadXml.Count != 1) { return; } using(var textReader = new StringReader(loadXml[0].Value)) { var errors = new StringBuilder(); try { var elementToUse = loadXml[0].HasElements ? loadXml[0] : XElement.Load(textReader, LoadOptions.None); var dependenciesFromXml = from desc in elementToUse.Descendants() where (desc.Name.LocalName.Contains("DsfDatabaseActivity") || desc.Name.LocalName.Contains("DsfPluginActivity") || desc.Name.LocalName.Contains("DsfWebserviceActivity") || desc.Name.LocalName.Contains("DsfActivity")) && desc.Attribute("UniqueID") != null select desc; var xElements = dependenciesFromXml as List<XElement> ?? dependenciesFromXml.ToList(); var count = xElements.Count(); if(count > 0) { Dependencies = new List<IResourceForTree>(); xElements.ForEach(element => { var uniqueIdAsString = element.AttributeSafe("UniqueID"); var resourceIdAsString = element.AttributeSafe("ResourceID"); var resourceName = element.AttributeSafe("ServiceName"); var actionTypeStr = element.AttributeSafe("Type"); var resourceType = GetResourceTypeFromString(actionTypeStr); Guid uniqueId; Guid.TryParse(uniqueIdAsString, out uniqueId); Guid resId; Guid.TryParse(resourceIdAsString, out resId); Dependencies.Add(CreateResourceForTree(resId, uniqueId, resourceName, resourceType)); AddRemoteServerDependencies(element); }); } AddEmailSources(elementToUse); AddDatabaseSourcesForSqlBulkInsertTool(elementToUse); } catch(Exception e) { var resName = xml.AttributeSafe("Name"); errors.AppendLine("Loading dependencies for [ " + resName + " ] caused " + e.Message); } } }
public void Init(XElement xml) { if(xml == null) { Version = new Version(1, 0); Logging = new LoggingSettings(WebServerUri); Security = new SecuritySettings(WebServerUri); Backup = new BackupSettings(WebServerUri); } else { WebServerUri = xml.AttributeSafe("WebServerUri"); Version = new Version(xml.AttributeSafe("Version")); Logging = new LoggingSettings(xml.Element(LoggingSettings.SettingName), WebServerUri); Security = new SecuritySettings(xml.Element(SecuritySettings.SettingName), WebServerUri); Backup = new BackupSettings(xml.Element(BackupSettings.SettingName), WebServerUri); } Logging.PropertyChanged += SettingChanged; Security.PropertyChanged += SettingChanged; Backup.PropertyChanged += SettingChanged; NotifyOfPropertyChange(() => HasChanges); }
public SharepointSource(XElement xml) : base(xml) { ResourceType = ResourceType.SharepointServerSource; AuthenticationType = AuthenticationType.Windows; var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Server", string.Empty }, { "AuthenticationType", string.Empty }, { "UserName", string.Empty }, { "Password", string.Empty } }; var conString = xml.AttributeSafe("ConnectionString"); var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString; ParseProperties(connectionString, properties); Server = properties["Server"]; UserName = properties["UserName"]; Password = properties["Password"]; var isSharepointSourceValue = xml.AttributeSafe("IsSharepointOnline"); bool isSharepointSource; if (bool.TryParse(isSharepointSourceValue, out isSharepointSource)) { IsSharepointOnline = isSharepointSource; } AuthenticationType authType; AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out authType) ? authType : AuthenticationType.Windows; }
public PluginSource(XElement xml) : base(xml) { ResourceType = Common.Interfaces.Data.ResourceType.PluginSource; AssemblyLocation = xml.AttributeSafe("AssemblyLocation"); AssemblyName = xml.AttributeSafe("AssemblyName"); }
public PluginSource(XElement xml) : base(xml) { ResourceType = ResourceType.PluginSource; AssemblyLocation = xml.AttributeSafe("AssemblyLocation"); AssemblyName = xml.AttributeSafe("AssemblyName"); }
public WorkflowDescriptor(XElement xml) { if(xml == null) { return; } ResourceName = xml.AttributeSafe("ResourceName"); ResourceID = xml.AttributeSafe("ResourceID"); IsSelected = true; }
/// <summary> /// Extracts the meta data. /// </summary> /// <param name="xe">The executable.</param> /// <param name="obj">The object.</param> /// <returns></returns> public static ServiceMetaData ExtractMetaData(XElement xe, ref DynamicServiceObjectBase obj) { ServiceMetaData result = new ServiceMetaData(); var tmp = ExtractValue(xe, "Category"); obj.Category = tmp; tmp = ExtractValue(xe, "DisplayName"); obj.DisplayName = tmp; tmp = ExtractValue(xe, "Comment"); obj.Comment = tmp; tmp = ExtractValue(xe, "IconPath"); obj.IconPath = tmp; tmp = ExtractValue(xe, "HelpLink"); obj.HelpLink = tmp; tmp = ExtractValue(xe, "DataList", true); obj.DataListSpecification = new StringBuilder(tmp); obj.Name = xe.AttributeSafe("Name"); return result; }
public WebSource(XElement xml) : base(xml) { ResourceType = Common.Interfaces.Data.ResourceType.WebSource; AuthenticationType = AuthenticationType.Anonymous; var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Address", string.Empty }, { "DefaultQuery", string.Empty }, { "AuthenticationType", string.Empty }, { "UserName", string.Empty }, { "Password", string.Empty } }; ParseProperties(xml.AttributeSafe("ConnectionString"), properties); Address = properties["Address"]; DefaultQuery = properties["DefaultQuery"]; UserName = properties["UserName"]; Password = properties["Password"]; AuthenticationType authType; AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out authType) ? authType : AuthenticationType.Windows; }
public WebSource(XElement xml) : base(xml) { ResourceType = ResourceType.WebSource; AuthenticationType = AuthenticationType.Anonymous; var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Address", string.Empty }, { "DefaultQuery", string.Empty }, { "AuthenticationType", string.Empty }, { "UserName", string.Empty }, { "Password", string.Empty } }; var conString = xml.AttributeSafe("ConnectionString"); var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString; ParseProperties(connectionString, properties); Address = properties["Address"]; DefaultQuery = properties["DefaultQuery"]; UserName = properties["UserName"]; Password = properties["Password"]; AuthenticationType authType; AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out authType) ? authType : AuthenticationType.Windows; }
public Connection(XElement xml) : base(xml) { ResourceType = ResourceType.Server; var conString = xml.AttributeSafe("ConnectionString"); var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString):conString; var props = connectionString.Split(';'); foreach(var p in props.Select(prop => prop.Split('=')).Where(p => p.Length >= 1)) { switch(p[0].ToLowerInvariant()) { case "appserveruri": Address = p[1]; break; case "webserverport": int port; WebServerPort = Int32.TryParse(p[1], out port) ? port : DefaultWebServerPort; break; case "authenticationtype": AuthenticationType authType; AuthenticationType = Enum.TryParse(p[1], true, out authType) ? authType : AuthenticationType.Windows; break; case "username": UserName = p[1]; break; case "password": Password = p[1]; break; } } }
public DbSource(XElement xml) : base(xml) { ResourceType = ResourceType.DbSource; // Setup type include default port switch(xml.AttributeSafe("ServerType")) { case "SqlDatabase": ServerType = enSourceType.SqlDatabase; Port = 1433; break; case "MySqlDatabase": ServerType = enSourceType.MySqlDatabase; break; default: ServerType = enSourceType.Unknown; break; } ConnectionString = xml.AttributeSafe("ConnectionString"); }
public DbSource(XElement xml) : base(xml) { ResourceType = ResourceType.DbSource; // Setup type include default port switch(xml.AttributeSafe("ServerType")) { case "SqlDatabase": ServerType = enSourceType.SqlDatabase; Port = 1433; break; case "MySqlDatabase": ServerType = enSourceType.MySqlDatabase; break; default: ServerType = enSourceType.Unknown; break; } var conString = xml.AttributeSafe("ConnectionString"); var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString; ConnectionString = connectionString; }
public OauthSource(XElement xml) : base(xml) { ResourceType = ResourceType.OauthSource; var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Secret", string.Empty }, { "Key", string.Empty } }; var conString = xml.AttributeSafe("ConnectionString"); var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString; ParseProperties(connectionString, properties); Secret = properties["Secret"]; Key = properties["Key"]; }
public static Guid SetID(ref XElement xe) { Guid id = new Guid(); var tmpId = xe.AttributeSafe("ID"); if(!string.IsNullOrEmpty(tmpId)) { Guid.TryParse(tmpId, out id); } else { xe.Add(new XAttribute("ID", id.ToString())); } return id; }
Node CreateNode(XElement nodeElm, string resourceName, double width, double height, ref double count) { double screenWidth = width; double screenHeight = height - 150; int centerX = Convert.ToInt32(screenWidth / 2); int centerY = Convert.ToInt32(screenHeight / 2); int maxX = Convert.ToInt32(screenWidth); int maxY = Convert.ToInt32(screenHeight); const int Distance = 300; Point centerPoint = new Point(centerX, centerY); double x; double y; var tmpX = nodeElm.AttributeSafe("x"); var tmpY = nodeElm.AttributeSafe("y"); double.TryParse(tmpX, out x); double.TryParse(tmpY, out y); string id = nodeElm.Attribute("id").Value; bool isTarget = id == resourceName; bool broken = String.Equals(nodeElm.Attribute("broken").Value, "true", StringComparison.OrdinalIgnoreCase); if(isTarget) { x = centerX; y = centerY; } else { if(count > Distance) { count = 1.5; } int xCoOrd = ((int)Math.Round(centerPoint.X - Distance * Math.Sin(count))); int yCoOrd = ((int)Math.Round(centerPoint.Y - Distance * Math.Cos(count))); if(xCoOrd >= maxX) { xCoOrd = maxX; } if(yCoOrd >= maxY) { yCoOrd = maxY; } x = xCoOrd; y = yCoOrd; count++; } return new Node(id, x, y, isTarget, broken); }
public LoggingSettings(XElement xml, string webserverUri) : base(xml, webserverUri) { IsInitializing = true; var postWorkflow = xml.Element("PostWorkflow"); bool boolValue; int intValue; IsLoggingEnabled = bool.TryParse(xml.AttributeSafe("IsLoggingEnabled"), out boolValue) && boolValue; IsVersionLogged = bool.TryParse(xml.AttributeSafe("IsVersionLogged"), out boolValue) && boolValue; IsTypeLogged = bool.TryParse(xml.AttributeSafe("IsTypeLogged"), out boolValue) && boolValue; IsDurationLogged = bool.TryParse(xml.AttributeSafe("IsDurationLogged"), out boolValue) && boolValue; IsDataAndTimeLogged = bool.TryParse(xml.AttributeSafe("IsDataAndTimeLogged"), out boolValue) && boolValue; IsInputLogged = bool.TryParse(xml.AttributeSafe("IsInputLogged"), out boolValue) && boolValue; IsOutputLogged = bool.TryParse(xml.AttributeSafe("IsOutputLogged"), out boolValue) && boolValue; NestedLevelCount = Int32.TryParse(xml.AttributeSafe("NestedLevelCount"), out intValue) ? intValue : 0; LogAll = bool.TryParse(xml.AttributeSafe("LogAll"), out boolValue) && boolValue; LogFileDirectory = xml.AttributeSafe("LogFileDirectory"); ServiceInput = xml.AttributeSafe("ServiceInput"); var workflows = xml.Element("Workflows"); if (workflows != null) { foreach (var workflow in workflows.Elements()) { Workflows.Add(new WorkflowDescriptor(workflow)); } } if (postWorkflow != null) { PostWorkflow = new WorkflowDescriptor(xml.Element("PostWorkflow")); } RunPostWorkflow = PostWorkflow != null; IsInitializing = false; }
public EmailSource(XElement xml) : base(xml) { ResourceType = ResourceType.EmailSource; Timeout = DefaultTimeout; Port = DefaultPort; var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Host", string.Empty }, { "UserName", string.Empty }, { "Password", string.Empty }, { "Port", string.Empty }, { "EnableSsl", string.Empty }, { "Timeout", string.Empty }, }; var conString = xml.AttributeSafe("ConnectionString"); var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString; ParseProperties(connectionString, properties); Host = properties["Host"]; UserName = properties["UserName"]; Password = properties["Password"]; int port; Port = Int32.TryParse(properties["Port"], out port) ? port : DefaultPort; bool enableSsl; EnableSsl = bool.TryParse(properties["EnableSsl"], out enableSsl) && enableSsl; int timeout; Timeout = Int32.TryParse(properties["Timeout"], out timeout) ? timeout : DefaultTimeout; }
void AddRemoteServerDependencies(XElement element) { var environmentIdString = element.AttributeSafe("EnvironmentID"); Guid environmentId; if(Guid.TryParse(environmentIdString, out environmentId) && environmentId != Guid.Empty) { if(environmentId == Guid.Empty) return; var resourceName = element.AttributeSafe("FriendlySourceName"); Dependencies.Add(CreateResourceForTree(environmentId, Guid.Empty, resourceName, ResourceType.Server)); } }
protected SettingsBase(XElement xml,string webServerUri) { if(xml == null) { throw new ArgumentNullException("xml"); } var displayName = xml.AttributeSafe("DisplayName"); if(string.IsNullOrEmpty(displayName)) { throw new NoNullAllowedException("displayName"); } if (string.IsNullOrEmpty(webServerUri)) { throw new NoNullAllowedException("webServerUri"); } SettingName = xml.Name.LocalName; DisplayName = displayName; WebServerUri = webServerUri; }
public Resource(XElement xml) { if(xml == null) { throw new ArgumentNullException("xml"); } Guid resourceId; if(!Guid.TryParse(xml.AttributeSafe("ID"), out resourceId)) { // This is here for legacy XML! resourceId = Guid.NewGuid(); IsUpgraded = true; } ResourceID = resourceId; ResourceType = ParseResourceType(xml.AttributeSafe("ResourceType")); ResourceName = xml.AttributeSafe("Name"); ResourcePath = xml.ElementSafe("Category"); ResourcePath = ResourcePath.Replace("\\\\", "\\"); if (String.IsNullOrEmpty(ResourcePath)) { ResourcePath = ResourceName; } VersionInfo = String.IsNullOrEmpty( xml.ElementStringSafe("VersionInfo"))?null: new VersionInfo(xml.ElementStringSafe("VersionInfo"), ResourceID); AuthorRoles = xml.ElementSafe("AuthorRoles"); // This is here for legacy XML! if(ResourceType == ResourceType.Unknown) { #region Check source type var sourceTypeStr = xml.AttributeSafe("Type"); enSourceType sourceType; if(Enum.TryParse(sourceTypeStr, out sourceType)) { switch(sourceType) { case enSourceType.Dev2Server: ResourceType = ResourceType.Server; IsUpgraded = true; break; case enSourceType.SqlDatabase: case enSourceType.MySqlDatabase: ResourceType = ResourceType.DbSource; IsUpgraded = true; break; case enSourceType.Plugin: ResourceType = ResourceType.PluginSource; IsUpgraded = true; break; } } #endregion #region Check action type var actions = xml.Element("Actions"); var action = actions != null ? actions.Descendants().FirstOrDefault() : xml.Element("Action"); if(action != null) { var actionTypeStr = action.AttributeSafe("Type"); ResourceType = GetResourceTypeFromString(actionTypeStr); IsUpgraded = true; } #endregion } var isValidStr = xml.AttributeSafe("IsValid"); bool isValid; if(bool.TryParse(isValidStr, out isValid)) { IsValid = isValid; } UpdateErrorsBasedOnXML(xml); LoadDependencies(xml); ReadDataList(xml); GetInputsOutputs(xml); SetIsNew(xml); }
void GetDependenciesForWorkerService(XElement xml) { var loadXml = xml.Descendants("Actions").ToList(); if(loadXml.Count != 1) { return; } using(var textReader = new StringReader(loadXml[0].Value)) { var errors = new StringBuilder(); try { var elementToUse = loadXml[0].HasElements ? loadXml[0] : XElement.Load(textReader, LoadOptions.None); var dependenciesFromXml = from desc in elementToUse.Descendants() where desc.Name.LocalName.Contains("Action") && desc.Attribute("SourceID") != null select desc; var xElements = dependenciesFromXml as List<XElement> ?? dependenciesFromXml.ToList(); var count = xElements.Count(); if(count > 0) { Dependencies = new List<IResourceForTree>(); xElements.ForEach(element => { var uniqueIdAsString = element.AttributeSafe("SourceID"); var resourceIdAsString = element.AttributeSafe("ResourceID"); var resourceName = element.AttributeSafe("SourceName"); var actionTypeStr = element.AttributeSafe("Type"); var resourceType = GetResourceTypeFromString(actionTypeStr); Guid uniqueId; Guid.TryParse(uniqueIdAsString, out uniqueId); Guid resId; Guid.TryParse(resourceIdAsString, out resId); if(resourceType == ResourceType.WebService) { resId = uniqueId; } Dependencies.Add(CreateResourceForTree(resId, uniqueId, resourceName, resourceType)); }); } } catch(Exception e) { var resName = xml.AttributeSafe("Name"); errors.AppendLine("Loading dependencies for [ " + resName + " ] caused " + e.Message); } } }