Ejemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            SqlDependency.Start(con);
        }
Ejemplo n.º 2
0
 protected void Application_Start()
 {
     AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimsIdentity.DefaultNameClaimType;
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     SqlDependency.Start(connString);
 }
Ejemplo n.º 3
0
        public Listener(string connectionString, SqlCommand command)
        {
            _Connection         = new SqlConnection(connectionString);
            _Command            = command;
            _Command.Connection = _Connection;
            _Connection.Open();

            SqlDependency.Start(_Connection.ConnectionString);
        }
        public EntityChangeNotifier(Expression <Func <TEntity, bool> > query)
        {
            _context          = new TDbContext();
            _query            = query;
            _connectionString = _context.Database.Connection.ConnectionString;

            SqlDependency.Start(_connectionString);
            RegisterNotification();
        }
Ejemplo n.º 5
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     //Start SqlDependency with application initialization
     SqlDependency.Start(connString);
 }
Ejemplo n.º 6
0
        private void EstablishConnection()
        {
            sqlConnection = new SqlConnection();
            sqlConnection.ConnectionString = "Data Source=(LocalDb)\\MSSQLLocalDB;Integrated Security=true;Database=CarsDB;";
            sqlConnection.Open();


            SqlDependency.Start("Data Source=(LocalDb)\\MSSQLLocalDB;Integrated Security=true;Database=CarsDB;");
        }
Ejemplo n.º 7
0
        private void Refresh(SqlCommand sqlCommand)
        {
            SqlDependency.Stop(DatabaseConnection.ConnectionString);
            SqlDependency.Start(DatabaseConnection.ConnectionString);

            SqlDependency dependency = new SqlDependency(sqlCommand);

            dependency.OnChange += new OnChangeEventHandler(OnChange);
        }
Ejemplo n.º 8
0
 protected void Application_Start()
 {
     LastRunTime = DateTime.Now;
     GlobalConfiguration.Configure(WebApiConfig.Register);
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     SqlDependency.Start(providerConnectionString);
 }
Ejemplo n.º 9
0
        private void dbChangeNotification(object sender, SqlNotificationEventArgs e)
        {
            var DonHangs = new List <DonHang>();
            int num1, num2;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();

                SqlDependency.Start(connectionString);

                string commandText = "select MaDH, TinhTrangDH from dbo.DonHang";

                SqlCommand cmd = new SqlCommand(commandText, conn);

                SqlDependency dependency = new SqlDependency(cmd);



                var reader = cmd.ExecuteReader();
                num1 = num2 = 0;
                while (reader.Read())
                {
                    var DonHang = new DonHang
                    {
                        MaDh = reader["MaDH"].ToString(),
                    };
                    if (reader["TinhTrangDH"].ToString() == "1")
                    {
                        num1++;
                    }
                    else if (reader["TinhTrangDH"].ToString() == "2")
                    {
                        num2++;
                    }
                    DonHangs.Add(DonHang);
                }
                newID = DonHangs.LastOrDefault().MaDh;
            };

            if (e.Type == SqlNotificationType.Change && e.Info == SqlNotificationInfo.Update)
            {
                _context.Clients.All.SendAsync("updateDonHangs", num1.ToString(), num2.ToString());
            }
            else
            {
                if (e.Type == SqlNotificationType.Change && e.Info == SqlNotificationInfo.Insert && a)
                {
                    _context.Clients.All.SendAsync("refreshDonHangs", newID, num1.ToString(), num2.ToString());
                    a = false;
                }
                else
                {
                    a = true;
                }
            }
        }
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     GlobalFilters.Filters.Add(new UserAuditFilter());
     SqlDependency.Start(ConfigurationManager.ConnectionStrings["TimesheetDBEntities"].ToString());
 }
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     SqlDependency.Start(_dbContext.Connectionstring());
 }
