public async Task <IActionResult> AppLogin(LoginViewModel model) { ParentModule module = new ParentModule(_context); if (ModelState.IsValid) { // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure : false); if (result.Succeeded) { _logger.LogInformation(1, "User logged in."); UserModule module1 = new UserModule(_context, _userManager, _signInManager); Users user = new Users { Email = model.Email }; string userid = module1.GetUserInfo(user).Id; //select userID if (userid.Length == 0) { return(NotFound()); } List <Parent> item = module.GetParentInfo2(userid); var resultToken = GetToken(model); return(CreatedAtAction("Get", new { Successed = true, statusCode = 200, tokenResult = resultToken, item })); //return Json(item); } } // If we got this far, something failed, redisplay form return(BadRequest()); }
public JsonResult Get(string id) { ParentModule module = new ParentModule(_context); var item = module.Get(id); return(Json(item)); }
public (object Instance, int BytesParsed) ObjectFromBytes(byte[] data, int length, Type type) { Type elementType = type.GetElementType(); if (!ParentModule.HasConverterOfType(elementType)) { NetBase.WriteDebug($"Invalid element type in array conversion! ({elementType})", true); } //The 'length' parameter here is used to determine how many bytes at the start of the array are for the length of the string data (ushort Instance, int BytesParsed)t = ParentModule.ObjectFromBytes <ushort>(data); ushort arraySize = t.Instance; byte[] arrayBytes = data.Skip(t.BytesParsed).ToArray(); Array instances = Array.CreateInstance(elementType, arraySize); int parsed = t.BytesParsed; for (int i = 0; i < arraySize; ++i) { (object Instance, int BytesParsed)instanceTuple = ParentModule.ObjectFromBytes(elementType, arrayBytes, t.BytesParsed); instances.SetValue(instanceTuple.Instance, i); parsed += instanceTuple.BytesParsed; arrayBytes = arrayBytes.Skip(instanceTuple.BytesParsed).ToArray(); } return(instances, parsed); }
public JsonResult CreateParent(Parent item) { ParentModule module = new ParentModule(_context); int parentID = module.CreateParent(item); return(Json(new { Succeeded = true, statusCode = 200, parentID = parentID })); }
public JsonResult Get() { ParentModule module = new ParentModule(_context); var resultVal = module.GetList(); return(Json(resultVal)); }
public async Task <JsonResult> LoginTest(LoginViewModel model) { ParentModule module = new ParentModule(_context); // Users item = new Users(); IQueryable <Users> item = module.GetParentInfo(model.Email); // If we got this far, something failed, redisplay form return(Json(item)); }
public JsonResult RegisterByDeskTop(Register model) { UserModule module = new UserModule(_context, _userManager, _signInManager); ParentModule parentMod = new ParentModule(_context); StudentModule studentMod = new StudentModule(_context); StudentParentModule stuParMod = new StudentParentModule(_context); StudentClassroomModule stuClassMod = new StudentClassroomModule(_context); //=========== checking validation for credencials key ===============// var credInfo = GetCredentialsInfo(model.Student.Key); // if ( GetCredentialsInfo(model.Student.Key) == null ) if (credInfo == null) { return(Json(new { Succeeded = false, statusCode = 501 })); } var resultVal = module.CreateUserByDeskTop(model.Users); if (resultVal.Result.StatusCode == 200) // success Users table { if (module.GetUserInfo(model.Users) != null) { Users user = new Users { UserName = model.Users.Email, PasswordHash = model.Users.PasswordHash }; string oauthResult = CreateOAuthUser(user); // need validation check. if result is success return success value else delete MPXUser data and return error. if (model.Parent == null) { model.Parent = new Parent(); } model.Parent.UserId = module.GetUserInfo(model.Users).Id; //select userID int parentID = parentMod.CreateParent(model.Parent); //save parent info model.Student.ParentID = parentID; int studentID = studentMod.CreateStudent(model.Student); //save student info StudentParent stuParModel = new StudentParent { ParentID = parentID, StudentID = studentID }; stuParMod.CreateStudentParent(stuParModel); //save StudentParent info StudentClassroom stuClassModel = new StudentClassroom { StudentID = studentID, IsActive = true, ClassroomID = credInfo.Teacher.ClassroomID }; stuClassMod.CreateStuClassroom(stuClassModel); //save studentclassroom // var roleresult = _userManager.AddToRoleAsync(model.Users, "Superusers"); } } return(Json(resultVal.Result)); }
public (object Instance, int BytesParsed) ObjectFromBytes(byte[] data, int length, Type type) { Type underlyingType = type.GetEnumUnderlyingType(); if (!ParentModule.HasConverterOfType(underlyingType)) { NetBase.WriteDebug($"Invalid element type for enum conversion! ({underlyingType})", true); } return(ParentModule.ObjectFromBytes(underlyingType, data, length)); }
void AddConditionButton_Click(object sender, EventArgs e) { try { SearchLayout.SuspendLayout(); new UISearchCondition(ModuleInfo, this); SearchLayout.ResumeLayout(); } catch (Exception ex) { ParentModule.ShowError(ex); } }
public void CreateFixedCondition(ModuleFieldInfo fieldInfo) { try { SearchLayout.SuspendLayout(); var newCondition = new UISearchCondition(ModuleInfo, this); newCondition.SetCondition(fieldInfo); SearchLayout.ResumeLayout(); ConditionModule.UpdateConditionQuery(); } catch (Exception ex) { ParentModule.ShowError(ex); } }
public (object Instance, int BytesParsed) ObjectFromBytes(byte[] data, int length, Type type) { if (length == -1) { return(Encoding.UTF8.GetString(data), data.Length); } //The 'length' parameter here is used to determine how many bytes at the start of the array are for the length of the string data byte[] lengthData = data.Take(length).ToArray(); ushort dataLength = ParentModule.ObjectFromBytes <ushort>(lengthData).Instance; byte[] utf8Bytes = data.Skip(length).Take(dataLength).ToArray(); return(Encoding.UTF8.GetString(utf8Bytes), lengthData.Length + utf8Bytes.Length); }
private double processModulation(object state) { if (!IsDisposed && ModulationEnabled) { double radian = 2 * Math.PI * (modulationStep / HighPrecisionTimer.TIMER_BASIC_1KHZ); double mdepth = 0; if (ParentModule.ModulationDepthes[NoteOnEvent.Channel] > 64) { if (modulationStartCounter < 10d * HighPrecisionTimer.TIMER_BASIC_1KHZ) { modulationStartCounter += 1.0; } if (modulationStartCounter > ParentModule.GetModulationDelaySec(NoteOnEvent.Channel) * HighPrecisionTimer.TIMER_BASIC_1KHZ) { mdepth = (double)ParentModule.ModulationDepthes[NoteOnEvent.Channel] / 127d; } } //急激な変化を抑制 var mv = ((double)ParentModule.Modulations[NoteOnEvent.Channel] / 127d) + mdepth; if (mv != modulationLevel) { modulationLevel += (mv - modulationLevel) / 1.25; } double modHz = radian * ParentModule.GetModulationRateHz(NoteOnEvent.Channel); ModultionDeltaNoteNumber = modulationLevel * Math.Sin(modHz); ModultionDeltaNoteNumber *= ((double)ParentModule.ModulationDepthRangesNote[NoteOnEvent.Channel] + ((double)ParentModule.ModulationDepthRangesCent[NoteOnEvent.Channel] / 127d)); OnPitchUpdated(); if (modulationStep == 0 && IsSoundOff) { return(-1); } modulationStep += 1.0; if (modHz > 2 * Math.PI) { modulationStep = 0; } return(1); } return(-1); }
public byte[] ConvertToBytes(object instance, bool includeLength) { Enum e = (Enum)instance; Type underlyingType = e.GetType().GetEnumUnderlyingType(); if (!ParentModule.HasConverterOfType(underlyingType)) { NetBase.WriteDebug($"Invalid element type for enum conversion! ({underlyingType})", true); } List <byte> data = new List <byte>(); data.AddRange(ParentModule.ConvertToBytes(Convert.ChangeType(e, underlyingType), includeLength)); return(data.ToArray()); }
public async Task <Result> Execute(CommandMetadata data, int x, string type) { if (x <= 0 || x >= 1000) { return(new Result(null, "Failed to create reminder: Amount needs to bigger than 0 and less than 1000")); } DateTime reminderTime = DateTime.Now; switch (type) { case "min": case "mins": reminderTime = reminderTime.AddMinutes(x); break; case "hour": case "hours": reminderTime = reminderTime.AddHours(x); break; case "day": case "days": reminderTime = reminderTime.AddDays(x); break; case "month": case "months": reminderTime = reminderTime.AddMonths(x); break; case "year": case "years": reminderTime = reminderTime.AddYears(x); break; default: return(new Result(null, "Failed to create reminder: Unkown time type")); } await ParentModule.AddReminder(data.Message as IUserMessage, data.AuthorID, reminderTime); return(new Result(null, $"Reminder set {reminderTime.ToShortDateString()} {reminderTime.ToShortTimeString()}")); }
public byte[] ConvertToBytes(object instance, bool includeLength) { string s = (string)instance; byte[] utf8Bytes = Encoding.UTF8.GetBytes(s); if (!includeLength) { return(utf8Bytes); } byte[] lengthBytes = ParentModule.ConvertToBytes((ushort)utf8Bytes.Length); byte[] data = new byte[lengthBytes.Length + utf8Bytes.Length]; lengthBytes.CopyTo(data, 0); utf8Bytes.CopyTo(data, lengthBytes.Length); return(data); }
public int RegisterParent(string userid, string firstname, string lastname) { ParentModule parentMod = new ParentModule(_context); Parent parentItem = new Parent { UserId = userid }; int parentID = parentMod.CreateParent(parentItem); //save parent info Users user = new Users { Id = userid, FirstName = firstname, LastName = lastname }; UserModule module = new UserModule(_context, _userManager, _signInManager); module.GetUpdateUserInfo(user); return(parentID); }
public byte[] ConvertToBytes(object instance, bool includeLength) { Array a = (Array)instance; Type elementType = instance.GetType().GetElementType(); if (!ParentModule.HasConverterOfType(elementType)) { NetBase.WriteDebug($"Invalid element type in array conversion! ({elementType})", true); } List <byte> data = new List <byte>(); data.AddRange(ParentModule.ConvertToBytes((ushort)a.Length)); for (int i = 0; i < a.Length; ++i) { data.AddRange(ParentModule.ConvertToBytes(a.GetValue(i))); } return(data.ToArray()); }
/// <summary> /// /// </summary> /// <returns></returns> protected double CalcCurrentVolume(bool ignoreVelocity) { double v = 1; v *= ParentModule.Expressions[NoteOnEvent.Channel] / 127d; v *= ParentModule.Volumes[NoteOnEvent.Channel] / 127d; if (!ignoreVelocity && string.IsNullOrWhiteSpace(Timbre.MDS.VelocityMap)) { v *= NoteOnEvent.Velocity / 127d; } CombinedTimbreSettings parent = ParentModule.TryGetBaseTimbreSettings(NoteOnEvent, Timbre, BaseTimbreIndex); if (AdsrEngine != null) { v *= AdsrEngine.OutputLevel; } if (FxEngine != null) { v *= FxEngine.OutputLevel; } v *= ArpeggiateLevel; if (parent != null) { v += parent.VolumeOffest; } if (v > 1.0) { v = 1.0; } else if (v < 0.0) { v = 0.0; } return(v); }
public async Task <JsonResult> Login2(LoginViewModel model) { ParentModule module = new ParentModule(_context); if (ModelState.IsValid) { // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure : false); if (result.Succeeded) { _logger.LogInformation(1, "User logged in."); IQueryable <Users> item = module.GetParentInfo(model.Email); return(Json(item)); } } // If we got this far, something failed, redisplay form return(Json("error")); }
private void UpdateConditionValueControl() { m_ConditionGroupLayout.BeginUpdate(); m_EditValueLayoutItem.BeginInit(); if (m_EditValue != null) { m_EditValueLayoutItem.Control = null; m_EditValue.Parent = null; } // Lấy thông tin Field được chọn var fieldInfo = m_Condition.EditValue as ModuleFieldInfo; // Tạo Control theo đúng field m_EditValue = (ParentModule.CreateControl(fieldInfo)) as BaseEdit; ParentModule.SetupControlListSource(fieldInfo, m_EditValue); m_EditValueLayoutItem.Control = m_EditValue; m_EditValueLayoutItem.TextVisible = false; m_EditValueLayoutItem.EndInit(); m_ConditionGroupLayout.EndUpdate(); ParentModule.SetControlDefaultValue(m_EditValue); }
/// <summary> /// /// </summary> /// <returns></returns> protected double CalcCurrentPitchDeltaNoteNumber() { CombinedTimbreSettings parent = ParentModule.TryGetBaseTimbreSettings(NoteOnEvent, Timbre, BaseTimbreIndex); int pKeyShift = parent != null ? parent.KeyShift : 0; int pPitchShift = parent != null ? parent.PitchShift : 0; var pitch = (int)ParentModule.Pitchs[NoteOnEvent.Channel] - 8192; var range = (int)ParentModule.PitchBendRanges[NoteOnEvent.Channel]; var scale = (int)ParentModule.ScaleTunings[NoteOnEvent.Channel].ScalesNums[(int)Math.Abs(NoteOnEvent.NoteNumber + Timbre.MDS.KeyShift + pKeyShift) % 12]; double d1 = ((double)pitch / 8192d) * range; double d = d1 + ModultionDeltaNoteNumber + PortamentoDeltaNoteNumber + ArpeggiateDeltaNoteNumber + pKeyShift + Timbre.MDS.KeyShift + ((pPitchShift + Timbre.MDS.PitchShift) / 100d) + (scale / 100d); if (FxEngine != null) { d += FxEngine.DeltaNoteNumber; } lastPitch = d; return(d); }
private void UpdateOperatorComboBox() { // Lấy thông tin Field được chọn var field = m_Condition.EditValue as ModuleFieldInfo; // Lấy các phép toán tương ứng với FieldType if (field != null) { var opField = FieldUtils.GetModuleFieldByID( ParentModule.ModuleInfo.ModuleType, field.ConditionType); m_ConditionGroupLayout.BeginUpdate(); m_EditValueLayoutItem.BeginInit(); if (m_Operator != null) { m_OperatorLayoutItem.Control = null; m_Operator.Parent = null; } m_Operator = (ImageComboBoxEdit)ParentModule.CreateControl(opField); ParentModule.SetControlListSource(m_Operator); } m_OperatorLayoutItem.Control = m_Operator; m_OperatorLayoutItem.TextVisible = false; m_OperatorLayoutItem.SizeConstraintsType = SizeConstraintsType.Custom; m_OperatorLayoutItem.MinSize = m_OperatorLayoutItem.MaxSize = new Size(180, 1); m_EditValueLayoutItem.EndInit(); m_ConditionGroupLayout.EndUpdate(); ParentModule.SetControlDefaultValue(m_Operator); }
/// <summary> /// /// </summary> /// <returns></returns> protected byte CalcCurrentPanpot() { int pan = ParentModule.Panpots[NoteOnEvent.Channel] - 1; if (FxEngine != null) { pan += FxEngine.PanShift; } if (ParentModule.ChannelTypes[NoteOnEvent.Channel] == ChannelType.Drum) { pan += (int)ParentModule.DrumTimbres[NoteOnEvent.NoteNumber].PanShift; } else { pan += Timbre.MDS.PanShift; } CombinedTimbreSettings parent = ParentModule.TryGetBaseTimbreSettings(NoteOnEvent, Timbre, BaseTimbreIndex); if (parent != null) { pan += parent.PanShift; } if (pan < 0) { pan = 0; } else if (pan > 127) { pan = 127; } return((byte)pan); }
public bool IsBlocked(long guildId) { return(!(BlockedCommandService.Instance.Repository.GetByName(Name, guildId) == null) || (ParentModule != BotConstants.EmptyParent ? ParentModule.IsBlocked(guildId) : false)); }