예제 #1
0
        public void GetAllDesignersWithProducts()
        {
            var         sql   = @"select * from DapperDesigners D 
                LEFT OUTER JOIN Products P
                ON P.DapperDesignerId = D.Id";
            List <long> times = new List <long>();
            IEnumerable <DapperDesigner> designers = new List <DapperDesigner>();

            for (int i = 0; i < _iterations; i++)
            {
                using (var conn = Utils.CreateOpenConnection()) {
                    _sw.Reset();
                    _sw.Start();
                    designers = conn.Query <DapperDesigner, Product, DapperDesigner>(sql,
                                                                                     (designer, product) => { designer.Products.Add(product); return(designer); });

                    _sw.Stop();
                    times.Add(_sw.ElapsedMilliseconds);
                    _retrievedObjects = designers.Count();
                }
            }
            var analyzer = new TimeAnalyzer(times);

            Utils.Output(times, analyzer, "Dapper: GetAllDesignersWithProducts");
            Console.WriteLine($"Latest Retrieved Object Count:{_retrievedObjects}");
            Assert.AreNotEqual(0, designers.Count());
        }
예제 #2
0
        public void GetAllDesignersWithClients_ViaRawSqlNotTracked()
        {
            List <long> times     = new List <long>();
            var         sql       = @"SELECT D.*,C.*
                  FROM DapperDesigners D  
                  LEFT OUTER JOIN DapperDesignerClients dc on (D.Id = dc.DapperDesigner_Id)
                  LEFT OUTER JOIN Clients C on (dc.Client_Id = C.Id);";
            var         designers = new List <DapperDesigner>();

            for (int i = 0; i < _iterations; i++)
            {
                using (var context = new DapperDesignerContext()) {
                    _sw.Reset();
                    _sw.Start();
                    designers = context.Designers.SqlQuery(sql).AsNoTracking().ToList();
                    _sw.Stop();
                    times.Add(_sw.ElapsedMilliseconds);
                    _trackedObjects = context.ChangeTracker.Entries().Count();
                }
            }
            var analyzer = new TimeAnalyzer(times);

            Utils.Output(times, analyzer, "EF: GetAllDesignersWithClientsViaRawSqlNotTracked");
            Console.WriteLine($"Latest Tracked Objects:{_trackedObjects}");

            Assert.AreNotEqual(0, designers.Select(d => d.Clients).Count());
        }
예제 #3
0
        public void GetAllDesignersWithClients()
        {
            var         sql   = @"SELECT D.Id, d.LabelName,C.Id, C.Name
                  FROM DapperDesigners D  
                  LEFT OUTER JOIN DapperDesignerClients dc on (D.Id = dc.DapperDesigner_Id)
                  LEFT OUTER JOIN Clients C on (dc.Client_Id = C.Id);";
            List <long> times = new List <long>();
            IEnumerable <DapperDesigner> designers = new List <DapperDesigner>();

            for (int i = 0; i < _iterations; i++)
            {
                using (var conn = Utils.CreateOpenConnection()) {
                    _sw.Reset();
                    _sw.Start();
                    designers = conn.Query <DapperDesigner, Client, DapperDesigner>
                                    (sql, (designer, client)
                                    => { designer.Clients.Add(client); return(designer); }
                                    );

                    _sw.Stop();
                    times.Add(_sw.ElapsedMilliseconds);
                    _retrievedObjects = designers.Count();
                }
            }
            var analyzer = new TimeAnalyzer(times);

            Utils.Output(times, analyzer, "Dapper: GetAllDesignersWithClients");
            Console.WriteLine($"Latest Retrieved Object Count:{_retrievedObjects}");
            Assert.AreNotEqual(0, designers.Select(d => d.Clients).Count());
        }
