private IEnumerable<Gnosis.ILink> GetLinks(ICommandBuilder builder)
        {
            IDbConnection connection = null;
            var links = new List<Gnosis.ILink>();

            try
            {
                connection = GetConnection();

                var command = builder.ToCommand(connection);

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var link = ReadLink(reader);
                        links.Add(link);
                    }
                }

                return links;
            }
            finally
            {
                if (defaultConnection == null && connection != null)
                    connection.Close();
            }
        }
        private IEnumerable<IMedia> GetMedia(ICommandBuilder builder)
        {
            IDbConnection connection = null;
            var media = new List<IMedia>();

            try
            {
                connection = GetConnection();

                var command = builder.ToCommand(connection);

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var medium = ReadMedium(reader);
                        media.Add(medium);
                    }
                }

                return media;
            }
            finally
            {
                if (defaultConnection == null && connection != null)
                    connection.Close();
            }
        }
 private IEnumerable<IDictionary<string, object>> ExecuteQuery(ICommandBuilder commandBuilder)
 {
     var connection = _connection ?? _adapter.CreateConnection();
     var command = commandBuilder.GetCommand(connection);
     command.Transaction = _transaction;
     return TryExecuteQuery(command);
 }
        private IEnumerable<Gnosis.ITag> GetTags(ICommandBuilder builder)
        {
            IDbConnection connection = null;
            var tags = new List<Gnosis.ITag>();

            try
            {
                connection = GetConnection();
                
                var command = builder.ToCommand(connection);

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var tag = ReadTag(reader);
                        tags.Add(tag);
                    }
                }
                
                return tags;
            }
            finally
            {
                if (defaultConnection == null && connection != null)
                    connection.Close();
            }
        }
		private object ExecuteScalar(ICommandBuilder commandBuilder)
		{
			var connection = _connection ?? _adapter.CreateConnection();
			var command = commandBuilder.GetCommand(connection);
			command.Transaction = _transaction;
			return TryExecuteScalar(command);
		}
Exemple #6
0
        public MusicModule(IQueryBuilder queryBuilder, ICommandBuilder commandBuilder)
            : base("/music")
        {
            _queryBuilder = queryBuilder;
            _commandBuilder = commandBuilder;

            Get["/"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresReadClaim("music");

                var paging = this.BindAndValidate<Paging>();
                var result = _queryBuilder.For<IPagedEnumerable<TrackDto>>().With(paging);

                return Response.AsAccepted(result, new[] { "json", "m3u" }, model => Response.AsJson(model));
            };

            Post["/"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresWriteClaim("music");

                var model = this.BindAndValidate<AddTrack>();
                _commandBuilder.Execute(model);

                return new Response
                {
                    StatusCode = HttpStatusCode.Created
                };
            };

            Post["/tagged"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresWriteClaim("music");

                var model = this.BindAndValidate<MarkTrackWithTags>();
                _commandBuilder.Execute(model);

                return new Response
                {
                    StatusCode = HttpStatusCode.OK
                };
            };

            Delete["/tagged"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresWriteClaim("music");

                var model = this.BindAndValidate<RemoreTagsFromTrack>();
                _commandBuilder.Execute(model);

                return new Response
                {
                    StatusCode = HttpStatusCode.OK
                };
            };
        }
Exemple #7
0
 public CommandInterpreter(ICommandBuilder producer, IScene scene, TextReader reader)
     : this(producer, scene)
 {
     if (reader != null)
     {
         Console.SetIn(reader);
     }
 }
 public AutoUpdaterCommandCreator(ICheckTimer checkTimer, IConfigurationConverter configurationConverter, ICommandBuilder commandBuilder,
     INowGetter nowGetter, ILogger logger)
 {
     _checkTimer = checkTimer;
     _configurationConverter = configurationConverter;
     _commandBuilder = commandBuilder;
     _nowGetter = nowGetter;
     _logger = logger;
 }
        public CommandEndpoint(ICommandBuilder commandBuilder, Configuration.IProvider configurationProvider)
        {
            _commandBuilder = commandBuilder;
            _settings = configurationProvider.GetSettings();
            _instructionNumber = new InstructionNumber();

            _ipAddress = string.IsNullOrWhiteSpace(_settings.LocalIpAddress)
              ? Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork)
              : IPAddress.Parse(_settings.LocalIpAddress);
        }
