示例#1
0
        /// <summary>
        /// 获取内容模板信息
        /// </summary>
        /// <param name="url"></param>
        /// <param name="isMobile"></param>
        void GetContentTemplate(string url, bool isMobile)
        {
            Console.WriteLine(url);
            //url = url.Replace("." + BaseConfig.extension, "");
            double      dataTypeId = 0, rootId = 0, moduleId = 0, skinId = 0, id = 0, classId = 0;
            TableHandle table             = new TableHandle("maintable");
            Dictionary <string, object> p = new Dictionary <string, object>();

            p.Add("url", url);
            Dictionary <string, object> variable = DAL.DAL.M("maintable").Field("dataTypeId,classId,id,skinId,moduleId, rootId").Where(new object[, ] {
                { "url", "=", url },
                { "orderId", ">", -1 }
            }).Find();

            if (variable == null)
            {
                throw new Exception("访问数据不存在");
            }
            moduleId   = (double)variable["moduleId"];
            rootId     = (double)variable["rootId"];
            dataTypeId = (double)variable["dataTypeId"];
            skinId     = (double)variable["skinId"];
            id         = (double)variable["id"];
            classId    = (double)variable["classId"];
            if (skinId == 0)
            {
                Dictionary <string, object> rs = DAL.DAL.M("class").Field((isMobile ? "_contentSkinID" : "contentSkinID") + " contentSkinID").Get(classId);
                if (rs != null)
                {
                    skinId = rs["contentSkinID"].ToDouble();
                }
            }
            DAL.Datatype.TableHandle T = new DAL.Datatype.TableHandle(dataTypeId);
            variable = T.GetModel(id);
            variable["attribute"] = "";
            this.Variable         = variable;
            if (skinId > 0)
            {
                try
                {
                    Get(skinId);
                }
                catch
                {
                    Get(moduleId, rootId, 2, dataTypeId, isMobile);
                }
            }
            else
            {
                Get(moduleId, rootId, 2, dataTypeId, isMobile);
            }
        }
示例#2
0
        /// <summary>
        /// 获取内容模板信息
        /// </summary>
        /// <param name="url"></param>
        /// <param name="isMobile"></param>
        void GetContentTemplate(string url, bool isMobile)
        {
            //url = url.Replace("." + BaseConfig.extension, "");
            double      dataTypeId = 0, rootId = 0, moduleId = 0, skinId = 0, id = 0, classId = 0;
            TableHandle table             = new TableHandle("maintable");
            Dictionary <string, object> p = new Dictionary <string, object>();

            p.Add("url", url);
            Dictionary <string, object> variable = table.GetModel("dataTypeId,classId,id,skinId,moduleId, rootId", "url=@url and orderId>-1", p);

            if (variable == null)
            {
                throw new Exception("访问数据不存在");
            }
            moduleId   = (double)variable["moduleId"];
            rootId     = (double)variable["rootId"];
            dataTypeId = (double)variable["dataTypeId"];
            skinId     = (double)variable["skinId"];
            id         = (double)variable["id"];
            classId    = (double)variable["classId"];
            MySqlDataReader rs = null;

            if (skinId == 0)
            {
                rs = Sql.ExecuteReader("select " + (isMobile ? "_contentSkinID" : "contentSkinID") + " from class where id=@id", new MySqlParameter[] { new MySqlParameter("id", classId) });
                if (rs.Read())
                {
                    skinId = rs.IsDBNull(0) ? 0 : rs.GetDouble(0);
                }
                rs.Close();
            }
            DAL.Datatype.TableHandle T = new DAL.Datatype.TableHandle(dataTypeId);
            variable = T.GetModel(id);
            variable["attribute"] = "";

            /*
             * string tableName = (string)Helper.Sql.ExecuteScalar("select tableName from datatype where id=" + dataTypeId.ToString());
             * rs = Helper.Sql.ExecuteReader("select * from " + tableName + " where id=@id", new MySqlParameter[] {
             *      new MySqlParameter("id",id)});
             * if (rs.Read())
             * {
             *  for (int i = 0; i < rs.FieldCount; i++)
             *  {
             *      string fieldName = rs.GetName(i);
             *
             *      if (rs.IsDBNull(i))
             *      {
             *          variable[rs.GetName(i)] = "";
             *      }
             *      else
             *      {
             *          if (rs.GetDataTypeName(rs.GetOrdinal(fieldName)) == "ntext")
             *          {
             *              //SystemLink v1 = new SystemLink();
             *              string FieldValue = rs[i] + "";
             *              //FieldValue = v1.Replace(FieldValue);
             *              variable[fieldName] = FieldValue;
             *          }
             *          else
             *          {
             *              variable[fieldName] = rs[i];
             *          }
             *      }
             *  }
             * }
             * rs.Close();*/
            this.Variable = variable;
            if (skinId > 0)
            {
                try
                {
                    Get(skinId);
                }
                catch
                {
                    Get(moduleId, rootId, 2, dataTypeId, isMobile);
                }
            }
            else
            {
                Get(moduleId, rootId, 2, dataTypeId, isMobile);
            }
        }