예제 #1
0
        WebReply GenericException(SystemObject sys, string Body, string Title)
        {
            Dialog   d  = new Dialog(sys);
            WebReply wr = d.CreateDialog("ErrDialog1", Title, Body, 200, 200);

            return(wr);
        }
예제 #2
0
        public WebReply DocumentView()
        {
            Section  sT  = Sys.RenderSection("Document View", "Documents", 1, this, SystemObject.SectionMode.View);
            WebReply wTV = sT.Render(this, true);

            return(wTV);
        }
예제 #3
0
        public WebReply TicketList_AddNew()
        {
            Section  TicketAdd = Sys.RenderSection("Ticket View", "Ticket", 1, this, SystemObject.SectionMode.Add);
            GodEdit  geBtnB    = TicketAdd.AddButton("btnSave", "Save");
            WebReply ta        = TicketAdd.Render(this, true);

            return(ta);
        }
예제 #4
0
        // Ticket History area:
        public WebReply TicketHistory()
        {
            //Id,TicketId,Body,Added,updated,deleted
            SQLDetective s  = Sys.GetSectionSQL("Ticket History", "TicketHistory", this.ViewGuid);
            Weblist      w  = new Weblist(Sys);
            WebReply     wr = w.GetWebList(s.GenerateQuery(), "Ticket History", "tickethistory", "Body", "TicketHistory", this, false);

            return(wr);
        }
예제 #5
0
        public WebReply TicketView()
        {
            Section sT = Sys.RenderSection("Ticket View", "Ticket", 1, this, SystemObject.SectionMode.View);
            //Add Ticket View + Ticket History to web reply
            WebReply wTV = sT.Render(this, true);
            WebReply wTH = TicketHistory();

            wTV.AddWebPackages(wTH.Packages);
            return(wTV);
        }
예제 #6
0
        public WebReply PictureView()
        {
            Section sT   = Sys.RenderSection("Picture View", "Picture", 1, this, SystemObject.SectionMode.View);
            string  sURL = Sys.GetPictureURL(this.ViewGuid);

            sT.DisplayPictureHTML = "<a id=PV name=PV data-featherlight='" + sURL + "'><img src='" + sURL + "' /></a>";
            WebReply wTV = sT.Render(this, true);

            return(wTV);
        }
예제 #7
0
        public WebReply Phase3()
        {
            Section s = new Section("Phase3", 3, Sys, this);

            if (Sys.GetObjectValue("Phase3", "ConditionCount") == "")
            {
                Sys.SetObjectValue("Phase3", "ConditionCount", "1");
            }

            int iConditionCount = Convert.ToInt32(Sys.GetObjectValue("Phase3", "ConditionCount"));

            for (int x = 0; x < iConditionCount; x++)
            {
                GodEdit ddFields = new GodEdit("Phase3", "Fields" + x.ToString(), Sys);
                ddFields.Type         = GodEdit.GEType.Lookup;
                ddFields.CaptionText  = "Field:";
                ddFields.LookupValues = ddFields.ConvertStringToLookupList("Address;City;State;Zip;Phone");
                s.AddControl(ddFields);
                string sValueOfFieldsControl = Sys.GetObjectValue("Phase3", "Fields" + x.ToString());

                GodEdit ddConditions = new GodEdit("Phase3", "Conditions" + x.ToString(), Sys);
                ddConditions.Type        = GodEdit.GEType.Lookup;
                ddConditions.CaptionText = "Conditions:";


                ddConditions.LookupValues = new List <SystemObject.LookupValue>();


                SystemObject.LookupValue i1 = new SystemObject.LookupValue();
                i1.ID      = "Underlying ID";
                i1.Value   = "DisplayValue";
                i1.Caption = "Caption";
                string sValueOfLookup = Sys.GetObjectValue("Phase3", "Conditions" + x.ToString());
                ddConditions.LookupValues.Add(i1);

                SystemObject.LookupValue i2 = new SystemObject.LookupValue();
                i2.ID      = "Underlying ID2";
                i2.Value   = "DisplayValueTwo";
                i2.Caption = "CaptionTwo";
                ddConditions.LookupValues.Add(i2);
                s.AddControl(ddConditions);
                GodEdit txtValue = new GodEdit("Phase3", "SelectedValue" + x.ToString(), Sys);
                txtValue.Type        = GodEdit.GEType.Text;
                txtValue.CaptionText = "Selected Value:";
                string sValueOfSelected = Sys.GetObjectValue("Phase3", "SelectedValue" + x.ToString());
                s.AddControl(txtValue);
            }
            s.AddButton("btnAddCondition", "Add Condition");
            WebReply wr1 = s.Render(this, true);

            return(wr1);
        }
예제 #8
0
        public WebReply btnLightbox_Click()
        {
            Section s = new Section("Lightbox", 1, Sys, this);
            GodEdit g = new GodEdit("Lightbox", GodEdit.GEType.Lightbox, Sys);

            g.Name        = "Lightbox";
            g.CaptionText = "Open";
            g.URL         = "images/Data.png";
            s.AddControl(g);
            WebReply wr1 = s.Render(this, true);

            return(wr1);
        }
예제 #9
0
        public WebReply CreateDialogWebList(string sID, string Title, string Body, int Width, int Height)
        {
            string sHTML = "<div id='" + sID + "' title='" + Title + "'>"
                           + "<p><span class='ui-icon ui-icon-circle-check' style='float:none !IMPORTANT; margin:0 7px 50px 0;'></span>"
                           + Body + " </p></div>";
            string sWH = String.Empty;

            if (Width > 0 || Height > 0)
            {
                sWH = "width: " + Width.ToString() + ", height: " + Height.ToString() + ",";
            }
            string   sOpt        = "var opt = {        autoOpen: false,   position: { my: 'top', at: 'top+150' },     modal: true, " + sWH + "title: '" + sID + "' };";
            string   sJavascript = sOpt + " var theDialog = $('#" + sID + "').dialog(opt); theDialog.dialog('open');";
            WebReply wr          = new WebReply(sHTML, sJavascript, sID, true);

            return(wr);
        }
예제 #10
0
        public WebReply PictureList()
        {
            SQLDetective s = Sys.GetSectionSQL("Picture List", "Picture", string.Empty);

            if (WhereClause.Length > 0)
            {
                s.WhereClause = WhereClause;
            }
            else
            {
                s.WhereClause = "Picture.Organization='" + Sys.Organization.ToString() + "' and Picture.Deleted=0  and Picture.ParentID = '" + this.ParentID.ToString() + "'";
            }
            string   sql = s.GenerateQuery();
            Weblist  w   = new Weblist(Sys);
            WebReply wr  = w.GetWebList(sql, "Picture List", "Picture List", "", "Picture", this, false);

            return(wr);
        }
예제 #11
0
        public WebReply DocumentList()
        {
            SQLDetective s = Sys.GetSectionSQL("Document List", "Documents", string.Empty);

            // If they are coming in from the search page
            if (WhereClause.Length > 0)
            {
                s.WhereClause = WhereClause;
            }
            else
            {
                s.WhereClause = "Documents.Organization='" + Sys.Organization.ToString() + "' and Documents.deleted=0  and Documents.ParentID = '" + this.ParentID.ToString() + "'";
            }
            string   sql = s.GenerateQuery();
            Weblist  w   = new Weblist(Sys);
            WebReply wr  = w.GetWebList(sql, "Document List", "Document List", "", "Documents", this, false);

            return(wr);
        }
