示例#1
0
        public void main(workspace wspace)
        {
            this.wspace = wspace;
            var cd = new cachedata();

            cachedata.Instance = cd;
            // ensure the target database exists
            new merge_op.target_dbop(data.database.Instance, cd).process(wspace);
            // process avatar table
            new merge_op.avatar_tblop(data.database.Instance, cd).process(wspace);
            // process account table
            new merge_op.account_tblop(data.database.Instance, cd).process(wspace);
            // rename avatar
            new merge_op.rename_avatar(data.database.Instance, cd).process(wspace);
            // remap account
            new merge_op.remap_account(data.database.Instance, cd).process(wspace);
            // simple copy some empty tables
            new merge_op.simplecopy_tblop(data.database.Instance, cd).process(wspace);
            // copy table & rename id
            new merge_op.remapid_tblop(data.database.Instance, cd).process(wspace);
            // simple one table
            new merge_op.simpleone_tblop(data.database.Instance, cd).process(wspace);
            // drop all tables
            new merge_op.simpledropall_tbop(data.database.Instance, cd).process(wspace);
            // rename id & name
            new merge_op.remap_idname_tblop(data.database.Instance, cd).process(wspace);
            // script ids
            new merge_op.remap_script_id_tblop(data.database.Instance, cd).process(wspace);
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("hint: change mysql ip/database settings in the Program.cs first.(yes to continue,or else quit)");
            var opt_str = Console.ReadLine();

            if (!opt_str.Trim().ToLower().StartsWith("y"))
            {
                Console.WriteLine("hit any key to exit");
                Console.ReadKey();
            }
            else
            {
                var db = new data.database();
                try
                {
                    db.startup("192.168.1.8", "root", "123456");
                    data.database.Instance = db;
                    var wspace = new workspace();
                    wspace.Name      = "todo";
                    wspace.TargetDb  = new data.dbname("merged");
                    wspace.SourceDbs = new List <data.dbname>()
                    {
                        new data.dbname("card1"),
                        new data.dbname("card2"),
                        new data.dbname("card3")
                    };

                    Console.WriteLine("menu:");
                    Console.WriteLine("  1: merge source dbs");
                    Console.WriteLine("  2: deep find all ids");
                    Console.WriteLine("  3: clean local disk cache files");
                    var watch = new System.Diagnostics.Stopwatch();
                    watch.Start();
                    opt_str = Console.ReadLine().Trim().ToLower();
                    switch (opt_str)
                    {
                    case "1":
                        new merge().main(wspace);
                        break;

                    case "2":
                        new deepfind.check().main(wspace);
                        break;

                    case "3":
                        new cleanup.cleaner().main(wspace);
                        break;
                    }
                    watch.Stop();
                    Console.WriteLine(watch.ElapsedMilliseconds / 1000 + " seconds used");
                    Console.WriteLine("hit any key to exit");
                    Console.ReadKey();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("exception,(is mysql config right?),hit any key to exit");
                    Console.WriteLine("msg:" + ex.Message);
                    Console.ReadKey();
                }
                finally
                {
                    db.cleanup();
                }
            }
        }