//获取单个块的html public static string GetOneBlockHtmls(string userId, string blockId, string blockType) { string blockHtmls = ""; string BlockBeginHtml = "<DIV class=\"drag_div\" id=\"drag_{0}\" style=\"BORDER-COLOR: {1}; BACKGROUND: #fff;Height:{2}\">"; string BlockEndHtml = @"<DIV id='drag_switch_{0}'> <DIV class='drag_editor' id='drag_editor_{0}' style='DISPLAY: none'> <DIV id='loadeditorid_{0}' style='WIDTH: 100px'><IMG src='/Modules/WebPart/loading.gif'><SPAN id='loadeditortext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <DIV class='drag_content' id='drag_content_{0}' style='background-color:{2}'> <DIV id='loadcontentid_{0}' style='WIDTH: 100px'><IMG src='/Modules/WebPart/loading.gif'><SPAN id='loadcontenttext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <SCRIPT>{1}</SCRIPT> </DIV> </DIV>" ; if (blockId != "") { WebPart bl = WebPart.Find(blockId); WebPartTemplate dr = WebPartTemplate.FindAllByProperties("UserId", userId, "IsDefault", "T", "BlockType", blockType)[0]; string templateXml = dr.TemplateXml; DataCollection list = new DataCollection(templateXml); DataElement item = list.GetElement("Id", blockId); if (item != null) { bl.BlockKey = item.GetAttr("BlockKey"); bl.BlockImage = item.GetAttr("BlockImage"); bl.BlockTitle = item.GetAttr("BlockTitle"); bl.BlockType = item.GetAttr("BlockType"); bl.ColorValue = item.GetAttr("ColorValue"); bl.Color = item.GetAttr("Color"); bl.RepeatItemCount = int.Parse(item.GetAttr("RepeatItemCount")); bl.RepeatItemLength = int.Parse(item.GetAttr("RepeatItemLength")); bl.DelayLoadSecond = int.Parse(item.GetAttr("DelayLoadSecond")); } blockHtmls += string.Format(BlockBeginHtml, blockId, bl.ColorValue, bl.DefaultHeight); WebPartExt wb = new WebPartExt(bl, userId); blockHtmls += wb.GetHeadHtml(); //是否延时加载 if (bl.DelayLoadSecond.ToString().Trim() != "0") { blockHtmls += string.Format(BlockEndHtml, blockId, "window.setTimeout(\"loadDragContent('" + blockId + "','" + bl.RepeatItemCount + "')\"," + Convert.ToString(bl.DelayLoadSecond * 1000) + ");", bl.ContentColor); } else { blockHtmls += string.Format(BlockEndHtml, blockId, "loadDragContent('" + blockId + "','" + bl.RepeatItemCount + "');", bl.ContentColor); } } return(blockHtmls); }
private static WebPartTemplate GetWebPartTemplateRecord(string userId, string userName, string blockType, string templateId, string isManage) { WebPartTemplate wp = null; if (!String.IsNullOrEmpty(blockType) && blockType != "Portal") { wp = WebPartTemplate.FindFirstByProperties("BlockType", blockType); if (HttpContext.Current.Request["DeptId"] != null && HttpContext.Current.Request["DeptId"].Trim() != "") { SimpleQuery query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE BaseTemplateId='" + HttpContext.Current.Request["DeptId"] + "' AND UserId IS NULL AND BlockType='DeptPortal'"); if (((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query)).Length == 0) { query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE Type IS NULL AND UserId IS NULL AND BlockType='Portal'"); WebPartTemplate wpT = ((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query))[0]; wp = new WebPartTemplate(); wp.BaseTemplateId = wpT.Id; wp.Type = ""; wp.BlockType = "DeptPortal"; wp.BaseTemplateId = HttpContext.Current.Request["DeptId"].Trim(); wp.IsDefault = "T"; wp.TemplateColWidth = wpT.TemplateColWidth; wp.TemplateString = ""; wp.TemplateXml = "<List></List>"; wp.GlobalColor = wpT.GlobalColor; wp.GlobalColorValue = wpT.GlobalColorValue; wp.Save(); } else { wp = ((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query))[0]; } } } else { if (userId == "46c5f4df-f6d1-4b36-96ac-d39d3dd65a5d" || isManage == "T") { SimpleQuery query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE Type IS NULL AND UserId IS NULL AND BlockType='Portal'"); wp = ((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query))[0]; //wp = WebPartTemplate.FindAllByProperties("Type", "", "UserId", "", "BlockType", "Portal")[0]; } else { if (WebPartTemplate.Exists(" UserId=? and IsDefault='T' and BlockType=? and Type='User'", userId, "Portal") && isManage != "T") { wp = WebPartTemplate.FindAllByProperties("UserId", userId, "IsDefault", "T", "BlockType", "Portal")[0]; } else { SimpleQuery query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE Type IS NULL AND UserId IS NULL AND BlockType='Portal'"); WebPartTemplate wpT = ((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query))[0]; wp = new WebPartTemplate(); wp.BaseTemplateId = wpT.Id; wp.Type = "User"; wp.UserId = userId; wp.UserName = userName; wp.IsDefault = "T"; wp.TemplateColWidth = wpT.TemplateColWidth; wp.TemplateString = wpT.TemplateString; wp.TemplateXml = wpT.TemplateXml; wp.GlobalColor = wpT.GlobalColor; wp.GlobalColorValue = wpT.GlobalColorValue; wp.BlockType = wpT.BlockType; wp.Save(); } } //wp = WebPartTemplate.FindFirst(); } if (wp != null) { return(wp); } if (!String.IsNullOrEmpty(templateId)) { if (WebPartTemplate.Exists(" UserId=? and IsDefault='T' and BlockType=? and BaseTemplateId = ?", userId, templateId) && isManage != "T") { wp = WebPartTemplate.FindAllByProperties("UserId", userId, "IsDefault", "T", "BlockType", blockType, "BaseTemplateId", templateId)[0]; } else { WebPartBaseTemplate wpT = WebPartBaseTemplate.Find(templateId); wp = new WebPartTemplate(); wp.BaseTemplateId = wpT.Id; wp.Type = "User"; wp.UserId = userId; wp.UserName = ""; wp.IsDefault = "T"; wp.TemplateColWidth = wpT.TemplateColWidth; wp.TemplateString = wpT.TemplateString; wp.TemplateXml = wpT.TemplateXml; wp.GlobalColor = wpT.GlobalColor; wp.GlobalColorValue = wpT.GlobalColorValue; wp.BlockType = wpT.BlockType; wp.Save(); } } else { wp = WebPartTemplate.FindFirstByProperties("UserId", userId, "IsDefault", "T", "BlockType", blockType); } return(wp); }