Exemplo n.º 1
0
        //imperial collage settings
        public override void Seed(IDbContext context)
        {
            var metadata = Seeder._cache[Seeder.Metadata] as MetadataSettings;
            var security = Seeder._cache[Seeder.Security] as SecuritySettings;

            var authnRequestSettings = this.GetAutnRequestSettings();

            var imperialFederationParty = new FederationPartySettings
            {
                RefreshInterval     = 30,
                AutoRefreshInterval = 1000,
                MetadataPath        = "https://shibboleth.imperial.ac.uk/idp/shibboleth",
                MetadataLocation    = "HTTP",
                FederationPartyId   = "imperial.ac.uk"
            };

            imperialFederationParty.MetadataSettings    = metadata;
            imperialFederationParty.SecuritySettings    = security;
            imperialFederationParty.AutnRequestSettings = authnRequestSettings;

            //shibboleth test metadata settings
            var testFederationParty = new FederationPartySettings
            {
                RefreshInterval     = 30,
                AutoRefreshInterval = 1000,
                MetadataPath        = "https://www.testshib.org/metadata/testshib-providers.xml",
                MetadataLocation    = "HTTP",
                FederationPartyId   = "testShib"
            };

            testFederationParty.MetadataSettings    = metadata;
            testFederationParty.SecuritySettings    = security;
            testFederationParty.AutnRequestSettings = authnRequestSettings;

            //local
            var localFederationParty = new FederationPartySettings
            {
                RefreshInterval     = 30,
                AutoRefreshInterval = 1000,
                MetadataPath        = "https://nadim/idp/shibboleth",
                MetadataLocation    = "HTTP",
                FederationPartyId   = "local"
            };

            localFederationParty.MetadataSettings    = metadata;
            localFederationParty.SecuritySettings    = security;
            localFederationParty.AutnRequestSettings = authnRequestSettings;

            context.Add <FederationPartySettings>(imperialFederationParty);
            context.Add <FederationPartySettings>(testFederationParty);
            context.Add <FederationPartySettings>(localFederationParty);

            metadata.RelyingParties.Add(imperialFederationParty);
            metadata.RelyingParties.Add(localFederationParty);
            metadata.RelyingParties.Add(testFederationParty);

            security.RelyingParties.Add(imperialFederationParty);
            security.RelyingParties.Add(localFederationParty);
            security.RelyingParties.Add(testFederationParty);
        }
Exemplo n.º 2
0
        public void GetEntity_GetEntityFuncLambda_RealEntity()
        {
            DbMock = new MongoDbContext(false);
            InfoEntity infoEntity00 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };
            InfoEntity infoEntity01 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3212000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            DbMock.Add(infoEntity00);
            DbMock.Add(infoEntity01);

            InfoEntity infoEntity = DbMock.GetEntity <InfoEntity>(x => x.Email == "*****@*****.**" && x.Name == "cName").FirstOrDefault();

            Assert.AreEqual(infoEntity.Id, ObjectId.Parse("5c89c3212000000000000000"));
        }
Exemplo n.º 3
0
        public void DeleteEntity_Entity_Success()
        {
            DbMock = new MongoDbContext(false);
            InfoEntity infoEntity00 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };
            InfoEntity infoEntity01 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3212000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            DbMock.Add(infoEntity00);
            DbMock.Add(infoEntity01);

            #region Remove Element
            DbMock.Remove(infoEntity00);
            #endregion

            #region Assert condition
            InfoEntity[] infoEntities = DbMock.GetEntity <InfoEntity>(x => true).ToArray();
            Assert.AreEqual(infoEntities.Length, 1);
            Assert.AreEqual(infoEntities[0].Email, "*****@*****.**");
            #endregion
        }