예제 #12
0
        public WebReply btnLogin_Click()
        {
            Sys.SetObjectValue("Login", "Caption1", "Enter Username and Password and click Login.");
            // Authenticate User
            bool bAuth = VerifyUser(Sys.GetObjectValue("Login", "Username"), Sys.GetObjectValue("Login", "Password"), ref Sys, false);


            Sys.SetObjectValue("Login", "Caption1", String.Empty);
            if (bAuth)
            {
                //Log in to First System Page
                WebReply        wr   = Sys.Redirect("Home", this);
                WebReplyPackage wrp1 = wr.Packages[0];
                wrp1.Javascript = "location.reload();";
                return(wr);
            }
            // Present Log in Screen
            return(LoginSection());
        }
예제 #13
0
        public WebReply CreateYesNoDialog(string sSectionName, string sDialogID, string sYesID, string sNoID, string Title, string Body, object Caller)
        {
            GodEdit btnYes = new GodEdit(sSectionName, GodEdit.GEType.Button, sYesID, "Yes", Sys);

            btnYes.IsInDialog = true;
            btnYes.DialogName = sDialogID;
            string  sBtnYes = btnYes.Render(Caller).Packages[0].HTML;
            GodEdit btnNo   = new GodEdit(sSectionName, GodEdit.GEType.Button, sNoID, "No", Sys);

            btnNo.IsInDialog = true;
            btnNo.DialogName = sDialogID;
            string sBtnNo   = btnNo.Render(Caller).Packages[0].HTML;
            string sButtons = "<table><tr><td>" + sBtnYes + "</td><td>" + sBtnNo + "</td></tr></table>";
            string sHidden  = "<input type='hidden' id='hdialog' name='hdialog' value='hdialog'>";
            string sHTML    = "<div id='" + sDialogID + "' title='" + Title + "'>"
                              + "<p><span class='ui-icon ui-icon-circle-check' style='float:left; margin:0 7px 50px 0;'></span>"
                              + Body + " </p><p>" + sButtons + "</p>" + sHidden + "<p></div>";
            string   sOpt        = "var opt = {        autoOpen: false,        modal: true,        width: 550,        height:350,        title: '" + sDialogID + "' };";
            string   sJavascript = sOpt + " var theDialog = $('#" + sDialogID + "').dialog(opt); theDialog.dialog('open');";
            WebReply wr          = new WebReply(sHTML, sJavascript, sSectionName, true);

            return(wr);
        }
예제 #14
0
        public WebReply btnResetPassword_Click()
        {
            string sUsername = Sys.GetObjectValue("Login", "Username");
            // Verify the user exists
            string sql    = "Select id,email from Users where username='******'";
            string id     = Sys._data.GetScalarString(sql, "id");
            string sEmail = Sys._data.GetScalarString(sql, "email");
            string sNarr  = "";

            if (id.Length == 0)
            {
                sNarr = "Unable to retrieve a user with that username";
            }
            else if (!Sys.IsValidEmailFormat(sEmail))
            {
                sNarr = "Email address on file for this user is not valid.  Please send an e-mail to [email protected].";
            }
            else
            {
                sNarr = "Password reset instructions have been sent to the e-mail address on file.  Please click the link in your e-mail and follow the instructions in order to reset your password.";
                // Send the email here
                string sLink = HttpContext.Current.Request.Url.ToString();
                sLink  = sLink.Substring(0, sLink.Length - 10);
                sLink += "/Action.aspx?action=password_recovery&id=" + id.ToString();

                string sBody = "Dear " + sUsername.ToUpper() + ",<br><br>Please follow these instructions to reset your Pool Password:<br><br>Click the link below, and after browser authentication, the pool will reset your password to a new password.  <br><br>Copy the new password from the screen, then log in, and then optionally change your password.<br><br><a href='" + sLink + "'>Recover Password</a><br><br>Thank you for using BiblePay.<br><br>Best Regards,<br>BiblePay Support";

                bool sent = Sys.SendEmail(sEmail, "BiblePay Pool Password Recovery", sBody, true);

                string sErr = "";
            }

            Dialog   d  = new Dialog(Sys);
            WebReply wr = d.CreateDialog("PASSWORD_RECOVERY", "PASSWORD_RECOVERY", sNarr, 425, 200);

            return(wr);
        }
예제 #15
0
        public WebReply TicketList()
        {
            //Produces a web list of Tickets assigned to the current user
            SQLDetective s = Sys.GetSectionSQL("Ticket List", "Ticket", string.Empty);

            // If they are coming in from the search page
            if (WhereClause.Length > 0)
            {
                s.WhereClause = WhereClause;
            }
            else
            {
                if (ParentID == "")
                {
                    ParentID = Sys.Organization.ToString();
                }
                s.WhereClause = "AssignedTo='" + Sys.UserGuid.ToString() + "' and Ticket.deleted=0  and Ticket.ParentID = '" + this.ParentID.ToString() + "'";
            }
            string   sql = s.GenerateQuery();
            Weblist  w   = new Weblist(Sys);
            WebReply wr  = w.GetWebList(sql, "My Tickets", "Ticket List", "", "Ticket", this, false);

            return(wr);
        }
