예제 #1
0
        private static void FillVariables(IEnumerable <XmlElement> sections, Dictionary <string, string> variables, Instance instance, IPipelineController controller)
        {
            var @params = sections.SingleOrDefault(s => s.Name.EqualsIgnoreCase("params"));

            if (@params != null)
            {
                var children = @params.ChildNodes.OfType <XmlElement>();
                foreach (XmlElement param in children)
                {
                    var variableName = param.GetAttribute("name");
                    if (variables.ContainsKey(variableName))
                    {
                        continue;
                    }

                    var variableTitle        = param.GetAttribute("title");
                    var defaultVariableValue = param.GetAttribute("defaultValue");
                    var mode          = param.GetAttribute("mode");
                    var options       = param.GetAttribute("options");
                    var typeName      = param.GetAttribute("getOptionsType");
                    var methodName    = param.GetAttribute("getOptionsMethod");
                    var multiselect   = mode.EqualsIgnoreCase("multiselect");
                    var variableValue = controller != null
            ? (multiselect || mode.Equals("select")
              ? controller.Select(variableTitle, !string.IsNullOrEmpty(options)
                ? options.Split('|')
                : GetOptions(typeName, methodName, instance), multiselect, defaultVariableValue)
              : controller.Ask(variableTitle, defaultVariableValue))
            : defaultVariableValue;
                    variables.Add(variableName, variableValue);
                }
            }
        }
예제 #2
0
        public static string ResolveConflict(SqlConnectionStringBuilder defaultConnectionString, ConnectionString connectionString, string databasePath, string databaseName, IPipelineController controller)
        {
            string existingDatabasePath = SqlServerManager.Instance.GetDatabaseFileName(databaseName, defaultConnectionString);

            if (string.IsNullOrEmpty(existingDatabasePath))
            {
                var m = "The database with the same '{0}' name is already exists in the SQL Server metabase but points to non-existing file. ".FormatWith(databaseName);
                if (controller.Confirm(m + "Would you like to delete it?"))
                {
                    SqlServerManager.Instance.DeleteDatabase(databaseName, defaultConnectionString);
                    return(databaseName);
                }

                throw new Exception(m);
            }

            if (existingDatabasePath.EqualsIgnoreCase(databasePath))
            {
                return(null);
            }

            // todo: replce this with shiny message box
            string       delete      = "Delete the '{0}' database".FormatWith(databaseName);
            const string AnotherName = "Use another database name";
            const string Cancel      = "Terminate current action";

            string[] options = new[]
            {
                delete, AnotherName, Cancel
            };
            string m2     = "The database with '{0}' name already exists".FormatWith(databaseName);
            string result = controller.Select(m2, options);

            switch (result)
            {
            case Cancel:
                throw new Exception(m2);

            case AnotherName:
                databaseName = ResolveConflictByUnsedName(defaultConnectionString, connectionString, databaseName);
                break;

            default:
                SqlServerManager.Instance.DeleteDatabase(databaseName, defaultConnectionString);
                break;
            }

            return(databaseName);
        }
        private static void FillVariables(IEnumerable<XmlElement> sections, Dictionary<string, string> variables, Instance instance, IPipelineController controller)
        {
            var @params = sections.SingleOrDefault(s => s.Name.EqualsIgnoreCase("params"));
              if (@params != null)
              {
            var children = @params.ChildNodes.OfType<XmlElement>();
            foreach (XmlElement param in children)
            {
              string variableName = param.GetAttribute("name");
              if (variables.ContainsKey(variableName))
              {
            continue;
              }

              string variableTitle = param.GetAttribute("title");
              string defaultVariableValue = param.GetAttribute("defaultValue");
              string mode = param.GetAttribute("mode");
              var options = param.GetAttribute("options");
              var typeName = param.GetAttribute("getOptionsType");
              var methodName = param.GetAttribute("getOptionsMethod");
              var multiselect = mode.EqualsIgnoreCase("multiselect");
              string variableValue = controller != null
            ? (multiselect || mode.Equals("select")
              ? controller.Select(variableTitle, !string.IsNullOrEmpty(options)
                ? options.Split('|')
                : GetOptions(typeName, methodName, instance), multiselect, defaultVariableValue)
              : controller.Ask(variableTitle, defaultVariableValue))
            : defaultVariableValue;
              variables.Add(variableName, variableValue);
            }
              }
        }
        public static string ResolveConflict(SqlConnectionStringBuilder defaultConnectionString, ConnectionString connectionString, string databasePath, string databaseName, IPipelineController controller)
        {
            string existingDatabasePath = SqlServerManager.Instance.GetDatabaseFileName(databaseName, defaultConnectionString);

              if (string.IsNullOrEmpty(existingDatabasePath))
              {
            var m = "The database with the same '{0}' name is already exists in the SQL Server metabase but points to non-existing file. ".FormatWith(databaseName);
            if (controller.Confirm(m + "Would you like to delete it?"))
            {
              SqlServerManager.Instance.DeleteDatabase(databaseName, defaultConnectionString);
              return databaseName;
            }

            throw new Exception(m);
              }

              if (existingDatabasePath.EqualsIgnoreCase(databasePath))
              {
            return null;
              }

              // todo: replce this with shiny message box
              string delete = "Delete the '{0}' database".FormatWith(databaseName);
              const string AnotherName = "Use another database name";
              const string Cancel = "Terminate current action";
              string[] options = new[]
              {
            delete, AnotherName, Cancel
              };
              string m2 = "The database with '{0}' name already exists".FormatWith(databaseName);
              string result = controller.Select(m2, options);
              switch (result)
              {
            case Cancel:
              throw new Exception(m2);
            case AnotherName:
              databaseName = ResolveConflictByUnsedName(defaultConnectionString, connectionString, databaseName);
              break;
            default:
              SqlServerManager.Instance.DeleteDatabase(databaseName, defaultConnectionString);
              break;
              }

              return databaseName;
        }