Esempio n. 1
0
        public void KeyCachingIsSharedByAllInstances()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var keyCache = new BasePrimaryKeyCache();
                var hubRepo  = new HubRepository <H_TestHub_Default>(context, HashFunctions.MD5, null);
                var linkRepo = new LinkRepository <L_TestLink_Default>(context, HashFunctions.MD5, keyCache, DVKeyCaching.Enabled);
                var loadDate = DateTime.Now;

                hubRepo.Insert(hubs, loadDate);

                //single insert
                var insertedLink = linkRepo.Insert(new L_TestLink_Default(hub1.PrimaryKey, hub2.PrimaryKey), loadDate);

                //new repository created -> cache is initialized from memory context
                // -> cache already kontains the key
                linkRepo = new LinkRepository <L_TestLink_Default>(context, HashFunctions.MD5, keyCache, DVKeyCaching.Enabled);

                // same key again -> insert prevented
                var insertedLink2 = linkRepo.Insert(new L_TestLink_Default(hub1.PrimaryKey, hub2.PrimaryKey), loadDate);

                var list = linkRepo.Get();
                Assert.NotNull(list);
                Assert.Single(list);
            }
        }
        public void TestQueriesAndInsert()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var hubRepo       = new HubRepository <H_TestHub_Stores>(context, HashFunctions.MD5, null);
                var satelliteRepo = new SatelliteRepository <S_TestSatellite_Stores>(context, HashFunctions.MD5);
                var linkRepo      = new LinkRepository <L_TestLink_Stores>(context, HashFunctions.MD5, null, DVKeyCaching.Disabled);

                var loadDate = DateTime.Now;

                // HUB - storing info
                hubRepo.Insert(TestHub1, loadDate, loadInformation: LoadInfo1);

                var hub = hubRepo.GetByKey(TestHub1.PrimaryKey);

                Assert.Equal(LoadInfo1.RecordSource, hub.RecordSource);
                Assert.Equal(LoadInfo1.LoadedBy, hub.LoadedBy);

                // SATELLITE - storing info
                Hub1Satellite1 = satelliteRepo.Insert(Hub1Satellite1, loadDate, loadInformation: LoadInfo1);

                var sat = satelliteRepo.GetCurrent(s => s.Reference == TestHub1.PrimaryKey).Single();

                Assert.Equal(LoadInfo1.RecordSource, sat.RecordSource);
                Assert.Equal(LoadInfo1.LoadedBy, sat.LoadedBy);

                // LINK - storing info
                Link1 = linkRepo.Insert(Link1, loadDate, loadInformation: LoadInfo1);

                var link = linkRepo.GetByKey(Link1.PrimaryKey);

                Assert.Equal(LoadInfo1.RecordSource, link.RecordSource);
                Assert.Equal(LoadInfo1.LoadedBy, link.LoadedBy);
            }
        }
        public async Task LinkRepositoryCRUDTest()
        {
            var context = new NoodleDbContext("NoodleDb");

            context.Init();

            ILinkRepository repository = new LinkRepository(context);

            var id = Guid.NewGuid();

            var record = new Link
            {
                Id          = id,
                ReferenceId = Guid.Empty,
                Uri         = "test"
            };

            await repository.CreateAsync(record);

            record.Uri = "U_" + record.Uri;

            await repository.UpdateAsync(record);

            var record2 = await repository.GetByIdAsync(id);

            Assert.AreEqual(record.Id, record2.Id);
            Assert.AreEqual(record.Uri, record2.Uri);

            await repository.DeleteAsync(record.Id);

            var record3 = await repository.GetByIdAsync(id);

            Assert.IsNull(record3);
        }
Esempio n. 4
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        Link link = LinkRepository.FindById(DataUtility.ParseInt(QsLinkId));

        LinkRepository.Delete(link);
        Response.Redirect(Cancel.NavigateUrl);
    }
