//更新用户自己的block设置
        public static bool UpdateUserBlock(string userId, string blockId, string title, string rptcount, string rptlength, string color, string colorvalue, string blockType, string templateId, string isManage)
        {
            try
            {
                WebPartTemplate dr = GetWebPartTemplateRecord(userId, blockType, templateId, isManage);
                //DbRecord dr = new DbRecord(daAccess,"DoorTemplate","UserId",userId,"IsDefault","T","BlockType",blockType);
                string         tempXml = dr.TemplateXml;
                DataCollection list    = new DataCollection(tempXml);
                DataElement    item    = list.GetElement("Id", blockId);
                item.SetAttr("BlockTitle", title);
                item.SetAttr("RepeatItemCount", rptcount);
                item.SetAttr("RepeatItemLength", rptlength);
                item.SetAttr("Color", color);
                item.SetAttr("ColorValue", colorvalue);
                dr.TemplateXml = list.ToString();
                dr.Update();
                return(true);
            }
#if debug
            catch (Exception ex)
#else
            catch
#endif
            { return(false); }
        }
        //保存模版布局
        public static void SaveGetBlocks(string userId, string TemplateString, string blockType, string templateId, string isManage)
        {
            WebPartTemplate dr = GetWebPartTemplateRecord(userId, blockType, templateId, isManage);

            //DbRecord dr = new DbRecord(daAccess,"DoorTemplate","UserId",userId,"IsDefault","T","BlockType",blockType);
            dr.TemplateString = TemplateString;
            dr.Update();
        }
        //获得小图表列表
        public static string SetIcon(string userId, string blockId, string blockType, string imgUrl, string templateId, string isManage)
        {
            WebPartTemplate dr      = GetWebPartTemplateRecord(userId, blockType, templateId, isManage);
            string          tempXml = dr.TemplateXml;
            DataCollection  list    = new DataCollection(tempXml);
            DataElement     item    = list.GetElement("Id", blockId);

            item.SetAttr("BlockImage", imgUrl);
            dr.TemplateXml = list.ToString();
            dr.Update();
            return("");
        }
        //保存模版布局的各个宽度
        public static void ChangeColumnsWidth(string userId, string columns, string blockType, string templateId, string isManage, params string[] lists)
        {
            WebPartTemplate dr = GetWebPartTemplateRecord(userId, blockType, templateId, isManage);
            //DbRecord dr = new DbRecord(daAccess,"DoorTemplate","UserId",userId,"IsDefault","T","BlockType",blockType);
            int    cols   = int.Parse(columns);
            string widths = "";

            for (int i = 0; i < cols; i++)
            {
                widths += lists[i] + "%,";
            }
            widths = widths.TrimEnd(',');
            dr.TemplateColWidth = widths;
            dr.Update();
        }
        //设置全局色
        public static void SetGlobalColor(string userId, string color, string colorValue, string blockType, string templateId, string isManage)
        {
            WebPartTemplate dr      = GetWebPartTemplateRecord(userId, blockType, templateId, isManage);
            string          tempXml = dr.TemplateXml;
            DataCollection  list    = new DataCollection(tempXml);

            foreach (DataElement item in list.GetElements(""))
            {
                item.SetAttr("Color", color);
                item.SetAttr("ColorValue", colorValue);
            }
            dr.TemplateXml      = list.ToString();
            dr.GlobalColor      = color;
            dr.GlobalColorValue = colorValue;
            dr.Update();
        }
        //删除模版中的块
        public static void DeleteBlockFromTemplate(string userId, string blockId, string blockType, string templateId, string isManage)
        {
            WebPartTemplate dr      = GetWebPartTemplateRecord(userId, blockType, templateId, isManage);
            string          tempXml = dr.TemplateXml;
            DataCollection  list    = new DataCollection(tempXml);
            DataElement     item    = list.GetElement("Id", blockId);

            list.Remove(item);
            dr.TemplateXml    = list.ToString();
            dr.TemplateString = dr.TemplateString.IndexOf("," + blockId) >= 0 ? dr.TemplateString.Replace("," + blockId, "") : dr.TemplateString.Replace(blockId + ",", "");
            if (dr.TemplateString.IndexOf(blockId) >= 0)
            {
                dr.TemplateString = dr.TemplateString.Replace(blockId, "");
            }
            dr.Update();
        }
        //添加新模块了,保存主页个人模版
        public static void UpdateAfterAddNewOneBlock(string userId, string blockId, string blockType, string templateId, string isManage)
        {
            WebPartTemplate dr = GetWebPartTemplateRecord(userId, blockType, templateId, isManage);
            //DbRecord dr = new DbRecord(daAccess,"DoorTemplate","UserId",userId,"IsDefault","T","BlockType",blockType);
            string         tempXml = dr.TemplateXml;
            DataCollection list    = new DataCollection(tempXml);
            WebPart        bl      = WebPart.Find(blockId);
            DataElement    item    = list.NewElement();

            item.SetAttr("Id", bl.Id);
            item.SetAttr("BlockTitle", bl.BlockTitle);
            item.SetAttr("BlockKey", bl.BlockKey);
            item.SetAttr("BlockImage", bl.BlockImage);
            item.SetAttr("RepeatItemCount", bl.RepeatItemCount.Value.ToString());
            item.SetAttr("RepeatItemLength", bl.RepeatItemLength.Value.ToString());
            item.SetAttr("Color", bl.Color);
            item.SetAttr("ColorValue", bl.ColorValue);
            item.SetAttr("DelayLoadSecond", bl.DelayLoadSecond.Value.ToString());
            dr.TemplateXml    = list.ToString();
            dr.TemplateString = dr.TemplateString + "," + blockId;
            dr.Update();
        }