Пример #1
0
        public static void resetUrl(double columnId, double id)
        {
            ColumnInfo    column  = ColumnClass.get(columnId);
            ColumnInfo    channel = ColumnClass.get(column.rootId);
            StringBuilder url     = new StringBuilder(BaseConfig.contentUrlTemplate);

            /*
             * url.Replace("$id", "'+convert(varchar(20),convert(decimal(18,0),id))+'");
             * url.Replace("$create.year", "'+convert(varchar(4),year(createdate))+'");
             * url.Replace("$create.month", "'+right('00'+cast(month(createdate) as varchar),2)+'");
             * url.Replace("$create.day", "'+right('00'+cast(day(createdate) as varchar),2)+'");
             * url.Replace("$column.dirPath", column.dirPath);
             * url.Replace("$column.dirName", column.dirName);
             * url.Replace("$channel.dirName", channel.dirName);
             * url.Replace(".$extension", "");
             * string sql = "update maintable set url='" + url + "' where id=@id";
             */

            url.Replace("$id", "',id,'");
            url.Replace("$create.year", "',DATE_FORMAT(createdate,'%Y'),'");
            url.Replace("$create.month", "',DATE_FORMAT(createdate,'%m'),'");
            url.Replace("$create.day", "',DATE_FORMAT(createdate,'%d'),'");
            url.Replace("$column.dirPath", column.dirPath);
            url.Replace("$column.dirName", column.dirName);
            url.Replace("$channel.dirName", channel.dirName);
            url.Replace(".$extension", "");
            string sql = "update maintable set url=CONCAT('" + url + "') where id=@id";

            Sql.ExecuteNonQuery(sql, new MySqlParameter[] { new MySqlParameter("id", id) });
        }
Пример #2
0
        public static ReturnValue resetContentUrl(double id)
        {
            ReturnValue   err     = new ReturnValue();
            ColumnInfo    column  = ColumnClass.get(id);
            ColumnInfo    channel = column.classId == 7 ? column : ColumnClass.get(column.classId);
            StringBuilder url     = new StringBuilder(BaseConfig.contentUrlTemplate);

            url.Replace(".$extension", "");
            //url.Replace("$id", "'+convert(varchar(20),convert(decimal(18,0),id))+'");
            //url.Replace("$create.year", "'+convert(varchar(4),year(createdate))+'");
            //url.Replace("$create.month", "'+right('00'+cast(month(createdate) as varchar),2)+'");
            //url.Replace("$create.day", "'+right('00'+cast(day(createdate) as varchar),2)+'");
            url.Replace("$id", "',id,'");
            url.Replace("$create.year", "',DATE_FORMAT(createdate,'%Y'),'");
            url.Replace("$create.month", "',DATE_FORMAT(createdate,'%m'),'");
            url.Replace("$create.day", "',DATE_FORMAT(createdate,'%d'),'");
            url.Replace("$column.dirPath", column.dirPath);
            url.Replace("$column.dirName", column.dirName);
            url.Replace("$channel.dirName", channel.dirName);
            string sql = "update maintable set url=CONCAT('" + url + "'),rootId=@rootId,moduleId=@moduleId where classId=@classId";

            Sql.ExecuteNonQuery(sql, new MySqlParameter[] {
                new MySqlParameter("classId", id),
                new MySqlParameter("rootId", column.rootId),
                new MySqlParameter("moduleId", column.moduleId)
            });
            return(err);
        }