Esempio n. 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _pager           = new PagerHelper(GetCurrentPage(), GetPageSize(), LinkRepository.GetCount());
     Links.DataSource = LinkRepository.CreateQuery(
         "from Link l order by l.Category.Name, l.Name"
         ).SetFirstResult(_pager.CurrentRow).SetMaxResults(_pager.PageSize).List();
     Links.DataBind();
 }
Esempio n. 6
0
 public void OnGet(int id)
 {
     if (id > 0)
     {
         LinkRepository lRepository = new LinkRepository(connectionString);
         Link = lRepository.Get(id);
     }
 }
Esempio n. 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         var repo = new LinkRepository();
         gridLinks.DataSource = repo.GetAll();
         gridLinks.DataBind();
     }
 }
 public TodoAppDbContext(DbContextOptions options) : base(options)
 {
     context               = this;
     CategoryRepository    = new CategoryRepository(context);
     SubCategoryRepository = new SubCategoryRepository(context);
     TodoRepository        = new TodoRepository(context);
     NoteRepository        = new NoteRepository(context);
     LinkRepository        = new LinkRepository(context);
     FileRepository        = new FileRepository(context);
 }
Esempio n. 9
0
        private static LinkRepository InitializeCosmosClientInstance(LinkConfig linkConfig)
        {
            Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder clientBuilder = new Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder(linkConfig.ConnectionString);
            Microsoft.Azure.Cosmos.CosmosClient client = clientBuilder
                                                         .WithConnectionModeDirect()
                                                         .Build();
            LinkRepository linkRepository = new LinkRepository(client, linkConfig.DatabaseName, linkConfig.ContainerName);

            return(linkRepository);
        }
Esempio n. 10
0
 public frmPrimary()
 {
     InitializeComponent();
     dbPath    = string.Empty;
     folderImg = string.Empty;
     db        = Init();
     rpLink    = new LinkRepository(db);
     rpMovie   = new MovieRepository(db);
     rpInfo    = new InfoRepository(db);
 }
Esempio n. 11
0
 public BookService(
     DefaultDbContext context,
     BookRepository bookRepository,
     TagRepository tagRepository,
     LinkRepository linkRepository)
     : base(context)
 {
     _bookRepository = bookRepository;
     _tagRepository  = tagRepository;
     _linkRepository = linkRepository;
 }
        public void TestQueriesAndInsert()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var referenceRepo = new CRUDRepository <LoadInformation, long>(context);

                var hubRepo       = new HubRepository <H_TestHub_References>(context, HashFunctions.MD5, null);
                var satelliteRepo = new SatelliteRepository <S_TestSatellite_References>(context, HashFunctions.MD5);
                var linkRepo      = new LinkRepository <L_TestLink_References>(context, HashFunctions.MD5, null, DVKeyCaching.Disabled);

                var loadDate = DateTime.Now;

                // REFERENCE ENTRY - inserting and data persistence tests
                var load1Key = referenceRepo.Insert(LoadInfo1);
                var load2Key = referenceRepo.Insert(LoadInfo2);

                var hubList = referenceRepo.Get();
                Assert.NotEmpty(hubList);
                Assert.Equal(2, hubList.Count());
                Assert.False(load1Key == default);
                Assert.False(load2Key == default);

                var loadInfo = referenceRepo.Get(x => x.PrimaryKey == load2Key).Single();

                Assert.Equal(LoadInfo2.RecordSource, loadInfo.RecordSource);
                Assert.Equal(LoadInfo2.LoadedBy, loadInfo.LoadedBy);

                // HUB - referencing
                TestHub1 = hubRepo.Insert(TestHub1, loadDate, loadReference: LoadInfo1);
                TestHub2 = hubRepo.Insert(TestHub2, loadDate, loadReference: LoadInfo2);
                Assert.Equal(load1Key, TestHub1.LoadReference);
                Assert.Equal(load2Key, TestHub2.LoadReference);

                // SATELLITE - referencing
                Hub1Satellite1 = satelliteRepo.Insert(Hub1Satellite1, loadDate, loadReference: LoadInfo1);
                Hub2Satellite1 = satelliteRepo.Insert(Hub2Satellite1, loadDate, loadReference: LoadInfo2);

                Assert.Equal(load1Key, Hub1Satellite1.LoadReference);
                Assert.Equal(load2Key, Hub2Satellite1.LoadReference);

                var satelliteList = satelliteRepo.GetCurrent();
                Assert.NotEmpty(satelliteList);
                Assert.Equal(2, satelliteList.Count());


                // LINK - referencing
                Link1 = linkRepo.Insert(Link1, loadDate, loadReference: LoadInfo1);

                Assert.Equal(load1Key, Link1.LoadReference);

                Link1 = linkRepo.Get().Single();
                Assert.Equal(load1Key, Link1.LoadReference);
            }
        }
Esempio n. 13
0
 public void OnGet(Guid id)
 {
     if (id != null)
     {
         LinkRepository linkRepository = new LinkRepository(connectionString);
         Link = linkRepository.Get(id);
         if (Link != null)
         {
             FileRepository fileRepository = new FileRepository(connectionString);
             File = fileRepository.Get(Link.FileId);
         }
     }
 }
Esempio n. 14
0
        public void CreateLink()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var keyCache = new BasePrimaryKeyCache();
                var hubRepo  = new HubRepository <H_TestHub_Default>(context, HashFunctions.MD5, null);
                var linkRepo = new LinkRepository <L_TestLink_Default>(context, HashFunctions.MD5, keyCache, DVKeyCaching.Enabled);
                var loadDate = DateTime.Now;

                hubRepo.Insert(hubs, loadDate);

                linkRepo.Insert(new L_TestLink_Default(hub1.PrimaryKey, hub2.PrimaryKey), loadDate);
                linkRepo.Insert(new L_TestLink_Default(hub1.PrimaryKey, hub2.PrimaryKey), loadDate);
            }
        }
Esempio n. 15
0
        private static void ConfigureUniqueIdentifierGenerator()
        {
            string firstId = String.Empty;

            using (var linkRepository = new LinkRepository(new LinkDataContext()))
            {
                var link = linkRepository.LastOrDefault();
                if (link != null)
                {
                    firstId = link.Id;
                }
            }

            UniqueIdGenerator.Configure(firstId);
        }
Esempio n. 16
0
        public IEnumerable <SSRSDto> GetSSRSReportsBySchoolID(int schoolID)
        {
            var query =
                from x in DocumentRepository.All()
                join y in LinkRepository.All() on x.DocumentID equals y.DocumentID
                where x.DocumentTypeID == 2 && y.SchoolID == schoolID
                select new SSRSJoin {
                DocumentID     = x.DocumentID, DocumentName = x.DocumentFilename,
                DocumentTypeID = (int)x.DocumentTypeID, ExtraReportParameters = y.ExtraReportParameters, TopicID = y.TopicID, SchoolID = (int)y.SchoolID
            };

            var data = Mapper.Map <IEnumerable <SSRSJoin>, IEnumerable <SSRSDto> >(query.AsEnumerable());

            return(data);
        }
Esempio n. 17
0
        public void KeyCalculation()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var keyCache = new BasePrimaryKeyCache();
                var hubRepo  = new HubRepository <H_TestHub_Default>(context, HashFunctions.MD5, null);
                var linkRepo = new LinkRepository <L_TestLink_Default>(context, HashFunctions.MD5, keyCache, DVKeyCaching.Enabled);
                var loadDate = DateTime.Now;

                hubRepo.Insert(hubs, loadDate);

                L_TestLink_Default link = new L_TestLink_Default(hub1.PrimaryKey, hub2.PrimaryKey);
                //single insert
                var insertedLink = linkRepo.Insert(link, loadDate);
                Assert.Equal(HashFunctions.MD5(link.GetBusinessKeyString()), insertedLink.PrimaryKey);
            }
        }
