Exemple #1
0
 public GetCommand(GetOptions options, IAzureClient azureClient, IOutput output, IUrlStore urlStore)
 {
     _options     = options;
     _azureClient = azureClient;
     _output      = output;
     _urlStore    = urlStore;
 }
Exemple #2
0
        protected override void ExecuteTask()
        {
            //TODO: Adding the alternet use of a fileset instead of the LocalItem property
            Workspace MyWorkspace = this.WorkspaceHelper.GetWorkspace(this.WorkspaceName, this.LocalItem, this.ServerConnection);

            GetOptions Options = this.GetGetOptions();

            this.ServerConnection.SourceControl.Getting += new GettingEventHandler(OnGet);

            if (!String.IsNullOrEmpty(this.ServerItem))
            {
                RecursionType Recursion = RecursionType.None;
                if (this.Recursive)
                {
                    Recursion = RecursionType.Full;
                }

                GetRequest GetReq = new GetRequest(new ItemSpec(this.ServerItem, Recursion), this.VersionSpec.GetVersionSpec());
                MyWorkspace.Get(GetReq, Options);
            }
            else
            {
                MyWorkspace.Get(this.VersionSpec.GetVersionSpec(), Options);
            }

            this.ServerConnection.SourceControl.Getting -= new GettingEventHandler(OnGet);
        }
        public void Intercept_CreatesObjectLazily_CallsInvokeMethod()
        {
            //Assign
            var typeContext = Substitute.For <AbstractTypeCreationContext>();
            var options     = new GetOptions();

            typeContext.Options = options;

            var config  = Substitute.For <AbstractTypeConfiguration>();
            var service = Substitute.For <IAbstractService>();

            var args = new ObjectConstructionArgs(
                null,
                typeContext,
                config,
                service
                );

            var invocation = Substitute.For <IInvocation>();

            invocation.Method.Returns(typeof(StubClass).GetMethod("CalledMe"));
            service.InstantiateObject(typeContext).Returns(new StubClass());

            var interceptor = new LazyObjectInterceptor(args, new LazyLoadingHelper());

            //Act
            interceptor.Intercept(invocation);

            //Assert
            invocation.Received(1).Proceed();
        }
        /// <summary>
        /// Converts LoadOptionsPost to LoadOptions of T
        /// </summary>
        /// <param name="posted"></param>
        /// <returns></returns>
        public GetOptions <T> ToModelGetOptions(LoadOpts posted)
        {
            GetOptions <T> opts = new GetOptions <T>();

            opts.Skip       = posted.Skip;
            opts.Showing    = posted.Showing;
            opts.SearchTerm = posted.SearchTerm;
            SortDir dir;

            if (Enum.TryParse(posted.Direction, out dir))
            {
                opts.Direction = dir;
            }

            if (string.IsNullOrEmpty(posted.OrderProperty) && opts.Showing != 0)
            {
                throw new Exception("OrderProperty must be set if Showing is not 0");
            }
            opts.OrderProperty = posted.OrderProperty;

            if (posted.Filters != null)
            {
                opts.Filters = ToFilterExpressions(posted.Filters);
            }
            return(opts);
        }
Exemple #5
0
 public virtual void GetTypeOptions(GetOptions options)
 {
     if (options.Cache == Cache.Default)
     {
         options.Cache = Cache;
     }
 }
Exemple #6
0
        public async Task Get_With_Pagination_Options_Should_Return_PageList_With_Page_1_When_30_Users_Exists()
        {
            // Arrange...
            var inMemoryContext = InMemoryContextHelper.Create();

            InMemoryContextHelper.AddUsersToContext(_fixture, inMemoryContext, 30);
            var sut             = new UserRepository(inMemoryContext);
            var getUsersOptions = new GetOptions
            {
                PageSize   = 10,
                PageNumber = 1
            };

            // Act...
            var pagedList = await sut.Get(getUsersOptions);

            // Assert...
            pagedList.Should().NotBeNull();
            pagedList.Count.Should().Be(10);
            pagedList.TotalCount.Should().Be(30);
            pagedList.CurrentPage.Should().Be(1);
            pagedList.TotalPages.Should().Be(3);
            pagedList.HasPrevious.Should().BeFalse();
            pagedList.HasNext.Should().BeTrue();
        }
Exemple #7
0
 public GetStatus Get(GetRequest request, GetOptions options,
                      GetFilterCallback filterCallback, object userData)
 {
     GetRequest[] requests = new GetRequest[1];
     requests[0] = request;
     return(Get(requests, options, filterCallback, userData));
 }
Exemple #8
0
        public static List <T> ToListWith <T>(this IQueryable <T> q, GetOptions <T> opts) where T : class
        {
            ExpressionGenerator <T> gen = new ExpressionGenerator <T>();

            //Expression<Func<T, bool>> fil = null;
            if (opts.Filters != null)
            {
                //fil = (Expression<Func<T, bool>>)opts.Filters[0];
                for (int i = 0; i < opts.Filters.Count; i++)
                {
                    Expression <Func <T, bool> > e = (Expression <Func <T, bool> >)opts.Filters[i];
                    q = q.Where(e);
                }
            }

            if (!string.IsNullOrEmpty(opts.OrderProperty))
            {
                q = gen.SortWith(q, opts.OrderProperty, opts.Direction);
            }

            if (opts.Showing > 0)
            {
                q = q.Skip(opts.Skip).Take(opts.Showing);
            }

            return(q.ToList());
        }
Exemple #9
0
        public async Task Sort_Should_Sort_Users_Into_Correct_Order_When_Ascending()
        {
            // Arrange...
            var inMemoryContext = InMemoryContextHelper.Create();

            InMemoryContextHelper.AddUsersToContext(_fixture, inMemoryContext, 3);
            var sut        = new UserRepository(inMemoryContext);
            var getOptions = new GetOptions();
            var ordering   = new Ordering("FirstName", SortOrder.Ascending);

            getOptions.AddOrdering(ordering);

            // Act...
            var pageOfUsers = await sut.Get(getOptions);

            // Assert...
            pageOfUsers.Should().NotBeNull();
            pageOfUsers.Count.Should().Be(3);
            pageOfUsers.TotalCount.Should().Be(3);
            var orderedInMemoryUsers = inMemoryContext.Users.OrderBy(x => x.FirstName);
            var firstUser            = orderedInMemoryUsers.Skip(0).Take(1);
            var secondUser           = orderedInMemoryUsers.Skip(1).Take(1);
            var thirdUser            = orderedInMemoryUsers.Skip(2).Take(1);

            pageOfUsers.Skip(0).Take(1).Should().BeEquivalentTo(firstUser);
            pageOfUsers.Skip(1).Take(1).Should().BeEquivalentTo(secondUser);
            pageOfUsers.Skip(2).Take(1).Should().BeEquivalentTo(thirdUser);
        }
Exemple #10
0
        private static bool DoValidate(GetOptions options)
        {
            bool valid = true;

            // -exe and -asm are required
            if (!options.Has("-exe"))
            {
                Console.Error.WriteLine("-exe is required");
                valid = false;
            }
            if (!options.Has("-asm"))
            {
                Console.Error.WriteLine("-asm is required");
                valid = false;
            }

            // should not be any operands
            if (options.Operands.Length > 0)
            {
                Console.Error.WriteLine("operands are not supported");
                valid = false;
            }

            return(valid);
        }
        public GetStatus Get(GetRequest request, GetOptions options, IProgressMonitor monitor = null)
        {
            var requests = new List <GetRequest> {
                request
            };

            return(Get(requests, options, monitor));
        }
        public override void GetPropertyOptions(GetOptions propertyOptions)
        {
            propertyOptions.InferType = this.InferType;

            base.GetPropertyOptions(propertyOptions);

            propertyOptions.Type = GetTypeToConstruct();
        }
Exemple #13
0
        private static void DoParse(GetOptions options, string[] args)
        {
            options.Add("-exe=", "Path to the smokey exe");
            options.Add("-asm=", "Comma separated list of assemblies");
            options.Add("-help", "-?", "Show this help list and exit");
            options.Add("-version", "Display version and licensing information and exit");

            options.Parse(args);
        }