Exemple #10
0
        public ICommand GetCommand()
        {
            if (this.currentBuilder == null)
            {
                return null;
            }

            var command = this.currentBuilder.GetCommand();
            this.currentBuilder = null;

            return command;
        }
Exemple #11
0
        public AccountModule(ICommandBuilder commandBuilder, IQueryBuilder queryBuilder)
            : base("/account")
        {
            _commandBuilder = commandBuilder;
            _queryBuilder = queryBuilder;

            Get["/"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresReadClaim("account");

                var paging = this.BindAndValidate<Paging>();
                var result = _queryBuilder.For<IPagedEnumerable<UserDto>>().With(paging);

                return Response.AsJson(result);
            };

            Post["/"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresWriteClaim("account");

                var findByEmail = this.BindAndValidate<FindByEmail>();
                var emailAlreadyInUse = _queryBuilder.For<UserDto>().With(findByEmail) != null;
                if (emailAlreadyInUse)
                {
                    return new Response
                    {
                        StatusCode = HttpStatusCode.BadRequest
                    };
                }

                var user = this.BindAndValidate<CreateUser>();
                _commandBuilder.Execute(user);

                return new Response
                {
                    StatusCode = HttpStatusCode.Created
                };
            };

            Post["/{email}"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresReadClaim("account");

                var credentials = this.BindAndValidate<Credentials>();
                var result = _queryBuilder.For<UserDto>().With(credentials);

                return Response.AsJson(result);
            };
        }
Exemple #12
0
 public IEnumerable<string> GetJoinClauses(IEnumerable<JoinClause> joins, ICommandBuilder commandBuilder)
 {
     var expressionFormatter = new ExpressionFormatter(commandBuilder, _schema);
     foreach (var join in joins)
     {
         var builder = new StringBuilder(JoinKeyword);
         builder.AppendFormat(" JOIN {0}{1} ON ({2})",
             _schema.FindTable(_schema.BuildObjectName(join.Table.ToString())).QualifiedName,
             string.IsNullOrWhiteSpace(join.Table.GetAlias()) ? string.Empty : " " + _schema.QuoteObjectName(join.Table.GetAlias()),
             expressionFormatter.Format(join.JoinExpression));
         yield return builder.ToString().Trim();
     }
 }
 public static void Filter(ref StringBuilder sqlBuilder,string field, ICommandBuilder builder)
 {
     if (OracleKeyWords.Exsit(field))
     {
         sqlBuilder.AppendFormat("{0}{1}{2}"
             , builder.ObjectNamePrefix
             , field
             , builder.ObjectNameSuffix
             );
     }
     else {
         sqlBuilder.Append(field);
     }
 }
		public void Get_UsingBuilderFactory_ShouldReturnCorrectValue(
			string name,
			ISchedulers schedulers,
			ICommandBuilder expected)
		{
			//arrange
			var sut = new CommandBuilderProvider(schedulers, (action, schedulers1, arg3) => expected);

			//act
			var actual = sut.Get(name);

			//assert
			actual.Should().Be(expected);
		}
 public ExpressionFormatter(ICommandBuilder commandBuilder, DatabaseSchema schema)
 {
     _commandBuilder = commandBuilder;
     _schema = schema;
     _expressionFormatters = new Dictionary<SimpleExpressionType, Func<SimpleExpression, string>>
           {
               {SimpleExpressionType.And, LogicalExpressionToWhereClause},
               {SimpleExpressionType.Or, LogicalExpressionToWhereClause},
               {SimpleExpressionType.Equal, EqualExpressionToWhereClause},
               {SimpleExpressionType.NotEqual, NotEqualExpressionToWhereClause},
               {SimpleExpressionType.GreaterThan, expr => BinaryExpressionToWhereClause(expr, ">")},
               {SimpleExpressionType.GreaterThanOrEqual, expr => BinaryExpressionToWhereClause(expr, ">=")},
               {SimpleExpressionType.LessThan, expr => BinaryExpressionToWhereClause(expr, "<")},
               {SimpleExpressionType.LessThanOrEqual, expr => BinaryExpressionToWhereClause(expr, "<=")},
           };
 }
