예제 #1
0
        public static void AddScheduleQuestions(int scheduleId, RequestProfile requestProfile)
        {
            // get all questions
            var questionData = QuestionDataManager.GetList(requestProfile);

            // filter question records using Question Category 'EOD Questions'
            questionData.DefaultView.RowFilter = "QuestionCategory = 'EOD Questions'";
            questionData = questionData.DefaultView.ToTable();

            var scheduleQuestionData = new ScheduleQuestionDataModel();

            // for loop for entering default answers for all questions
            for (var i = 0; i < questionData.Rows.Count; i++)
            {
                var questionid = int.Parse(questionData.Rows[i][QuestionDataModel.DataColumns.QuestionId].ToString());

                scheduleQuestionData = new ScheduleQuestionDataModel();

                scheduleQuestionData.ScheduleId = scheduleId;
                scheduleQuestionData.QuestionId = int.Parse(questionid.ToString());
                scheduleQuestionData.Answer     = "No";

                ScheduleQuestionDataManager.Create(scheduleQuestionData, requestProfile);
            }
        }
예제 #2
0
        public void LoadData(int questionId, bool showId)
        {
            Clear();

            var data = new QuestionDataModel();

            data.QuestionId = questionId;
            var items = QuestionDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);


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

            var item = items[0];

            QuestionId = item.QuestionId;
            Question   = item.QuestionPhrase;
            Category   = item.QuestionCategoryId;
            SortOrder  = item.SortOrder;

            if (!showId)
            {
                txtQuestionId.Text = item.QuestionId.ToString();
                oHistoryList.Setup(PrimaryEntity, questionId, PrimaryEntityKey);
            }
            else
            {
                txtQuestionId.Text = String.Empty;
            }

            oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);
        }
예제 #3
0
        public override int?Save(string action)
        {
            var data = new QuestionDataModel();

            data.QuestionId         = QuestionId;
            data.QuestionPhrase     = Question;
            data.QuestionCategoryId = Category;
            data.SortOrder          = SortOrder;

            if (action == "Insert")
            {
                var dtQuestion = QuestionDataManager.DoesExist(data, SessionVariables.RequestProfile);

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

            return(QuestionId);
        }
예제 #4
0
        protected override void ShowData(int questionId)
        {
            base.ShowData(questionId);

            oDetailButtonPanel.SetId = SetId;

            Clear();

            var data = new QuestionDataModel();

            data.QuestionId = questionId;

            var items = QuestionDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

            if (items.Count == 1)
            {
                var item = items[0];

                lblQuestionId.Text = item.QuestionId.ToString();
                lblQuestion.Text   = item.QuestionPhrase;
                lblCategory.Text   = item.QuestionCategory;
                lblSortOrder.Text  = item.SortOrder.ToString();

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

                oHistoryList.Setup(PrimaryEntity, questionId, "Question");
            }
        }
예제 #5
0
        protected override DataTable UpdateData()
        {
            var UpdatedData = new DataTable();

            var data = new QuestionDataModel();

            UpdatedData = QuestionDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.QuestionId =
                    Convert.ToInt32(SelectedData.Rows[i][QuestionDataModel.DataColumns.QuestionId].ToString());
                data.QuestionPhrase     = SelectedData.Rows[i][QuestionDataModel.DataColumns.QuestionPhrase].ToString();
                data.QuestionCategoryId = Convert.ToInt32(SelectedData.Rows[i][QuestionDataModel.DataColumns.QuestionCategoryId].ToString());
                data.SortOrder          =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(QuestionDataModel.DataColumns.SortOrder))
                    ? int.Parse(CheckAndGetRepeaterTextBoxValue(QuestionDataModel.DataColumns.SortOrder).ToString())
                    : int.Parse(SelectedData.Rows[i][QuestionDataModel.DataColumns.SortOrder].ToString());

                QuestionDataManager.Update(data, SessionVariables.RequestProfile);
                data            = new QuestionDataModel();
                data.QuestionId = Convert.ToInt32(SelectedData.Rows[i][QuestionDataModel.DataColumns.QuestionId].ToString());
                var dt = QuestionDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }
예제 #6
0
        // GET api/summary/GetList
        public IEnumerable <QuestionDataModel> GetList(string value, string value1)
        {
            var settingCategory = value1;
            var searchString    = value;

            var dictionaryObject = JsonConvert.DeserializeObject <Dictionary <string, string> >(searchString);

            // save search filter parameters in user preference
            if (dictionaryObject != null)
            {
                foreach (var searchFilterColumnName in dictionaryObject.Keys)
                {
                    var searchFilterValue = dictionaryObject[searchFilterColumnName];
                    PerferenceUtility.UpdateUserPreference(settingCategory, searchFilterColumnName, dictionaryObject[searchFilterColumnName]);
                }
            }
            var dataQuery = new QuestionDataModel();

            try
            {
                dataQuery = JsonConvert.DeserializeObject <QuestionDataModel>(searchString);
            }
            catch { }

            // igonore when value is -1
            if (dataQuery.QuestionCategoryId == -1)
            {
                dataQuery.QuestionCategoryId = null;
            }
            return(QuestionDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile));
        }
예제 #7
0
        private System.Data.DataTable GetData()
        {
            var data = new QuestionDataModel();

            var dt = QuestionDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
예제 #8
0
        public static void SyncQuestions(int scheduleId, RequestProfile requestProfile)
        {
            // Get all ScheduleId related records from ScheduleQuestion
            var dtScheduleQuestion = ScheduleQuestionDataManager.GetBySchedule(scheduleId, requestProfile);

            // Get all Question Records
            var questionData = QuestionDataManager.GetList(requestProfile);

            // filter question records using Question Category 'EOD Questions'
            questionData.DefaultView.RowFilter = "QuestionCategory = 'EOD Questions'";
            questionData = questionData.DefaultView.ToTable();

            var scheduleQuestionData = new ScheduleQuestionDataModel();

            // for loop for entering default answers for all questions
            for (var i = 0; i < questionData.Rows.Count; i++)
            {
                var questionid = int.Parse(questionData.Rows[i][QuestionDataModel.DataColumns.QuestionId].ToString());

                var filterExpression = QuestionDataModel.DataColumns.QuestionId + " = " + questionid;

                // find if record for this question id exists in ScheduleQuestion for the particular ScheduleId
                var rows = dtScheduleQuestion.Select(filterExpression);

                // insert if no record found
                if (rows.Length == 0)
                {
                    scheduleQuestionData = new ScheduleQuestionDataModel();

                    scheduleQuestionData.ScheduleId = scheduleId;
                    scheduleQuestionData.QuestionId = int.Parse(questionid.ToString());
                    scheduleQuestionData.Answer     = "No";

                    ScheduleQuestionDataManager.Create(scheduleQuestionData, requestProfile);
                }
            }
            // refresh data table with newly added records
            dtScheduleQuestion = ScheduleQuestionDataManager.GetBySchedule(scheduleId, requestProfile);

            // for removing invalid category schedule questions
            for (var i = 0; i < dtScheduleQuestion.Rows.Count; i++)
            {
                var questionid = int.Parse(dtScheduleQuestion.Rows[i][ScheduleQuestionDataModel.DataColumns.QuestionId].ToString());

                var filterExpression = ScheduleQuestionDataModel.DataColumns.QuestionId + " = " + questionid;

                // find if record for this question id exists in ScheduleQuestion for the particular ScheduleId
                var rows = questionData.Select(filterExpression);

                // insert if no record found, so it is invalid
                if (rows.Length == 0)
                {
                    scheduleQuestionData = new ScheduleQuestionDataModel();
                    scheduleQuestionData.ScheduleQuestionId = int.Parse(dtScheduleQuestion.Rows[i][ScheduleQuestionDataModel.DataColumns.ScheduleQuestionId].ToString());
                    ScheduleQuestionDataManager.Delete(scheduleQuestionData, requestProfile);
                }
            }
        }
예제 #9
0
        private DataTable GetAssociatedQuestionCategorys(int questionId)
        {
            QuestionDataModel data = new QuestionDataModel();

            data.QuestionId = questionId;
            var dt = QuestionDataManager.GetDetails(data, SessionVariables.RequestProfile);

            return(dt);
        }
예제 #10
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var questiondata = new QuestionDataModel();

            questiondata.QuestionId = entityKey;
            var results = QuestionDataManager.Search(questiondata, SessionVariables.RequestProfile);

            return(results);
        }
