Example #1
0
        public void TriggerTableConstructorTest()
        {
            TriggerTable target = new TriggerTable(new Trigger("Change_Submit", 1, TriggerType.ChangeSubmit, "//depot/main/...", "p4 submit"), null);
            Trigger      Entry1 = new Trigger("Add_a_fix", 1, TriggerType.FixAdd, "//depot/main/fixes/...", "p4 fix");
            Trigger      Entry2 = new Trigger("Form_In", 1, TriggerType.FormIn, "//depot/main/...", "p4 spec");

            target.Add(Entry1);
            target.Add(Entry2);
            Assert.AreEqual(Entry1, target[0]);
            Assert.AreEqual(Entry2, target[1]);
        }
Example #2
0
        public static string GetQuestPartCategoriesForID(int id)
        {
            Set <String> categoriesSet = new Set <String>();

            // look for trigger categories
            DataRow[] triggerRows = TriggerTable.Select(COL_QUESTPARTTRIGGER_QUESTPARTID + "=" + id);
            foreach (DataRow triggerRow in triggerRows)
            {
                DataRow triggerTypeRow = GetTriggerTypeRowForID((int)triggerRow[COL_QUESTPARTTRIGGER_TYPE]);
                if (!String.IsNullOrEmpty((string)triggerTypeRow[COL_TRIGGERTYPE_CATEGORY]))
                {
                    string   categoryString = (string)triggerTypeRow[COL_TRIGGERTYPE_CATEGORY];
                    string[] categories     = categoryString.Split(';');

                    foreach (string category in categories)
                    {
                        CategoryComparator comparer = new CategoryComparator(category);
                        if (comparer.Compare(triggerRow))
                        {
                            categoriesSet.Add(comparer.Name);
                        }
                    }
                }
            }

            // look for requirement categories
            DataRow[] requRows = RequirementTable.Select(COL_QUESTPARTREQUIREMENT_QUESTPARTID + "=" + id);
            foreach (DataRow requRow in requRows)
            {
                DataRow requTypeRow = GetRequirementTypeRowForID((int)requRow[COL_QUESTPARTREQUIREMENT_TYPE]);
                if (!String.IsNullOrEmpty((string)requTypeRow[COL_REQUIREMENTTYPE_CATEGORY]))
                {
                    string   categoryString = (string)requTypeRow[COL_REQUIREMENTTYPE_CATEGORY];
                    string[] categories     = categoryString.Split(';');

                    foreach (string category in categories)
                    {
                        CategoryComparator comparer = new CategoryComparator(category);
                        if (comparer.Compare(requRow))
                        {
                            categoriesSet.Add(comparer.Name);
                        }
                    }
                }
            }

            // look for action categories
            DataRow[] actionRows = ActionTable.Select(COL_QUESTPARTACTION_QUESTPARTID + "=" + id);
            foreach (DataRow actionRow in actionRows)
            {
                DataRow actionTypeRow = GetActionTypeRowForID((int)actionRow[COL_QUESTPARTACTION_TYPE]);
                if (!String.IsNullOrEmpty((string)actionTypeRow[COL_ACTIONTYPE_CATEGORY]))
                {
                    string   categoryString = (string)actionTypeRow[COL_ACTIONTYPE_CATEGORY];
                    string[] categories     = categoryString.Split(';');

                    foreach (string category in categories)
                    {
                        CategoryComparator comparer = new CategoryComparator(category);
                        if (comparer.Compare(actionRow))
                        {
                            categoriesSet.Add(comparer.Name);
                        }
                    }
                }
            }


            StringBuilder categoryStringBuilder = new StringBuilder();

            for (int i = 0; i < categoriesSet.Count; i++)
            {
                categoryStringBuilder.Append(categoriesSet[i]);
                categoryStringBuilder.Append(";");
            }

            return(categoryStringBuilder.ToString());
        }
Example #3
0
        public void disp_data()
        {
            //Creates a command for the SQL query
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;

            string query = " SELECT processing_date AS 'Processing Date' ," +
                           " CONCAT('$', amount) AS Amount ," +
                           " CONCAT('$', balance) AS Balance ," +
                           " Action ," +
                           " Description ," +
                           " State FROM CustomerData" +
                           " WHERE STATE IN ( SELECT Description" +
                           "                    FROM TRIGGERS ) " +
                           " UNION " +
                           " SELECT processing_date AS 'Processing Date' ," +
                           " CONCAT('$', amount) AS Amount ," +
                           " CONCAT('$', balance) AS Balance ," +
                           " Action ," +
                           " Description ," +
                           " State FROM CustomerData" +
                           " WHERE Description IN ( SELECT Description" +
                           "                       FROM TRIGGERS);";

            cmd.CommandText = query;



            /*
             * SELECT processing_date AS 'Processing Date',
             *  CONCAT('$', amount) AS Amount,
             *  CONCAT('$', balance) AS Balance,
             *  Action,
             *  Description,
             *  State
             * FROM CustomerData
             * WHERE STATE IN (
             * SELECT Description
             * FROM TRIGGERS)
             * UNION
             * SELECT processing_date AS 'Processing Date',
             *  CONCAT('$', amount) AS Amount,
             *  CONCAT('$', balance) AS Balance,
             *  Action,
             *  Description,
             *  State FROM CustomerData
             * WHERE Description IN (
             * SELECT Description FROM TRIGGERS);
             *
             */

            //Executes the SQL query
            cmd.ExecuteNonQuery();

            //Data Table Read from sql server
            DataTable dt = new DataTable();

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            //Fills the SQL Data by the Data Table
            da.Fill(dt);

            //Gets the Data from the data table and places it into the HTML
            TriggerTable.DataSource = dt;
            TriggerTable.DataBind();
        }