Exemple #16
0
        public void AppendLine(string line)
        {
            if (this.currentBuilder == null)
            {
                foreach (var pair in this.commands.Where(pair => pair.Key.IsMatch(line)))
                {
                    this.currentBuilder = pair.Value(this.scene);
                    break;
                }
            }

            if (this.currentBuilder == null)
            {
                throw new ArgumentException("Can not recognize the command.");
            }

            this.currentBuilder.AppendLine(line);
        }
Exemple #17
0
        public static byte[] CreateLogoData(Emulation emulation)
        {
            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            builder.Append(Encoding.UTF8.GetBytes("*Normal*\n"));
            builder.AppendLogo(LogoSize.Normal, 1);

            builder.Append(Encoding.UTF8.GetBytes("\n*Double Width*\n"));
            builder.AppendLogo(LogoSize.DoubleWidth, 1);

            builder.Append(Encoding.UTF8.GetBytes("\n*Double Height*\n"));
            builder.AppendLogo(LogoSize.DoubleHeight, 1);

            builder.Append(Encoding.UTF8.GetBytes("\n*Double Width and Double Height*\n"));
            builder.AppendLogo(LogoSize.DoubleWidthDoubleHeight, 1);

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.EndDocument();

            return(builder.Commands);
        }
 public DotNetCliExecutor(ICommandBuilder commandBuilder)
 {
     _commandBuilder = commandBuilder;
 }
        public void TestCleanup()
        {
            _commandBuilder = null;

            _updatePackageMock = null;
            _singleFileMock = null;
            _loggerMock = null;
            _directoryMock = null;
        }
 public RemoveProductFromSubscriptionCommand(ICommandBuilder commandBuilder)
 {
     _commandBuilder = commandBuilder;
 }
Exemple #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:QueryBuilder" /> class.
 /// </summary>
 /// <param name="builder">The command builder.</param>
 /// <returns>The new instance.</returns>
 public static QueryBuilder NewQuery(ICommandBuilder builder)
 {
     return(new QueryBuilder(builder));
 }
Exemple #22
0
 public static Task ExecuteAsync(this ICommandBuilder builder, IInstrument instrument)
 {
     return(instrument.CommandAsync(builder.BuildCommand()));
 }
Exemple #23
0
 private static int Execute(ICommandBuilder commandBuilder, IAdapterTransaction transaction)
 {
     var dbTransaction = ((AdoAdapterTransaction) transaction).Transaction;
     using (var command = commandBuilder.GetCommand(dbTransaction.Connection))
     {
         command.Transaction = dbTransaction;
         return TryExecute(command);
     }
 }
        public override void AppendDotImpact3inchTextReceiptData(ICommandBuilder builder, bool utf8)
        {
            string encoding;

            if (utf8)
            {
                encoding = "UTF-8";

                builder.AppendCodePage(CodePageType.UTF8);
            }
            else
            {
                encoding = "Big5";
            }

            builder.AppendCharacterSpace(0);

            builder.AppendAlignment(AlignmentPosition.Center);

            builder.AppendEmphasis(true);

            builder.AppendMultipleHeight(Encoding.GetEncoding(encoding).GetBytes("Star Micronics\n"), 3);

            builder.AppendEmphasis(false);

            builder.Append(Encoding.GetEncoding(encoding).GetBytes("------------------------------------------\n"));

            builder.AppendMultiple(Encoding.GetEncoding(encoding).GetBytes(
                                       "電子發票證明聯\n" +
                                       "103年01-02月\n" +
                                       "EV-99999999\n"), 2, 2);

            builder.AppendAlignment(AlignmentPosition.Left);

            builder.Append(Encoding.GetEncoding(encoding).GetBytes(
                               "2014/01/15 13:00\n" +
                               "隨機碼 : 9999    總計 : 999\n" +
                               "賣方 : 99999999\n" +
                               "\n" +
                               "商品退換請持本聯及銷貨明細表。\n" +
                               "9999999-9999999 999999-999999 9999\n" +
                               "\n"));

            builder.AppendAlignment(Encoding.GetEncoding(encoding).GetBytes("銷貨明細表  (銷售)\n"), AlignmentPosition.Center);

            builder.AppendAlignment(Encoding.GetEncoding(encoding).GetBytes("2014-01-15 13:00:02\n"), AlignmentPosition.Right);

            builder.Append(Encoding.GetEncoding(encoding).GetBytes(
                               "\n" +
                               "烏龍袋茶2g20入             55 x2 110TX\n" +
                               "茉莉烏龍茶2g20入           55 x2 110TX\n" +
                               "天仁觀音茶2g*20            55 x2 110TX\n"));

            builder.AppendEmphasis(Encoding.GetEncoding(encoding).GetBytes(
                                       "      小  計 :             330\n" +
                                       "      總   計 :             330\n"));

            builder.Append(Encoding.GetEncoding(encoding).GetBytes(
                               "------------------------------------------\n" +
                               "現 金                       400\n" +
                               "      找  零 :              70\n"));

            builder.AppendEmphasis(Encoding.GetEncoding(encoding).GetBytes(" 101 發票金額 :             330\n"));

            builder.Append(Encoding.GetEncoding(encoding).GetBytes(
                               "2014-01-15 13:00\n" +
                               "\n" +
                               "商品退換、贈品及停車兌換請持本聯。\n" +
                               "9999999-9999999 999999-999999 9999\n"));
        }
