Exemplo n.º 1
0
        public static ModelDeleteStatus Delete(int modelID)
        {
            ContModelInfo     cacheModelByID = ContModel.GetCacheModelByID(modelID);
            ModelDeleteStatus result;

            if (cacheModelByID == null)
            {
                result = ModelDeleteStatus.ModelNotExists;
            }
            else
            {
                int num = ContModel.IsModelRefing(modelID);
                if (num > 0)
                {
                    result = (ModelDeleteStatus)num;
                }
                else if (BizBase.dbo.DeleteModel <ContModelInfo>(cacheModelByID))
                {
                    ContField.DeleteByModelID(modelID);
                    BizBase.dbo.ExecSQL(" DROP TABLE " + cacheModelByID.TableName);
                    CacheUtils.Del("JsonLeeCMS_CacheForGetContModel");
                    result = ModelDeleteStatus.Success;
                }
                else
                {
                    CacheUtils.Del("JsonLeeCMS_CacheForGetContModel");
                    result = ModelDeleteStatus.Error;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        private string NodeToXml(NodeInfo node)
        {
            System.Text.StringBuilder stringBuilder  = new System.Text.StringBuilder();
            ContModelInfo             cacheModelByID = ContModel.GetCacheModelByID(node.ModelID);

            stringBuilder.Append(string.Concat(new object[]
            {
                "<Node name=\"",
                node.NodeName,
                "\" id=\"",
                node.UrlRewriteName,
                "\" model=\"",
                cacheModelByID.ModelName,
                "\" ismenu=\"",
                node.IsShowOnMenu ? 1 : 0,
                "\" tpindex=\"",
                node.NodeSetting.TemplateOfNodeIndex,
                "\" tplist=\"",
                node.NodeSetting.TemplateOfNodeList,
                "\" tpdetail=\"",
                node.NodeSetting.TemplateOfNodeContent,
                "\">"
            }));
            if (node.ChildCount > 0)
            {
                foreach (NodeInfo current in SinGooCMS.BLL.Node.GetCacheChildNode(node.AutoID))
                {
                    stringBuilder.Append(this.NodeToXml(current));
                }
            }
            stringBuilder.Append("</Node>");
            return(stringBuilder.ToString());
        }
Exemplo n.º 3
0
        public static ModelAddState Add(ContModelInfo model)
        {
            int           num = ContModel.ExistsModel(model.ModelName, model.TableName);
            ModelAddState result;

            if (num > 0)
            {
                result = (ModelAddState)num;
            }
            else
            {
                string tableName = "dbo." + model.TableName;
                int    num2      = BizBase.dbo.InsertModel <ContModelInfo>(model);
                if (num2 > 0)
                {
                    try
                    {
                        TableManager.CreateTable(tableName, "AutoID");
                        TableManager.AddTableColumn(tableName, "ContID", "INT", false, "0");
                        ContModel.AddDefaultField(num2);
                        CacheUtils.Del("JsonLeeCMS_CacheForGetContModel");
                        result = ModelAddState.Success;
                        return(result);
                    }
                    catch
                    {
                        result = ModelAddState.CreateTableError;
                        return(result);
                    }
                }
                CacheUtils.Del("JsonLeeCMS_CacheForGetContModel");
                result = ModelAddState.Error;
            }
            return(result);
        }
Exemplo n.º 4
0
        public static bool AddCustomContent(ContModelInfo model, IList <ContFieldInfo> fieldList)
        {
            string commandText = Content.GenerateSqlOfInsert(model.TableName, fieldList);

            SqlParameter[] parameters = Content.PrepareSqlParameters(fieldList);
            return(DBHelper.ExecuteNonQuery(commandText, parameters) > 0);
        }
Exemplo n.º 5
0
        public static FieldAddState Add(ContFieldInfo field)
        {
            ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(field.ModelID);
            FieldAddState result;

            if (cacheModelByID == null)
            {
                result = FieldAddState.ModelNotExists;
            }
            else
            {
                int value = BizBase.dbo.GetValue <int>(string.Concat(new object[]
                {
                    "SELECT COUNT(*) FROM cms_ContField WHERE ModelID=",
                    field.ModelID,
                    " AND FieldName='",
                    field.FieldName,
                    "'"
                }));
                if (value > 0)
                {
                    result = FieldAddState.FieldNameExists;
                }
                else
                {
                    if (BizBase.dbo.InsertModel <ContFieldInfo>(field) > 0)
                    {
                        try
                        {
                            string text = field.DataType;
                            if (string.Compare(text, "nvarchar", true) == 0)
                            {
                                object obj = text;
                                text = string.Concat(new object[]
                                {
                                    obj,
                                    "(",
                                    field.DataLength,
                                    ")"
                                });
                            }
                            TableManager.AddTableColumn(cacheModelByID.TableName, field.FieldName, text, true, field.DefaultValue);
                        }
                        catch
                        {
                            result = FieldAddState.CreateColumnError;
                            return(result);
                        }
                    }
                    CacheUtils.Del("JsonLeeCMS_CacheForGetContModel");
                    result = FieldAddState.Success;
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            ContentInfo   currentContent = base.GetCurrentContent();
            NodeInfo      cacheNodeById  = SinGooCMS.BLL.Node.GetCacheNodeById((currentContent == null) ? 0 : currentContent.NodeID);
            ContModelInfo cacheModelByID = ContModel.GetCacheModelByID((currentContent == null) ? 0 : currentContent.ModelID);

            if (currentContent == null)
            {
                base.Response.Redirect("/Include/Error/ErrorMsg_404.htm");
            }
            else if (cacheNodeById == null)
            {
                base.Alert(base.GetCaption("CMS_NodeNotExist"), base.ResolveUrl("~/"));
            }
            else if (cacheNodeById.NodeSetting.NeedLogin)
            {
                if (base.UserID.Equals(-1))
                {
                    base.Alert(base.GetCaption("CMS_NodeNeedLoginToView"), "/User/LoginExpire.html?returnurl=" + HttpUtility.UrlEncode(base.Request.RawUrl));
                }
                else
                {
                    bool   flag  = !string.IsNullOrEmpty(cacheNodeById.NodeSetting.EnableViewUGroups);
                    bool   flag2 = !string.IsNullOrEmpty(cacheNodeById.NodeSetting.EnableViewULevel);
                    string text  = StringUtils.AppendStr(cacheNodeById.NodeSetting.EnableViewUGroups, ',');
                    string text2 = StringUtils.AppendStr(cacheNodeById.NodeSetting.EnableViewULevel, ',');
                    if (ConfigUtils.GetAppSetting <string>("ViewPurviewType") == ViewPurviewType.Superior.ToString())
                    {
                        ViewPurview viewPurview = new ViewPurview();
                        new ViewPurview().GetAccessPurview(cacheNodeById, ref viewPurview);
                        flag  = !string.IsNullOrEmpty(viewPurview.GroupPurview);
                        flag2 = !string.IsNullOrEmpty(viewPurview.LevelPurview);
                        text  = StringUtils.AppendStr(viewPurview.GroupPurview, ',');
                        text2 = StringUtils.AppendStr(viewPurview.LevelPurview, ',');
                    }
                    if (flag && !text.Contains("," + base.LoginUser.GroupID.ToString() + ","))
                    {
                        this.Alert(base.GetCaption("CMS_TheUserGroupAccessDenied"), "/");
                    }
                    else if (flag2 && !text2.Contains("," + base.LoginUser.LevelID.ToString() + ","))
                    {
                        this.Alert(base.GetCaption("CMS_TheUserLevelAccessDenied"), "/");
                    }
                    else
                    {
                        this.ShowTemplate(cacheNodeById, currentContent);
                    }
                }
            }
            else
            {
                this.ShowTemplate(cacheNodeById, currentContent);
            }
        }
Exemplo n.º 7
0
        public static bool Delete(int fieldID)
        {
            ContFieldInfo dataById  = ContField.GetDataById(fieldID);
            ContModelInfo dataById2 = ContModel.GetDataById(dataById.ModelID);

            if (BizBase.dbo.DeleteModel <ContFieldInfo>(dataById))
            {
                TableManager.DropTableColumn(dataById2.TableName, dataById.FieldName);
            }
            CacheUtils.Del("JsonLeeCMS_CacheForGetContModel");
            return(true);
        }
Exemplo n.º 8
0
        private void InitForModify()
        {
            ContModelInfo dataById = ContModel.GetDataById(base.OpID);

            this.TextBox1.Text = dataById.ModelName;
            this.TextBox2.Text = dataById.TableName.Split(new char[]
            {
                '_'
            })[2];
            this.TextBox3.Text    = dataById.ModelDesc;
            this.TextBox2.Enabled = false;
        }
Exemplo n.º 9
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.intModelID  = WebUtils.GetQueryInt("ModelID");
     this.modelParent = ContModel.GetCacheModelByID(this.intModelID);
     if (this.modelParent == null)
     {
         base.ShowMsg("没有找到内容模型信息");
     }
     else if (!base.IsPostBack)
     {
         this.BindData();
     }
 }
Exemplo n.º 10
0
        protected void lnk_Delete_Click(object sender, System.EventArgs e)
        {
            if (!base.IsAuthorizedOp(ActionType.Delete.ToString()))
            {
                base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền");
            }
            else
            {
                int           @int           = WebUtils.GetInt((sender as LinkButton).CommandArgument);
                ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(@int);
                if (cacheModelByID == null)
                {
                    base.ShowAjaxMsg(this.UpdatePanel1, "Những thông tin này không được tìm thấy, các dữ liệu không tồn tại hoặc đã bị xóa");
                }
                else
                {
                    ModelDeleteStatus modelDeleteStatus  = ContModel.Delete(@int);
                    ModelDeleteStatus modelDeleteStatus2 = modelDeleteStatus;
                    switch (modelDeleteStatus2)
                    {
                    case ModelDeleteStatus.Error:
                        base.ShowAjaxMsg(this.UpdatePanel1, "删除内容模型失败");
                        break;

                    case ModelDeleteStatus.ModelNotExists:
                        base.ShowAjaxMsg(this.UpdatePanel1, "模型不存在或者已经被删除");
                        break;

                    case ModelDeleteStatus.NodesRef:
                        base.ShowAjaxMsg(this.UpdatePanel1, "无法删除,模型正被栏目引用");
                        break;

                    case ModelDeleteStatus.ContentRef:
                        base.ShowAjaxMsg(this.UpdatePanel1, "无法删除,模型正被内容引用");
                        break;

                    default:
                        if (modelDeleteStatus2 == ModelDeleteStatus.Success)
                        {
                            this.BindData();
                            PageBase.log.AddEvent(base.LoginAccount.AccountName, "删除内容模型[" + cacheModelByID.ModelName + "] thành công");
                            base.ShowAjaxMsg(this.UpdatePanel1, "删除内容模型成功");
                        }
                        break;
                    }
                }
            }
        }
Exemplo n.º 11
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.intModelID  = WebUtils.GetQueryInt("ModelID");
     this.modelParent = ContModel.GetCacheModelByID(this.intModelID);
     if (this.modelParent == null)
     {
         base.ClientScript.RegisterClientScriptBlock(base.GetType(), "alertandredirect", "<script>alert('Không tìm thấy kiểu dữ liệu信息');history.go(-1);</script>");
     }
     else
     {
         this.labModelName.Text = this.modelParent.ModelName;
         if (base.IsEdit && !base.IsPostBack)
         {
             this.InitForModify();
         }
     }
 }
Exemplo n.º 12
0
        public static ContModelInfo GetCacheModelByID(int modelID)
        {
            ContModelInfo         result         = null;
            IList <ContModelInfo> cacheModelList = ContModel.GetCacheModelList();

            if (cacheModelList != null && cacheModelList.Count > 0)
            {
                foreach (ContModelInfo current in cacheModelList)
                {
                    if (current.AutoID == modelID)
                    {
                        result = current;
                        break;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 13
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.strType  = WebUtils.GetQueryString("ListType", "Normal");
     this.contNode = SinGooCMS.BLL.Node.GetCacheNodeById(WebUtils.GetQueryInt("NodeID"));
     if (base.IsEdit)
     {
         this.contInit = SinGooCMS.BLL.Content.GetContentById(base.OpID);
         this.contNode = SinGooCMS.BLL.Node.GetCacheNodeById((this.contInit == null) ? 0 : this.contInit.NodeID);
     }
     if (this.contNode == null)
     {
         base.ShowMsgAndRdirect("没有找到栏目信息", string.Concat(new object[]
         {
             "ContentList.aspx?CatalogID=",
             base.CurrentCatalogID,
             "&Module=",
             base.CurrentModuleCode,
             "&action=View&ListType=",
             this.strType
         }));
     }
     else if (base.IsEdit && this.contInit == null)
     {
         base.ShowMsgAndRdirect("没有找到内容信息", string.Concat(new object[]
         {
             "ContentList.aspx?CatalogID=",
             base.CurrentCatalogID,
             "&Module=",
             base.CurrentModuleCode,
             "&action=View&ListType=",
             this.strType
         }));
     }
     else
     {
         this.contModel = (base.IsEdit ? ContModel.GetCacheModelByID(this.contInit.ModelID) : ContModel.GetCacheModelByID(this.contNode.ModelID));
         if (!base.IsPostBack)
         {
             this.BindData();
         }
     }
 }
Exemplo n.º 14
0
        public static bool Update(ContFieldInfo field)
        {
            ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(field.ModelID);
            ContFieldInfo dataById       = ContField.GetDataById(field.AutoID);
            bool          result;

            if (BizBase.dbo.UpdateModel <ContFieldInfo>(field))
            {
                if (!dataById.IsSystem)
                {
                    try
                    {
                        string text = field.DataType;
                        if (string.Compare(text, "nvarchar", true) == 0)
                        {
                            object obj = text;
                            text = string.Concat(new object[]
                            {
                                obj,
                                "(",
                                field.DataLength,
                                ")"
                            });
                        }
                        TableManager.AlterTableColumn(cacheModelByID.TableName, dataById.FieldName, field.FieldName, text, true, field.DefaultValue);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                CacheUtils.Del("JsonLeeCMS_CacheForGetContModel");
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 15
0
        protected void btnok_Click(object sender, System.EventArgs e)
        {
            if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
            {
                base.ShowMsg("Không có thẩm quyền");
            }
            else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
            {
                base.ShowMsg("Không có thẩm quyền");
            }
            else
            {
                ContModelInfo contModelInfo = new ContModelInfo();
                if (base.IsEdit)
                {
                    contModelInfo = ContModel.GetCacheModelByID(base.OpID);
                }
                contModelInfo.ModelName = WebUtils.GetString(this.TextBox1.Text);
                contModelInfo.TableName = "cms_C_" + WebUtils.GetString(this.TextBox2.Text);
                contModelInfo.ModelDesc = WebUtils.GetString(this.TextBox3.Text);
                contModelInfo.IsUsing   = true;
                contModelInfo.Creator   = base.LoginAccount.AccountName;
                if (string.IsNullOrEmpty(contModelInfo.ModelName))
                {
                    base.ShowMsg("模型名称不能为空");
                }
                else if (string.IsNullOrEmpty(this.TextBox2.Text))
                {
                    base.ShowMsg("数据表名不能为空");
                }
                else
                {
                    if (base.Action.Equals(ActionType.Add.ToString()))
                    {
                        contModelInfo.AutoTimeStamp = System.DateTime.Now;
                        ModelAddState modelAddState  = ContModel.Add(contModelInfo);
                        ModelAddState modelAddState2 = modelAddState;
                        switch (modelAddState2)
                        {
                        case ModelAddState.Error:
                            base.ShowMsg("添加模型失败");
                            break;

                        case ModelAddState.ModelNameExists:
                            base.ShowMsg("模型名称已经存在");
                            break;

                        case ModelAddState.TableNameIsUsing:
                            base.ShowMsg("已经存在相同的自定义表名称");
                            break;

                        case ModelAddState.TableExists:
                            base.ShowMsg("自定义表已经存在");
                            break;

                        case ModelAddState.CreateTableError:
                            base.ShowMsg("创建自定义表失败");
                            break;

                        default:
                            if (modelAddState2 == ModelAddState.Success)
                            {
                                PageBase.log.AddEvent(base.LoginAccount.AccountName, "添加模型[" + contModelInfo.ModelName + "] thành công");
                                MessageUtils.DialogCloseAndParentReload(this);
                            }
                            break;
                        }
                    }
                    if (base.Action.Equals(ActionType.Modify.ToString()))
                    {
                        if (ContModel.Update(contModelInfo))
                        {
                            PageBase.log.AddEvent(base.LoginAccount.AccountName, "修改模型[" + contModelInfo.ModelName + "] thành công");
                            MessageUtils.DialogCloseAndParentReload(this);
                        }
                        else
                        {
                            base.ShowMsg("修改模型失败");
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void AddNode(XmlNode node, int intParentID)
        {
            NodeInfo nodeInfo = (from p in SinGooCMS.BLL.Node.GetCacheAllNodes()
                                 where p.AutoID.Equals(intParentID)
                                 select p).FirstOrDefault <NodeInfo>();
            string strModelName = "普通文章";

            if (node.Attributes["model"] != null)
            {
                strModelName = node.Attributes["model"].Value.Trim();
            }
            ContModelInfo modelByName         = ContModel.GetModelByName(strModelName);
            string        templateOfNodeIndex = "栏目首页.html";

            if (node.Attributes["tpindex"] != null)
            {
                templateOfNodeIndex = node.Attributes["tpindex"].Value.Trim();
            }
            else if (nodeInfo != null)
            {
                templateOfNodeIndex = nodeInfo.NodeSetting.TemplateOfNodeIndex;
            }
            string templateOfNodeList = "栏目列表页.html";

            if (node.Attributes["tplist"] != null)
            {
                templateOfNodeList = node.Attributes["tplist"].Value.Trim();
            }
            else if (nodeInfo != null)
            {
                templateOfNodeList = nodeInfo.NodeSetting.TemplateOfNodeList;
            }
            string templateOfNodeContent = "栏目详情页.html";

            if (node.Attributes["tpdetail"] != null)
            {
                templateOfNodeContent = node.Attributes["tpdetail"].Value.Trim();
            }
            else if (nodeInfo != null)
            {
                templateOfNodeContent = nodeInfo.NodeSetting.TemplateOfNodeContent;
            }
            if (node.Attributes["name"] != null && modelByName != null)
            {
                string nodeName       = node.Attributes["name"].Value.Trim();
                string urlRewriteName = StringUtils.GetNewFileName();
                if (node.Attributes["id"] != null)
                {
                    urlRewriteName = node.Attributes["id"].Value.Trim();
                }
                bool isShowOnMenu = false;
                if (node.Attributes["ismenu"] != null)
                {
                    isShowOnMenu = (node.Attributes["ismenu"].Value.Trim() == "1");
                }
                NodeInfo nodeInfo2 = new NodeInfo();
                nodeInfo2.NodeName       = nodeName;
                nodeInfo2.UrlRewriteName = urlRewriteName;
                nodeInfo2.ParentID       = intParentID;
                nodeInfo2.ModelID        = modelByName.AutoID;
                nodeInfo2.NodeBanner     = string.Empty;
                nodeInfo2.SeoKey         = nodeInfo2.NodeName;
                nodeInfo2.SeoDescription = nodeInfo2.NodeName;
                nodeInfo2.Remark         = string.Empty;
                nodeInfo2.ItemPageSize   = 10;
                nodeInfo2.IsShowOnMenu   = isShowOnMenu;
                nodeInfo2.IsShowOnNav    = false;
                nodeInfo2.IsTop          = false;
                nodeInfo2.IsRecommend    = false;
                nodeInfo2.CustomLink     = string.Empty;
                nodeInfo2.Lang           = base.cultureLang;
                nodeInfo2.AutoTimeStamp  = System.DateTime.Now;
                nodeInfo2.NodeSetting.EnableAddInParent = true;
                nodeInfo2.NodeSetting.AllowComment      = true;
                nodeInfo2.NodeSetting.NeedLogin         = false;
                string empty = string.Empty;
                nodeInfo2.NodeSetting.EnableViewUGroups = empty;
                string empty2 = string.Empty;
                nodeInfo2.NodeSetting.EnableViewULevel      = empty2;
                nodeInfo2.NodeSetting.TemplateOfNodeIndex   = templateOfNodeIndex;
                nodeInfo2.NodeSetting.TemplateOfNodeList    = templateOfNodeList;
                nodeInfo2.NodeSetting.TemplateOfNodeContent = templateOfNodeContent;
                int num = 0;
                if (SinGooCMS.BLL.Node.Add(nodeInfo2, out num) == NodeAddStatus.Success)
                {
                    ContentInfo entity = new ContentInfo
                    {
                        NodeID        = num,
                        NodeName      = nodeInfo2.NodeName,
                        ModelID       = modelByName.AutoID,
                        TableName     = modelByName.TableName,
                        Title         = "栏目(" + nodeInfo2.NodeName + ")的测试标题",
                        Summary       = "栏目(" + nodeInfo2.NodeName + ")的测试摘要",
                        Content       = "栏目(" + nodeInfo2.NodeName + ")的测试内容",
                        Sort          = SinGooCMS.BLL.Content.MaxSort + 1,
                        Lang          = base.cultureLang,
                        Inputer       = base.LoginAccount.AccountName,
                        Status        = 99,
                        AutoTimeStamp = System.DateTime.Now
                    };
                    int num2 = SinGooCMS.BLL.Content.Add(entity);
                    if (num2 > 0)
                    {
                        System.Collections.Generic.IList <ContFieldInfo> customFieldListByModelID = ContField.GetCustomFieldListByModelID(modelByName.AutoID);
                        foreach (ContFieldInfo current in customFieldListByModelID)
                        {
                            if (current.FieldName == "ContID")
                            {
                                current.Value = num2.ToString();
                            }
                            else
                            {
                                current.Value = string.Empty;
                            }
                        }
                        SinGooCMS.BLL.Content.AddCustomContent(modelByName, customFieldListByModelID);
                    }
                    if (node.HasChildNodes)
                    {
                        foreach (XmlNode node2 in node.ChildNodes)
                        {
                            this.AddNode(node2, num);
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
 public static bool Update(ContModelInfo model)
 {
     CacheUtils.Del("JsonLeeCMS_CacheForGetContModel");
     return(BizBase.dbo.UpdateModel <ContModelInfo>(model));
 }
Exemplo n.º 18
0
        public static bool CopyContent(int intContID)
        {
            ContentInfo dataById = Content.GetDataById(intContID);
            bool        result;

            if (dataById != null)
            {
                ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(dataById.ModelID);
                string        strSQL         = string.Concat(new object[]
                {
                    "INSERT INTO cms_Content (     NodeID,     NodeName,     ModelID,     TableName,     Title,     SubTitle,     Summary,     Author,     Editor,     Source,     SourceUrl,     Content,     Attachment,     TagKey,     ContentImage,     SeoKey,     SeoDescription,     Lang,     Inputer,     Sort,     Status,     AutoTimeStamp ) SELECT      NodeID,     NodeName,     ModelID,     TableName,     '复制:'+Title,     SubTitle,     Summary,     Author,     Editor,     Source,     SourceUrl,     Content,     Attachment,     TagKey,     ContentImage,     SeoKey,     SeoDescription,     Lang,     '",
                    Account.GetLoginAccount().AccountName,
                    "',    (SELECT MAX(Sort)+1 FROM cms_Content) AS CurrSort,     0,     getdate() FROM cms_Content WHERE AutoID=",
                    intContID,
                    ";if @@rowcount>0 select @@IDENTITY"
                });
                object @object = BizBase.dbo.GetObject(strSQL);
                int    num     = (@object == null) ? 0 : Convert.ToInt32(@object);
                if (num > 0)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append(" INSERT INTO " + dataById.TableName + " ( ");
                    IList <ContFieldInfo> customFieldListByModelID = ContField.GetCustomFieldListByModelID(cacheModelByID.AutoID);
                    for (int i = 0; i < customFieldListByModelID.Count; i++)
                    {
                        if (customFieldListByModelID[i].FieldName != "AutoID")
                        {
                            if (i == customFieldListByModelID.Count - 1)
                            {
                                stringBuilder.Append(customFieldListByModelID[i].FieldName);
                            }
                            else
                            {
                                stringBuilder.Append(customFieldListByModelID[i].FieldName + ",");
                            }
                        }
                    }
                    stringBuilder.Append(" ) ");
                    stringBuilder.Append(" SELECT ");
                    for (int i = 0; i < customFieldListByModelID.Count; i++)
                    {
                        if (customFieldListByModelID[i].FieldName != "AutoID")
                        {
                            if (i == customFieldListByModelID.Count - 1)
                            {
                                if (customFieldListByModelID[i].FieldName.Equals("ContID"))
                                {
                                    stringBuilder.Append(num.ToString());
                                }
                                else
                                {
                                    stringBuilder.Append(customFieldListByModelID[i].FieldName);
                                }
                            }
                            else if (customFieldListByModelID[i].FieldName.Equals("ContID"))
                            {
                                stringBuilder.Append(num.ToString() + ",");
                            }
                            else
                            {
                                stringBuilder.Append(customFieldListByModelID[i].FieldName + ",");
                            }
                        }
                    }
                    stringBuilder.Append(string.Concat(new object[]
                    {
                        " FROM ",
                        dataById.TableName,
                        " WHERE ContID=",
                        dataById.AutoID
                    }));
                    result = BizBase.dbo.ExecSQL(stringBuilder.ToString());
                    return(result);
                }
            }
            result = false;
            return(result);
        }
Exemplo n.º 19
0
        public static bool UpdateContent(ContentInfo content, Dictionary <string, ContFieldInfo> dicField)
        {
            bool result;

            if (content == null)
            {
                result = false;
            }
            else
            {
                ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(content.ModelID);
                if (cacheModelByID == null)
                {
                    result = false;
                }
                else
                {
                    content.Title = Content.GetStringFromDic("Title", dicField);
                    if (string.IsNullOrEmpty(content.Title))
                    {
                        content.Title = "默认的标题";
                    }
                    content.SubTitle       = Content.GetStringFromDic("SubTitle", dicField);
                    content.Summary        = Content.GetStringFromDic("Summary", dicField);
                    content.Author         = Content.GetStringFromDic("Author", dicField);
                    content.Editor         = Content.GetStringFromDic("Editor", dicField);
                    content.Source         = Content.GetStringFromDic("Source", dicField);
                    content.SourceUrl      = Content.GetStringFromDic("SourceUrl", dicField);
                    content.Content        = Content.GetStringFromDic("Content", dicField);
                    content.TagKey         = Content.GetStringFromDic("TagKey", dicField);
                    content.ContentImage   = Content.GetStringFromDic("ContentImage", dicField);
                    content.Attachment     = Content.GetStringFromDic("Attachment", dicField);
                    content.RelateContent  = Content.GetStringFromDic("RelateContent", dicField);
                    content.SeoKey         = Content.GetStringFromDic("SeoKey", dicField);
                    content.SeoDescription = Content.GetStringFromDic("SeoDescription", dicField);
                    content.IsTop          = Content.GetBoolFromDic("IsTop", dicField, false);
                    content.IsRecommend    = Content.GetBoolFromDic("IsRecommend", dicField, false);
                    content.IsNew          = Content.GetBoolFromDic("IsNew", dicField, false);
                    content.TemplateFile   = Content.GetStringFromDic("TemplateFile", dicField);
                    content.Hit            = Content.GetIntFromDic("Hit", dicField, 0);
                    content.Sort           = Content.GetIntFromDic("Sort", dicField, 999);
                    content.AutoTimeStamp  = Content.GetDateTimeFromDic("AutoTimeStamp", dicField, new DateTime(1900, 1, 1));
                    Content.Update(content);
                    IList <ContFieldInfo> customFieldListByModelID = ContField.GetCustomFieldListByModelID(content.ModelID);
                    foreach (ContFieldInfo current in customFieldListByModelID)
                    {
                        if (current.FieldName == "ContID")
                        {
                            current.Value = content.AutoID.ToString();
                        }
                        else
                        {
                            current.Value = Content.GetStringFromDic(current.FieldName, dicField);
                        }
                    }
                    if (Content.ExistsCustomTableData(cacheModelByID.TableName, content.AutoID))
                    {
                        Content.UpdateCustomContent(content.AutoID, content.TableName, customFieldListByModelID);
                    }
                    else
                    {
                        Content.AddCustomContent(cacheModelByID, customFieldListByModelID);
                    }
                    result = true;
                }
            }
            return(result);
        }
Exemplo n.º 20
0
        public static int Add(ContentInfo content, Dictionary <string, ContFieldInfo> dicField)
        {
            NodeInfo cacheNodeById = Node.GetCacheNodeById(content.NodeID);
            int      result;

            if (cacheNodeById == null)
            {
                result = 0;
            }
            else
            {
                ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(cacheNodeById.ModelID);
                if (cacheModelByID == null)
                {
                    result = 0;
                }
                else
                {
                    content.NodeName  = cacheNodeById.NodeName;
                    content.ModelID   = cacheModelByID.AutoID;
                    content.TableName = cacheModelByID.TableName;
                    content.Title     = Content.GetStringFromDic("Title", dicField);
                    if (string.IsNullOrEmpty(content.Title))
                    {
                        content.Title = "默认的标题";
                    }
                    content.SubTitle       = Content.GetStringFromDic("SubTitle", dicField);
                    content.Summary        = Content.GetStringFromDic("Summary", dicField);
                    content.Author         = Content.GetStringFromDic("Author", dicField);
                    content.Editor         = Content.GetStringFromDic("Editor", dicField);
                    content.Source         = Content.GetStringFromDic("Source", dicField);
                    content.SourceUrl      = Content.GetStringFromDic("SourceUrl", dicField);
                    content.Content        = Content.GetStringFromDic("Content", dicField);
                    content.TagKey         = Content.GetStringFromDic("TagKey", dicField);
                    content.ContentImage   = Content.GetStringFromDic("ContentImage", dicField);
                    content.Attachment     = Content.GetStringFromDic("Attachment", dicField);
                    content.RelateContent  = Content.GetStringFromDic("RelateContent", dicField);
                    content.SeoKey         = Content.GetStringFromDic("SeoKey", dicField);
                    content.SeoDescription = Content.GetStringFromDic("SeoDescription", dicField);
                    content.IsTop          = Content.GetBoolFromDic("IsTop", dicField, false);
                    content.IsRecommend    = Content.GetBoolFromDic("IsRecommend", dicField, false);
                    content.IsNew          = Content.GetBoolFromDic("IsNew", dicField, false);
                    content.TemplateFile   = Content.GetStringFromDic("TemplateFile", dicField);
                    content.Hit            = Content.GetIntFromDic("Hit", dicField, 0);
                    content.Sort           = Content.GetIntFromDic("Sort", dicField, 999);
                    content.Inputer        = Account.GetLoginAccount().AccountName;
                    content.Lang           = JObject.cultureLang;
                    if (dicField.ContainsKey("AutoTimeStamp"))
                    {
                        content.AutoTimeStamp = Content.GetDateTimeFromDic("AutoTimeStamp", dicField, DateTime.Now);
                    }
                    else
                    {
                        content.AutoTimeStamp = DateTime.Now;
                    }
                    int num = Content.Add(content);
                    IList <ContFieldInfo> customFieldListByModelID = ContField.GetCustomFieldListByModelID(cacheModelByID.AutoID);
                    foreach (ContFieldInfo current in customFieldListByModelID)
                    {
                        if (current.FieldName == "ContID")
                        {
                            current.Value = num.ToString();
                        }
                        else
                        {
                            current.Value = Content.GetStringFromDic(current.FieldName, dicField);
                        }
                    }
                    Content.AddCustomContent(cacheModelByID, customFieldListByModelID);
                    result = num;
                }
            }
            return(result);
        }