Exemplo n.º 1
0
        private static string Save(TaskScheduleDataModel data, RequestProfile requestProfile, string action)
        {
            var sql = "EXEC ";

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

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

            default:
                break;
            }

            sql = sql + ", " + ToSQLParameter(data, TaskScheduleDataModel.DataColumns.TaskScheduleId) +
                  ", " + ToSQLParameter(data, TaskScheduleDataModel.DataColumns.TaskScheduleTypeId) +
                  ", " + ToSQLParameter(data, TaskScheduleDataModel.DataColumns.TaskEntityId);
            return(sql);
        }
Exemplo n.º 2
0
        public override int?Save(string action)
        {
            var data = new TaskScheduleDataModel();

            data.TaskScheduleId     = TaskScheduleId;
            data.TaskEntityId       = TaskEntityId;
            data.TaskScheduleTypeId = TaskScheduleTypeId;

            if (action == "Insert")
            {
                var dtTaskSchedule = Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.DoesExist(data, SessionVariables.RequestProfile);

                if (dtTaskSchedule.Rows.Count == 0)
                {
                    Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.Create(data, SessionVariables.RequestProfile);
                }
                else
                {
                    throw new Exception("Record with given ID already exists.");
                }
            }
            else
            {
                Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.Update(data, SessionVariables.RequestProfile);
            }

            // not correct ... when doing insert, we didn't get/change the value of TaskScheduleID ?
            return(TaskScheduleId);
        }
Exemplo n.º 3
0
        public static List <TaskScheduleDataModel> GetEntityDetails(TaskScheduleDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.TaskScheduleSearch ";

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

            List <TaskScheduleDataModel> result;

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

            return(result);
        }
