Exemplo n.º 1
0
        public string wmGetClips()
        {
            dataAccess dc = new dataAccess();
            FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();
            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sUserID = ui.GetSessionUserID();
                string sErr = "";

                //note: some literal values are selected here.  That's because DrawReadOnlyStep
                //requires a more detailed record, but the snip doesn't have some of those values
                //so we hardcode them.
                string sSQL = "select s.clip_dt, s.step_id, s.step_desc, s.function_name, s.function_xml," +
                    " f.function_label, f.category_name, c.category_label, f.icon," +
                    " s.output_parse_type, s.output_row_delimiter, s.output_column_delimiter, s.variable_xml," +
                    " -1 as step_order, 0 as commented " +
                    " from task_step_clipboard s" +
                    " join lu_task_step_function f on s.function_name = f.function_name" +
                    " join lu_task_step_function_category c on f.category_name = c.category_name" +
                    " where s.user_id = '" + sUserID + "'" +
                    " and s.codeblock_name is null" +
                    " order by s.clip_dt desc";

                DataTable dt = new DataTable();
                if (!dc.sqlGetDataTable(ref dt, sSQL, ref sErr))
                {
                    throw new Exception(sErr);
                }

                string sHTML = "";

                foreach (DataRow dr in dt.Rows)
                {
                    string sStepID = dr["step_id"].ToString();
                    string sLabel = dr["function_label"].ToString();
                    string sIcon = dr["icon"].ToString();
                    string sClipDT = dr["clip_dt"].ToString();
                    string sDesc = ui.GetSnip(dr["step_desc"].ToString(), 75);

                    sHTML += "<li" +
                        " id=\"clip_" + sStepID + "\"" +
                        " name=\"clip_" + sStepID + "\"" +
                        " class=\"command_item function clip\"" +
                        ">";

                    //a table for the label so the clear icon can right align
                    sHTML += "<table width=\"99%\" border=\"0\"><tr>";
                    sHTML += "<td width=\"1px\"><img alt=\"\" src=\"../images/" + sIcon + "\" /></td>";
                    sHTML += "<td style=\"vertical-align: middle; padding-left: 5px;\">" + sLabel + "</td>";
                    sHTML += "<td width=\"1px\" style=\"vertical-align: middle;\">";

                    //view icon
                    //due to the complexity of telling the core routines to look in the clipboard table, it
                    //it not possible to easily show the complex command types
                    // without a redesign of how this works.  NSC 4-19-2011
                    //due to several reasons, most notable being that the XML node for each of those commands
                    //that contains the step_id is hardcoded and the node names differ.
                    //and GetSingleStep requires a step_id which must be mined from the XML.
                    //so.... don't show a preview icon for them
                    string sFunction = dr["function_name"].ToString();
                    if (!"loop,exists,if,while".Contains(sFunction))
                    {
                        sHTML += "<span id=\"btn_view_clip\" view_id=\"v_" + sStepID + "\">" +
                            "<img src=\"../images/icons/search.png\" style=\"width: 16px; height: 16px;\" alt=\"\" />" +
                            "</span>";
                    }
                    sHTML += "</td></tr>";

                    sHTML += "<tr><td>&nbsp;</td><td><span class=\"code\">" + sClipDT + "</span></td>";
                    sHTML += "<td>";
                    //delete icon
                    sHTML += "<span id=\"btn_clear_clip\" remove_id=\"" + sStepID + "\">" +
                        "<img src=\"../images/icons/fileclose.png\" style=\"width: 16px; height: 16px;\" alt=\"\" />" +
                        "</span>";
                    sHTML += "</td></tr></table>";

                    sHTML += "<div class=\"hidden\" id=\"help_text_clip_" + sStepID + "\">" + sDesc + "</div>";

                    //we use this function because it draws a smaller version than DrawReadOnlyStep
                    string sStepHTML = "";
                    //and don't draw those complex ones either
                    if (!"loop,exists,if,while".Contains(sFunction))
                        sStepHTML = ft.DrawEmbeddedReadOnlyStep(dr, true);

                    sHTML += "<div class=\"hidden\" id=\"v_" + sStepID + "\">" + sStepHTML + "</div>";
                    sHTML += "</li>";

                }

                return sHTML;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }