public void InsertUpdateDeleteRecord(MasterFile file, StatementType statementType)
        {
            if (statementType == StatementType.Insert && this.Contains(file))
            {
                return;
            }
            else if (statementType == StatementType.Update && !this.Contains(file))
            {
                statementType = StatementType.Insert;
            }

            var sysIOcmd = new SqlCommand("dbo.usp_SysIO_InsertUpdateDelete")
            {
                CommandType = CommandType.StoredProcedure
            };

            sysIOcmd.Parameters.Add("@Filepath", SqlDbType.NVarChar).Value       = file.Filepath;
            sysIOcmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value           = file.SysIOProps["Name"].ToString();
            sysIOcmd.Parameters.Add("@Directory", SqlDbType.NVarChar).Value      = file.SysIOProps["Directory"].ToString();
            sysIOcmd.Parameters.Add("@Extension", SqlDbType.NVarChar).Value      = file.SysIOProps["Extension"].ToString();
            sysIOcmd.Parameters.Add("@CreationTime", SqlDbType.DateTime).Value   = Convert.ToDateTime(file.SysIOProps["CreationTime"]);
            sysIOcmd.Parameters.Add("@LastAccessTime", SqlDbType.DateTime).Value = Convert.ToDateTime(file.SysIOProps["LastAccessTime"]);
            sysIOcmd.Parameters.Add("@Size", SqlDbType.BigInt).Value             = Convert.ToInt64(file.SysIOProps["Size"]);
            sysIOcmd.Parameters.Add("@StatementType", SqlDbType.NVarChar).Value  = statementType.ToString();

            var tagLibcmd = new SqlCommand("dbo.usp_TagLib_InsertUpdateDelete")
            {
                CommandType = CommandType.StoredProcedure
            };

            tagLibcmd.Parameters.Add("@Filepath", SqlDbType.NVarChar).Value      = file.Filepath;
            tagLibcmd.Parameters.Add("@BitRate", SqlDbType.Int).Value            = Convert.ToInt32(file.TagLibProps["BitRate"]);
            tagLibcmd.Parameters.Add("@MediaType", SqlDbType.NVarChar).Value     = file.TagLibProps["MediaType"].ToString();
            tagLibcmd.Parameters.Add("@Artist", SqlDbType.NVarChar).Value        = file.TagLibProps["Artist"].ToString();
            tagLibcmd.Parameters.Add("@Album", SqlDbType.NVarChar).Value         = file.TagLibProps["Album"].ToString();
            tagLibcmd.Parameters.Add("@Genres", SqlDbType.NVarChar).Value        = file.TagLibProps["Genres"].ToString();
            tagLibcmd.Parameters.Add("@Lyrics", SqlDbType.NVarChar).Value        = file.TagLibProps["Lyrics"].ToString();
            tagLibcmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value         = file.TagLibProps["Title"].ToString();
            tagLibcmd.Parameters.Add("@Track", SqlDbType.Int).Value              = Convert.ToInt32(file.TagLibProps["Track"]);
            tagLibcmd.Parameters.Add("@Year", SqlDbType.Int).Value               = Convert.ToInt32(file.TagLibProps["Year"]);
            tagLibcmd.Parameters.Add("@Rating", SqlDbType.TinyInt).Value         = Convert.ToByte(file.TagLibProps["Rating"]);
            tagLibcmd.Parameters.Add("@IsCover", SqlDbType.Bit).Value            = (bool)file.TagLibProps["IsCover"] == true ? 1 : 0;
            tagLibcmd.Parameters.Add("@IsLive", SqlDbType.Bit).Value             = (bool)file.TagLibProps["IsLive"] == true ? 1 : 0;
            tagLibcmd.Parameters.Add("@Duration", SqlDbType.BigInt).Value        = ((TimeSpan)file.TagLibProps["Duration"]).Ticks;
            tagLibcmd.Parameters.Add("@StatementType", SqlDbType.NVarChar).Value = statementType.ToString();

            if (statementType == StatementType.Delete)
            {
                sysIOcmd.CommandType  = CommandType.StoredProcedure;
                tagLibcmd.CommandType = CommandType.StoredProcedure;
                ExecuteSqlCommands(new SqlCommand[] { sysIOcmd, tagLibcmd });
            }
            else
            {
                ExecuteSqlCommands(new SqlCommand[] { tagLibcmd, sysIOcmd });
            }
            PopulateIDColumn();
        }
        private string CreateExceptionMessage(StatementType statementType)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.Append("Update requires a valid ");
            sb.Append(statementType.ToString());
            sb.Append("Command when passed DataRow collection with ");

            switch (statementType)
            {
            case StatementType.Insert:
                sb.Append("new");
                break;

            case StatementType.Update:
                sb.Append("modified");
                break;

            case StatementType.Delete:
                sb.Append("deleted");
                break;
            }

            sb.Append(" rows.");

            return(sb.ToString());
        }
 public override string Description()
 {
     return(string.Format("{0}: Statement: {1}, Summarize: {2}, Declaration: {3}, Residency: {4}, Health Annuity: {5}, Social Annuity: {5}",
                          Code.ToEnum <ArticleResultCode>().GetSymbol(),
                          StatementType.ToString(), SummarizeType.GetSymbol(), DeclaracyType.ToString(), ResidencyType.ToString(),
                          HealthAnnuity.FormatAmount(), SocialAnnuity.FormatAmount()));
 }
