private void MakeMemProject(int iUpdateFlag) { foreach (var item in lstProjectsByDb) { if (dicMemPrjWithAllInfo.ContainsKey(item.Id)) { MemProjectInfo mem = dicMemPrjWithAllInfo[item.Id]; mem.UpdateFlag = iUpdateFlag; if (mem.Project.UpdateDt != item.UpdateDt) { mem.Project = item; // 更新 // todo 可能会造成内存泄漏,一直有部分list没有删除 } } else { MemProjectInfo aNewMemObj = new MemProjectInfo() { Project = item, //DicCardOfProject = new Dictionary<int, MemCardInfo>(), //DicCommDevOfProject = new Dictionary<int, MemCommDev>(), UpdateFlag = iUpdateFlag }; dicMemPrjWithAllInfo.Add(item.Id, aNewMemObj); } } }
private void InsertNewCard(DataTable dwCard) { foreach (DataRow row in dwCard.Rows) { string strId = row["Index"].ToString(); string strName = row["CardName"].ToString(); string strPass = row["CardPassword"].ToString(); string strSn = row["CardSn"].ToString(); string strMod = row["CardModel"].ToString(); string strIsDoub = row["IsDouble"].ToString(); string strPointCount = row["PointCount"].ToString(); string strRefProject = row["RefProject"].ToString(); string strScreenCount = row["ScreenCount"].ToString(); if (CardWithCommDevBll.IsNameExist(strName)) { continue; } if (CardWithCommDevBll.IsSnExise(strSn)) { continue; } int iPointIdx = 0; int iScreenCount = 0; int.TryParse(strPointCount, out iPointIdx); int.TryParse(strScreenCount, out iScreenCount); MemCfgInfo.MemProjectInfo prj = MemCfgInfo.MemDbMgr.Get().GetMemProjectByName(strRefProject); if (prj == null) { continue; } GlareSysEfDbAndModels.GasCardWithCommInfo card = new GlareSysEfDbAndModels.GasCardWithCommInfo() { Address = "", BEnable = 1, CardBrightness = 9, CardContext = "", CardIsDouble = strIsDoub == "1" ? 1 : 0, CardModel = strMod, CardNumberCount = GetDigNumByModel(strMod), CardPointCount = iPointIdx, CardScreenCount = iScreenCount, CityId = "", Comment = "", CommServerSn = strSn, CommExtConnInfo = "", CommSerialBaud = 0, CommSerialDataBit = 0, CommSerialParity = 0, CommSerialPort = "", CommSerialStopBit = 0, CommServerIp = "", CommServerPort = 0, CommTimeoutMs = 2000, CommType = 0, CreateDt = DateTime.Now, DefName = strName, DefPassword = strPass, GroupId = prj.RefToMemGroup.GroupInfo.Id, Id = 0, IsDel = 0, OrgId = prj.RefToMemGroup.RefOrg.Org.Id, Password = strPass, PosLatitude = "", PosLongitude = "", ProjectId = prj.Project.Id, ProtocolType = 1, ScreenNams = "1#-2#-3#-4#-5#-6#", Name = strName, UpdateDt = DateTime.Now }; string strError; CardWithCommDevBll.AddDev(ref card, out strError); } MemCfgInfo.MemDbMgr.Get().Load(); }