Пример #3
0
        public static ReturnValue moveData(string ids, double classId)
        {
            ReturnValue info = new ReturnValue();

            string[] id = ids.Split(',');
            try
            {
                for (int i = 0; i < id.Length; i++)
                {
                    double.Parse(id[i]);
                }
            }
            catch
            {
                info.errNo  = -1;
                info.errMsg = "参数不合法";
                return(info);
            }
            ColumnInfo column = ColumnClass.get(classId);

            if (column == null)
            {
                info.errNo  = -1;
                info.errMsg = "栏目不存在";
                return(info);
            }
            ColumnInfo    channel = ColumnClass.get(column.rootId);
            StringBuilder url     = new StringBuilder(BaseConfig.contentUrlTemplate);

            /*url.Replace("$id", "'+convert(varchar(20),convert(decimal(18,0),id))+'");
             * url.Replace("$create.year", "'+convert(varchar(4),year(createdate))+'");
             * url.Replace("$create.month", "'+right('00'+cast(month(createdate) as varchar),2)+'");
             * url.Replace("$create.day", "'+right('00'+cast(day(createdate) as varchar),2)+'");*/
            url.Replace("$id", "',id,'");
            url.Replace("$create.year", "',DATE_FORMAT(createdate,'%Y'),'");
            url.Replace("$create.month", "',DATE_FORMAT(createdate,'%m'),'");
            url.Replace("$create.day", "',DATE_FORMAT(createdate,'%d'),'");
            url.Replace("$column.dirPath", column.dirPath);
            url.Replace("$column.dirName", column.dirName);
            url.Replace("$channel.dirName", channel.dirName);
            url.Replace(".$extension", "");
            Sql.ExecuteNonQuery("update maintable set  classId=@classId,rootId=@rootId,moduleId=@moduleId, url=CONCAT('" + url + "')  where id in (" + ids + ")", new MySqlParameter[] { new MySqlParameter("classId", classId), new MySqlParameter("rootId", column.rootId), new MySqlParameter("moduleId", column.moduleId) });

            return(info);
        }
Пример #4
0
        public static ReturnValue editDirName(double id, string dirName, UserInfo user)
        {
            ReturnValue err   = new ReturnValue();
            ColumnInfo  info  = ColumnClass.get(id);
            int         count = int.Parse(Sql.ExecuteScalar("select count(1) from class where id<>@id and classId=@classId and dirName=@dirName", new MySqlParameter[] {
                new MySqlParameter("id", info.id),
                new MySqlParameter("classId", info.classId),
                new MySqlParameter("dirName", dirName.ToLower())
            }).ToString());

            if (count > 0)
            {
                err.errNo  = -1;
                err.errMsg = "所在栏目下目录名已存在";
                return(err);
            }
            Sql.ExecuteNonQuery("update class set dirName=@dirName where id=@id", new MySqlParameter[] {
                new MySqlParameter("id", id),
                new MySqlParameter("dirName", dirName)
            });
            return(err);
        }
Пример #5
0
        public static ReturnValue editDirName(double id, string dirName, UserInfo user)
        {
            ReturnValue err   = new ReturnValue();
            ColumnInfo  info  = ColumnClass.get(id);
            int         count = DAL.M("class").Where(new object [, ] {
                { "id", "<>", info.id },
                { "classId", "=", info.classId },
                { "dirName", "=", dirName.ToLower() },
            }).Count();

            if (count > 0)
            {
                err.errNo  = -1;
                err.errMsg = "所在栏目下目录名已存在";
                return(err);
            }
            DAL.M("class").Where(new object[, ] {
                { "id", "=", id }
            }).Update(new Dictionary <string, object> {
                { "dirName", dirName }
            });
            return(err);
        }