Esempio n. 18
0
        public static async Task Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            LinkRepository linkRepository = new LinkRepository();

            LinkFilter linkFilter = new LinkFilter();

            LinkService linkService = new LinkService(linkRepository);

            LinkView linkView = new LinkView();

            LinkController linkController = new LinkController(linkService, linkView);

            linkController.StartWork();
        }
Esempio n. 19
0
 private void CreateRepos()
 {
     mEntities                      = new V308CMSEntities();
     ProductRepos                   = new ProductRepository(mEntities);
     ProductRepos.PageSize          = PageSize;
     ProductHelper.ProductShowLimit = ProductRepos.PageSize;
     AccountRepos                   = new AccountRepository(mEntities);
     NewsRepos                      = new NewsRepository(mEntities);
     CommentRepo                    = new TestimonialRepository(mEntities);
     CategoryRepo                   = new CategoryRepository(mEntities);
     LinkRepo            = new LinkRepository(mEntities);
     BannerRepo          = new BannerRepository(mEntities);
     TicketRepo          = new TicketRepository(mEntities);
     CouponRepo          = new CouponRepository(mEntities);
     CouponRepo.PageSize = PageSize;
 }
Esempio n. 20
0
        public ILinkRepository <TEntity> GetLinkRepository <TEntity>() where TEntity : IDvLinkEntity, new()
        {
            if (_repositories == null)
            {
                _repositories = new Dictionary <Type, object>();
            }

            var type = typeof(TEntity);

            if (!_repositories.ContainsKey(type))
            {
                _repositories[type] = new LinkRepository <TEntity>(DataVaultContext);
            }

            return((ILinkRepository <TEntity>)_repositories[type]);
        }
Esempio n. 21
0
        protected void btnModify_Click(object sender, EventArgs e)
        {
            LinkModel link = new LinkModel();

            link.Title       = this.txtTitle.Value;
            link.Url         = this.txtUrl.Value;
            link.ViewOrder   = Convert.ToInt32(this.txtViewOrder.Value);
            link.Description = this.txtDescription.Value;

            link.Id = Convert.ToInt32(Request["Id"]);

            var linkRepo = new LinkRepository();

            linkRepo.UpdateLink(link);

            this.lblError.Text = "수정되었습니다.";
        }
Esempio n. 22
0
        public void TestLinkRecordSaving()
        {

            RepositoryResult<LinkRecord> response=default(RepositoryResult<LinkRecord>);
            var now = DateTime.Now;
            using (var scope = new TransactionScope())
            {
                using (var rep = new LinkRepository())
                {
                    var url = string.Format("https://google.kz?id={0}", (new Random()).Next(int.MaxValue));                       
                    response = rep.CreateAndSave(url);
                }
            }
            Assert.IsTrue(response.IsSuccess);
            Assert.That(response.Data.Id, Is.GreaterThan(0));
            Assert.That(response.Data.CreateDate, Is.GreaterThan(now));
        }
Esempio n. 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["Id"] != null)
                {
                    LinkRepository repo           = new LinkRepository();
                    var            toBeEditedLink = repo.GetById(Request.QueryString["Id"].ToSafeInt());

                    if (toBeEditedLink != null)
                    {
                        txtTitle.Text = toBeEditedLink.Title;
                        txtHref.Text  = toBeEditedLink.Href;
                    }
                }
            }
        }
Esempio n. 24
0
 public IActionResult OnPostSave(int id, string email)
 {
     if (id > 0)
     {
         LinkRepository lRepository = new LinkRepository(connectionString);
         Link       = lRepository.Get(id);
         Link.Email = email;
         lRepository.Update(Link);
         if (!String.IsNullOrEmpty(email))
         {
             EmailServices eServices = new EmailServices();
             eServices.SendLink(email, $"{Request.Scheme}://{this.Request.Host}{this.Request.PathBase}/{Link.Url}");
         }
         return(RedirectToPage("Index", new { Id = Link.FileId }));
     }
     return(RedirectToPage("/Error"));
 }