Exemple #25
0
 protected ParameterBuilder(ICommandBuilder command, string name, Type type) : this(command)
 {
     Name = name;
     SetParameterType(type);
 }
 public DatabaseStatusFiller(string commandText, ICommandBuilder builder) : base(commandText, builder)
 {
 }
Exemple #27
0
 /// <exception cref="NotImplementedException"></exception>
 void IBindablePredicate.BindHaving(ICommandBuilder builder)
 {
     throw new NotImplementedException();
 }
Exemple #28
0
 /// <summary>
 /// Executes the command builder
 /// </summary>
 /// <param name="args"></param>
 /// <param name="sb"></param>
 /// <param name="cmd"></param>
 private void ExecuteCommandBuilder(ICommandBuilder cmd, GenerationArgs args, StringBuilder sb)
 {
     cmd.Build(args, sb);
 }
Exemple #29
0
 public CreateClientFormHandler(ICommandBuilder commandBuilder)
 {
     _commandBuilder = commandBuilder;
 }
        public virtual Object ReadObject(Type returnType, String elementName, int id, IReader reader)
        {
            if (!XmlDictionary.SetElement.Equals(elementName) && !XmlDictionary.ListElement.Equals(elementName))
            {
                throw new Exception("Element '" + elementName + "' not supported");
            }
            String lengthValue = reader.GetAttributeValue(XmlDictionary.SizeAttribute);
            int    length      = lengthValue != null && lengthValue.Length > 0 ? Int32.Parse(lengthValue) : 0;
            // Do not remove although in Java it is not necessary to extract the generic type information of a collection.
            // This code is important for environments like C#
            Type componentType = ClassElementHandler.ReadFromAttribute(reader);

            if (returnType.IsGenericType)
            {
                componentType = returnType.GetGenericArguments()[0];
            }
            MethodInfo addMethod = null;

            Object[]    parameters = new Object[1];
            IEnumerable coll;

            if (XmlDictionary.SetElement.Equals(elementName))
            {
                Type setType = typeof(HashSet <>).MakeGenericType(componentType);
                coll      = (IEnumerable)Activator.CreateInstance(setType);
                addMethod = setType.GetMethod("Add");
            }
            else
            {
                Type listType = typeof(List <>).MakeGenericType(componentType);
                coll      = (IEnumerable)(length > 0 ? Activator.CreateInstance(listType, length) : Activator.CreateInstance(listType));
                addMethod = listType.GetMethod("Add");
            }
            reader.PutObjectWithId(coll, id);
            reader.NextTag();
            bool                 useObjectFuture     = false;
            ICommandBuilder      commandBuilder      = CommandBuilder;
            ICommandTypeRegistry commandTypeRegistry = reader.CommandTypeRegistry;

            while (reader.IsStartTag())
            {
                Object item = reader.ReadObject(componentType);
                if (item is IObjectFuture)
                {
                    IObjectFuture  objectFuture = (IObjectFuture)item;
                    IObjectCommand command      = commandBuilder.Build(commandTypeRegistry, objectFuture, coll, addMethod);
                    reader.AddObjectCommand(command);
                    useObjectFuture = true;
                }
                else if (useObjectFuture)
                {
                    IObjectCommand command = commandBuilder.Build(commandTypeRegistry, null, coll, addMethod, item);
                    reader.AddObjectCommand(command);
                }
                else
                {
                    parameters[0] = item;
                    addMethod.Invoke(coll, parameters);
                }
            }
            return(coll);
        }
        public void AppendEscPos3inchTextReceiptData(ICommandBuilder commandBuilder, bool utf8)
        {
            Encoding encoding;

            if (utf8)
            {
                encoding = Encoding.UTF8;

                commandBuilder.AppendCodePage(CodePageType.UTF8);
            }
            else
            {
                encoding = Encoding.GetEncoding("Windows-1252");

                commandBuilder.AppendCodePage(CodePageType.CP1252);
            }

            commandBuilder.AppendInternational(InternationalType.Germany);

            commandBuilder.AppendCharacterSpace(0);

            commandBuilder.AppendAlignment(AlignmentPosition.Center);

            commandBuilder.AppendMultiple(encoding.GetBytes("STAR\n" +
                                                            "Supermarkt\n"), 2, 2);

            commandBuilder.Append(encoding.GetBytes("\n" +
                                                    "Das Internet von seiner\n" +
                                                    "genussvollsten Seite\n" +
                                                    "\n"));

            commandBuilder.AppendMultipleHeight(encoding.GetBytes("www.Star-EMEM.com\n"), 2);

            commandBuilder.Append(encoding.GetBytes("Gebührenfrei Rufnummer:\n"));

            commandBuilder.AppendEmphasis(encoding.GetBytes("08006646701\n"));

            commandBuilder.AppendAlignment(AlignmentPosition.Left);

            commandBuilder.Append(encoding.GetBytes("------------------------------------------\n"));

            commandBuilder.AppendEmphasis(encoding.GetBytes("                                       EUR\n"));

            commandBuilder.Append(encoding.GetBytes("Schmand 24%                           0.42\n" +
                                                    "Kefir                                 0.79\n" +
                                                    "Haarspray                             1.79\n" +
                                                    "Gurken ST                             0.59\n" +
                                                    "Mandelknacker                         1.59\n" +
                                                    "Mandelknacker                         1.59\n" +
                                                    "Nussecken                             1.69\n" +
                                                    "Nussecken                             1.69\n" +
                                                    "Clemen.1kg NZ                         1.49\n" +
                                                    "2X\n" +
                                                    "Zitronen ST                           1.18\n" +
                                                    "4X\n" +
                                                    "Grapefruit                            3.16\n" +
                                                    "Party Garnelen                        9.79\n" +
                                                    "Apfelsaft                             1.39\n" +
                                                    "Lauchzw./Schl.B                       0.49\n" +
                                                    "Butter                                1.19\n" +
                                                    "Profi-Haartrockner                   27.99\n" +
                                                    "Mozarella 45%                         0.59\n" +
                                                    "Mozarella 45%                         0.59\n" +
                                                    "Bruschetta Brot                       0.59\n" +
                                                    "Weizenmehl                            0.39\n" +
                                                    "Jodsalz                               0.19\n" +
                                                    "Eier M braun Bod                      1.79\n" +
                                                    "Schlagsahne                           1.69\n" +
                                                    "Schlagsahne                           1.69\n" +
                                                    "\n" +
                                                    "Rueckgeld                        EUR  0.00\n" +
                                                    "\n" +
                                                    "19.00% MwSt.                         13.14\n" +
                                                    "NETTO-UMSATZ                         82.33\n" +
                                                    "------------------------------------------\n" +
                                                    "KontoNr:  0551716000 / 0 / 0512\n" +
                                                    "BLZ:      58862159\n" +
                                                    "Trace-Nr: 027929\n" +
                                                    "Beleg:    7238\n" +
                                                    "------------------------------------------\n" +
                                                    "Kas: 003/006    Bon  0377 PC01 P\n" +
                                                    "Dat: 30.03.2015 Zeit 18:06:01 43\n" +
                                                    "\n"));

            commandBuilder.AppendAlignment(AlignmentPosition.Center);

            commandBuilder.Append(encoding.GetBytes("USt–ID:    DE125580123\n" +
                                                    "\n"));

            commandBuilder.AppendEmphasis(encoding.GetBytes("Vielen dank\n" +
                                                            "für Ihren Einkauf!\n" +
                                                            "\n"));

//          commandBuilder.AppendBarcode(encoding      .GetBytes("{BStar."), BarcodeSymbology.Code128, BarcodeWidth.Mode2, 40, true);
//          commandBuilder.AppendBarcode(Encoding.ASCII.GetBytes("{BStar."), BarcodeSymbology.Code128, BarcodeWidth.Mode2, 40, true);
            commandBuilder.AppendBarcode(Encoding.UTF8.GetBytes("{BStar."), BarcodeSymbology.Code128, BarcodeWidth.Mode2, 40, true);
        }
