public static TraceWrapperBase Create(ConnectionInfo connection)
        {
            string prefix="ConnectionInfoExtended";
            foreach (string Extended in ConfigurationManager.AppSettings.AllKeys
                            .Where(key => key.StartsWith(prefix))
                            .ToArray())
            {

                connection[Extended.Substring(prefix.Length, Extended.Length - prefix.Length)] = ConfigurationManager.AppSettings[Extended];

            }
            //string dataBase = ConfigurationManager.AppSettings["DataBase"];
            //if (!string.IsNullOrEmpty(dataBase)) connection.DataBase = dataBase;
            //string sourceTable = ConfigurationManager.AppSettings["SourceTable"];
            //if (!string.IsNullOrEmpty(sourceTable)) connection.SourceTable = sourceTable;
            string traceWrapperType = ConfigurationManager.AppSettings["TraceWrapperBase"];
            if (!string.IsNullOrEmpty(traceWrapperType))
            {
                Type type = ReflectionUtil.CreateType(traceWrapperType);
                return (TraceWrapperBase)Activator.CreateInstance(type, new object[] { connection });
            }
            else
            {
                return new TraceWrapperTraceServer(connection);
            }
        }
Beispiel #2
0
        public BenchmarkResult(ConnectionInfo connection, DataTable tableWeight, DataTable operationWeight)
        {
            this.connectionInfo = connection;
            this.tableWeight = GetDictionaryFromTable(tableWeight);
            this.operationWeight = GetDictionaryFromTable(operationWeight);

            List<IResultHandler> handlers = new List<IResultHandler>();
            handlers.Add(handler);
            traceDB = new TraceWrapperSQLDB(connectionInfo, handlers);
            traceDB.ProgressUpdated +=new TraceWrapperProgressBase.ProgressUpdateDele(traceDB_ProgressUpdated);
            traceDB.OnStateChanged += new StateChangeNotifierDele(traceDB_OnStateChanged);
        }
Beispiel #3
0
        private void button_start_Click(object sender, EventArgs e)
        {
            if (this.trace == null || this.trace.State == TraceState.NotInitiated || this.trace.State == TraceState.Stopped)
            {

                ConnectionInfo connectioninfo = new ConnectionInfo();
                connectioninfo.ServerName = textBox_server.Text;
                connectioninfo.UseIntegratedSecurity = checkBox_useintegratedsecrity.Checked;
                if (!connectioninfo.UseIntegratedSecurity)
                {
                    connectioninfo.UserName = textBox_user.Text;
                    connectioninfo.Password = textBox_password.Text;
                }
                try
                {

                    trace = TraceWrapperFactory.Create(connectioninfo);
                    if (checkBox_Interval.Checked) trace.Interval = new TimeSpan(0,Convert.ToInt32(textBox_Interval.Text),0);
                    tabControl1.TabPages.Clear();
                    dgdic.Clear();
                    foreach (IResultHandler handler in trace.Handlers)
                    {
                        handler.OnResultChange += new ResultEventHandler(trace_TraceEventHandler);
                        TabPage tabpage = new TabPage(handler.GetType().Name);
                        DataGridView dg = new DataGridView();
                        dg.MouseDown += new MouseEventHandler(dg_MouseDown);
                        dg.AllowUserToAddRows = false;
                        dg.Name= "dg"+handler.GetType().Name;
                        dg.Dock = DockStyle.Fill;
                        tabpage.Controls.Add(dg);
                        tabControl1.TabPages.Add(tabpage);
                        dgdic.Add(handler.GetType().Name, dg);
                    }
                    trace.Start();
                    this.toolStripStatusLabel1.Text = "started";

                }
                catch (Exception ex)
                {
                    this.toolStripStatusLabel1.Text = ex.Message;
                    return;
                }

            }

            //button_pause.Enabled = true;
            button_stop.Enabled = true;
            button_start.Enabled = false;
        }
        public TraceWrapperTraceServer(ConnectionInfo connectionInfo, List<IResultHandler> handlers = null)
            : base(handlers)
        {
            this.connectionInfo = FromConnectionInfo(connectionInfo);

            TraceDefinitionFile.SaveAsTDF("mytrace.tdf");
            traceDefinitionFile = "mytrace.tdf";

            this.State = TraceState.NotInitiated;

            this.backWorker.WorkerReportsProgress = true;
            this.backWorker.WorkerSupportsCancellation = true;
            this.backWorker.ProgressChanged += new ProgressChangedEventHandler(backWorker_ProgressChanged);
            this.backWorker.DoWork += new DoWorkEventHandler(backWorker_DoWork);
        }