Exemplo n.º 4
0
        //imperial collage settings
        public override void Seed(IDbContext context)
        {
            var relyingParty = new RelyingPartySettings
            {
                RefreshInterval     = 30,
                AutoRefreshInterval = 1000,
                MetadataPath        = "https://shibboleth.imperial.ac.uk/idp/shibboleth",
                MetadataLocation    = "HTTP",
                RelyingPartyId      = "imperial.ac.uk"
            };

            //shibboleth test metadata settings
            var testRelyingParty = new RelyingPartySettings
            {
                RefreshInterval     = 30,
                AutoRefreshInterval = 1000,
                MetadataPath        = "https://www.testshib.org/metadata/testshib-providers.xml",
                MetadataLocation    = "HTTP",
                RelyingPartyId      = "testShib"
            };
            var localRelyingParty = new RelyingPartySettings
            {
                RefreshInterval     = 30,
                AutoRefreshInterval = 1000,
                MetadataPath        = "https://dg-mfb/idp/shibboleth",
                MetadataLocation    = "HTTP",
                RelyingPartyId      = "local"
            };

            context.Add <RelyingPartySettings>(relyingParty);
            context.Add <RelyingPartySettings>(testRelyingParty);
            context.Add <RelyingPartySettings>(localRelyingParty);
        }
Exemplo n.º 5
0
        public SetVar Get(String app, String kode)
        {
            _ctx.CommandText = _helper.GetRecord();
            _ctx.Add(p_AppId, app);
            _ctx.Add(p_Kode, kode);
            DataRow row = DaoBase.GetDataRow(_ctx);

            return((row == null) ? null : (SetVar)_helper.DataRowToObject(row, new SetVar()));
        }
Exemplo n.º 6
0
        public override void Seed(IDbContext context)
        {
            var redirectBinding = new Binding {
                Uri = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect", Name = "HTTP-Redirect"
            };

            context.Add <Binding>(redirectBinding);
            var postBinding = new Binding {
                Uri = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST", Name = "HTTP-POST"
            };

            context.Add <Binding>(postBinding);
            Seeder._cache.Add(Seeder.BindingsKey, new[] { redirectBinding, postBinding });
        }
        public override void Seed(IDbContext context)
        {
            var redirectBinding = new Binding {
                Uri = Bindings.Http_Redirect, Name = "HTTP-Redirect"
            };

            context.Add <Binding>(redirectBinding);
            var postBinding = new Binding {
                Uri = Bindings.Http_Post, Name = "HTTP-POST"
            };

            context.Add <Binding>(postBinding);
            Seeder._cache.Add(Seeder.BindingsKey, new[] { redirectBinding, postBinding });
        }
Exemplo n.º 8
0
        public void UpdateEntity_Entity_Success()
        {
            DbMock = new MongoDbContext(false);
            InfoEntity infoEntity = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            InfoEntity infoEntityUpdated = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            DbMock.Add(infoEntity);

            #region Update element
            DbMock.Update(infoEntityUpdated);
            #endregion

            #region Assert Condition
            InfoEntity retrieveInfoEntity = DbMock.GetEntity <InfoEntity>(x => true).FirstOrDefault();
            Assert.AreEqual(retrieveInfoEntity.Email, "*****@*****.**");
            #endregion
        }
Exemplo n.º 9
0
 public static void Add <T>(this IDbContext dbContext, IEnumerable <T> models) where T : EntityBase, new()
 {
     foreach (var item in models)
     {
         dbContext.Add <T>(item);
     }
 }
Exemplo n.º 10
0
        public static List <spSensusRIPerBulanPerKelas> GetspSensusRIPerBulanPerKelasList(String[] parameterField, String[] param)
        {
            List <spSensusRIPerBulanPerKelas> result = new List <spSensusRIPerBulanPerKelas>();
            IDbContext ctx = DbFactory.Configure();

            try
            {
                DbHelper helper = new DbHelper(typeof(spSensusRIPerBulanPerKelas));
                ctx.CommandText = "sprirpt_SensusRI_perBulan_perKelas";
                ctx.CommandType = System.Data.CommandType.StoredProcedure;
                //Add Parameter
                int count = parameterField.Length;
                for (int i = 0; i < count; i++)
                {
                    ctx.Add(parameterField[i], param[i]);
                }
                using (IDataReader reader = DaoBase.GetDataReader(ctx))
                    while (reader.Read())
                    {
                        result.Add((spSensusRIPerBulanPerKelas)helper.IDataReaderToObject(reader, new spSensusRIPerBulanPerKelas()));
                    }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                ctx.Close();
            }
            return(result);
        }
