Esempio n. 1
0
        public static string Save(DBNameDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";

            switch (action)
            {
            case "Create":
                sql += "dbo.DBNameInsert  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                       ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);
                break;

            case "Update":
                sql += "dbo.DBNameUpdate  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, DBNameDataModel.DataColumns.DBNameId) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder);

            return(sql);
        }
Esempio n. 2
0
        //
        // GET: /ReleaseNoteBusinessDifficulty/
        public ActionResult Index(string searchString, int?page, int?pageSize)
        {
            var obj = new DBNameDataModel();

            obj.Name = searchString;
            var list = DBNameDataManager.GetEntitySearch(obj, SessionVariables.RequestProfile);

            if (pageSize.HasValue)
            {
                SessionVariables.DefaultRowCount = pageSize.Value;
            }

            int pageNumber = (page - 1 ?? 0);

            ViewBag.searchString = searchString;

            ViewBag.CurrentPage = list.Count > 0 ? pageNumber + 1 : 0;
            ViewBag.TotalPages  = list.Count / SessionVariables.DefaultRowCount;
            if (list.Count % SessionVariables.DefaultRowCount != 0)
            {
                ViewBag.TotalPages = (list.Count / SessionVariables.DefaultRowCount) + 1;
            }

            list = list.Count > 0 ? list.Skip(pageNumber * SessionVariables.DefaultRowCount).Take(SessionVariables.DefaultRowCount).ToList() : list;
            return(View(list));
        }
Esempio n. 3
0
        public static int Create(DBNameDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("DBName.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Esempio n. 4
0
        public static List <DBNameDataModel> GetEntityDetails(DBNameDataModel dataQuery, int auditId, int applicationModeId = 0)
        {
            const string sql = @"dbo.DBNameSearch ";

            var parameters =
                new
            {
                AuditId           = auditId
                , DBNameId        = dataQuery.DBNameId
                , ApplicationMode = applicationModeId
                , ReturnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails
                , Name            = dataQuery.Name
            };

            List <DBNameDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                var sp = Log4Net.LogSQLInfoStart(sql, DataStoreKey, parameters);

                result = dataAccess.Connection.Query <DBNameDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();

                Log4Net.LogSQLInfoStop(sp, result.Count);
            }

            return(result);
        }
Esempio n. 5
0
        static public List <DBNameDataModel> GetEntitySearch(DBNameDataModel obj, int auditId)
        {
            var dt = Search(obj, auditId, 0);            //SessionVariables.ApplicationMode);

            var list = ToList(dt);

            return(list);
        }
Esempio n. 6
0
        static public List <DBNameDataModel> GetEntitySearch(DBNameDataModel obj, RequestProfile requestProfile)
        {
            var dt = Search(obj, requestProfile);//SessionVariables.ApplicationMode);

            var list = ToList(dt);

            return(list);
        }
Esempio n. 7
0
        public static DataSet GetChildren(DBNameDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.DBNameChildrenGet" +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, DBNameDataModel.DataColumns.DBNameId);
            var oDT = new Framework.Components.DataAccess.DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
Esempio n. 8
0
        public ActionResult Create(DBNameDataModel obj)
        {
            if (ModelState.IsValid)
            {
                DBNameDataManager.Create(obj, SessionVariables.RequestProfile);
                return(RedirectToAction("Index"));
            }

            return(View(obj));
        }
Esempio n. 9
0
        public ActionResult Delete(DBNameDataModel obj)
        {
            if (ModelState.IsValid)
            {
                DBNameDataManager.Delete(obj, SessionVariables.AuditId);
                return(RedirectToAction("Index"));
            }

            return(View(obj));
        }
Esempio n. 10
0
        public static DataTable GetDetails(DBNameDataModel data, int auditId)
        {
            var sql = "EXEC dbo.DBNameSearch " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, auditId) +
                      //", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ReturnAuditInfo ,BaseDataManager .ReturnAduitInfoOnDetails ) +
                      ", " + ToSQLParameter(data, DBNameDataModel.DataColumns.DBNameId);

            var oDT = new DBDataTable("DBName.Details", sql, DataStoreKey);

            return(oDT.DBTable);
        }
Esempio n. 11
0
        public static bool DoesExist(DBNameDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new DBNameDataModel();

            doesExistRequest.ApplicationId = data.ApplicationId;
            doesExistRequest.Name          = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile, 0);

            return(list.Count > 0);
        }
Esempio n. 12
0
        public static DataTable DoesExist(DBNameDataModel data, int auditId)
        {
            var sql = "EXEC dbo.DBNameSearch " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, auditId) +
                      ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, ApplicationId) +
                      ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) +
                      ", " + ToSQLParameter(data, DBNameDataModel.DataColumns.DBNameId);

            var oDT = new DBDataTable("DBName.DoesExist", sql, DataStoreKey);

            return(oDT.DBTable);
        }