Ejemplo n.º 12
0
        //--------------------------------------------------------------------------------------------------------
        //--------------------------------------------------------------------------------------------------------
        //--------------------------------------------------------------------------------------------------------
        //---------------------------------------INICIA EL PROCESO------------------------------------------------
        //--------------------------------------------------------------------------------------------------------
        //--------------------------------------------------------------------------------------------------------
        //--------------------------------------------------------------------------------------------------------

        /*public static void showNotification(int days)
         * {
         *  Notificacion VentanaNotificacion = new Notificacion(days);
         *  VentanaNotificacion.Show();---
         *  PopupNotifier popup = new PopupNotifier();
         *  popup.TitleText = "Alerta de deias";
         *  popup.ContentText = "7 dias de trabajo";
         *  popup.AnimationDuration = 1000;
         *
         *  popup.Popup();
         * }*/

        public Inicio()
        {
            string connectionString = "Server = DESKTOP-P78S0RT; Database = AxTrax1; Trusted_Connection = True;";

            InitializeComponent();
            SqlDependency.Stop(connectionString);
            SqlDependency.Start(connectionString);
            RegisterForChanges();
        }
Ejemplo n.º 13
0
 public SqlDependencyHelper(Action obj, string cmd)
 {
     ConnectionString = QLGN.Properties.Settings.Default.CATSHIPConnectionString;
     Act     = obj;
     command = cmd;
     // Start listening notification
     SqlDependency.Stop(ConnectionString);
     SqlDependency.Start(ConnectionString);
 }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            SqlDependency.Start(ConfigurationManager.ConnectionStrings["DataQuickJob"].ConnectionString);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Starts the notification of SqlDependency
 /// </summary>
 /// <param name="context">An instance of dbcontext</param>
 public static void StartMonitor(DbContext context)
 {
     try {
         SqlDependency.Start(context.Database.Connection.ConnectionString);
     }
     catch (Exception ex) {
         throw new System.Exception("Fails to Start the SqlDependency in the RegularlyNotificationRegister class", ex);
     }
 }
Ejemplo n.º 16
0
 /**
  * @ 构造函数
  * @ dbString 数据库连接字符串
  * */
 public SqlCacheExpiration(string dbString)
 {
     if (string.IsNullOrEmpty(dbString))
     {
         throw new ArgumentNullException("dbConnectionStr不能为空");
     }
     dbConnectionString = dbString;
     SqlDependency.Start(dbConnectionString);
 }
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     SqlDependency.Start(con);
     log4net.Config.XmlConfigurator.Configure(new FileInfo(Server.MapPath("~/Web.config")));
 }