Exemple #32
0
        public virtual Object ReadObject(Type returnType, String elementName, int id, IReader reader)
        {
            if (!XmlDictionary.ArrayElement.Equals(elementName))
            {
                throw new Exception("Element '" + elementName + "' not supported");
            }
            int  length        = Int32.Parse(reader.GetAttributeValue(XmlDictionary.SizeAttribute));
            Type componentType = ClassElementHandler.ReadFromAttribute(reader);

            Array targetArray;

            if (!reader.IsEmptyElement())
            {
                reader.NextTag();
            }
            if ("values".Equals(reader.GetElementName()))
            {
                String listOfValuesString = reader.GetAttributeValue("v");

                if (typeof(char).Equals(componentType) || typeof(byte).Equals(componentType) || typeof(sbyte).Equals(componentType) ||
                    typeof(bool).Equals(componentType))
                {
                    targetArray = (Array)ConversionHelper.ConvertValueToType(componentType.MakeArrayType(), listOfValuesString, EncodingInformation.SOURCE_BASE64 | EncodingInformation.TARGET_PLAIN);
                    reader.PutObjectWithId(targetArray, id);
                }
                else
                {
                    targetArray = Array.CreateInstance(componentType, length);
                    reader.PutObjectWithId(targetArray, id);
                    String[] items = splitPattern.Split(listOfValuesString);
                    for (int a = 0, size = items.Length; a < size; a++)
                    {
                        String item = items[a];
                        if (item == null || item.Length == 0)
                        {
                            continue;
                        }
                        Object convertedValue = ConversionHelper.ConvertValueToType(componentType, items[a]);
                        targetArray.SetValue(convertedValue, a);
                    }
                }
                reader.MoveOverElementEnd();
            }
            else
            {
                if (returnType.IsGenericType)
                {
                    componentType = returnType.GetGenericArguments()[0];
                }
                targetArray = Array.CreateInstance(componentType, length);
                reader.PutObjectWithId(targetArray, id);
                ICommandBuilder      commandBuilder      = CommandBuilder;
                ICommandTypeRegistry commandTypeRegistry = reader.CommandTypeRegistry;
                for (int index = 0; index < length; index++)
                {
                    Object item = reader.ReadObject(componentType);
                    if (item is IObjectFuture)
                    {
                        IObjectFuture  objectFuture = (IObjectFuture)item;
                        IObjectCommand command      = commandBuilder.Build(commandTypeRegistry, objectFuture, targetArray, index);
                        reader.AddObjectCommand(command);
                    }
                    else
                    {
                        targetArray.SetValue(item, index);
                    }
                }
            }
            return(targetArray);
        }