Exemple #4
0
        /// <summary>
        /// Used to draw in the Statement class
        /// </summary>
        /// <param name="spriteBatch">From the monogame framework used to draw</param>
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
            spriteBatch.DrawString(GameWorld.smallFont, statementText, position + new Vector2(5, 0), Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 1.0f);

            spriteBatch.Draw(icon, new Vector2(position.X + 100 - ((icon.Width * iconScale) / 2), position.Y + 50), iconRect, Color.White, 0f, origin, iconScale, SpriteEffects.None, layer);

            #if DEBUG
            if (question)
            {
                spriteBatch.DrawString(GameWorld.font, "You clicked " + type.ToString(), new Vector2(200, 200), Color.Black);
            }
            #endif
        }
        // RowUpdatingEventArgs.StatementType
        internal static ArgumentOutOfRangeException InvalidStatementType(StatementType value)
        {
#if DEBUG
            switch (value)
            {
            case StatementType.Select:
            case StatementType.Insert:
            case StatementType.Update:
            case StatementType.Delete:
            case StatementType.Batch:
                Debug.Assert(false, "valid StatementType " + value.ToString());
                break;
            }
#endif
            return(InvalidEnumerationValue(typeof(StatementType), (int)value));
        }
Exemple #6
0
        public sealed override string ToString()
        {
            JObject o = new JObject();

            o.Add(nameof(Keyword), Keyword);
            o.Add(nameof(StatementType), StatementType.ToString());
            if (_lineNumber > 0 && _linePosition > 0)
            {
                o.Add("LineNumber", _lineNumber);
                o.Add("LinePosition", _linePosition);
            }
            o.Add(nameof(Parameters), JToken.FromObject(Parameters));

            JArray a = new JArray();

            foreach (Statement s in NestedStatements)
            {
                a.Add(JToken.Parse(s.ToString()));
            }
            o.Add(nameof(NestedStatements), a);
            return(o.ToString(Formatting.None));
        }
 //
 // DbDataAdapter
 //
 internal static ArgumentException UnwantedStatementType(StatementType statementType)
 {
     return(Argument(SR.Format(SR.ADP_UnwantedStatementType, statementType.ToString())));
 }
 internal static ArgumentOutOfRangeException NotSupportedStatementType(StatementType value, string method)
 {
     return(NotSupportedEnumerationValue(typeof(StatementType), value.ToString(), method));
 }
 public override string ToString()
 {
     return($"{KeywordType}: {StatementType.ToString()}");
 }
Exemple #10
0
 public override string ToString()
 {
     return(kind.ToString());
 }
