Esempio n. 1
0
        internal Source(DataSet xmlDataSet,string xmlFileName)
        {
            string Publisher = string.Empty;
            string Title = string.Empty;
            string Year = string.Empty;
            int IndexOfSeparator = -1;

            // get source question
            this._SourceValue = Questionnarie.GetQuestion(xmlDataSet, MandatoryQuestionsKey.SorucePublisher);

            this._Publisher = Questionnarie.GetQuestion(xmlDataSet, MandatoryQuestionsKey.SorucePublisher);
            this._Title = Questionnarie.GetQuestion(xmlDataSet, MandatoryQuestionsKey.SourceTitle);
            this._Year = Questionnarie.GetQuestion(xmlDataSet, MandatoryQuestionsKey.SourceYear);
            FillList(xmlFileName);

            //reset publisher,title and year values
            if (!string.IsNullOrEmpty(this._SourceValue.DataValue))
            {
                string SourceString = string.Empty;
                SourceString = this.SourceValue.DataValue;
                IndexOfSeparator = SourceString.IndexOf(Constants.SourceSeparator);

                if(IndexOfSeparator>0)
                {
                    Publisher = SourceString.Substring(0,IndexOfSeparator);

                    // get year
                    Year = SourceString.Substring(SourceString.LastIndexOf(Constants.SourceSeparator)+ 1);

                    // get title
                    Title= SourceString.Replace(Publisher +"_","").Replace("_"+Year,"");

                }

                this._Publisher.DataValue = Publisher;
                this._Title.DataValue = Title;
                this._Year.DataValue = Year;
            }
        }
Esempio n. 2
0
        internal Area(DataSet xmlDataSet, string areaXmlFileName)
        {
            string[] AreaValue ;

            this.AreaXmlFileName = areaXmlFileName;

            // get area table
            this._AreaTable=this.GetAreaTable();

            //get area question
            this.AreaQuestion = Questionnarie.GetQuestion(xmlDataSet, MandatoryQuestionsKey.Area);

            //update datavalue for AreaId and AreaName
            if (!string.IsNullOrEmpty(this.AreaQuestion.DataValue))
            {
                //AreaValue= this.AreaQuesiton.DataValue.Split(Constants.AreaValueSeparator.ToCharArray());
                AreaValue = Questionnarie.SplitString(this.AreaQuestion.DataValue.ToString(), Constants.AreaValueSeparator);
                if (AreaValue.Length > 0)
                {
                    this._AreaName = AreaValue[0];
                }
                if (AreaValue.Length > 1)
                {
                    this._AreaID = AreaValue[1];
                }
                if (AreaValue.Length > 2)
                {
                    this._AreaGId = AreaValue[2];
                }
            }
            else
            {
                this._AreaGId = string.Empty;
                this._AreaID = string.Empty;
                this._AreaName = string.Empty;
            }
        }
Esempio n. 3
0
        private void WriteQuestionIntoExcel(DIExcel excelFile, Question xmlQuestion,ref int RowIndex)
        {
            int DataValueRowIndex = RowIndex + 1;
            int BoldStartIndex = -1;
            int BoldEndIndex = -1;
            int ItalicStartIndex = -1;
            int ItalicEndIndex = -1;
            string BoldStartTag="<b>";
            string ItalicStartTag="<i>";
            string BoldEndTag = "</b>";
            string ItalicEndTag = "</i>";
            string QuestionText=xmlQuestion.Text;

            //set question no and question text
            excelFile.SetCellValue(Constants.SheetIndex, RowIndex, Constants.QuestionNoColumnIndex, xmlQuestion.No);
            excelFile.SetColumnWidth(Constants.SheetIndex, 6, RowIndex, Constants.QuestionNoColumnIndex, RowIndex, Constants.QuestionNoColumnIndex);
            //replace <br> with new line character and remove enter key

            QuestionText= QuestionText.Replace(Char.ConvertFromUtf32(13), string.Empty);

            QuestionText = QuestionText.Replace("\n", string.Empty);
            QuestionText = QuestionText.Replace(Microsoft.VisualBasic.ControlChars.CrLf, string.Empty);
            QuestionText = QuestionText.Replace(Microsoft.VisualBasic.ControlChars.Lf.ToString(), string.Empty);
            QuestionText=QuestionText.Replace("<br>", Microsoft.VisualBasic.ControlChars.NewLine);

            //apply bold tag
            BoldStartIndex = QuestionText.IndexOf(BoldStartTag);
            if (BoldStartIndex >= 0)
            {
                QuestionText = QuestionText.Replace(BoldStartTag, string.Empty);
                BoldEndIndex = QuestionText.IndexOf(BoldEndTag);
                QuestionText = QuestionText.Replace(BoldEndTag, string.Empty);
            }

            //apply italic tag
            ItalicStartIndex = QuestionText.IndexOf(ItalicStartTag);
            if (ItalicStartIndex >= 0)
            {
                QuestionText = QuestionText.Replace(ItalicStartTag, string.Empty);
                ItalicEndIndex = QuestionText.IndexOf(ItalicEndTag);
                QuestionText = QuestionText.Replace(ItalicEndTag, string.Empty);
            }

            //set question text
            QuestionText.Replace(ItalicStartTag, string.Empty);
            excelFile.SetCellValue(Constants.SheetIndex, RowIndex, Constants.QuestionTextColumnIndex, QuestionText);

            //set bold
            if (BoldStartIndex >= 0 & BoldEndIndex >= 0)
            {
                excelFile.GetCellCharacters(Constants.SheetIndex, Constants.QuestionTextColumnIndex, RowIndex, BoldStartIndex, BoldEndIndex-BoldStartIndex).Font.Bold = true;
            }

            //set italic
            if (ItalicStartIndex >= 0 & ItalicEndIndex >= 0)
            {
                excelFile.GetCellCharacters(Constants.SheetIndex, Constants.QuestionTextColumnIndex, RowIndex, ItalicStartIndex, ItalicEndIndex-ItalicStartIndex).Font.Italic= true;
            }

            //set layout of question text cell and question no cell
            //excelFile.MergeCells(Constants.SheetIndex, RowIndex, Constants.QuestionTextColumnIndex, RowIndex, Constants.QuestionTextColumnIndex + 6);
            //excelFile.SetHorizontalAlignment(Constants.SheetIndex, RowIndex, Constants.QuestionTextColumnIndex, SpreadsheetGear.HAlign.Justify);
            //excelFile.SetVerticalAlignment(Constants.SheetIndex, RowIndex, Constants.QuestionTextColumnIndex, SpreadsheetGear.VAlign.Justify);
            //excelFile.GetCellFont(Constants.SheetIndex, RowIndex, Constants.QuestionTextColumnIndex).Bold = true;

            excelFile.GetCellFont(Constants.SheetIndex, RowIndex, Constants.QuestionNoColumnIndex).Bold = true;
            excelFile.AutoFitColumn(Constants.SheetIndex, Constants.QuestionNoColumnIndex);

            this.WriteDataValue(excelFile, xmlQuestion,ref DataValueRowIndex);

            RowIndex =DataValueRowIndex+ 2;
        }
Esempio n. 4
0
        private void WriteDataValue(DIExcel excelFile, Question xmlQuestion,ref int dataValueRowIndex)
        {
            string[] SelectedValues =null;
            int Index=0;
            switch (xmlQuestion.AnswerType)
            {
                case AnswerType.TB:
                case AnswerType.TBN:
                case AnswerType.RB:
                case AnswerType.CB:
                case AnswerType.DateType:
                    excelFile.SetCellValue(Constants.SheetIndex, dataValueRowIndex, Constants.DataValueColumnIndex, xmlQuestion.DataValue);
                    break;
                case AnswerType.SCB:
                case AnswerType.SRB:
                    break;
                case AnswerType.CH:
                    SelectedValues = DICommon.SplitStringNIncludeEmpyValue(xmlQuestion.DataValue, ",");
                    foreach (AnswerTypeOption Option in xmlQuestion.Options)
                    {
                        excelFile.GetCellFont(Constants.SheetIndex, dataValueRowIndex, Constants.DataValueColumnIndex).Name = "Wingdings";

                        if (SelectedValues[Index] == "1")
                        {
                            excelFile.SetCellValue(Constants.SheetIndex, dataValueRowIndex, Constants.DataValueColumnIndex, Char.ConvertFromUtf32(252) );
                        }
                        else
                        {
                            excelFile.SetCellValue(Constants.SheetIndex, dataValueRowIndex, Constants.DataValueColumnIndex, Char.ConvertFromUtf32(251));
                        }

                        excelFile.SetCellValue(Constants.SheetIndex, dataValueRowIndex, Constants.DataValueColumnIndex + 1, Option.Text);
                        dataValueRowIndex += 1;
                        Index += 1;
                    }
                    break;
                case AnswerType.GridType:
                    int StartRowIndex=dataValueRowIndex;
                    int EndRowIndex;
                    int EndColIndex;
                    excelFile.LoadDataTableIntoSheet(dataValueRowIndex,Constants.DataValueColumnIndex, xmlQuestion.GridTable,Constants.SheetIndex, true);
                    dataValueRowIndex += xmlQuestion.GridTable.Rows.Count;
                    EndRowIndex=dataValueRowIndex-1;
                    EndColIndex =Constants.DataValueColumnIndex+  xmlQuestion.GridTable.Columns.Count-1;
                    excelFile.SetRangeBorder(Constants.SheetIndex, StartRowIndex, Constants.DataValueColumnIndex, EndRowIndex, EndColIndex,
                         SpreadsheetGear.LineStyle.Continous, SpreadsheetGear.BorderWeight.Thin, System.Drawing.Color.Black, SpreadsheetGear.BordersIndex.InsideHorizontal);
                    excelFile.SetRangeBorder(Constants.SheetIndex, StartRowIndex, Constants.DataValueColumnIndex, EndRowIndex, EndColIndex,
                         SpreadsheetGear.LineStyle.Continous, SpreadsheetGear.BorderWeight.Thin, System.Drawing.Color.Black, SpreadsheetGear.BordersIndex.InsideVertical);
                    excelFile.SetRangeBorder(Constants.SheetIndex, StartRowIndex, Constants.DataValueColumnIndex, EndRowIndex, EndColIndex,
                         SpreadsheetGear.LineStyle.Continous, SpreadsheetGear.BorderWeight.Thin, System.Drawing.Color.Black, SpreadsheetGear.BordersIndex.EdgeBottom);
                    excelFile.SetRangeBorder(Constants.SheetIndex, StartRowIndex, Constants.DataValueColumnIndex, EndRowIndex, EndColIndex,
                         SpreadsheetGear.LineStyle.Continous, SpreadsheetGear.BorderWeight.Thin, System.Drawing.Color.Black, SpreadsheetGear.BordersIndex.EdgeTop);
                    excelFile.SetRangeBorder(Constants.SheetIndex, StartRowIndex, Constants.DataValueColumnIndex, EndRowIndex, EndColIndex,
                                             SpreadsheetGear.LineStyle.Continous, SpreadsheetGear.BorderWeight.Thin, System.Drawing.Color.Black, SpreadsheetGear.BordersIndex.EdgeLeft);
                    excelFile.SetRangeBorder(Constants.SheetIndex, StartRowIndex, Constants.DataValueColumnIndex, EndRowIndex, EndColIndex,
                         SpreadsheetGear.LineStyle.Continous, SpreadsheetGear.BorderWeight.Thin, System.Drawing.Color.Black, SpreadsheetGear.BordersIndex.EdgeRight);

                    break;
                case AnswerType.Calculate:
                    break;
                case AnswerType.Aggregate:
                    break;

                default:
                    break;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Returns the Question based on key
        /// </summary>
        /// <param name="xmlDataSet"></param>
        /// <param name="key">TODO</param>
        /// <returns></returns>
        public static Question GetQuestion(DataSet xmlDataSet, string key)
        {
            Question RetVal = null;
            DataRow[] Rows;

            try
            {
                Rows = xmlDataSet.Tables[TableNames.QuestionTable].Select(QuestionTableColumns.QuestionKey + "='" + key + "'");
                if (Rows.Length > 0)
                {
                    RetVal = new Question(key, Rows[0], xmlDataSet);
                }
            }
            catch (Exception)
            {

                //throw;
                RetVal = null;
            }
            return RetVal;
        }
Esempio n. 6
0
        private void UpdateVisibilityForChildQuestions(Question currentQuestion)
        {
            string[] JumpNextArray;

            JumpNextArray = Questionnarie.SplitString(currentQuestion.JumpNext, Constants.Dependentquestion);
            foreach (string JumpNext in JumpNextArray)
            {
                if (JumpNext.StartsWith(currentQuestion.NumericValue + Constants.JumpQuestionSeprator))
                {
                    //Do Nothing
                }
                else
                {
                    //-- set visible property to false and clear data value
                    this.BeforeUpdatingJumpQuestions(JumpNext.Substring(JumpNext.IndexOf(Constants.JumpQuestionSeprator) + 1), false);
                }
            }

            foreach (string JumpNext in JumpNextArray)
            {
                if (JumpNext.StartsWith(currentQuestion.NumericValue + Constants.JumpQuestionSeprator))
                {
                    //-- if condition is true then set visible property to true
                    this.BeforeUpdatingJumpQuestions(JumpNext.Substring(JumpNext.IndexOf(Constants.JumpQuestionSeprator) + 1), true);
                    break;
                }
            }
        }
Esempio n. 7
0
        private void UpdateChildQuestionsForChkBox(Question currentQuestion)
        {
            string[] JumpNextArray = null;
            string[] StringIDArray = null;
            string[] DataValueArray = null;
            string[] VisibleQuestionArray = null;
            string SelectedStringID = string.Empty;
            string VisibleQuestions = string.Empty;
            string AllDependentQuestions = string.Empty;

            Dictionary<string, string> JumpNextList = new Dictionary<string, string>();

            try
            {
                JumpNextArray = Questionnarie.SplitString(currentQuestion.JumpNext, Constants.Dependentquestion);

                //create the list of jumpNextArray
                foreach (string JumpNext in JumpNextArray)
                {
                    JumpNextList.Add(JumpNext.Substring(0, JumpNext.IndexOf(Constants.JumpQuestionSeprator)), JumpNext.Substring(JumpNext.IndexOf(Constants.JumpQuestionSeprator) + 1));

                    if (!string.IsNullOrEmpty(AllDependentQuestions))
                    {
                        AllDependentQuestions += Constants.JumpNextQuestionSeparator;
                    }
                    AllDependentQuestions += JumpNext.Substring(JumpNext.IndexOf(Constants.JumpQuestionSeprator) + 1);
                }

                //create an array for string IDs
                StringIDArray = Questionnarie.SplitString(currentQuestion.StringIDs, Constants.StringIDSeparator);

                DataValueArray = Questionnarie.SplitString(currentQuestion.DataValue, Constants.StringIDSeparator);

                for (int Index = 0; Index < DataValueArray.Length; Index++)
                {
                    if (DataValueArray[Index] == "1")
                    {
                        //get string ID for the selected value
                        SelectedStringID = StringIDArray[Index].ToString();

                        //get dependent question for selected stringID
                        if (JumpNextList.ContainsKey(SelectedStringID))
                        {
                            if (!string.IsNullOrEmpty(VisibleQuestions))
                            {
                                VisibleQuestions += Constants.JumpNextQuestionSeparator;
                            }

                            VisibleQuestions += JumpNextList[SelectedStringID].ToString(); ;
                        }
                    }
                }

                //get visible questions array
                VisibleQuestionArray = Questionnarie.SplitString(VisibleQuestions, Constants.JumpNextQuestionSeparator);

                //-- set visible property to false and clear data value
                foreach (string DependentQuestion in Questionnarie.SplitString(AllDependentQuestions, Constants.JumpNextQuestionSeparator))
                {
                    if (Array.IndexOf(VisibleQuestionArray, DependentQuestion) == -1)
                    {
                        this.BeforeUpdatingJumpQuestions(DependentQuestion, false);
                    }
                }

                //-- set visible property to true
                foreach (string VisibleQuestion in VisibleQuestionArray)
                {
                    this.BeforeUpdatingJumpQuestions(VisibleQuestion, true);
                }

            }
            catch (Exception)
            {

            }
        }
Esempio n. 8
0
        /// <summary>
        /// assumption: 
        /// 1. before calling this function update currentQuestion object : like get datavalue form control N update question.
        /// </summary>
        /// <param name="currentQuestion"></param>
        public void updateChildQuestions(Question currentQuestion)
        {
            string JumpNextString = string.Empty;

            //getDataValueFromControls
            //-- if  jump condition is true then hide & clear value of all mapped questions

            JumpNextString = currentQuestion.JumpNext;
            if (JumpNextString.Length > 0)
            {
                if (currentQuestion.AnswerType == AnswerType.CH)
                {
                    this.UpdateChildQuestionsForChkBox(currentQuestion);
                }
                else
                {
                    this.UpdateVisibilityForChildQuestions(currentQuestion);
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Open the Questionnaire, check for valid Questionnaire, update its schema and update the paging or questions total
        /// </summary>
        /// <param name="xmlFileName"></param>
        /// <returns></returns>
        public bool OpenQuestionnaire(string xmlFileName)
        {
            DataRow[] Rows;
            bool RetVal = false;
            RetVal = this.LoadXML(xmlFileName);

            if (RetVal)
            {
                this._XmlFileName = xmlFileName;
                this._IsInterviewerQuestionExists = null;

                // clear mandatory questions
                this._InterviewerQuestion = null;
                this._SourceQuestion = null;
                this._AreaQuestion = null;
                this._TimeperiodQuestion = null;

                this.UpdateQuestionnaireSchema();
                this.CheckPagingNUpdateTotal();

                // -- set the font name
                Rows = this.QuestionnaireDataSet.Tables[TableNames.QuestionTable].Select(QuestionTableColumns.QuestionKey + "='" + QuestionTableColumns.Font + "'");
                if (Rows.Length > 0)
                {
                    this._FontName = Rows[0][QuestionTableColumns.QuestionText].ToString();
                }

                #region -- change no 3 --

                //-- set the font size
                Rows = this.QuestionnaireDataSet.Tables[TableNames.QuestionTable].Select(QuestionTableColumns.QuestionKey + "='" + MandatoryQuestionsKey.FONT_SIZE + "'");
                if (Rows.Length > 0)
                {
                    this._FontSize = Rows[0][QuestionTableColumns.QuestionText].ToString();
                }

                #endregion

                // set value of display gps questionnaire by checking visible and required properties of GPS question
                try
                {
                    Rows = this.QuestionnaireDataSet.Tables[TableNames.QuestionTable].Select(QuestionTableColumns.QuestionKey + "='" + MandatoryQuestionsKey.GPS + "'");

                    if (Rows.Length > 0)
                    {
                        if (Convert.ToBoolean(Rows[0][QuestionTableColumns.Visible]) & Convert.ToBoolean(Rows[0][QuestionTableColumns.Required]))
                        {
                            this.DisplayGPsQuestion = true;
                        }
                        else
                        {
                            this.DisplayGPsQuestion = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    // do nothing
                }

            }

            return RetVal;
        }
Esempio n. 10
0
        internal void GetUpdatedValues(DataSet xmlDataSet)
        {
            string[] AreaValue ;

            this.AreaQuestion=Questionnarie.GetQuestion(xmlDataSet, MandatoryQuestionsKey.Area);

            if (!string.IsNullOrEmpty(AreaQuestion.DataValue))
            {
                AreaValue = Questionnarie.SplitString(AreaQuestion.DataValue.ToString(), Constants.AreaValueSeparator);
                if (AreaValue.Length == 3)
                {
                    this._AreaName = AreaValue[0];
                    this._AreaID = AreaValue[1];
                    this._AreaGId = AreaValue[2];
                }
                else
                {
                    this._AreaName = string.Empty;
                    this._AreaID = string.Empty;
                    this._AreaGId = string.Empty;
                }
            }
        }