Ejemplo n.º 1
0
        public void Run()
        {
            Global.UserRightProvider.CanDo(Right.RightItem.Optimize);

            if (Parameters.Count > 2 || Parameters.Count <= 0)
            {
                throw new ArgumentException("the number of parameters must be 1. Parameter 1 is table name.");
            }

            Data.DBProvider dbProvider = Data.DBProvider.GetDBProvider(Parameters[0]);

            if (dbProvider == null)
            {
                OutputMessage(string.Format("Table name {0} does not exist!", Parameters[0]));
                return;
            }
            else
            {
                int option = 1;

                if (Parameters.Count == 2)
                {
                    option = int.Parse(Parameters[1]);
                }

                switch (option)
                {
                case 1:
                    dbProvider.Optimize(Hubble.Core.Data.OptimizationOption.Minimum);
                    break;

                case 2:
                    dbProvider.Optimize(Hubble.Core.Data.OptimizationOption.Middle);
                    break;

                case 3:
                    dbProvider.Optimize(Hubble.Core.Data.OptimizationOption.Speedy);
                    break;

                default:
                    dbProvider.Optimize();
                    break;
                }
            }

            OutputMessage(string.Format("System optimizing {0} in background now. Maybe need a few minutes to finish it!",
                                        dbProvider.TableName));
        }