//
        // GET: /LeadInfo/
        public ActionResult Index()
        {
            try
            {
                DataObjectLoader DOL           = new API.ExternalData.DataObjectLoader();
                DataObjects      DisplayObject = (DataObjects)SessionManager.GetDataObject(HttpContext.Session, "SXMLead");

                var     myType   = GenerateClass.CompileResultType(DisplayObject.Details);
                dynamic myObject = Activator.CreateInstance(myType);

                DisplayObject.ReverseObjectMatch(string.Empty, myObject);


                ViewBag.LeadName              = string.Format("{0} {1}", myObject.FIRST_NAME, myObject.LAST_NAME);
                ViewBag.LeadAddress           = string.Format("{0} {1}\n{2} {3}", myObject.ADDRESS1, myObject.ADDRESS2, myObject.CITY, myObject.STATE);
                ViewBag.ACCOUNT_NUMBER        = myObject.ACCOUNT_NUMBER;
                ViewBag.Email                 = myObject.EMAIL;
                ViewBag.PLAN_DESCRIPTION      = myObject.PLAN_DESCRIPTION;
                ViewBag.PLAN_START_DATE       = !string.IsNullOrEmpty(myObject.PLAN_START_DATE) ? Convert.ToDateTime(myObject.PLAN_START_DATE).ToString("MM/dd/yyyy") : string.Empty;
                ViewBag.NEXT_RENEWAL_DATE     = !string.IsNullOrEmpty(myObject.NEXT_RENEWAL_DATE) ? Convert.ToDateTime(myObject.NEXT_RENEWAL_DATE).ToString("MM/dd/yyyy") : string.Empty;
                ViewBag.ESN_DEACTIVATION_DATE = !string.IsNullOrEmpty(myObject.ESN_DEACTIVATION_DATE) ? Convert.ToDateTime(myObject.ESN_DEACTIVATION_DATE).ToString("MM/dd/yyyy") : string.Empty;
                ViewBag.AUTO_MAKE             = myObject.AUTO_MAKE;
                ViewBag.AUTO_MODEL            = myObject.AUTO_MODEL;
                ViewBag.Auto_Trim_Year        = string.Format("{0} {1}", myObject.Auto_Trim, myObject.Auto_Year);
            }
            catch { }

            return(PartialView("_LeadInfo"));
        }
        public string Render(decimal id, ControllerContext ContCont)
        {
            ViewBag.DataViewID = id;

            ScreenViewer.API.Elements.DataViewController DVC = new API.Elements.DataViewController();
            var actionResult = DVC.GetScriptDataView(id);

            var response = actionResult as OkNegotiatedContentResult <Data.ScriptDataView>;

            Data.ScriptDataView theDataView = response.Content;
            DataObjectManager   DOM         = new DataObjectManager();

            ScreenViewer.API.DataObjectController DOC = new API.DataObjectController();

            ViewBag.OID = response.Content.ScriptDataViewID.ToString();

            switch (theDataView.DataViewType)
            {
            case "R":
                DataObjectLoader DOL = new API.ExternalData.DataObjectLoader();

                string      objectname    = System.Text.RegularExpressions.Regex.Split(theDataView.DataViewSource, "::")[1];
                DataObjects DisplayObject = (DataObjects)SessionManager.GetDataObject(ContCont.HttpContext.Session, objectname);

                //Models.DataObjects DisplayObject = (Models.DataObjects)SessionControl.SessionManager.GetDataObject(HttpContext.Session,theDataView.DataViewObjectSource);
                if (DisplayObject != null)
                {
                    return(RenderHelper.RenderViewToString(ContCont, "~/Views/DataView/_DataView_Record.cshtml", DisplayObject.Details, ViewData));
                    //return PartialView("_DataView_Record", DisplayObject.Details);
                }
                else
                {
                    return(string.Empty);
                }

            case "C":

                string objectcolletion = System.Text.RegularExpressions.Regex.Split(theDataView.DataViewSource, "::")[1];
                string dataobname      = System.Text.RegularExpressions.Regex.Split(objectcolletion, "\\.")[0];

                if (SessionManager.GetDataObject(ContCont.HttpContext.Session, dataobname) != null)
                {
                    string tabledata = SPutilities.GenerateGridData3(objectcolletion, ContCont.HttpContext.Session);
                    ViewBag.Table = tabledata;
                    return(RenderHelper.RenderViewToString(ContCont, "~/Views/DataView/_DataView_Grid.cshtml", null, ViewData));
                }
                else
                {
                    ViewBag.Table = string.Empty;
                    return(RenderHelper.RenderViewToString(ContCont, "~/Views/DataView/_DataView_Grid.cshtml", null, ViewData));
                }

            case "S":
                return(string.Empty);

            default:
                return(string.Empty);
            }
        }
        //HttpContext.Session
        // GET: /DataView/Details/5
        public ActionResult Display(decimal id)
        {
            ViewBag.DataViewID = id;

            ScreenViewer.API.Elements.DataViewController DVC = new API.Elements.DataViewController();
            var actionResult = DVC.GetScriptDataView(id);



            var response = actionResult as OkNegotiatedContentResult <Data.ScriptDataView>;

            //Assert.IsNotNull(response);
            Data.ScriptDataView theDataView = response.Content;
            DataObjectManager   DOM         = new DataObjectManager();

            ScreenViewer.API.DataObjectController DOC = new API.DataObjectController();
            switch (theDataView.DataViewType)
            {
            case "R":
                DataObjectLoader DOL = new API.ExternalData.DataObjectLoader();

                string objectname = System.Text.RegularExpressions.Regex.Split(theDataView.DataViewSource, "::")[1];

                DataObjects DisplayObject = (DataObjects)SessionManager.GetDataObject(HttpContext.Session, objectname);

                //Models.DataObjects DisplayObject = (Models.DataObjects)SessionControl.SessionManager.GetDataObject(HttpContext.Session,theDataView.DataViewObjectSource);
                if (DisplayObject != null)
                {
                    return(PartialView("_DataView_Record", DisplayObject.Details));
                }

                break;

            case "C":

                string objectcolletion = System.Text.RegularExpressions.Regex.Split(theDataView.DataViewSource, "::")[1];
                string dataobname      = System.Text.RegularExpressions.Regex.Split(objectcolletion, "\\.")[0];
                string tabledata       = SPutilities.GenerateGridData2(objectcolletion, HttpContext.Session);
                ViewBag.Table = tabledata;
                return(PartialView("_DataView_Grid", ViewData));

            case "S":

                break;

            default:
                break;
            }


            return(View());
        }