Esempio n. 13
0
        public DBNameDataModel GetById(int id)
        {
            var obj = new DBNameDataModel();

            obj.DBNameId = id;
            var list = DBNameDataManager.GetEntityDetails(obj, SessionVariables.RequestProfile);

            if (list == null || list.Count == 0)
            {
                return(null);
            }
            return(list[0]);
        }
Esempio n. 14
0
        public static DataTable Search(DBNameDataModel data, int auditId, int applicationModeId = 0)
        {
            // formulate SQL
            var sql = "EXEC dbo.DBNameSearch " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, auditId) +
                      ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationMode, applicationModeId) +
                      ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, ApplicationId) +
                      ", " + ToSQLParameter(data, DBNameDataModel.DataColumns.DBNameId) +
                      ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name);

            var oDT = new DBDataTable("DBName.Search", sql, DataStoreKey);

            return(oDT.DBTable);
        }
Esempio n. 15
0
        public static void Delete(DBNameDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.DBNameDelete ";

            var parameters =
                new
            {
                AuditId    = requestProfile.AuditId
                , DBNameId = data.DBNameId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Esempio n. 16
0
        public static bool IsDeletable(DBNameDataModel data, RequestProfile requestProfile)
        {
            var isDeletable = true;
            var ds          = GetChildren(data, requestProfile);

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataTable dt in ds.Tables)
                {
                    if (dt.Rows.Count > 0)
                    {
                        isDeletable = false;
                        break;
                    }
                }
            }
            return(isDeletable);
        }
Esempio n. 17
0
        static private List <DBNameDataModel> ToList(DataTable dt)
        {
            var list = new List <DBNameDataModel>();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    var dataItem = new DBNameDataModel();

                    dataItem.DBNameId = (int?)dr[DBNameDataModel.DataColumns.DBNameId];

                    SetStandardInfo(dataItem, dr);

                    list.Add(dataItem);
                }
            }
            return(list);
        }
Esempio n. 18
0
        public static void Delete(DBNameDataModel data, int auditId)
        {
            const string sql = @"dbo.DBNameDelete ";

            var parameters = new
            {
                AuditId    = auditId
                , DBNameId = data.DBNameId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                var sp = Log4Net.LogSQLInfoStart(sql, DataStoreKey, parameters);

                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);

                Log4Net.LogSQLInfoStop(sp);
            }
        }
Esempio n. 19
0
        public static void Save(string name, string component, int sortOrder, RequestProfile requestProfile)
        {
            var obj = new DBNameDataModel();

            obj.Name          = name;
            obj.ApplicationId = requestProfile.ApplicationId;
            obj.Description   = name;
            obj.SortOrder     = sortOrder;
            var list = DBNameDataManager.GetEntityDetails(obj, requestProfile);

            if (list.Count == 0)
            {
                DBNameDataManager.Create(obj, requestProfile);
            }
            else if (list.Count == 1)
            {
                obj.DBNameId = list[0].DBNameId;
                DBNameDataManager.Update(obj, requestProfile);
            }
        }
Esempio n. 20
0
        public static List <DBNameDataModel> GetEntityDetails(DBNameDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.DBNameSearch ";

            var parameters =
                new
            {
                AuditId           = requestProfile.AuditId
                , ApplicationId   = requestProfile.ApplicationId
                , ApplicationMode = requestProfile.ApplicationModeId
                , ReturnAuditInfo = returnAuditInfo
                , DBNameId        = dataQuery.DBNameId
                , Name            = dataQuery.Name
            };

            List <DBNameDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                result = dataAccess.Connection.Query <DBNameDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();
            }

            return(result);
        }