Exemple #14
0
        public override void Copy(GetOptions other)
        {
            var local = other as GetKnownOptions;

            if (local != null)
            {
            }
            base.Copy(other);
        }
Exemple #15
0
        private static void DoShowHelp(GetOptions options)
        {
            Version version = Assembly.GetExecutingAssembly().GetName().Version;

            Console.WriteLine("functest {0} - Copyright (C) 2007-2008 Jesse Jones", version);                   // TODO: update the year as needed
            Console.WriteLine("Functional test for Smokey.");
            Console.WriteLine();

            options.ShowHelp();
        }
        public GetStatus Get(List <GetRequest> requests, GetOptions options, IProgressMonitor monitor = null)
        {
            bool force = options.HasFlag(GetOptions.GetAll);
            bool noGet = options.HasFlag(GetOptions.Preview);

            var getOperations = this.VersionControlService.Get(this, requests, force, noGet);

            ProcessGetOperations(getOperations, ProcessType.Get, monitor);
            return(new GetStatus(getOperations.Count));
        }
        public override void Copy(GetOptions other)
        {
            var local = other as GetItemsByQueryOptions;

            if (local != null)
            {
                this.Query = local.Query;
            }
            base.Copy(other);
        }
        private void GizmoAction()
        {
            var options = GetOptions.ToList();

            if (options.Count == 0)
            {
                return;
            }
            Find.WindowStack.Add(new FloatMenu(options));
        }
Exemple #19
0
        public virtual void GetPropertyOptions(GetOptions propertyOptions)
        {
            var scPropertyOptions = propertyOptions as GetItemOptions;

            Assert.IsNotNull(scPropertyOptions, "propertyOptions  must be of type GetItemOptions");

            scPropertyOptions.EnforceTemplate = SitecoreEnforceTemplate.Default;

            base.GetPropertyOptions(propertyOptions);
        }
Exemple #20
0
        public override void Copy(GetOptions other)
        {
            var local = other as GetItemByPathOptions;

            if (local != null)
            {
                this.Path = local.Path;
            }
            base.Copy(other);
        }
Exemple #21
0
        public override void Copy(GetOptions other)
        {
            var local = other as GetItemByIdOptions;

            if (local != null)
            {
                this.Id = local.Id;
            }
            base.Copy(other);
        }
        public void Get()
        {
            var getOptions = new GetOptions
            {
                MakeWritable = MakeWritableType.MakeAllFilesWritable, Recursive = true, Merge = MergeType.OverwriteWorkingCopy, PerformDeletions = PerformDeletionsType.RemoveWorkingCopy
            };

            Console.WriteLine("Getting from SourceGear");
            GetOperations.ProcessCommandGet(new [] { _repoFolder }, getOptions);
        }
        public override void Copy(GetOptions other)
        {
            var local = other as GetItemsByFuncOptions;

            if (local != null)
            {
                this.ItemsFunc = local.ItemsFunc;
            }
            base.Copy(other);
        }
Exemple #24
0
        public LoadResult FindAs <TR>(Expression <Func <T, TR> > exp, GetOptions <TR> opts, Expression <Func <T, bool> > cond = null) where TR : class
        {
            var q = Loader;

            if (cond != null)
            {
                q = q.Where(cond);
            }

            return(q.Select(exp).LoadWith(opts));
        }
        public virtual void GetPropertyOptions(GetOptions propertyOptions)
        {
            var local = propertyOptions as GetItemOptions;

            if (local != null)
            {
                local.EnforceTemplate = EnforceTemplate;
                local.TemplateId      = TemplateId;
            }
            base.GetPropertyOptions(propertyOptions);
        }
Exemple #26
0
        public override void Copy(GetOptions other)
        {
            var local = other as GetItemOptionsParams;

            if (local != null)
            {
                this.Language = local.Language;
                this.Version  = local.Version;
            }
            base.Copy(other);
        }
        public HttpResponseMessage Get(GetOptions options)
        {
            var injections = DataContext.Instance().ExecuteQuery <Injection>(
                CommandType.StoredProcedure,
                "WebGoat_GetInjections",
                ValidateTop(options.Top),
                ValidateOrder(options.Order));

            var messages = injections.Select(i => i.Message);

            return(this.Request.CreateResponse(HttpStatusCode.OK, messages));
        }