Exemple #33
0
 void ICommandHeaders.Build(ICommandBuilder builder)
 {
     action(builder);
 }
Exemple #34
0
 private int Execute(ICommandBuilder commandBuilder, IAdapterTransaction transaction)
 {
     using (var command = commandBuilder.GetCommand(((AdoAdapterTransaction)transaction).Transaction.Connection))
     {
         return TryExecute(command);
     }
 }
Exemple #35
0
 /// <summary>
 ///     Initializes a new <see cref="ComponentCommandParameterBuilder"/>.
 /// </summary>
 /// <param name="command">Parent command of this parameter.</param>
 /// <param name="name">Name of this command.</param>
 /// <param name="type">Type of this parameter.</param>
 public ComponentCommandParameterBuilder(ICommandBuilder command, string name, Type type) : base(command, name, type)
 {
 }
Exemple #36
0
 public CommandLoader(ICommandBuilder commandBuilder)
 {
     this.CommandBuilder = commandBuilder;
 }
Exemple #37
0
 public ActUponCommandBase(ICommandBuilder <TContext, ActUponCommandBase <TContext> > b) : base(b)
 {
 }
Exemple #38
0
        private void ApplyPaging(SimpleQuery query, List <ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause, TakeClause takeClause, bool hasWithClause, IQueryPager queryPager)
        {
            const int maxInt = 2147483646;

            IEnumerable <string> commandTexts;

            if (skipClause == null && !hasWithClause)
            {
                commandTexts = queryPager.ApplyLimit(mainCommandBuilder.Text, takeClause.Count);
            }
            else
            {
                var table = _adapter.GetSchema().FindTable(query.TableName);
                var keys  = new string[0];
                if (table.PrimaryKey != null && table.PrimaryKey.Length > 0)
                {
                    keys = table.PrimaryKey.AsEnumerable()
                           .Select(k => string.Format("{0}.{1}", table.QualifiedName, _adapter.GetSchema().QuoteObjectName(k)))
                           .ToArray();
                }

                int skip = skipClause == null ? 0 : skipClause.Count;
                int take = takeClause == null ? maxInt : takeClause.Count;
                commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, keys, skip, take);
            }

            commandBuilders.AddRange(
                commandTexts.Select(
                    commandText =>
                    new CommandBuilder(commandText, _adapter.GetSchema(), mainCommandBuilder.Parameters)));
        }