Exemplo n.º 11
0
        public static DataTable GetDataReport(string procedureName, string[] parameterField, string[] param)
        {
            DataTable  result;
            IDbContext ctx = DbFactory.Configure();

            try
            {
                ctx.CommandText = procedureName;
                ctx.CommandType = CommandType.StoredProcedure;
                ctx.Clear();
                //Add Parameter
                int count = parameterField.Length;
                for (int i = 0; i < count; i++)
                {
                    ctx.Add(parameterField[i], param[i]);
                }

                //Get DataReader
                result = DaoBase.GetDataTable(ctx);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                ctx.Close();
            }

            return(result);
        }
Exemplo n.º 12
0
        public static List <spPharmacyStockCard> GetspPharmacyStockCardList(String[] parameterField, String[] param)
        {
            List <spPharmacyStockCard> result = new List <spPharmacyStockCard>();
            IDbContext ctx = DbFactory.Configure();

            try
            {
                DbHelper helper = new DbHelper(typeof(spPharmacyStockCard));
                ctx.CommandText = "spfmrpt_KartuPersediaanFarmasi";
                ctx.CommandType = System.Data.CommandType.StoredProcedure;
                //Add Parameter
                int count = parameterField.Length;
                for (int i = 0; i < count; i++)
                {
                    ctx.Add(parameterField[i], param[i]);
                }
                using (IDataReader reader = DaoBase.GetDataReader(ctx))
                    while (reader.Read())
                    {
                        result.Add((spPharmacyStockCard)helper.IDataReaderToObject(reader, new spPharmacyStockCard()));
                    }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                ctx.Close();
            }
            return(result);
        }
Exemplo n.º 13
0
        public async Task <IActionResult> Create(
            [Bind("Id,FirstName,LastName,Email")] Teacher teacher,
            [Bind("Email,Password,ConfirmPassword")] RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(user, "Teacher");

                    _context.Add(teacher);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }

            TeacherCreateViewModel teacherCreateViewModel = new TeacherCreateViewModel
            {
                LastName  = teacher.LastName,
                FirstName = teacher.FirstName,
                Email     = teacher.Email,
            };

            return(View(teacherCreateViewModel));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Create(
            [Bind("id,Name,Address,Surname,Birthdate,CNP,Email")] Student student,
            [Bind("Email,Password,ConfirmPassword")] RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(user, "Student");

                    _context.Add(student);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }

            StudentCreateViewModel studentCreateViewModel = new StudentCreateViewModel
            {
                Name    = student.Name,
                Surname = student.Surname,
                Address = student.Address,
                CNP     = student.CNP,
                Email   = student.Email
            };

            return(View(studentCreateViewModel));
        }
