Exemplo n.º 1
0
        public static List <relation> GetRelationArray(int level, string type) //得到不同level不同type的模块对应的关系数组
        {
            List <string>   modulesName   = ModulesOperator.ReadModulesForDiffLevelAndType(level, type);
            RelationData    relation      = RelationOperator.GetRelationInfoForDiffModList(modulesName);
            List <relation> relationArray = new List <relation>();

            for (int i = 0; i < relation.Tables[RelationData.RELATION_TABLE].Rows.Count; i++)
            {
                relation relationOne = new relation();
                relationOne.sourceName   = relation.Tables[RelationData.RELATION_TABLE].Rows[i][RelationData.SOURCENAME_FIELD].ToString();
                relationOne.targetName   = relation.Tables[RelationData.RELATION_TABLE].Rows[i][RelationData.TARGETNAME_FIELD].ToString();
                relationOne.bidirection  = relation.Tables[RelationData.RELATION_TABLE].Rows[i][RelationData.BIDIRECTION_FIELD].ToString();
                relationOne.relationName = relation.Tables[RelationData.RELATION_TABLE].Rows[i][RelationData.NAME_FIELD].ToString();
                relationOne.comment      = relation.Tables[RelationData.RELATION_TABLE].Rows[i][RelationData.COMMENT_FIELD].ToString();
                if (relation.Tables[RelationData.RELATION_TABLE].Rows[i][RelationData.SHOW_FIELD].ToString() == "1")
                {
                    relationOne.show = 1;
                }
                else
                {
                    relationOne.show = 0;
                }
                relationArray.Add(relationOne);
            }
            return(relationArray);
        }
Exemplo n.º 2
0
        private static bool CheckAllModule(List <string> modulesName)
        {
            string cmdCheck = "SELECT count(*) FROM modules WHERE name in " + RelationOperator.GetString(modulesName);

            using (SQLiteConnection conn = new SQLiteConnection(globalParameters.dbPath))
            {
                conn.Open();
                using (SQLiteCommand cmdReader = new SQLiteCommand(cmdCheck, conn))
                {
                    using (SQLiteDataReader reader = cmdReader.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            if (reader.GetInt32(0) == 0)
                            {
                                conn.Close();
                                return(true);
                            }
                        }
                        conn.Close();
                        return(false);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static List <ModulesList> CountModuleLevelAndType(int level, string type)
        {
            List <string>      modulesName = ReadModulesForDiffLevelAndType(level, type);
            RelationData       relation    = RelationOperator.GetRelationInfoForDiffModList(modulesName);//Type为3
            List <ModulesList> modules     = new List <ModulesList>();

            for (int i = 0; i < modulesName.Count; i++)
            {
                ModulesList module = new ModulesList();
                DataRow[]   rl     = relation.Tables[RelationData.RELATION_TABLE].Select(RelationData.SOURCENAME_FIELD + " = '" + modulesName[i] + "' or " + RelationData.TARGETNAME_FIELD + "='" + modulesName[i] + "'");
                module.name  = modulesName[i];
                module.count = rl.Length;
                modules.Add(module);
            }
            return(modules);
        }
Exemplo n.º 4
0
        public static bool importModules(List <string> modulesName)
        {
            if (modulesName.Count == 0)
            {
                return(false);
            }
            bool check = CheckAllModule(modulesName);

            if (!check)
            {
                return(false);
            }
            string sql1  = "insert into modules select * from secondDb.modules where name in " + RelationOperator.GetString(modulesName);
            string sql00 = "ATTACH DATABASE '" + globalParameters.secondDbPath + "' as 'secondDb'";

            using (SQLiteConnection conn = new SQLiteConnection(globalParameters.dbPath))
            {
                conn.Open();
                using (SQLiteCommand cmd = new SQLiteCommand(sql00, conn))
                {
                    cmd.ExecuteNonQuery();
                }
                using (SQLiteCommand cmd = new SQLiteCommand(sql1, conn))
                {
                    cmd.ExecuteNonQuery();
                }
                conn.Close();
            }
            return(true);
        }