Example #1
0
 public HandlerNode()
 {
     previous = next = null;
     nodeHandler = null;
     nextTimeOuts = 1000; //默认间隔一秒
     handlerName = "undefined";
 }
Example #2
0
        private void CopyFiles(String sourceFile, String targetFile, UInt32 bufferLength, Boolean overwrite, IncrementalHash sourceHash)
        {
            if (this.IsAbort)
            {
                return;
            }

            // Ensure the target file exists as requested and initially takes the same length as the source file has.
            AccessHandler.Create(targetFile, overwrite, AccessHandler.GetLength(sourceFile));

            using (AccessHandler reader = new AccessHandler(this.logger))
                using (AccessHandler writer = new AccessHandler(this.logger))
                {
                    reader.OpenRead(sourceFile);
                    writer.OpenWrite(targetFile);

                    Byte[] buffer = new Byte[bufferLength];
                    Int32  count  = 0;
                    Int32  total  = 0;

                    while (!this.IsAbort && reader.ReadChunk(buffer, out count))
                    {
                        if (sourceHash != null)
                        {
                            sourceHash.AppendData(buffer, 0, count);
                        }

                        total += count;

                        if (this.IsAbort)
                        {
                            return;
                        }

                        if (!writer.WriteChunk(buffer, count, out Int32 written))
                        {
                            this.IsError = true;
                            this.logger.Error(
                                MethodBase.GetCurrentMethod(),
                                "Buffer processing failure.",
                                this.GetDetail("source-length", count.ToSafeString(nameof(Byte))),
                                this.GetDetail("target-length", written.ToSafeString(nameof(Byte))));
                            return;
                        }
                    }

                    if (this.IsAbort)
                    {
                        return;
                    }

                    this.logger.Trace(
                        MethodBase.GetCurrentMethod(),
                        $"Processed file length: {total.ToSafeString(nameof(Byte))}.",
                        this.GetSourceFileDetail(sourceFile));
                }
        }
Example #3
0
        public HandlerNode(HandlerNode previous, AccessHandler cur,string handlerName, int timeOuts = 1000)
        {
            this.previous = previous;
            this.nodeHandler = cur;
            nextTimeOuts = timeOuts;
            this.handlerName = handlerName;

            // 与前一个关联
            this.previous.next = this;
        }
Example #4
0
 /// <summary>
 ///     On getting access
 /// </summary>
 /// <param name="args">Arguments</param>
 /// <returns></returns>
 public virtual Tuple <object, bool, CurrentProvider> OnGetAccess
 (
     AccessHandler args
 )
 {
     return(GetAccess?.Invoke
            (
                args
            ));
 }
Example #5
0
        // カード読込メソッド
        private async Task <string> Getmid()
        {
            // Reader検索
            var selector = SmartCardReader.GetDeviceSelector(SmartCardReaderKind.Any);
            var devices  = await DeviceInformation.FindAllAsync(selector);

            var device = devices.FirstOrDefault();

            if (device == null)
            {
                return("");
            }

            var reader = await SmartCardReader.FromIdAsync(device.Id);

            if (reader == null)
            {
                return("");
            }

            // カード検索
            var cards = await reader.FindAllCardsAsync();

            var card = cards.FirstOrDefault();

            if (card == null)
            {
                return("");
            }

            // 接続してポーリングコマンド送信
            using (var con = await card.ConnectAsync())
            {
                var handler = new AccessHandler(con);
                try
                {
                    var result = await handler.TransparentExchangeAsync(new byte[] { 6, 0, 0xff, 0xff, 0, 3 });

                    byte[] idm = new byte[8];
                    Array.Copy(result, 2, idm, 0, idm.Length);
                    string s = "";
                    foreach (byte b in idm)
                    {
                        // 0x00がでたらループを抜けるならここにif文とかいれる
                        s += b.ToString("X2");
                    }
                    return(s);
                }
                catch
                {
                    return("");
                }
            }
        }
Example #6
0
        private void VerifyFiles(String targetFile, UInt32 bufferLength, IncrementalHash sourceHash, IncrementalHash targetHash)
        {
            if (this.IsAbort)
            {
                return;
            }

            using (AccessHandler reader = new AccessHandler(this.logger))
            {
                reader.OpenRead(targetFile);

                Byte[] buffer = new Byte[bufferLength];
                Int32  total  = 0;

                while (!this.IsAbort && reader.ReadChunk(buffer, out Int32 length))
                {
                    targetHash.AppendData(buffer, 0, length);

                    total += length;
                }

                if (this.IsAbort)
                {
                    return;
                }

                String sourceResult = sourceHash.GetHashAndReset().ToSafeHexString();
                String targetResult = targetHash.GetHashAndReset().ToSafeHexString();

                if (String.Compare(sourceResult, targetResult) != 0)
                {
                    this.IsError = true;
                    this.logger.Error(
                        MethodBase.GetCurrentMethod(),
                        "File verification mismatch.",
                        this.GetSourceHashDetail(sourceResult),
                        this.GetTargetHashDetail(targetResult));
                    return;
                }

                if (this.IsAbort)
                {
                    return;
                }

                this.logger.Trace(
                    MethodBase.GetCurrentMethod(),
                    $"Verified file length: {total.ToSafeString(nameof(Byte))}.",
                    this.GetTargetHashDetail(targetResult),
                    this.GetTargetFileDetail(targetFile));
            }
        }
