private void Poc(ref string str, int startloc, int length, string idleaf) { var id = Math.Abs(Guid.NewGuid().GetHashCode()); var table = str.Substring(startloc, length); var startstr = str.Substring(0, startloc); var endstr = str.Substring(startloc + length, str.Length - table.Length - startstr.Length); byte[] pdfFile = this.ConvertHtmlTextToPDF(table); string urlkey = "http://@#"; string rev = PostResponse(ConfigurationManager.AppSettings["posturl"].ToString(), new Dictionary <string, string>(), Encoding.UTF8, pdfFile); var re = JsonConvert.DeserializeObject <result>(rev); string a = "<a href=\"" + re.url + "\" title=\"" + re.title + "\">" + re.title + "</a>"; listkeyvalue.Add(new KeyValuePair <string, string>(urlkey, a)); str = startstr + urlkey.PadRight(table.Length, ' ') + endstr; string sql = @"insert into media_attrach (attr_id, attr_type, attr_title, attr_tag, attr_path, start_page, attr_author, attr_note, creator, createtime, inputtime) values(" + id + ", 2, '" + re.title + "','','" + re.url + "','','系统', '后台表格替换','后台系统','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"; SqlHeplerTo.ExcuteSQL(sql); sql = "select isnull(max(auto_no),0) no from dbo.media_attr_use"; var maxdata = SqlHeplerTo.GetTable(sql); sql = @"insert into media_attr_use (auto_no, attr_id, use_tag, mapping_key, mapping_val, creator, createtime) values(" + Convert.ToInt32(maxdata.Rows[0][0]) + ", '" + id + "', '','IDLeaf','" + idleaf + "','系统','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"; SqlHeplerTo.ExcuteSQL(sql); }
private void InsertMedia() { string sql = "select content_id,path,name from v_content_ext"; var mediatData = SqlHeplerFrom.GetTable(sql); foreach (DataRow row in mediatData.Rows) { try { sql = "select attr_id from dbo.media_attrach where attr_path='" + Convert.ToString(row["path"]) + "'"; var isExistData = SqlHeplerTo.GetTable(sql); string attrid = string.Empty; if (isExistData.Rows.Count == 0) { attrid = Math.Abs(Guid.NewGuid().GetHashCode()).ToString(); sql = @"insert into media_attrach(attr_id,attr_type,attr_title,attr_tag,attr_path,start_page,attr_author,attr_note,creator,createtime,inputtime) values('" + attrid + "',2,'" + Convert.ToString(row["name"]) + "','','" + Convert.ToString(row["path"]) + "','','administrator','系统','administrator','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"; SqlHeplerTo.ExcuteSQL(sql); } else { attrid = Convert.ToString(isExistData.Rows[0]["attr_id"]); } sql = @"insert into dbo.media_attr_use (auto_no,attr_id,use_tag,mapping_key,mapping_val,creator,createtime) values('" + Math.Abs(Guid.NewGuid().GetHashCode()).ToString() + "','" + attrid + "',1,'IDLeaf','" + Convert.ToString(row["content_id"]) + "','administrator','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"; SqlHeplerTo.ExcuteSQL(sql); } catch (Exception ex) { logger.Error(ex.Message); } } }
private void Deletebak() { string sql = "TRUNCATE TABLE resourceobj79_bak"; SqlHeplerTo.ExcuteSQL(sql); sql = "TRUNCATE TABLE node_objdata_bak"; SqlHeplerTo.ExcuteSQL(sql); sql = "TRUNCATE TABLE media_attrach"; SqlHeplerTo.ExcuteSQL(sql); sql = "TRUNCATE TABLE media_attr_use"; SqlHeplerTo.ExcuteSQL(sql); }
private void InsertMedia() { string sql = "select content_id,path,name from v_content_ext"; var mediatData = SqlHeplerFrom.GetTable(sql); foreach (DataRow row in mediatData.Rows) { try { sql = @"insert into media_attrach(content_id,path,name) values('" + Convert.ToString(row["content_id"]) + "','" + Convert.ToString(row["path"]) + "','" + Convert.ToString(row["name"]) + "')"; SqlHeplerTo.ExcuteSQL(sql); } catch (Exception ex) { logger.Error(ex.Message); } } }
/// <summary> /// /// </summary> private void InsertNode() { var site = ConfigurationManager.AppSettings["site"].ToString(); var mapkey = ConfigurationManager.AppSettings["objName"].ToString(); string sql = "select id,isnull(parent_id,0) parent_id,name from v_channel"; var Channeldata = SqlHeplerFrom.GetTable(sql); foreach (DataRow row in Channeldata.Rows) { try { sql = @"insert into site_node_bak (node_id,site_code,node_name,node_type,map_type,map_key,node_status,is_audit,audit_wf,is_review,is_auedit,creator,createtime,inputtime,isdept,urlPre) values (" + Convert.ToString(row["id"]) + ",'" + site + "','" + Convert.ToString(row["name"]) + "',0,0,'" + mapkey + "',0,1,'" + mapkey + "',0,1,'Creator','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "',0,'gg')"; SqlHeplerTo.ExcuteSQL(sql); sql = @"select node_path from node_net_bak where node_id='" + Convert.ToString(row["parent_id"]) + "'"; var nodeTable = SqlHeplerTo.GetTable(sql); if (nodeTable.Rows.Count > 0) { foreach (DataRow netrow in nodeTable.Rows) { sql = @"insert into node_net_bak (node_id,node_pid,node_path,order_no) values('" + Convert.ToString(row["id"]) + "','" + Convert.ToString(netrow["node_path"]) + "','" + Convert.ToString(netrow["node_path"]) + "-" + Convert.ToString(row["id"]) + "',1)"; SqlHeplerTo.ExcuteSQL(sql); } } else { sql = @"insert into node_net_bak (node_id,node_pid,node_path,order_no) values('" + Convert.ToString(row["id"]) + "',0,'0-" + Convert.ToString(row["id"]) + "',1)"; SqlHeplerTo.ExcuteSQL(sql); } } catch (Exception ex) { logger.Error(ex.Message); } } }
private void InsertScript() { var mapkey = ConfigurationManager.AppSettings["objName"].ToString(); string sql = "select id,channel_id,top_level,title,short_title,author,link,release_date,content from v_content"; var scriptData = SqlHeplerFrom.GetTable(sql); foreach (DataRow row in scriptData.Rows) { try { sql = @"insert into v_content (id,channel_id,top_level,title,short_title,author,link,release_date,content) values('" + Convert.ToString(row["id"]) + "', '" + Convert.ToString(row["channel_id"]) + "', '" + Convert.ToString(row["title"]) + "', '" + Convert.ToString(row["short_title"]) + "', '" + Convert.ToString(row["author"]) + "', '" + Convert.ToString(row["link"]) + "', '" + Convert.ToString(row["release_date"]) + "', '" + Convert.ToString(row["content"]) + "')"; SqlHeplerTo.ExcuteSQL(sql); } catch (Exception ex) { logger.Error(ex.Message); } } }
/// <summary> /// /// </summary> private void InsertNode() { var site = ConfigurationManager.AppSettings["site"].ToString(); var mapkey = ConfigurationManager.AppSettings["objName"].ToString(); string sql = "select id,parent_id,name from v_channel"; var Channeldata = SqlHeplerFrom.GetTable(sql); foreach (DataRow row in Channeldata.Rows) { try { sql = @"insert into v_channel (id,parent_id,name) values ('" + Convert.ToString(row["id"]) + "','" + Convert.ToString(row["parent_id"]) + "','" + Convert.ToString(row["name"]) + "')"; SqlHeplerTo.ExcuteSQL(sql); } catch (Exception ex) { logger.Error(ex.Message); } } }
private void InsertScript() { var mapkey = ConfigurationManager.AppSettings["objName"].ToString(); string sql = "select id,channel_id,top_level,title,short_title,author,isnull(link,origin_url) link,release_date,content,title_img from v_content"; var scriptData = SqlHeplerFrom.GetTable(sql); string content1 = string.Empty; foreach (DataRow row in scriptData.Rows) { try { content1 = Convert.ToString(row["content"]); string content = ConvertTableToA(Convert.ToString(row["content"]), Convert.ToString(row["id"])); var arr = content.ToLower().Split(new string[] { "src=\"" }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length > 1) { for (int i = 1; i < arr.Length; i++) { if (!arr[i].Contains("http")) { arr[i] = ConfigurationManager.AppSettings["imgeurl"].ToString() + arr[i]; } } content = string.Join("src=\"", arr); } var arrshref = content.ToLower().Split(new string[] { "href=\"" }, StringSplitOptions.RemoveEmptyEntries); if (arrshref.Length > 1) { for (int i = 1; i < arrshref.Length; i++) { if (!arrshref[i].Contains("http")) { arrshref[i] = ConfigurationManager.AppSettings["imgeurl"].ToString() + arrshref[i]; } } content = string.Join("href=\"", arrshref); } string link = Convert.ToString(row["link"]); if (!string.IsNullOrWhiteSpace(link)) { if (!link.Contains("http")) { link = ConfigurationManager.AppSettings["imgeurl"].ToString() + link; } } sql = @"insert into " + ConfigurationManager.AppSettings["table"].ToString() + "_bak" + @" (IDLeaf, resourceprop1, resourceprop3,creator,url,createtime, content,state,name,img_top) values(@IDLeaf,@resourceprop1, @resourceprop3,@creator,@url,@createtime,@content,99,@name,@imgtop)"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@IDLeaf", Convert.ToString(row["id"])), new SqlParameter("@resourceprop1", Convert.ToString(row["top_level"])), new SqlParameter("@resourceprop3", Convert.ToString(row["short_title"])), new SqlParameter("@creator", Convert.ToString(row["author"])), new SqlParameter("@url", link), new SqlParameter("@createtime", Convert.ToString(row["release_date"]).PadRight(20, ' ').Substring(0, 19)), new SqlParameter("@content", content.Replace("'", "''")), new SqlParameter("@name", Convert.ToString(row["title"])), new SqlParameter("@imgtop", Convert.ToString(row["title_img"])) }; SqlHeplerTo.ExcuteSQL(sql, paras); sql = @"insert into [node_objdata_bak] (node_id,obj_name,ID_Leaf,order_no,is_head,is_top,is_hot) values (@nodeid,@objname,@idleaf,0,0,0,0)"; SqlParameter[] parass = new SqlParameter[] { new SqlParameter("@nodeid", Convert.ToString(row["channel_id"])), new SqlParameter("@objname", mapkey), new SqlParameter("@idleaf", Convert.ToString(row["id"])) }; SqlHeplerTo.ExcuteSQL(sql, parass); } catch (Exception ex) { logger.Error(ex.StackTrace); logger.Error(content1); logger.Error(ex.Message); } } }