public static int Create(ReleaseFeatureDataModel data, RequestProfile requestProfile) { var sql = CreateOrUpdate(data, requestProfile, "Create"); var ReleaseFeatureId = DBDML.RunScalarSQL("ReleaseFeature.Insert", sql, DataStoreKey); return(Convert.ToInt32(ReleaseFeatureId)); }
public static int Create(DevelopmentCategoryDataModel data, RequestProfile requestProfile) { var sql = CreateOrUpdate(data, requestProfile, "Create"); var DevelopmentCategoryId = DBDML.RunScalarSQL("DevelopmentCategory.Insert", sql, DataStoreKey); return(Convert.ToInt32(DevelopmentCategoryId)); }
public static int Create(TaskTypeDataModel data, RequestProfile requestProfile) { var sql = CreateOrUpdate(data, requestProfile, "Create"); var taskTypeId = DBDML.RunScalarSQL("TaskType.Insert", sql, DataStoreKey); return(Convert.ToInt32(taskTypeId)); }
public static int Create(UserPreferenceDataModel data, RequestProfile requestProfile) { var sql = String.Empty; try { sql = Save(data, requestProfile, "Create"); var id = DBDML.RunScalarSQL("UserPreference.Insert", sql, DataStoreKey); return(Convert.ToInt32(id)); } catch (Exception ex) { Log4Net.LogError(sql, MethodBase.GetCurrentMethod().DeclaringType.ToString(), requestProfile.ApplicationId, ex); throw ex; } }
public static int GetNextSequence(string entityName, int systemEntityTypeId, RequestProfile requestProfile) { var data = new SystemEntityTypeDataModel(); data.SystemEntityTypeId = systemEntityTypeId; data.EntityName = entityName; var sql = "EXEC dbo.SystemEntityTypeGetNextSequenceTemp " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(data, SystemEntityTypeDataModel.DataColumns.SystemEntityTypeId) + ", " + ToSQLParameter(data, SystemEntityTypeDataModel.DataColumns.EntityName) + ", " + ToSQLParameter(data, SystemEntityTypeDataModel.DataColumns.NextValue); var newId = DBDML.RunScalarSQL("SystemEntityTypeGetNextSequence", sql, DataStoreKey).ToString(); //var newId = int.Parse(DBDML.RunScalarSQL("SystemEntityTypeGetNextSequence", sql, DataStoreKey).ToString()); return(int.Parse(newId)); }
public static int GetRecordCount(string sourceTable, DateTime?recordDate) { var recordCount = 0; var SQLKey = ".SQL.GetTableRecordCount.sql"; var srcColumn = "Date"; if (sourceTable == "UserLogin") { srcColumn = "RecordDate"; } else if (sourceTable == "UserLoginHistory") { srcColumn = "DateVisited"; } // Get SQL Template and replace parameters var assembly = Assembly.GetExecutingAssembly(); var scriptTemplate = GetResourceText(assembly, SQLKey); var replacementFieldSet = new Dictionary <string, string>(); var replacementOtherSet = new Dictionary <string, string>(); replacementOtherSet.Add("@SourceTableName@", sourceTable); replacementOtherSet.Add("@SourceColumnName@", srcColumn); if (recordDate != null) { replacementOtherSet.Add("@RecordDate@", recordDate.Value.ToString()); } else { replacementOtherSet.Add("'@RecordDate@'", "NULL"); replacementOtherSet.Add("<", "="); } var sql = GetSQL(replacementFieldSet, replacementOtherSet, scriptTemplate, assembly.GetName().Name + SQLKey); var result = DBDML.RunScalarSQL("GetCounts", sql, DataStoreKey); recordCount = int.Parse(result.ToString()); return(recordCount); }
public static int GetEntityMinId(string entityName) { var minId = 0; var SQLKey = ".SQL.GetEntityMinId.sql"; // Get SQL Template and replace parameters var assembly = Assembly.GetExecutingAssembly(); var scriptTemplate = GetResourceText(assembly, SQLKey); var replacementFieldSet = new Dictionary <string, string>(); var replacementOtherSet = new Dictionary <string, string>(); replacementOtherSet.Add("@EntityName@", entityName); var sql = GetSQL(replacementFieldSet, replacementOtherSet, scriptTemplate, assembly.GetName().Name + SQLKey); var id = DBDML.RunScalarSQL("EntityName.GetMinId", sql, DataStoreKey); minId = Convert.ToInt32(id); return(minId); }
public static DataTable EntityTestData(RequestProfile requestProfile, int applicationId, string appName, string entityName) { // add columns as entityname, application id, entity id, test data count, audit data count DataTable result = new DataTable(); result.Columns.Add("Entity Id"); result.Columns.Add("Application Id"); result.Columns.Add("Entity Name"); result.Columns.Add("Test Data Count"); result.Columns.Add("Audit Data Count"); DataRow tempRow = null; DataTable dtEntities; //if (applicationId != -1) dtEntities = GetList(requestProfile); //else //{ //RequestProfile rp=new RequestProfile(); //rp.ApplicationId = applicationId; //dtEntities = GetList(null); //} DataTable dtSetupConfiguration = null; // i think u'll have to check this if it is using some application id or not for fetching data,, if not plz modify it if (applicationId != -1) { dtSetupConfiguration = SetupConfiguration.GetList(-1, appName); } else { dtSetupConfiguration = SetupConfiguration.GetList(-1, null); } if (entityName != "All") { var entityId = 0; var tmpRows = dtEntities.Select("EntityName = '" + entityName + "'"); if (tmpRows.Length > 0) { entityId = Convert.ToInt32(tmpRows[0]["SystemEntityTypeId"]); } // Execute step2 var count = 0; var SQLKey = ".SQL.GetEntityTestDataCount.sql"; // Get SQL Template and replace parameters var assembly = Assembly.GetExecutingAssembly(); var scriptTemplate = GetResourceText(assembly, SQLKey); var replacementFieldSet = new Dictionary <string, string>(); var replacementOtherSet = new Dictionary <string, string>(); replacementOtherSet.Add("@EntityName@", entityName); if (applicationId != -1) { replacementOtherSet.Add("@ApplicationId@", applicationId.ToString()); } else { replacementOtherSet.Add("@ApplicationId@", requestProfile.ApplicationId.ToString()); } var sql = GetSQL(replacementFieldSet, replacementOtherSet, scriptTemplate, assembly.GetName().Name + SQLKey); var id = DBDML.RunScalarSQL("EntityName.GetCount", sql, DataStoreKey); count = Convert.ToInt32(id); //execute step 3 var noOfAudit = 0; var SQLAuditCount = ".SQL.GetEntityDetails.sql"; var scriptAuditTemplate = GetResourceText(assembly, SQLAuditCount); var replacementFieldSetAudit = new Dictionary <string, string>(); var replacementOtherSetAudit = new Dictionary <string, string>(); replacementOtherSetAudit.Add("@EntityName@", entityName); replacementOtherSetAudit.Add("@SystemEntityTypeId@", entityId.ToString()); var sqlAudit = GetSQL(replacementFieldSetAudit, replacementOtherSetAudit, scriptAuditTemplate, assembly.GetName().Name + SQLAuditCount); var noOfAuditRecords = DBDML.RunScalarSQL("EntityName.GetAuditCount", sqlAudit, DataStoreKey); noOfAudit = Convert.ToInt32(noOfAuditRecords); // create a row in result table tempRow = result.NewRow(); // add the data in row tempRow["Entity Id"] = entityId.ToString(); if (applicationId != -1) { tempRow["Application Id"] = applicationId.ToString(); } else { tempRow["Application Id"] = requestProfile.ApplicationId; } //tempRow["Application Id"] = appId; tempRow["Entity Name"] = entityName; tempRow["Test Data Count"] = count; tempRow["Audit Data Count"] = noOfAudit; result.Rows.Add(tempRow); } else { foreach (DataRow row in dtSetupConfiguration.Rows) { entityName = row["EntityName"].ToString(); var appId = row["ConnectionKeyName"].ToString(); var entityId = 0; var tmpRows = dtEntities.Select("EntityName = '" + entityName + "'"); if (tmpRows.Length > 0) { entityId = Convert.ToInt32(tmpRows[0]["SystemEntityTypeId"]); } // Execute step2 var count = 0; var SQLKey = ".SQL.GetEntityTestDataCount.sql"; // Get SQL Template and replace parameters var assembly = Assembly.GetExecutingAssembly(); var scriptTemplate = GetResourceText(assembly, SQLKey); var replacementFieldSet = new Dictionary <string, string>(); var replacementOtherSet = new Dictionary <string, string>(); replacementOtherSet.Add("@EntityName@", entityName); if (applicationId != -1) { replacementOtherSet.Add("@ApplicationId@", applicationId.ToString()); } else { replacementOtherSet.Add("@ApplicationId@", requestProfile.ApplicationId.ToString()); } var sql = GetSQL(replacementFieldSet, replacementOtherSet, scriptTemplate, assembly.GetName().Name + SQLKey); var id = DBDML.RunScalarSQL("EntityName.GetCount", sql, DataStoreKey); count = Convert.ToInt32(id); //execute step 3 var noOfAudit = 0; var SQLAuditCount = ".SQL.GetEntityDetails.sql"; var scriptAuditTemplate = GetResourceText(assembly, SQLAuditCount); var replacementFieldSetAudit = new Dictionary <string, string>(); var replacementOtherSetAudit = new Dictionary <string, string>(); replacementOtherSetAudit.Add("@EntityName@", entityName); replacementOtherSetAudit.Add("@SystemEntityTypeId@", entityId.ToString()); var sqlAudit = GetSQL(replacementFieldSetAudit, replacementOtherSetAudit, scriptAuditTemplate, assembly.GetName().Name + SQLAuditCount); var noOfAuditRecords = DBDML.RunScalarSQL("EntityName.GetAuditCount", sqlAudit, DataStoreKey); noOfAudit = Convert.ToInt32(noOfAuditRecords); // create a row in result table tempRow = result.NewRow(); // add the data in row tempRow["Entity Id"] = entityId.ToString(); if (applicationId != -1) { tempRow["Application Id"] = applicationId.ToString(); } else { tempRow["Application Id"] = appId; } tempRow["Entity Name"] = entityName; tempRow["Test Data Count"] = count; tempRow["Audit Data Count"] = noOfAudit; result.Rows.Add(tempRow); } } return(result); }
public static DataTable EntityIncorrectNextValueData(RequestProfile requestProfile, int applicationId) { // add columns as entityname, application id, entity id, test data count, audit data count DataTable result = new DataTable(); result.Columns.Add("Entity Id"); result.Columns.Add("Application Id"); result.Columns.Add("Entity Name"); result.Columns.Add("Next PrimaryKey Value"); result.Columns.Add("Next Value"); DataRow tempRow = null; var dtEntities = GetList(requestProfile); // i think u'll have to check this if it is using some application id or not for fetching data,, if not plz modify it var dtSetupConfiguration = SetupConfiguration.GetList(applicationId); foreach (DataRow row in dtSetupConfiguration.Rows) { var entityName = row["EntityName"].ToString(); var appId = row["ApplicationId"].ToString(); var entityId = 0; var tmpRows = dtEntities.Select("EntityName = '" + entityName + "'"); if (tmpRows.Length > 0) { entityId = Convert.ToInt32(tmpRows[0]["SystemEntityTypeId"]); } // Execute step2 var maxValue = 0; var SQLKey = ".SQL.GetEntityMaxId.sql"; // Get SQL Template and replace parameters var assembly = Assembly.GetExecutingAssembly(); var scriptTemplate = GetResourceText(assembly, SQLKey); var replacementFieldSet = new Dictionary <string, string>(); var replacementOtherSet = new Dictionary <string, string>(); replacementOtherSet.Add("@EntityName@", entityName); var sql = GetSQL(replacementFieldSet, replacementOtherSet, scriptTemplate, assembly.GetName().Name + SQLKey); var maxId = DBDML.RunScalarSQL("EntityName.GetEntityMaxId", sql, DataStoreKey); if (maxId != System.DBNull.Value) { maxValue = Convert.ToInt32(maxId); } else { maxValue = 0; } //execute step 3 var nextIdValue = 0; var SQLAuditCount = ".SQL.GetNextValue.sql"; var scriptAuditTemplate = GetResourceText(assembly, SQLAuditCount); var replacementFieldSetAudit = new Dictionary <string, string>(); var replacementOtherSetAudit = new Dictionary <string, string>(); replacementOtherSetAudit.Add("@EntityName@", entityName); var sqlAudit = GetSQL(replacementFieldSetAudit, replacementOtherSetAudit, scriptAuditTemplate, assembly.GetName().Name + SQLAuditCount); var nextValue = DBDML.RunScalarSQL("EntityName.GetNextValue", sqlAudit, DataStoreKey); nextIdValue = Convert.ToInt32(nextValue); // create a row in result table if (nextIdValue != (maxValue + 1)) { tempRow = result.NewRow(); // add the data in row tempRow["Entity Id"] = entityId.ToString(); if (applicationId != -1) { tempRow["Application Id"] = applicationId.ToString(); } else { tempRow["Application Id"] = appId; } tempRow["Entity Name"] = entityName; tempRow["Next PrimaryKey Value"] = maxValue + 1; tempRow["Next Value"] = nextIdValue; result.Rows.Add(tempRow); } } return(result); }
public static int Create(CreditFacilityDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Create", requestProfile); var newId = DBDML.RunScalarSQL("CreditFacility.Insert", sql, DataStoreKey); return Convert.ToInt32(newId); }
public static DataTable EntityTestData(RequestProfile requestProfile) { // add columns as entityname, application id, entity id, test data count, audit data count DataTable result = new DataTable(); result.Columns.Add("Entity Id"); result.Columns.Add("Application Id"); result.Columns.Add("Entity Name"); result.Columns.Add("Test Data Count"); result.Columns.Add("Audit Data Count"); DataRow tempRow = null; var dtEntities = GetList(requestProfile); // i think u'll have to check this if it is using some application id or not for fetching data,, if not plz modify it var dtSetupConfiguration = SetupConfiguration.GetList(); foreach (DataRow row in dtSetupConfiguration.Rows) { var entityName = row["EntityName"].ToString(); var entityId = 0; if (dtEntities.Where(x => x.EntityName == entityName).Any()) { entityId = dtEntities.Where(x => x.EntityName == entityName).First().SystemEntityTypeId.Value; } // Execute step2 var count = 0; var SQLKey = ".SQL.GetEntityTestDataCount.sql"; // Get SQL Template and replace parameters var assembly = Assembly.GetExecutingAssembly(); var scriptTemplate = GetResourceText(assembly, SQLKey); var replacementFieldSet = new Dictionary <string, string>(); var replacementOtherSet = new Dictionary <string, string>(); replacementOtherSet.Add("@EntityName@", entityName); var sql = GetSQL(replacementFieldSet, replacementOtherSet, scriptTemplate, assembly.GetName().Name + SQLKey); var id = DBDML.RunScalarSQL("EntityName.GetCount", sql, DataStoreKey); count = Convert.ToInt32(id); //execute step 3 var noOfAudit = 0; var SQLAuditCount = ".SQL.GetEntityDetails.sql"; var scriptAuditTemplate = GetResourceText(assembly, SQLAuditCount); var replacementFieldSetAudit = new Dictionary <string, string>(); var replacementOtherSetAudit = new Dictionary <string, string>(); replacementOtherSetAudit.Add("@EntityName@", entityName); replacementOtherSetAudit.Add("@SystemEntityTypeId@", entityId.ToString()); var sqlAudit = GetSQL(replacementFieldSetAudit, replacementOtherSetAudit, scriptAuditTemplate, assembly.GetName().Name + SQLAuditCount); var noOfAuditRecords = DBDML.RunScalarSQL("EntityName.GetAuditCount", sqlAudit, DataStoreKey); noOfAudit = Convert.ToInt32(noOfAuditRecords); // create a row in result table tempRow = result.NewRow(); // add the data in row tempRow["Entity Id"] = entityId.ToString(); tempRow["Application Id"] = requestProfile.ApplicationId.ToString(); tempRow["Entity Name"] = entityName; tempRow["Test Data Count"] = count; tempRow["Audit Data Count"] = noOfAudit; result.Rows.Add(tempRow); } return(result); }