예제 #16
0
        public WebReply GetWebList(string sql, string sTitle, string sSectionName, string CommentsRow, string SourceTable, object caller, bool bRemoveDiv)
        {
            string     myClass    = caller.GetType().ToString();
            StackTrace stackTrace = new StackTrace();

            StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
            StackFrame   callingFrame = stackFrames[1];
            MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
            string       sMyMethod    = method.Name;

            // CONTEXT MENU
            AddContextMenuitem(".", "", ".");

            string htmlCMI = "";

            foreach (ContextMenuItem cm1 in listContextMenuItems)
            {
                string sRow = "";
                sRow     = "   \"" + cm1.Name + "\": {name: \"" + cm1.Caption + "\", icon: \"" + cm1.Caption + "\"},";
                htmlCMI += sRow;
            }

            string sContextMenuCssClass = "context-menu-" + CleanName(sSectionName);

            if (htmlCMI.Length > 0)
            {
                htmlCMI = htmlCMI.Substring(0, htmlCMI.Length - 1);
            }
            string sContextEvent = " onclick=\"var sUSGDID = $(this)[0].getAttribute('usgdid');postdiv(this,'contextmenu','" + myClass + "','" + sMyMethod + "_ContextMenu_'+key,USGDID);\"";

            sContextEvent = " var sUSGDID = $(this)[0].getAttribute('usgdid');postdiv(this,'contextmenu','" + myClass + "','" + sMyMethod + "_ContextMenu_'+key,sUSGDID);";


            string sContextMenu = "  $(function() {   $.contextMenu({     selector: '." + sContextMenuCssClass + "',        callback: function(key, options) { " +
                                  "       " + sContextEvent + "            },"
                                  + "       items: {  " + htmlCMI + "                     }                    });"
                                  + "       $('." + sContextMenuCssClass + "').on('click', function(e){      console.log('clicked', this);        })        });";

            bool   Expanded       = !(sys.GetObjectValue(sSectionName, "ExpandableSection" + myClass + sMyMethod) == "EXPANDED" ? true : false);
            string sExpandedClass = Expanded ? "icon-minus" : "icon-plus";

            sExpandedClass = Expanded ? "icon-chevron-up" : "icon-chevron-down";

            string sAddNewButton = "<span onclick=postdiv(this,'addnew','" + myClass + "','" + sMyMethod + "_AddNew',''); style='float:right;' class='"
                                   + "icon-plus" + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";

            string sExpandButton = "<span onclick=postdiv(this,'expand','" + myClass + "','" + sMyMethod + "',''); style='float:right;' class='"
                                   + sExpandedClass + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";

            string sButtons = sExpandButton + sAddNewButton; //These buttons end up going in reverse order.
            string html     = "";

            if (!bRemoveDiv)
            {
                html += "<div id='" + sSectionName + "' name='" + sSectionName + "'>";
            }

            html += "<table frame=box cellspacing=4 cellpadding=4 width=100% class=TFtable style='xmin-eight:1vh'>"
                    + "<tr><th colspan=10 cellpadding=0 cellspacing=0 class='ui-dialog-titlebar ui-corner-all ui-widget-header'>"
                    + "<span class='ui-dialog-title'>" + sTitle + "</span>" + sButtons + "</th></tr>";
            // Custom Context Sensitive menu and event, and Dispatch Function

            if (Expanded)
            {
                USGDTable dt = null;
                try
                {
                    dt = sys.GetUSGDTable(sql, SourceTable);
                }
                catch (Exception ex)
                {
                    string sErr = html + "<tr><td>" + ex.Message + "</td></tr></table></div>";

                    WebReply wr5 = new WebReply();
                    wr5.AddWebReply(sErr, "", "Error Dialog", false);
                    return(wr5);
                }
                // Column Names
                string sHeader = "<TR>";
                for (int c = 0; c < dt.Cols; c++)
                {
                    string sCN  = dt.ColumnNames[c];
                    string sKey = SourceTable.ToUpper() + "," + sCN.ToUpper();

                    string sCaption = sys.GetFieldCaption(SourceTable, sCN);

                    bool   bCommentsColumn = false;
                    string sColspan        = string.Empty;

                    if (sCaption.ToUpper() == CommentsRow.ToUpper())
                    {
                        bCommentsColumn = true;
                    }
                    if (bCommentsColumn)
                    {
                        sHeader += "</TR><TR>";
                        sColspan = "colspan='" + dt.Cols.ToString() + "'";
                    }
                    // Mask column if its a primary key guid
                    bool bMasked = false;
                    if (sCaption.ToUpper() == "ID" || sCaption.ToUpper() == "CLOAK" || sCaption.ToUpper() == "BATCHID")
                    {
                        bMasked = true;
                    }
                    if (!bMasked)
                    {
                        // Icon OrderBy
                        string sOrderByClass = sys.GetObjectValue(sSectionName, "OrderByClass" + sCN) == "down" ? "icon-chevron-up" : "icon-chevron-down";
                        string sButtons2     = "<span onclick=postdiv(this,'OrderByClick','" + myClass + "','" + sMyMethod + "_OrderByClick','" + sCN + "'); style='float:right;' class='"
                                               + sOrderByClass + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
                        sHeader += "<th align=left " + sColspan + "class='ui-dialog-titlebar' style='border-bottom: grey thin solid'>" + sCaption + sButtons2 + "</th>";
                    }
                }
                sHeader += "</TR>";
                html    += sHeader;
                // RENDER VALUES
                for (int y = 0; y < dt.Rows; y++)
                {
                    string sID         = dt.GuidValue(y, "Id").ToString();
                    string sOnRowClick = "postdiv(this,'rowclick','" + myClass + "','" + sMyMethod + "_RowClick','" + sID + "');";
                    // This is where we render each weblist ROW of data
                    bool bRowHighlighted = false;
                    bool bRowCloaked     = false;
                    //Prescan row to see if highlighted
                    for (int xCol = 0; xCol < dt.Cols; xCol++)
                    {
                        string sCaption = dt.ColumnNames[xCol];
                        string sValue   = dt.Value(y, xCol).ToString();
                        if (sCaption.ToUpper() == "USERNAME" && sValue == sys.Username)
                        {
                            bRowHighlighted = true;
                        }
                    }
                    if (bSupportCloaking)
                    {
                        string sValue = dt.Value(y, "Cloak").ToString();
                        if (sValue == "1")
                        {
                            bRowCloaked = true;
                        }
                    }
                    string sSpecialCSS = bRowHighlighted && bShowRowHighlightedByUserName ? "Activated" : "";
                    // Add the context sensitive right click menu here:
                    string sRow = "<TR usgdid='" + sID + "'  class='" + sContextMenuCssClass + " " + sSpecialCSS
                                  + "'   onclick=\"$(this).addClass('Activated').siblings().removeClass('Activated');" + sOnRowClick + "\">";

                    for (int x = 0; x < dt.Cols; x++)
                    {
                        string sValue          = dt.Value(y, x).ToString();
                        string sCaption        = dt.ColumnNames[x];
                        string sColspan        = string.Empty;
                        bool   bCommentsColumn = false;
                        if (sCaption.ToUpper() == "USERNAME" || sCaption.ToUpper() == "MINERNAME")
                        {
                            if (bRowCloaked)
                            {
                                sValue = "Anonymous";
                            }
                        }
                        if (sCaption.ToUpper() == "STATS")
                        {
                            if (bRowCloaked)
                            {
                                sValue = "Anonymous";
                            }
                        }
                        if (sCaption.ToUpper() == CommentsRow.ToUpper())
                        {
                            bCommentsColumn = true;
                            sColspan        = "colspan='" + dt.Cols.ToString() + "'";
                        }
                        if (bCommentsColumn)
                        {
                            sRow += "</TR><TR class='" + sContextMenuCssClass + "'>";
                        }
                        // Mask column if its a guid
                        bool bMasked = false;
                        if (sCaption.ToUpper() == "ID" || sCaption.ToUpper() == "TICKETID" || sCaption.ToUpper() == "TICKET GUID" || sCaption.ToUpper() == "BATCHID" || sCaption.ToUpper() == "CLOAK")
                        {
                            bMasked = true;
                        }
                        if (!bMasked)
                        {
                            if (sCaption.ToUpper() == "URL")
                            {
                                string sGuid = dt.Value((int)y, "id").ToString();
                                string s1    = "<div id='div" + sGuid
                                               + "' name='div" + sGuid + "'><a id='img"
                                               + sCaption
                                               + "' name='img" + sGuid
                                               + "' data-featherlight='" + sValue + "'>" + URLDefaultValue + "</a></div>";
                                string j1 = "$('#img" + sGuid + "').featherlightGallery();";
                                sContextMenu += j1;
                                sValue        = s1;
                            }

                            if (sCaption.ToUpper() == "NEEDWRITTEN")
                            {
                                string sVal = sValue.ToString() == "1" ? "TRUE" : "FALSE";
                                sValue = sVal;
                            }
                            sRow += "<TD class='ui-dialog-title' style='float:none' " + sColspan + ">" + sValue;
                            // Add buttons to view the row
                            if (x == dt.Cols - 1)
                            {
                                //Button for Viewing the row
                                string sButtons2 = "<span align=right onclick=postdiv(this,'handview','" + myClass + "','" + sMyMethod + "','" + sID + "'); style='float:right;' class='"
                                                   + "icon-hand-up" + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
                                if (bShowRowSelect)
                                {
                                    sRow += sButtons2;
                                }
                                // Button for Deleting the Row (Trash Icon)
                                string sButtons3 = "<span align=right onclick=postdiv(this,'handview','" + myClass + "','" + sMyMethod
                                                   + "_Delete_Click','" + sID + "'); style='float:right;' class='"
                                                   + "icon-trash" + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
                                if (bShowRowTrash)
                                {
                                    sRow += sButtons3;
                                }
                            }
                            sRow += "</TD>";
                        }
                    }

                    sRow += "</TR>";
                    html += sRow;
                }
            }

            html += "</TABLE><p>";
            if (!bRemoveDiv)
            {
                html += "</div>";
            }
            string javascript = sContextMenu;

            WebReply wr = new WebReply(html, javascript, sSectionName, false);

            return(wr);
        }
