Ejemplo n.º 1
0
 public GodEdit(string sSection, string ControlName, SystemObject sys)
 {
     Name         = ControlName;
     Type         = GEType.Text;
     Sys          = sys;
     Section      = sSection;
     TextBoxValue = Sys.GetObjectValue(sSection, Name);
 }
Ejemplo n.º 2
0
        public GodEdit(string sSection, GEType ControlType, string ControlName, string ControlCaptionText, SystemObject sys)
        {
            Type        = ControlType;
            Section     = sSection;
            Name        = ControlName;
            CaptionText = ControlCaptionText;
            if (ControlType == GEType.Button || ControlType == GEType.UploadControl)
            {
                Method = Name + "_Click";
            }

            if (ControlType == GEType.UploadControl)
            {
                Method = Name + "_Click";
            }
            Sys          = sys;
            TextBoxValue = Sys.GetObjectValue(Section, Name);
        }
Ejemplo n.º 3
0
        public Section(string name, int iColCt, SystemObject sys, object caller)
        {
            Name        = name;
            ColumnCount = iColCt;
            _controls   = new Dictionary <string, object>();
            Sys         = sys;
            string myClass = caller.GetType().ToString();

            StackTrace stackTrace = new StackTrace();

            StackFrame[] stackFrames  = stackTrace.GetFrames();
            StackFrame   callingFrame = stackFrames[1];
            MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();

            if (method.Name == "RenderSection")
            {
                callingFrame = stackFrames[2];
                method       = (MethodInfo)callingFrame.GetMethod();
            }
            string sMyMethod = method.Name;

            sys.ActiveSection = name;
            Expanded          = Sys.GetObjectValue(Name, "ExpandableSection" + myClass + sMyMethod) == "UNEXPANDED" ? false : true;
        }
Ejemplo n.º 4
0
        public string HandleRequest(string sPostData, SystemObject Sys)
        {
            // Deserialize the strongly typed javascript object back to c# object
            WebObj g = new WebObj();

            g = JsonConvert.DeserializeObject <WebObj>(sPostData);
            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];
                    string   sChecked   = vCols[4];
                    WebObj   fnew       = new WebObj();
                    fnew.value   = sValue;
                    fnew.name    = sName;
                    fnew.usgdid  = sUSGDID;
                    fnew.Checked = sChecked;
                    //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 (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);
                        return(myJason);
                    }
                    if (g.guid == "")
                    {
                        string[] vCol = g.body.Split(new string[] { "[COL]" }, StringSplitOptions.None);
                        if (vCol.Length > 0)
                        {
                            //g.guid = vCol[0];
                        }
                        g.guid = "0";
                    }
                    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
                    {
                        // RAISE EVENT INTO PROGRAM

                        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);
                        return(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);
                        return(myJason);
                    }
                }
            }
            return("UNKNOWN_REQUEST");
        }