Exemple #28
0
 public GetRequest(Qoollo.BobClient.BobKey key, bool fullGet = false)
 {
     Key = new BlobKey
     {
         //Key = ByteString.CopyFrom(key.GetKeyBytes())
         Key = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(key.GetKeyBytes())
     };
     Options = new GetOptions
     {
         Source = fullGet ? GetSource.All : GetSource.Normal,
     };
 }
Exemple #29
0
        public override void Copy(GetOptions other)
        {
            var local = other as GetOptionsSc;

            if (local != null)
            {
                //this.TemplateId = local.TemplateId;
                // this.EnforceTemplate = local.EnforceTemplate;
                this.VersionCount = local.VersionCount;
            }
            base.Copy(other);
        }
Exemple #30
0
        public GetStatus Get(string[] items, VersionSpec version,
                             RecursionType recursion, GetOptions options)
        {
            List <GetRequest> requests = new List <GetRequest>();

            foreach (string item in items)
            {
                requests.Add(new GetRequest(item, recursion, version));
            }

            return(Get(requests.ToArray(), options, null, null));
        }
Exemple #31
0
        public static void Main(string[] args)
        {
            #if LOG4NET
            log4net.Config.BasicConfigurator.Configure();
            #endif
            var con = Connection;
            var provider = Provider;

            Console.WriteLine("--- {0} ({1}) ---", con, con.ConnectionString);
            Console.WriteLine("--- " + provider + " ---");
            //int count = 100000;
            int count = 100;
            DateTime start, stop;

            // WARMUP
            con.Open();
            con.Close();

            Console.WriteLine("--- CONNECT ---");
            start = DateTime.UtcNow;
            con.Open();
            stop = DateTime.UtcNow;
            Console.WriteLine("IDbConnect.Open(): took: " + (stop - start).TotalMilliseconds + " ms");

            Console.WriteLine("--- DISCONNECT ---");
            start = DateTime.UtcNow;
            con.Close();
            stop = DateTime.UtcNow;
            Console.WriteLine("IDbConnect.Close(): took: " + (stop - start).TotalMilliseconds + " ms");

            con.Open();
            DatabaseManager dbMan = new DatabaseManager(con, provider);
            if (dbMan.TableExists(typeof(DBTest))) {
                dbMan.DropTable(typeof(DBTest));
            }
            dbMan.InitTable(typeof(DBTest));

            // WARMUP
            TestLowLevel(con, 1);
            dbMan.EmptyTable(typeof(DBTest));
            TestHighLevel(dbMan, 1);
            dbMan.EmptyTable(typeof(DBTest));

            // RUN

            // HARD CLEAN UP
            dbMan.DropTable(typeof(DBTest));
            dbMan.InitTable(typeof(DBTest));

            // SHOWTIME
            start = DateTime.UtcNow;
            TestLowLevel(con, count);
            stop = DateTime.UtcNow;
            double sqlAvg = (stop - start).TotalMilliseconds / count;

            // BREAK
            Thread.Sleep(5000);

            // HARD CLEAN UP
            dbMan.DropTable(typeof(DBTest));
            dbMan.InitTable(typeof(DBTest));

            // BREAK
            Thread.Sleep(5000);

            // SHOWTIME
            Console.WriteLine("--- INSERT (" + count + ") ---");
            start = DateTime.UtcNow;
            TestHighLevel(dbMan, count);
            stop = DateTime.UtcNow;
            double queryAvg = (stop - start).TotalMilliseconds / count;

            Console.WriteLine("raw SQL INSERTs avg: " + sqlAvg + " ms/query");
            Console.WriteLine("query.Add() avg: " + queryAvg  + " ms/query");

            Query<DBTest> query = new Query<DBTest>(dbMan);
            // warm up
            IList<DBTest> tests = query.GetAll(null, "PKInt32");
            DBTest template;
            int limit = count / 4;
            int offset = count / 2;
            GetOptions options;

            Console.WriteLine("--- SELECT pk_int32 ---");
            start = DateTime.UtcNow;
            tests = query.GetAll(null, "PKInt32");
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetAll() rows: " + tests.Count);
            Console.WriteLine("query.GetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.GetAll() avg: " + (stop - start).TotalMilliseconds / tests.Count  + " ms/row");

            Console.WriteLine("--- SELECT * ---");
            start = DateTime.UtcNow;
            tests = query.GetAll(null, "*");
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetAll() rows: " + tests.Count);
            Console.WriteLine("query.GetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.GetAll() avg: " + (stop - start).TotalMilliseconds / tests.Count  + " ms/row");

            Console.WriteLine("--- SELECT pk_int32 WHERE pk_int32 = 1 ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.PKInt32 = 1;
            tests = query.GetAll(template, "PKInt32");
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetAll() rows: " + tests.Count);
            Console.WriteLine("query.GetAll() took: " + (stop - start).TotalMilliseconds + " ms");

            Console.WriteLine("--- SELECT pk_int32 WHERE pk_int32 = 1 AND string_column = 'abc' ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.PKInt32 = 1;
            template.StringColumn = "abc";
            tests = query.GetAll(template, "PKInt32");
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetAll() rows: " + tests.Count);
            Console.WriteLine("query.GetAll() took: " + (stop - start).TotalMilliseconds + " ms");

            Console.WriteLine("--- SELECT pk_int32 WHERE pk_int32 = 1 ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.PKInt32 = 1;
            query.GetSingle(template, "PKInt32");
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetSingle() took: " + (stop - start).TotalMilliseconds + " ms");

            Console.WriteLine("--- SELECT pk_int32 LIMIT " + limit + " ---");
            start = DateTime.UtcNow;
            options = new GetOptions();
            options.SelectFields = new string[] { "PKInt32" };
            options.Limit = limit;
            tests = query.GetAll(null, options);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetAll() rows: " + tests.Count);
            Console.WriteLine("query.GetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.GetAll() avg: " + (stop - start).TotalMilliseconds / tests.Count  + " ms/row");

            Console.WriteLine("--- SELECT pk_int32 LIMIT " + limit + " OFFSET " + offset + " ---");
            start = DateTime.UtcNow;
            options = new GetOptions();
            options.SelectFields = new string[] { "PKInt32" };
            options.Limit = limit;
            options.Offset = offset;
            tests = query.GetAll(null, options);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetAll() rows: " + tests.Count);
            Console.WriteLine("query.GetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.GetAll() avg: " + (stop - start).TotalMilliseconds / tests.Count  + " ms/row");

            Console.WriteLine("--- SELECT pk_int32 ORDER BY pk_int32 ASC ---");
            start = DateTime.UtcNow;
            options = new GetOptions();
            options.SelectFields.Add("PKInt32");
            options.OrderBy.Add("pk_int32", OrderByDirection.Ascending);
            tests = query.GetAll(null, options);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetAll() rows: " + tests.Count);
            Console.WriteLine("query.GetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.GetAll() avg: " + (stop - start).TotalMilliseconds / tests.Count  + " ms/row");

            Console.WriteLine("--- SELECT pk_int32 ORDER BY datetime_column ASC ---");
            start = DateTime.UtcNow;
            options = new GetOptions();
            options.SelectFields.Add("PKInt32");
            options.OrderBy.Add("datetime_column", OrderByDirection.Ascending);
            tests = query.GetAll(null, options);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetAll() rows: " + tests.Count);
            Console.WriteLine("query.GetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.GetAll() avg: " + (stop - start).TotalMilliseconds / tests.Count  + " ms/row");

            Console.WriteLine("--- SELECT pk_int32 ORDER BY datetime_column DESC, pk_int ASC ---");
            start = DateTime.UtcNow;
            options = new GetOptions();
            options.SelectFields.Add("PKInt32");
            options.OrderBy.Add("datetime_column", OrderByDirection.Descending);
            options.OrderBy.Add("pk_int32", OrderByDirection.Ascending);
            tests = query.GetAll(null, options);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetAll() rows: " + tests.Count);
            Console.WriteLine("query.GetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.GetAll() avg: " + (stop - start).TotalMilliseconds / tests.Count  + " ms/row");

            Console.WriteLine("--- SELECT pk_int32 LIMIT 1 ---");
            start = DateTime.UtcNow;
            options = new GetOptions();
            options.SelectFields.Add("PKInt32");
            query.GetFirst(null, options);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.GetFirst() took: " + (stop - start).TotalMilliseconds + " ms");

            Console.WriteLine("--- UPDATE string_column WHERE pk_int32 = 1 ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.PKInt32 = 1;
            template.StringColumn = "foobar";
            int rows = query.SetAll(template);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.SetAll() rows: " + rows);
            Console.WriteLine("query.SetAll() took: " + (stop - start).TotalMilliseconds + " ms");

            /*
            Console.WriteLine("--- UPDATE string_column WHERE pk_int32 = 1 AND string_column = 'foobar' ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.PKInt32 = 1;
            template.StringColumn = "foobar";
            rows = query.SetAll(template);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.SetAll() rows: " + rows);
            Console.WriteLine("query.SetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            */

            Console.WriteLine("--- UPDATE string_column WHERE pk_int32 = 1 ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.PKInt32 = 1;
            template.StringColumn = "barfoo";
            query.SetSingle(template);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.SetSingle() took: " + (stop - start).TotalMilliseconds + " ms");

            Console.WriteLine("--- UPDATE string_column * ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.StringColumn = "barfoo123";
            rows = query.SetAll(template);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.SetAll() rows: " + rows);
            Console.WriteLine("query.SetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.SetAll() avg: " + (stop - start).TotalMilliseconds / rows  + " ms/row");

            Console.WriteLine("--- UPDATE bool_column WHERE pk_int32 = 1 ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.PKInt32 = 1;
            template.BooleanColumn = false;
            query.SetSingle(template);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.SetSingle() took: " + (stop - start).TotalMilliseconds + " ms");

            Console.WriteLine("--- UPDATE bool_column * ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.BooleanColumn = false;
            rows = query.SetAll(template);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.SetAll() rows: " + rows);
            Console.WriteLine("query.SetAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.SetAll() avg: " + (stop - start).TotalMilliseconds / rows  + " ms/row");

            Console.WriteLine("--- DELETE WHERE pk_int32 = 1 ---");
            start = DateTime.UtcNow;
            template = new DBTest();
            template.PKInt32 = 1;
            query.RemoveSingle(template);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.RemoveSingle() took: " + (stop - start).TotalMilliseconds + " ms");

            Console.WriteLine("--- DELETE * ---");
            start = DateTime.UtcNow;
            rows = query.RemoveAll(null);
            stop = DateTime.UtcNow;
            Console.WriteLine("query.RemoveAll() rows: " + rows);
            Console.WriteLine("query.RemoveAll() took: " + (stop - start).TotalMilliseconds + " ms");
            Console.WriteLine("query.RemoveAll() avg: " + (stop - start).TotalMilliseconds / rows  + " ms/row");

            con.Close();
            con.Dispose();
        }
Exemple #32
0
        public GetStatus Get(string[] items, VersionSpec version,
													RecursionType recursion, GetOptions options)
        {
            List<GetRequest> requests = new List<GetRequest>();
            foreach (string item in items)
                {
                    requests.Add(new GetRequest(item, recursion, version));
                }

            return Get(requests.ToArray(), options, null, null);
        }
Exemple #33
0
 public GetStatus Get(VersionSpec versionSpec, GetOptions options)
 {
     GetRequest request = new GetRequest(versionSpec);
     return Get(request, GetOptions.None, null, null);
 }
Exemple #34
0
 public GetStatus Get(GetRequest[] requests, GetOptions options)
 {
     return Get(requests, options, null, null);
 }
Exemple #35
0
        public GetStatus Get(GetRequest request, GetOptions options, 
												 GetFilterCallback filterCallback, object userData)
        {
            GetRequest[] requests = new GetRequest[1];
            requests[0] = request;
            return Get(requests, options, filterCallback, userData);
        }
Exemple #36
0
        public GetStatus Get(GetRequest[] requests, GetOptions options, 
												 GetFilterCallback filterCallback, object userData)
        {
            bool force = ((GetOptions.Overwrite & options) == GetOptions.Overwrite);
            bool noGet = false; // not implemented below: ((GetOptions.Preview & options) == GetOptions.Preview);

            SortedList<int, DateTime> changesetDates = new SortedList<int, DateTime>();
            GetOperation[] getOperations = Repository.Get(Name, OwnerName, requests, force, noGet);
            if (null != filterCallback) filterCallback(this, getOperations, userData);

            UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);
            foreach (GetOperation getOperation in getOperations)
                {
                    string uPath = null;
                    GettingEventArgs args = new GettingEventArgs(this, getOperation);

                    // Console.WriteLine(getOperation.ToString());

                    if (getOperation.DeletionId != 0)
                        {
                            if ((getOperation.ItemType == ItemType.Folder)&&
                                    (Directory.Exists(getOperation.SourceLocalItem)))
                                {
                                    UnsetDirectoryAttributes(getOperation.SourceLocalItem);
                                    Directory.Delete(getOperation.SourceLocalItem, true);
                                }
                            else if ((getOperation.ItemType == ItemType.File)&&
                                             (File.Exists(getOperation.SourceLocalItem)))
                                {
                                    UnsetFileAttributes(getOperation.SourceLocalItem);
                                    File.Delete(getOperation.SourceLocalItem);
                                }
                        }
                    else if ((!String.IsNullOrEmpty(getOperation.TargetLocalItem))&&
                                     (!String.IsNullOrEmpty(getOperation.SourceLocalItem))&&
                                     (getOperation.SourceLocalItem != getOperation.TargetLocalItem))
                        {
                            uPath = getOperation.TargetLocalItem;
                            try
                                {
                                    File.Move(getOperation.SourceLocalItem, getOperation.TargetLocalItem);
                                }
                            catch (IOException)
                                {
                                    args.Status = OperationStatus.TargetIsDirectory;
                                }
                        }
                    else if (getOperation.ChangeType == ChangeType.None &&
                                     getOperation.VersionServer != 0)
                        {
                            uPath = getOperation.TargetLocalItem;
                            string directory = uPath;

                            if (getOperation.ItemType == ItemType.File)
                                directory = Path.GetDirectoryName(uPath);

                            if (!Directory.Exists(directory))
                                Directory.CreateDirectory(directory);

                            if (getOperation.ItemType == ItemType.File)
                                {
                                    DownloadFile.WriteTo(uPath, Repository, getOperation.ArtifactUri);

                                    // ChangesetMtimes functionality : none standard!
                                    if (mTimeSetting)
                                        {
                                            int cid = getOperation.VersionServer;
                                            DateTime modDate;

                                            if (!changesetDates.TryGetValue(cid, out modDate))
                                                {
                                                    Changeset changeset = VersionControlServer.GetChangeset(cid);
                                                    modDate = changeset.CreationDate;
                                                    changesetDates.Add(cid, modDate);
                                                }

                                            File.SetLastWriteTime(uPath, modDate);
                                        }

                                    // do this after setting the last write time!
                                    SetFileAttributes(uPath);
                                }
                        }

                    versionControlServer.OnDownloading(args);
                    updates.QueueUpdate(getOperation.ItemId, uPath, getOperation.VersionServer);
                }

            updates.Flush();
            return new GetStatus(getOperations.Length);
        }
Exemple #37
0
        private byte[] OnGetOptions(GameSession session, byte[] body)
        {
            GetOptions request = new GetOptions();
            using(Stream stream = new MemoryStream(body)) {
                request.Deserialize(stream);
            }

            ClientOptions response = new ClientOptions();
            response.Options.Add(new PegasusUtil.ClientOption() {
                Index = 1,
                AsUint64 = 0x20FFFF3FFFCCFCFF
            });

            response.Options.Add(new PegasusUtil.ClientOption() {
                Index = 2,
                AsUint64 = 0xF0BFFFEF3FFF
            });

            response.Options.Add(new PegasusUtil.ClientOption() {
                Index = 18,
                AsUint64 = 0xB765A8C
            });

            return response.EncodeResponse(241);
        }