public object AddItem(object item) { DataFile df; Type type = item.GetType(); string name = type.Name; if (m_listDataName.IndexOf(name) == -1) { df = DataFile.Open(type); if (df.Opened) { if (m_dataFile.TryAdd(name, df)) { m_listDataName.Add(name); } } } else { df = GetDF(name); } if (df != null && df.Opened) { return(df.AddItem(item.ToDictionary())); } return(EditStatus.FAIL_ITEM_NOT_EXIST); }
public void Start() { //new Thread(() => //{ string dbUSER = typeof(USER).Name; DataFile dfUSER = null; string[] fs = Directory.GetFiles(m_PathData, "*.df"); if (fs.Length > 0) { for (int k = 0; k < fs.Length; k++) { DataFile df = new DataFile(fs[k]); if (df.Opened) { if (df.Model.Name == dbUSER) { dfUSER = df; } string name = df.Model.Name; if (m_dataFile.TryAdd(name, df)) { m_listDataName.Add(name); } } } } if (dfUSER == null) { dfUSER = DataFile.Open(typeof(USER)); if (dfUSER.Opened) { if (m_dataFile.TryAdd(dbUSER, dfUSER)) { m_listDataName.Add(dbUSER); } } } if (dfUSER != null && dfUSER.Count == 0) { var ra = dfUSER.AddItems(new USER[] { new USER() { FULLNAME = "Admin", PASSWORD = "******", USERNAME = "******" }, new USER() { FULLNAME = "user", PASSWORD = "******", USERNAME = "******" }, //new USER() { FULLNAME = "free", PASSWORD = "******", USERNAME = "******" }, }); //var ra2 = dfUSER.AddItems(new USER[] { new USER() { FULLNAME = "user", PASSWORD = "******", USERNAME = "******" }, }); if (ra[0] != EditStatus.SUCCESS) { if (OnOpen != null) { OnOpen(m_listDataName.ToArray()); } return; } } Open = true; if (OnOpen != null) { OnOpen(m_listDataName.ToArray()); } //}).Start(); }