예제 #11
0
        protected override void Update(Dictionary <string, string> values)
        {
            var data = new QuestionDataModel();

            // copies properties from values dictionary object to data object
            PropertyMapper.CopyProperties(data, values);

            QuestionDataManager.Update(data, SessionVariables.RequestProfile);
            base.Update(values);
        }
예제 #12
0
        private void SetupDropdown()
        {
            var isTesting    = SessionVariables.IsTesting;
            var questionData = QuestionDataManager.GetList(SessionVariables.RequestProfile);

            UIHelper.LoadDropDown(questionData, drpQuestionList, QuestionDataModel.DataColumns.QuestionPhrase,
                                  QuestionDataModel.DataColumns.QuestionId);

            var scheduleData = TaskTimeTracker.Components.Module.TimeTracking.ScheduleDataManager.GetList(SessionVariables.RequestProfile);

            UIHelper.LoadDropDown(scheduleData, drpScheduleList, ScheduleDataModel.DataColumns.ScheduleId,
                                  ScheduleDataModel.DataColumns.ScheduleId);

            if (isTesting)
            {
                drpQuestionList.AutoPostBack = true;
                drpScheduleList.AutoPostBack = true;
                if (drpQuestionList.Items.Count > 0)
                {
                    if (!string.IsNullOrEmpty(txtQuestionId.Text.Trim()))
                    {
                        drpQuestionList.SelectedValue = txtQuestionId.Text;
                    }
                    else
                    {
                        txtQuestionId.Text = drpQuestionList.SelectedItem.Value;
                    }
                }
                if (drpScheduleList.Items.Count > 0)
                {
                    if (!string.IsNullOrEmpty(txtScheduleId.Text.Trim()))
                    {
                        drpScheduleList.SelectedValue = txtScheduleId.Text;
                    }
                    else
                    {
                        txtScheduleId.Text = drpScheduleList.SelectedItem.Value;
                    }
                }
                txtScheduleId.Visible = true;
                txtQuestionId.Visible = true;
            }
            else
            {
                if (!string.IsNullOrEmpty(txtQuestionId.Text.Trim()))
                {
                    drpQuestionList.SelectedValue = txtQuestionId.Text;
                }
                if (!string.IsNullOrEmpty(txtScheduleId.Text.Trim()))
                {
                    drpScheduleList.SelectedValue = txtScheduleId.Text;
                }
            }
        }
예제 #13
0
        private void UpdateData(ArrayList values)
        {
            var data = new QuestionDataModel();

            data.QuestionId         = int.Parse(values[0].ToString());
            data.QuestionPhrase     = values[1].ToString();
            data.QuestionCategoryId = int.Parse(values[2].ToString());
            data.SortOrder          = int.Parse(values[3].ToString());
            QuestionDataManager.Update(data, SessionVariables.RequestProfile);
            ReBindEditableGrid();
        }