Esempio n. 25
0
        private void DisplayData()
        {
            var repo = new LinkRepository();

            var link = repo.GetLink(Convert.ToInt32(Request["Id"]));

            if (link != null)
            {
                this.txtTitle.Value       = link.Title;
                this.txtUrl.Value         = link.Url;
                this.txtViewOrder.Value   = link.ViewOrder.ToString();
                this.txtDescription.Value = link.Description;
            }
            else
            {
                lblError.ForeColor = System.Drawing.Color.Red;
                lblError.Text      = "해당되는 데이터가 없습니다.";
            }
        }
Esempio n. 26
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log, ExecutionContext context)
        {
            var config           = new ConfigurationBuilder().SetBasePath(context.FunctionAppDirectory).AddJsonFile("local.settings.json", optional: true, reloadOnChange: true).AddEnvironmentVariables().Build();
            var connectionString = config.GetConnectionString("ConnectionString");

            //log.LogInformation("Connection String:" + connectionString);
            //Console.WriteLine(connectionString);
            LinkContext.connectionString = connectionString;

            string linkOriginal = req.QueryString.Value.Substring(6);

            string  requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);
            //linkOriginal = linkOriginal ?? data?.name;

            Link link = new Link();

            link.LinkOriginal = linkOriginal;

            string message = "";
            string responseMessage;

            if (link.ValidateOriginal(ref message))
            {
                LinkRepository linkRepository = new LinkRepository(new LinkContext());
                linkRepository.InsertLink(link);

                //Console.WriteLine(link.Status);

                responseMessage = JsonConvert.SerializeObject(new { Domain = linkOriginal, ShortenedLink = "https://www.linkmir.com/" + link.LinkShort, Status = link.Status });

                return(new OkObjectResult(responseMessage));
            }
            else
            {
                responseMessage = message;
                return(new BadRequestObjectResult(responseMessage));
            }
        }
Esempio n. 27
0
    protected void WriteLinks(HtmlTextWriter output)
    {
        Category     currentCategory = null;
        IList <Link> links           = LinkRepository.CreateQuery(
            "from Link l order by l.Category.Name, l.Name"
            ).List <Link>();

        output.RenderBeginTag(HtmlTextWriterTag.Dl);
        foreach (Link link in links)
        {
            if (link.Category != currentCategory)
            {
                if (currentCategory != null)
                {
                    // Render the end of the DD and UL tags.
                    output.RenderEndTag();
                    output.RenderEndTag();
                }
                currentCategory = link.Category;
                output.RenderBeginTag(HtmlTextWriterTag.Dt);
                output.WriteEncodedText(currentCategory.Name);
                output.RenderEndTag();
                output.RenderBeginTag(HtmlTextWriterTag.Dd);
                output.RenderBeginTag(HtmlTextWriterTag.Ul);
            }
            output.RenderBeginTag(HtmlTextWriterTag.Li);
            output.AddAttribute(HtmlTextWriterAttribute.Href, link.Url);
            output.AddAttribute(HtmlTextWriterAttribute.Target, "_blank");
            output.AddAttribute(HtmlTextWriterAttribute.Title, string.Format("Open {0} in a new window", link.Url));
            output.RenderBeginTag(HtmlTextWriterTag.A);
            output.WriteEncodedText(link.Name);
            output.RenderEndTag();
            output.RenderEndTag();
        }
        // Render the end of the DD and UL tags.
        output.RenderEndTag();
        output.RenderEndTag();
        // Render the end of the DL list.
        output.RenderEndTag();
    }
Esempio n. 28
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            LinkModel link = new LinkModel();

            link.Title       = txtTitle.Value;
            link.Url         = txtUrl.Value;
            link.ViewOrder   = Convert.ToInt32(txtViewOrder.Value);
            link.Description = txtDescription.Value;

            var repo = new LinkRepository();

            int result = repo.AddLink(link);

            if (result > 0)
            {
                lblError.Text = "저장 완료";
            }
            else
            {
                lblError.Text = "저장되지 않음";
            }
        }