Exemple #11
0
        private string GetStatementCondition(string line, ref string sLogic, StatementType StatementType)
        {
            if (line == "END")
            {
                sLogic = sLogic + "\r\t" + "}";
                return("");
            }

            string sIfStatement     = "";
            string strStatementType = StatementType.ToString();

            for (int i = 0; i < line.Trim().Split(' ').Length; i++)
            {
                var cIfChar = line.Trim().Split(' ')[i];

                if (cIfChar.ToUpper().StartsWith(strStatementType.ToUpper().ToString()))
                {
                    foreach (var l1 in cIfChar.Trim().Split('('))
                    {
                        sIfStatement = sIfStatement + "(";

                        if ((l1.ToUpper().StartsWith(strStatementType.ToUpper().ToString()) || l1.StartsWith("LEN")) || (l1.StartsWith("RTRIM")) || (l1.StartsWith("LTRIM")))
                        {
                            continue;
                        }

                        if (l1.Contains(")"))
                        {
                            foreach (var l2 in l1.Trim().Split(')'))
                            {
                                if (string.IsNullOrEmpty((l2)))
                                {
                                    sIfStatement = sIfStatement + ")";
                                    continue;
                                }

                                if (l2.Contains("@"))
                                {
                                    if (PrivateMemmberList.Find(x => x == l2.Substring(l2.IndexOf('@')).Substring(1)) != null)
                                    {
                                        sIfStatement = sIfStatement + l2.Replace(l2.Substring(l2.IndexOf('@')), l2.Substring(l2.IndexOf('@')).Substring(1));
                                    }
                                    else
                                    {
                                        sIfStatement = sIfStatement + l2.Replace(l2.Substring(l2.IndexOf('@')), "_" + _intermediateModel.BLClassName + "Model." + l2.Substring(l2.IndexOf('@')).Substring(1));
                                    }
                                }

                                sIfStatement = sIfStatement + ")";
                            }
                        }
                        else
                        {
                            sIfStatement = sIfStatement + l1;
                        }
                    }
                    continue;
                }

                if (cIfChar.Contains("@"))
                {
                    foreach (var l2 in cIfChar.Trim().Split(')'))
                    {
                        if (string.IsNullOrEmpty((l2)))
                        {
                            sIfStatement = sIfStatement + ")";
                            continue;
                        }

                        if (PrivateMemmberList.Find(x => x == l2.Substring(cIfChar.IndexOf('@')).Substring(1)) != null)
                        {
                            sIfStatement = sIfStatement + l2.Replace(l2.Substring(l2.IndexOf('@')), l2.Substring(l2.IndexOf('@')).Substring(1));
                        }
                        else
                        {
                            sIfStatement = sIfStatement + l2.Replace(l2.Substring(l2.IndexOf('@')), "_" + _intermediateModel.BLClassName + "Model." + l2.Substring(l2.IndexOf('@')).Substring(1));
                        }
                    }
                }
                else if (cIfChar.StartsWith("="))
                {
                    sIfStatement = sIfStatement + " == ";
                }
                else if (cIfChar.ToUpper().StartsWith("AND"))
                {
                    sIfStatement = sIfStatement + " && ";
                }
                else if (cIfChar.ToUpper().StartsWith("OR"))
                {
                    sIfStatement = sIfStatement + " || ";
                }
                else if (cIfChar.ToUpper().StartsWith("NULL"))
                {
                    if (cIfChar.ToUpper().Contains(")"))
                    {
                        sIfStatement = sIfStatement + " null) ";
                    }
                    else
                    {
                        sIfStatement = sIfStatement + " null ";
                    }
                }
                else if (cIfChar.ToUpper().StartsWith("IS"))
                {
                    int j = i + 1;
                    if (cIfChar.ToUpper().StartsWith("IS") && line.Trim().Split(' ')[j].ToUpper().StartsWith("NOT") && line.Trim().Split(' ')[++j].ToUpper().StartsWith("NULL"))
                    {
                        sIfStatement = sIfStatement + " != null ";
                        i            = i + 2;
                    }
                    else
                    {
                        sIfStatement = sIfStatement + " == ";
                    }
                }
                else if (cIfChar.StartsWith("'"))
                {
                    sIfStatement = sIfStatement + " " + cIfChar.Replace("'", "\"");
                }
                else if (cIfChar.StartsWith("BEGIN"))
                {
                    sIfStatement = sIfStatement + " ) " + "";
                }
                else if (cIfChar.StartsWith("<>"))
                {
                    sIfStatement = sIfStatement + " != " + "";
                }
                else
                {
                    sIfStatement = sIfStatement + " " + cIfChar.Replace("'", "\"");
                }
            }
            if (sIfStatement.Split('(').Length > sIfStatement.Split(')').Length)
            {
                int iCountLeft = sIfStatement.Split('(').Length - sIfStatement.Split(')').Length;

                while (iCountLeft > 0)
                {
                    sIfStatement = sIfStatement + ")";
                    iCountLeft--;
                }
            }


            return(sIfStatement);
        }
