Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EX_Admin.Power("usernode_add", "添加自定义结点"))
            {
                PageReturnMsg = PageNoPowerMsg();
            }

            int Node_id = RequestTool.RequestInt("Node_id", 0);

            UserNode = B_Lebi_Node.GetModel(Node_id);
            lang     = RequestTool.RequestString("lang");
            key      = RequestTool.RequestString("key");
            if (UserNode == null)
            {
                code = RequestTool.RequestString("code");
                if (code == "")
                {
                    code = "UserNode";
                }
                UserNode = NodePage.GetNodeByCode(code);
            }
            if (UserNode.Code == "Help")
            {
                PageCode = "P_Help";
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id  = RequestTool.RequestInt("id", 0);
            int pid = RequestTool.RequestInt("pid", 0);

            model = B_Lebi_Node.GetModel(id);
            if (model == null)
            {
                if (!EX_Admin.Power("usernode_add", "添加自定义结点"))
                {
                    WindowNoPower();
                }
                model = new Lebi_Node();
            }
            else
            {
                if (!EX_Admin.Power("usernode_edit", "编辑自定义结点"))
                {
                    WindowNoPower();
                }
                pid = model.parentid;
            }
            PNode = B_Lebi_Node.GetModel(pid);
            if (PNode == null)
            {
                PNode = new Lebi_Node();
            }
            UserNode = NodePage.GetNodeByCode("UserNode");
        }
Example #3
0
 // Inserts a new group after the last selected group
 public void InsertAfterInstructionGroup(IInstructionGroupItem groupFactory)
 {
     if (runtimeService.DisconnectDialog(this))
     {
         IInstructionGroupItem foundIG = null;
         foreach (var instructionGroupIterator in Items)
         {
             IInstructionGroupItem instructionGroup = null;
             instructionGroup = instructionGroupIterator as IInstructionGroupItem;
             if (instructionGroup != null && instructionGroup.IsSelected)
             {
                 foundIG = instructionGroup;
             }
         }
         if (foundIG != null)
         {
             var      newItem = groupFactory.Create(this, null);
             NodePage newPage = WorkingCopy.NodeInstructionGroupChildren.InsertAfter(foundIG.InstructionGroup, newItem.InstructionGroup);
             insertNewGroup(newItem, newPage);
         }
         else
         {
             PageEditorParent.messagingService.ShowMessage(
                 Resources.Strings.PageEditor_GroupCommand_NoneSelected,
                 Resources.Strings.PageEditor_GroupCommand_NoneSelected_Title);
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            int id  = RequestTool.RequestInt("id", 0);
            int pid = RequestTool.RequestInt("pid", 0);

            model = B_Lebi_Node.GetModel(id);
            if (model == null)
            {
                if (!EX_Admin.Power("usernode_add", "添加自定义结点"))
                {
                    WindowNoPower();
                }
                model = new Lebi_Node();
                model.Type_id_PublishType = 120;
                model.haveson             = 1;
            }
            else
            {
                if (!EX_Admin.Power("usernode_edit", "编辑自定义结点"))
                {
                    WindowNoPower();
                }
                pid = model.parentid;
            }
            PNode = B_Lebi_Node.GetModel(pid);
            if (PNode == null)
            {
                PNode = new Lebi_Node();
            }
            string code = RequestTool.RequestString("code");

            Topnode = NodePage.GetNodeByCode(code);
        }
Example #5
0
 private void ScanPage(NodeRuntimeApplication rta, NodePage page)
 {
     foreach (var instructionGroup in page.NodeInstructionGroupChildren)
     {
         ScanInstructionGroup(rta, instructionGroup);
     }
 }
Example #6
0
 public PageItem(ISolutionItem parent, NodePage page)
     : base(parent, page.PageName.ToString())
 {
     ContextMenu      = extensionService.Sort(contextMenu);
     Page             = page;
     HeaderIsEditable = true;
     SetIconFromBitmap(Resources.Images.Page);
 }
            public SignalTreeClass(SignalChooserDialog dlg)
            {
                var      tpl = dlg.runtimeService.FindParentPageAndRuntimeApp(dlg.NodeItem);
                NodePage pg  = tpl.Item1;
                NodeRuntimeApplication rta = tpl.Item2;

                Items = BuildSignalTree(dlg, rta, pg, dlg.SignalId, dlg.m_dataTypefilter);
            }
Example #8
0
 public PageItem(ISolutionItem parent, NodePage page)
     : base(parent, page.PageName.ToString())
 {
     ContextMenu = extensionService.Sort(contextMenu);
     Page = page;
     HeaderIsEditable = true;
     SetIconFromBitmap(Resources.Images.Page);
 }
Example #9
0
 public void AppendInstructionGroup(IInstructionGroupItem groupFactory)
 {
     if (runtimeService.DisconnectDialog(this))
     {
         var      newItem = groupFactory.Create(this, null);
         NodePage newPage = WorkingCopy.NodeInstructionGroupChildren.Append(newItem.InstructionGroup);
         insertNewGroup(newItem, newPage);
     }
 }
Example #10
0
 public void AddPage()
 {
     if (runtimeService.DisconnectDialog(this))
     {
         PageCollection = PageCollection.NodePageChildren.Append(
             NodePage.BuildWith(new FieldPageName(
                                    Resources.Strings.Solution_Pad_PageItem_NewPageName)));
     }
 }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EX_Admin.Power("usernode_add", "添加自定义结点"))
            {
                PageReturnMsg = PageNoPowerMsg();
            }
            string code = RequestTool.RequestString("code");

            Topnode = NodePage.GetNodeByCode(code);
        }