예제 #4
0
        public void GetAllDesignersWithContactInfo()
        {
            var         sql   = @"select * from DapperDesigners D 
                LEFT OUTER JOIN ContactInfoes C
                ON C.Id = D.Id";
            List <long> times = new List <long>();
            IEnumerable <DapperDesigner> designers = new List <DapperDesigner>();

            for (int i = 0; i < _iterations; i++)
            {
                using (var conn = Utils.CreateOpenConnection()) {
                    _sw.Reset();
                    _sw.Start();
                    designers = conn.Query <DapperDesigner, ContactInfo, DapperDesigner>(sql,
                                                                                         (designer, contact) => { designer.ContactInfo = contact; return(designer); });

                    _sw.Stop();
                    times.Add(_sw.ElapsedMilliseconds);
                    _retrievedObjects = designers.Count();
                }
            }
            var analyzer = new TimeAnalyzer(times);

            Utils.Output(times, analyzer, "Dapper: GetAllDesignersWithContactInfo");
            Console.WriteLine($"Latest Retrieved Object Count:{_retrievedObjects}");
            Console.WriteLine($"Proof of Contact: {designers.FirstOrDefault().ContactInfo.Twitter}");
            Assert.IsNotNull(designers.FirstOrDefault().ContactInfo);
        }
예제 #5
0
        public void GetAllDesignersWithContactsAndClients_Tracking()
        {
            List <long> times = new List <long>();

            for (int i = 0; i < _iterations; i++)
            {
                using (var context = new DapperDesignerContext()) {
                    _sw.Reset();
                    _sw.Start();
                    var designers = context.Designers.Include(d => d.ContactInfo).Include(d => d.Clients).ToList();
                    _sw.Stop();
                    times.Add(_sw.ElapsedMilliseconds);
                    _trackedObjects = context.ChangeTracker.Entries().Count();
                }
            }
            var analyzer = new TimeAnalyzer(times);

            Utils.Output(times, analyzer, "EF: GetAllDesignersWithContactsAndClientsTracking");
            Console.WriteLine($"Latest Tracked Objects:{_trackedObjects}");
            Assert.IsTrue(true);
        }
예제 #6
0
        public async Task <ActionResult <TSUser> > Authorize(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "user/authorize")] HttpRequest req,
            ILogger log)
        {
            TSUser tsUser = await MyFromBody <TSUser> .FromBody(req, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));


            ClaimsPrincipal User = MyTokenValidator.Authenticate(req, AllowedRoles, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));


            Guid UserID = Guid.Parse(LocalFunctions.CmdGetValueFromClaim(User.Claims, "UserID", 10, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod())));


            await CosmosAPI.cosmosDBClientActivity.AddActivityLog(UserID, "Requested authentication", TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));

            TSUser result = new TSUser();


            tsUser.ID = UserID;

            result = CosmosAPI.cosmosDBClientUser.GetUser(tsUser, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod())).Result;


            if (!result.ID.Equals(Guid.Empty))
            {
                await CosmosAPI.cosmosDBClientFeedMessage.AddFeedMessage(RequestedActionEnum.NotifyAdmin, "New Login " + result.UserName, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));

                await CosmosAPI.cosmosDBClientSetting.UpdateSettingCounter(Guid.Empty, "LiveUsersCount", true, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));
            }
            else
            {
                result.UserName = "******";
                result.FullName = "Can't find user!";
            }

            TimeAnalyzer.LogAll();

            return(result);
        }
예제 #7
0
        public void GetAllProjectedDesigners()
        {
            List <long> times = new List <long>();

            for (int i = 0; i < _iterations; i++)
            {
                using (var conn = Utils.CreateOpenConnection()) {
                    _sw.Reset();
                    _sw.Start();
                    var designers = conn.Query <DapperDesigner>("select  LabelName as Name, id from DapperDesigners");
                    _sw.Stop();
                    times.Add(_sw.ElapsedMilliseconds);
                    _retrievedObjects = designers.Count();
                }
            }
            var analyzer = new TimeAnalyzer(times);

            Utils.Output(times, analyzer, "Dapper: GetAllProjectedDesigners");
            Console.WriteLine($"Latest Retrieved Object Count:{_retrievedObjects}");

            Assert.IsTrue(true);
        }
