Esempio n. 1
0
        private void comboBoxForeignScriptObject_SelectedIndexChanged(object sender, EventArgs e)
        {
            ScriptObject foreignScriptObject = (ScriptObject)comboBoxForeignScriptObject.SelectedItem;

            comboBoxForeignColumn.DataSource    = foreignScriptObject.Columns;
            comboBoxForeignColumn.DisplayMember = "Alias";
            comboBoxForeignColumn.ValueMember   = "Name";

            PopulateFilterComboBox(comboBoxForeignFilter, foreignScriptObject, false, listViewForeignColumn);

            // If Stored Procedure the filter must contain required paramters
            if (_primaryRelationship == null && foreignScriptObject.GetType() == typeof(ArchAngel.Providers.Database.Model.StoredProcedure))
            {
                ArchAngel.Providers.Database.Model.StoredProcedure parentStoredProcedure = (ArchAngel.Providers.Database.Model.StoredProcedure)foreignScriptObject;
                foreach (Filter.FilterColumn filterColumn in parentStoredProcedure.Filters[0].FilterColumns)
                {
                    AddForeignColumn(filterColumn.Column);
                }
            }
        }
Esempio n. 2
0
        private void comboBoxScriptObject_SelectedIndexChanged(object sender, EventArgs e)
        {
            ScriptObject scriptObject = (ScriptObject)comboBoxScriptObject.SelectedItem;

            comboBoxColumn.DataSource    = scriptObject.Columns;
            comboBoxColumn.DisplayMember = "Alias";
            comboBoxColumn.ValueMember   = "Name";

            // If Stored Procedure the filter must contain required paramters
            if (scriptObject.GetType() == typeof(ArchAngel.Providers.Database.Model.StoredProcedure))
            {
                listViewColumn.Items.Clear();
                radioButtonFilterAnd.Checked = false;
                radioButtonFilterOr.Checked  = false;

                ArchAngel.Providers.Database.Model.StoredProcedure storedProcedure = (ArchAngel.Providers.Database.Model.StoredProcedure)scriptObject;

                textBoxName.Text = storedProcedure.Filters[0].Name;
                foreach (Filter.FilterColumn filterColumn in storedProcedure.Filters[0].FilterColumns)
                {
                    AddFilterColumn(filterColumn.Column);
                }
            }
        }
Esempio n. 3
0
        public bool NameValidate(StoredProcedure storedProcedure, out string failReason)
        {
            failReason = "";
            /*Don't check items that are not enabled*/

            if (!storedProcedure.Enabled)
            {
                return true;
            }
            if (string.IsNullOrEmpty(storedProcedure.Name))
            {
                failReason = "Name cannot be zero-length.";
                return false;
            }
            if (storedProcedure.Name.IndexOf(" ") >= 0)
            {
                failReason = "Name cannot have spaces.";
                return false;
            }

            foreach (ScriptObject sibling in storedProcedure.Database.EnabledScriptObjects)
            {
                if (sibling != this && sibling.Enabled && ArchAngel.Providers.Database.Helper.Script.StringsAreEqual(sibling.Name, Name, false))
                {
                    failReason = "Duplicate name: " + Name;
                    return false;
                }
            }
            return true;
        }
Esempio n. 4
0
        public bool AliasPluralValidate(StoredProcedure storedProcedure, out string failReason)
        {
            failReason = "";

            /*Don't check items that are not enabled*/
            if (!storedProcedure.Enabled)
            {
                return true;
            }
            if (string.IsNullOrEmpty(storedProcedure.AliasPlural))
            {
                failReason = "AliasPlural cannot be zero-length.";
                return false;
            }
            if (storedProcedure.AliasPlural.IndexOf(" ") >= 0)
            {
                failReason = "AliasPlural cannot have spaces.";
                return false;
            }
            if (ArchAngel.Providers.Database.Helper.Script.StringsAreEqual(storedProcedure.AliasPlural, storedProcedure.Alias, false))
            {
                failReason = "AliasPlural must be different to Alias.";
                return false;
            }

            foreach (ScriptObject sibling in storedProcedure.Database.EnabledScriptObjects)
            {
                if (sibling != this && sibling.Enabled)
                {
                    if (ArchAngel.Providers.Database.Helper.Script.StringsAreEqual(sibling.AliasPlural, AliasPlural, false))
                    {
                        failReason = string.Format("Duplicate AliasPlural: {0}", AliasPlural);
                        return false;
                    }
                    if (ArchAngel.Providers.Database.Helper.Script.StringsAreEqual(sibling.Alias, AliasPlural, false))
                    {
                        failReason = string.Format("Stored procedure with same name exists: {0}", sibling.Alias);
                        return false;
                    }
                }
            }
            return true;
        }
Esempio n. 5
0
 public virtual string AliasPluralDefault(StoredProcedure storedProcedure)
 {
     return ArchAngel.Providers.Database.Helper.Script.GetPlural(storedProcedure.Alias);
 }
Esempio n. 6
0
        public string AliasDefault(StoredProcedure storedProcedure)
        {
            string alias = ArchAngel.Providers.Database.Helper.Script.GetSingleWord(storedProcedure.Name.Trim());
            string aliasLower = alias.ToLower();

            foreach (string prefix in StoredProcedurePrefixes)
            {
                if (aliasLower.IndexOf(prefix.ToLower()) == 0)
                {
                    alias = alias.Substring(prefix.Length);
                    break;
                }
            }
            return ArchAngel.Providers.Database.Helper.Script.GetSingular(alias);
        }
Esempio n. 7
0
 public static string GetDataType(StoredProcedure.Parameter parameter)
 {
     bool isNullable = false; // TODO: need to add a property to Parameters that specify whether they are nullable (have default values).
     return CSharp.GetDataType(parameter.DataType, isNullable);
 }
Esempio n. 8
0
        public static string GetStoredProcedureParameterValueString(StoredProcedure storedProcedure)
        {
            StringBuilder result = new StringBuilder(100);

            for (int i = 0; i < storedProcedure.Parameters.Length; i++)
            {
                if (i > 0)
                {
                    result.Append(", ");
                }

                StoredProcedure.Parameter parameter = storedProcedure.Parameters[i];
                string modifier = "";

                if (parameter.Direction.ToLower().IndexOf("out") >= 0)
                {
                    modifier = "ref ";
                }
                result.Append(string.Format("{0}{1}", modifier, Script.GetCamelCase(parameter.Alias)));
            }
            return result.ToString();
        }
Esempio n. 9
0
 public Mapping(Column primaryColumn, Column associatedColumn, StoredProcedure.Parameter associatedParameter)
 {
     PrimaryColumn = primaryColumn;
     AssociatedColumn = associatedColumn;
     AssociatedParameter = associatedParameter;
 }
Esempio n. 10
0
 public Mapping FindMappingByAssociatedParameter(StoredProcedure.Parameter associatedParameter)
 {
     foreach (Mapping mapping in Mappings)
     {
         if (mapping.AssociatedParameter == associatedParameter)
         {
             return mapping;
         }
     }
     return null;
 }