Example #12
0
 public PageEditorItem(PageEditor parent, NodePage page)
     : base(null)
 {
     if (page == null)
     {
         throw new ArgumentNullException();
     }
     m_parent    = parent;
     WorkingCopy = page;
 }
Example #13
0
 public void MoveSelectedAfter(IInstructionGroupItem instructionGroup)
 {
     if (runtimeService.DisconnectDialog(this))
     {
         var      nodesToMove = new ReadOnlyCollection <NodeInstructionGroup>(getSelectedNodes());
         NodePage newPage     = WorkingCopy;
         newPage = newPage.NodeInstructionGroupChildren.Remove(nodesToMove);
         newPage = newPage.NodeInstructionGroupChildren.InsertAfter(instructionGroup.InstructionGroup, nodesToMove);
         simplePageEdit(newPage, Resources.Strings.PageEditor_UndoDescription_MoveGroups);
     }
 }
Example #14
0
            private void simplePageEdit(NodePage newPage, string undoDescription)
            {
                NodePage origPage    = WorkingCopy;
                var      undoActions = new List <Action>();
                var      doActions   = new List <Action>();

                doActions.Add(() => WorkingCopy   = newPage);
                undoActions.Add(() => WorkingCopy = origPage);
                Do(new UndoMemento(this, ActionType.EDIT,
                                   undoDescription, undoActions, doActions));
            }
Example #15
0
        public string GetTreeString(int parentID, int deep)
        {
            string           str   = "";
            List <Lebi_Node> nodes = B_Lebi_Node.GetList("parentid=" + parentID + "", "Sort desc");

            if (nodes.Count > 0)
            {
                foreach (Lebi_Node node in nodes)
                {
                    str += "<tr class=\"list\" onDblClick=\"Node_Edit(0," + node.id + ")\">";
                    str += "<td><strong>";
                    str += node.Code;
                    str += "</strong></td>";

                    str += "<td>" + node.Sort + "</td>";
                    if (deep == 0)
                    {
                        str += "<td><strong>" + node.Name + "</strong></td>";
                    }
                    else
                    {
                        str += "<td>" + GetDeep("<label class=\"subFlag\">┗</label>" + node.Name, deep) + "</td>";
                    }
                    str += "<td>";
                    str += NodePage.NodeType(node.TypeFlag);
                    str += "</td>";
                    str += "<td>";
                    str += (node.IsLanguages == 1?"Yes":"No");
                    str += "</td>";
                    str += "<td>";
                    str += B_Lebi_Page.Counts("node_id=" + node.id + "").ToString();
                    str += "</td>";

                    str += "<td>";
                    //str += "<a href=\"#\" onclick=\"UpdateNode(" + node.ParentNodeID + ",0);\">" + Tag("创建同级结点") + "</a>";
                    //str += "<span class=\"editSep\">|</span>";

                    str += "<a href=\"#\" onclick=\"Node_Edit(0," + node.id + ");\">" + Tag("修改") + "</a>";
                    str += " | ";
                    str += "<a href=\"#\" onclick=\"Node_Del(" + node.id + ");\">" + Tag("删除") + "</a>";
                    if (node.haveson == 1)
                    {
                        str += " | ";
                        str += "<a href=\"#\" onclick=\"Node_Edit(" + node.id + ",0);\">" + Tag("创建子结点") + "</a>";
                    }
                    str += "</td>";
                    str += "</tr>";
                    str += GetTreeString(node.id, deep + 1);
                }
                //str += "</ul>  \r\n";
            }
            return(str);
        }
        /// <summary>
        /// 文章分类
        /// </summary>
        /// <returns></returns>
        public string Article()
        {
            Lebi_Node        node  = NodePage.GetNodeByCode("Info");
            List <Lebi_Node> nodes = B_Lebi_Node.GetList("parentid=" + node.id + "", "");
            string           str   = "<tr><th>" + Tag("类别") + ":</th><td>";

            foreach (Lebi_Node n in nodes)
            {
                str += "<input type=\"checkbox\" name=\"node\" value=\"" + n.id + "\" shop=\"true\" >" + n.Name + "</br>";
            }
            str += "</td></tr>";
            return(str);
        }