Пример #6
0
        public double insert(double id)
        {
            if (parentColumn == null)
            {
                throw new Exception("未指定栏目或栏目不存在");
            }
            columnConfig = ColumnClass.getConfig(parentColumn.id);
            #region 标题重复处理
            if (!columnConfig.titleRepeat)//标题不允许重复
            {
                string where = "title=@title";
                if (columnConfig.isModule)
                {
                    where += " and moduleId=@moduleId";
                }
                else if (columnConfig.isRoot)
                {
                    where += " and rootId=@rootId";
                }
                else
                {
                    where += " and classId in (" + columnConfig.childId + ")";
                }
                int c = int.Parse(Sql.ExecuteScalar("select count(1) from maintable where " + where, new MySqlParameter[] {
                    new MySqlParameter("title", title),
                    new MySqlParameter("moduleId", parentColumn.moduleId),
                    new MySqlParameter("rootId", parentColumn.rootId)
                }).ToString());
                if (c > 0)
                {
                    throw new Exception("标题已存在");
                }
            }
            #endregion
            //if (classId != null) size = API.getThumbnailSize(classId);
            string          datatypeclassid = null;
            double          dataTypeId      = 0;
            MySqlDataReader rsv             = Sql.ExecuteReader("select id,classid,tablestructure from datatype where tablename='" + tableName + "'");
            if (rsv.Read())
            {
                dataTypeId = rsv.GetDouble(0); datatypeclassid = rsv[1].ToString();
            }
            rsv.Close();
            System.Text.StringBuilder str  = new System.Text.StringBuilder();
            System.Text.StringBuilder str1 = new System.Text.StringBuilder();
            this.addField("id", id);
            this.addField("createdate", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            this.addField("updatedate", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            this.addField("datatypeId", dataTypeId);
            this.addField("moduleId", parentColumn.moduleId);
            this.addField("rootId", parentColumn.rootId);
            this.addField("userId", _user.id);
            //this.addField("orderId",orderId);

            string field1_1 = "", field1_2 = "", field2_1 = "id", field2_2 = "@id";
            int    picFieldIndex = -1;
            foreach (var item in fields)
            {
                MySqlParameter p = (MySqlParameter)((DictionaryEntry)item).Value;
                if (p.ParameterName.IndexOf("u_") > -1)
                {
                    if (field2_1 != "")
                    {
                        field2_1 += ","; field2_2 += ",";
                    }
                    field2_1 += p.ParameterName;
                    field2_2 += "@" + p.ParameterName;
                }
                else
                {
                    //if (p.ParameterName == "pic") picFieldIndex = n;
                    if (field1_1 != "")
                    {
                        field1_1 += ","; field1_2 += ",";
                    }
                    field1_1 += p.ParameterName;
                    field1_2 += "@" + p.ParameterName;
                }
                if (p.Value != null && p.Value.GetType().Name == "String")
                {
                    string value = (string)p.Value;
                    verificationWord(ref value);
                    downFiles(ref value);
                    p.Value = value;
                }
            }
            if (fields["pic"] == null) //没有添加缩略图字段时
            {
                field1_1 += ",pic"; field1_2 += ",@pic"; addField("pic", defaultPic);
            }
            else
            {
                if ((string)((MySqlParameter)fields["pic"]).Value == "")
                {
                    ((MySqlParameter)fields["pic"]).Value = defaultPic;
                }
                setThumbnail((string)((MySqlParameter)fields["pic"]).Value, (string)((MySqlParameter)fields["pic"]).Value);
            }
            int count = Sql.ExecuteNonQuery("insert into maintable (" + field1_1 + ")values(" + field1_2 + ")", fields);
            count = Sql.ExecuteNonQuery("insert into " + tableName + " (" + field2_1 + ")values(" + field2_2 + ")", fields);
            if (count > 0)
            {
                resetUrl(parentColumn.id, id);
            }
            return(id);
        }
Пример #7
0
        public double update(double id)
        {
            if (parentColumn == null)
            {
                throw new Exception("未指定栏目或栏目不存在");
            }
            columnConfig = ColumnClass.getConfig(parentColumn.id);
            if (!columnConfig.titleRepeat)//标题不允许重复
            {
                string where = "id<>@id and title=@title";
                if (columnConfig.isModule)
                {
                    where += " and moduleId=@moduleId";
                }
                else if (columnConfig.isRoot)
                {
                    where += " and rootId=@rootId";
                }
                else
                {
                    where += " and classId in (" + columnConfig.childId + ")";
                }
                int c = int.Parse(Sql.ExecuteScalar("select count(1) from maintable where " + where, new MySqlParameter[] {
                    new MySqlParameter("title", title),
                    new MySqlParameter("moduleId", parentColumn.moduleId),
                    new MySqlParameter("rootId", parentColumn.rootId),
                    new MySqlParameter("id", id)
                }).ToString());
                if (c > 0)
                {
                    throw new Exception("标题已存在");
                }
            }
            addField("updatedate", System.DateTime.Now);
            System.Text.StringBuilder str = new System.Text.StringBuilder();
            this.addField("id", id);
            this.addField("moduleId", parentColumn.moduleId);
            this.addField("rootId", parentColumn.rootId);
            string field1 = "", field2 = "";
            int    picFieldIndex = -1;

            foreach (var item in fields)
            {
                MySqlParameter p = (MySqlParameter)((DictionaryEntry)item).Value;
                if (p.ParameterName.IndexOf("u_") > -1)
                {
                    if (field2 != "")
                    {
                        field2 += ",";
                    }
                    field2 += p.ParameterName + "=" + "@" + p.ParameterName;
                }
                else
                {
                    if (field1 != "")
                    {
                        field1 += ",";
                    }
                    field1 += p.ParameterName + "=" + "@" + p.ParameterName;
                }
                if (p.Value != null && p.Value.GetType().Name == "String")
                {
                    string value = (string)p.Value;
                    verificationWord(ref value);
                    downFiles(ref value);
                    p.Value = value;
                }
            }
            if (picFieldIndex > -1)
            {
                setThumbnail((string)((MySqlParameter)fields[picFieldIndex]).Value, (string)((MySqlParameter)fields[picFieldIndex]).Value);
            }

            int count = 0;

            count = Sql.ExecuteNonQuery("update maintable set " + field1 + " where id=@id", fields);
            count = Sql.ExecuteNonQuery("update " + tableName + " set " + field2 + " where id=@id", fields);
            return(id);
        }
Пример #8
0
        public void addField(string fieldName, object fieldValue)
        {
            FieldInfo f = table.fields.Find(delegate(FieldInfo o) {
                return(o.name.ToLower() == fieldName.ToLower());
            });

            if (f != null)
            {
                switch (f.type)
                {
                case "Number":
                    try
                    {
                        fieldValue = int.Parse(fieldValue.ToString());
                    }
                    catch
                    {
                        return;
                    }
                    break;

                case "Double":
                    try
                    {
                        fieldValue = double.Parse(fieldValue.ToString());
                    }
                    catch
                    {
                        return;
                    }
                    break;

                case "DateTime":
                    try
                    {
                        fieldValue = DateTime.Parse(fieldValue.ToString());
                    }catch
                    {
                        return;
                    }
                    break;
                }
            }
            else
            {
                throw new Exception(f.name + "字段不存在");
            }
            if (String.Compare(fieldName, "classid", true) == 0)
            {
                parentColumn = ColumnClass.get((double)fieldValue);
            }
            else if (String.Compare(fieldName, "title", true) == 0)
            {
                title = (string)fieldValue;
            }
            else if (String.Compare(fieldName, "pic", true) == 0)
            {
                defaultPic = (string)fieldValue;
            }

            fields[fieldName.ToLower()] = new MySqlParameter(fieldName, fieldValue);
            //            fields.Add(new MySqlParameter(fieldName,fieldValue));
        }
Пример #9
0
        public static ReturnValue edit(TemplateInfo value, UserInfo user)
        {
            ReturnValue info = new ReturnValue();
            string      url  = @"/" + value.title;

            if (value.classId == 0)
            {
                if (!user.isAdministrator)
                {
                    info.errNo  = -1;
                    info.errMsg = "没有权限";
                    return(info);
                }
            }
            else
            {
                Permissions _perm      = null;
                ModuleInfo  moduleInfo = ModuleClass.get(value.classId);
                if (moduleInfo == null)
                {
                    ColumnInfo columnInfo = ColumnClass.get(value.classId);
                    url   = @"/" + columnInfo.dirName + "/" + value.title;
                    _perm = user.getColumnPermissions(value.classId);
                }
                else
                {
                    if (moduleInfo.type)
                    {
                        url = @"/" + moduleInfo.dirName + "/" + value.title;
                    }
                    _perm = user.getModulePermissions(value.classId);
                }
                if (!_perm.all)
                {
                    info.errNo  = -1;
                    info.errMsg = "没有权限";
                    return(info);
                }
            }


            MatchCollection mc, mc2;
            Regex           r = new Regex(@"(</title>).*?(</head>)", RegexOptions.Singleline | RegexOptions.IgnoreCase); //定义一个Regex对象实例

            mc = r.Matches(value.u_content);
            if (mc.Count > 0)//如果找到头部信息时
            {
                string H  = mc[0].Value;
                Regex  r2 = new Regex(@"<script(.*)</script>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
                mc2 = r2.Matches(H);
                if (mc2.Count == 0)//如果没有js时
                {
                    string H2 = H.Replace("</head>", "<script type=\"text/javascript\" src=\"" + Config.webPath + "/static/m5_public.js\"></script>\n</head>");
                    value.u_content = value.u_content.Replace(H, H2);
                }
                else
                {
                    bool tag = false;
                    for (int i = 0; i < mc2.Count; i++)
                    {
                        if (mc2[i].Value.ToLower().IndexOf("m5_public.js") > -1)//如果包含系统js时
                        {
                            i   = mc2.Count;
                            tag = true;
                        }
                    }
                    if (!tag)//如果所有的js都不是系统js时
                    {
                        string H2 = H.Replace(mc2[0].Value, "<script type=\"text/javascript\" src=\"" + Config.webPath + "/static/m5_public.js\"></script>\n" + mc2[0].Value);
                        value.u_content = value.u_content.Replace(H, H2);
                    }
                }
            }
            //-----------------自定义页面重名检测--------------------
            if (value.u_type == -3 && TemplateClass.customPageExist(value.id, value.classId, value.title))
            {
                info.errNo  = -1;
                info.errMsg = "页面“" + value.title + "”已存在请不要重复创建";
                return(info);
            }
            //-------------------获取默认模板信息--------------------
            if (value.u_defaultFlag == 1)
            {
                object _id = Sql.ExecuteScalar("select B.id from template B where B.classId=@classId and B.u_type=@typeId and B.u_defaultFlag=@defaultTag and B.u_datatypeId=@datatypeId and B.u_webFAid=@webFAid",
                                               new MySqlParameter[] {
                    new MySqlParameter("classId", value.classId),
                    new MySqlParameter("typeId", value.u_type),
                    new MySqlParameter("defaultTag", value.u_defaultFlag),
                    new MySqlParameter("datatypeId", value.u_datatypeId),
                    new MySqlParameter("webFAid", value.u_webFAid)
                });
                if (_id != null)
                {
                    value.id = (double)_id;
                }
            }

            //-------------------编译模板----------------------------
            try
            {
                TemplateCode code = new TemplateCode(value.id.ToString(), value.u_content);
                code.compile();
            }
            catch (Exception ex)
            {
                info.errNo  = -1;
                info.errMsg = ex.Message;
                return(info);
            }
            //-------------------保存模板----------------------------
            int u_layer = 0;

            if (value.classId > 0)
            {
                object obj = Sql.ExecuteScalar("select id from module where id=" + value.classId);
                u_layer = 1;
                if (obj == null)
                {
                    obj     = Sql.ExecuteScalar("select id from class where id=" + value.classId);
                    u_layer = 2;
                }
            }
            MySqlParameter[] p = new MySqlParameter[] {
                new MySqlParameter("id", value.id),
                new MySqlParameter("classId", value.classId),
                new MySqlParameter("u_type", value.u_type),
                new MySqlParameter("title", value.title),
                new MySqlParameter("u_content", value.u_content),
                new MySqlParameter("u_defaultFlag", value.u_defaultFlag),
                new MySqlParameter("u_datatypeId", value.u_datatypeId),
                new MySqlParameter("u_editboxStatus", value.u_editboxStatus),
                new MySqlParameter("u_parameterValue", value.u_parameterValue),
                new MySqlParameter("u_webFAId", value.u_webFAid),
                new MySqlParameter("createDate", System.DateTime.Now),
                new MySqlParameter("updateDate", System.DateTime.Now),
                new MySqlParameter("url", url),
                new MySqlParameter("u_layer", u_layer)
            };
            if (value.id < 1)
            {
                p[0].Value = double.Parse(Tools.GetId());
                Sql.ExecuteNonQuery("insert into template (id,classId,u_type,title,u_content,u_defaultFlag,u_editboxStatus,u_parameterValue,u_webFAId,u_datatypeId,createDate,updateDate,url,u_layer)values(@id,@classId,@u_type,@title,@u_content,@u_defaultFlag,@u_editboxStatus,@u_parameterValue,@u_webFAId,@u_datatypeId,@createDate,@updateDate,@url,@u_layer)", p);
            }
            else
            {
                Sql.ExecuteNonQuery("update template set updateDate=@updateDate,classId=@classId,u_type=@u_type,title=@title,u_content=@u_content,u_defaultFlag=@u_defaultFlag,u_editboxStatus=@u_editboxStatus,u_parameterValue=@u_parameterValue,u_webFAId=@u_webFAId,u_datatypeId=@u_datatypeId,url=@url,u_layer=@u_layer where id=@id", p);
            }
            info.userData = p[0].Value;


            return(info);
        }
Пример #10
0
        /// <summary>
        /// 删除模板
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns></returns>
        public static ReturnValue del(double id, UserInfo user)
        {
            ReturnValue  v    = new ReturnValue();
            TemplateInfo info = TemplateClass.get(id);

            if (info != null)
            {
                #region 权限验证
                if (info.classId == 0)
                {
                    if (!user.isAdministrator)
                    {
                        v.errNo  = -1;
                        v.errMsg = "没有权限";
                        return(v);
                    }
                }
                else
                {
                    Permissions _perm      = null;
                    ModuleInfo  moduleInfo = ModuleClass.get(info.classId);
                    if (moduleInfo == null)
                    {
                        ColumnInfo columnInfo = ColumnClass.get(info.classId);
                        _perm = user.getColumnPermissions(info.classId);
                    }
                    else
                    {
                        _perm = user.getModulePermissions(info.classId);
                    }
                    if (!_perm.all)
                    {
                        v.errNo  = -1;
                        v.errMsg = "没有权限";
                        return(v);
                    }
                }
                #endregion
                if ((info.u_type == 1 || info.u_type == 2) && info.u_defaultFlag == 0)//自定义栏目模板时
                {
                    string flag = "";
                    if (info.u_webFAid == 1)
                    {
                        flag = "_";
                    }

                    if (info.u_type == 1)
                    {
                        Sql.ExecuteNonQuery("update class set " + flag + "skinId=0 where " + flag + "skinId=@skinId", new MySqlParameter[] { new MySqlParameter("skinId", info.id) });
                    }
                    if (info.u_type == 2)
                    {
                        Sql.ExecuteNonQuery("update class set " + flag + "contentSkinId=0 where " + flag + "contentSkinId=@skinId", new MySqlParameter[] { new MySqlParameter("skinId", info.id) });
                    }
                }
                Sql.ExecuteNonQuery("delete  template where id=@id", new MySqlParameter[] {
                    new MySqlParameter("id", id)
                });
            }
            v.errNo = 0;
            return(v);
        }
Пример #11
0
        public static ReturnValue move(double classId, double moduleId1, double classId1, UserInfo user)
        {
            ReturnValue err = new ReturnValue();

            if (classId == classId1)
            {
                err.errNo  = -1;
                err.errMsg = "移动栏目不能为父栏目";
                return(err);
            }
            bool            mtag2 = false, tag = true;
            double          dataTypeId2 = -1;
            MySqlDataReader rs;

            rs = Sql.ExecuteReader("select type,saveDataType from module where id=@id", new MySqlParameter[] { new MySqlParameter("id", moduleId1) });
            if (rs.Read())
            {
                dataTypeId2 = rs.GetDouble(1);
                mtag2       = rs.GetBoolean(0);
                if (moduleId1 == classId1 && !mtag2)
                {
                    classId1 = 7;
                }
            }
            rs.Close();
            if (dataTypeId2 == -1)
            {
                err.errNo  = -1;
                err.errMsg = "目标模块不存在";
                return(err);
            }
            ColumnInfo  column = ColumnClass.get(classId);
            Permissions p      = null;

            #region 获取要移动栏目的父栏目权限
            if (column.classId == 7)
            {
                p = user.getModulePermissions(column.moduleId);
            }
            else
            {
                p = user.getColumnPermissions(column.classId);
            }
            if (!p.all)
            {
                err.errNo  = -1;
                err.errMsg = "越权操作,移动栏目失败";
                return(err);
            }
            #endregion
            #region 获取目标位置权限
            if (classId1 == 7)
            {
                p = user.getModulePermissions(moduleId1);
            }
            else
            {
                p = user.getColumnPermissions(classId1);
            }
            if (!p.all)
            {
                err.errNo  = -1;
                err.errMsg = "越权操作,无目标栏目权限,移动栏目失败";
                return(err);
            }
            #endregion
            #region 栏目移动
            if (column.saveDataType == dataTypeId2)
            {
                string where = "";
                if (classId1 != 7)
                {
                    rs = Sql.ExecuteReader("select rootid from class where id=@id", new MySqlParameter[] { new MySqlParameter("id", classId1) });
                    if (rs.Read())
                    {
                        where = ",rootid=" + rs[0].ToString();
                    }
                    rs.Close();
                }
                Sql.ExecuteNonQuery("update class set moduleid=" + moduleId1 + ",classid=" + classId1 + where + " where id=" + classId);
                ColumnClass.reset(column.rootId);//重置旧栏目结构
            }
            else
            {
                err.errMsg = "数据类型不匹配";
                err.errNo  = -1;
                tag        = false;//移动失败,类型不匹配
            }
            #endregion
            return(err);
        }
Пример #12
0
        public ReturnPageData getDataList(double moduleId = 0, double classId = 0, int pageNo = 1, string orderBy = "", int sortDirection = 0, string where = "")
        {
            orderBy = orderBy + "";
            ReturnPageData r = new ReturnPageData();
            string         fieldStr = "";
            bool           attachedFlag = false;//是否有附加字段
            bool           showClassId = false, showUserId = false, showAuditorId = false;

            foreach (FieldInfo f in fields)
            {
                if (f.visible || f.isNecessary)
                {
                    if (fieldStr != "")
                    {
                        fieldStr += ",";
                    }
                    if (f.name == "attribute")
                    {
                        //sqlserver
                        //fieldStr += "(convert(varchar(6),A.orderid)+','+convert(varchar(1),A.attr0)+','+convert(varchar(1),A.attr1)+','+convert(varchar(1),A.attr2)+','+convert(varchar(1),A.attr3)+','+convert(varchar(1),A.attr4)) attribute";
                        //mysql
                        fieldStr += "CONCAT(A.orderid,',',A.attr0,',',A.attr1,',',A.attr2,',',A.attr3) attribute";
                    }
                    else if (f.name == "classId")
                    {
                        fieldStr   += "C.className";
                        showClassId = true;
                    }
                    else if (f.name == "userId")
                    {
                        fieldStr  += "D.uname";
                        showUserId = true;
                    }
                    else if (f.name == "auditorId")
                    {
                        fieldStr     += "E.uname auditor";
                        showAuditorId = true;
                    }
                    else
                    {
                        fieldStr += (f.name.IndexOf("u_") == -1 ? "A." : "B.") + f.name;
                    }
                    if (!f.isPublicField)
                    {
                        attachedFlag = true;
                    }
                }
            }
            if (where.IndexOf("u_") > -1)
            {
                attachedFlag = true;
            }
            string orderStr = "order by A.orderid desc,A.createdate desc";

            if (orderBy != "")
            {
                orderStr = "order by " + ((orderBy.IndexOf("u_") == -1) ? "A." : "B.") + orderBy + " " + (sortDirection == 1 ? "desc" : "");
            }
            string mainWhere = "";

            if (moduleId == classId)
            {
                mainWhere = " A.moduleId=" + moduleId.ToString() + " ";
            }
            else
            {
                string childId = ColumnClass.getChildId(classId);
                mainWhere = " A.classId in (" + childId + ") ";
            }

            string countSql = "select count(1) from maintable A ";
            string sql2     = "";

            //sqlserver
            //sql2 = "select " + fieldStr + ",ROW_NUMBER() Over(" + orderStr + ") as rowNum from maintable A";
            //mysql
            sql2 = "select " + fieldStr + "  from maintable A";
            if (attachedFlag)
            {
                sql2     += " left join " + tableName + " B on A.id=B.id ";
                countSql += " left join " + tableName + " B on A.id=B.id ";
            }

            r.recordCount = int.Parse(Sql.ExecuteScalar(countSql + " where" + mainWhere + where).ToString());
            //if (attachedFlag) sql2 += " on A.id=B.id ";
            if (showClassId)
            {
                sql2 += " left join class C on A.classId=C.id ";
            }
            if (showUserId)
            {
                sql2 += " left join m_admin D on A.userId=D.id ";
            }
            if (showAuditorId)
            {
                sql2 += " left join m_admin E on A.auditorId=E.id ";
            }

            sql2 += " where " + mainWhere + " " + where;
            string sql = "";//

            //sqlserver
            sql = "SELECT * FROM (" +
                  sql2 +
                  " ) as A where rowNum> " + ((pageNo - 1) * r.pageSize).ToString() + " and rowNum<" + (pageNo * r.pageSize + 1).ToString();
            //mysql
            sql      = sql2 + " limit " + ((pageNo - 1) * r.pageSize).ToString() + "," + r.pageSize.ToString();
            r.data   = Sql.ExecuteArrayObj(sql);
            r.pageNo = pageNo;
            return(r);
        }
Пример #13
0
        /// <summary>
        /// 获取栏目权限
        /// </summary>
        /// <param name="moduleId">模块id</param>
        /// <param name="columnId">栏目id</param>
        /// <returns></returns>
        public Permissions getColumnPermissions(double columnId)
        {
            ColumnInfo column = ColumnClass.get(columnId);

            return(getColumnPermissions(column));
        }
Пример #14
0
        public static ReturnValue add(ModuleInfo info, UserInfo user)
        {
            ReturnValue err = new ReturnValue();

            #region 验证
            if (info.moduleName.Trim() == "")
            {
                err.errNo  = -1;
                err.errMsg = "栏目名不能为空";
                return(err);
            }
            if (info.dirName.Trim() == "")
            {
                err.errNo  = -1;
                err.errMsg = "目录名不能为空";
                return(err);
            }
            #endregion
            info.id = double.Parse(Tools.GetId());
            int count = int.Parse(Sql.ExecuteScalar("select count(1) from module where dirName=@dirName", new MySqlParameter[] {
                new MySqlParameter("dirName", info.dirName.ToLower())
            }).ToString());
            if (count > 0)
            {
                throw new Exception("频道目录名已存在");
            }

            if (info.type)
            {
                ColumnInfo column = new ColumnInfo();
                column.id               = info.id;
                column.className        = info.moduleName;
                column.classId          = 7;
                column.moduleId         = info.id;
                column.custom           = info.custom;
                column.thumbnailWidth   = info.thumbnailWidth;
                column.thumbnailHeight  = info.thumbnailHeight;
                column.thumbnailForce   = info.thumbnailForce;
                column.saveRemoteImages = info.saveRemoteImages;
                column.inherit          = info.inherit;
                column.dirName          = info.dirName;
                column.saveDataType     = info.saveDataType;
                column.titleRepeat      = info.titleRepeat;
                ColumnClass.add(column, user);
            }
            Sql.ExecuteNonQuery("insert into module " +
                                "(id,moduleName,type,saveDataType,dirName,createDate,updateDate,custom,thumbnailWidth,thumbnailHeight,thumbnailForce,saveRemoteImages,orderId,titleRepeat,watermark)" +
                                "values" +
                                "(@id,@moduleName,@type,@saveDataType,@dirName,@createDate,@updateDate,@custom,@thumbnailWidth,@thumbnailHeight,@thumbnailForce,@saveRemoteImages,@orderId,@titleRepeat,@watermark)"
                                , new MySqlParameter[] {
                new MySqlParameter("id", info.id),
                new MySqlParameter("moduleName", info.moduleName),
                new MySqlParameter("type", info.type),
                new MySqlParameter("saveDataType", info.saveDataType),
                new MySqlParameter("dirName", info.dirName),
                new MySqlParameter("createDate", info.createDate),
                new MySqlParameter("updateDate", info.updateDate),
                new MySqlParameter("custom", info.custom),
                new MySqlParameter("thumbnailWidth", info.thumbnailWidth),
                new MySqlParameter("thumbnailHeight", info.thumbnailHeight),
                new MySqlParameter("thumbnailForce", info.thumbnailForce),
                new MySqlParameter("saveRemoteImages", info.saveRemoteImages),
                new MySqlParameter("orderId", info.orderId),
                new MySqlParameter("titleRepeat", info.titleRepeat),
                new MySqlParameter("watermark", info.watermark)
            }
                                );
            err.userData = info.id;
            return(err);
        }