コード例 #1
0
        public BangGiaTrucTuyen()
        {
            InitializeComponent();

            try
            {
                SqlClientPermission ss = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
                ss.Demand();
            }
            catch (Exception)
            {
                throw;
            }
            SqlDependency.Stop(m_connect);
            SqlDependency.Start(m_connect);
            Program.conn = new SqlConnection(m_connect);
            string strLenh = "EXEC SP_BangGiaTrucTuyen";

            Program.myReader = Program.ExecSqlDataReader(strLenh);
            if (Program.myReader == null)
            {
                return;
            }
            Program.myReader.Close();
        }
コード例 #2
0
        private bool CanRequestNotifications()
        {
            // In order to use the callback feature of the
            // SqlDependency, the application must have
            // the SqlClientPermission permission.
            try
            {
                SqlClientPermission perm =
                    new SqlClientPermission(
                        PermissionState.Unrestricted);

                perm.Demand();

                return(true);
            }
            catch (SecurityException se)
            {
                MessageBox.Show(se.Message, "Permission Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
コード例 #3
0
    private void StartNotifyConnection()
    {
        _sqlConn = new SqlConnection(_connectString);

        // check if hosting enviromnet can listen to exceptions
        SqlClientPermission perm = new SqlClientPermission(PermissionState.Unrestricted);

        try
        {
            perm.Demand();
        }
        catch (Exception ex)
        {
            var secEx = new Exception("The hosting enviromnent does not have SqlClientPermission", ex);
            broadCastException(secEx);
            throw secEx;
        }

        try
        {
            _sqlConn.Open();
            SqlDependency.Stop(_connectString);
            SqlDependency.Start(_connectString);
            StartNotifying();
        }
        catch (Exception ex)
        {
            broadCastException(ex);
            throw;
        }
    }
コード例 #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            SqlClientPermission sqlClientPermission = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);

            sqlClientPermission.Demand();
            SqlDependency.Start(connectionString);
            LoadData();
        }
コード例 #5
0
 private void InitSqlDependency()
 {
     LazyInitializer.EnsureInitialized(ref _sqlDependencyInit, () =>
     {
         SqlDependency.Start(_connectionString);
         var perm = new SqlClientPermission(PermissionState.Unrestricted);
         perm.Demand();
         return(new object());
     });
 }
コード例 #6
0
 //check if user has permission
 private bool DoesUserHavePermission()
 {
     try {
         SqlClientPermission clientPermission =
             new SqlClientPermission(PermissionState.Unrestricted);
         clientPermission.Demand();
         return(true);
     }
     catch {
         return(false);
     }
 }
コード例 #7
0
 bool DoesHavePermitions()
 {
     try
     {
         SqlClientPermission clientPermition = new SqlClientPermission(PermissionState.Unrestricted);
         clientPermition.Demand();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #8
0
 public bool CanRequestNotifications()
 {
     try
     {
         var perm = new SqlClientPermission(PermissionState.Unrestricted);
         perm.Demand();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #9
0
        static private bool HasEnoughPermission()
        {
            SqlClientPermission permsission = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);

            try
            {
                permsission.Demand();
                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
コード例 #10
0
        //kiểm tra dịch vụ SQL Broker
        private bool CanRequestNotifications()
        {
            try
            {
                SqlClientPermission perm = new SqlClientPermission(PermissionState.Unrestricted);

                perm.Demand();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #11
0
        private bool CanRequestNotifications()
        {
            SqlClientPermission permission = new SqlClientPermission(PermissionState.Unrestricted);

            try
            {
                permission.Demand();
                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
コード例 #12
0
ファイル: FrmGiaoDich.cs プロジェクト: bngoc-ptit/ChungKhoan
 // --------------- ZONE NGOC CODE ----------------- //
 private Boolean canRequestNotifications()
 {
     try
     {
         SqlClientPermission permision = new SqlClientPermission(PermissionState.Unrestricted);
         permision.Demand();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(false);
     }
 }
コード例 #13
0
        public Real_Time_Nofication()
        {
            InitializeComponent();

            try
            {
                SqlClientPermission perm = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
                perm.Demand();
            }
            catch
            {
                throw new ApplicationException("No permission");
            }
        }
コード例 #14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.StartPosition = FormStartPosition.Manual;
            this.Location      = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width,
                                           Screen.PrimaryScreen.WorkingArea.Height - this.Height);
            string connectionString = @"data source=localhost;
   initial catalog = BondDB; persist security info = True;
            Integrated Security = SSPI; ";
            SqlClientPermission sqlClientPermission = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);

            sqlClientPermission.Demand();
            SqlDependency.Start(connectionString);
            LoadData();
        }
コード例 #15
0
ファイル: THONGTIN.cs プロジェクト: nhattan-dev/CHUNGKHOANG
 public THONGTIN()
 {
     InitializeComponent();
     try
     {
         SqlClientPermission ss = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
         ss.Demand();
     }
     catch (Exception)
     {
         throw;
     }
     SqlDependency.Start(m_connect);
     con = new SqlConnection(m_connect);
 }
コード例 #16
0
ファイル: Form1.cs プロジェクト: ThanhNam2202/Chung-Khoan
 private bool CheckPermission()
 {
     try
     {
         SqlClientPermission clientPermission =
             new SqlClientPermission(PermissionState.Unrestricted);
         clientPermission.Demand();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
コード例 #17
0
        private bool CanRequestNotifications()
        {
            try
            {
                SqlClientPermission perm = new SqlClientPermission(PermissionState.Unrestricted);

                perm.Demand();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Notification", MessageBoxButtons.OK);
                return(false);
            }
        }
コード例 #18
0
ファイル: TheoDoiCongViec.cs プロジェクト: B06-0253/NVTHAO
        public frmTheoDoiCongViec()
        {
            InitializeComponent();
            try
            {
                SqlClientPermission sq = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
                sq.Demand();
            }
            catch (Exception)
            {
            }

            //SqlDependency.Stop(Global.ConnectionString);
            //SqlDependency.Start(Global.ConnectionString);
        }
コード例 #19
0
ファイル: DatabaseUtil.cs プロジェクト: rurdea/NetChat
        /// <summary>
        /// Make sure the sql dependency can work
        /// </summary>
        public void CheckUserPermissions()
        {
            try
            {
                SqlClientPermission permissions = new SqlClientPermission(PermissionState.Unrestricted);

                //if we cann Demand() it will throw an exception if the current user
                //doesnt have the proper permissions
                permissions.Demand();
            }
            catch (Exception ex)
            {
                throw new Exception("The current user does not have enough rights to run this application on the current machine or the database connection string is invalid. ", ex);
            }
        }
コード例 #20
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Chat_User_Tes()
        {
            InitializeComponent();

            // Make sure client has permissions
            try
            {
                SqlClientPermission perm = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
                perm.Demand();
            }
            catch
            {
                throw new ApplicationException("No permission");
            }
        }
コード例 #21
0
        public bool EnoughPermission()
        {
            SqlClientPermission perm = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);

            try
            {
                perm.Demand();
                LoggerUtility.Debug("SVC_DEBUG", (object)"-  EnoughPermission::True -");
                return(true);
            }
            catch (System.Exception ex)
            {
                LoggerUtility.Error("SVC_ERROR", (object)"-  EnoughPermission::False -", ex);
                return(false);
            }
        }
コード例 #22
0
 public fmMain()
 {
     InitializeComponent();
     try
     {
         SqlClientPermission ss = new SqlClientPermission(PermissionState.Unrestricted);
         ss.Demand();
     }
     catch (Exception)
     {
         throw;
     }
     SqlDependency.Stop(Program.connstr);
     SqlDependency.Start(Program.connstr);
     con = new SqlConnection(Program.connstr);
 }
コード例 #23
0
 private void EnsureSqlDependencyListening()
 {
     if (!_sqlDependencyListenerStarted)
     {
         lock (_ensureSqlDependencyListeningLocker)
         {
             if (!_sqlDependencyListenerStarted)
             {
                 SqlDependency.Start(ConnectionString);
                 var perm = new SqlClientPermission(PermissionState.Unrestricted);
                 perm.Demand();
                 _sqlDependencyListenerStarted = true;
             }
         }
     }
 }
コード例 #24
0
        private bool DoesUserHavePermission()
        {
            try
            {
                SqlClientPermission clientPermission = new SqlClientPermission(PermissionState.Unrestricted);

                // will throw an error if user does not have permissions
                clientPermission.Demand();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #25
0
 public frmBGTT()
 {
     InitializeComponent();
     try
     {
         SqlClientPermission ss = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
         ss.Demand();
     }
     catch (Exception)
     {
         throw;
     }
     SqlDependency.Stop(connectionString);
     SqlDependency.Start(connectionString);
     connect = new SqlConnection(connectionString);
 }
コード例 #26
0
 private bool CanRequestNotifications()
 {
     // In order to use the callback feature of the
     // SqlDependency, the application must have
     // the SqlClientPermission permission.
     try
     {
         SqlClientPermission perm = new SqlClientPermission(PermissionState.Unrestricted);
         perm.Demand();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #27
0
        public void StartSucriber(string conectionString)
        {
            ConectionString = conectionString;
            ConectionString = ConectionString.Substring(conectionString.IndexOf(@"connection string='"));
            ConectionString = ConectionString.Replace("connection string='", "").Replace("'", "");
            SqlClientPermission clientPermission = new SqlClientPermission(PermissionState.Unrestricted);

            clientPermission.Demand();
            SqlDependency.Stop(ConectionString);
            SqlDependency.Start(ConectionString);
            foreach (Models.Notification item in Notifcations)
            {
                TablesInNotify.Add(item.NotificationName.ToUpper(), new Notify());
                TablesInNotify.FirstOrDefault(v =>
                                              v.Key == item.NotificationName.ToUpper()).Value?.StartNotifycation(ConectionString, item.TableName, item.NotificationName, item.ColumNotify, item.EventDatabase, item.RecipientsType, item.FillterValidatePostScript, item.QueryPostEvent, item.NotificationModuleTable, item.DelayTimeOut);
            }
        }
コード例 #28
0
 public main()
 {
     InitializeComponent();
     CheckForIllegalCrossThreadCalls = false;
     try
     {
         SqlClientPermission ss = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
         ss.Demand();
     }
     catch (Exception)
     {
         throw;
     }
     SqlDependency.Stop(conn);
     SqlDependency.Start(conn);
     con = new SqlConnection(conn);
 }
コード例 #29
0
        //private Thread myThread;
        //Initialize
        public HostingForm()
        {
            InitializeComponent();

            _rkApp.SetValue("Vents service", Application.ExecutablePath);

            try
            {
                var perm = new SqlClientPermission(PermissionState.Unrestricted);
                perm.Demand();
            }
            catch
            {
                throw new ApplicationException("No permission");
            }

            CheckPdmVault();

            Program.HostForm = this;
        }
コード例 #30
0
        public INFOChange()
        {
            InitializeComponent();
            this.Load += new System.EventHandler(this.INFOChange_Load);

            /*
             * Para monitorear la base de datos es necesario abilitat ENABLE_BROKER
             * use [ArrendamientoInmueble]
             * ALTER DATABASE [Chatter] SET  ENABLE_BROKER   --   IMPORTANTE
             */
            try
            {
                SqlClientPermission perm = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
                perm.Demand();
            }
            catch
            {
                throw new ApplicationException("No permission");
            }
        }