Exemplo n.º 15
0
        public override void Seed(IDbContext context)
        {
            var transientNameIdFormat = new NameIdFormat {
                Key = "Transient", Uri = NameIdentifierFormats.Transient
            };

            context.Add <NameIdFormat>(transientNameIdFormat);

            var persistentNameIdFormat = new NameIdFormat {
                Key = "Persistent", Uri = NameIdentifierFormats.Persistent
            };

            context.Add <NameIdFormat>(persistentNameIdFormat);

            Seeder._cache.Add(Seeder.NameIdKey, new[] { transientNameIdFormat, persistentNameIdFormat });
        }
        public override void Seed(IDbContext context)
        {
            var organisation = new OrganisationSettings();

            organisation.Names.Add(new LocalisedName {
                Language = CultureInfo.CurrentCulture.Name, Name = "Company name."
            });
            organisation.Urls.Add(new LocalisedName {
                Language = CultureInfo.CurrentCulture.Name, Name = "https://company.co.uk/"
            });
            var contact = new PersonContact
            {
                ContactType = Kernel.Federation.MetaData.Configuration.Organisation.ContactType.Technical,
                Forename    = new LocalisedName {
                    Name = "John", Language = CultureInfo.CurrentCulture.Name
                },
                Surname = new LocalisedName {
                    Name = "Doe", Language = CultureInfo.CurrentCulture.Name
                },
            };

            contact.Emails.Add(new LocalisedName {
                Language = CultureInfo.CurrentCulture.Name, Name = "*****@*****.**"
            });
            contact.Phones.Add(new Phone {
                Type = PhoneType.Working, Number = "020 123 456"
            });
            contact.Organisations.Add(organisation);
            organisation.Contacts.Add(contact);
            Seeder._cache.Add(Seeder.Organisation, organisation);
            context.Add <OrganisationSettings>(organisation);
        }
Exemplo n.º 17
0
        public override void Seed(IDbContext context)
        {
            var descriptor = new EntityDescriptorSettings
            {
                //EntityId = "https://imperial.flowz_test.co.uk/",
                EntityId      = "https://www.eca-international-dev.com",
                FederationId  = String.Format("{0}_{1}", "eca", Guid.NewGuid()),
                CacheDuration = new DatepartValue {
                    Value = 100, Datepart = Datapart.Day
                },
                ValidUntil = DateTimeOffset.Now.AddDays(90),
            };

            //organisation
            if (Seeder._cache.ContainsKey(Seeder.Organisation))
            {
                var organisation = Seeder._cache[Seeder.Organisation] as OrganisationSettings;
                descriptor.Organisation = organisation;
            }
            //sp descriptors
            var spDescriptors = Seeder._cache[Seeder.SPDescriptorsKey] as IEnumerable <SPDescriptorSettings>;

            spDescriptors.Aggregate(descriptor, (d, next) => { d.RoleDescriptors.Add(next); return(d); });

            context.Add <EntityDescriptorSettings>(descriptor);
            Seeder._cache[Seeder.EntityDescriptor] = descriptor;
        }
Exemplo n.º 18
0
        public override void Seed(IDbContext context)
        {
            var certificate = new Certificate
            {
                IsDefault        = true,
                Use              = Kernel.Federation.MetaData.Configuration.Cryptography.KeyUsage.Signing,
                CetrificateStore = "TestCertStore",
                StoreLocation    = StoreLocation.LocalMachine
            };
            var storeCriterion = new StoreSearchCriterion
            {
                SearchCriteriaType = System.Security.Cryptography.X509Certificates.X509FindType.FindBySubjectName,
                SearchCriteria     = "ApiraTestCertificate",
            };
            var signingCritencials = new SigningCredential
            {
                DigestAlgorithm    = SecurityAlgorithms.Sha1Digest,
                SignatureAlgorithm = SecurityAlgorithms.RsaSha1Signature,
            };

            certificate.SigningCredentials.Add(signingCritencials);
            signingCritencials.Certificates.Add(certificate);
            certificate.StoreSearchCriteria.Add(storeCriterion);
            context.Add <Certificate>(certificate);
            Seeder._cache.Add(Seeder.CertificatesKey, new[] { certificate });
        }
Exemplo n.º 19
0
        public void AddEntity_EntityNotImplementICollection_ThrowException()
        {
            DbMock = new MockPersistence(new DbContextUtility());
            NotDeclareEntity entity = new NotDeclareEntity();

            DbMock.Add(entity);
        }
