/** 舊寫法不用 private string getMeetingInfo(string htmlCode) { nmtssVO vo = new nmtssVO(); //string strDate = string.Empty; //日期 //string strSpeaker = string.Empty;//演講人 //string strStartTime = string.Empty;//開始時間 //string strEndTime = string.Empty;//結束時間 //string strStackholder = string.Empty;//主持人 //string strPhoneNum = string.Empty;//電話 //string strAddress = string.Empty;//會場地址 //string strComments = string.Empty;//意見 //string strSubject = string.Empty;//主旨 // Date vo.MeetingDate = getWords(ref htmlCode, @"日期:</td>"); //先做基本格式確認,若不符,此筆資料就不Parsing 了。 if (vo.MeetingDate == string.Empty) return string.Empty; // Speaker Name vo.Speaker = getWords(ref htmlCode, @"演講人"); //strStartTime string strStartTime = getWords(ref htmlCode, @"開始時間"); strStartTime = strStartTime.Insert(strStartTime.IndexOf(":") + 3, ":00"); vo.StartTime = changeFormate(strStartTime); //strEndTime string strEndTime = getWords(ref htmlCode, @"結束時間"); strEndTime = strEndTime.Insert(strEndTime.IndexOf(":") + 3, ":00"); vo.EndTime = changeFormate(strEndTime); //Stackholder vo.Host = getWords(ref htmlCode, @"主持人"); //Phone vo.Tel = getWords(ref htmlCode, @"電話"); //會場電話 vo.Tel2 = getWords(ref htmlCode, @"會場電話"); //Address string strAddress = getWords(ref htmlCode, @"會場地址"); vo.Locate2 = strAddress.Replace("<br />", "-").Replace("\r", "").Replace("\n", "").Trim(); //Comments string strNotes = getWords(ref htmlCode, @"意見"); vo.Notes = strNotes.Replace("<br />", "-").Replace("\r", "").Replace("\n", "").Trim(); //會場地點 string strLocate1 = getWords(ref htmlCode, @"會場地點"); vo.Locate1 = strLocate1.Replace("<br />", "-").Replace("\r", "").Replace("\n", "").Trim(); //會議主旨 string strSubject = getSubject(ref htmlCode); vo.MeetingName = strSubject.Replace("<br />", "-").Replace("\r", "").Replace("\n", "").Trim(); //Compose the csv file for Google Canlendar return composeCanlenderText(vo); } */ //2015-09-29 Modified. private string getMeetingInfo2(string htmlCode) { nmtssVO vo = new nmtssVO(); m_EvtDoc.LoadHtml(htmlCode); var node= m_EvtDoc.DocumentNode.SelectSingleNode("//div[@class=\"column\"]"); //主辦者 vo.Host = node.SelectSingleNode("./div[contains(label,'主辦者')]/text()").InnerText.Replace(System.Environment.NewLine,string.Empty); //電子郵件: vo.EMail = node.SelectSingleNode("./div[contains(label,'電子郵件')]/text()").InnerText.Trim().Replace(System.Environment.NewLine, string.Empty); ; //主持人(可能會帶入演講人姓名) vo.STACKHOLDER = node.SelectSingleNode("./div[contains(label,'主持人姓名')]/text()").InnerText.Replace(System.Environment.NewLine, string.Empty); //主持人電話: vo.Tel = node.SelectSingleNode("./div[contains(label,'主持人電話')]/text()").InnerText.Trim().Replace(System.Environment.NewLine, string.Empty); ; //演講嘉賓: vo.Speaker = node.SelectSingleNode("./div[contains(label,'演講嘉賓')]/text()").InnerText.Trim().Replace(System.Environment.NewLine, string.Empty); ; //若沒填演講嘉賓,改查"主講人" if (vo.Speaker == string.Empty) vo.Speaker = node.SelectSingleNode("//p/label[contains(.,'主講人')]/following-sibling::div[1]").InnerText.Trim(); //其他意見: vo.Notes = node.SelectSingleNode("//div/label[contains(.,'其他意見')]/following-sibling::div[1]").InnerText.Trim(); //日期 vo.MeetingDate = node.SelectSingleNode("//div[@class=\"eventDate\"]/text()").InnerText.Trim(); //Get Time Period ~ string strTimePeriod = node.SelectSingleNode("//div[@class=\"eventDate\"]/following-sibling::div[1]/text()").InnerText.Trim(); vo.StartTime = strTimePeriod.Split('-')[0].Trim(); vo.EndTime = strTimePeriod.Split('-')[1].Trim(); //會場地址 vo.Locate1 = node.SelectSingleNode("//div[@class=\"eventDate\"]/following-sibling::div[3]/text()").InnerText.Trim() + " " + node.SelectSingleNode("//div[@class=\"eventDate\"]/following-sibling::div[2]/text()").InnerText.Trim(); vo.Locate2 = getReginNameInString(node.SelectSingleNode("//div[@class=\"eventDate\"]/following-sibling::div[3]/text()").InnerText.Trim()); //會議主旨 vo.MeetingName = node.SelectSingleNode("//h3/span[@class='meetingID']/following-sibling::text()").InnerText.Trim(); return composeCanlenderText(vo); }
private string composeCanlenderText(nmtssVO vo) { //string contents = @""主旨,"2009/5/14","上午 09:00:00","2009/5/14","上午 09:30:00","假","假","2009/5/14","上午 08:45:00",,,,,"地點","2","假",,,"普通","comments","普通" //地方研討會,有人不填演講人姓名。在此進行判斷 if (vo.Speaker.Equals(string.Empty)) { string strPatten = string.Empty; if (vo.STACKHOLDER.LastIndexOf(":") > 0) strPatten = ":"; if (vo.STACKHOLDER.LastIndexOf(":") > 0) strPatten = ":"; if(strPatten != string.Empty) vo.Speaker = vo.STACKHOLDER.Substring(vo.STACKHOLDER.LastIndexOf(strPatten)+1,3); } StringBuilder sb = new StringBuilder(); sb.Append("\"").Append("[").Append(vo.Locate2).Append("]").Append(converter(vo.MeetingName)).Append("-").Append(vo.Speaker).Append("\",") .Append("\"").Append(vo.MeetingDate).Append("\",") .Append("\"").Append(vo.StartTime).Append("\",") .Append("\"").Append(vo.MeetingDate).Append("\",") .Append("\"").Append(vo.EndTime).Append("\",") .Append("\"假\",\"假\"").Append(",") .Append("\"").Append(vo.MeetingDate).Append("\",") .Append("\"").Append(vo.StartTime).Append("\"").Append(@",,,,,") .Append("\"").Append(vo.Locate1).Append("\"").Append(",\"2\",\"假\",,,\"普通\",") .Append("\"").Append(@"主辦人:").AppendLine(vo.Host).Append("演講人:").AppendLine(vo.Speaker).Append(@"(").Append("主持人:").Append(vo.STACKHOLDER).Append("-").Append(vo.Tel).Append(")") .AppendLine("").Append(vo.Notes).Append("\"").Append(",\"普通\""); return sb.ToString(); }