Exemple #12
0
 public override string Description()
 {
     return(string.Format("{0}: Statement: {1}, Summarize: {2}, Foreigner: {3}, Health Annuity: {4}",
                          Code.ToEnum <ArticleResultCode>().GetSymbol(),
                          StatementType.ToString(), SummarizeType.GetSymbol(), ForeignerType.ToString(), HealthAnnuity.FormatAmount()));
 }
 internal static ArgumentException UnwantedStatementType(StatementType statementType)
 {
     return Argument(System.Data.Res.GetString("ADP_UnwantedStatementType", new object[] { statementType.ToString() }));
 }
 internal static ArgumentOutOfRangeException NotSupportedStatementType(StatementType value, string method)
 {
     return NotSupportedEnumerationValue(typeof(StatementType), value.ToString(), method);
 }
Exemple #15
0
        /// <summary>
        /// Perform a numeric operation on two values.
        /// </summary>
        /// <param name="op1">First operand</param>
        /// <param name="op2">Second operand</param>
        /// <param name="operation">Which operation to perform</param>
        /// <returns>Result of the operation</returns>
        public static Value DoNumericOperation(Value op1, Value op2, StatementType operation)
        {
            // Check types
            ValueType operationType = ValueType.INTEGER;

            if (op1.Type == ValueType.FLOAT || op2.Type == ValueType.FLOAT)
            {
                operationType = ValueType.FLOAT;
                if (op1.Type == ValueType.INTEGER)
                {
                    op1 = new Value(ValueType.FLOAT, (double)(long)op1.Val);
                }
                else if (op1.Type != ValueType.FLOAT)
                {
                    throw new Exception("Value told to do numeric operation on non-numeric value: (" + op1.Type.ToString( ) + ") " + op1.ToString( ));
                }
                if (op2.Type == ValueType.INTEGER)
                {
                    op2 = new Value(ValueType.FLOAT, (double)(long)op2.Val);
                }
                else if (op2.Type != ValueType.FLOAT)
                {
                    throw new Exception("Value told to do numeric operation on non-numeric value: (" + op2.Type.ToString( ) + ") " + op2.ToString( ));
                }
            }

            // Complete operation
            switch (operation)
            {
            case StatementType.OP_ADD:
                return(operationType == ValueType.INTEGER
                                                ? new Value(ValueType.INTEGER, (long)op1.Val + (long)op2.Val)
                                                : new Value(ValueType.FLOAT, (double)op1.Val + (double)op2.Val));

            case StatementType.OP_SUB:
                return(operationType == ValueType.INTEGER
                                                ? new Value(ValueType.INTEGER, (long)op1.Val - (long)op2.Val)
                                                : new Value(ValueType.FLOAT, (double)op1.Val - (double)op2.Val));

            case StatementType.OP_MUL:
                return(operationType == ValueType.INTEGER
                                                ? new Value(ValueType.INTEGER, (long)op1.Val * (long)op2.Val)
                                                : new Value(ValueType.FLOAT, (double)op1.Val * (double)op2.Val));

            case StatementType.OP_DIV:
                return(operationType == ValueType.INTEGER
                                                ? new Value(ValueType.INTEGER, (long)op1.Val / (long)op2.Val)
                                                : new Value(ValueType.FLOAT, (double)op1.Val / (double)op2.Val));

            case StatementType.OP_POW:
                return(operationType == ValueType.INTEGER
                                                ? new Value(ValueType.INTEGER, (long)Math.Pow((long)op1.Val, (long)op2.Val))
                                                : new Value(ValueType.FLOAT, Math.Pow((double)op1.Val, (double)op2.Val)));

            case StatementType.OP_LOG:
                // Only do logs with floats
                if (op1.Type == ValueType.INTEGER)
                {
                    op1 = new Value(ValueType.FLOAT, (double)(long)op1.Val);
                }
                if (op2.Type == ValueType.INTEGER)
                {
                    op2 = new Value(ValueType.FLOAT, (double)(long)op2.Val);
                }
                return(new Value(ValueType.FLOAT, Math.Log((double)op1.Val, (double)op2.Val)));

            default:
                throw new Exception("Unexpected operation type for numeric operation (" + operation.ToString( ) + ").");
            }
        }