Exemplo n.º 20
0
        public override void Seed(IDbContext context)
        {
            var organisation = new OrganisationSettings();

            organisation.Names.Add(new LocalisedName {
                Language = CultureInfo.CurrentCulture.Name, Name = "Apira LTD"
            });
            organisation.Urls.Add(new LocalisedName {
                Language = CultureInfo.CurrentCulture.Name, Name = "https://apira.co.uk/"
            });
            var contact = new PersonContact
            {
                ContactType = Kernel.Federation.MetaData.Configuration.Organisation.ContactType.Technical,
                Forename    = new LocalisedName {
                    Name = "John", Language = CultureInfo.CurrentCulture.Name
                },
                Surname = new LocalisedName {
                    Name = "Murphy", Language = CultureInfo.CurrentCulture.Name
                },
            };

            contact.Emails.Add(new LocalisedName {
                Language = CultureInfo.CurrentCulture.Name, Name = "*****@*****.**"
            });
            contact.Phones.Add(new Phone {
                Type = PhoneType.Working, Number = "020 xxx"
            });
            contact.Organisations.Add(organisation);
            organisation.Contacts.Add(contact);
            Seeder._cache.Add(Seeder.Organisation, organisation);
            context.Add <OrganisationSettings>(organisation);
        }
Exemplo n.º 21
0
        public async Task <IActionResult> Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = await _context.Accounts.SingleOrDefaultAsync(usr => usr.Email.ToLower() == model.Email.ToLower());

                if (user != null && model.Password == user.PasswordHash)
                {
                    var principal = new ClaimsPrincipal(new ClaimsIdentity(user.Claims(), CookieAuthenticationDefaults.AuthenticationScheme));
                    await HttpContext.SignInAsync(principal);

                    HttpContext.User = principal;
                    if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else if (await _context.Accounts.CountAsync() == 0)
                {
                    _context.Add(new Account(model.Email, model.Email, model.Password));
                    await _context.SaveChangesAsync();

                    return(await Login(model, returnUrl));
                }
                else
                {
                    ModelState.AddModelError(nameof(Login), "Combinação de e-mail e senha incorreta");
                }
            }
            return(View(model));
        }
        public override void Seed(IDbContext context)
        {
            var roleDescriptor = new RoleDescriptorSettings
            {
                CacheDuration = 100,
                ValidUntil    = DateTimeOffset.Now.AddDays(90),
                ErrorUrl      = "http://localhost:60879/api/Account/Error"
            };
            var protocols = Seeder._cache[Seeder.ProtocolsKey] as IEnumerable <Protocol>;

            protocols.Aggregate(roleDescriptor, (d, next) =>
            {
                next.RoleDescriptors.Add(roleDescriptor);
                d.Protocols.Add(next);
                return(d);
            });

            var certificates = Seeder._cache[Seeder.CertificatesKey] as IEnumerable <Certificate>;

            certificates.Aggregate(roleDescriptor, (d, next) =>
            {
                d.Certificates.Add(next);
                next.RoleDescriptors.Add(roleDescriptor);
                return(d);
            });

            context.Add <RoleDescriptorSettings>(roleDescriptor);
        }
Exemplo n.º 23
0
        public Report Get(String reportID)
        {
            _ctx.CommandText = _helper.GetRecord();
            _ctx.Add(p_ReportID, reportID);
            DataRow row = DaoBase.GetDataRow(_ctx);

            return((row == null) ? null : (Report)_helper.DataRowToObject(row, new Report()));
        }
Exemplo n.º 24
0
        public App Get(String AppId)
        {
            _ctx.CommandText = _helper.GetRecord();
            _ctx.Add(p_AppId, AppId);
            DataRow row = DaoBase.GetDataRow(_ctx);

            return((row == null) ? null : (App)_helper.DataRowToObject(row, new App()));
        }
Exemplo n.º 25
0
        public ReportParameterLabel Get(Int32 id)
        {
            _ctx.CommandText = _helper.GetRecord();
            _ctx.Add(p_Id, id);
            DataRow row = DaoBase.GetDataRow(_ctx);

            return((row == null) ? null : (ReportParameterLabel)_helper.DataRowToObject(row, new ReportParameterLabel()));
        }