Ejemplo n.º 18
0
        //initiate notification
        private void NotifyNewItem()
        {
            if (DoesUserHavePermission())
            {
                if (isFirst)
                {
                    SqlDependency.Stop(ConnectionString);
                    SqlDependency.Start(ConnectionString);
                }
                try {
                    using (SqlConnection conn = new SqlConnection(ConnectionString)) {
                        var cmd = Command;
                        if (!string.IsNullOrEmpty(_controlField))
                        {
                            cmd += (cmd.Contains(" WHERE ") ? " AND " : " WHERE ") + _controlField + " > " + _controlConsecutive;
                        }

                        using (SqlCommand com = new SqlCommand(cmd, conn)) {
                            com.Notification = null;
                            SqlDependency dep = new SqlDependency(com);
                            //subscribe to sql dependency event handler
                            dep.OnChange += new OnChangeEventHandler(dep_OnChange);
                            conn.Open();
                            using (var reader = com.ExecuteReader()) {
                                //convert reader to list<T> using reflection
                                while (reader.Read())
                                {
                                    var obj        = Activator.CreateInstance <T>();
                                    var properties = obj.GetType().GetProperties();
                                    foreach (var property in properties)
                                    {
                                        try {
                                            if (reader[property.Name] != DBNull.Value)
                                            {
                                                property.SetValue(obj, reader[property.Name], null);
                                            }
                                            if (!string.IsNullOrEmpty(_controlField) && reader[_controlField] != DBNull.Value)
                                            {
                                                int.TryParse(reader[_controlField].ToString(), out _controlConsecutive);
                                            }
                                        }
                                        catch (Exception ex) {
                                            Console.WriteLine(ex.Message);
                                        }
                                    }
                                    CollectionReturn.Add(obj);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    Console.WriteLine(ex.Message);
                }
            }
        }
        static void Main(string[] args)
        {
            SqlDependency.Start(connectionString);

            getDataWithSqlDependency();
            Console.WriteLine("Waiting for data changes");
            Console.WriteLine("Press enter to quit");
            Console.ReadLine();
            SqlDependency.Stop(connectionString);
        }
Ejemplo n.º 20
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     StripeConfiguration.SetApiKey(ConfigurationManager.AppSettings["stripeSecretKey"]);
     SqlDependency.Start(con);
 }
Ejemplo n.º 21
0
        public EntityChangeNotifier(Expression <Func <TEntity, bool> > query)
        {
            _context          = new TDbContext();
            _query            = query;
            _connectionString = _context.Database.Connection.ConnectionString;

            SafeCountDictionary.Increment(_connectionString, x => { SqlDependency.Start(x); });

            RegisterNotification();
        }
Ejemplo n.º 22
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            SqlDependency.Start(Constants.CONNECTIONSTRING);
        }
Ejemplo n.º 23
0
 private void DtFill(DataTable table, string query)
 {
     command.Notification = null;
     Dependency.AddCommandDependency(command);
     SqlDependency.Start(Connection.ConnectionString);
     command.CommandText = query;
     Connection.Open();
     table.Load(command.ExecuteReader());
     Connection.Close();
 }
Ejemplo n.º 24
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

            SqlDependency.Start(ConfigurationManager.ConnectionStrings["MusicProject"].ConnectionString);
        }
Ejemplo n.º 25
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     //RouteTable.Routes.MapHubs();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     WebApiConfig.Register(GlobalConfiguration.Configuration);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     SqlDependency.Start(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
 }
Ejemplo n.º 26
0
        protected void Application_Start()
        {
            SqlDependency.Start(ConfigurationManager.ConnectionStrings["proworldzdbNEWEntities1"].ConnectionString);
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Ejemplo n.º 27
0
 private void InitSqlDependency()
 {
     LazyInitializer.EnsureInitialized(ref _sqlDependencyInit, () =>
     {
         SqlDependency.Start(_connectionString);
         var perm = new SqlClientPermission(PermissionState.Unrestricted);
         perm.Demand();
         return(new object());
     });
 }
Ejemplo n.º 28
0
        //public void dbEnter(string login, string password)
        //{
        //    command.CommandText = "SELECT count(*) FROM [dbo].[Employee] " +
        //        "where [Employee_Login] = '" + login + "' and [Employee_Password] = '" +
        //            password + "'";
        //    connection.Open();
        //    IDuser = Convert.ToInt32(command.ExecuteScalar().ToString());
        //    connection.Close();
        //}

        // Функция на вывод данных из таблицы БД
        private void dtFill(DataTable table, string query)
        {
            command.Notification = null;
            Dependency.AddCommandDependency(command);
            SqlDependency.Start(connection.ConnectionString);
            command.CommandText = query;         // Кладем запрос в переменную
            connection.Open();                   // Открываем подключение
            table.Load(command.ExecuteReader()); // Считывание таблицы баз данных
            connection.Close();                  // ЗАкрываем подключение
        }
Ejemplo n.º 29
0
        public void Test_DoubleStart_SameConnStr()
        {
            Assert.True(SqlDependency.Start(_startConnectionString), "Failed to start listener.");

            Assert.False(SqlDependency.Start(_startConnectionString), "Expected failure when trying to start listener.");

            Assert.False(SqlDependency.Stop(_startConnectionString), "Expected failure when trying to completely stop listener.");

            Assert.True(SqlDependency.Stop(_startConnectionString), "Failed to stop listener.");
        }
Ejemplo n.º 30
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //Uygulama Başladığında SQL Dependency Çalışır
            SqlDependency.Start(connString);

            UnityConfig.RegisterComponents();
        }