public IList <Pair <string, string> > GetTokens() { IState startState = NewToken.Instance(); startState.Read(this); return(this.Tokens); }
//public event EventHandler<EventArgs> EndRecording; public DTMFClipListener(bool buildToken = false) { DetectSilence = false; IsTokenBuildEnabled = buildToken; if (IsTokenBuildEnabled) { parser = new DTMFTokenParser(); parser.NewToken += (sender, e) => { if (NewToken != null) { NewToken.BeginInvoke(sender, e, null, null); } }; } }
public IActionResult SignIn([FromBody] User user) { if (user.Password.Length == 0) { ModelState.AddModelError("Password", "Поле password не может быть пустым"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } bool isNewUser = repo.CheckUser(user.Login); if (isNewUser) { return(BadRequest(new { authError = "Неверное имя или пароль" })); } var existUser = repo.Get(user.Login); var IsUserValid = _service.IsValidUser(user.Password, existUser.Hash, existUser.Salt); if (IsUserValid) { var token = NewToken.GetToken(user, _authOptions); var response = new { token = new JwtSecurityTokenHandler().WriteToken(token), expiration = token.ValidTo }; return(Json(response)); } return(BadRequest(new { authError = "Неверное имя пользователя или пароль" })); }
protected virtual void OnNewToken(string e) { NewToken?.Invoke(this, e); }
public Token Create(User actingUser, NewToken request) { return(null); }
private Token DeserializeNext( byte tokenCode = Byte.MaxValue ) { var tokenPosition = CodePosition; if( tokenCode == Byte.MaxValue ) { tokenCode = FixToken( Buffer.ReadByte() ); AlignSize( sizeof(byte) ); } Token tokenItem = null; if( tokenCode >= (byte)ExprToken.FirstNative ) { tokenItem = FindNativeTable( tokenCode ); } else if( tokenCode >= (byte)ExprToken.ExtendedNative ) { tokenItem = FindNativeTable( (tokenCode - (byte)ExprToken.ExtendedNative) << 8 | Buffer.ReadByte() ); AlignSize( sizeof(byte) ); } else switch( tokenCode ) { #region Cast case (byte)ExprToken.DynamicCast: tokenItem = new DynamicCastToken(); break; case (byte)ExprToken.MetaCast: tokenItem = new MetaCastToken(); break; case (byte)ExprToken.InterfaceCast: if( Buffer.Version < PrimitveCastVersion ) // UE1 { tokenItem = new IntToStringToken(); } else { tokenItem = new InterfaceCastToken(); } break; // Redefined, can be RotatorToVector!(UE1) case (byte)ExprToken.PrimitiveCast: if( Buffer.Version < PrimitveCastVersion ) // UE1 { tokenItem = new RotatorToVectorToken(); } else // UE2+ { // Next byte represents the CastToken! tokenCode = Buffer.ReadByte(); AlignSize( sizeof(byte) ); tokenItem = DeserializeCastToken( tokenCode ); //tokenitem = new PrimitiveCastToken(); } break; #endregion #region Context case (byte)ExprToken.ClassContext: tokenItem = new ClassContextToken(); break; case (byte)ExprToken.InterfaceContext: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new ByteToStringToken(); } else { tokenItem = new InterfaceContextToken(); } break; case (byte)ExprToken.Context: tokenItem = new ContextToken(); break; case (byte)ExprToken.StructMember: tokenItem = new StructMemberToken(); break; #endregion #region Assigns case (byte)ExprToken.Let: tokenItem = new LetToken(); break; case (byte)ExprToken.LetBool: tokenItem = new LetBoolToken(); break; case (byte)ExprToken.EndParmValue: tokenItem = new EndParmValueToken(); break; // Redefined, can be FloatToBool!(UE1) case (byte)ExprToken.LetDelegate: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new FloatToBoolToken(); } else { tokenItem = new LetDelegateToken(); } break; // Redefined, can be NameToBool!(UE1) case (byte)ExprToken.Conditional: tokenItem = new ConditionalToken(); break; case (byte)ExprToken.Eval: // case (byte)ExprToken.DynArrayFindStruct: case (byte)ExprToken.Conditional: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new NameToBoolToken(); } else if( Buffer.Version >= 300 ) { tokenItem = new DynamicArrayFindStructToken(); } else { tokenItem = new ConditionalToken(); } break; #endregion #region Jumps case (byte)ExprToken.Return: tokenItem = new ReturnToken(); break; case (byte)ExprToken.ReturnNothing: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new ByteToIntToken(); } // Definitely existed since GoW(490) else if( Buffer.Version > 420 && (DeserializedTokens.Count > 0 && !(DeserializedTokens[DeserializedTokens.Count - 1] is ReturnToken)) ) // Should only be done if the last token wasn't Return { tokenItem = new DynamicArrayInsertToken(); } else { tokenItem = new ReturnNothingToken(); } break; case (byte)ExprToken.GotoLabel: tokenItem = new GoToLabelToken(); break; case (byte)ExprToken.Jump: tokenItem = new JumpToken(); break; case (byte)ExprToken.JumpIfNot: tokenItem = new JumpIfNotToken(); break; case (byte)ExprToken.Switch: tokenItem = new SwitchToken(); break; case (byte)ExprToken.Case: tokenItem = new CaseToken(); break; case (byte)ExprToken.DynArrayIterator: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new RotatorToStringToken(); } else { tokenItem = new ArrayIteratorToken(); } break; case (byte)ExprToken.Iterator: tokenItem = new IteratorToken(); break; case (byte)ExprToken.IteratorNext: tokenItem = new IteratorNextToken(); break; case (byte)ExprToken.IteratorPop: tokenItem = new IteratorPopToken(); break; case (byte)ExprToken.FilterEditorOnly: tokenItem = new FilterEditorOnlyToken(); break; #endregion #region Variables case (byte)ExprToken.NativeParm: tokenItem = new NativeParameterToken(); break; // Referenced variables that are from this function e.g. Local and params case (byte)ExprToken.InstanceVariable: tokenItem = new InstanceVariableToken(); break; case (byte)ExprToken.LocalVariable: tokenItem = new LocalVariableToken(); break; case (byte)ExprToken.StateVariable: tokenItem = new StateVariableToken(); break; // Referenced variables that are default case (byte)ExprToken.UndefinedVariable: #if BORDERLANDS2 if( _Container.Package.Build == UnrealPackage.GameBuild.BuildName.Borderlands2 ) { tokenItem = new DynamicVariableToken(); break; } #endif tokenItem = new UndefinedVariableToken(); break; case (byte)ExprToken.DefaultVariable: tokenItem = new DefaultVariableToken(); break; // UE3+ case (byte)ExprToken.OutVariable: tokenItem = new OutVariableToken(); break; case (byte)ExprToken.BoolVariable: tokenItem = new BoolVariableToken(); break; // Redefined, can be FloatToInt!(UE1) case (byte)ExprToken.DelegateProperty: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new FloatToIntToken(); } else { tokenItem = new DelegatePropertyToken(); } break; case (byte)ExprToken.DefaultParmValue: if( Buffer.Version < PrimitveCastVersion ) // StringToInt { tokenItem = new StringToIntToken(); } else { tokenItem = new DefaultParameterToken(); } break; #endregion #region Misc // Redefined, can be BoolToFloat!(UE1) case (byte)ExprToken.DebugInfo: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new BoolToFloatToken(); } else { tokenItem = new DebugInfoToken(); } break; case (byte)ExprToken.Nothing: tokenItem = new NothingToken(); break; case (byte)ExprToken.EndFunctionParms: tokenItem = new EndFunctionParmsToken(); break; case (byte)ExprToken.IntZero: tokenItem = new IntZeroToken(); break; case (byte)ExprToken.IntOne: tokenItem = new IntOneToken(); break; case (byte)ExprToken.True: tokenItem = new TrueToken(); break; case (byte)ExprToken.False: tokenItem = new FalseToken(); break; case (byte)ExprToken.NoDelegate: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new IntToFloatToken(); } else { tokenItem = new NoDelegateToken(); } break; // No value passed to an optional parameter. case (byte)ExprToken.NoParm: tokenItem = new NoParmToken(); break; case (byte)ExprToken.NoObject: tokenItem = new NoObjectToken(); break; case (byte)ExprToken.Self: tokenItem = new SelfToken(); break; // End of state code. case (byte)ExprToken.Stop: tokenItem = new StopToken(); break; case (byte)ExprToken.Assert: tokenItem = new AssertToken(); break; case (byte)ExprToken.LabelTable: tokenItem = new LabelTableToken(); break; case (byte)ExprToken.EndOfScript: //CastToken.BoolToString: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new BoolToStringToken(); } else { tokenItem = new EndOfScriptToken(); } break; case (byte)ExprToken.Skip: tokenItem = new SkipToken(); break; case (byte)ExprToken.StructCmpEq: tokenItem = new StructCmpEqToken(); break; case (byte)ExprToken.StructCmpNE: tokenItem = new StructCmpNeToken(); break; case (byte)ExprToken.DelegateCmpEq: tokenItem = new DelegateCmpEqToken(); break; case (byte)ExprToken.DelegateFunctionCmpEq: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new IntToBoolToken(); } else { tokenItem = new DelegateFunctionCmpEqToken(); } break; case (byte)ExprToken.DelegateCmpNE: tokenItem = new DelegateCmpNEToken(); break; case (byte)ExprToken.DelegateFunctionCmpNE: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new IntToBoolToken(); } else { tokenItem = new DelegateFunctionCmpNEToken(); } break; case (byte)ExprToken.InstanceDelegate: tokenItem = new InstanceDelegateToken(); break; case (byte)ExprToken.EatString: tokenItem = new EatStringToken(); break; case (byte)ExprToken.New: tokenItem = new NewToken(); break; case (byte)ExprToken.FunctionEnd: // case (byte)ExprToken.DynArrayFind: if( Buffer.Version < 300 ) { tokenItem = new EndOfScriptToken(); } else { tokenItem = new DynamicArrayFindToken(); } break; case (byte)ExprToken.VarInt: case (byte)ExprToken.VarFloat: case (byte)ExprToken.VarByte: case (byte)ExprToken.VarBool: //case (byte)ExprToken.VarObject: // See UndefinedVariable if (_Container.Package.Build == UnrealPackage.GameBuild.BuildName.Mass_Effect) { // Don't know what this op code is for.... just know it takes two bytes. tokenItem = new MassEffectUnknownToken(); } else { tokenItem = new DynamicVariableToken(); } break; #endregion #region Constants case (byte)ExprToken.IntConst: tokenItem = new IntConstToken(); break; case (byte)ExprToken.ByteConst: tokenItem = new ByteConstToken(); break; case (byte)ExprToken.IntConstByte: tokenItem = new IntConstByteToken(); break; case (byte)ExprToken.FloatConst: tokenItem = new FloatConstToken(); break; // ClassConst? case (byte)ExprToken.ObjectConst: tokenItem = new ObjectConstToken(); break; case (byte)ExprToken.NameConst: tokenItem = new NameConstToken(); break; case (byte)ExprToken.StringConst: tokenItem = new StringConstToken(); break; case (byte)ExprToken.UniStringConst: tokenItem = new UniStringConstToken(); break; case (byte)ExprToken.RotatorConst: tokenItem = new RotatorConstToken(); break; case (byte)ExprToken.VectorConst: tokenItem = new VectorConstToken(); break; #endregion #region Functions case (byte)ExprToken.FinalFunction: tokenItem = new FinalFunctionToken(); break; case (byte)ExprToken.VirtualFunction: tokenItem = new VirtualFunctionToken(); break; case (byte)ExprToken.GlobalFunction: tokenItem = new GlobalFunctionToken(); break; // Redefined, can be FloatToByte!(UE1) case (byte)ExprToken.DelegateFunction: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new FloatToByteToken(); } else { tokenItem = new DelegateFunctionToken(); } break; #endregion #region Arrays case (byte)ExprToken.ArrayElement: tokenItem = new ArrayElementToken(); break; case (byte)ExprToken.DynArrayElement: tokenItem = new DynamicArrayElementToken(); break; case (byte)ExprToken.DynArrayLength: tokenItem = new DynamicArrayLengthToken(); break; case (byte)ExprToken.DynArrayInsert: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new BoolToByteToken(); } else { tokenItem = new DynamicArrayInsertToken(); } break; case (byte)ExprToken.DynArrayInsertItem: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new VectorToStringToken(); } else { tokenItem = new DynamicArrayInsertItemToken(); } break; // Redefined, can be BoolToInt!(UE1) case (byte)ExprToken.DynArrayRemove: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new BoolToIntToken(); } else { tokenItem = new DynamicArrayRemoveToken(); } break; case (byte)ExprToken.DynArrayRemoveItem: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new NameToStringToken(); } else { tokenItem = new DynamicArrayRemoveItemToken(); } break; case (byte)ExprToken.DynArrayAdd: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new FloatToStringToken(); } else { tokenItem = new DynamicArrayAddToken(); } break; case (byte)ExprToken.DynArrayAddItem: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new ObjectToStringToken(); } else { tokenItem = new DynamicArrayAddItemToken(); } break; case (byte)ExprToken.DynArraySort: tokenItem = new DynamicArraySortToken(); break; // See FunctionEnd and Eval /*case (byte)ExprToken.DynArrayFind: break; case (byte)ExprToken.DynArrayFindStruct: break;*/ #endregion default: { #region Casts if( Buffer.Version < PrimitveCastVersion ) { // No other token was matched. Check if it matches any of the CastTokens // We don't just use PrimitiveCast detection due compatible with UE1 games tokenItem = DeserializeCastToken( tokenCode ); } break; #endregion } } if( tokenItem == null ) { tokenItem = new UnknownExprToken(); } Console.Out.WriteLine("Token is: "+ tokenCode.ToString("X") + " type: " + tokenItem.GetType().Name + " pos: " + Buffer.Position); tokenItem.Decompiler = this; tokenItem.RepresentToken = tokenCode; tokenItem.Position = tokenPosition;// + (uint)Owner._ScriptOffset; tokenItem.StoragePosition = (uint)Buffer.Position - (uint)_Container.ScriptOffset - 1; // IMPORTANT:Add before deserialize, due the possibility that the tokenitem might deserialize other tokens as well. DeserializedTokens.Add( tokenItem ); tokenItem.Deserialize( Buffer ); // Includes all sizes of followed tokens as well! e.g. i = i + 1; is summed here but not i = i +1; (not>>)i ++; tokenItem.Size = (ushort)(CodePosition - tokenPosition); tokenItem.StorageSize = (ushort)((uint)Buffer.Position - (uint)_Container.ScriptOffset - tokenItem.StoragePosition); tokenItem.PostDeserialized(); return tokenItem; }
private void OnNewToken(object sender, DTMFTokenBuildedEventArgs edt) { lock (sync_object) { DAL dal = new DAL(); List <Partition> particiones = dal.GetAllPartitions(); if (edt.Token == prefs_model.Pin) { prefs_model.Ready = !prefs_model.Ready; if (prefs_model.Ready) { /*if(speech_engine_inited) * speech_synt.Speak("Alarma activada",QueueMode.Flush,null);*/ particiones.ForEach((p) => dal.UpdatePartitionState(p.Id, true)); NotifyEvent("Alarma Activada", "Todas las particiones activadas"); var h = new HistoryItem { Time = DateTime.Now, State = Action.ACTION_ID_ACTIVATED, PartitionName = "TODAS", Detail = "TODAS LAS PARTICIONES ACTIVADAS" }; dal.RegiterEvent(h); NotifyNewEvent(h); //Ready=true; } else { /*if(speech_engine_inited) * speech_synt.Speak("Alarma desactivada",QueueMode.Flush,null);*/ particiones.ForEach((p) => dal.UpdatePartitionState(p.Id, false)); NotifyEvent("Alarma Desactivada", "Todas las particiones desactivadas"); var h = new HistoryItem { Time = DateTime.Now, State = Action.ACTION_ID_DESACTIVATED, PartitionName = "TODAS", Detail = "TODAS LAS PARTICIONES DESACTIVADAS" }; dal.RegiterEvent(h); NotifyNewEvent(h); } } else { var p = particiones.Find((part) => part.Code == edt.Token); if (p != null) { string detail = ""; p.Zones = dal.GetPartitionsZones(p.Id); if (p.Activated) { detail = "Particion Desactivada:" + "Particion " + p.Name + " Desactivada"; NotifyEvent("Particion Desactivada", "Particion " + p.Name + " Desactivada"); var h = new HistoryItem { Time = DateTime.Now, State = Action.ACTION_ID_DESACTIVATED, PartitionName = p.Name, Detail = detail }; dal.RegiterEvent(h); NotifyNewEvent(h); p.Activated = false; dal.UpdatePartitionState(p.Id, false); if (particiones.Find((part) => part.Activated) == null) { prefs_model.Ready = false; } } else { detail = "Particion Activada:" + "Particion " + p.Name + " Activada"; NotifyEvent("Particion Activada", "Particion " + p.Name + " Activada"); p.Activated = true; dal.UpdatePartitionState(p.Id, false); var h = new HistoryItem { Time = DateTime.Now, State = Action.ACTION_ID_ACTIVATED, PartitionName = p.Name, Detail = detail }; dal.RegiterEvent(h); NotifyNewEvent(h); prefs_model.Ready = false; } } else { var z = (edt.Token.All(cp => cp == edt.Token[0])) ? dal.GetZoneByCode(edt.Token[0].ToString()) : null; if (z != null) { p = particiones.Find((part) => part.Id == z.PartitionId); if (!z.Fired && p.Activated) { if ((DateTime.Now - p.ChangeStateTime) >= new TimeSpan(0, 0, prefs_model.Time_To_GO)) { var due_time = (z.Inmediate ? 0 : prefs_model.Time_To_IN * 1000); var timer = new System.Threading.Timer((o) => { Partition particion = o as Partition; var zone = particion.Zones[0]; particion = dal.GetPartitionByName(p.Name); if (particion.Activated) { prefs_model.Fired = true; zone.Fired = true; dal.UpdateZoneState(zone.Id, true); string message = "Sensor: " + z.Name + ".Partición: " + particion.Name + ".Hora:" + DateTime.Now.ToShortTimeString(); var h = new HistoryItem { Time = DateTime.Now, State = Action.ACTION_ID_FIRED, PartitionName = particion.Name, Detail = message }; dal.RegiterEvent(h); NotifyNewEvent(h); Intent intent = new Intent("DroidVigia.DroidVigia.DroidVigia.ToneDetected"); intent.PutExtra("message", message); SendBroadcast(intent); if (!Notificando) { Notificando = true; } } }, new Partition { Id = p.Id, Name = p.Name, Activated = p.Activated, ChangeStateTime = p.ChangeStateTime, Zones = new List <Zone> { z } }, due_time, -1); } } } } } } if (NewToken != null) { try { NewToken.BeginInvoke(null, edt, null, null); } catch { } } }