示例#1
0
文件: RegexFilter.cs 项目: wpmyj/c3
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public byte[] Filtrate(byte[] source)
        {
            string strTemp = (string)HexStringConverter.Default.ConvertToObject(source);

            strTemp = Filtrate(strTemp);

            byte[] bs = null;
            try
            {
                bs = HexStringConverter.Default.ConvertToBytes(strTemp);
            }
            catch (Exception ex)
            {
                ErrorManager em = SoftManager.GetSoft().ErrorManager;
            }
            return(bs);
        }
示例#2
0
        public ExecuteResult Doit(ExecuteArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            this._executeArgs = args;
            int     deviceID = args.DeviceID;
            IDevice device   = SoftManager.GetSoft().Hardware.FindDevice(deviceID);

            ExecuteResult r = null;

            if (StringHelper.Equal(args.ExecuteName, DefineExecuteNames.IsReady))
            {
                if (device == null)
                {
                    string s = string.Format(RemoteStrings.NotFindDeviceByID, deviceID);
                    r = ExecuteResult.CreateFailExecuteResult(s);
                }
                else
                {
                    if (device.Station.CommuniPort != null &&
                        device.Station.CommuniPort.IsOpened)
                    {
                        r = ExecuteResult.CreateSuccessExecuteResult();
                    }
                    else
                    {
                        r = ExecuteResult.CreateFailExecuteResult(RemoteStrings.NotConnection);
                    }
                }
            }
            else
            {
                Debug.Assert(device != null);
                TaskExecutor te = new TaskExecutor();
                te.Ended += new EventHandler(te_Ended);
                r         = te.Execute(device, args.ExecuteName, args.KeyValues);
            }
            return(r);
        }
示例#3
0
文件: RemoteServer.cs 项目: wpmyj/c3
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void RemoteObject_Executeing(object sender, ExecuteEventArgs e)
        {
            ExecuteResult r      = null;
            int           id     = e.ExecuteArgs.DeviceID;
            IDevice       device = SoftManager.GetSoft().Hardware.FindDevice(id);

            if (StringHelper.Equal(e.ExecuteArgs.ExecuteName, DefineExecuteNames.IsReady))
            {
                if (device == null)
                {
                    string s = string.Format(RemoteStrings.NotFindDeviceByID, id);
                    r = ExecuteResult.CreateFailExecuteResult(s);
                }
                else
                {
                    if (device.Station.CommuniPort != null &&
                        device.Station.CommuniPort.IsOpened)
                    {
                        r = ExecuteResult.CreateSuccessExecuteResult();
                    }
                    else
                    {
                        r = ExecuteResult.CreateFailExecuteResult(RemoteStrings.NotConnection);
                    }
                }
            }
            else
            {
                TaskExecutor te = new TaskExecutor();
                r = te.Execute(device, e.ExecuteArgs.ExecuteName, e.ExecuteArgs.KeyValues);
                log.Info("task execute : {0}, {1}", r.IsSuccess, r.FailMessage);
                if (r.IsSuccess)
                {
                    this.Add(e, te);
                }
            }
            e.Result = r;
        }