예제 #14
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var notDeletableIds = new List <int>();
                var deleteIndexList = DeleteIds.Split(',');

                foreach (var index in deleteIndexList)
                {
                    var data = new QuestionDataModel();
                    data.QuestionId = int.Parse(index);

                    if (!QuestionDataManager.IsDeletable(data, SessionVariables.RequestProfile))
                    {
                        notDeletableIds.Add((int)(data.QuestionId));
                    }
                }

                if (notDeletableIds.Count == 0)
                {
                    foreach (var index in deleteIndexList)
                    {
                        var data = new QuestionDataModel();
                        data.QuestionId = int.Parse(index);

                        QuestionDataManager.Delete(data, SessionVariables.RequestProfile);
                    }

                    DeleteAndRedirect();
                }
                else
                {
                    var msg = String.Empty;

                    foreach (var id in notDeletableIds)
                    {
                        if (!string.IsNullOrEmpty(msg))
                        {
                            msg += ", <br/>";
                        }
                        msg += "QuestionId: " + id + " has detail records";
                    }
                    Response.Write(msg);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
예제 #15
0
        private DataTable GetQuestionData(int questionCategoryId)
        {
            var data = new QuestionDataModel();

            data.QuestionCategoryId = questionCategoryId;
            var dt       = QuestionDataManager.Search(data, SessionVariables.RequestProfile);
            var fdt      = QuestionDataManager.GetList(SessionVariables.RequestProfile);
            var resultdt = fdt.Clone();

            foreach (DataRow row in dt.Rows)
            {
                var rows = fdt.Select(QuestionDataModel.DataColumns.QuestionId + " = " + row[QuestionDataModel.DataColumns.QuestionId]);
                resultdt.ImportRow(rows[0]);
            }
            return(resultdt);
        }
예제 #16
0
        // GET api/summary/GetList
        public IEnumerable <string> GetAutoCompleteList(string value, string value1)
        {
            var primaryEntity = value;
            var searchField   = value1;
            var lstOptions    = new List <string>();

            if (primaryEntity.Equals("MenuCategory", StringComparison.InvariantCultureIgnoreCase))
            {
                if (searchField == "Name")
                {
                    var dt = MenuCategoryDataManager.GetList(SessionVariables.RequestProfile);
                    lstOptions = (from row in dt.AsEnumerable()
                                  select row["Name"].ToString().Trim()).ToList();
                }
            }
            else if (primaryEntity.Equals("Question", StringComparison.InvariantCultureIgnoreCase))
            {
                if (searchField == "QuestionPhrase")
                {
                    var dt = QuestionDataManager.GetList(SessionVariables.RequestProfile);
                    lstOptions = (from row in dt.AsEnumerable()
                                  select row["QuestionPhrase"].ToString().Trim()).ToList();
                }
            }

            else if (primaryEntity.Equals("Log4Net", StringComparison.InvariantCultureIgnoreCase))
            {
                if (searchField == "Computer")
                {
                    lstOptions = Framework.Components.LogAndTrace.Log4NetDataManager.GetComputerDetails(SessionVariables.RequestProfile);
                }
                if (searchField == "ConnectionKey")
                {
                    lstOptions = Framework.Components.LogAndTrace.Log4NetDataManager.GetConnectionKeyList(SessionVariables.RequestProfile);
                }
            }

            return(lstOptions);
        }
예제 #17
0
        protected override DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();

                var selectedrows = new DataTable();
                var questiondata = new QuestionDataModel();

                selectedrows = QuestionDataManager.GetDetails(questiondata, SessionVariables.RequestProfile).Clone();
                if (!string.IsNullOrEmpty(SuperKey))
                {
                    var systemEntityTypeId = (int)PrimaryEntity;
                    var lstEntityKeys      = ApplicationCommon.GetSuperKeyDetails(systemEntityTypeId, SuperKey);

                    foreach (var entityKey in lstEntityKeys)
                    {
                        questiondata.QuestionId = entityKey;
                        var result = QuestionDataManager.GetDetails(questiondata, SessionVariables.RequestProfile);
                        selectedrows.ImportRow(result.Rows[0]);
                    }
                }
                else
                {
                    questiondata.QuestionId = SetId;
                    var result = QuestionDataManager.GetDetails(questiondata, SessionVariables.RequestProfile);
                    selectedrows.ImportRow(result.Rows[0]);
                }
                return(selectedrows);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

            return(null);
        }
예제 #18
0
        protected override DataTable GetData()
        {
            var dt = QuestionDataManager.Search(oSearchFilter.SearchParameters, SessionVariables.RequestProfile);

            return(dt);
        }
예제 #19
0
 private void ReBindEditableGrid()
 {
     var data       = new QuestionDataModel();
     var dtQuestion = QuestionDataManager.Search(data, SessionVariables.RequestProfile);
 }