Beispiel #5
0
        public static DataTable CreateTableWeight(ConnectionInfo connectioninfo)
        {
            //DataSet ds = new DataSet("TableWeight");
            DataTable casinolink = new DataTable("TableWeight");
            casinolink.Columns.Add("Table");
            casinolink.Columns.Add("Weight",typeof(decimal));
            SqlConnection sqlconnection = new SqlConnection();
            try
            {
                sqlconnection.ConnectionString = connectioninfo.AsConnectionString;
                sqlconnection.Open();
                string sqlstr = "select Name from dbo.sysobjects where  OBJECTPROPERTY(id,N'IsUserTable')=1";
                SqlCommand command = sqlconnection.CreateCommand();
                command.CommandText = sqlstr;
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                foreach (DataRow tabledr in dt.Rows)
                {
                    string tablename = tabledr[0].ToString();
                    SqlCommand commands = sqlconnection.CreateCommand();
                    commands.CommandText = "select count(*) from "+tablename;
                    int count= (int)commands.ExecuteScalar();
                    casinolink.Rows.Add(new object[] {tablename,count });
                }

                return casinolink;

            }
            catch (Exception)
            {

            }
            finally
            {
                sqlconnection.Close();
            }
            //casinolink.Rows.Add(new object[] { "PatronPoint",1});
            //casinolink.Rows.Add(new object[] { "PatronPointDetail", 1.5 });
            //casinolink.Rows.Add(new object[] { "PatronPointPending", 0.01 });
            //casinolink.Rows.Add(new object[] { "PatronPointPlayDailyUsed", 0.1 });

            return casinolink;
        }
Beispiel #6
0
        public TraceWrapperSMO(ConnectionInfo connectionInfo, List<IResultHandler> handlers = null)
            : base(handlers)
        {
            server = new Server(connectionInfo.ServerName);

            eventSetServer = new ServerTraceEventSet(ServerTraceEvent.LockDeadlock,
             ServerTraceEvent.LockDeadlockChain,
             ServerTraceEvent.DeadlockGraph);
            //TraceDefinitionFile to eventSetServer

            //eventSetServer = new ServerTraceEventSet();
            //foreach (PropertyInfo pi in typeof(ServerTraceEvent).GetProperties())
            //{
            //    if (pi.PropertyType == typeof(ServerTraceEvent))
            //    {
            //        eventSetServer.Add((ServerTraceEvent)pi.GetValue(null, null));
            //    }
            //}
        }
Beispiel #7
0
 public TraceWrapperSQLDB(ConnectionInfo connectionInfo, List<IResultHandler> handlers = null)
     : base(handlers)
 {
     this.traceTable = connectionInfo.SourceTable;
     this.connection = new SqlConnection(connectionInfo.AsConnectionString);
 }
Beispiel #8
0
 private void LoadSettings(ConnectionInfo connectionInfo)
 {
     this.traceTable = connectionInfo["SourceTable"];
     this.traceTableCriteria = connectionInfo["Criteria"];
     this.connection = new SqlConnection(connectionInfo.AsConnectionString);
 }
Beispiel #9
0
 public TraceWrapperSQLDB(ConnectionInfo connectionInfo, List<IResultHandler> handlers)
     : base(handlers)
 {
     LoadSettings(connectionInfo);
 }
Beispiel #10
0
 public TraceWrapperSQLDB(ConnectionInfo connectionInfo)
     : base(null)
 {
     LoadSettings(connectionInfo);
 }
 public TraceWrapperServerSide(ConnectionInfo connectionInfo,string servertrcfile, List<IResultHandler> handlers = null)
     : base(handlers)
 {
     fileTRC = servertrcfile;
     this.connectionInfo = connectionInfo;
 }
Beispiel #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataTable operationWeight = new DataTable();
            operationWeight.ReadXml("OperationWeight.xml");
            DataTable tableWeight = new DataTable();
            tableWeight.ReadXml("TableWeight.xml");
            ConnectionInfo connection = new ConnectionInfo();
            connection.ServerName = textBox_server.Text;
            connection.UserName = textBox_user.Text;
            connection["DataBase"] = textBox_database.Text;
            connection.Password = textBox_password.Text;
            connection.UseIntegratedSecurity = checkBox_useintegratedsecrity.Checked;
            connection["SourceTable"] = textBox_table.Text;
            connection["Criteria"] = textBox_Criteria.Text;

            excelname = textBox_excel.Text;
            label = textBox_label.Text;

            BenchmarkResult.BenchmarkResult br = new BenchmarkResult.BenchmarkResult(connection, tableWeight, operationWeight);
            br.ProgressUpdated += new BenchmarkResult.BenchmarkResult.progressdele(br_ProgressUpdated);
            br.ResultUpdated += new BenchmarkResult.BenchmarkResult.resultdele(br_ResultUpdated);
            br.Start();
            //Dictionary<string, decimal> result = br.GetResult();
            //using (ExcelHelper.ExcelHelper excelHelper = new ExcelHelper.ExcelHelper(textBox_excel.Text))
            //{
            //    excelHelper.Append(textBox_label.Text, result);
            //}
        }
 protected virtual SqlConnectionInfo FromConnectionInfo(ConnectionInfo info)
 {
     SqlConnectionInfo connectionInfo = new SqlConnectionInfo();
     connectionInfo.ServerName = info.ServerName;
     connectionInfo.UseIntegratedSecurity = info.UseIntegratedSecurity;
     if (!connectionInfo.UseIntegratedSecurity)
     {
         connectionInfo.UserName = info.UserName;
         connectionInfo.Password = info.Password;
     }
     return connectionInfo;
 }