private DataObject GetDataObjectDetail(string dataObjectID)
        {
            var dataobject = new DataObjectManager().GetDataObject(dataObjectID);

            if (dataobject.DataSource == null)
            {
                var dataSource = DataSourceService.GetInstance().GetDataSource(dataobject.DataSourceName);
                if (dataSource != null)
                {
                    dataobject.DataSource = dataSource;
                }
            }
            if (!string.IsNullOrWhiteSpace(dataobject.TableShardingStrategyID))
            {
                var strategy = ShardingStrategyService.GetInstance().GetTableShardingStrategy(dataobject.TableShardingStrategyID);
                if (strategy != null)
                {
                    dataobject.TableShardingStrategy = strategy;
                    if (string.IsNullOrWhiteSpace(dataobject.ActualTableNames))
                    {
                        var tableNames = ShardingStrategyService.GetInstance().GetShardingTableNames(strategy, dataobject.LogicTableName);
                        if (tableNames != null && tableNames.Count > 0)
                        {
                            dataobject.ActualTableNames = string.Join(",", tableNames);
                        }
                    }
                }
            }

            return(dataobject);
        }
        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());
        }
        // GET: /Workflow/
        public ActionResult Display(int id)
        {
            //DataObjectLoader DOL = new API.ExternalData.DataObjectLoader();
            WorkflowDisplay wfDisplay = new WorkflowDisplay();

            WFNodeInfo nextNode = null;

            ScreenViewer.API.WorkflowController WFC = new API.WorkflowController();
            var actionResult      = WFC.GetScriptWorkflow(id);
            DataObjectManager DOM = new DataObjectManager();

            if (actionResult != null)
            {
                var response = actionResult as OkNegotiatedContentResult <ScriptWorkflow>;
                ViewBag.WorkflowName   = response.Content.WorkflowName;
                wfDisplay.workflowName = response.Content.WorkflowName;

                nextNode = DetermineNextNode((ScriptWorkflow)response.Content, currentNode, direction);

                if (nextNode != null)
                {
                    if (!direction.Equals(MoveDirection.Current) && nextNode.nodeName != null && nextNode.nodeType.Equals(NodeType.Section))
                    {
                        SessionManager.StoreNavigation(HttpContext.Session, nextNode.nodeName, wfDisplay.workflowName.ToString());
                    }

                    if (nextNode.nodeActions != "") //&& fireactions
                    {
                        FireActions(nextNode.nodeActions);
                    }

                    switch (nextNode.nodeType)
                    {
                    case NodeType.Section:
                        AddtoWFHistory(response.Content.ScriptWorkflowID, nextNode.NodeUniqueID, response.Content.WorkflowName, nextNode.nodeName);
                        break;

                    case NodeType.Workflow:
                        return(RedirectToAction("Display", "Workflow", new { id = WFC.GetScriptWorkflowId(nextNode.nodeName) }));

                    case NodeType.PreviousWorkflow:
                        return(RedirectToAction("DisplayByDirection", "Workflow", new { id = WFC.GetScriptWorkflowId(nextNode.nodeName), currentNode = nextNode.DocUID, moveDirection = MoveDirection.Current }));

                    case NodeType.SignPost:
                        MoveDirection direction2 = direction == MoveDirection.Start ? MoveDirection.Forward : direction;
                        WFNodeInfo    holdNode   = nextNode;
                        nextNode = DetermineNextNode((ScriptWorkflow)response.Content, nextNode.NodeUniqueID, direction2);
                        if (nextNode == null)
                        {
                            direction = MoveDirection.Current;
                            return(Display(Convert.ToInt32(Request.Form["hdnWorkflowId"])));
                            //nextNode = holdNode;
                        }
                        else
                        {
                            if (!direction.Equals(MoveDirection.Current) && nextNode.nodeName != null)
                            {
                                SessionManager.StoreNavigation(HttpContext.Session, nextNode.nodeName, wfDisplay.workflowName.ToString());
                                AddtoWFHistory(response.Content.ScriptWorkflowID, nextNode.NodeUniqueID, response.Content.WorkflowName, nextNode.nodeName);
                            }

                            if (nextNode.nodeType.Equals(NodeType.Workflow))
                            {
                                return(RedirectToAction("Display", "Workflow", new { id = WFC.GetScriptWorkflowId(nextNode.nodeName) }));
                            }
                        }
                        FireActions(nextNode.nodeActions);
                        if (nextNode.nodeType.Equals(NodeType.SignPost))
                        {
                            nextNode = DetermineNextNode((ScriptWorkflow)response.Content, nextNode.NodeUniqueID, direction2);

                            if (nextNode == null)
                            {
                                direction = MoveDirection.Current;
                                return(Display(Convert.ToInt32(Request.Form["hdnWorkflowId"])));
                                //nextNode = holdNode;
                            }
                            else
                            {
                                if (!direction.Equals(MoveDirection.Current) && nextNode.nodeName != null)
                                {
                                    SessionManager.StoreNavigation(HttpContext.Session, nextNode.nodeName, wfDisplay.workflowName.ToString());
                                    AddtoWFHistory(response.Content.ScriptWorkflowID, nextNode.NodeUniqueID, response.Content.WorkflowName, nextNode.nodeName);
                                }

                                if (nextNode.nodeType.Equals(NodeType.Workflow))
                                {
                                    return(RedirectToAction("Display", "Workflow", new { id = WFC.GetScriptWorkflowId(nextNode.nodeName) }));
                                }
                            }
                            FireActions(nextNode.nodeActions);
                        }
                        break;
                    }

                    if (IsNextNode((ScriptWorkflow)response.Content, nextNode.NodeUniqueID))
                    {
                        wfDisplay.showNext = true;
                    }
                    else
                    {
                        wfDisplay.showNext = false;
                    }
                }
                else
                {
                    direction = MoveDirection.Current;
                    return(Display(Convert.ToInt32(Request.Form["hdnWorkflowId"])));
                }
            }

            if (AddHistory)
            {
                if (SessionManager.GetWorkflowHistory(HttpContext.Session).Length >= 2)
                {
                    wfDisplay.showPrevious = true;
                }
                else
                {
                    wfDisplay.showPrevious = false;
                }
            }
            Session["layout"]    = null;
            wfDisplay.nextNode   = nextNode;
            wfDisplay.workflowID = id.ToString();
            nextNode.DocUID      = id;
            SessionManager.StoreNextNode(HttpContext.Session, nextNode);
            wfDisplay.callNotes = SessionManager.GetContactNotes(HttpContext.Session);

            string layoutname = "_default";

            if (!string.IsNullOrEmpty(SessionManager.GetScreenLayout(HttpContext.Session)))
            {
                layoutname = SessionManager.GetScreenLayout(HttpContext.Session);
            }

            WorkflowLayoutsController WLC = new WorkflowLayoutsController();

            //var actionResult2 = WLC.GetWorkflowLayoutString(layoutname, ScreenViewer.ClientHelper.GetClientIdByUserID(System.Web.HttpContext.Current.User.Identity.GetUserId()));
            var actionResult2 = WLC.GetWorkflowLayoutString(layoutname, SessionManager.GetScriptParameterByKey("ClientId", HttpContext.Session));

            if (actionResult2 != null)
            {
                var response = actionResult2 as OkNegotiatedContentResult <string>;
                wfDisplay.Layout = response.Content;
            }
            ScriptProject scriptproject = null;

            API.ProjectController PC = new API.ProjectController();
            var actionResult3        = PC.GetScriptProject(SessionManager.GetProjectId(HttpContext.Session));

            if (actionResult3 != null)
            {
                var response = actionResult3 as OkNegotiatedContentResult <ScriptProject>;
                scriptproject = response.Content;
            }

            string notif = scriptproject.NotificationText;

            wfDisplay.menuHTML = SessionManager.GetMenuHTML(HttpContext.Session);

            wfDisplay.Notifications = scriptproject.NotificationText; //notif.Replace(System.Environment.NewLine,"");

            return(View("_WorkFlowViewLayout1", wfDisplay));
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 private DataObjectManageService()
 {
     manager         = new DataObjectManager();
     dataObjectCache = new ConcurrentDictionary <string, DataObject>();
 }