예제 #17
0
        public WebReply Render(object caller, bool ClearScreen)
        {
            string     myClass    = caller.GetType().ToString();
            StackTrace stackTrace = new StackTrace();

            StackFrame[] stackFrames  = stackTrace.GetFrames();
            StackFrame   callingFrame = stackFrames[1];
            MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
            string       sMyMethod    = method.Name;
            // Button for Expand-Collapse
            string sExpandedClass = Expanded ? "icon-minus" : "icon-plus";

            sExpandedClass = Expanded ? "icon-chevron-up" : "icon-chevron-down";
            string sExpandButton = GetHeaderButton("expand", myClass, sMyMethod, sExpandedClass);
            string sEditButton   = "";

            if (SecMode == SystemObject.SectionMode.View)
            {
                sEditButton = GetHeaderButton("edit", myClass, sMyMethod + "_EditClick", "icon-pencil");
            }

            string sButtons = sExpandButton + sEditButton;
            // Button for Edit
            string divname      = this.Name;
            string sNarrative   = "";
            string sBorderStyle = "";
            string sFrameStyle  = "";

            if (SecMode == SystemObject.SectionMode.View)
            {
                sNarrative = "View";
            }
            else if (SecMode == SystemObject.SectionMode.Add)
            {
                sNarrative = "Add";
            }
            else if (SecMode == SystemObject.SectionMode.Edit)
            {
                sNarrative = "Edit";
            }
            else if (SecMode == SystemObject.SectionMode.Customize)
            {
                sNarrative = "Customize";
            }
            string FriendlyName = this.Name;

            if (!this.MaskSectionMode)
            {
                FriendlyName += " <font size=1>[" + sNarrative + "]</font>";
            }


            string sDivClass = "class='dragContent'";

            if (SecMode == SystemObject.SectionMode.Customize)
            {
                sBorderStyle = "style='border-top: solid 1px; border-bottom:solid 1px; border-left: solid 1px; border-right:solid 1px;'";
            }
            else
            {
                sFrameStyle = "frame=box";
            }


            // CONTEXT MENU
            AddContextMenuitem("Customize", "Customize", "Customize");


            string htmlCMI = "";

            foreach (Weblist.ContextMenuItem cm1 in listContextMenuItems)
            {
                string sRow = "";
                sRow     = "   \"" + cm1.Name + "\": {name: \"" + cm1.Caption + "\", icon: \"" + cm1.Caption + "\"},";
                htmlCMI += sRow;
            }

            string sContextMenuCssClass = "context-menu-" + CleanName(divname);



            string sOut = "<div id='" + divname + "' " + sDivClass + " name='" + divname + "'><table " + sBorderStyle + " class='" + sContextMenuCssClass + "' " + sFrameStyle + " cellspacing=5 cellpadding=5 width=100%>"
                          + "<tr><th colspan=10 cellpadding=0 cellspacing=0 style='border-bottom: grey thin solid' class='ui-dialog-titlebar ui-corner-all ui-widget-header'>"
                          + "<span class='ui-dialog-title'>" + FriendlyName + "</span>" + sButtons + "</th></tr>";

            string javascript = "";

            if (htmlCMI.Length > 0)
            {
                htmlCMI = htmlCMI.Substring(0, htmlCMI.Length - 1);
            }
            string sContextEvent = " onclick=postdiv(this,'contextmenu','" + myClass + "','" + sMyMethod + "_ContextMenu_'+key,'');";
            string sContextMenu  = "  $(function() {   $.contextMenu({     selector: '." + sContextMenuCssClass + "',        callback: function(key, options) { " +
                                   "       " + sContextEvent + "            },"
                                   + "       items: {  " + htmlCMI + "                     }                    });"
                                   + "       $('." + sContextMenuCssClass + "').on('click', function(e){      console.log('clicked', this);        })        });";



            javascript += sContextMenu;

            int iCurCol       = 0;
            int iCurCellCount = 0;
            int iCurRowCount  = 0;

            if (Expanded)
            {
                foreach (KeyValuePair <string, object> entry in _controls)
                {
                    GodEdit ge = (GodEdit)entry.Value;
                    if (iCurCol == 0)
                    {
                        sOut += "<TR>";
                    }

                    WebReply wr          = ge.Render(caller);
                    string   sDivWrapper = "divWrapper" + Guid.NewGuid().ToString();

                    if (SecMode == SystemObject.SectionMode.Customize)
                    {
                        string sObject = ge.CaptionText + ": " + ge.TextBoxValue;
                        string susgdid = Guid.NewGuid().ToString();
                        string sCoords = "coords" + iCurCol.ToString() + "-" + iCurRowCount.ToString();
                        sOut += "<td " + sBorderStyle + "><span usgdid='z" + susgdid + "' usgdname='" + sCoords + "' usgdcaption='" + sCoords + "'></span><div class='drag1'>"
                                + "<span usgdcaption='" + ge.CaptionText + "' usgdname='" + ge.Name + "' usgdid='" + susgdid
                                + "' usgdvalue='" + ge.TextBoxValue + "' >" + sObject + "&nbsp;</span></div></td>";
                    }
                    else
                    {
                        sOut += "<td>" + wr.Packages[0].HTML + "</td>";
                    }
                    javascript += wr.Packages[0].Javascript;
                    iCurCol++;
                    iCurCellCount++;
                    if (iCurCol == ColumnCount)
                    {
                        if (iCurRowCount == 0)
                        {
                            if (DisplayPictureHTML != null)
                            {
                                sOut += "<td rowspan=5>" + DisplayPictureHTML + "</TD>";
                            }
                        }

                        iCurRowCount++;
                        sOut   += "</TR>";
                        iCurCol = 0;
                    }
                }
            }

            sOut += "</TR>";
            sOut += "</table></div><p>";
            WebReply wr1 = new WebReply();

            string sIdentifier         = "USGDrag";
            string sEvent              = "alert('test');";
            string sJavaEventAfterDrop = "  var sOut=''; $(this).closest('table').find('span').each(function (index) "
                                         + "        {        var sUSGDID = $(this)[0].getAttribute('usgdid'); "
                                         + "                 var sUSGDValue = $(this)[0].getAttribute('usgdvalue'); "
                                         + "                 var sUSGDCaption = $(this)[0].getAttribute('usgdcaption'); "
                                         + "                 var sUSGDName = $(this)[0].getAttribute('usgdname'); "
                                         + "        var s = $(this)[0].name + '[COL]' + $(this)[0].value + '[COL]' + sUSGDID + '[COL]' + sUSGDValue + '[COL]' + sUSGDCaption + '[COL]' + sUSGDName + '[ROW]';"
                                         + "      if (sUSGDID != null) {  if (sUSGDID.length > 0)   sOut += s;  }  }); ";

            string sDropEvent = sJavaEventAfterDrop + "postdiv(this,'dropevent','" + myClass + "','" + sMyMethod + "','[DROPPABLE]"
                                + divname + "[/DROPPABLE][DATA]' + sOut + '[/DATA]');";


            string DraggableJavascript = "     $('.drag1').draggable({  "
                                         + "    helper: 'clone',        start: function(event, ui)"
                                         + "    {            c.tr = this;                c.helper = ui.helper;            }    });"
                                         + "   $('.drag1').droppable({     drop: function(event, ui) {     "
                                         + "  "
                                         + "   $(c.helper).remove();        }     });";

            DraggableJavascript = " var myDraggedObject = null; $(function() { $( '.drag1' ).draggable({containment:parent});  }); ";
            DraggableJavascript = "var myDraggedObject = null; var myOriginalHTML = null; $('.drag1').draggable(  "
                                  + "{ revert: function(droppableContainer) {         if(droppableContainer) { var thisisvalid='valid';    }       else {        myDraggedObject.innerHTML=myOriginalHTML;     } } ,"
                                  + "      helper: 'clone', "
                                  + "      containment: '.dragContent', cursor:'move', snap: true, snapMode: 'inner',"
                                  + "     start: function(event, ui)   {  myDraggedObject = this; this.setAttribute('usgdname','test'); "
                                  + "       myOriginalHTML = myDraggedObject.innerHTML; myDraggedObject.setAttribute('usgdname','bye3');  "
                                  + "       myDraggedObject.innerHTML ='&nbsp;';      }   });  "
                                  + "                $('.drag1').droppable(  {drop: function(event, ui) { ui.helper[0].innerHTML='bye'; myDraggedObject.innerHTML = myOriginalHTML; ui.draggable.detach().appendTo($(this));   " + sDropEvent + "  }     }); ";

            if (SecMode == SystemObject.SectionMode.Customize)
            {
                javascript += DraggableJavascript;
            }
            wr1.AddWebReply(sOut, javascript, Name, false);
            WebReplyPackage wrp1 = wr1.Packages[0];

            wrp1.ClearScreen = ClearScreen;
            wr1.Packages[0]  = wrp1;
            return(wr1);
        }