Exemplo n.º 4
0
        public static List <TaskScheduleDataModel> GetTaskScheduleList(RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.TaskScheduleSearch" +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);

            var result = new List <TaskScheduleDataModel>();

            using (var reader = new DBDataReader("Get List", sql, DataStoreKey))
            {
                var dbReader = reader.DBReader;

                while (dbReader.Read())
                {
                    var dataItem = new TaskScheduleDataModel();

                    dataItem.TaskScheduleId   = (int)dbReader[TaskScheduleDataModel.DataColumns.TaskScheduleId];
                    dataItem.TaskScheduleType = dbReader[TaskScheduleDataModel.DataColumns.TaskScheduleType].ToString();
                    //SetStandardInfo(dataItem, dbReader);

                    result.Add(dataItem);
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        protected override DataTable UpdateData()
        {
            var UpdatedData = new DataTable();
            var data        = new TaskScheduleDataModel();

            UpdatedData = TaskScheduleDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.TaskScheduleId =
                    Convert.ToInt32(SelectedData.Rows[i][TaskScheduleDataModel.DataColumns.TaskScheduleId].ToString());

                data.TaskEntityId =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(TaskScheduleDataModel.DataColumns.TaskEntityId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(TaskScheduleDataModel.DataColumns.TaskEntityId).ToString())
                                        : int.Parse(SelectedData.Rows[i][TaskScheduleDataModel.DataColumns.TaskEntityId].ToString());


                data.TaskScheduleTypeId =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(TaskScheduleDataModel.DataColumns.TaskScheduleTypeId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(TaskScheduleDataModel.DataColumns.TaskScheduleTypeId).ToString())
                                        : int.Parse(SelectedData.Rows[i][TaskScheduleDataModel.DataColumns.TaskScheduleTypeId].ToString());

                TaskScheduleDataManager.Update(data, SessionVariables.RequestProfile);
                data = new TaskScheduleDataModel();
                data.TaskScheduleId = Convert.ToInt32(SelectedData.Rows[i][TaskScheduleDataModel.DataColumns.TaskScheduleId].ToString());
                var dt = TaskScheduleDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }
Exemplo n.º 6
0
        protected override void ShowData(int taskScheduleId)
        {
            base.ShowData(taskScheduleId);

            oDetailButtonPanel.SetId = SetId;

            Clear();

            var dataQuery = new TaskScheduleDataModel();

            dataQuery.TaskScheduleId = taskScheduleId;

            var entityList = Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

            if (entityList.Count == 1)
            {
                foreach (var entityItem in entityList)
                {
                    lblTaskScheduleId.Text   = entityItem.TaskScheduleId.ToString();
                    lblApplicationId.Text    = entityItem.ApplicationId.ToString();
                    lblTaskEntity.Text       = entityItem.TaskEntity.ToString();
                    lblTaskScheduleType.Text = entityItem.TaskScheduleType.ToString();

                    oUpdateInfo.LoadText(entityItem.UpdatedDate, entityItem.UpdatedBy, entityItem.LastAction);

                    oHistoryList.Setup(PrimaryEntity, taskScheduleId, "TaskSchedule");
                }
            }
        }
Exemplo n.º 7
0
        public static DataTable DoesExist(TaskScheduleDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new TaskScheduleDataModel();

            doesExistRequest.Name = data.Name;

            return(Search(doesExistRequest, requestProfile));
        }
Exemplo n.º 8
0
        public static DataTable Search(TaskScheduleDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            var table = list.ToDataTable();

            return(table);
        }
Exemplo n.º 9
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var taskScheduledata = new TaskScheduleDataModel();

            taskScheduledata.TaskScheduleId = entityKey;
            var results = TaskScheduleDataManager.Search(taskScheduledata, SessionVariables.RequestProfile);

            return(results);
        }
Exemplo n.º 10
0
        private System.Data.DataTable GetData()
        {
            // TODO: on all export pages
            var data = new TaskScheduleDataModel();

            var dt = Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Exemplo n.º 11
0
        private static DataSet GetChildren(TaskScheduleDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.TaskScheduleChildrenGet " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, TaskScheduleDataModel.DataColumns.TaskScheduleId);

            var oDT = new DataAccess.DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
Exemplo n.º 12
0
        protected override void Clear()
        {
            base.Clear();

            var data = new TaskScheduleDataModel();

            TaskScheduleId     = data.TaskScheduleId;
            TaskEntityId       = data.TaskEntityId;
            TaskScheduleTypeId = data.TaskScheduleTypeId;
        }
Exemplo n.º 13
0
        private void Update(Dictionary <string, string> values)
        {
            var data = new TaskScheduleDataModel();

            data.TaskScheduleId = int.Parse(values[TaskScheduleDataModel.DataColumns.TaskScheduleId].ToString());
            data.TaskEntityId   = int.Parse(values[TaskScheduleDataModel.DataColumns.TaskEntityId].ToString());
            data.TaskScheduleId = int.Parse(values[TaskScheduleDataModel.DataColumns.TaskScheduleTypeId].ToString());

            Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.Update(data, SessionVariables.RequestProfile);
            InlineEditingList.Data = GetData();
        }
Exemplo n.º 14
0
        public static bool DoesExist(TaskScheduleDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new TaskScheduleDataModel();

            doesExistRequest.TaskEntityId       = data.TaskEntityId;
            doesExistRequest.TaskScheduleTypeId = data.TaskScheduleTypeId;

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

            return(list.Count > 0);
        }
Exemplo n.º 15
0
        public static void Delete(TaskScheduleDataModel dataQuery, RequestProfile requestProfile)
        {
            const string sql = @"dbo.TaskScheduleDelete ";

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

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Exemplo n.º 16
0
        private DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();
                var selectedrows     = new DataTable();
                var TaskScheduledata = new TaskScheduleDataModel();

                selectedrows = Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.GetDetails(TaskScheduledata, SessionVariables.RequestProfile).Clone();
                if (!string.IsNullOrEmpty(SuperKey))
                {
                    var data = new SuperKeyDetailDataModel();
                    data.SuperKeyId = Convert.ToInt32(SuperKey);
                    // Change System Entity Type
                    data.SystemEntityTypeId = (int)Framework.Components.DataAccess.SystemEntity.TaskSchedule;
                    var dt = Framework.Components.Core.SuperKeyDetailDataManager.Search(data, SessionVariables.RequestProfile);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        var keys = new int[dt.Rows.Count];
                        for (var i = 0; i < dt.Rows.Count; i++)
                        {
                            keys[i] = Convert.ToInt32(dt.Rows[i][SuperKeyDetailDataModel.DataColumns.EntityKey]);
                            TaskScheduledata.TaskScheduleId = keys[i];
                            var result = Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.GetDetails(TaskScheduledata, SessionVariables.RequestProfile);
                            selectedrows.ImportRow(result.Rows[0]);
                        }
                    }
                }
                else
                {
                    var key = SetId;
                    TaskScheduledata.TaskScheduleId = key;
                    var result = Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.GetDetails(TaskScheduledata, SessionVariables.RequestProfile);
                    selectedrows.ImportRow(result.Rows[0]);
                }
                return(selectedrows);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(null);
        }
Exemplo n.º 17
0
        public static bool IsDeletable(TaskScheduleDataModel 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);
        }
Exemplo n.º 18
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string[] deleteIndexList = DeleteIds.Split(',');
                foreach (string index in deleteIndexList)
                {
                    var data = new TaskScheduleDataModel();
                    data.TaskScheduleId = int.Parse(index);
                    Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.Delete(data, SessionVariables.RequestProfile);
                }

                DeleteAndRedirect();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Exemplo n.º 19
0
        public void LoadData(int taskScheduleId, bool showId)
        {
            // clear UI

            Clear();

            var dataQuery = new TaskScheduleDataModel();

            dataQuery.TaskScheduleId = taskScheduleId;

            var items = Framework.Components.TasksAndWorkflow.TaskScheduleDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

            if (items.Count != 1)
            {
                return;
            }

            var item = items[0];

            TaskScheduleId     = item.TaskScheduleId;
            TaskEntityId       = item.TaskEntityId;
            TaskScheduleTypeId = item.TaskScheduleTypeId;

            if (!showId)
            {
                txtTaskScheduleId.Text = item.TaskScheduleId.ToString();

                // only show Audit History in case of Update page, not for Clone.
                oHistoryList.Setup((int)Framework.Components.DataAccess.SystemEntity.TaskSchedule, taskScheduleId, "TaskSchedule");
            }
            else
            {
                txtTaskScheduleId.Text = String.Empty;
            }

            oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);
        }
Exemplo n.º 20
0
        public static string ToSQLParameter(TaskScheduleDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

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

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

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

            return(returnValue);
        }
Exemplo n.º 21
0
        public static TaskScheduleDataModel GetDetails(TaskScheduleDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }
Exemplo n.º 22
0
        public static void Update(TaskScheduleDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, requestProfile, "Update");

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