Ejemplo n.º 1
0
        public List <Dictionary <string, string> > GetAndDeleteRecords(string tableName, string[] targetColumns, List <string> filters)
        {
            string sqlquery   = "DELETE dbo." + tableName + " OUTPUT DELETED.* ";
            string conditions = "";

            if (filters != null && filters.Count > 0)
            {
                conditions = " Where ";
                for (int i = 0; i < filters.Count; i++)
                {
                    if (i > 0)
                    {
                        conditions += " AND ";
                    }

                    conditions += filters[i];
                }
            }

            sqlquery += conditions;

            SQLServerAccessor dbAccessor = new SQLServerAccessor();

            List <Dictionary <string, string> > output = dbAccessor.TableSearch(targetColumns, sqlquery);

            return(output);
        }
Ejemplo n.º 2
0
        private List <ExamItem> GenerateProcessItems(string sqlquery)
        {
            SQLServerAccessor dbAccessor = new SQLServerAccessor();

            List <Dictionary <string, string> > output = dbAccessor.TableSearch(targetColumns, sqlquery);

            List <ExamItem> list  = new List <ExamItem>();
            int             index = 0;

            foreach (Dictionary <string, string> rec in output)
            {
                ExamItem item = new ExamItem();
                item.index          = index++;
                item.question       = rec["Question"];
                item.answerRegex    = rec["AnswerRegex"];
                item.answer         = rec["Answer"];
                item.answerType     = rec["AnswerType"];
                item.interpret      = rec["Interpret"];
                item.askbackMessage = rec["AskbackMessage"];
                if (!string.IsNullOrWhiteSpace(rec["Score"]))
                {
                    item.score = int.Parse(rec["Score"]);
                }
                list.Add(item);
            }

            return(list);
        }
Ejemplo n.º 3
0
        public List <TestItem> GenerateTestItems(int count, string courseInTest)
        {
            string tableName = "calculator3";

            string sqlquery = "select top " + count.ToString() + " * from dbo." + tableName + " Where CourseName = N'" + courseInTest + "' order by newid()";

            string[] targetColumns = { "Formula", "Result", "ResultMatchRule" };

            SQLServerAccessor dbAccessor = new SQLServerAccessor();

            List <Dictionary <string, string> > output = dbAccessor.TableSearch(targetColumns, sqlquery);

            List <TestItem> list  = new List <TestItem>();
            int             index = 0;

            foreach (Dictionary <string, string> rec in output)
            {
                TestItem item = new TestItem();
                item.index           = index++;
                item.question        = rec["Formula"];
                item.correctResult   = rec["Result"];
                item.answerMatchRule = rec["ResultMatchRule"];

                list.Add(item);
            }

            return(list);
        }
Ejemplo n.º 4
0
        private Dictionary <int, IRItem> GenerateProcessItems(string sqlquery)
        {
            SQLServerAccessor dbAccessor = new SQLServerAccessor();

            List <Dictionary <string, string> > output = dbAccessor.TableSearch(targetColumns, sqlquery);

            Dictionary <int, IRItem> dict = new Dictionary <int, IRItem>();
            int index = 0;

            foreach (Dictionary <string, string> rec in output)
            {
                IRItem item = new IRItem();
                item.index       = index++;
                item.stepNo      = int.Parse(rec["StepNo"]);
                item.content     = rec["Content"];
                item.options     = rec["Options"];
                item.optionRegex = rec["OptionRegex"];
                item.nextStep    = rec["NextStep"];

                item.askbackMessage = rec["AskbackMessage"];

                dict.Add(item.stepNo, item);
            }

            return(dict);
        }
Ejemplo n.º 5
0
        public List <TestItem> GenerateTestItems(int count)
        {
            string tableName = "scorescripts";

            string sqlquery = "select top " + count.ToString() + " * from dbo." + tableName + " order by newid()";

            string[] targetColumns = { "script" };

            SQLServerAccessor dbAccessor = new SQLServerAccessor();

            List <Dictionary <string, string> > output = dbAccessor.TableSearch(targetColumns, sqlquery);

            List <TestItem> list = new List <TestItem>();

            foreach (Dictionary <string, string> rec in output)
            {
                TestItem item = new TestItem();
                item.question = rec["script"];
                list.Add(item);
            }

            return(list);
        }