Exemple #1
0
        /// <summary>
        /// method Sign Up
        /// </summary>
        public ActionResult SignUp(Notification notification)
        {
            // if the notification.EmailAddress exists
            if ((NullHelper.Exists(notification)) && (TextHelper.Exists(notification.EmailAddress)))
            {
                // Create a new instance of a 'Gateway' object.
                Gateway gateway = new Gateway();

                // check if exists
                Notification existingNotification = gateway.FindNotificationByEmailAddress(notification.EmailAddress);

                // If the existingNotification object does not exist
                if (NullHelper.IsNull(existingNotification))
                {
                    // perform the save
                    bool saved = gateway.SaveNotification(ref notification);

                    // if saved
                    if (saved)
                    {
                        bool isNew = notification.IsNew;
                    }
                }
            }

            // to do: return signed up user.
            return(View());
        }
        public override object GetValue()
        {
            if (_property == null)
            {
                return(null);
            }

            object instance = _target.GetValue();

            if (NullHelper.IsNull(instance))
            {
                return(null);
            }

            object result;

            try
            {
                result = _property.GetValue(instance);
            }
            catch (NQueryException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionBuilder.PropertyBindingGetValueFailed(ex);
            }

            return(NullHelper.UnifyNullRepresentation(result));
        }
Exemple #3
0
        /// <summary>
        /// This method compares two Lists of ExcludeInfo objects. If the number of items is different, or if
        /// any of the values are different, then the object has changed.
        /// </summary>
        /// <param name="originalValues"></param>
        /// <param name="currentValues"></param>
        /// <returns></returns>
        public static bool HasObjectChanged(List <ExcludeInfo> originalValues, List <ExcludeInfo> currentValues)
        {
            // initial value
            bool hasObjectChanged = false;

            // If both objects exist
            if (NullHelper.Exists(originalValues, currentValues))
            {
                // if the counts are different
                if (originalValues.Count != currentValues.Count)
                {
                    // these objects are different
                    hasObjectChanged = true;
                }
                else
                {
                    // iterate the items
                    for (int x = 0; x < originalValues.Count; x++)
                    {
                        // if the values are different
                        if (originalValues[x].Exclude != currentValues[x].Exclude)
                        {
                            // these objects are different
                            hasObjectChanged = true;

                            // break out of loop
                            break;
                        }
                    }
                }
            }
            else if ((NullHelper.IsNull(originalValues)) && (NullHelper.Exists(currentValues)))
            {
                // these objects are different
                hasObjectChanged = true;
            }
            else if ((NullHelper.IsNull(currentValues)) && (NullHelper.Exists(originalValues)))
            {
                // these objects are different
                hasObjectChanged = true;
            }

            // return value
            return(hasObjectChanged);
        }
        public override object GetValue()
        {
            if (_method == null)
            {
                return(null);
            }

            object targetValue = _target.GetValue();

            if (NullHelper.IsNull(targetValue))
            {
                return(null);
            }

            object[] argumentValues = new object[_arguments.Length];

            for (int i = 0; i < argumentValues.Length; i++)
            {
                argumentValues[i] = _arguments[i].GetValue();
            }

            object result;

            try
            {
                result = _method.Invoke(targetValue, argumentValues);
            }
            catch (TargetInvocationException ex)
            {
                // Special handling for target invocation since we are only
                // interested in the inner one.
                throw ExceptionBuilder.MethodBindingInvokeFailed(ex.InnerException);
            }
            catch (NQueryException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionBuilder.MethodBindingInvokeFailed(ex);
            }

            return(NullHelper.UnifyNullRepresentation(result));
        }
Exemple #5
0
        public override bool Read()
        {
            if (!_rows.MoveNext())
            {
                return(false);
            }

            foreach (RuntimeColumnValueOutput definedValue in DefinedValues)
            {
                ColumnBinding columnBinding = definedValue.ColumnBinding;

                object value;

                try
                {
                    value = columnBinding.GetValue(_rows.Current);
                }
                catch (NQueryException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw ExceptionBuilder.ColumnBindingGetValueFailed(ex);
                }

                if (NullHelper.IsNull(value))
                {
                    RowBuffer[definedValue.TargetIndex] = null;
                }
                else
                {
                    RowBuffer[definedValue.TargetIndex] = value;
                }
            }

            return(true);
        }