Exemple #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:QueryBuilder" /> class.
 /// </summary>
 /// <param name="builder">The command builder.</param>
 public QueryBuilder(ICommandBuilder builder)
 {
     this.builder = builder;
 }
Exemple #40
0
 private static void RegisterCommandBuilder(ICommandBuilder commandBuilder)
 {
     CommandBuilders.Add(commandBuilder.Key.ToUpper(), commandBuilder);
 }
 public override void AppendTextLabelData(ICommandBuilder builder, bool utf8)
 {
     // not implemented
 }
Exemple #42
0
 internal int Execute(ICommandBuilder commandBuilder, IDbConnection connection)
 {
     using (connection.MaybeDisposable())
     {
         using (IDbCommand command = commandBuilder.GetCommand(connection, AdoOptions))
         {
             connection.OpenIfClosed();
             return command.TryExecuteNonQuery();
         }
     }
 }
Exemple #43
0
        void IBindablePredicate.BindHaving(ICommandBuilder builder)
        {
            builder.AppendFrom(Column.Table);

            builder.HavingPredicates.Add(this);
        }
Exemple #44
0
 internal int Execute(ICommandBuilder commandBuilder, IDbTransaction dbTransaction)
 {
     using (IDbCommand command = commandBuilder.GetCommand(dbTransaction.Connection, AdoOptions))
     {
         command.Transaction = dbTransaction;
         return command.TryExecuteNonQuery();
     }
 }
        public void TestInitialize()
        {
            TestCleanup();

            _updatePackageAccessMock = new UpdatePackageAccessMock();
            _updatePackageAccessMock.GetFilenameOnly = _fileName; // wird sowieso nie echt drauf zugegriffen
            _updatePackageMock = new UpdatePackageMock() { Access = _updatePackageAccessMock };
            _updatePackageMock.Settings = new ServerSettings()
            {
                DatabaseUpdaterCommandArguments = "ddl",
                DatabaseUpdaterCommand = "connectionString",
                CheckUrlsAfterInstallation = new[] { "fakeCheckUrl1", "fakeCheckUrl2" },
            };

            _singleFileMock = new SingleFileMock();
            _loggerMock = new LoggerMock();
            _directoryMock = new DirectoryMock();
            _runExternalCommandMock = new RunExternalCommandMock();
            _htmlGetterMock = new Mock<IHtmlGetter>();
            _nowGetterMock = new NowGetterMock();
            _blackboardMock = new Mock<IBlackboard>();

            _commandBuilder = new CommandBuilder(_singleFileMock, _directoryMock, _loggerMock, _runExternalCommandMock, _htmlGetterMock.Object, _nowGetterMock, _blackboardMock.Object);
        }
 private IEnumerable<IDictionary<string, object>> ExecuteQuery(ICommandBuilder commandBuilder)
 {
     using (var connection = CreateConnection())
     {
         using (var command = commandBuilder.GetCommand(connection))
         {
             return TryExecuteQuery(connection, command);
         }
     }
 }