예제 #8
0
        public void GetAllDesigners_ViaRawSqlNotTracked()
        {
            List <long> times = new List <long>();
            var         sql   = "select * from DapperDesigners";

            for (int i = 0; i < _iterations; i++)
            {
                using (var context = new DapperDesignerContext()) {
                    _sw.Reset();
                    _sw.Start();
                    var designers = context.Designers.SqlQuery(sql).AsNoTracking().ToList();
                    _sw.Stop();
                    times.Add(_sw.ElapsedMilliseconds);
                    _trackedObjects = context.ChangeTracker.Entries().Count();
                }
            }
            var analyzer = new TimeAnalyzer(times);

            Utils.Output(times, analyzer, "EF: GetAllDesignersRawSql");
            Console.WriteLine($"Latest Tracked Objects:{_trackedObjects}");

            Assert.IsTrue(true);
        }
예제 #9
0
        public void GetProjectedDesigners_ViaRawSqlNotTracked()
        {
            List <long> times     = new List <long>();
            var         sql       = "select LabelName as Name,id from DapperDesigners";
            var         designers = new List <MiniDesigner>();

            for (int i = 0; i < _iterations; i++)
            {
                using (var context = new DapperDesignerContext()) {
                    _sw.Reset();
                    _sw.Start();
                    designers = context.Database.SqlQuery <MiniDesigner>(sql).ToList();
                    _sw.Stop();
                    times.Add(_sw.ElapsedMilliseconds);
                    _trackedObjects = context.ChangeTracker.Entries().Count();
                }
            }
            var analyzer = new TimeAnalyzer(times);

            Utils.Output(times, analyzer, "EF: GetProjectedDesigners_ViaRawSqlNotTracked");
            Console.WriteLine($"Latest Tracked Objects:{_trackedObjects}");

            Assert.AreNotEqual(0, designers.Count());
        }
예제 #10
0
        static void Main(string[] args)
        {
            TimeAnalyzer.StartTimeCounter();

            LocalData.appMode = AppMode.CleanDeadCodeAndMangle;

            LocalData.inputDir  = new DirectoryInfo("E:/monocecil/_bin");
            LocalData.outputDir = new DirectoryInfo("E:/monocecil/_bin2");

            LocalData.resolver.AddSearchDirectory(LocalData.outputDir.FullName);

            LocalData.CleanerRepeatCount = 3;

            LocalData.verbose      = true;
            LocalData.verboseDeep  = false;
            LocalData.manglePublic = false;

            LocalFunctions.EnsureOutputDirectory();

            FileInfo[] files = LocalData.inputDir.GetFiles("*.dll", SearchOption.AllDirectories);


            if (files.Count() > 0)
            {
                LocalData.BlazorFilesList = new List <BlazorFile>();
                foreach (var item in files)
                {
                    BlazorFile bf = new BlazorFile()
                    {
                        FI     = item,
                        Name   = item.Name.Replace(".dll", null),
                        module = ModuleDefinition.ReadModule(item.FullName, new ReaderParameters {
                            AssemblyResolver = LocalData.resolver
                        }),
                        OutputFile = new FileInfo(Path.Combine(LocalData.outputDir.FullName, item.Name)),
                        IsPrimary  = false,
                        References = new List <BlazorFile>(),
                    };
                    LocalData.BlazorFilesList.Add(bf);
                }



                if (LocalData.BlazorFilesList.Count > 1)
                {
                    LocalFunctions.AnalyzeReferences();
                }
                else
                {
                    LocalData.BlazorFilesList.First().IsPrimary = true;
                }

                // LocalData.BlazorFilesList.Single(x => x.IsPrimary).Process = false;


                switch (LocalData.appMode)
                {
                case AppMode.CleanDeadCodeAndMangle:
                    LocalFunctions.RunDCCleaner();
                    LocalFunctions.RunMangler();
                    LocalFunctions.SaveResult();
                    break;

                case AppMode.Mangle:
                    LocalFunctions.RunMangler();
                    LocalFunctions.SaveResult();
                    break;

                case AppMode.CleanDeadCode:
                    LocalFunctions.RunDCCleaner();
                    LocalFunctions.SaveResult();
                    break;

                case AppMode.ReportDeadCode:
                    LocalFunctions.RunDCReporter();
                    break;

                default:
                    break;
                }

                //    LocalFunctions.AnalyzeHardCodedPropertyNames();

                // LocalFunctions.AnalyzeOutsideCalls();
            }
            else
            {
                Console.WriteLine("Files not found in " + LocalData.inputDir.FullName);
            }



            TimeAnalyzer.FinishTimeCounter();
        }