Example #1
0
 /// <summary>Initializes a new instance of the <see cref="T:System.IO.FileSystemWatcher" /> class, given the specified directory and type of files to monitor.</summary>
 /// <param name="path">The directory to monitor, in standard or Universal Naming Convention (UNC) notation. </param>
 /// <param name="filter">The type of files to watch. For example, "*.txt" watches for changes to all text files. </param>
 /// <exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is null.-or- The <paramref name="filter" /> parameter is null. </exception>
 /// <exception cref="T:System.ArgumentException">The <paramref name="path" /> parameter is an empty string ("").-or- The path specified through the <paramref name="path" /> parameter does not exist. </exception>
 public FileSystemWatcher(string path, string filter)
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     if (filter == null)
     {
         throw new ArgumentNullException("filter");
     }
     if (path == string.Empty)
     {
         throw new ArgumentException("Empty path", "path");
     }
     if (!Directory.Exists(path))
     {
         throw new ArgumentException("Directory does not exists", "path");
     }
     this.enableRaisingEvents = false;
     this.filter = filter;
     this.includeSubdirectories = false;
     this.internalBufferSize    = 8192;
     this.notifyFilter          = (NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite);
     this.path = path;
     this.synchronizingObject = null;
     this.InitWatcher();
 }
Example #2
0
        private void OnCollectionWasChanged(
            Action action, DeviceBase device)
        {
            KeyedCollectionWasChangedEventArgs <DeviceBase> args =
                new KeyedCollectionWasChangedEventArgs <DeviceBase>(action, device);
            EventHandler <KeyedCollectionWasChangedEventArgs <DeviceBase> > handler =
                CollectionWasChanged;

            if (handler != null)
            {
                foreach (EventHandler <KeyedCollectionWasChangedEventArgs <DeviceBase> > SingleCast
                         in handler.GetInvocationList())
                {
                    System.ComponentModel.ISynchronizeInvoke syncInvoke =
                        SingleCast.Target as System.ComponentModel.ISynchronizeInvoke;

                    try
                    {
                        if ((syncInvoke != null) && (syncInvoke.InvokeRequired))
                        {
                            syncInvoke.Invoke(SingleCast, new Object[] { this, args });
                        }
                        else
                        {
                            SingleCast(this, args);
                        }
                    }
                    catch
                    { throw; }
                }
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        private void OnControllerChangedStatus()
        {
            EventArgs    args    = new EventArgs();
            EventHandler handler = this.ControllerChangedStatus;

            if (handler != null)
            {
                foreach (EventHandler SingleCast in handler.GetInvocationList())
                {
                    System.ComponentModel.ISynchronizeInvoke syncInvoke =
                        SingleCast.Target as System.ComponentModel.ISynchronizeInvoke;

                    try
                    {
                        if ((syncInvoke != null) && (syncInvoke.InvokeRequired))
                        {
                            syncInvoke.Invoke(SingleCast, new Object[] { this, args });
                        }
                        else
                        {
                            SingleCast(this, args);
                        }
                    }
                    catch
                    { throw; }
                }
            }
        }
Example #4
0
        void autoUpdater1_UpdateProgress(object sender, SinoSZJS.Base.UpdateProgessEventArgs e)
        {
            //MethodInvoker invoker = new MethodInvoker(UpdateProgress);
            //synchronizer.Invoke(invoker, new object[] { e.Message});

            System.ComponentModel.ISynchronizeInvoke synchronizer = this;
            progressEventHandle invoker = new progressEventHandle(UpdateProgress);

            synchronizer.BeginInvoke(invoker, new object[] { e.Message });
        }
        /// <summary> 根据线程选择是否异步执行 </summary>
        public static void DoThread <T>(this EventHandler handle, EventArgs args)
        {
            if (handle == null)
            {
                return;
            }

            if (handle.Target is System.ComponentModel.ISynchronizeInvoke)
            {
                System.ComponentModel.ISynchronizeInvoke aSynch = handle.Target as System.ComponentModel.ISynchronizeInvoke;

                if (aSynch.InvokeRequired)
                {
                    object[] a = new object[] { handle, args };
                    // Todo :检查是否异步调用
                    aSynch.BeginInvoke(handle, a);
                }
                else
                {
                    // Todo :检查同步调用
                    handle(handle, args);
                }
            }
        }
Example #6
0
 public bool Wait(TimeSpan a, TimeSpan b, System.ComponentModel.ISynchronizeInvoke synchronizingObject)
 {
     throw new NotImplementedException();
 }
Example #7
0
 public void Connect(int pollingInterval, int timeout, System.ComponentModel.ISynchronizeInvoke synchronizingObject)
 {
     throw new NotImplementedException();
 }
Example #8
0
        public void Login()
        {
            SinoUser _su;

            try
            {
                string ls_name      = textUser.EditValue.ToString().Trim();
                string ls_pass      = textPass.EditValue.ToString();
                string ls_checktype = ConvertToCheckType(cb_CheckType.EditValue.ToString());

                if (ls_checktype == "windows")
                {
                    string cdn = GetDomainName();

                    if (cdn == "")
                    {
#if DEBUG
                        ls_name = "lijianlin";
#else
                        throw new Exception("未登录到域,不可进行域认证!");
#endif
                    }

                    ls_pass = StrUtils.EncodeByDESC(ls_name, "DOMAINCK");
                }

                // 取数据接口
                using (AuthorizeService.AuthorizeServiceClient _client = new AuthorizeService.AuthorizeServiceClient())
                {
                    _su = _client.LoginSys(ConfigFile.SystemID, ls_name, ls_pass, ls_checktype);
                }

                if (_su != null)
                {
                    SessionClass.CurrentLogonName     = ls_name;
                    SessionClass.CurrentLogonPass     = ls_pass;
                    SessionClass.CurrentSinoUser      = _su;
                    SessionClass.CurrentCheckType     = ls_checktype;
                    SessionClass.CurrentTicket        = new SinoSZTicketInfo(_su.UserID, _su.IPAddress, _su.EncryptedTicket);
                    SinoBestTicketCache.CurrentTicket = _su.EncryptedTicket;

                    using (CommonService.CommonServiceClient _cs = new CommonService.CommonServiceClient())
                    {
                        SessionClass.ServerConfigData = _cs.GetServerConfig();

                        DataRow[] _drs = _UserDs.User.Select(string.Format("Username='******'", ls_name));
                        if (_drs.Length == 0)
                        {
                            DataRow row = _UserDs.User.NewRow();
                            row["Username"] = ls_name;
                            _UserDs.User.Rows.Add(row);
                            _UserDs.WriteXml(_schemaFile, XmlWriteMode.IgnoreSchema);
                        }

                        _su.DwID = _su.CurrentPost.PostDwID;

                        loginTimes = 0;
                        System.ComponentModel.ISynchronizeInvoke synchronizer = this;
                        MethodInvoker invoker = new MethodInvoker(LoginSuccess);
                        synchronizer.Invoke(invoker, null);
                    }
                }
                else
                {
                    XtraMessageBox.Show("用户名/口令不正确或过期!", "系统提示");
                    System.ComponentModel.ISynchronizeInvoke synchronizer = this;
                    MethodInvoker invoker = new MethodInvoker(ResetForm);
                    synchronizer.Invoke(invoker, null);
                }


                loginTimes++;

                if (loginTimes > 2)
                {
                    System.ComponentModel.ISynchronizeInvoke synchronizer = this;
                    MethodInvoker invoker = new MethodInvoker(CancelApplicaton);
                    synchronizer.Invoke(invoker, null);
                }
            }
            catch (Exception e)
            {
                ShowMessageDelegate showProgress = new ShowMessageDelegate(ShowMessage);
                string _msg = string.Format("发生错误:{0}", e.Message);
                this.Invoke(showProgress, new object[] { _msg });
            }
        }
 public void RegisterConflictHandler(SharpSvn.SvnClientArgsWithConflict args, System.ComponentModel.ISynchronizeInvoke synch)
 {
     args.Conflict += new EventHandler <SvnConflictEventArgs>(new Handler(this, synch).OnConflict);
 }
 /// <summary>
 /// Creates a network connection to the current <see cref="ClientConnection.Address"/> and <see cref="ClientConnection.Port"/>
 /// </summary>
 /// <remarks>
 /// <p>When using this class from an application, 
 /// you need to pass in a control so that data-receiving thread can sync with your application.</p>
 /// <p>If calling this from a form or other control, just pass in the current instance.</p>
 /// </remarks>
 /// <example>
 /// <code>
 /// [C#]
 /// client.Connection.Connect(this);
 /// 
 /// [VB]
 /// client.Connection.Connect(Me)
 /// </code>
 /// </example>
 public virtual void Connect( System.ComponentModel.ISynchronizeInvoke syncObject )
 {
     this.SynchronizationObject = syncObject;
     this.Connect();
 }
 /// <summary>
 /// Waits for a network connection on the current <see cref="ServerConnection.Port"/>.
 /// </summary>
 /// <param name="syncObject">
 /// The <see cref="System.Windows.Forms.Control"/> which this will synchronize with when calling events.
 /// </param>
 /// <remarks>
 /// <p>When using this class from a Windows.Forms application, 
 /// you need to pass in a control so that data-receiving thread can sync with your application.</p>
 /// <p>If calling this from a form or other control, just pass in the current instance.</p>
 /// </remarks>
 /// <example>
 /// <code>
 /// [C#]
 /// myServerConnection.Listen(this);
 /// 
 /// [VB]
 /// myServerConnection.Listen(Me)
 /// </code>
 /// </example>
 public virtual void Listen( System.ComponentModel.ISynchronizeInvoke syncObject )
 {
     this.synchronizationObject = syncObject;
     Listen();
 }
Example #12
0
        public void Login()
        {
            try
            {
                string ls_name = textUser.EditValue.ToString().Trim();
                string ls_pass = textPass.EditValue.ToString();
                string ls_type = this.CE_AuthorType.EditValue.ToString();

                #region 取数据接口
                IAuthorize _authService = LoginConfig.GetAuthorizeInterface();
                if (_authService == null)
                {
                    throw new Exception("未找到服务器端登录服务!");
                }

                #endregion
                SinoUser _su = _authService.LoginSys(ConfigFile.SystemID, ls_name, ls_pass, ls_type);
                if (_su != null)
                {
                    SessionClass.CurrentLogonName = ls_name;
                    SessionClass.CurrentLogonPass = ls_pass;
                    SessionClass.CurrentSinoUser  = _su;
                    SessionClass.CurrentTicket    = new SinoSZTicketInfo(_su.LoginName, _su.IPAddress, _su.EncryptedTicket);
                    SessionClass.ServerConfigData = _authService.GetServerConfig();
                    DataRow[] _drs = _UserDs.User.Select(string.Format("Username='******'", ls_name));
                    if (_drs.Length == 0)
                    {
                        DataRow row = _UserDs.User.NewRow();
                        row["Username"] = ls_name;
                        _UserDs.User.Rows.Add(row);
                        _UserDs.WriteXml(_schemaFile, XmlWriteMode.IgnoreSchema);
                    }

                    _su.DwID = _su.CurrentPost.PostDwID;

                    loginTimes = 0;
                    System.ComponentModel.ISynchronizeInvoke synchronizer = this;
                    MethodInvoker invoker = new MethodInvoker(LoginSuccess);
                    synchronizer.Invoke(invoker, null);
                }
                else
                {
                    XtraMessageBox.Show("用户名/口令不正确或过期!", "系统提示");
                    System.ComponentModel.ISynchronizeInvoke synchronizer = this;
                    MethodInvoker invoker = new MethodInvoker(ResetForm);
                    synchronizer.Invoke(invoker, null);
                }


                loginTimes++;

                if (loginTimes > 2)
                {
                    System.ComponentModel.ISynchronizeInvoke synchronizer = this;
                    MethodInvoker invoker = new MethodInvoker(CancelApplicaton);
                    synchronizer.Invoke(invoker, null);
                }
            }
            catch (Exception e)
            {
                ShowMessageDelegate showProgress = new ShowMessageDelegate(ShowMessage);
                string _msg = string.Format("发生错误:{0}", e.Message);
                this.Invoke(showProgress, new object[] { _msg });
            }
        }