Exemple #47
0
 public SimpleReferenceFormatter(DatabaseSchema schema, ICommandBuilder commandBuilder)
 {
     _schema         = schema;
     _commandBuilder = commandBuilder;
 }
 public override void FillCommandBuilder(ICommandBuilder updateCommandBuilder)
 {
 }
 public void AppendTextLabelData(ICommandBuilder commandBuilder, bool utf8)
 {
     throw new NotImplementedException();
 }
 public override void AppendPasteTextLabelData(ICommandBuilder builder, string pasteText, bool utf8)
 {
     // not implemented
 }
Exemple #51
0
 public UpdateHelper(DatabaseSchema schema)
 {
     _schema              = schema;
     _commandBuilder      = new CommandBuilder(schema);
     _expressionFormatter = new ExpressionFormatter(_commandBuilder, _schema);
 }
Exemple #52
0
 private int Execute(ICommandBuilder commandBuilder)
 {
     var connection = CreateConnection();
     using (connection.MaybeDisposable())
     {
         using (var command = commandBuilder.GetCommand(connection))
         {
             connection.OpenIfClosed();
             return TryExecute(command);
         }
     }
 }
Exemple #53
0
 private int Execute(ICommandBuilder commandBuilder)
 {
     IDbConnection connection = CreateConnection();
     using (connection.MaybeDisposable())
     {
         using (IDbCommand command = commandBuilder.GetCommand(connection, AdoOptions))
         {
             connection.OpenIfClosed();
             return command.TryExecuteNonQuery();
         }
     }
 }
Exemple #54
0
 internal ComponentCommandParameterBuilder(ICommandBuilder command) : base(command)
 {
 }
Exemple #55
0
 internal int Execute(ICommandBuilder commandBuilder, IAdapterTransaction transaction)
 {
     IDbTransaction dbTransaction = ((AdoAdapterTransaction) transaction).DbTransaction;
     return Execute(commandBuilder, dbTransaction);
 }
 private void DeferPaging(ref SimpleQuery query, ICommandBuilder mainCommandBuilder, List<ICommandBuilder> commandBuilders,
                          List<SimpleQueryClauseBase> unhandledClausesList)
 {
     unhandledClausesList.AddRange(query.Clauses.OfType<SkipClause>());
     unhandledClausesList.AddRange(query.Clauses.OfType<TakeClause>());
     query = query.ClearSkip().ClearTake();
     var commandBuilder = new CommandBuilder(mainCommandBuilder.Text, _adapter.GetSchema(),
                                             mainCommandBuilder.Parameters);
     commandBuilders.Add(commandBuilder);
 }
 private int Execute(ICommandBuilder commandBuilder)
 {
     using (var connection = CreateConnection())
     {
         using (var command = commandBuilder.GetCommand(connection))
         {
             return TryExecute(connection, command);
         }
     }
 }
        private void ApplyPaging(SimpleQuery query, List<ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause, TakeClause takeClause, bool hasWithClause, IQueryPager queryPager)
        {
            const int maxInt = 2147483646;

            IEnumerable<string> commandTexts;
            if (skipClause == null && !hasWithClause)
            {
                commandTexts = queryPager.ApplyLimit(mainCommandBuilder.Text, takeClause.Count);
            }
            else
            {
                var table = _adapter.GetSchema().FindTable(query.TableName);
                if (table.PrimaryKey == null || table.PrimaryKey.Length == 0)
                {
                    throw new AdoAdapterException("Cannot apply paging to a table with no primary key.");
                }
                var keys = table.PrimaryKey.AsEnumerable()
                     .Select(k => string.Format("{0}.{1}", table.QualifiedName, _adapter.GetSchema().QuoteObjectName(k)))
                     .ToArray();
                int skip = skipClause == null ? 0 : skipClause.Count;
                int take = takeClause == null ? maxInt : takeClause.Count;
                commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, keys,  skip, take);
            }

            commandBuilders.AddRange(
                commandTexts.Select(
                    commandText =>
                    new CommandBuilder(commandText, _adapter.GetSchema(), mainCommandBuilder.Parameters)));
        }
        internal int Execute(ICommandBuilder commandBuilder, IAdapterTransaction transaction)
        {
            IDbTransaction dbTransaction = ((AdoAdapterTransaction)transaction).DbTransaction;

            return(Execute(commandBuilder, dbTransaction));
        }
Exemple #60
0
 public CreatePoemForPersonEventHandler(ICommandBuilder commandBuilder)
 {
     this.commandBuilder = commandBuilder;
 }