Exemple #16
0
        /// <summary>
        /// Perform a comparison operation on two values.
        /// </summary>
        /// <param name="op1">First operand</param>
        /// <param name="op2">Second operand</param>
        /// <param name="operation">Which operation to perform</param>
        /// <returns>Result of the operation, or a null value if the types are incompatiible</returns>
        public static Value DoComparisonOperation(Value op1, Value op2, StatementType operation)
        {
            switch (op1.Type)
            {
            case ValueType.INTEGER:
            case ValueType.FLOAT: {
                if (op2.Type != ValueType.INTEGER && op2.Type != ValueType.FLOAT)
                {
                    return(NAN);
                }

                double v1 = (op1.Type == ValueType.INTEGER) ? (long)op1.Val : (double)op1.Val;
                double v2 = (op2.Type == ValueType.INTEGER) ? (long)op2.Val : (double)op2.Val;

                switch (operation)
                {
                case StatementType.OP_TEST_EQ:
                    return((v1 == v2) ? TRUE : FALSE);

                case StatementType.OP_TEST_NE:
                    return((v1 != v2) ? TRUE : FALSE);

                case StatementType.OP_TEST_GT:
                    return((v1 > v2) ? TRUE : FALSE);

                case StatementType.OP_TEST_LT:
                    return((v1 < v2) ? TRUE : FALSE);

                default:
                    throw new Exception("Unexpected operation type for comparison operation (" + operation.ToString( ) + ").");
                }
            }

            case ValueType.STRING: {
                if (op2.Type == ValueType.STRING)
                {
                    if (operation == StatementType.OP_TEST_EQ)
                    {
                        return(((string)op1.Val).Equals((string)op2.Val) ? TRUE : FALSE);
                    }
                    else if (operation == StatementType.OP_TEST_NE)
                    {
                        return(((string)op1.Val).Equals((string)op2.Val) ? FALSE : TRUE);
                    }
                    else
                    {
                        throw new RuntimeException("Can only test string equality or inequality");
                    }
                }
                else if (op2.Type == ValueType.INTEGER)
                {
                    string s = (string)op1.Val;
                    long   i = (long)op2.Val;
                    switch (operation)
                    {
                    case StatementType.OP_TEST_EQ:
                        return((s.Length == i) ? TRUE : FALSE);

                    case StatementType.OP_TEST_NE:
                        return((s.Length != i) ? TRUE : FALSE);

                    case StatementType.OP_TEST_GT:
                        return((s.Length > i) ? TRUE : FALSE);

                    case StatementType.OP_TEST_LT:
                        return((s.Length < i) ? TRUE : FALSE);

                    default:
                        throw new Exception("Unexpected operation type for comparison operation (" + operation.ToString( ) + ").");
                    }
                }
                else
                {
                    return(NAN);
                }
            }

            case ValueType.LIST: {
                if (op2.Type == ValueType.LIST)
                {
                    bool test  = true;
                    var  list1 = (List <Value>)op1.Val;
                    var  list2 = (List <Value>)op2.Val;

                    if (operation != StatementType.OP_TEST_EQ)
                    {
                        return(NAN);
                    }

                    for (int i = 0; i < list1.Count; i += 1)
                    {
                        if (i >= list2.Count)
                        {
                            test = false;
                            break;
                        }
                        var elementTest = DoComparisonOperation(list1[i], list2[i], operation);
                        if (elementTest == FALSE)
                        {
                            test = false;
                            break;
                        }
                    }

                    return(test ? TRUE : FALSE);
                }
                else if (op2.Type == ValueType.INTEGER)
                {
                    var  l = (List <Value>)op1.Val;
                    long i = (long)op2.Val;
                    switch (operation)
                    {
                    case StatementType.OP_TEST_EQ:
                        return((l.Count == i) ? TRUE : FALSE);

                    case StatementType.OP_TEST_NE:
                        return((l.Count != i) ? TRUE : FALSE);

                    case StatementType.OP_TEST_GT:
                        return((l.Count > i) ? TRUE : FALSE);

                    case StatementType.OP_TEST_LT:
                        return((l.Count < i) ? TRUE : FALSE);

                    default:
                        throw new Exception("Unexpected operation type for comparison operation (" + operation.ToString( ) + ").");
                    }
                }
                else
                {
                    return(NAN);
                }
            }


            default:
                throw new Exception("Invalid token type for comparison operation: "
                                    + "op1:(" + op1.Type.ToString( ) + ") op2:(" + op2.Type.ToString( ) + ")");
            }
        }