Esempio n. 29
0
        public IActionResult OnPost(Guid id)
        {
            if (id != null)
            {
                LinkRepository linkRepository = new LinkRepository(connectionString);
                Link = linkRepository.Get(id);
                if (Link != null)
                {
                    FileRepository fileRepository = new FileRepository(connectionString);
                    File = fileRepository.Get(Link.FileId);
                    string filePath = env.WebRootPath + File.Path + @"/" + File.Name;
                    string fileName = File.Name;

                    byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);

                    Link.Count++;
                    linkRepository.Update(Link);
                    return(File(fileBytes, "application/force-download", fileName));
                }
            }
            return(NotFound());
        }
Esempio n. 30
0
 public Link GenerateNewLink(LinkRepository lRepository, int fileId)
 {
     if (lRepository != null)
     {
         Link l = new Link();
         l.FileId   = fileId;
         l.Email    = "";
         l.Count    = 0;
         l.PublicId = Guid.NewGuid();
         while (lRepository.Get(l.PublicId) != null)
         {
             l.PublicId = Guid.NewGuid();
         }
         l.Url = "/Files/Download/" + l.PublicId;
         l.Id  = lRepository.Add(l);
         return(l);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 31
0
        public void LinkKeyCaching()
        {
            //Caching enabled -> same key is ignored
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var keyCache = new BasePrimaryKeyCache();
                var hubRepo  = new HubRepository <H_TestHub_Default>(context, HashFunctions.MD5, null);
                var linkRepo = new LinkRepository <L_TestLink_Default>(context, HashFunctions.MD5, keyCache, DVKeyCaching.Enabled);
                var loadDate = DateTime.Now;

                hubRepo.Insert(hubs, loadDate);

                //single insert
                var insertedLink = linkRepo.Insert(new L_TestLink_Default(hub1.PrimaryKey, hub2.PrimaryKey), loadDate);
                // same key again
                var insertedLink2 = linkRepo.Insert(new L_TestLink_Default(hub1.PrimaryKey, hub2.PrimaryKey), loadDate);

                Assert.Equal(insertedLink.PrimaryKey, insertedLink2.PrimaryKey);

                var queriedLinks = linkRepo.Get();

                Assert.NotNull(queriedLinks);
                Assert.Single(queriedLinks);
            }

            //caching disabled -> insert throws exception
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var hubRepo  = new HubRepository <H_TestHub_Default>(context, HashFunctions.MD5, null);
                var linkRepo = new LinkRepository <L_TestLink_Default>(context, HashFunctions.MD5, null, DVKeyCaching.Disabled);
                var loadDate = DateTime.Now;

                hubRepo.Insert(hubs, loadDate);

                //single insert
                var insertedLink = linkRepo.Insert(new L_TestLink_Default(hub1.PrimaryKey, hub2.PrimaryKey), loadDate);
                // same key again
                Assert.Throws <InvalidOperationException>(() => linkRepo.Insert(new L_TestLink_Default(hub1.PrimaryKey, hub2.PrimaryKey), loadDate));
            }
        }
Esempio n. 32
0
        public void TestRetrieveByShortLink()
        {
            using (var scope = new TransactionScope())
            {
                var now = DateTime.Now;
                LinkRecord created = null;
                using (var createRep = new LinkRepository())
                {
                    var url = string.Format("http://google.kz?id={0}", (new Random()).Next(int.MaxValue));
                    var response = createRep.CreateAndSave(url);
                    created = response.Data;
                }
                LinkRecord readen = null;
                using(var readRep = new LinkRepository())
                {
                    readen = readRep.RetrieveByShortLink(created.ShortLink).Data;

                }

                Assert.That(readen.Id, Is.EqualTo(created.Id));
                Assert.That(readen.OriginalLink, Is.EqualTo(created.OriginalLink));
            }
        }