public CaseStruct Get(int id) { _connection.SqlConnection.Open(); var cmd = new SqlCommand("SELECT [Case].[CaseNumber], [CaseStatus].[Description], [Case].[Comment], [Case].[Active], [Case].[LastEdited] FROM [Case]" + "INNER JOIN [CaseStatus] ON " + "CaseStatus.idCaseStatus = [Case].[idCaseStatus] " + "WHERE [Case].[idCase] = @idCase", _connection.SqlConnection); cmd.Parameters.Add(new SqlParameter("idCase", id)); var reader = cmd.ExecuteReader(); CaseStruct cs = null; while (reader.Read()) { cs = new CaseStruct( reader.GetString(0), new CaseStatusStruct(reader.GetString(1)), reader.GetString(2), reader.GetBoolean(3), reader.GetDateTime(4)); } _connection.SqlConnection.Close(); return(cs); }
protected override Boolean GetOneCase(string[] htmlarg, IWebElement item, params string[] bak_xpath) { CaseStruct caseStruct = new CaseStruct { Websource = Websource }; String Title = item.FindElement(By.TagName("h2")).Text; if (IsTitleExist(Title)) { return(false); } Int16 casetype = Judgement(Title); caseStruct.Title = Title; try { caseStruct.WebUrl = item.FindElement(By.TagName("a")).GetAttribute("href"); } catch (Exception) { caseStruct.WebUrl = item.GetAttribute("href"); } caseStruct.Content = item.FindElement(By.TagName("p")).Text; caseStruct.PublishTime = Convert.ToDateTime(item.FindElement(By.TagName("i")).Text + ":00"); UpdateDB(Title, casetype, caseStruct); return(true); }
//public ICaseDAL CaseDAL { get; private set; } = CaseFactory.CreateCaseDAL(); public Case(CaseStruct caseStruct) { this.id = caseStruct.Id; this.CaseNumber = caseStruct.CaseNumber; this.CaseStatus = caseStruct.CaseStatus; this.Comment = caseStruct.Comment; this.Active = caseStruct.Active; this.LastEdited = caseStruct.LastEdited; }
protected void UpdateDB(string Title, short casetype, CaseStruct caseStruct) { var ll = GetLanAndLon.GetLatAndLonByTitle(Title); caseStruct.Casetype = casetype; caseStruct.Address = ll.strPlace; caseStruct.Lat = ll.lat; caseStruct.Lon = ll.lon;//数据加载至casestruct DB.Update(caseStruct.GetSql()); InsertTitle2Hashtable(caseStruct.Title); UpdateTrainSet(Title, casetype); }
protected virtual Boolean GetOneCase(string[] htmlarg, IWebElement item, params string[] bak_xpath) { CaseStruct caseStruct = new CaseStruct { Websource = Websource }; String Title = item.Text; if (Title.Length < 5) { return(false); } if (IsTitleExist(Title)) { return(false); } Int16 casetype = Judgement(Title); //if (casetype == 0) //{ // UpdateTrainSet(Title); // return; //} caseStruct.Title = Title; try { caseStruct.WebUrl = item.FindElement(By.TagName("a")).GetAttribute("href"); } catch (Exception) { caseStruct.WebUrl = item.GetAttribute("href"); } List <string>[] comboxXpath = ComboxXpath(htmlarg[2], htmlarg[3], bak_xpath); object[] TimeAndContent = GetCase(caseStruct.WebUrl, comboxXpath[0].ToArray(), comboxXpath[1].ToArray(), htmlarg[4]); caseStruct.Content = TimeAndContent[1] as string; caseStruct.PublishTime = Convert.ToDateTime(TimeAndContent[0]); UpdateDB(Title, casetype, caseStruct); return(true); }
public Case Get(int id) { CaseStruct caseStruct = _caseContext.Get(id); return(new Case(caseStruct)); }