Example #17
0
 /// <summary>
 /// Helper method
 /// </summary>
 /// <param name="newItem">Item created by factory</param>
 /// <param name="newPage">NodePage with node already inserted at the desired position</param>
 private void insertNewGroup(IInstructionGroupItem newItem, NodePage newPage)
 {
     if (runtimeService.DisconnectDialog(this))
     {
         NodePage origPage    = WorkingCopy;
         var      undoActions = new List <Action>();
         var      doActions   = new List <Action>();
         doActions.Add(() => Items.Add(newItem));
         doActions.Add(() => WorkingCopy   = newPage);
         undoActions.Add(() => WorkingCopy = origPage);
         Do(new UndoMemento(this, ActionType.ADD,
                            Resources.Strings.PageEditor_UndoDescription_InsertGroup, undoActions, doActions));
     }
 }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PageSize = RequestTool.getpageSize(25);

            node = NodePage.GetNodeByCode("shopindeximages");
            if (node == null)
            {
                PageReturnMsg = PageErrorMsg();
            }

            string where = "Node_id=" + node.id + " and Supplier_id=" + CurrentSupplier.id;
            int recordCount = B_Lebi_Page.Counts(where);

            pages      = B_Lebi_Page.GetList(where, "Sort desc,id desc", PageSize, page);
            PageString = Shop.Bussiness.Pager.GetPaginationString("?page={0}", page, PageSize, recordCount);
        }
Example #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int Page_id = RequestTool.RequestInt("id", 0);

            model = B_Lebi_Page.GetModel(Page_id);
            node  = NodePage.GetNodeByCode("shopindeximages");
            if (node == null)
            {
                PageReturnMsg = PageErrorMsg();
            }
            if (model == null)
            {
                model             = new Lebi_Page();
                model.Supplier_id = CurrentSupplier.id;
            }
        }
Example #20
0
        /// <summary>
        /// Returns a dictionary of signal names, and those signals, in a depth
        /// first search of the runtime application.  For those signals within
        /// the same page, it has no prefix, but for those in other pages or
        /// in the device configuration, it adds a directory-like prefix.
        /// </summary>
        public Dictionary <string, NodeSignal> SignalList(INodeWrapper requester, FieldDataType.DataTypeEnum dataTypeFilter)
        {
            var      dict = new Dictionary <string, NodeSignal>();
            var      tpl  = FindParentPageAndRuntimeApp(requester);
            NodePage pg   = tpl.Item1;
            NodeRuntimeApplication rta = tpl.Item2;

            if (rta != null)
            {
                if (pg != null)
                {
                    // Search the local page first
                    SignalsDepthFirst(pg, string.Empty, dict, pg, dataTypeFilter);
                }
                SignalsDepthFirst(rta, string.Empty, dict, pg, dataTypeFilter);
            }
            return(dict);
        }