Exemplo n.º 26
0
        public Pasien Get(String NoRM)
        {
            _ctx.CommandText = _helper.GetRecord();
            _ctx.Add(p_norm, NoRM);
            DataRow row = DaoBase.GetDataRow(_ctx);

            return((row == null) ? null : (Pasien)_helper.DataRowToObject(row, new Pasien()));
        }
Exemplo n.º 27
0
        public void DeleteEntityUsingExpression_Entity_Success()
        {
            DbMock = new MongoDbContext(false);
            InfoEntity infoEntity00 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };
            InfoEntity infoEntity01 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3212000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };
            InfoEntity infoEntity02 = new InfoEntity
            {
                Id       = ObjectId.Parse("5ed6af61b7f0c68829022ebc"),
                Guid     = Guid.Parse("EBDB974B-291B-460A-9F43-871734958676"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            DbMock.Add(infoEntity00);
            DbMock.Add(infoEntity01);
            DbMock.Add(infoEntity02);

            #region Remove Element
            DbMock.Remove <InfoEntity>(x => x.Guid == Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"));
            #endregion

            #region Assert condition
            InfoEntity[] infoEntities = DbMock.GetEntity <InfoEntity>(x => true).ToArray();
            Assert.AreEqual(infoEntities.Length, 1);
            Assert.AreEqual(infoEntities[0].Email, "*****@*****.**");
            #endregion
        }
        public override void Seed(IDbContext context)
        {
            var protocol = new Protocol {
                Uri = "urn:oasis:names:tc:SAML:2.0:protocol"
            };

            context.Add <Protocol>(protocol);
            Seeder._cache.Add(Seeder.ProtocolsKey, new[] { protocol });
        }
Exemplo n.º 29
0
        public override void Seed(IDbContext context)
        {
            var settings = new SecuritySettings
            {
                X509CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.Custom,
                PinnedValidation = false
            };

            context.Add <SecuritySettings>(settings);
        }
Exemplo n.º 30
0
        public void Execute(IDbContext context)
        {
            switch (Type)
            {
            case StoreInteractionType.Added: context.Add(Entity); break;

            case StoreInteractionType.Updated: context.Update(Entity); break;

            case StoreInteractionType.Removed: context.Remove(Entity); break;
            }
        }
Exemplo n.º 31
0
        public IDbContext Insert(IDbContext ctx, object obj, bool isAuditLog)
        {
            string sqlInsert;
            string fieldName = "";
            string parameter = "";

            //Simpan informasi nama table di session untuk informasi error handling bila terjadi duplicate key
            if (HttpContext.Current != null)
            {
                HttpContext.Current.Session["_LastSqlProcessTable"] = "";
                HttpContext.Current.Session["_LastSqlProcessPKField"] = "";
                HttpContext.Current.Session["_LastSqlProcessPKValue"] = "";
            }

            if (obj is DbDataModel)
            {
                Type type = obj.GetType();
                PropertyInfo[] propInfs = type.GetProperties();
                foreach (PropertyInfo prop in propInfs)
                {
                    object[] custAttr = prop.GetCustomAttributes(false);
                    foreach (Attribute attrib in custAttr)
                    {
                        ColumnAttribute schema = attrib as ColumnAttribute;
                        if (schema != null && !schema.IsComputed
                            && !schema.IsIdentity
                            && !schema.IsTimeStamp)
                        {
                            object fieldValue = prop.GetValue(obj, null);
                            if (!schema.IsNullable)
                                fieldValue = CheckIsNull(fieldValue, prop.PropertyType);

                            //if (fieldValue != null &&
                            //    !(schema.IsNullable && IsFieldNullAbleNotAssignValue(fieldValue, prop.PropertyType)))
                            //{
                            //    ctx.Add(string.Format("{0}{1}", _prefixParameter, schema.Name), fieldValue);
                            //    fieldName += string.Format(", {0}", schema.Name);
                            //    parameter += string.Format(", {0}{1}", _prefixParameter, schema.Name);

                            //    //Simpan informasi primary key di session untuk informasi error handling bila terjadi duplicate key
                            //    if (schema.IsPrimaryKey)
                            //    {
                            //        HttpContext.Current.Session["_LastSqlProcessPKField"] += ";" + schema.Name;
                            //        HttpContext.Current.Session["_LastSqlProcessPKValue"] += ";" + fieldValue;
                            //    }
                            //}

                            fieldName += string.Format(", {0}", schema.Name);
                            if (fieldValue != null &&
                               !(schema.IsNullable && IsFieldNullAbleNotAssignValue(fieldValue, prop.PropertyType)))
                            {
                                parameter += string.Format(", {0}{1}", _prefixParameter, schema.Name);

                                if (fieldValue.GetType().FullName.Contains("DateTime"))
                                {
                                    if (fieldValue is DBNull || Convert.ToDateTime(fieldValue).Year < 1900)
                                        fieldValue = new DateTime(1900, 1, 1);
                                }
                                ctx.Add(string.Format("{0}{1}", _prefixParameter, schema.Name), fieldValue);

                            }
                            else
                            {
                                parameter += ", NULL";
                            }

                            //Simpan informasi primary key di session untuk informasi error handling bila terjadi duplicate key
                            if (schema.IsPrimaryKey && HttpContext.Current != null)
                            {
                                HttpContext.Current.Session["_LastSqlProcessPKField"] += ";" + schema.Name;
                                HttpContext.Current.Session["_LastSqlProcessPKValue"] += ";" + fieldValue;
                            }

                        }
                    }
                }
            }

            //Simpan informasi nama table di session untuk informasi error handling bila terjadi duplicate key
            if (HttpContext.Current != null)
            {
                HttpContext.Current.Session["_LastSqlProcessTable"] = _tableName;

                if (HttpContext.Current.Session["_LastSqlProcessPKField"].ToString().Trim() != string.Empty)
                {
                    HttpContext.Current.Session["_LastSqlProcessPKField"] =
                        HttpContext.Current.Session["_LastSqlProcessPKField"].ToString().Substring(1);
                    HttpContext.Current.Session["_LastSqlProcessPKValue"] =
                        HttpContext.Current.Session["_LastSqlProcessPKValue"].ToString().Substring(1);
                }
            }
            fieldName = (fieldName.Length > 2) ? fieldName.Substring(2) : fieldName;
            parameter = (parameter.Length > 2) ? parameter.Substring(2) : parameter;

            sqlInsert = string.Format("INSERT INTO {0} ", _tableName);
            sqlInsert += string.Format("( {0}) ", fieldName);
            sqlInsert += string.Format(" {0} ", "VALUES");
            sqlInsert += string.Format("( {0} )", parameter);

            if (isAuditLog)
                ctx.CommandText = GetInsertAuditLogScript(obj) + "; " + sqlInsert;
            else
                ctx.CommandText = sqlInsert;

            //if (!_tableName.ToLower().Contains("systranslation"))
            //{
            //    SiAuto.Main.LogSql("Insert " + _tableName, ctx.CommandText);
            //    SiAuto.Main.LogObject(_tableName, obj);
            //}

            return ctx;
        }
Exemplo n.º 32
0
        public IDbContext Delete(IDbContext ctx, object obj, bool isAuditLog)
        {
            ctx.CommandText = "";
            if (obj != null && obj is DbDataModel)
            {
                string keys = "";
                foreach (DbFieldValue dbValue in GetKeyValues(obj))
                {
                    keys += string.Format(" AND {0} = {1}{0}", dbValue.FieldName, _prefixParameter);
                    ctx.Add(string.Format("{0}{1}", _prefixParameter, dbValue.FieldName), dbValue.Current);
                }
                if (!keys.Equals(string.Empty))
                {
                    string query;
                    query = string.Format("DELETE {0} ", _tableName);
                    query += string.Format("WHERE {0} ", keys.Substring(5));

                    if (isAuditLog)
                        ctx.CommandText = GetDeleteAuditLogScript(obj) + "; " + query;
                    else
                        ctx.CommandText = query;

                    //if (!_tableName.ToLower().Contains("systranslation"))
                    //{
                    //    SiAuto.Main.LogSql("Delete " + _tableName, ctx.CommandText);
                    //    SiAuto.Main.LogObject(_tableName, obj);
                    //}
                }
            }

            return ctx;
        }
Exemplo n.º 33
0
        public IDbContext Update(IDbContext ctx, object obj, bool isAuditLog)
        {
            ctx.CommandText = "";
            if (obj != null && obj is DbDataModel)
            {
                Type type = obj.GetType();
                Hashtable hash = ((DbDataModel) obj).OriginalValue;

                string fields = "";

                foreach (PropertyInfo prop in type.GetProperties())
                {
                    foreach (Attribute attrib in prop.GetCustomAttributes(false))
                    {
                        ColumnAttribute schema = attrib as ColumnAttribute;
                        if (schema != null && !schema.IsPrimaryKey)
                        {
                            object oriValue = hash != null ? hash[schema.Name] : null;
                            object newValue = prop.GetValue(obj, null);
                            if (schema.IsNullable && IsFieldNullAbleNotAssignValue(newValue, prop.PropertyType))
                            //(newValue == null && schema.IsNullable && oriValue != null)
                            {
                                //Sql Script Update
                                fields += string.Format(", {0} = null", schema.Name);
                            }
                            else if (newValue != null && !newValue.Equals(oriValue))
                            {
                                //Sql Script Update
                                fields += string.Format(", {0} = {1}{0}", schema.Name, _prefixParameter);
                                //Parameter
                                ctx.Add(string.Format("{0}{1}", _prefixParameter, schema.Name), newValue);
                            }

                            //newValue = CheckIsNull(newValue, prop.PropertyType);
                            //if (newValue.GetType().FullName.Contains("Int64"))
                            //    if (Convert.ToInt64(newValue) == 0)
                            //        newValue = null;
                            //if (newValue == null && schema.IsNullable)
                            //{
                            //    //Sql Script Update
                            //    fields += string.Format(", {0} = null", schema.Name);
                            //}
                            //else if (!newValue.Equals(oriValue))
                            //{
                            //    ////if (newValue.GetType().FullName.Contains("DateTime"))
                            //    ////    if (Convert.ToDateTime(newValue).Year < 1900)
                            //    ////        newValue = new DateTime(1900, 1, 1);
                            //    newValue = CheckIsNull(newValue, prop.PropertyType);
                            //    //Sql Script Update
                            //    fields += string.Format(", {0} = {1}{0}", schema.Name, _prefixParameter);
                            //    //Parameter
                            //    ctx.Add(string.Format("{0}{1}", _prefixParameter, schema.Name), newValue);
                            //}
                        }
                    }
                }
                if (!fields.Equals(string.Empty))
                {
                    string keys = "";
                    foreach (DbFieldValue dbValue in GetKeyValues(obj))
                    {
                        keys += string.Format(" AND {0} = {1}{0}", dbValue.FieldName, _prefixParameter);
                        ctx.Add(string.Format("{0}{1}", _prefixParameter, dbValue.FieldName), dbValue.Current);
                    }

                    string query;
                    query = string.Format("UPDATE {0} SET ", _tableName);
                    query += string.Format("{0} ", fields.Substring(2));
                    query += string.Format("WHERE {0} ", keys.Substring(5));

                    if (isAuditLog)
                        ctx.CommandText = GetUpdateAuditLogScript(obj) + "; " + query;
                    else
                        ctx.CommandText = query;

                    //if (!_tableName.ToLower().Contains("systranslation"))
                    //{
                    //    SiAuto.Main.LogSql("Update " + _tableName, ctx.CommandText);
                    //    SiAuto.Main.LogObject(_tableName, obj);
                    //}
                }
            }

            return ctx;
        }