Exemple #6
0
        public override LiteralExpression VisitLiteralValue(LiteralExpression expression)
        {
            _xmlWriter.WriteStartElement("literalExpression");

            _xmlWriter.WriteStartElement("value");
            WriteTypeAttribute(expression.ExpressionType);

            object value = expression.GetValue();

            if (NullHelper.IsNull(value))
            {
                _xmlWriter.WriteAttributeString("value", "<null>");
            }
            else
            {
                _xmlWriter.WriteAttributeString("value", value.ToString());
            }
            _xmlWriter.WriteEndElement();

            _xmlWriter.WriteEndElement();

            return(expression);
        }
Exemple #7
0
        /// <summary>
        /// This method does the actual comparison; it is called by the RemoteCompare and the normal comparison
        /// </summary>
        private void CompareDatabaseStructure(Database sourceDatabase, Database targetDatabase)
        {
            // local
            SchemaComparison schemaComparison = new SchemaComparison();

            // verify both objects exist
            if (NullHelper.Exists(sourceDatabase, targetDatabase))
            {
                // test if any data was loaded before showing 'The target database is up to date message incorrectly'
                if (sourceDatabase.Tables.Count > 0)
                {
                    // Get the value for IgnoreDiagramProcedures
                    bool ignoreDiagramProcedures = this.IgnoreDiagramProceduresCheckBox.Checked;

                    // Create a new database comparer
                    DatabaseComparer comparer = new DatabaseComparer(sourceDatabase, targetDatabase, ignoreDiagramProcedures);

                    // Compare the two database schemas
                    schemaComparison = comparer.Compare();
                }
                else
                {
                    // Add this as a message
                    schemaComparison.SchemaDifferences.Add("The source database does not contain any tables; the comparison cannot continue.");
                }

                // compare the two schemas
                if (schemaComparison != null)
                {
                    // if the two database are equal
                    if (schemaComparison.IsEqual)
                    {
                        // Show the two databases are equal
                        this.ResultsTextBox.Text = "The target database is up to date.";
                    }
                    else
                    {
                        // Display the count
                        this.CountLabel.Text = "Count: " + schemaComparison.SchemaDifferences.Count;

                        // Create a string builder
                        StringBuilder sb = new StringBuilder("The target database is not valid.");

                        // Append a new line
                        sb.Append(Environment.NewLine);

                        // iterate the errors
                        foreach (string schemaDifference in schemaComparison.SchemaDifferences)
                        {
                            // Append an indention
                            sb.Append("    ");
                            sb.Append(schemaDifference);
                            sb.Append(Environment.NewLine);
                        }

                        // Show the schema differences
                        this.ResultsTextBox.Text = sb.ToString();

                        // This is a stub for an update for Version 3.0 that isn't ready to be released
                        //// create a message for how to
                        //message = "Would you like to attempt to fix any errors if possible?";

                        //// Get the users response
                        //DialogResult result = MessageBoxHelper.GetUserResponse(message, "Fix Schema Differences?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        //// if the user choose yes
                        //if (result == DialogResult.Yes)
                        //{
                        //    // attempt to fix any schema differences
                        //    int fixedCount = SqlUpdater.FixSchemaDifferences(schemaComparison.SchemaDifferences, targetDatabaseConnector, sourceDatabase);
                        //}
                    }
                }
            }
            else if (NullHelper.IsNull(sourceDatabase))
            {
                // Show the user a message
                this.ResultsTextBox.Text = "The source database could not be loaded.";
            }
            else if (NullHelper.IsNull(targetDatabase))
            {
                // Show the user a message
                this.ResultsTextBox.Text = "The target database could not be loaded.";
            }
        }
        /// <summary>
        /// Converts a ObjectLibrary.Database
        /// SQLServer database to a DataJuggler.Net Database
        /// and reads the schema.
        /// </summary>
        /// <param name="databases"></param>
        /// <returns></returns>
        private Database ConvertSQLDatabase(DTNDatabase db, List <Enumeration> enumerations)
        {
            // Create sqlConnector
            SQLDatabaseConnector sqlConnector = new SQLDatabaseConnector();

            // if the tables are not loaded for the db
            if ((NullHelper.Exists(db)) && (!ListHelper.HasOneOrMoreItems(db.Tables)))
            {
                // Create a new instance of a 'Gateway' object.
                Gateway gateway = new Gateway();

                // load the tables
                db.Tables = gateway.LoadDTNTablesByProjectId(this.CurrentProject.ProjectId);
            }

            // if the DataManager does not exist
            if (NullHelper.IsNull(DataManager))
            {
                if (NullHelper.Exists(CurrentProject))
                {
                    // Don't know why this is still here, VB.Net was abandoned in 2006 or 2007
                    DataManager = new DataManager(CurrentProject.ProjectFolder, currentProject.ProjectName, DataManager.ClassOutputLanguage.CSharp);
                }
                else
                {
                    // exit
                    return(null);
                }
            }

            // Create Database
            DataJuggler.Net.Database database = new Database(this.DataManager);

            // Set Database Properties
            database.ClassFileName     = this.DataManager.ClassFileName;
            database.ClassName         = db.DatabaseName + ".cs";
            database.ConnectionString  = db.ConnectionString;
            database.Name              = db.DatabaseName;
            database.ParentDataManager = this.DataManager;
            database.Password          = db.DBPassword;
            database.Serializable      = true;
            database.StoredProcedures  = new List <StoredProcedure>();

            // set connection string
            sqlConnector.DatabaseConnection.ConnectionString = database.ConnectionString;

            // open database
            sqlConnector.DatabaseConnection.Open();

            // read database schema
            database = sqlConnector.LoadDatabaseSchema(database);

            // close this database
            sqlConnector.DatabaseConnection.Close();

            // if there are one or more tables
            if (ListHelper.HasOneOrMoreItems(database.Tables))
            {
                // iterate the collection of tables
                foreach (DataTable table in database.Tables)
                {
                    // if a DotNet5 project and EnableBlazorFeatures is true and BindingCallBack option is set to CreateBinding
                    if ((currentProject.TargetFramework != TargetFrameworkEnum.NetFramework) && (currentProject.EnableBlazorFeatures) && (currentProject.BindingCallbackOption == BindingCallbackOptionEnum.Create_Binding))
                    {
                        // Create the BindingCall back needs to be set to true to code generate the Callback.
                        table.CreateBindingCallback = true;
                    }

                    // if there are one or more fields
                    if (ListHelper.HasOneOrMoreItems(table.Fields, enumerations))
                    {
                        // iterate the fields
                        foreach (DataField field in table.Fields)
                        {
                            // now iterate te enumerations
                            foreach (Enumeration enumeration in enumerations)
                            {
                                // if this field is designated as an enumeration
                                if (TextHelper.IsEqual(field.FieldName, enumeration.FieldName))
                                {
                                    // set to true
                                    field.IsEnumeration = true;

                                    // Set this as enumeration
                                    field.DataType = DataManager.DataTypeEnum.Enumeration;

                                    // Set the EnumerationName
                                    field.EnumDataTypeName = enumeration.EnumerationName;
                                }
                            }
                        }
                    }
                }
            }

            // return value
            return(database);
        }
        /// <summary>
        /// This method returns the Pixel Criteria
        /// </summary>
        public static PixelCriteria CreatePixelCriteria(string text, ActionTypeEnum actionType, int lineNumber, PixelCriteria existingCriteria = null)
        {
            // initial value
            PixelCriteria pixelCriteria = null;

            // only use a space as a delimiter character
            char[] delimiterChars = { ' ' };

            // If the text string exists
            if (TextHelper.Exists(text))
            {
                // Set the BackColor
                if (actionType == ActionTypeEnum.SetBackColor)
                {
                    // Create a new instance of a 'PixelCriteria' object.
                    pixelCriteria = new PixelCriteria();

                    // Get the words
                    List <Word> words = WordParser.GetWords(text, delimiterChars);

                    // If the words collection exists and has one or more items
                    if (ListHelper.HasOneOrMoreItems(words))
                    {
                        // if there are 3 words
                        if (words.Count == 3)
                        {
                            // if the third word is null
                            if (words[2].Text.ToLower() == "null")
                            {
                                // Set the value for the property 'RemoveBackColor' to true
                                pixelCriteria.RemoveBackColor = true;
                            }
                            else
                            {
                                // Set the BackColor
                                pixelCriteria.BackColor = Color.FromName(words[2].Text);
                            }
                        }
                        else if (words.Count == 5)
                        {
                            // set the value for Red, Green & Blue
                            int red   = NumericHelper.ParseInteger(words[2].Text, -1, -1);
                            int green = NumericHelper.ParseInteger(words[3].Text, -1, -1);
                            int blue  = NumericHelper.ParseInteger(words[4].Text, -1, -1);

                            // if all the RGB values are set
                            if ((red >= 0) && (green >= 0) && (blue >= 0))
                            {
                                // Set the BackColor
                                pixelCriteria.BackColor = Color.FromArgb(red, green, blue);
                            }
                        }
                    }
                }
                // if this is a draw line
                else if (actionType == ActionTypeEnum.DrawLine)
                {
                    // if the existingCriteria
                    if (NullHelper.IsNull(existingCriteria))
                    {
                        // Create a new instance of a 'PixelCriteria' object.
                        pixelCriteria = new PixelCriteria();
                    }
                    else
                    {
                        // use the existing criteria so more properties can be set on it
                        pixelCriteria = existingCriteria;
                    }

                    // Set to DrawLine
                    pixelCriteria.PixelType = PixelTypeEnum.DrawLine;

                    // if this is the first line
                    if (lineNumber == 1)
                    {
                        // Get the words
                        List <Word> words = WordParser.GetWords(text, delimiterChars);

                        // If the words collection exists and has one or more items
                        if (ListHelper.HasOneOrMoreItems(words))
                        {
                            // Get the lastWord
                            Word lastWord = words[words.Count - 1];

                            // Set the thickness
                            pixelCriteria.Thickness = NumericHelper.ParseInteger(lastWord.Text, -1000, -1001);
                        }
                    }
                    else if (lineNumber == 3)
                    {
                        // Set the RepeatType and the repeating attributes
                        pixelCriteria.RepeatType = SetRepeatType(text);

                        // if the repeat type was found
                        if (pixelCriteria.RepeatType != RepeatTypeEnum.NoRepeat)
                        {
                            // get the text after the repeat
                            string repeatText = GetRepeatText(text, pixelCriteria.RepeatType);

                            // get the words
                            List <Word> words = WordParser.GetWords(repeatText);

                            // if there are exactly two words
                            if ((ListHelper.HasOneOrMoreItems(words)) && (words.Count == 2))
                            {
                                // set the repititions
                                pixelCriteria.Repititions = NumericHelper.ParseInteger(words[0].Text, 0, -1);

                                // set the Distance
                                pixelCriteria.Distance = NumericHelper.ParseInteger(words[1].Text, 0, -1);
                            }
                        }
                    }
                }
                else if (lineNumber > 1)
                {
                    // Create a new instance of a 'PixelCriteria' object.
                    pixelCriteria = new PixelCriteria();

                    // if this text contains bluegreen
                    if (text.Contains("x"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.X;
                    }
                    else if (text.Contains("y"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Y;
                    }
                    else if (text.Contains("bluegreen"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.BlueGreen;
                    }
                    // if this text contains bluegreen
                    else if (text.Contains("bluered"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.BlueRed;
                    }
                    // if this text contains bluegreen
                    else if (text.Contains("greenred"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.GreenRed;
                    }
                    else if (text.Contains("red"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Red;
                    }
                    else if (text.Contains("green"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Green;
                    }
                    else if (text.Contains("blue"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Blue;
                    }
                    else if (text.Contains("total"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Total;
                    }
                }
            }

            // return value
            return(pixelCriteria);
        }