Example #21
0
        /// <summary>
        /// 帮助中心页面
        /// </summary>
        /// <param name="lang"></param>
        /// <param name="model"></param>
        /// <param name="theme"></param>
        /// <param name="urlpath"></param>
        private void P_Help(List <Lebi_Language> langs, Lebi_Theme_Page model, string urlpath)
        {
            string    url;
            Lebi_Node pnode     = NodePage.GetNodeByCode("Help");
            string    file      = "";
            int       pageindex = RequestTool.RequestInt("pageindex", 0);
            int       pagesize  = RequestTool.RequestInt("pagesize", 0);

            string where = "parentid=" + pnode.id + "";
            List <Lebi_Node> nodes = B_Lebi_Node.GetList(where, "", pagesize, pageindex);
            int count     = B_Lebi_Node.Counts(where);
            int pagecount = Pager.GetPageCount(pagesize, count);
            int per       = 100;

            if (pagecount > 0)
            {
                per = Convert.ToInt32(pageindex * 100 / pagecount);
            }
            List <Lebi_Site> sites = GetSites();
            Lebi_Site        site;

            foreach (Lebi_Node node in nodes)
            {
                foreach (Lebi_Language lang in langs)
                {
                    if (node.Language.ToLower().Contains(lang.Code.ToLower()))
                    {
                        site = GetSite(sites, lang.Site_id);
                        file = site.Path + "/" + lang.Path + "/" + model.StaticPath + "/" + model.StaticPageName;
                        file = file.Replace("{0}", node.id.ToString());
                        file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                        file = ThemeUrl.CheckPath(file);

                        url = model.PageName + "?" + model.PageParameter;
                        url = url.Replace("{0}", node.id.ToString());
                        url = urlpath + "/" + site.Path + "/" + lang.Path + "/" + url;
                        url = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                        url = ThemeUrl.CheckURL(url);
                        HtmlEngine.Instance.CreatHtml(url, file);
                    }
                }
            }
            Response.Write("{\"msg\":\"OK\",\"per\":\"" + per + "\"}");
        }
Example #22
0
        /// <summary>
        /// 新闻详情页面
        /// </summary>
        /// <param name="lang"></param>
        /// <param name="model"></param>
        /// <param name="theme"></param>
        /// <param name="urlpath"></param>
        private void P_NewsDetails(List <Lebi_Language> langs, Lebi_Theme_Page model, string urlpath)
        {
            string    url;
            Lebi_Node pnode     = NodePage.GetNodeByCode("News");
            DateTime  time1     = RequestTool.RequestTime("time1");
            DateTime  time2     = RequestTool.RequestTime("time2");
            int       pageindex = RequestTool.RequestInt("pageindex", 0);
            int       pagesize  = RequestTool.RequestInt("pagesize", 0);
            string    file      = "";

            string where = "Node_id=" + pnode.id + "  and Time_Add>='" + time1 + "' and Time_Add<='" + time2 + "'";
            List <Lebi_Page> pages = B_Lebi_Page.GetList(where, "", pagesize, pageindex);
            int count     = B_Lebi_Page.Counts(where);
            int pagecount = Pager.GetPageCount(pagesize, count);
            int per       = 100;

            if (pagecount > 0)
            {
                per = Convert.ToInt32(pageindex * 100 / pagecount);
            }
            List <Lebi_Site> sites = GetSites();
            Lebi_Site        site;

            foreach (Lebi_Page page in pages)
            {
                foreach (Lebi_Language lang in langs)
                {
                    if (page.Language.ToLower().Contains(lang.Code.ToLower()))
                    {
                        site = GetSite(sites, lang.Site_id);
                        file = site.Path + "/" + lang.Path + "/" + model.StaticPath + "/" + model.StaticPageName;
                        file = file.Replace("{0}", page.id.ToString());
                        file = ThemeUrl.CheckPath(file);

                        url = model.PageName + "?" + model.PageParameter;
                        url = url.Replace("{0}", page.id.ToString());
                        url = urlpath + "/" + site.Path + "/" + lang.Path + "/" + url;
                        url = ThemeUrl.CheckURL(url);
                        HtmlEngine.Instance.CreatHtml(url, file);
                    }
                }
            }
            Response.Write("{\"msg\":\"OK\",\"per\":\"" + per + "\"}");
        }
Example #23
0
        public List <shopindeximage> Getindeximages(int top)
        {
            List <shopindeximage> indeximgaes = new List <shopindeximage>();
            Lebi_Node             node        = NodePage.GetNodeByCode("shopindeximages");

            if (node != null)
            {
                List <Lebi_Page> ps = B_Lebi_Page.GetList("Node_id=" + node.id + " and Supplier_id=" + supplier.id + "", "Sort desc", top, 1);
                foreach (Lebi_Page p in ps)
                {
                    shopindeximage img = new shopindeximage();
                    img.image = p.ImageOriginal;
                    img.title = p.Name;
                    img.url   = p.url;
                    indeximgaes.Add(img);
                }
            }
            return(indeximgaes);
        }