Esempio n. 21
0
        public static string ToSQLParameter(DBNameDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

            switch (dataColumnName)
            {
            case DBNameDataModel.DataColumns.DBNameId:
                if (data.DBNameId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, DBNameDataModel.DataColumns.DBNameId, data.DBNameId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, DBNameDataModel.DataColumns.DBNameId);
                }
                break;

            default:
                returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }

            return(returnValue);
        }
Esempio n. 22
0
        public static void Update(DBNameDataModel data, int auditId)
        {
            var sql = Save(data, auditId, "Update");

            DBDML.RunSQL("DBName.Update", sql, DataStoreKey);
        }
Esempio n. 23
0
        public static DBNameDataModel GetDetails(DBNameDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }
Esempio n. 24
0
        public static DataTable Search(DBNameDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }
Esempio n. 25
0
        public static void SaveEntityDetails(String entityName, String dbName, String dbProjectName, String dbComponentName, RequestProfile requestProfile)
        {
            var dbNameId          = 0;
            var dbComponentNameId = 0;
            var dbProjectNameId   = 0;

            var obj1 = new DBNameDataModel();

            obj1.Name = dbName;
            var dt = DBNameDataManager.Search(obj1, requestProfile);

            if (dt.Rows.Count >= 1)
            {
                if (dbName.Equals(obj1.Name))
                {
                    dbNameId = Convert.ToInt32(dt.Rows[0][DBNameDataModel.DataColumns.DBNameId].ToString());
                }
            }

            var obj2 = new DBComponentNameDataModel();

            obj2.Name = dbComponentName;
            dt        = DBComponentNameDataManager.Search(obj2, requestProfile);

            if (dt.Rows.Count >= 1)
            {
                if (dbComponentName.Equals(obj2.Name))
                {
                    dbComponentNameId = Convert.ToInt32(dt.Rows[0][DBComponentNameDataModel.DataColumns.DBComponentNameId].ToString());
                }
            }

            var obj3 = new DBProjectNameDataModel();

            obj3.Name = dbProjectName;
            dt        = DBProjectNameDataManager.Search(obj3, requestProfile);

            if (dt.Rows.Count >= 1)
            {
                if (dbProjectName.Equals(obj3.Name))
                {
                    dbProjectNameId = Convert.ToInt32(dt.Rows[0][DBProjectNameDataModel.DataColumns.DBProjectNameId].ToString());
                }
            }

            var obj4 = new AllEntityDetailDataModel();
            var AllEntityDetailId = 0;

            obj4.EntityName = entityName;
            dt = AllEntityDetailDataManager.Search(obj4, requestProfile);

            if (dt.Rows.Count >= 1)
            {
                if (entityName.Equals(obj4.EntityName))
                {
                    AllEntityDetailId = Convert.ToInt32(dt.Rows[0][AllEntityDetailDataModel.DataColumns.AllEntityDetailId].ToString());
                }
            }

            var obj = new AllEntityDetailDataModel();

            obj.ApplicationId          = requestProfile.ApplicationId;
            obj.EntityName             = entityName;
            obj.DB_Name                = dbName;
            obj.DB_Project_Name        = dbProjectName;
            obj.Component_Project_Name = dbComponentName;
            obj.DBNameId               = dbNameId;
            obj.DBProjectNameId        = dbProjectNameId;
            obj.DBComponentNameId      = dbComponentNameId;

            if (AllEntityDetailId == 0)
            {
                AllEntityDetailDataManager.Create(obj, requestProfile);
            }

            else if (AllEntityDetailId != 0)
            {
                obj.AllEntityDetailId = AllEntityDetailId;
                AllEntityDetailDataManager.Update(obj, requestProfile);
            }
        }
Esempio n. 26
0
        public static void Update(DBNameDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("DBName.Update", sql, DataStoreKey);
        }