/// <summary>
		/// The execute query simple.
		/// </summary>
		/// <param name="query">The query.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <param name="version">The version.</param>
		/// <param name="progress">The progress.</param>
		/// <param name="groups">The groups.</param>
		/// <returns>
		/// The <see cref="QueryInstanceResultInfo" />.
		/// </returns>
		public QueryInstanceResultInfo ExecuteQuerySimple(
			QueryInfo                query,
			QueryExecutionParams     parameters,
			InstanceVersion          version,
			ProgressItem             progress,
			params GroupDefinition[] groups
		)
		{
			// Log.InfoFormat("73:query:'{0}'",
			// 	query
			// );

			QueryInstanceResultInfo result = new QueryInstanceResultInfo(this.Instance);
			QueryItemInfo queryItem        = query.Items.GetQueryItemForVersion(version);

			this.PrepareProgress(progress, groups);

			this.ExecuteQuery(
				query,
				parameters,
				progress,
				groups,
				result,
				queryItem
			);

			return result;
		}
Exemplo n.º 2
0
        /// <summary>
        /// The execute query simple.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="parameterValues">The parameter values.</param>
        /// <param name="version">The version.</param>
        /// <param name="progress">The progress.</param>
        /// <param name="groups">The groups.</param>
        /// <returns>
        /// The <see cref="QueryInstanceResultInfo" />.
        /// </returns>
        public QueryInstanceResultInfo ExecuteQuerySimple(
            QueryInfo query,
            QueryExecutionParams parameters,
            InstanceVersion version,
            ProgressItem progress,
            params GroupDefinition[] groups
            )
        {
            // Log.InfoFormat("73:query:'{0}'",
            //  query
            // );

            QueryInstanceResultInfo result    = new QueryInstanceResultInfo(this.Instance);
            QueryItemInfo           queryItem = query.Items.GetQueryItemForVersion(version);

            this.PrepareProgress(progress, groups);

            this.ExecuteQuery(
                query,
                parameters,
                progress,
                groups,
                result,
                queryItem
                );

            return(result);
        }
        /// <inheritdoc />
        protected override QueryItemInfo GetQueryForGroups(QueryInfo query, InstanceVersion version)
        {
            if (query.GroupSelect != null && query.GroupSelect.Count > 0)
            {
                return query.GroupSelect.GetQueryItemForVersion(version);
            }

            return query.DatabaseSelect.GetQueryItemForVersion(version);
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        protected override QueryItemInfo GetQueryForGroups(QueryInfo query, InstanceVersion version)
        {
            if (query.GroupSelect != null && query.GroupSelect.Count > 0)
            {
                return(query.GroupSelect.GetQueryItemForVersion(version));
            }

            return(query.DatabaseSelect.GetQueryItemForVersion(version));
        }
		/// <summary>
		/// The get groups.
		/// </summary>
		/// <param name="query">
		/// The query information.
		/// </param>
		/// <param name="parameterValues">
		/// The parameter values.
		/// </param>
		/// <param name="version">
		/// The version.
		/// </param>
		/// <returns>
		/// The <see cref="Dictionary{TKey,TValue}"/>.
		/// </returns>
		public virtual ICollection<GroupDefinition> GetGroups(
			QueryInfo                   query,
			IEnumerable<ParameterValue> parameterValues,
			InstanceVersion             version
		)
		{
			var groups = new List<GroupDefinition>();

			// TODO: Create GroupDefinition with childrens
			QueryItemInfo selectGroupsSql = this.GetQueryForGroups(query, version);

			if (selectGroupsSql != null)
			{
				try
				{
					var paramsArray = parameterValues as ParameterValue[] ?? parameterValues.ToArray();

					DataTable[] groupsTabels = this.ExecuteSqlFunction(
						this.Instance,
						selectGroupsSql,
						null,
						query.Parameters,
						paramsArray,
						null,
						true
					);

					foreach (DataTable groupTable in groupsTabels)
					{
						this.AddGroupsFromTable(groupTable, groups);
					}

					if (selectGroupsSql.ChildGroups.IsNullOrEmpty())
					{
						return groups;
					}

					foreach (GroupDefinition groupDefinition in groups)
					{
						this.GetChildGroupsDefinitions(selectGroupsSql, groupDefinition, paramsArray, version);
					}
				}
				catch (OperationCanceledException ex)
				{
					log.Error(ex);
					throw;
				}
				catch (Exception ex)
				{
					log.Error("instance=" + this.Instance.Name + " query=" + query, ex);
				}
			}

			return groups;
		}
        /// <summary>
        /// The get groups.
        /// </summary>
        /// <param name="query">
        /// The query information.
        /// </param>
        /// <param name="parameterValues">
        /// The parameter values.
        /// </param>
        /// <param name="version">
        /// The version.
        /// </param>
        /// <returns>
        /// The <see cref="Dictionary{TKey,TValue}"/>.
        /// </returns>
        public virtual ICollection <GroupDefinition> GetGroups(
            QueryInfo query,
            IEnumerable <ParameterValue> parameterValues,
            InstanceVersion version
            )
        {
            var groups = new List <GroupDefinition>();

            // TODO: Create GroupDefinition with childrens
            QueryItemInfo selectGroupsSql = this.GetQueryForGroups(query, version);

            if (selectGroupsSql != null)
            {
                try
                {
                    var paramsArray = parameterValues as ParameterValue[] ?? parameterValues.ToArray();

                    DataTable[] groupsTabels = this.ExecuteSqlFunction(
                        this.Instance,
                        selectGroupsSql,
                        null,
                        query.Parameters,
                        paramsArray,
                        null,
                        true
                        );

                    foreach (DataTable groupTable in groupsTabels)
                    {
                        this.AddGroupsFromTable(groupTable, groups);
                    }

                    if (selectGroupsSql.ChildGroups.IsNullOrEmpty())
                    {
                        return(groups);
                    }

                    foreach (GroupDefinition groupDefinition in groups)
                    {
                        this.GetChildGroupsDefinitions(selectGroupsSql, groupDefinition, paramsArray, version);
                    }
                }
                catch (OperationCanceledException ex)
                {
                    log.Error(ex);
                    throw;
                }
                catch (Exception ex)
                {
                    log.Error("instance=" + this.Instance.Name + " query=" + query, ex);
                }
            }

            return(groups);
        }
 /// <inheritdoc />
 public override ICollection<GroupDefinition> GetGroups(QueryInfo query, IEnumerable<ParameterValue> values, InstanceVersion i)
 {
     return new List<GroupDefinition>()
                {
                    new GroupDefinition(this.Instance, string.Empty, string.Empty)
                        {
                            GroupType
                                =
                                QueryScope
                                .Instance
                        }
                };
 }
        /// <summary>
        /// The get child groups definitions.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="parentDefinition">The parent definition.</param>
        /// <param name="parameterValues">The parameter values.</param>
        /// <param name="version">The version.</param>
        private void GetChildGroupsDefinitions(
            QueryItemInfo parent,
            GroupDefinition parentDefinition,
            IEnumerable <ParameterValue> parameterValues,
            InstanceVersion version
            )
        {
            QueryItemInfo childGroupSql = parent.ChildGroups.GetQueryItemForVersion(version);
            var           tempParams    = parameterValues.ToList();

            tempParams.AddRange(this.GetParametersFromDefinition(parentDefinition));

            try
            {
                DataTable[] groupsTabels = this.ExecuteSqlFunction(
                    this.Instance,
                    childGroupSql,
                    null,
                    childGroupSql.Parameters,
                    tempParams,
                    null,
                    true
                    );

                foreach (DataTable groupTable in groupsTabels)
                {
                    this.AddGroupsFromTable(groupTable, parentDefinition.ChildGroups);
                }

                if (childGroupSql.ChildGroups == null || childGroupSql.ChildGroups.Count <= 0)
                {
                    return;
                }

                foreach (GroupDefinition childGroup in parentDefinition.ChildGroups)
                {
                    this.GetChildGroupsDefinitions(childGroupSql, childGroup, tempParams, version);
                }
            }
            catch (OperationCanceledException ex)
            {
                log.Error(ex);
                throw;
            }
            catch (Exception ex)
            {
                log.Error("instance=" + this.Instance.Name + " query=" + childGroupSql, ex);
            }
        }
Exemplo n.º 9
0
        private List <InstanceInfo> ExecuteSelectInstancesCommand(SQLiteConnection connection, string sql)
        {
            List <InstanceInfo> result = new List <InstanceInfo>();

            new SqlSelectCommand(
                connection,
                sql,
                reader =>
            {
                InstanceVersion version = new InstanceVersion(reader[ServerInstanceDirectory.ServerInstanceVersionFn].ToString());

                ServerProperties props = new ServerProperties(
                    version,
                    reader[ServerInstanceDirectory.ServerInstanceNameFn].ToString(),
                    DateTime.Now
                    );

                AuthenticationInfo auth = new AuthenticationInfo
                {
                    IsWindows = (bool)reader[LoginDirectory.IsWinAuthFn],
                    Username  = reader[LoginDirectory.LoginFn].ToString(),
                    Password  = this._cryptoService.Decrypt(reader[LoginDirectory.PasswordFn].ToString())
                };

                result.Add(
                    new InstanceInfo(props)
                {
                    Authentication = auth,
                    Instance       = reader[ServerInstanceDirectory.ConnectionNameFn].ToString(),
                    IsEnabled      = true,
                    Name           = reader[ServerInstanceDirectory.ConnectionNameFn].ToString(),
                    DbType         = reader[ServerInstanceDirectory.DbTypeFn].ToString(),
                    IsODBC         = (bool)reader[ServerInstanceDirectory.IsOdbcFn]
                }
                    );
            }
                ).Execute(100);

            return(result);
        }
Exemplo n.º 10
0
        /// <summary>
        /// The execute query.
        /// </summary>
        /// <param name="query">The query info.</param>
        /// <param name="parameterValues">The parameter values.</param>
        /// <param name="version">The version.</param>
        /// <param name="progress">The progress.</param>
        /// <returns>
        /// The <see cref="QueryInstanceResultInfo" />.
        /// </returns>
        public QueryInstanceResultInfo ExecuteQuery(
            QueryInfo query,
            QueryExecutionParams parameters,
            InstanceVersion version,
            ProgressItem progress
            )
        {
            // Log.InfoFormat("107:query:'{0}'",
            //  query
            // );

            var groups = this
                         .GetGroupsResolver()
                         .GetGroups(query, parameters.Values, version);

            return(this.ExecuteQuerySimple(
                       query,
                       parameters,
                       version,
                       progress,
                       groups.ToArray()
                       ));
        }
Exemplo n.º 11
0
        private string GetDeploymentSteps(Instance instance, string version)
        {
            // Create a new string builder that
            // contains the result html string.
            StringBuilder result = new StringBuilder();

            InstanceVersion toVersion = new InstanceVersion(version);

            int i = 0;

            foreach (string server in instance.Servers)
            {
                result.Append(string.Format(
                                  Global.LanguageManager.GetText("DeploymentStep1"),
                                  i++,
                                  instance.Owner.Servers.Items[server].Description,
                                  instance.Name
                                  ));

                result.Append(string.Format(
                                  Global.LanguageManager.GetText("DeploymentStep2"),
                                  i++,
                                  instance.Owner.Servers.Items[server].Description,
                                  instance.Name,
                                  toVersion
                                  ));

                result.Append(string.Format(
                                  Global.LanguageManager.GetText("DeploymentStep3"),
                                  i++,
                                  instance.Owner.Servers.Items[server].Description,
                                  instance.Name
                                  ));
            }

            return(result.ToString());
        }
        private void CreateClient(HttpContext context)
        {
            // Get the client name from
            // the http request's parameters.
            string clientName = context.Request.Params["Client"];

            // Get the source instance name from
            // the http request's parameters.
            string instanceName = context.Request.Params["Instance"];

            string hostname = string.Format(
                ConfigurationManager.AppSettings["Hostname"],
                clientName
                );

            InstanceCollection instances = new InstanceCollection(
                ConfigurationManager.AppSettings["InstanceRoot"]
                );

            if (!instances.Instances.ContainsKey(instanceName))
            {
                context.Response.Write("__ERROR__Instance does not exist on the server.");
                return;
            }

            Instance instance = instances.Instances[instanceName];

            ClientManager clientManager = new ClientManager(Path.Combine(
                                                                ConfigurationManager.AppSettings["InstanceRoot"],
                                                                instanceName,
                                                                "App_Data",
                                                                "Clients.xml"
                                                                ));

            clientManager.Append(
                clientName.ToLower(),
                clientName,
                hostname,
                "#6CAEE0",
                "#FCB040",
                DateTime.Today.ToString("dd-MM-yyyy"),
                context.Request.Params["Servers"]
                );

            InstanceVersion version = new InstanceVersion(instance.Version);

            string databaseScriptsDirectory = Path.Combine(
                context.Request.PhysicalApplicationPath,
                "App_Data",
                "ClientCreation",
                version.ToString(),
                "DATABASE"
                );

            while (!Directory.Exists(databaseScriptsDirectory))
            {
                version -= 1;

                if (version.ToString() == "0.0.0.0")
                {
                    return;
                }

                databaseScriptsDirectory = Path.Combine(
                    context.Request.PhysicalApplicationPath,
                    "App_Data",
                    "ClientCreation",
                    version.ToString(),
                    "DATABASE"
                    );
            }

            string databaseRoot = ConfigurationManager.AppSettings["DatabaseRoot"];

            int i = 0;

            foreach (string scriptFile in Directory.GetFiles(databaseScriptsDirectory))
            {
                string script = File.ReadAllText(scriptFile);
                script = script.Replace("###CLIENTNAME###", clientName);
                script = script.Replace("###DATABASEROOT###", databaseRoot);

                ExecuteQuery(
                    i == 0 ? "master" : clientName,
                    script
                    );

                i++;
            }

            string fileSystemRoot = Path.Combine(
                context.Request.PhysicalApplicationPath,
                "App_Data",
                "ClientCreation",
                version.ToString(),
                "FILESYSTEM"
                );

            foreach (string directory in Directory.GetDirectories(fileSystemRoot))
            {
                string target = directory.Replace(
                    fileSystemRoot, Path.Combine(
                        ConfigurationManager.AppSettings["InstanceRoot"],
                        instanceName
                        ));

                CopyDirectory(
                    directory,
                    target,
                    clientName
                    );
            }

            try
            {
                IISBindings iisBindings = new IISBindings();
                iisBindings.AddBindings(instanceName, hostname);
            }
            catch { }

            string caseDataDirectory = Path.Combine(
                ConfigurationManager.AppSettings["CaseDataPath"],
                clientName
                );

            if (!Directory.Exists(caseDataDirectory))
            {
                Directory.CreateDirectory(caseDataDirectory);
            }

            ExecuteQuery(clientName,
                         "INSERT INTO [Roles] (Id, CreationDate, Name, Description) " +
                         "VALUES ({0}, {1}, {2}, {3})",
                         Guid.Parse("00000000-0000-0000-0000-000000000000"),
                         DateTime.Now,
                         "Administrators",
                         "Blueocean administrators"
                         );

            XmlDocument document = new XmlDocument();

            document.Load(Path.Combine(
                              ConfigurationManager.AppSettings["InstanceRoot"],
                              instanceName,
                              "App_Data",
                              "Permissions.xml"
                              ));

            foreach (XmlNode xmlNodePermission in document.SelectNodes("//Permission"))
            {
                ExecuteQuery(clientName,
                             "INSERT INTO [RolePermissions] (Id, IdRole, Permission, CreationDate) " +
                             "VALUES (NEWID(), {0}, {1}, {2})",
                             Guid.Parse("00000000-0000-0000-0000-000000000000"),
                             int.Parse(xmlNodePermission.Attributes["Id"].Value),
                             DateTime.Now
                             );
            }
        }
 /// <inheritdoc />
 protected override QueryItemInfo GetQueryForGroups(QueryInfo query, InstanceVersion version)
 {
     return query.GroupSelect.GetQueryItemForVersion(version);
 }
Exemplo n.º 14
0
 /// <inheritdoc />
 protected override QueryItemInfo GetQueryForGroups(QueryInfo query, InstanceVersion version)
 {
     return(query.GroupSelect.GetQueryItemForVersion(version));
 }
Exemplo n.º 15
0
		/// <summary>
		/// The get child groups definitions.
		/// </summary>
		/// <param name="parent">The parent.</param>
		/// <param name="parentDefinition">The parent definition.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <param name="version">The version.</param>
		private void GetChildGroupsDefinitions(
			QueryItemInfo               parent,
			GroupDefinition             parentDefinition,
			IEnumerable<ParameterValue> parameterValues,
			InstanceVersion             version
		)
		{
			QueryItemInfo childGroupSql = parent.ChildGroups.GetQueryItemForVersion(version);
			var           tempParams    = parameterValues.ToList();

			tempParams.AddRange(this.GetParametersFromDefinition(parentDefinition));

			try
			{
				DataTable[] groupsTabels = this.ExecuteSqlFunction(
					this.Instance,
					childGroupSql,
					null,
					childGroupSql.Parameters,
					tempParams,
					null,
					true
				);

				foreach (DataTable groupTable in groupsTabels)
				{
					this.AddGroupsFromTable(groupTable, parentDefinition.ChildGroups);
				}

				if (childGroupSql.ChildGroups == null || childGroupSql.ChildGroups.Count <= 0)
				{
					return;
				}

				foreach (GroupDefinition childGroup in parentDefinition.ChildGroups)
				{
					this.GetChildGroupsDefinitions(childGroupSql, childGroup, tempParams, version);
				}
			}
			catch (OperationCanceledException ex)
			{
				log.Error(ex);
				throw;
			}
			catch (Exception ex)
			{
				log.Error("instance=" + this.Instance.Name + " query=" + childGroupSql, ex);
			}
		}
Exemplo n.º 16
0
		/// <summary>
		/// The execute query.
		/// </summary>
		/// <param name="query">The query info.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <param name="version">The version.</param>
		/// <param name="progress">The progress.</param>
		/// <returns>
		/// The <see cref="QueryInstanceResultInfo" />.
		/// </returns>
		public QueryInstanceResultInfo ExecuteQuery(
			QueryInfo            query,
			QueryExecutionParams parameters,
			InstanceVersion      version,
			ProgressItem         progress
		)
		{
			// Log.InfoFormat("107:query:'{0}'",
			// 	query
			// );

			var groups = this
				.GetGroupsResolver()
				.GetGroups(query, parameters.Values, version);

			return this.ExecuteQuerySimple(
				query,
				parameters,
				version,
				progress,
				groups.ToArray()
			);
		}
Exemplo n.º 17
0
		/// <summary>
		/// The get query item for version.
		/// </summary>
		/// <param name="query">
		/// The query.
		/// </param>
		/// <param name="version">
		/// The version.
		/// </param>
		/// <returns>
		/// The <see cref="QueryItemInfo"/>.
		/// </returns>
		protected abstract QueryItemInfo GetQueryForGroups(QueryInfo query, InstanceVersion version);
 /// <inheritdoc />
 protected override QueryItemInfo GetQueryForGroups(QueryInfo query, InstanceVersion version)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 19
0
        private void GetDeploymentDetails(HttpContext context)
        {
            // Get the name of the instance where to deploy to.
            string instance = context.Request.Params["Instance"];

            InstanceCollection instances = new InstanceCollection();

            if (!instances.Instances.ContainsKey(instance))
            {
                return;
            }

            InstanceVersion instanceVerion = new InstanceVersion(
                instances.Instances[instance].Version
                );

            // Create a new string builder that
            // contains the result JSON string.
            StringBuilder result = new StringBuilder();

            result.Append("{");

            result.Append(string.Format(
                              "\"FromVersion\": \"{0}\",",
                              instances.Instances[instance].Version
                              ));

            result.Append(string.Format(
                              "\"Errors\": [",
                              instances.Instances[instance].Version
                              ));

            bool hasErrors = false;

            foreach (string server in instances.Instances[instance].Servers)
            {
                if (instances.Servers.Items.ContainsKey(server) == false ||
                    instances.Servers.Items[server].State == ServerState.Offline)
                {
                    hasErrors = true;

                    result.Append(string.Format("\"{0}\",", string.Format(Global.LanguageManager.GetText(
                                                                              "SoftwareUpdateError_ServerOffline"),
                                                                          instances.Servers.Items.ContainsKey(server) ?
                                                                          instances.Servers.Items[server].Description :
                                                                          server
                                                                          )));
                }
            }

            if (hasErrors)
            {
                result = result.Remove(result.Length - 1, 1);

                result.Append("]}");

                context.Response.Write(result.ToString());

                return;
            }

            result.Append("],");

            result.Append("\"AvailableUpdates\": [");

            ServiceLink service = new ServiceLink(string.Format(
                                                      "http://{0}:8080/Handler.ashx",
                                                      instances.Instances[instance].Servers[0]
                                                      ));

            XmlDocument document = new XmlDocument();

            document.LoadXml(service.Request(new string[] {
                "Method=GetAvailableUpdates"
            }));

            foreach (XmlNode xmlNode in document.DocumentElement.SelectNodes("Update"))
            {
                InstanceVersion version = new InstanceVersion(
                    xmlNode.Attributes["Version"].Value
                    );

                if (version.ToInt() <= instanceVerion.ToInt())
                {
                    continue;
                }

                result.Append(string.Format(
                                  "\"{0}\",",
                                  (version).ToString()
                                  ));
            }

            if (result.ToString().EndsWith(","))
            {
                result = result.Remove(result.Length - 1, 1);
            }

            result.Append("]");

            result.Append("}");

            context.Response.Write(result.ToString());
        }
Exemplo n.º 20
0
        private void DeployUpdateAsynch(object _parameters)
        {
            object[] paramters = (object[])_parameters;

            Instance         instance = (Instance)paramters[0];
            HttpSessionState session  = (HttpSessionState)paramters[1];
            InstanceVersion  version  = new InstanceVersion((string)paramters[2]);
            string           physicalApplicationPath = (string)paramters[3];

            StringBuilder result = new StringBuilder();

            result.Append("<Servers>");

            int step = 0;

            foreach (string server in instance.Servers)
            {
                session["DeploymentStep"] = step++;

                // Take the server offline for the deployment.
                instance.Owner.Servers.Items[server].State = ServerState.Offline;
                instance.Owner.Servers.Save();

                session["DeploymentStep"] = step++;

                ServiceLink service = new ServiceLink(string.Format(
                                                          "http://{0}:8080/Handler.ashx",
                                                          server
                                                          ));

                string xmlString = service.Request(new string[]
                {
                    "Method=DeployUpdate",
                    "Instance=" + instance.Name,
                    "Version=" + version.ToString()
                });

                result.Append(string.Format(
                                  "<Server IP=\"{0}\">{1}</Server>",
                                  server,
                                  xmlString
                                  ));

                session["DeploymentStep"] = step++;

                // Bring the server online.
                instance.Owner.Servers.Items[server].State = ServerState.Online;
                instance.Owner.Servers.Save();
            }

            result.Append("</Servers>");

            string fileName = Path.Combine(
                physicalApplicationPath,
                "Logs",
                "Deployment_" + DateTime.Now.ToString("yyyyMMddHHmmss")
                );

            File.WriteAllText(
                fileName,
                result.ToString()
                );

            session["DeploymentResult"] = fileName;
            session["DeploymentStep"]   = null;
        }
        private void DeployUpdate(HttpContext context)
        {
            context.Response.Write("<Errors>");

            // Get the source instance name from
            // the http request's parameters.
            string instanceName = context.Request.Params["Instance"];

            InstanceVersion toVersion = new InstanceVersion(context.Request.Params["Version"]);

            string instanceRoot = ConfigurationManager.AppSettings["InstanceRoot"];

            InstanceCollection instances = new InstanceCollection(instanceRoot);

            if (!instances.Instances.ContainsKey(instanceName))
            {
                return;
            }

            InstanceVersion version = new InstanceVersion(instances.Instances[instanceName].Version);

            version += 1;

            while (version.ToInt() <= toVersion.ToInt())
            {
                string directory = Path.Combine(
                    context.Request.PhysicalApplicationPath,
                    "App_Data",
                    "SoftwareUpdate",
                    version.ToString()
                    );

                if (!Directory.Exists(directory))
                {
                    continue;
                }

                string fileArchive = Path.Combine(
                    directory,
                    "Files.zip"
                    );

                if (File.Exists(fileArchive))
                {
                    try
                    {
                        string tempDirectory = Path.Combine(
                            Path.GetTempPath(),
                            Guid.NewGuid().ToString()
                            );

                        Directory.CreateDirectory(tempDirectory);

                        System.IO.Compression.ZipFile.ExtractToDirectory(
                            fileArchive,
                            tempDirectory
                            );

                        DeployDirectory(tempDirectory, Path.Combine(
                                            instanceRoot,
                                            instanceName
                                            ), version.ToString());
                    }
                    catch (Exception ex)
                    {
                        context.Response.Write(string.Format(
                                                   "<Error Type=\"Software\" Version=\"{1}\">{0}</Error>",
                                                   ex.ToString(),
                                                   version.ToString()
                                                   ));
                    }
                }

                string databaseScripts = Path.Combine(
                    directory,
                    "DATABASE"
                    );

                if (!Directory.Exists(databaseScripts))
                {
                    version += 1;
                    continue;
                }

                Client[] clients = instances.Instances[instanceName].GetClients();

                foreach (Client client in clients)
                {
                    foreach (string script in Directory.GetFiles(databaseScripts))
                    {
                        try
                        {
                            ExecuteQuery(client.Database, File.ReadAllText(script));
                        }
                        catch (Exception ex)
                        {
                            context.Response.Write(string.Format(
                                                       "<Error Type=\"Database\" Version=\"{1}\" Client=\"{2}\">{0}</Error>",
                                                       ex.ToString(),
                                                       version.ToString(),
                                                       client.Name
                                                       ));
                        }
                    }
                }

                version += 1;
            }

            context.Response.Write("</Errors>");
        }
 /// <summary>
 /// The get query item for version.
 /// </summary>
 /// <param name="query">
 /// The query.
 /// </param>
 /// <param name="version">
 /// The version.
 /// </param>
 /// <returns>
 /// The <see cref="QueryItemInfo"/>.
 /// </returns>
 protected abstract QueryItemInfo GetQueryForGroups(QueryInfo query, InstanceVersion version);
 /// <inheritdoc />
 public override ICollection <GroupDefinition> GetGroups(QueryInfo query, IEnumerable <ParameterValue> values, InstanceVersion i)
 {
     return(new List <GroupDefinition>()
     {
         new GroupDefinition(this.Instance, string.Empty, string.Empty)
         {
             GroupType
                 =
                     QueryScope
                     .Instance
         }
     });
 }
 /// <inheritdoc />
 protected override QueryItemInfo GetQueryForGroups(QueryInfo query, InstanceVersion version)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 25
0
 /// <summary>
 /// Get item query for this version.
 /// </summary>
 /// <param name="list">List item query.</param>
 /// <param name="version">Version.</param>
 /// <returns>
 /// Item for your version.
 /// </returns>
 public static QueryItemInfo GetQueryItemForVersion(this IEnumerable <QueryItemInfo> list, InstanceVersion version)
 {
     return((from itemInfo in list where itemInfo.IsApplicableVersion(version) select itemInfo).FirstOrDefault());
 }