Example #1
0
 public static QuestionResponseDto TestAddQuestionResponseDto(QuestionnaireDto _currentQuestionnaire, PageElementChoiceDto pers)
 {
     long responseKey = FormRegistry.ResponseDao.CreateSubmitResponse(Constants.UnknownCustomer, null, _currentQuestionnaire.QuestionnaireId, ViewType.CleanSheetOverlay).First;
     Assert.Greater(responseKey, 0);
     QuestionResponseDto dto = new QuestionResponseDto(responseKey, pers.ChoiceId, "choiceText", null, "ckmfieldid_tirumala");
     Assert.IsTrue(FormRegistry.ResponseDao.Add(dto));
     return dto;
 }
        public override List<ResponseDto> GetResponseDto(long responseId)
        {
            RfgExternalPage page = Page as RfgExternalPage;
            if (page == null)
            {
                throw new BugException(GetType().Name + " is only supported within RFG pages");
            }
            List<ResponseDto> retval = new List<ResponseDto>();

            if (_phone != null)
            {
                if (!String.IsNullOrEmpty(Ux_Telephone.Text))
                {
                    QuestionResponseDto phone = new QuestionResponseDto(responseId, _phone.ChoiceId, Ux_Telephone.Text, null);
                    retval.Add(phone);
                }
            }

            if (_callBack != null)
            {
                if (Ux_CallBack.SelectedIndex > 0)
                {
                    int lovFk = 0;
                    if (Int32.TryParse(Ux_CallBack.SelectedItem.Value, out lovFk))
                    {
                        QuestionResponseDto callback = new QuestionResponseDto(responseId, _callBack.ChoiceId, null, lovFk);
                        retval.Add(callback);
                    }
                }
            }

            if (retval.Count > 0)
            {
                bool cidSubmit = false;
                bool crmSubmit = page.PageAssembly.Questionnaire.SendToCrm;
                string elementType = SpecificCrmResponseDto.ElementTypeRequestCallback;
                int pageId = page.PageAssembly.Page.PageId;
                int? questionId = PageElement.ElementId;
                int questionnaireId = page.PageAssembly.Questionnaire.QuestionnaireId;
                //string respDesc = "Response to RFG web form - " + Page.Request.Url;
                string respDesc = "Response to RFG web form - qid " + questionnaireId;
                SpecificCrmResponseDto response = new SpecificCrmResponseDto(responseId, cidSubmit, crmSubmit, elementType, pageId, questionId, questionnaireId, respDesc);
                retval.Add(response);
            }
            return retval;
        }
Example #3
0
 private void Write(DbCommand sp, QuestionResponseDto dto)
 {
     _dbLayer.AddInParameter(sp, "@response_id", DbType.Int64, dto.ResponseKey);
     _dbLayer.AddInParameter(sp, "@choice_id", DbType.Int32, dto.ChoiceId);
     _dbLayer.AddInParameter(sp, "@choice_text", DbType.String, dto.ChoiceText);
     if (dto.ListOfValuesId.HasValue)
     {
         _dbLayer.AddInParameter(sp, "@lov_FK", DbType.Int32, dto.ListOfValuesId);
     }
 }
Example #4
0
        public bool Add(QuestionResponseDto dto)
        {
            bool retval = false;
            DbCommand sp = null;
            DbConnection connection = null;
            IDataReader reader = null;
            try
            {
                connection = _dbLayer.GetConnection();
                sp = connection.CreateCommand();

                sp.CommandText = "insert_response_question";
                sp.CommandType = CommandType.StoredProcedure;
                _dbLayer.AddReturnParameter(sp);
                Write(sp, dto);
                sp.ExecuteNonQuery();
                int err = _dbLayer.GetReturnValue(sp);
                if (err == 0)
                {
                    retval = true;
                }
                else
                {
                    Trace.WriteLine("ResponseDao.Add(" + dto + "): returned " + err);
                }
            }
            catch (DbException e)
            {
                Trace.WriteLine("ResponseDao.Add(" + dto + "): " + e.Message);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }

                if (sp != null)
                {
                    sp.Dispose();
                }

                if (connection != null)
                {
                    _dbLayer.ReturnConnection(connection);
                }
                else
                {
                    _dbLayer.ReturnConnection(connection, true);
                }
            }

            return retval;
        }
        public override List<ResponseDto> GetResponseDto(long responseId)
        {
            RfgExternalPage page = Page as RfgExternalPage;
            if (page == null)
            {
                throw new BugException(GetType().Name + " is only supported within RFG pages");
            }
            List<ResponseDto> retval = new List<ResponseDto>();

            if (Ux_Yes.Checked)
            {
                //ReadResponse(_yes, responseId, null, retval);
                retval.Add(new QuestionResponseDto(responseId, _yes.ChoiceId, null, null));
            }
            else
            {
                if (Ux_No.Checked)
                {
                    //ReadResponse(_no, responseId, null, retval);
                    retval.Add(new QuestionResponseDto(responseId, _no.ChoiceId, null, null));
                }
            }

            if (Ux_TimeFrame.SelectedIndex > 0)
            {
                int lovFk = 0;
                if (Int32.TryParse(Ux_TimeFrame.SelectedItem.Value, out lovFk))
                {
                    QuestionResponseDto callback = new QuestionResponseDto(responseId, _timeFrame.ChoiceId, null, lovFk);
                    retval.Add(callback);
                }
            }

            if (retval.Count > 0)
            {
                bool cidSubmit = false;
                bool crmSubmit = page.PageAssembly.Questionnaire.SendToCrm;
                string elementType = SpecificCrmResponseDto.ElementTypeRespondInterest;
                int pageId = page.PageAssembly.Page.PageId;
                int? questionId = PageElement.ElementId;
                int questionnaireId = page.PageAssembly.Questionnaire.QuestionnaireId;
                //string respDesc = "Response to RFG web form - " + Page.Request.Url;
                string respDesc = "Response to RFG web form - qid " + questionnaireId;
                SpecificCrmResponseDto response = new SpecificCrmResponseDto(responseId, cidSubmit, crmSubmit, elementType, pageId, questionId, questionnaireId, respDesc);
                retval.Add(response);
            }
            return retval;
        }
 private static void ReadResponse(PageElementChoiceDto choice, long responseId, string text, List<ResponseDto> retval)
 {
     LovInfo info = Array.Find<LovInfo>(choice.LovInfos, delegate(LovInfo cur) { return cur.ColName == "willingness_to_buy"; });
     int? lovFk = null;
     if (info != null)
     {
         lovFk = info.LovKey;
     }
     QuestionResponseDto response = new QuestionResponseDto(responseId, choice.ChoiceId, text, lovFk);
     retval.Add(response);
 }
