예제 #1
0
        private static string CreateOrUpdate(SearchKeyDetailDataModel data, RequestProfile requestProfile, string action)
        {
            var sql = "EXEC ";

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

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

            default:
                break;
            }

            sql = sql + ", " + ToSQLParameter(data, SearchKeyDetailDataModel.DataColumns.SearchKeyDetailId) +
                  ", " + ToSQLParameter(data, SearchKeyDetailDataModel.DataColumns.SearchKeyId) +
                  ", " + ToSQLParameter(data, SearchKeyDetailDataModel.DataColumns.SearchParameter) +
                  ", " + ToSQLParameter(data, SearchKeyDetailDataModel.DataColumns.SortOrder);
            return(sql);
        }
예제 #2
0
        public static int Create(SearchKeyDetailDataModel data, RequestProfile requestProfile)
        {
            var sql = CreateOrUpdate(data, requestProfile, "Create");
            var SearchKeyDetailId = DBDML.RunScalarSQL("SearchKeyDetail.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(SearchKeyDetailId));
        }
예제 #3
0
        public static List <SearchKeyDetailDataModel> GetEntityDetails(SearchKeyDetailDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.SearchKeyDetailSearch ";

            var parameters =
                new
            {
                AuditId = requestProfile.AuditId
                ,
                SearchKeyDetailId = dataQuery.SearchKeyDetailId
                ,
                SearchKeyId = dataQuery.SearchKeyId
                ,
                SearchParamater = dataQuery.SearchParameter
                ,
                ApplicationMode = requestProfile.ApplicationModeId
                ,
                ApplicationId = requestProfile.ApplicationId
                ,
                ReturnAuditInfo = returnAuditInfo
            };

            List <SearchKeyDetailDataModel> result;

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

            return(result);
        }
예제 #4
0
        public static DataTable DoesExist(SearchKeyDetailDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new SearchKeyDetailDataModel();

            doesExistRequest.SearchKeyDetailId = data.SearchKeyDetailId;

            return(Search(doesExistRequest, requestProfile));
        }
예제 #5
0
        public static DataTable Search(SearchKeyDetailDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            var table = list.ToDataTable();

            return(table);
        }
예제 #6
0
        public static bool DoesExist(SearchKeyDetailDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new SearchKeyDetailDataModel();

            doesExistRequest.SearchKeyDetailId = data.SearchKeyDetailId;

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

            return(list.Count > 0);
        }
예제 #7
0
        private int GetSearchKey()
        {
            var searchKeyId = 0;

            var data = new SearchKeyDataModel();

            data.Name        = DateTime.Now.ToLongTimeString();
            data.View        = "ScheduleDetail";
            data.SortOrder   = 1;
            data.Description = "ScheduleDetail";

            searchKeyId = SearchKeyDataManager.Create(data, SessionVariables.RequestProfile);

            var listKeys = new List <string>();

            listKeys.Add(ScheduleDetailDataModel.DataColumns.PersonId);
            listKeys.Add(ScheduleDetailDataModel.DataColumns.ScheduleDetailActivityCategoryId);

            listKeys.Add(ScheduleDetailDataModel.DataColumns.Message);
            listKeys.Add(ScheduleDetailDataModel.DataColumns.WorkDate);

            listKeys.Add(ApplicationCommon.XAxisKey);
            listKeys.Add(ApplicationCommon.YAxisKey);
            listKeys.Add(ApplicationCommon.ZAxisKey);
            listKeys.Add(ApplicationCommon.AggeregateFunctionKey);
            listKeys.Add(ApplicationCommon.ShowAggeregateKey);

            foreach (var key in listKeys)
            {
                //try
                //{
                var columnName  = key;
                var columnValue = PerferenceUtility.GetUserPreferenceByKey(key, SettingCategory);

                var dataDetail = new SearchKeyDetailDataModel();
                dataDetail.SearchKeyId = searchKeyId;

                //ApplicationCommon.UpdateUserPreference(SettingCategory, columnName, columnValue);
                dataDetail.SearchParameter = columnName;
                dataDetail.SortOrder       = 1;
                var detailId = SearchKeyDetailDataManager.Create(dataDetail, SessionVariables.RequestProfile);

                var dataDetailItem = new SearchKeyDetailItemDataModel();
                dataDetailItem.SearchKeyDetailId = detailId;
                dataDetailItem.SortOrder         = 1;

                dataDetailItem.Value = columnValue;
                SearchKeyDetailItemDataManager.Create(dataDetailItem, SessionVariables.RequestProfile);
            }

            return(searchKeyId);
        }
예제 #8
0
        public static void Delete(SearchKeyDetailDataModel dataQuery, RequestProfile requestProfile)
        {
            const string sql = @"dbo.SearchKeyDetailDelete ";

            var parameters =
                new
            {
                AuditId = requestProfile.AuditId
                ,
                SearchKeyDetailId = dataQuery.SearchKeyDetailId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
예제 #9
0
        private int SaveSearchKey()
        {
            var searchKeyId = 0;

            if (SearchColumns != null)
            {
                var data = new SearchKeyDataModel();
                data.Name        = DateTime.Now.ToLongTimeString();
                data.View        = "FunctionalityXFunctionalityImage";
                data.SortOrder   = 1;
                data.Description = "FunctionalityXFunctionalityImage";

                searchKeyId = Framework.Components.Core.SearchKeyDataManager.Create(data, SessionVariables.RequestProfile);

                foreach (DataRow dr in SearchColumns.Rows)
                {
                    try
                    {
                        var columnName  = Convert.ToString(dr["Name"]);
                        var columnValue = CheckAndGetFieldValue(columnName, false).ToString();

                        var dataDetail = new SearchKeyDetailDataModel();
                        dataDetail.SearchKeyId = searchKeyId;

                        //ApplicationCommon.UpdateUserPreference(SettingCategory, columnName, columnValue);
                        dataDetail.SearchParameter = columnName;
                        dataDetail.SortOrder       = 1;
                        var detailId = Framework.Components.Core.SearchKeyDetailDataManager.Create(dataDetail, SessionVariables.RequestProfile);

                        var dataDetailItem = new SearchKeyDetailItemDataModel();
                        dataDetailItem.SearchKeyDetailId = detailId;
                        dataDetailItem.SortOrder         = 1;

                        dataDetailItem.Value = columnValue;
                        Framework.Components.Core.SearchKeyDetailItemDataManager.Create(dataDetailItem, SessionVariables.RequestProfile);
                    }
                    catch
                    { }
                }
            }
            return(searchKeyId);
        }
예제 #10
0
        public static string ToSQLParameter(SearchKeyDetailDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

            case SearchKeyDetailDataModel.DataColumns.SearchKeyId:
                if (data.SearchKeyId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, SearchKeyDetailDataModel.DataColumns.SearchKeyId, data.SearchKeyId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SearchKeyDetailDataModel.DataColumns.SearchKeyId);
                }
                break;

            case SearchKeyDetailDataModel.DataColumns.SearchParameter:
                if (!string.IsNullOrEmpty(data.SearchParameter))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, SearchKeyDetailDataModel.DataColumns.SearchParameter, data.SearchParameter.Trim());
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SearchKeyDetailDataModel.DataColumns.SearchParameter);
                }
                break;

            case SearchKeyDetailDataModel.DataColumns.SearchKey:
                if (!string.IsNullOrEmpty(data.SearchKey))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, SearchKeyDetailDataModel.DataColumns.SearchKey, data.SearchKey.Trim());
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SearchKeyDetailDataModel.DataColumns.SearchKey);
                }
                break;

            case SearchKeyDetailDataModel.DataColumns.SortOrder:
                if (data.SortOrder != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, SearchKeyDetailDataModel.DataColumns.SortOrder, data.SortOrder);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SearchKeyDetailDataModel.DataColumns.SortOrder);
                }
                break;

            default:
                returnValue = BaseDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }
            return(returnValue);
        }
예제 #11
0
        public static void Update(SearchKeyDetailDataModel data, RequestProfile requestProfile)
        {
            var sql = CreateOrUpdate(data, requestProfile, "Update");

            DBDML.RunSQL("SearchKeyDetail.Update", sql, DataStoreKey);
        }
예제 #12
0
        public static SearchKeyDetailDataModel GetDetails(SearchKeyDetailDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }