Exemple #1
0
        /// <summary>
        /// 检查各项是否已经创建
        /// </summary>
        void Exist()
        {
            IDataBaseHelper helper = DataBaseHelperFactory.Create();
            StringBuilder   sb     = new StringBuilder();

            sb.Append("{\"modelName\":\"" + ModelInfo.ModelName + "\",\"Data\":[");

            #region 检查部件
            //部件
            int    widgetCount  = 0;
            string viewPath     = ModelHelper.GetWidgetDirectory(modelInfo, "View");
            string listPath     = ModelHelper.GetWidgetDirectory(modelInfo, "List");
            string pageListPath = ModelHelper.GetWidgetDirectory(modelInfo, "PagedList");
            if (Directory.Exists(viewPath))
            {
                widgetCount++;
            }
            if (Directory.Exists(listPath))
            {
                widgetCount++;
            }
            if (Directory.Exists(pageListPath))
            {
                widgetCount++;
            }
            //存在至少一个部件
            if (widgetCount > 0)
            {
                sb.Append("{\"name\":\"createWidget\",\"exist\":true},");
            }
            else
            {
                sb.Append("{\"name\":\"createWidget\",\"exist\":false},");
            }
            #endregion

            if (isArticle)
            {
                #region 检查表结构
                int rowCount = 0;
                try
                {
                    rowCount = helper.Count(ModelInfo.Name, "");
                    sb.Append("{\"name\":\"createTable\",\"exist\":true},");
                }
                catch
                {
                    sb.Append("{\"name\":\"createTable\",\"exist\":false},");
                }

                #endregion

                #region 检查左侧菜单
                MenuHelper MenuHelper        = HelperFactory.Instance.GetHelper <MenuHelper>();
                We7.CMS.Common.MenuItem item = MenuHelper.GetMenuItemByTitle(ModelInfo.Label + "管理");
                if (item != null && !string.IsNullOrEmpty(item.ID))
                {
                    sb.Append("{\"name\":\"addLeftMenu\",\"exist\":true},");
                }
                else
                {
                    sb.Append("{\"name\":\"addLeftMenu\",\"exist\":false},");
                }
                #endregion

                #region 检查布局

                string layoutPath = ModelHelper.GetModelLayoutDirectory(ModelInfo.ModelName) + "GenerateLayout.ascx";
                if (File.Exists(layoutPath))
                {
                    layoutPath = String.Format("{0}/{1}/{2}/{3}", ModelConfig.ModelsDirectory, ModelInfo.GroupName, ModelInfo.Name, "GenerateLayout.ascx");
                    EditInfo entity = ModelInfo.Layout.Panels["edit"].EditInfo;
                    sb.Append("{\"name\":\"createLayout\",\"exist\":true,\"path\":\"" + layoutPath + "\"},");

                    //ModelInfo.Layout.Panels["edit"].EditInfo.Layout;
                    if (!string.IsNullOrEmpty(entity.Layout))
                    {
                        chkAE.Checked = true;
                    }

                    if (!string.IsNullOrEmpty(entity.ViewerLayout))
                    {
                        chkView.Checked = true;
                    }

                    if (!string.IsNullOrEmpty(entity.UcLayout))
                    {
                        chkUC.Checked = true;
                    }
                }
                else
                {
                    sb.Append("{\"name\":\"createLayout\",\"exist\":false},");
                }


                #endregion
            }
            sb.Append("]}");
            strScript = sb.ToString();
            strScript = strScript.Remove(strScript.LastIndexOf(","), 1);

            strScript = new JavaScriptSerializer().Serialize(strScript);
        }