Example #7
0
        private void SubmitSpecialQuestions(int QuestionnaireID, int Page_ID, int privacycount)
        {
            bool isTransferToSiebel = IsSiebelToTransferFlag(QuestionnaireID);
            SpecificCrmResponseDto SpecificResponseQuestions = null;
            QuestionResponseDto ResponseQuestions = null;
            Int32 questionID = 0;
            int SubmittedSiebelQuestionCount = 0;

            string strExtraChoiceText = string.Empty;

            if (SpecialQuestion_Answers != null)
            {
                if (SpecialQuestion_Answers.Rows.Count > 0)
                {
                    foreach (DataRow drs in SpecialQuestionChoiceTexts.Rows)
                    {
                        if (Convert.ToInt16(drs["lov_fk"].ToString()) != 0)
                        {
                            ResponseQuestions = new QuestionResponseDto(Convert.ToInt64(ResponseID), Convert.ToInt32(drs["choice_id"].ToString()), drs["Question_Choice_ExtraText"].ToString(), Convert.ToInt16(drs["lov_fk"].ToString()));
                            FormRegistry.ResponseDao.Add(ResponseQuestions);
                            responses.Add(ResponseQuestions);
                            if (ResponseQuestions.ChoiceId.ToString() != "")
                            {
                                SubmittedSiebelQuestionCount++;
                            }
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(drs["choice_id"].ToString()))
                            {
                                ResponseQuestions = new QuestionResponseDto(Convert.ToInt64(ResponseID), Convert.ToInt32(drs["choice_id"].ToString()), drs["Question_Choice_ExtraText"].ToString(), null);
                                FormRegistry.ResponseDao.Add(ResponseQuestions);
                                responses.Add(ResponseQuestions);
                                if (ResponseQuestions.ChoiceId.ToString() != "")
                                {
                                    SubmittedSiebelQuestionCount++;
                                }
                            }
                        }
                    }
                    foreach (DataRow QuestionRow in SpecialQuestion_Answers.Rows)
                    {
                        if ((QuestionRow["element_type_fk"].ToString().Equals("dm")))
                        {
                            questionID = int.Parse(QuestionRow["element_id"].ToString());
                            int choiceID = int.Parse(QuestionRow["question_id"].ToString());
                            if (questionID != 0 && choiceID != 0)
                            {
                                DataRow[] mailtosubject = null;
                                Hashtable h_params = new Hashtable();
                                h_params.Add("question_id", questionID);
                                DataTable MailtoSubject = DB.execProc("rfg_PageElement_ListChoices", h_params);

                                if (MailtoSubject != null)
                                {
                                    if (MailtoSubject.Rows.Count > 0)
                                    {
                                        mailtosubject = MailtoSubject.Select("choice_id = " + choiceID);
                                        if (mailtosubject != null)
                                        {
                                            if (mailtosubject.Length > 0)
                                                MailtoRecipent = mailtosubject[0]["mailto_recipient"].ToString().Trim();
                                        }
                                    }
                                }
                            }
                        }

                        if (!(QuestionRow["element_type_fk"].ToString().Equals("dm")))
                        {
                            if (isTransferToSiebel)
                            {
                                SpecificResponseQuestions = new SpecificCrmResponseDto(Convert.ToInt64(ResponseID), false, true, QuestionRow["element_type_FK"].ToString()
                                    , Convert.ToInt32(QuestionRow["page_id"].ToString()), Convert.ToInt32(QuestionRow["element_id"].ToString()),
                                   Convert.ToInt32(QuestionRow["questionnaire_id"].ToString()), QuestionResponseDescription);
                                FormRegistry.ResponseDao.Add(SpecificResponseQuestions);
                                responses.Add(SpecificResponseQuestions);
                            }
                        }
                    }

                   
                }


                if (isTransferToSiebel)
                {
                    if (privacycount > 0)
                    {
                        SpecificResponseQuestions = new SpecificCrmResponseDto(Convert.ToInt64(ResponseID), true, true, "--"
                        , Convert.ToInt32(Page_ID), null,
                        Convert.ToInt32(QuestionnaireID), QuestionResponseDescription);
                        //FormRegistry.ResponseDao.Add(SpecificResponseQuestions);
                        responses.Add(SpecificResponseQuestions);
                    }
                    else
                    {
                        //TODO: Check if that can be removed or element type can change to '--' 
                        //SpecificResponseQuestions = new SpecificCrmResponseDto(Convert.ToInt64(ResponseID), true, true, null
                        //, Convert.ToInt32(Page_ID), null,
                        //Convert.ToInt32(QuestinoareID), QuestionResponseDescription);
                        //FormRegistry.ResponseDao.Add(SpecificResponseQuestions);
                        //responses.Add(SpecificResponseQuestions);
                    }

                    // RFG 2.19 | DMS-update response type to "Complted Survey" if no sibel question submitted in the response and  privacy section exists
                    if (isTransferToSiebel)
                    {
                        foreach (ResponseDto response in responses)
                        {
                            if (response.GetType() == typeof(SpecificCrmResponseDto) && (((SpecificCrmResponseDto)response).ElementType == "--"))
                            {
                                if (SubmittedSiebelQuestionCount == 0 && !isAnyAsset)
                                {
                                    ((SpecificCrmResponseDto)response).ElementType = "##";
                                    FormRegistry.ResponseDao.Add((SpecificCrmResponseDto)response);
                                }
                                else
                                    FormRegistry.ResponseDao.Add((SpecificCrmResponseDto)response);
                            }
                        }
                    } //End RFG 2.19
                }
                else
                {
                    if (privacycount > 0)
                    {
                        SpecificResponseQuestions = new SpecificCrmResponseDto(Convert.ToInt64(ResponseID), true, false, "--"
                           , Convert.ToInt32(Page_ID), null,
                           Convert.ToInt32(QuestionnaireID), QuestionResponseDescription);
                        FormRegistry.ResponseDao.Add(SpecificResponseQuestions);
                        responses.Add(SpecificResponseQuestions);
                    }
                    else
                    {
                        //TODO: Check if that can be removed or element type can change to '--'
                        //SpecificResponseQuestions = new SpecificCrmResponseDto(Convert.ToInt64(ResponseID), true, false, null
                        //   , Convert.ToInt32(Page_ID), null,
                        //   Convert.ToInt32(QuestinoareID), QuestionResponseDescription);
                        //FormRegistry.ResponseDao.Add(SpecificResponseQuestions);
                        //responses.Add(SpecificResponseQuestions);
                    }
                }

                //trigger one time insertion for any asset crm response record "completed websurvey"
                if (isTransferToSiebel && isAnyAsset)
                {
                    SpecificResponseQuestions = new SpecificCrmResponseDto(Convert.ToInt64(ResponseID), false, true, ""
                       , Convert.ToInt32(Page_ID), null,
                       Convert.ToInt32(QuestionnaireID), QuestionResponseDescription);
                    FormRegistry.ResponseDao.Add(SpecificResponseQuestions);
                    //responses.Add(SpecificResponseQuestions);
                }
            }

        }
