Exemplo n.º 1
0
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            InstallationManager im = Installer;

            try
            {
                cvRootAndStart.IsValid = ddlRoot.SelectedIndex > 0 && ddlStartPage.SelectedIndex > 0;
                cvRoot.IsValid         = true;
                if (!cvRootAndStart.IsValid)
                {
                    return;
                }

                ContentItem root      = im.InsertRootNode(Type.GetType(ddlRoot.SelectedValue), "root", "Root Node");
                ContentItem startPage = im.InsertStartPage(Type.GetType(ddlStartPage.SelectedValue), root, "start", "Start Page");

                if (startPage.ID == Status.StartPageID && root.ID == Status.RootItemID)
                {
                    ltRootNode.Text = "<span class='ok'>Root and start pages inserted.</span>";
                    Installer.UpdateStatus(SystemStatusLevel.UpAndRunning);
                }
                else
                {
                    ltRootNode.Text = string.Format(
                        "<span class='warning'>Start page inserted but you must update web.config with root item id: <b>{0}</b> and start page id: <b>{1}</b></span>", root.ID, startPage.ID);
                    phSame.Visible   = false;
                    phDiffer.Visible = true;
                    RootId           = root.ID;
                    StartId          = startPage.ID;
                }
                phDiffer.DataBind();
            }
            catch (Exception ex)
            {
                ltRootNode.Text = string.Format("<span class='warning'>{0}</span><!--\n{1}\n-->", ex.Message, ex);
            }
        }