예제 #18
0
        public WebReply Render(object caller)
        {
            string sFlyout = (ErrorText ?? String.Empty).ToString().Length > 0 ? "example-right" : String.Empty;

            if (Type == GEType.Text || Type == GEType.Date || Type == GEType.Password)
            {
                string sSize     = size > 0 ? "size='" + size.ToString() + "'" : String.Empty;
                string sReadOnly = ReadOnly ? "READONLY" : string.Empty;
                string sClass    = ReadOnly ? "reado" : string.Empty;

                string sOut = "<td " + ColSpan + " " + Width + "><span>" + CaptionText + "</span></td><td " + ColSpan2 + "><input class='" + sClass + "' type='" + Type + "' " + sReadOnly + " name='"
                              + Name + "' " + sSize + " id='" + Name + "' " + TextBoxAttribute + " style='" + TextBoxStyle + "' value='" + TextBoxValue + "' />&nbsp;<label class='"
                              + sFlyout + "' for='" + Name + "'>" + ErrorText + "</label></td>";
                WebReply wr1 = new WebReply();
                wr1.AddWebReply(sOut, "", Section, false);
                return(wr1);
            }
            else if (Type == GEType.Image)
            {
                string sOut = "<td colspan=2 align=center><img name='"
                              + Name + "' id='" + Name + "' src='" + URL + "' />&nbsp;</td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.DIV)
            {
                string sOut = "<div name='"
                              + Name + "' id='" + Name + "'>";
                WebReply wr1 = new WebReply();
                wr1.AddWebReply(sOut, "", Section, false);
                return(wr1);
            }
            else if (Type == GEType.Lightbox)
            {
                string sData = "<div id='div" + Name + "' name='div" + Name + "'><a id='img" + Name + "' name='img" + Name + "' data-featherlight='" + URL + "'>" + CaptionText + "</a></div>";
                Javascript = "$('#img" + Name + "').featherlightGallery();";
                WebReply wr1 = new WebReply();
                wr1.AddWebReply(sData, Javascript, Section, false);
                return(wr1);
            }
            else if (Type == GEType.HTML)
            {
                string sOut = "<div name='"
                              + Name + "' id='" + Name + "'>" + HTML + "</div>";
                WebReply wr1 = new WebReply();
                wr1.AddWebReply(sOut, Javascript, Section, false);
                return(wr1);
            }
            else if (Type == GEType.Label)
            {
                string sOut = "<td><span id='" + Name + "'>" + CaptionText + "</span></td>";
                if (("" + TextBoxValue).Length > 0)
                {
                    sOut += "<td>" + TextBoxValue + "</td>";
                }
                return(new WebReply(sOut, "", Section, false));
            }

            else if (Type == GEType.TreeView)
            {
                string sJS = "      $('.acidjs-css3-treeview').delegate('label input:checkbox [title=flower]', 'change', function()"
                             + "\r\n {    "
                             + " var checkbox = $(this),     nestedList = checkbox.parent().next().next(),"
                             + "\r\n       selectNestedListCheckbox = nestedList.find('label:not([for]) input:checkbox [title=flower]'); "
                             + "  \r\n     if(checkbox.is(':checked')) {"
                             + "\r\n return selectNestedListCheckbox.prop('checked', true);    }"
                             + "  \r\n     selectNestedListCheckbox.prop('checked', false);  \r\n });";

                sJS = "";

                string sHTML = "<div class=\"acidjs-css3-treeview\">";

                // iterate through the nodes
                XmlNode eleOuter = Nodes.DocumentElement;
                XmlNode oNode    = eleOuter.SelectNodes("NODES")[0].SelectNodes("Organization")[0];
                if (oNode != null)
                {
                    sHTML += "<ul>";
                }
                traversenodes(oNode);
                sHTML += sCumulativeHTML + "</div>";
                return(new WebReply(sHTML, sJS, Section, false));
            }
            else if (Type == GEType.TreeViewDummy)
            {
                string sJS = "      $('.acidjs-css3-treeview').delegate('label input:checkbox', 'change', function()"
                             + "\r\n {    "
                             + " var checkbox = $(this),     nestedList = checkbox.parent().next().next(),"
                             + "\r\n       selectNestedListCheckbox = nestedList.find('label:not([for]) input:checkbox'); "
                             + "  \r\n     if(checkbox.is(':checked')) {"
                             + "\r\n return selectNestedListCheckbox.prop('checked', true);    }"
                             + "  \r\n     selectNestedListCheckbox.prop('checked', false);  \r\n });";


                string sHTML    = "<div class=\"acidjs-css3-treeview\"><ul>";
                int    iCounter = 0;
                // iterate through the nodes
                XmlNode eleOuter = Nodes.DocumentElement;
                XmlNode oNodes   = eleOuter.SelectNodes("xolddummy")[0];

                for (int y = 0; y < oNodes.ChildNodes.Count; y++)
                {
                    XmlNode oNode    = oNodes.ChildNodes[y];
                    string  sCaption = oNode["CAPTION"].InnerText;
                    string  sName    = oNode["NAME"].InnerText;
                    iCounter++;
                    string sRow = "<li><input type='checkbox' id='node-" + iCounter.ToString()
                                  + "' checked='' /><label><input type='checkbox' /><span></span></label><label for='node-" + iCounter.ToString() + "'>" + sCaption + "</label>";
                    sHTML += sRow;

                    for (int iSubNodeCounter = 0; iSubNodeCounter < 10; iSubNodeCounter++)
                    {
                        // If Any child nodes, process here
                        XmlNode oSubNodes = oNode.SelectNodes("SUBNODES")[0];
                        sHTML += "<ul>";
                        for (int j = 0; j < oSubNodes.ChildNodes.Count; j++)
                        {
                            XmlNode oNode2    = oSubNodes.ChildNodes[j];
                            string  sCaption2 = oNode2["CAPTION"].InnerText;
                            string  sName2    = oNode2["NAME"].InnerText;
                            iCounter++;
                            string sRow2 = "<li><input type='checkbox' id='node-" + iCounter.ToString()
                                           + "' checked='' /><label><input type='checkbox' /><span></span></label><label for='node-" + iCounter.ToString() + "'>" + sCaption2 + "</label>";
                            sHTML += sRow2;
                        }
                        sHTML += "</li>";
                        sHTML += "</ul>";
                    }
                    sHTML += "</li>";
                }

                sHTML += "</ul>";
                sHTML += "</div>";

                return(new WebReply(sHTML, sJS, Section, false));
            }
            else if (Type == GEType.SortableList)
            {
                string Name2 = Name + "2";
                string ul1   = "<ul id='" + Name + "'>";
                foreach (SystemObject.LookupValue lv in LookupValues)
                {
                    //Select the Selected TextBoxValue
                    string key = lv.ID;
                    key = lv.Value;
                    string sRow = "<li class='sortable' usgdname='" + lv.Name + "' usgdcaption='" + lv.Caption + "' usgdid='" + lv.ID + "' usgdvalue='" + lv.Value + "' id='" + key + "' value='" + lv.Value + "'>" + lv.Caption + "</li>";
                    ul1 += sRow;
                }

                ul1 += "</ul>";

                string ul2 = "<ul id='" + Name2 + "'>";
                foreach (SystemObject.LookupValue lv in LookupValuesSelected)
                {
                    //Select the Selected TextBoxValue
                    string key = lv.ID;
                    key = lv.Value;
                    string sRow = "<li class='sortable' usgdname='" + lv.Name + "' usgdcaption='" + lv.Caption + "' usgdid='" + lv.ID + "' usgdvalue='" + lv.Value + "' id='" + key + "' value='" + lv.Value + "'>" + lv.Caption + "</li>";
                    ul2 += sRow;
                }

                ul2 += "</ul>";

                string html = "<td><div><table><tr><td>" + CaptionText + "</td><td>" + CaptionText2 + "</td></tr><tr><td width='"
                              + Width.ToString() + "'>" + ul1 + "</td><td width='" + Width.ToString() + "'>"
                              + ul2 + "</td></tr></table></div></td>";


                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();            // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames();      // get method calls (frames)
                StackFrame   callingFrame = stackFrames[2];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = Name + "_Sort";

                string sJava2 = "  var sOut=''; $('#" + Name + "').closest('ul').find('li').each(function (index) "
                                + "        {         var sUSGDID = $(this)[0].getAttribute('usgdid'); "
                                + "                  var sUSGDValue = $(this)[0].getAttribute('usgdvalue'); "
                                + "                 var sUSGDCaption = $(this)[0].getAttribute('usgdcaption'); "
                                + "                 var sUSGDName = $(this)[0].getAttribute('usgdname'); "
                                + "        var s = $(this)[0].name + '[COL]' + $(this)[0].value + '[COL]' + sUSGDID + '[COL]' + sUSGDValue + '[COL]' + sUSGDCaption + '[COL]' + sUSGDName + '[ROW]';"
                                + "        sOut += s;    }); ";


                string sJava3 = "  var sOut2=''; $('#" + Name2 + "').closest('ul').find('li').each(function (index) "
                                + "        {         var sUSGDID = $(this)[0].getAttribute('usgdid'); "
                                + "                  var sUSGDValue = $(this)[0].getAttribute('usgdvalue'); "
                                + "                  var sUSGDCaption = $(this)[0].getAttribute('usgdcaption'); "
                                + "                  var sUSGDName = $(this)[0].getAttribute('usgdname'); "
                                + "        var s = $(this)[0].name + '[COL]' + $(this)[0].value + '[COL]' + sUSGDID + '[COL]' + sUSGDValue + '[COL]' + sUSGDCaption + '[COL]' + sUSGDName + '[ROW]';"
                                + "        sOut2 += s;    }); ";


                string serialize   = " " + sJava2 + sJava3 + " var order = $('#" + Name + "').sortable('toArray');  var order2=$('#" + Name2 + "').sortable('toArray'); var data = order.join(';'); var data2=order2.join(';'); ";
                string sUniqueId   = Section + "[ROWSET]" + Name + "[ROWSET]";
                string sEvent      = serialize + "postdiv(this,'sortevent','" + myClass + "','" + sMyMethod + "','[SORTABLE]" + sUniqueId + "' + sOut + '[ROWSET]'+sOut2);";
                string sIdentifier = "#" + Name + ",#" + Name2;

                string javascript = "   $('" + sIdentifier + "').sortable({     "
                                    + " stop: function(event, ui){      " + sEvent + "        },"
                                    + "connectWith: '" + sIdentifier + "'         });  $('" + sIdentifier + "').disableSelection();";


                return(new WebReply(html, javascript, Section, false));
            }
            else if (Type == GEType.UploadControl)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;

                string sEvent = "postdiv(this,'buttonevent','" + myClass + "','" + sMyMethod + "','');";
                //sEvent = "";

                string html = "<td colspan=2><form enctype='multipart/form-data' method='POST' action='Uploader.ashx'>"
                              + "<p id='DivUploadControl'></p>"
                              + "<input type='hidden' name='MAX_FILE_SIZE' value='3000000' />"
                              + "<label class='fileContainer roundbutton'>" + CaptionText
                              + "<input class='inputfile' type='file' "
                              + "id='myFile' name='myFile' multiple size=50 onchange=\"USGDFileUploader(this.form,'Uploader.ashx?parentid=" + ParentGuid + "&id=" + Id.ToString()
                              + "&parenttype=" + ParentType + "','divupload','" + myClass + "','" + sMyMethod + "','" + Section + "');" + "\" >"
                              + "</label>"
                              + "&nbsp;&nbsp;"
                              + "<div id=divupload></div>  </form></td>";
                return(new WebReply(html, "", Section, false));
            }
            else if (Type == GEType.TextArea)
            {
                string sReadOnly = ReadOnly ? "READONLY" : string.Empty;
                string sClass    = ReadOnly ? "reado" : string.Empty;
                string sColspan  = "";
                if (("" + ColSpan).Length > 0)
                {
                    sColspan = "colspan='" + ColSpan + "'";
                }
                string td1 = "";
                if (!MaskColumn1)
                {
                    td1 = "<td><span>" + CaptionText + "</span></td>";
                }
                string sOut = td1 + "<td " + TdWidth + " " + sColspan + "><textarea " + sReadOnly + " class='" + sClass + "' type='" + Type + "' name='"
                              + Name + "' rows='" + rows.ToString() + "' cols='" + cols.ToString() + "' id='"
                              + Name + "' style='width:" + Width + ";height:" + Height + ";' value='" + TextBoxValue + "'>" + TextBoxValue + "</textarea>&nbsp;<label class='"
                              + sFlyout + "' for='" + Name + "'>" + ErrorText + "</label></td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.Caption)
            {
                string sOut = "<td colspan=2><span id='" + Name + "'>" + TextBoxValue + "</span></td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.Button)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sOut = "";

                if (!MaskBeginTD)
                {
                    sOut += "<td colspan='" + ColSpan + "'>";
                }

                sOut += "<input class=roundbutton type=button name='" + Name + "' id='" + Name + "' value='"
                        + CaptionText + "' onclick=\"" + sJavascriptSuffix + "postdiv(this,'buttonevent','" + myClass + "','" + sMyMethod + "','');\"  />";
                if (!MaskEndTD)
                {
                    sOut += "</td>";
                }

                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.DoubleButton)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();
                StackFrame[] stackFrames  = stackTrace.GetFrames();
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sOut = "";
                if (!MaskBeginTD)
                {
                    sOut += "<td colspan='" + ColSpan + "'>";
                }
                Method = "" + Name + "_Click";

                sOut += "<input class=roundbutton type=button name='" + Name + "' id='" + Name + "' value='"
                        + CaptionText + "' onclick=\"" + sJavascriptSuffix + "postdiv(this,'buttonevent','" + myClass + "','" + Method + "','');\"  />";
                // Button2:
                Method = "" + Name2 + "_Click";

                sOut += "&nbsp;&nbsp;&nbsp;&nbsp;<input class=roundbutton type=button name='" + Name2 + "' id='" + Name2 + "' value='"
                        + CaptionText2 + "' onclick=\"" + sJavascriptSuffix + "postdiv(this,'buttonevent','" + myClass + "','" + Method + "','');\"  />";
                if (!MaskEndTD)
                {
                    sOut += "</td>";
                }



                return(new WebReply(sOut, "", Section, false));
            }

            else if (Type == GEType.IFrame)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sCSS = "background-color:grey";
                string sOut = "<td><iframe style='" + sCSS + "' src='" + URL + "' name='" + Name + "' id='" + Name + "' width='" + Width + "' height='" + Height + "'> </iframe></td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.CheckBox)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sCHECKED          = TextBoxValue == "true" ? "CHECKED" : "";
                string sOut = "<td>" + CaptionText + "</td><td><input class=roundbutton type=checkbox " + sCHECKED + " value='" + TextBoxValue + "' name='" + Name + "' id='" + Name + "' value='"
                              + CaptionText + "' /></td>";
                return(new WebReply(sOut, "", Section, false));
            }

            else if (Type == GEType.Anchor)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sOut = "<td colspan=1><a name='" + Name + "' id='" + Name + "' value='"
                              + "' href=# onclick=\"" + sJavascriptSuffix + "postdiv(this,'buttonevent','" + myClass + "','" + this.Name + "_Click','');return true;\" >" + CaptionText + "</a></td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.TableRow)
            {
                string sOut = "<tr>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.Lookup)
            {
                string sReadOnly = ReadOnly ? "DISABLED" : string.Empty;
                string sClass    = ReadOnly ? "reado" : string.Empty;
                // Event
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();                // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames();          // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                string       sEvent       = " onchange=postdiv(this,'lookupclick','" + myClass + "','" + Name + "_Selected',this.options[this.selectedIndex].value);";


                string sRows = "<td><span>" + CaptionText + "</span></td><td>" + "<select " + sReadOnly + " class='" + sClass + "' " + sEvent + " name='" + Name + "' id='" + Name + "'>";
                if (LookupValues != null)
                {
                    // Ensure we have a blank entry for empty or null values
                    string sBlankSelected = "";
                    if (TextBoxValue.Trim() == "")
                    {
                        sBlankSelected = "SELECTED";
                    }
                    sRows += "<option " + sBlankSelected + " classid='" + "000" + "' value='" + "" + "'>" + "" + "</option>";



                    foreach (SystemObject.LookupValue lv in LookupValues)
                    {
                        //Select the Selected TextBoxValue
                        string sSelected = String.Empty;
                        if (lv.Value == TextBoxValue)
                        {
                            sSelected = "SELECTED";
                        }
                        sRows += "<option " + sSelected + " USGDID='" + lv.ID + "' USGDVALUE='" + lv.Value + "' value='" + lv.Value + "'>" + lv.Caption + "</option>";
                    }
                }
                sRows += "</select></td>";
                return(new WebReply(sRows, "", Section, false));
            }
            else
            {
                string sErr = "";
            }
            return(new WebReply("", "", Section, false));
        }
