示例#1
0
        private void registryModel(DB_MODEL m)
        {
            var df = new DataFile(m);

            if (df.Opened)
            {
                if (m_dataFile.TryAdd(m.NAME, df))
                {
                    m_listDataName.Add(m.NAME);
                }
            }
        }
示例#2
0
        public bool ModelUpdate(DB_MODEL model, bool hasRemoveField)
        {
            DataFile db = GetDF(model.NAME);

            if (db != null && db.Opened)
            {
                //int kAdd = model.Fields.Where(x => x.FieldChange == dbFieldChange.ADD).Count();
                //int kRemove = model.Fields.Where(x => x.FieldChange == dbFieldChange.REMOVE).Count();
                //if (kAdd > 0 && kRemove > 0) return false;

                return(db.UpdateModel(model, hasRemoveField));
            }
            return(false);
        }
示例#3
0
        public bool CreateDb(dbModel model)
        {
            DataFile df = new DataFile(model);

            if (df.Opened)
            {
                string name = df.Model.Name;
                if (m_dataFile.TryAdd(name, df))
                {
                    m_listDataName.Add(name);
                }
                return(true);
            }
            return(false);
        }
示例#4
0
        public object[] UpdateOrAdd(object[] items, bool convertToDynamic = true)
        {
            if (items == null || items.Length == 0)
            {
                return(null);
            }
            string dbName = items[0].GetType().Name;

            DataFile db = GetDF(dbName);

            if (db != null && db.Opened)
            {
                return(db.AddItems(items, convertToDynamic));
            }
            return(null);
        }
示例#5
0
        public LOGIN_STATUS Login(string user, string pass)
        {
            LOGIN_STATUS ok = LOGIN_STATUS.USERNAME_PASS_WRONG;
            DataFile     db = GetDF(typeof(USER).Name);

            if (db != null && db.Opened)
            {
                if (db.Count == 0)
                {
                    ok = LOGIN_STATUS.MODEL_USER_IS_EMPTY;
                }
                else
                {
                    bool v = db.Exist("Username == @0 && Password == @1", user, pass);
                    if (v)
                    {
                        ok = LOGIN_STATUS.LOGIN_SUCCESSFULLY;
                    }
                }
            }
            return(ok);
        }
示例#6
0
        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();
        }
示例#7
0
        public void Start()
        {
            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_listMenu.Add(new MENU(df.Model));
                            m_listDataName.Add(name);
                        }
                    }
                }
            }

            modelBinding();

            ////////if (m_listDataName.IndexOf(typeof(CNDATA).Name) == -1)
            ////////{
            ////////    var df = DataFile.Open(typeof(CNDATA));
            ////////    if (df.Opened)
            ////////        if (m_dataFile.TryAdd(df.Model.Name, df))
            ////////            m_listDataName.Add(df.Model.Name);
            ////////}

            ////////if (m_listDataName.IndexOf(typeof(CNSPLIT).Name) == -1)
            ////////{
            ////////    var df = DataFile.Open(typeof(CNSPLIT));
            ////////    if (df.Opened)
            ////////        if (m_dataFile.TryAdd(df.Model.Name, df))
            ////////            m_listDataName.Add(df.Model.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.AddItem(new USER() { FULLNAME = "Admin", PASSWORD = "******", USERNAME = "******" }.ToDictionary());
            ////////    if (ra != EditStatus.SUCCESS)
            ////////    {
            ////////        if (OnOpen != null) OnOpen(m_listDataName.ToArray());
            ////////        return;
            ////////    }
            ////////}

            Open = true;
            if (OnOpen != null)
            {
                OnOpen(m_listDataName.ToArray());
            }
        }