Ejemplo n.º 5
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>";


            // Button for Exporting the Row (CSV printer icon)
            string sExportButton = "<span onclick=postdiv(this,'export','" + myClass + "','" + sMyMethod + "_Export',''); style='float:right; cursor:pointer;' class='"
                                   + "icon-print" + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
            string sButtons = "";

            if (bShowRowExport)
            {
                sButtons += sExportButton;
            }
            sButtons += sExpandButton + sAddNewButton; //These buttons end up going in reverse order.
            string html = "";

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

            if (OptionalHeaderComments != null)
            {
                sFullTitle += " " + OptionalHeaderComments;
            }
            html += "<table frame=box cellspacing=4 cellpadding=4 width=100% xclass=TFtable style='xmin-eight:1vh'>"
                    + "<tr><th colspan=20 cellpadding=0 cellspacing=0 class='ui-dialog-titlebar ui-corner-all ui-widget-header'>"
                    + "<span class='ui-dialog-title'>" + sFullTitle + "</span>" + sButtons + "</th></tr>";
            // Custom Context Sensitive menu and event, and Dispatch Function


            // Instead of tfTable,  background: grey;  alternate with this:

            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 class='Head1'>";
                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;
                    }
                    bool bMasked = false;
                    if (bCommentsColumn)
                    {
                        //sHeader += "</TR><TR>";
                        //sColspan = "colspan='" + dt.Cols.ToString() + "'";
                        //sCaption = "";
                        bMasked = true;
                    }
                    // Mask column if its a primary key guid

                    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 (clsStaticHelper.GetDouble(sValue) == 1)
                        {
                            bRowCloaked = true;
                        }
                    }
                    string sSpecialCSS = bRowHighlighted && bShowRowHighlightedByUserName ? "Activated" : "";

                    if (this.CurrentAltRow > this.AlternatingRows)
                    {
                        this.CurrentAltRow = 0;
                    }
                    string sAltCSS = "";
                    if ((this.AlternatingRows == 1 && this.CurrentAltRow == 0) || (this.AlternatingRows == 3 && this.CurrentAltRow < 2))
                    {
                        sAltCSS = "Alternated";
                    }
                    else
                    {
                        sAltCSS = AlternationColor;
                    }
                    this.CurrentAltRow++;

                    string sComments = "";
                    for (int xx = 0; xx < dt.Cols; xx++)
                    {
                        string sCaption = dt.ColumnNames[xx];
                        string sValue   = dt.Value(y, xx).ToString();

                        if (sCaption.ToUpper() == CommentsRow.ToUpper())
                        {
                            int iColCt = dt.Cols - 2;

                            string sColspan = "colspan='" + iColCt.ToString() + "'";
                            sComments  = "<TR class='" + sContextMenuCssClass + " " + sAltCSS + "'  >";
                            sComments += "<TD class='ui-dialog-title' style='float:none;border-top:solid 1px;color:gray' " + sColspan + ">" + sValue + "</TD></TR>";
                            html      += sComments;
                        }
                    }


                    // Add the context sensitive right click menu here:
                    string sRow = "<TR usgdid='" + sID + "'  class='" + sContextMenuCssClass + " " + sSpecialCSS + " " + sAltCSS
                                  + "'   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;
                        if (sCaption.ToUpper() == "USERNAME" || sCaption.ToUpper() == "MINERNAME")
                        {
                            if (bRowCloaked)
                            {
                                sValue = "Anonymous";
                            }
                        }
                        if (sCaption.ToUpper() == "STATS")
                        {
                            if (bRowCloaked)
                            {
                                sValue = "Anonymous";
                            }
                        }
                        // 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 (sCaption.ToUpper() == CommentsRow.ToUpper())
                        {
                            bMasked = true;
                        }


                        if (!bMasked)
                        {
                            if (URLDefaultValue == null)
                            {
                                URLDefaultValue = "View";
                            }

                            if (SourceTable == "Proposal" && sCaption.ToUpper() == "NAME")
                            {
                                //string sGobjectid = dt.Value(y, "GObjectID").ToString();
                                //   if (sGobjectid.Length > 0)      sValue = sValue + " - " + sGobjectid;
                            }
                            if ((SourceTable == "Links" || SourceTable == "Proposal" || SourceTable == "Expense") && sCaption.ToUpper() == "URL")
                            {
                                string js            = "var win = window.open('" + sValue + "', '_blank'); win.focus();";
                                string sDisplayValue = URLDefaultValue == "Display" ? sValue : URLDefaultValue;
                                sValue = "<a style='text-decoration: underline; cursor: pointer;' onclick=\"" + js + "\" xhref=" + URLDefaultValue + ">" + sDisplayValue + "</a>";
                            }
                            else 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);
        }
Ejemplo n.º 6
0
        public WebReply LoginSection()
        {
            // BIBLEPAY ACCOUNTABILITY
            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
                Home h = new Home(Sys);
                return(h.ExpenseList());
            }


            Section Login      = new Section("Login", 3, Sys, this);
            GodEdit geUserName = new GodEdit("Login", "Username", Sys);

            geUserName.CaptionText = "Username:"******"width=140px";
            Login.AddControl(geUserName);
            GodEdit geBR1 = new GodEdit("Login", GodEdit.GEType.HTML, "br1", "br1", Sys);

            Login.AddControl(geBR1);
            GodEdit geBR2 = new GodEdit("Login", GodEdit.GEType.HTML, "br2", "br2", Sys);

            Login.AddControl(geBR2);
            Login.AddControl(geBR1);
            GodEdit gePassword = new GodEdit("Login", GodEdit.GEType.Password, "Password", "Password:"******"Login", "Caption1") == String.Empty)
            {
                gePassword.ErrorText = "Invalid Username or Password";
            }
            GodEdit geBR3 = new GodEdit("Login", GodEdit.GEType.HTML, "br3", "br3", Sys);

            Login.AddControl(geBR3);
            GodEdit geBR4 = new GodEdit("Login", GodEdit.GEType.HTML, "br4", "br4", Sys);

            Login.AddControl(geBR4);

            GodEdit geBtnLogin = new GodEdit("Login", GodEdit.GEType.DoubleButton, "btnLogin", "Login", Sys);

            geBtnLogin.Name2        = "btnLogout";
            geBtnLogin.CaptionText2 = "Logout";
            Login.AddControl(geBtnLogin);

            GodEdit geBtnRegister = new GodEdit("Login", GodEdit.GEType.DoubleButton, "btnRegister", "Register", Sys);

            geBtnRegister.MaskBeginTD = true;
            geBtnRegister.MaskEndTD   = true;

            geBtnRegister.Name2        = "btnResetPassword";
            geBtnRegister.CaptionText2 = "Reset Password";
            Login.AddControl(geBtnRegister);


            // New Row, and global caption:
            GodEdit geTR3 = new GodEdit("Login", GodEdit.GEType.TableRow, "Tr3", "", Sys);

            Login.AddControl(geTR3);
            GodEdit geSpan = new GodEdit("Login", GodEdit.GEType.Caption, "Caption1", "", Sys);

            Login.AddControl(geSpan);
            Sys.SetObjectValue("", "ApplicationMessage", "Login");
            return(Login.Render(this, true));
        }
Ejemplo n.º 7
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);
                    }
                }
            }
        }