public int Insert(AgentDTO oAgentData) { DatabaseManager oDB; int agentId = -1; try { oDB = new DatabaseManager(); string sProcName = "up_Ins_AgentMaster"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sAgentCode", DbType.String, oAgentData.AgentCode); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sAgentName", DbType.String, oAgentData.AgentName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@AgentEmailId", DbType.String, DataSecurityManager.Encrypt(oAgentData.EmailId)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Password", DbType.String, DataSecurityManager.Encrypt(oAgentData.Password)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Category", DbType.String, DataSecurityManager.Encrypt(oAgentData.category)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Country", DbType.String, DataSecurityManager.Encrypt(oAgentData.country)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@localAgent", DbType.Byte, oAgentData.localagent); << << << < HEAD oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@CssPath", DbType.String, oAgentData.CssPath); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@RedirectURL", DbType.String, oAgentData.RedirectURL); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@IsPaymentBypass", DbType.Boolean, (oAgentData.IsPaymentBypass)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@AgentURL", DbType.String, (oAgentData.AgentURL));
/// <summary> /// Reads full database schema /// </summary> public override void FillSchema(DbDatabase schemaDatabase) { if (schemaDatabase == null) throw new ArgumentNullException("schemaDatabase", "Database is not specifed."); schemaDatabase.SchemaViews = ReadViews(); schemaDatabase.SchemaTables = ReadTables(schemaDatabase.SchemaViews); }
public Generator(ProjectDefinaton project, PatternProject pattern, DbDatabase database, ExSchemaEngine schemaEngine) { _patternProject = pattern; _projectDef = project; _database = database; _schemaEngine = schemaEngine; _optionGenerateUnselectedForeigns = false; }
public static void Start() { DbDatabase.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0"); // Sets the default database initialization code for working with Sql Server Compact databases // Uncomment this line and replace CONTEXT_NAME with the name of your DbContext if you are // using your DbContext to create and manage your database DbDatabase.SetInitializer(new DropCreateCeDatabaseIfModelChanges <TodoContext>()); }
protected void Application_Start() { DbDatabase.SetInitializer <SitioWebEntities>(new SitioWebInitializer()); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); }
public override string ToString() { DbDatabase db = new DbDatabase(); this.Person = db.GetPerson(this.PersonId); return(String.Format("index: {0}, Type: {1}, Name: {2}, Description: " + "{3}, Price: {4}, Phone: {5}, Owner: {6} {7}\n", AdvertId, Type, Name, Description, Price, Person.PhoneNumber, Person.PersonFirstname, Person.PersonLastname)); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); DbDatabase.SetInitializer(new ActivityLogDbInitilaizer()); }
/// <summary> /// Tries the delete table async. /// </summary> /// <param name="database"></param> /// <param name="databaseName"></param> /// <returns>A Task.</returns> public static async Task <int> TryDeleteDatabaseAsync <T>(this DbDatabase database, string databaseName) { var exist = await database.IsExistDataBaseAsync(databaseName); if (exist) { return(await database.CreateDatabaseAsync(databaseName)); } return(-1); }
/// <summary> /// Reads full database schema /// </summary> public override void FillSchema(DbDatabase schemaDatabase) { if (schemaDatabase == null) { throw new ArgumentNullException("schemaDatabase", "Database is not specifed."); } schemaDatabase.SchemaViews = ReadViews(); schemaDatabase.SchemaTables = ReadTables(schemaDatabase.SchemaViews); }
public HairAndSolelessContext() { // Instructions: // * You can add custom code to this file. Changes will *not* be lost when you re-run the scaffolder. // * If you want to regenerate the file totally, delete it and then re-run the scaffolder. // * You can delete these comments if you wish // * If you want Entity Framework to drop and regenerate your database automatically whenever you // change your model schema, uncomment the following line: DbDatabase.SetInitializer(new HairAndSolelessInitializer()); }
private static void runCodeFirst() { DbDatabase.SetInitializer <ConferenceModel>(new DropCreateDatabaseAlways <ConferenceModel>()); using (var context = new ConferenceModel()) { var speaker = new Speaker { FirstName = "Julie", LastName = "Lerman" }; var session = new Session { Title = "Code First Design", ConferenceTrack = new ConferenceTrack { TrackName = "Data", TrackChair = "Damien Guard", MinSessions = 5 }, Abstract = "tbd", }; var session2 = new Session { Title = "From Sap to Syrup", ConferenceTrack = new ConferenceTrack { TrackName = "Vermont", TrackChair = "Ethan Allen" }, Abstract = "How maple syrup is made", }; var speaker2 = new Speaker { FirstName = "Suzanne", LastName = "Shushereba" }; context.Speakers.Add(speaker); context.Speakers.Add(speaker2); speaker.Sessions = new List <Session>(); speaker.Sessions.Add(session); speaker.Sessions.Add(session2); speaker2.Sessions = new List <Session>(); speaker2.Sessions.Add(session2); context.SaveChanges(); } using (var context = new ConferenceModel()) { foreach (var dbSession in context.Sessions.Include("Speakers")) { Console.WriteLine(); Console.WriteLine(dbSession.Title); Console.WriteLine("Speakers:"); foreach (var sessionSpeaker in dbSession.Speakers) { Console.WriteLine(".... {0}", sessionSpeaker.Name); } } Console.WriteLine("Press Any Key To Continue..."); Console.ReadKey(); } }
public void InitializeDatabaseTest() { DbDatabase.SetInitializer(new NotifyIfModelOutOfSync <DatabaseContext>()); // TODO: Implement unit test using (var db = new DatabaseContext()) { db.Database.Initialize(true); } }
static void Main(string[] args) { DbDatabase.DefaultConnectionFactory = new System.Data.Entity.Database.SqlConnectionFactory("Data Source=.;Integrated Security=SSPI"); DbDatabase.SetInitializer <StockContext>(new DropCreateDatabaseIfModelChanges <StockContext>()); StockContext oContext = new StockContext(); oContext.StockOrders.Add(new StockOrder { StockOrderID = 2, Name = "test" }); oContext.SaveChanges(); }
/// <summary> /// Reads full database schema /// </summary> public override void FillSchema(DbDatabase schemaDatabase) { if (schemaDatabase == null) throw new ArgumentNullException("schemaDatabase", "Database is not specifed."); try { schemaDatabase.SchemaViews = ReadViews(); schemaDatabase.SchemaTables = ReadTables(schemaDatabase.SchemaViews); } finally { // be sure the connection is closed _dbConnection.Close(); } }
public bool updatestatus(RoomDTO oAccomRoomData) { string sProcName; DatabaseManager oDB; try { oDB = new DatabaseManager(); sProcName = "updateactivestatus"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sRoomNo", DbType.String, oAccomRoomData.RoomNo); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@iAccomId", DbType.Int32, oAccomRoomData.AccomodationId); << << << < HEAD oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@roomcatid", DbType.Int32, oAccomRoomData.roomcategoryid);
/// <summary> /// Reads full database schema /// </summary> public override void FillSchema(DbDatabase schemaDatabase) { if (schemaDatabase == null) { throw new ArgumentNullException("schemaDatabase", "Database is not specifed."); } try { schemaDatabase.SchemaViews = ReadViews(); schemaDatabase.SchemaTables = ReadTables(schemaDatabase.SchemaViews); } finally { // be sure the connection is closed _dbConnection.Close(); } }
public void TableSchemaConventionTest() { DbDatabase.SetInitializer(new DropCreateDatabaseAlways <DatabaseContext>()); using (var db = new DatabaseContext()) { db.Database.Initialize(true); var expected = typeof(DatabaseContext).GetProperties().Where(x => x.PropertyType.Name == "DbSet`1") .Select(x => new { Namespace = x.PropertyType.GetGenericArguments()[0].FullName, PropertyName = x.Name }) .Select(x => { var i1 = x.Namespace.LastIndexOf('.'); var i2 = x.Namespace.LastIndexOf('.', i1 - 1); return(x.Namespace.Substring(i2 + 1, i1 - i2) + x.PropertyName); }) .OrderBy(x => x).ToArray(); var actual = db.Database.SqlQuery <string>(SqlQueries.SelectFullTableNames).ToArray(); CollectionAssert.AreEqual(expected, actual); } }
static void Main(string[] args) { DbDatabase.SetInitializer(new CreateDatabaseIfNotExists <BookDbContext>()); using (var context = new ShapeDbContext()) { // creating a new object context.Polygons.Add(new Polygon { Name = "P1", Perimiter = 3 }); context.Polygons.Add(new Polygon { Name = "P2", Perimiter = 2 }); context.SaveChanges(); } using (var context = new ShapeDbContext()) { // creating a new object var polygons = context.Polygons.Where(o => o.Perimiter < 3); Console.WriteLine(polygons.Count()); } }
public void InitializeSchemaProject() { Project = new ProjectDefinaton(); Pattern = new PatternProject(); Database = new DbDatabase(); Project.GenerationPath = Path.Combine(Path.GetTempPath(), @"SalarDbCodeGenerator.Tests\" + DateTime.Now.Ticks); Project.ProjectName = "SalarDbCodeGenerator.Tests"; Pattern.LanguageSettings.KeywordsCaseSensitive = true; Pattern.LanguageSettings.LanguageInvalidChars = ", ./<>?;'\\:\"|[]{}`-=~!@#$%^&*()+"; Pattern.LanguageSettings.LanguageInvalidCharsSuppress = '_'; Pattern.LanguageSettings.LanguageKeywords.AddRange(new string[] { "readonly", "base", "break", "byte", "case", "catch", "checked", "class", "const", "continue", "default", "delegate", "do", "value", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "for", "foreach", "goto", "if", "implicit", "in", "interface", "internal", "is", "namespace", "new", "null", "object", "operator", "out", "override", "private", "protected", "public", "readonly", "ref", "return", "sealed", "sizeof", "static", "struct", "switch", "this", "throw", "true", "try", "typeof", "typeof", "unchecked", "unsafe", "using", "virtual", "while" }); Pattern.LanguageSettings.NullableDataTypes.AddRange(new[] { "String", "Object" }); Pattern.LanguageSettings.ExplicitCastDataTypes.AddRange(new[] { "Object", "Guid", "DateTimeOffset", "TimeSpan" }); Pattern.LanguageSettings.VoidDataType = "void"; Pattern.LanguageSettings.TextFieldIdenticator = "text"; Pattern.LanguageSettings.ArrayIdenticator = "[]"; Pattern.LanguageSettings.DbDecimalName = "decimal"; Pattern.LanguageSettings.DbNumericName = "numeric"; Pattern.LanguageSettings.DbDecimalType = "decimal([:Precision:],[:Scale:])"; Pattern.LanguageSettings.DbNumericType = "numeric([:Precision:],[:Scale:])"; Pattern.LanguageSettings.LanguageKeywordsSuppress = "{0}_{1}"; Database.DatabaseName = "SalarDbCodeGeneratorTests"; Database.Provider = DatabaseProvider.SQLServer; }
/// <summary> /// Checks the connection. /// </summary> /// <param name="connectionString">The connection string.</param> /// <remarks>Documented by Dev03, 2008-11-27</remarks> public void CheckConnection(ConnectionStringStruct connectionString) { if (!dbConnectionValid && connectionString.Typ != DatabaseType.Xml) { DummyUser user = new DummyUser(connectionString); DbConnection con = connectionString.Typ == DatabaseType.PostgreSQL ? PostgreSQLConn.CreateConnection(user) as DbConnection : MSSQLCEConn.GetConnection(user) as DbConnection; if (con.State == System.Data.ConnectionState.Open) { dbConnectionValid = true; } else { throw new ConnectionInvalidException(); } if (connectionString.Typ == DatabaseType.PostgreSQL) { con.Close(); } DbDatabase.GetInstance(new ParentClass(new DummyUser(connectionString), this)).CheckIfDatabaseVersionSupported(); } }
public static void Main(string[] args) { Advertisements Advertise = new Advertisements(); People People = new People(); Person NewUser = new Person(); Person AutorizedUser = new Person(); Validation Valid = new Validation(); DbDatabase db = new DbDatabase(); bool TimeToExit = false; bool NotValid = true; int choice = -1; while (!TimeToExit) { Console.WriteLine("///////////////////M E N U////////////////////////\n" + "Press number of action, that you want to do:\n" + "1: Show all services\n" + "2: Add new service\n" + "3: Delete certain service\n" + "4: Delete all services\n" + "5: Sort by...\n" + "6: Search by...\n" + "7: Save to...\n" + "8: Load from file\n" + "9: Show certain type\n" + "0: Exit"); try { choice = Convert.ToInt32(Console.ReadLine()); } catch { Console.WriteLine("Invalid symbol"); } switch (choice) { case 1: //Show all ads Console.WriteLine(Advertise.ToString()); if (Advertise.Count == 0) { Console.WriteLine("The List is empty"); } break; case 2: //Add new ad Console.WriteLine("Are you registered? Type Y for YES, N for NO"); string YesNo = Console.ReadLine(); if (YesNo == "Y" || YesNo == "y") { Console.WriteLine("Authentification:"); Console.WriteLine("Enter your email"); string email = Console.ReadLine(); Console.WriteLine("Enter your password"); string pass = Console.ReadLine(); Person person = People.Search(email)[0]; if (person.Password != pass) { Console.WriteLine("Invalid login or password"); } else { AutorizedUser = person; } } if (YesNo == "N" || YesNo == "n") { Console.WriteLine("Authorization:"); Console.WriteLine("Enter your firstname"); string fname = ""; NotValid = true; while (NotValid) { fname = Console.ReadLine(); if (Valid.IsValidFirstname(fname)) { NotValid = false; } else { Console.WriteLine("Invalid Name. Try again"); } } Console.WriteLine("Enter your lastname"); string lname = ""; NotValid = true; while (NotValid) { lname = Console.ReadLine(); if (Valid.IsValidFirstname(lname)) { NotValid = false; } else { Console.WriteLine("Invalid lastname. Try again"); } } Console.WriteLine("Enter your phone number"); string phoneNumber = ""; NotValid = true; while (NotValid) { phoneNumber = Console.ReadLine(); if (Valid.IsValidPhone(phoneNumber)) { NotValid = false; } else { Console.WriteLine("Invalid Phone. Try again"); } } Console.WriteLine("Enter your email"); string email = ""; NotValid = true; while (NotValid) { email = Console.ReadLine(); if (Valid.IsValidEmail(email)) { NotValid = false; } else { Console.WriteLine("Invalid email. Try again"); } } Console.WriteLine("Enter your password"); string pass = ""; NotValid = true; while (NotValid) { pass = Console.ReadLine(); if (Valid.IsValidPassword(pass)) { NotValid = false; } else { Console.WriteLine("Invalid password. Try again"); } } People.Add(new Person(fname, lname, phoneNumber, email, pass)); AutorizedUser = People.Search(email)[0]; } Console.WriteLine("Add new service:"); Console.WriteLine("Select type of service: press 1 for EDUCATION or 2 for REPAIR"); NotValid = true; string indexOfType = ""; while (NotValid) { indexOfType = Console.ReadLine(); if (Valid.IsValidType(indexOfType)) { NotValid = false; } else { Console.WriteLine("Invalid Type. Try again"); } } Console.WriteLine("Enter name of service:"); string name = ""; NotValid = true; while (NotValid) { name = Console.ReadLine(); if (Valid.IsValidName(name)) { NotValid = false; } else { Console.WriteLine("Invalid Name. Try again"); } } Console.WriteLine("Enter description of service:"); string description = Console.ReadLine(); Console.WriteLine("Enter price:"); string price = ""; NotValid = true; while (NotValid) { price = Console.ReadLine(); if (Valid.IsValidPrice(price)) { NotValid = false; } else { Console.WriteLine("Invalid Price. Try again"); } } try { Advertisement adv = new Advertisement(Advertise.Types[int.Parse(indexOfType) - 1], name, description, int.Parse(price), AutorizedUser); Advertise.Add(adv); Console.WriteLine("Added"); } catch { Console.WriteLine("ERROR"); } break; case 3: //Delete certain ad Console.WriteLine("Remove: \n Enter ID of service:"); if (Advertise.Remove(Advertise.AdvList[Convert.ToInt32(Console.ReadLine()) - 1])) { Console.WriteLine("Removed"); } else { Console.WriteLine("Error"); } break; case 4: //Delete all ads Console.WriteLine("Are you sure? Press Y for YES / N for NO"); if (Console.ReadLine() == "Y") { Advertise.Clear(); Console.WriteLine("Removed"); } else { Console.WriteLine("Canceled"); } break; case 5: //Sort by... Console.WriteLine("Sort: \nChoose an option: press 1 for sorting by NAME / 2 for DESCRIPTION / 3 for PRICE / 4 for PHONE / 5 for PERSON:"); Console.WriteLine(Advertise.ToString(Advertise.Sort(Advertise.AdvList, Convert.ToInt32(Console.ReadLine())))); break; case 6: //Search by... Console.WriteLine("Search: \nEnter keyword:"); Console.WriteLine(Advertise.ToString(Advertise.Search(Advertise.AdvList, Console.ReadLine()))); break; case 7: //Save to... Console.WriteLine("Saving: \nChoose file format: press 1 for XML / 2 for JSON / 3 for database"); int k = int.Parse(Console.ReadLine()); if (k == 1) //XML { Advertise.Serialize(); } if (k == 2) //JSON { Advertise.Serialize("jSon"); } if (k == 3) //DB { db.Create(Advertise.AdvList); } break; case 8: //Load from file Console.WriteLine("Loading: \nChoose file format: press 1 for XML / 2 for JSON"); int l = int.Parse(Console.ReadLine()); if (l == 1) //XML { Advertise.Deserialize(); Console.WriteLine(Advertise.ToString()); if (Advertise.AdvList.Count == 0) { Console.WriteLine("File is empty"); } } if (l == 2) //JSON { Advertise.Deserialize("jSon"); Console.WriteLine(Advertise.ToString()); if (Advertise.AdvList.Count == 0) { Console.WriteLine("File is empty"); } } break; case 9: //Show certain type Console.WriteLine("Choose type: press 1 for EDUCATION / 2 for REPAIR"); int type = int.Parse(Console.ReadLine()); foreach (Advertisement ser in Advertise.AdvList) { if (ser.Type == Advertise.Types[type - 1]) { Console.WriteLine(ser.ToString()); } } break; case 0: //Exit TimeToExit = true; break; default: Console.WriteLine("Invalid input"); break; } } }
public abstract void FillSchema(DbDatabase schemaDatabase);
public People() { db = new DbDatabase(); PersonList = db.GetAllPersons(); }
public SchemaAnalyzer(ProjectDefinaton project, PatternProject pattern, DbDatabase database) { _patternProject = pattern; _projectDef = project; _database = database; }
private void UiAction_Generate() { PleaseWait.ShowPleaseWait("Connecting to database server", true, false); using (System.Data.Common.DbConnection conn = _projectDefinition.DbSettions.GetNewConnection()) using (ExSchemaEngine schemaEngine = _projectDefinition.DbSettions.GetSchemaEngine(conn)) { // Connection to database conn.Open(); // Let application catchup Application.DoEvents(); // Reading database PleaseWait.WaitingState = "Reading database schema"; // 1 ========================== // Database schema reader var schemaDatabase = new DbDatabase(); schemaDatabase.Provider = _projectDefinition.DbSettions.DatabaseProvider; // shcema engine options schemaEngine.SpecificOwner = _projectDefinition.DbSettions.DatabaseProvider == DatabaseProvider.Oracle ? _projectDefinition.DbSettions.SqlUsername : _projectDefinition.DbSettions.SchemaName; // columns descriptions schemaEngine.ReadColumnsDescription = _projectDefinition.CodeGenSettings.GenerateColumnsDescription; schemaEngine.ReadTablesForeignKeys = _projectDefinition.CodeGenSettings.GenerateTablesForeignKeys; schemaEngine.ReadConstraintKeys = _projectDefinition.CodeGenSettings.GenerateConstraintKeys; // only selected tables schemaEngine.OnlyReadSelectedItems = true; schemaEngine.SelectedTables = _projectDefinition.DbSettions.GetSelectedTablesList(); schemaEngine.SelectedViews = _projectDefinition.DbSettions.GetSelectedViewsList(); // read database schema schemaEngine.FillSchema(schemaDatabase); PleaseWait.WaitingState = "Analyzing database schema"; // 2 ====================== var alanyzer = new SchemaAnalyzer(_projectDefinition, _patternProject, schemaDatabase); alanyzer.AnalyzeAndRename(); PleaseWait.WaitingState = "Generating output files"; // 3 ========================== // Start the generator var engine = new Generator(_projectDefinition, _patternProject, schemaDatabase, schemaEngine); engine.Generate(); // Update last generation _projectDefinition.LastGeneration = DateTime.Now; // 4 ========================== // Reaload the form Refresh_Form(); // Abort the please wait PleaseWait.Abort(); // Data is modified SetModified(true); // to active tab tabMainProject.SelectedTab = tabGenFiles; } }
public override bool IsValid(object value) { DbDatabase db = new DbDatabase(); return(db.SearchPerson((string)value).Count == 0); }
public Advertisements() { db = new DbDatabase(); AdvList = db.GetAllAdvertisements(); }