예제 #19
0
        public override void HandleRequest(System.Web.HttpContext context)
        {
            // Deserialize the strongly typed javascript object back to c# object
            WebObj g = new WebObj();

            g = JsonConvert.DeserializeObject <WebObj>(sPostData);
            SystemObject Sys = (SystemObject)HttpContext.Current.Session["Sys"];

            if (g.action == "postdiv" || g.action == "formload")
            {
                // Now we store the uploaded values on the business objects
                string[] vRows = g.body.Split(new string[] { "[ROW]" }, StringSplitOptions.None);
                for (int i = 0; i < vRows.Length - 1; i++)
                {
                    string[] vCols      = vRows[i].Split(new string[] { "[COL]" }, StringSplitOptions.None);
                    string   sName      = vCols[0];
                    string   sValue     = vCols[1];
                    string   sUSGDID    = vCols[2];
                    string   sUSGDVALUE = vCols[3];
                    WebObj   fnew       = new WebObj();
                    fnew.value  = sValue;
                    fnew.name   = sName;
                    fnew.usgdid = sUSGDID;
                    //Verify divname == sectioname
                    Sys.UpdateObject(g.divname, ref fnew);
                }
                // and we reply with a replacement div for this section only
                if (g.eventname == "sortevent" || g.eventname == "dropevent")
                {
                    string sPost = g.guid;
                    if (g.eventname == "dropevent")
                    {
                        // Get the guid of the section
                        string    sSection      = Sys.ExtractXML(sPost, "[DROPPABLE]", "[/DROPPABLE]");
                        string    sLastCoord    = "";
                        string    sCurrCoord    = "";
                        string    sql           = "Select * FROM SECTION WHERE Name='" + sSection + "' and deleted=0";
                        DataTable dt2           = Sys._data.GetDataTable(sql);
                        string    sSectionGuid  = dt2.Rows[0]["id"].ToString();
                        string    sCurrFields   = dt2.Rows[0]["Fields"].ToString();
                        string    sData         = Sys.ExtractXML(sPost, "[DATA]", "[/DATA]");
                        string[]  vRows2        = sData.Split(new string[] { "[ROW]" }, StringSplitOptions.None);
                        string    sCols         = "";
                        int       iCoordCounter = 0;

                        for (int i = 0; i < vRows2.Length - 1; i++)
                        {
                            string   sRow  = vRows2[i];
                            string[] vCols = sRow.Split(new string[] { "[COL]" }, StringSplitOptions.None);

                            string sName    = vCols[4];
                            string sCaption = vCols[3];
                            bool   bIsCoord = false;

                            if (sName.Contains("coords"))
                            {
                                bIsCoord   = true;
                                sCurrCoord = sName;
                                if (sCurrCoord != sLastCoord)
                                {
                                    sLastCoord = sName;
                                }
                                iCoordCounter++;
                            }

                            if (sName.Length > 0 && !bIsCoord)
                            {
                                sCols        += sName + ",";
                                iCoordCounter = 0;
                            }

                            if (iCoordCounter > 1)
                            {
                                sCols += ",";
                            }
                        }
                        string[] vF            = sCurrFields.Split(new string[] { "," }, StringSplitOptions.None);
                        string[] vTargetFields = sCols.Split(new string[] { "," }, StringSplitOptions.None);
                        bool     bFail         = false;
                        for (int iSource = 0; iSource < vF.Length; iSource++)
                        {
                            if (vF[iSource].Length > 0)
                            {
                                bool bFound = false;
                                for (int iTarget = 0; iTarget < vTargetFields.Length; iTarget++)
                                {
                                    if (vTargetFields[iTarget].Length > 0)
                                    {
                                        if (vTargetFields[iTarget].ToLower() == vF[iSource].ToLower())
                                        {
                                            bFound = true;
                                            break;
                                        }
                                    }
                                }
                                if (!bFound)
                                {
                                    bFail = true;
                                }
                            }
                        }

                        if (!bFail)
                        {
                            sCols = sCols.Substring(0, sCols.Length - 1);
                            string sSql = "Update Section set Fields='" + sCols + "' where id = '" + sSectionGuid + "'";
                            Sys._data.Exec(sSql);
                        }
                    }
                    else if (sPost.Contains("[SORTABLE]"))
                    {
                        sPost = sPost.Replace("[SORTABLE]", "");

                        string[] vRows2   = sPost.Split(new string[] { "[ROWSET]" }, StringSplitOptions.None);
                        string   sSection = vRows2[0];
                        string   sName    = vRows2[1];
                        string   sLeft    = vRows2[2];
                        string   sRight   = vRows2[3];
                        // Reconstitute the Lists

                        string[] vLookups      = sLeft.Split(new string[] { "[ROW]" }, StringSplitOptions.None);
                        string[] vLookupsRight = sRight.Split(new string[] { "[ROW]" }, StringSplitOptions.None);

                        List <SystemObject.LookupValue> lLVLeft  = new List <SystemObject.LookupValue>();
                        List <SystemObject.LookupValue> lLVRight = new List <SystemObject.LookupValue>();
                        lLVLeft  = SortableListToLookupValueList(vLookups);
                        lLVRight = SortableListToLookupValueList(vLookupsRight);

                        WebObj oLeft = new WebObj();
                        oLeft.name         = sName;
                        oLeft.divname      = sSection;
                        oLeft.LookupValues = lLVLeft;

                        WebObj oRight = new WebObj();
                        oRight.name         = sName + "_2";
                        oRight.divname      = sSection;
                        oRight.LookupValues = lLVRight;

                        Sys.UpdateObject(sSection, ref oLeft);
                        Sys.UpdateObject(sSection, ref oRight);
                    }
                }

                if (g.eventname == "buttonevent" || true)
                {
                    //Raise the event in the class, then return with some data.
                    Sys.LastWebObject = g;
                    var type1 = Type.GetType(g.classname);
                    if (type1 == null)
                    {
                        // Give the user the Nice Dialog showing that the object is null
                        WebReply wr1 = GenericException(Sys, "Web Class Not Found: " + g.classname, "Web Class Not Found");
                        g.divname    = "divErrors";
                        g.body       = wr1.Packages[0].HTML;
                        g.javascript = wr1.Packages[0].Javascript;
                        string myJason = JsonConvert.SerializeObject(g);
                        context.Response.Write(myJason);
                        return;
                    }
                    if (Sys.Organization.ToString() == "00000000-0000-0000-0000-000000000000")
                    {
                        //Session has expired
                        //throw new Exception("Session has expired."); (Deprecated)
                    }
                    if (g.eventname == "expand")
                    {
                        bool Expanded = !(Sys.GetObjectValue(g.divname, "ExpandableSection" + g.classname + g.methodname) == "UNEXPANDED" ? false : true);
                        Sys.SetObjectValue(g.divname, "ExpandableSection" + g.classname + g.methodname, Expanded ? "EXPANDED" : "UNEXPANDED");
                    }
                    else if (g.eventname.ToLower() == "orderbyclick")
                    {
                        //Toggle the Order by
                        string sOrderByClass = Sys.GetObjectValue(g.divname, "OrderByClass" + Sys.LastWebObject.guid);
                        string desc          = "";
                        if (sOrderByClass == "up")
                        {
                            sOrderByClass = "down";
                        }
                        else
                        {
                            sOrderByClass = "up";
                            desc          = " desc";
                        }
                        Sys.SetObjectValue(g.divname, "OrderByClass" + Sys.LastWebObject.guid, sOrderByClass);
                        g.orderby = Sys.LastWebObject.guid + " " + desc;
                    }
                    try
                    {
                        if (Sys.Organization.ToString() == "00000000-0000-0000-0000-000000000000")
                        {
                            // User is not logged in ( If the user has a valid session, use it first ):
                            string sTheUser = clsStaticHelper.GetCookie("username");
                            string sThePass = clsStaticHelper.GetCookie("password");
                            if (sTheUser != "" && sThePass != "")
                            {
                                Login l            = new Login(Sys);
                                bool  bMyDepersist = l.VerifyUser(sTheUser, sThePass, ref Sys, false);
                                if (bMyDepersist)
                                {
                                    //g.classname = "BiblePayPool2018.Home";
                                    //g.methodname = "Announce";
                                    //goto redirect2;
                                }
                            }
                        }
                    }
                    catch (Exception ex5)
                    {
                    }
                    try
                    {
                        //Store the event information in Sys, so the receiver can access it (before invoking):
                        if (Sys.Organization.ToString() == "00000000-0000-0000-0000-000000000000" && g.classname != "BiblePayPool2018.Login")
                        {
                            if (System.Diagnostics.Debugger.IsAttached && false)
                            {
                                // instantiate the user based on the debug user guid.
                                Login l = new Login(Sys);
                            }
                            if (HttpContext.Current.Request.Url.ToString().ToUpper().Contains("ACCOUNTABILITY"))
                            {
                                Login l     = new Login(Sys);
                                bool  bAuth = l.VerifyUser("guest", "guest", ref Sys, false);
                                // Start at the expense View Page when coming in from the Wallet accountability button
                                g.classname  = "BiblePayPool2018.Home";
                                g.methodname = "ExpenseList";
                            }

                            g.classname  = "BiblePayPool2018.Login";
                            g.methodname = "LoginSection";
                        }

                        if (Sys.Username == "" && g.classname != "BiblePayPool2018.Login")
                        {
                            // Redirect to Login Page
                            g.classname  = "BiblePayPool2018.Login";
                            g.methodname = "LoginSection";
                        }

                        type1 = Type.GetType(g.classname);
                        object     myObject1   = Activator.CreateInstance(type1, Sys);
                        MethodInfo methodInfo1 = type1.GetMethod(g.methodname);
                        WebRequest wRequest    = new WebRequest();
                        wRequest.eventName = g.eventname;
                        wRequest.action    = g.action;
                        object[]      parametersArray = new object[] { wRequest };
                        WebReply      wr           = (WebReply)methodInfo1.Invoke(myObject1, null);
                        List <WebObj> woReplies    = new List <WebObj>();
                        bool          bClearScreen = false;
                        if (g.eventname.ToLower() == "formevent")
                        {
                            bClearScreen = true;
                        }
                        int iInstanceCount = 0;
                        int iPackageCount  = wr.Packages.Count;
                        foreach (WebReplyPackage wrp in wr.Packages)
                        {
                            WebObj woInstance = new WebObj();
                            woInstance.ClearScreen = wrp.ClearScreen;
                            woInstance.SingleTable = wrp.SingleUITable;
                            iInstanceCount++;
                            if (iInstanceCount == 1 && bClearScreen)
                            {
                                woInstance.ClearScreen = true;
                            }
                            woInstance.body       = wrp.HTML;
                            woInstance.javascript = wrp.Javascript;
                            woInstance.doappend   = wrp.doappend;
                            // If we are clearing the screen, add a breadcrumb
                            if (woInstance.ClearScreen)
                            {
                                Sys.AddBreadcrumb(wrp.SectionName, g.classname, g.methodname, true);
                                Sys.SetObjectValue("", "ApplicationMessage", wrp.SectionName);
                            }
                            woInstance.breadcrumb         = Sys.GetBreadcrumbTrailHTML();
                            woInstance.breadcrumbdiv      = "divbreadcrumb";
                            woInstance.ApplicationMessage = Sys.GetObjectValue("", "ApplicationMessage");
                            woInstance.divname            = wrp.SectionName;
                            woInstance.action             = "refresh";
                            woReplies.Add(woInstance);
                        }
                        string myJason1 = JsonConvert.SerializeObject(woReplies);
                        context.Response.Write(myJason1);
                    }
                    catch (Exception ex)
                    {
                        WebReply wr1 = GenericException(Sys, "Web Class Not Found: " + g.classname, "Web Class Not Found");
                        g.divname    = "divErrors";
                        g.body       = wr1.Packages[0].HTML;
                        g.javascript = wr1.Packages[0].Javascript;
                        string myJason = JsonConvert.SerializeObject(g);
                        context.Response.Write(myJason);
                    }
                }
            }
        }