Example #8
0
        private void SubmitCustomQuestions()
        {
            QuestionResponseDto ResponseQuestions = null;
            string ChoiceAnswer = string.Empty;

            if (Question_ChoiceIDs != null)
            {
                if (Question_ChoiceIDs.Rows.Count > 0)
                {
                    foreach (DataRow QuestionRow in Question_ChoiceIDs.Rows)
                    {
                        if (QuestionRow["choice_id"].ToString() != "")
                        {
                            if (string.IsNullOrEmpty(QuestionRow["Choice_Answer"].ToString().Trim()))
                            {
                                if (QuestionChoiceTexts != null)
                                {
                                    if (QuestionChoiceTexts.Rows.Count > 0)
                                    {
                                        if (QuestionChoiceTexts.Select("choice_id = '" + QuestionRow["choice_id"].ToString() + "'").Length > 0)
                                        {
                                            DataRow[] dr = null;
                                            dr = QuestionChoiceTexts.Select("choice_id = '" + QuestionRow["choice_id"].ToString() + "'");
                                            ChoiceAnswer = dr[0]["Question_Choice_ExtraText"].ToString();
                                        }
                                        else
                                            ChoiceAnswer = String.Empty;
                                    }
                                }

                                ResponseQuestions = new QuestionResponseDto(Convert.ToInt64(ResponseID), Convert.ToInt32(QuestionRow["choice_id"].ToString()), ChoiceAnswer, null);
                            }
                            else
                            {
                                ResponseQuestions = new QuestionResponseDto(Convert.ToInt64(ResponseID), Convert.ToInt32(QuestionRow["choice_id"].ToString()), QuestionRow["Choice_Answer"].ToString(), null);
                            }
                            FormRegistry.ResponseDao.Add(ResponseQuestions);

                            if (ResponseQuestions != null)
                                responses.Add(ResponseQuestions);
                        }
                    }
                }
            }

            if (QuestionChoiceTexts != null)
            {
                if (QuestionChoiceTexts.Rows.Count > 0)
                {
                    foreach (DataRow QuestionRow in QuestionChoiceTexts.Rows)
                    {
                        if (QuestionRow["choice_id"].ToString() != "")
                        {
                            ResponseQuestions = new QuestionResponseDto(Convert.ToInt64(ResponseID), Convert.ToInt32(QuestionRow["choice_id"].ToString()), QuestionRow["Question_Choice_ExtraText"].ToString(), null);
                            //FormRegistry.ResponseDao.Add(ResponseQuestions);

                            if (ResponseQuestions != null)
                                responses.Add(ResponseQuestions);
                        }
                    }
                }
            }


        }