Exemple #17
0
        /// <summary>
        /// Perform a bitwise operation on two values.
        /// </summary>
        /// <param name="op1">First operand</param>
        /// <param name="op2">Second operand</param>
        /// <param name="operation">Which operation to perform</param>
        /// <returns>Result of the operation</returns>
        public static Value DoBitwiseOperation(Value op1, Value op2, StatementType operation)
        {
            // Check type
            if (op1.Type != ValueType.INTEGER || op2.Type != ValueType.INTEGER)
            {
                throw new Exception("Value told to do bitwise operation on non-integer type(s): "
                                    + "op1:(" + op1.Type.ToString( ) + ") op2:(" + op2.Type.ToString( ) + ")");
            }

            // Complete operation
            switch (operation)
            {
            case StatementType.OP_MOD:
                return(new Value(ValueType.INTEGER, (long)op1.Val % (long)op2.Val));

            case StatementType.OP_AND:
                return(new Value(ValueType.INTEGER, (long)op1.Val & (long)op2.Val));

            case StatementType.OP_OR:
                return(new Value(ValueType.INTEGER, (long)op1.Val | (long)op2.Val));

            case StatementType.OP_XOR:
                return(new Value(ValueType.INTEGER, (long)op1.Val ^ (long)op2.Val));

            default:
                throw new Exception("Unexpected operation type for bitwise operation (" + operation.ToString( ) + ").");
            }
        }
        private static DataRowVersion GetParameterSourceVersion(StatementType statementType, IDataParameter parameter)
        {
            switch (statementType)
            {
            case StatementType.Insert: return(DataRowVersion.Current);     // ignores parameter.SourceVersion

            case StatementType.Update: return(parameter.SourceVersion);

            case StatementType.Delete: return(DataRowVersion.Original);    // ignores parameter.SourceVersion

            case StatementType.Select:
            case StatementType.Batch:
                throw new ArgumentException(message: string.Format("Unwanted statement type {0}", statementType.ToString()), paramName: nameof(statementType));

            default:
                throw ADP.InvalidStatementType(statementType);
            }
        }
		private string CreateExceptionMessage(StatementType statementType)
		{
			System.Text.StringBuilder sb = new System.Text.StringBuilder();

			sb.Append("Update requires a valid ");
			sb.Append(statementType.ToString());
			sb.Append("Command when passed DataRow collection with ");

			switch (statementType)
			{
				case StatementType.Insert:
					sb.Append("new");
					break;

				case StatementType.Update:
					sb.Append("modified");
					break;

				case StatementType.Delete:
					sb.Append("deleted");
					break;
			}

			sb.Append(" rows.");

			return sb.ToString();
		}
Exemple #20
0
 // =======================================================================================
 // VBScript BASE SOURCE RE-GENERATION
 // =======================================================================================
 /// <summary>
 /// Re-generate equivalent VBScript source code for this block - there
 /// should not be a line return at the end of the content
 /// </summary>
 public string GenerateBaseSource(SourceRendering.ISourceIndentHandler indenter)
 {
     return(indenter.Indent + "Exit " + StatementType.ToString());
 }