/// <summary> /// 2015-09-16 李国庆 /// 根据康源提供的接口获取项目对照的数据 /// </summary> /// <param name="ob"></param> private void MainDeposit(object ob) { int n = 0; string msg = string.Empty; while (this._IsRunning) { try { ServiceByKangSource.TestItemUniquecodeCompareService kangSource = new ServiceByKangSource.TestItemUniquecodeCompareService(); string reValue = kangSource.findUniquecodeCompare(); //string reValue = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><data><data_row><olduniquecode>CAAR10000451</olduniquecode><newuniquecode>CAAB1000025052</newuniquecode><testname>大血小板比率(P-LCR)</testname><testmethodname>仪器法</testmethodname></data_row></data>"; if (!string.IsNullOrEmpty(reValue)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.InnerXml = reValue; XmlNodeList topM = xmlDoc.DocumentElement.ChildNodes; IList <ProjectControl> list = new List <ProjectControl>(); foreach (XmlElement element in topM) { if (element.Name.ToLower() == "data_row") { XmlNodeList nodelist = element.ChildNodes; if (nodelist.Count > 0) { ProjectControl item = new ProjectControl(); item.PID = Guid.NewGuid().ToString(); foreach (XmlElement el in nodelist)//读元素值 { if (el != null) { switch (el.Name.ToLower()) { case "olduniquecode": item.OldUniquecode = el.InnerText; break; case "newuniquecode": item.NewUniquecode = el.InnerText; break; case "testname": item.TestName = el.InnerText; break; } } } list.Add(item); } } } if (list != null && list.Count > 0) { ProjectControlService pr = new ProjectControlService(); string error = string.Empty; if (pr.InsertProjectControl(list, ref error)) { msg = "获取数据成功!此次共获取:" + list.Count + "条数据"; } else { msg = "获取数据失败。" + error; } n++; } } } catch (Exception ex) { n++; msg = "获取数据失败,失败原因:" + ex.Message; CreateErrorLog(msg); } // SetTB("第" + n + "次获取数据。" + msg + " 获取时间:" + DateTime.Now); Thread.Sleep(outTime * 1000); } }
public HomeController() { ProjectControlService = new ProjectControlService(new IndividualCounselingEntities()); }