Example #7
0
        protected virtual V OnSettingValue
        (
            [CanBeNull] V value
        )
        {
            AccessHandler handler = SettingValue;

            if (!ReferenceEquals(handler, null))
            {
                handler(Target, value);
            }

            return(value);
        }
Example #8
0
 public BaseController(TimeContext context)
 {
     Unit   = new UnitOfWork(context);
     Access = new AccessHandler(Unit);
     if (CurrentUser.Id != 0)
     {
         User = new UserModel
         {
             Id       = CurrentUser.Id,
             Name     = CurrentUser.Name,
             Username = CurrentUser.User,
             Role     = CurrentUser.Role
         };
     }
 }
        /// <summary>
        ///     Check level of the access to the application
        /// </summary>
        /// <param name="args">Login and Password</param>
        /// <returns></returns>
        public virtual Tuple <object, bool, CurrentProvider> CheckAccess
        (
            AccessHandler args
        )
        {
            List <object>[] data;
            using (ISelect db = new QQContext())
            {
                data = db.IsAccess
                       (
                    args.Login,
                    args.Password
                       );
            }

            if (data == null)
            {
                return(new Tuple <object, bool, CurrentProvider>
                       (
                           "On",
                           false,
                           null
                       ));
            }

            CreatePersonalData
            (
                data[0]
            );
            CreateRoomData
            (
                data[1]
            );

            return(new Tuple <object, bool, CurrentProvider>
                   (
                       "Off",
                       true,
                       this
                   ));
        }
Example #10
0
 public void SetPostProcess(AccessHandler postHandler)
 {
     this.postNode = postHandler;
 }
Example #11
0
 public void SetCondition(AccessHandler condition)
 {
     this.conditionNode = condition;
 }
Example #12
0
 public void Reset()
 {
     IsUsedGoto = false;
     isFirstTimeExcuteNode = true;
     conditionNode = null;
     preNode = null;
     postNode = null;
     nodeAtFirstTime = null;
     handleMap.Clear();
 }
Example #13
0
 public bool AddHandler(AccessHandler handler, int timeOuts)
 {
     return AddHandler(handler, null, timeOuts);
 }
Example #14
0
        /// <summary>
        /// 添加处理单元
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="name"></param>
        /// <param name="timeOuts"></param>
        /// <returns></returns>
        public bool AddHandler(AccessHandler handler, string name = null, int timeOuts = 1000)
        {
            MethodInfo method = handler.Method;
            string mName = name;
            if (name == null)
            {
                mName = method.Name;
            }
            if (handleMap.ContainsKey(mName))
            {
                PrintLog("已经具有同名函数", currentLogType);
                return false;
            }

            timeOuts += RandomGenerator.getRandom().Next(100);
            HandlerNode cur = new HandlerNode(priviousNode, handler, mName, timeOuts);
            handleMap.Add(mName, cur);
            priviousNode = cur;
              //  priviousNode.next = header.next;
            return true;
        }
Example #15
0
 public void SetPreProcess(AccessHandler preHandler)
 {
     this.preNode = preHandler;
 }
Example #16
0
            public void UpdateValue(string newValue, int ColI, int RowI)
            {
                AccessHandler handler = new AccessHandler(Path);

                handler.AddNewValue(newValue, ColI, RowI);
            }
 public GenericCommandResult Update([FromBody] UpdateAccessCommand command, [FromServices] AccessHandler handler)
 {
     return((GenericCommandResult)handler.Handler(command));
 }
Example #18
0
 public FelicaController(SmartCardConnection con)
 {
     _handler = new Felica.AccessHandler(con);
 }
Example #19
0
 public void SetProcessAtFirstTime(AccessHandler nodeAtFirst)
 {
     this.nodeAtFirstTime = nodeAtFirst;
 }
Example #20
0
 public UIAccessProcessor(LogHandler log)
 {
     header = new HandlerNode();
     priviousNode = header;
     printLog = log;
     IsStop = false;
     conditionNode = preNode = postNode = nodeAtFirstTime = null;
     HandlerTimeOuts = 5000;
 }
 public BaseController(TimeKeeperContext context)
 {
     Unit           = new UnitOfWork(context);
     Access         = new AccessHandler(Unit);
     resourceAccess = new ResouceAccessHandler(Unit);
 }
Example #22
0
        } // IEtcTag.ReadThingData

        public async Task CreateHandler()
        {
            SmartCardConnection connection = await m_card.ConnectAsync();

            m_handler = new AccessHandler(connection);
        } // CreateHandler