Example #24
0
        /// <summary>
        /// 编辑|添加店铺幻灯图片
        /// </summary>
        public void indeximage_Edit()
        {
            int       id    = RequestTool.RequestInt("id", 0);
            Lebi_Page model = B_Lebi_Page.GetModel(id);
            Lebi_Node node  = NodePage.GetNodeByCode("shopindeximages");

            if (model == null)
            {
                model = new Lebi_Page();
            }
            B_Lebi_Page.SafeBindForm(model);
            model.Supplier_id = CurrentSupplier.id;
            model.Node_id     = node.id;
            if (model.id == 0)
            {
                if (!Power("indeximage_add", "添加店铺幻灯"))
                {
                    AjaxNoPower();
                    return;
                }
                B_Lebi_Page.Add(model);
                id = B_Lebi_Page.GetMaxId();
                string action      = "添加店铺幻灯";
                string description = model.Name;
                Log.Add(action, "Page", id.ToString(), CurrentSupplier, description);
            }
            else
            {
                if (!Power("indeximage_edit", "编辑店铺幻灯"))
                {
                    AjaxNoPower();
                    return;
                }
                B_Lebi_Page.Update(model);
                string action      = Tag("编辑店铺幻灯");
                string description = model.Name;
                Log.Add(action, "Page", id.ToString(), CurrentSupplier, description);
            }
            //=========================================
            //处理静态页面
            ImageHelper.LebiImagesUsed(model.ImageOriginal, "page", id);
            Response.Write("{\"msg\":\"OK\",\"id\":\"" + id + "\"}");
        }
Example #25
0
        /// <summary>
        /// 编辑自定义结点
        /// </summary>
        public void CustomNode_Edit()
        {
            int       id      = RequestTool.RequestInt("id", 0);
            string    code    = RequestTool.RequestString("parentcode");
            Lebi_Node topnode = NodePage.GetNodeByCode(code);
            Lebi_Node model   = B_Lebi_Node.GetModel(id);

            if (model == null)
            {
                model = new Lebi_Node();
            }
            B_Lebi_Node.BindForm(model);
            if (topnode.IsLanguages == 1)
            {
                model.Name = Language.RequestString("Name");
            }
            if (model.id == 0)
            {
                if (!EX_Admin.Power("usernode_add", "添加自定义结点"))
                {
                    AjaxNoPower();
                    return;
                }
                B_Lebi_Node.Add(model);
                id = B_Lebi_Node.GetMaxId();
                string action      = Tag("添加自定义结点");
                string description = model.Name;
                Log.Add(action, "Node", model.id.ToString(), CurrentAdmin, description);
            }
            else
            {
                if (!EX_Admin.Power("usernode_edit", "编辑自定义结点"))
                {
                    AjaxNoPower();
                    return;
                }
                B_Lebi_Node.Update(model);
                string action      = Tag("编辑自定义结点");
                string description = model.Name;
                Log.Add(action, "Node", model.id.ToString(), CurrentAdmin, description);
            }
            Response.Write("{\"msg\":\"OK\",\"id\":\"" + id + "\"}");
        }
Example #26
0
        private IEnumerable <CompiledInstruction> compilePage(
            NodePage page,
            SignalTable signalTable)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }
            if (signalTable == null)
            {
                throw new ArgumentNullException("signalTable");
            }
            var result = new List <CompiledInstruction>();

            foreach (var instructionGroup in page.NodeInstructionGroupChildren) // instructionGroup == rung
            {
                result.AddRange(compileInstructionGroup(instructionGroup, signalTable));
            }

            return(result);
        }
Example #27
0
        protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode)
        {
            LoadTheme(themecode, siteid, languagecode, pcode);
            CurrentPage = B_Lebi_Theme_Page.GetModel("Code='P_ArticleDetails'");
            id          = Rint_Para("0");
            parentnode  = Node("Info");
            nodes       = B_Lebi_Node.GetList("Parentid=" + parentnode.id + " and ','+Language_ids+',' like '%," + CurrentLanguage.id + ",%'", "Sort desc");
            page        = B_Lebi_Page.GetModel(id);
            if (page == null)
            {
                node = nodes.FirstOrDefault();
                page = NodePage.GetPageByNode(node);
                if (page == null)
                {
                    PageError();
                }
            }
            else
            {
                page.Count_Views += 1;
                B_Lebi_Page.Update(page);
                node = B_Lebi_Node.GetModel(page.Node_id);
            }

            string where = "Node_id=" + node.id + " and ','+Language_ids+',' like '%," + CurrentLanguage.id + ",%'";
            PreviousPage = B_Lebi_Page.GetModel(where + " and Sort>=" + page.Sort + " and id>" + page.id + " order by Sort asc,id asc");
            NextPage     = B_Lebi_Page.GetModel(where + " and Sort<=" + page.Sort + " and id<" + page.id + " order by Sort desc,id desc");
            if (PreviousPage == null)
            {
                PreviousPage = new Lebi_Page();
            }
            if (NextPage == null)
            {
                NextPage = new Lebi_Page();
            }

            path = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("Ê×Ò³") + "\"><span>" + Tag("Ê×Ò³") + "</span></a><em class=\"home\">&raquo;</em><a href=\"" + URL("P_Article", "") + "\"><span>" + Tag(parentnode.Name) + "</span></a><em>&raquo;</em><a href=\"" + URL("P_Article", node.id) + "\"><span>" + node.Name + "</span></a><em>&raquo;</em><a href=\"" + URL("P_ArticleDetails", page.id) + "\"><span>" + page.Name + "</span></a>";
        }
Example #28
0
        /// <summary>
        /// Searches the runtime application for a signal matching the given signalId
        /// </summary>
        public Tuple <string, NodeSignal> FindSignal(INodeWrapper requester, FieldGuid signalId)
        {
            var      tpl = FindParentPageAndRuntimeApp(requester);
            NodePage pg  = tpl.Item1;
            NodeRuntimeApplication rta = tpl.Item2;

            if (rta != null)
            {
                var edits = new Dictionary <NodePage, NodePage>();

                if (pg != null)
                {
                    // Searches the local page first
                    var tryLocal = FindSignalAndName(pg, string.Empty, pg, signalId, edits);
                    if (tryLocal != null)
                    {
                        return(tryLocal);
                    }
                }

                // Make a list of edited page copies
                foreach (var d in layoutManager.Documents)
                {
                    var pageEditor = d as PageEditor;
                    if (pageEditor != null)
                    {
                        edits.Add(pageEditor.PageItemParent.Page, pageEditor.EditorRoot.WorkingCopy);
                    }
                }

                return(FindSignalAndName(rta, string.Empty, pg, signalId, edits));
            }
            else
            {
                return(null);
            }
        }
Example #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int Node_id = RequestTool.RequestInt("Node_id", 0);
            int Page_id = RequestTool.RequestInt("Page_id", 0);

            page = B_Lebi_Page.GetModel(Page_id);
            if (page != null)
            {
                if (!EX_Admin.Power("page_edit", "编辑结点内容"))
                {
                    PageReturnMsg = PageNoPowerMsg();
                }

                Node_id = page.Node_id;
            }
            else
            {
                if (!EX_Admin.Power("page_add", "添加结点内容"))
                {
                    PageReturnMsg = PageNoPowerMsg();
                }

                page = new Lebi_Page();
            }
            node = B_Lebi_Node.GetModel(Node_id);
            if (node == null)
            {
                node = new Lebi_Node();
            }
            pnode = B_Lebi_Node.GetModel(node.parentid);
            if (pnode == null)
            {
                pnode = new Lebi_Node();
            }
            UserNode = NodePage.GetNodeByCode("UserNode");
        }
Example #30
0
        public Tuple <NodePage, NodeRuntimeApplication> FindParentPageAndRuntimeApp(INodeWrapper requester)
        {
            var tpl = FindParentPageEditorItemPageItemAndRuntimeAppItem(requester);

            PageEditor.PageEditorItem pageEditorItem = tpl.Item1;
            PageItem pageItem = tpl.Item2;
            RuntimeApplicationItem runtimeAppItem = tpl.Item3;
            NodePage pg = null;
            NodeRuntimeApplication rta = null;

            if (pageEditorItem != null)
            {
                pg = pageEditorItem.WorkingCopy;
            }
            else if (pageItem != null)
            {
                pg = pageItem.Page;
            }
            if (runtimeAppItem != null)
            {
                rta = runtimeAppItem.RuntimeApplication;
            }
            return(new Tuple <NodePage, NodeRuntimeApplication>(pg, rta));
        }
Example #31
0
        private static Tuple<string, NodeSignal> FindSignalAndName(NodeBase fromNode, string header, NodePage localRoot, FieldGuid signalId, 
            Dictionary<NodePage, NodePage> edits)
        {
            const string SEPARATOR = "/";

            string prevHeader;
            if (header.Length == 0)
            {
                prevHeader = string.Empty;
            }
            else
            {
                prevHeader = header + SEPARATOR;
            }

            var thisSig = fromNode as NodeSignal;
            if (thisSig != null && thisSig.SignalId == signalId)
            {
                return new Tuple<string, NodeSignal>(prevHeader + thisSig.SignalName, thisSig);
            }
            else
            {
                foreach (var child in fromNode.ChildCollection)
                {
                    var nPageCollection = child as NodePageCollection;
                    var nPage = child as NodePage;
                    var nInstructionGroup = child as NodeInstructionGroup;
                    var nInstruction = child as NodeInstruction;
                    var nSignal = child as NodeSignal;
                    var nDeviceConfiguration = child as NodeDeviceConfiguration;
                    var nDriver = child as NodeDriver;
                    var nDevice = child as NodeDevice;
                    var nDiscreteInput = child as NodeDiscreteInput;
                    var nAnalogInput = child as NodeAnalogInput;
                    var nStringInput = child as NodeStringInput;

                    Tuple<string, NodeSignal> found = null;

                    if (nInstructionGroup != null || nInstruction != null || nDeviceConfiguration != null
                        || nDriver != null || nDiscreteInput != null || nAnalogInput != null
                        || nStringInput != null || nSignal != null)
                    {
                        found = FindSignalAndName(child, header, localRoot, signalId, edits);
                    }
                    else if (nPageCollection != null)
                    {
                        found = FindSignalAndName(child, prevHeader + nPageCollection.PageCollectionName, localRoot, signalId, edits);
                    }
                    else if (nPage != null)
                    {
                        string newHeader = prevHeader + nPage.PageName;
                        if (nPage == localRoot) // first, search local page, if there is one
                        {
                            found = FindSignalAndName(child, string.Empty, localRoot, signalId, edits);
                        }
                        if (found == null && edits.ContainsKey(nPage)) // search edited page, if there is one
                        {
                            found = FindSignalAndName(edits[nPage], newHeader, localRoot, signalId, edits);
                        }
                        if (found == null) // search from the root otherwise
                        {
                            found = FindSignalAndName(child, newHeader, localRoot, signalId, edits);
                        }
                    }
                    else if (nDevice != null)
                    {
                        found = FindSignalAndName(child, prevHeader + nDevice.DeviceName, localRoot, signalId, edits);
                    }
                    if (found != null)
                    {
                        return found;
                    }
                }
                return null;
            }
        }
            private Collection<SignalTreeItem> BuildSignalTree(SignalChooserDialog dlg, NodeBase n, 
                NodePage pg, FieldGuid selectedSignalId, FieldDataType.DataTypeEnum dataTypeFilter)
            {
                var items = new Collection<SignalTreeItem>();

                foreach (var child in n.ChildCollection)
                {
                    var nPageCollection = child as NodePageCollection;
                    var nPage = child as NodePage;
                    var nInstructionGroup = child as NodeInstructionGroup;
                    var nInstruction = child as NodeInstruction;
                    var nSignal = child as NodeSignal;
                    var nDeviceConfiguration = child as NodeDeviceConfiguration;
                    var nDriver = child as NodeDriver;
                    var nDevice = child as NodeDevice;
                    var nDiscreteInput = child as NodeDiscreteInput;
                    var nAnalogInput = child as NodeAnalogInput;
                    var nStringInput = child as NodeStringInput;

                    // the following logic sets one or the other, or neither
                    SignalTreeItem item = null;
                    NodeBase searchChildren = null;
                    bool sort = false;
                    var adjustedChild = child;

                    if (nPageCollection != null)
                    {
                        item = new SignalTreeItem(dlg, nPageCollection.PageCollectionName.ToString(), null);
                    }
                    else if (nPage != null)
                    {
                        var pgToUse = nPage;
                        if (pg != null && nPage.PageId == pg.PageId)
                        {
                            pgToUse = pg;
                            adjustedChild = pg;
                        }
                        item = new SignalTreeItem(dlg, pgToUse.PageName.ToString(), null);
                        sort = true;
                    }
                    else if (nInstructionGroup != null || nInstruction != null || nDiscreteInput != null || nAnalogInput != null || nStringInput != null)
                    {
                        searchChildren = adjustedChild;
                    }
                    else if (nSignal != null)
                    {
                        if (nSignal.DataType.IsOfType(dataTypeFilter))
                        {
                            item = new SignalTreeItem(dlg, nSignal.SignalName.ToString(), nSignal);
                            if (nSignal.SignalId == selectedSignalId)
                            {
                                item.IsSelected = true;
                            }
                        }
                    }
                    else if (nDeviceConfiguration != null)
                    {
                        item = new SignalTreeItem(dlg, Resources.Strings.Solution_Pad_DeviceConfigurationItem_Header, null);
                    }
                    else if (nDriver != null)
                    {
                        item = new SignalTreeItem(dlg, nDriver.DriverName.ToString(), null);
                    }
                    else if (nDevice != null)
                    {
                        item = new SignalTreeItem(dlg, nDevice.DeviceName.ToString(), null);
                    }

                    if (searchChildren != null)
                    {
                        var childItems = BuildSignalTree(dlg, searchChildren, pg, selectedSignalId, dataTypeFilter);
                        if(childItems != null)
                        {
                            foreach (var childItem in childItems)
                            {
                                items.Add(childItem);
                            }
                        }
                    }

                    if (item != null)
                    {
                        items.Add(item);
                        var childItems = BuildSignalTree(dlg, adjustedChild, pg, selectedSignalId, dataTypeFilter);
                        if (childItems != null)
                        {
                            if (sort)
                            {
                                var sorted = from c in childItems orderby c.Text select c;
                                childItems = new Collection<SignalTreeItem>();
                                foreach (var c in sorted)
                                {
                                    childItems.Add(c);
                                }
                            }
                            // make sure to have this branch of the tree expanded if the selected node is somewhere down there
                            if (childItems.Count((SignalTreeItem ti) => ti.IsSelected) > 0
                                || childItems.Count((SignalTreeItem ti) => ti.IsExpanded) > 0)
                            {
                                item.IsExpanded = true;
                            }

                            item.SetItems(childItems);
                        }
                    }
                }

                if (items.Count > 0)
                {
                    return items;
                }
                else
                {
                    return null;
                }
            }
Example #33
0
 private void ScanPage(NodeRuntimeApplication rta, NodePage page)
 {
     foreach (var instructionGroup in page.NodeInstructionGroupChildren)
     {
         ScanInstructionGroup(rta, instructionGroup);
     }
 }
Example #34
0
        private static void SignalsDepthFirst(NodeBase fromNode, string header, Dictionary<string, NodeSignal> dict, NodePage localRoot, 
            FieldDataType.DataTypeEnum dataTypeFilter)
        {
            const string SEPARATOR = "/";

            string prevHeader;
            if (header.Length == 0)
            {
                prevHeader = string.Empty;
            }
            else
            {
                prevHeader = header + SEPARATOR;
            }

            var thisSig = fromNode as NodeSignal;
            if(thisSig != null)
            {
                if (thisSig.SignalName.ToString().Length > 0) // ignore unnamed signals
                {
                    var key = prevHeader + thisSig.SignalName;
                    if (thisSig.DataType.IsOfType(dataTypeFilter))
                    {
                        if (!dict.ContainsKey(key))
                        {
                            dict.Add(key, thisSig);
                        }
                    }
                }
            }
            else
            {
                foreach (var child in fromNode.ChildCollection)
                {
                    var nPageCollection = child as NodePageCollection;
                    var nPage = child as NodePage;
                    var nInstructionGroup = child as NodeInstructionGroup;
                    var nInstruction = child as NodeInstruction;
                    var nSignal = child as NodeSignal;
                    var nDeviceConfiguration = child as NodeDeviceConfiguration;
                    var nDriver = child as NodeDriver;
                    var nDevice = child as NodeDevice;
                    var nDiscreteInput = child as NodeDiscreteInput;
                    var nAnalogInput = child as NodeAnalogInput;
                    var nStringInput = child as NodeStringInput;

                    if (nInstructionGroup != null || nInstruction != null || nDeviceConfiguration != null
                        || nDriver != null || nDiscreteInput != null || nAnalogInput != null
                        || nStringInput != null || nSignal != null)
                    {
                        SignalsDepthFirst(child, header, dict, localRoot, dataTypeFilter);
                    }
                    else if (nPageCollection != null)
                    {
                        SignalsDepthFirst(child, prevHeader + nPageCollection.PageCollectionName, dict, localRoot, dataTypeFilter);
                    }
                    else if (nPage != null)
                    {
                        string newHeader = prevHeader + nPage.PageName;
                        if (nPage == localRoot)
                        {
                            newHeader = string.Empty;
                        }
                        SignalsDepthFirst(child, newHeader, dict, localRoot, dataTypeFilter);
                    }
                    else if (nDevice != null)
                    {
                        SignalsDepthFirst(child, prevHeader + nDevice.DeviceName, dict, localRoot, dataTypeFilter);
                    }

                }
            }
        }
Example #35
0
 public Lebi_Node GetNode(string code)
 {
     return(NodePage.GetNodeByCode(code));
 }