private async void pnlOk_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(txtUserName.Text)) { frmNotification.PublicInfo.ShowMessage("نام کاربری نمی تواند خالی باشد"); txtUserName.Focus(); txtUserName.SelectAll(); return; } if (string.IsNullOrWhiteSpace(txtPass1.Text)) { frmNotification.PublicInfo.ShowMessage("کلمه عبور نمی تواند خالی باشد"); txtPass1.Focus(); txtPass1.SelectAll(); return; } var user = await UserBussines.GetAsync(txtUserName.Text.Trim()); if (user == null) { frmNotification.PublicInfo.ShowMessage($"کاربر با نام کاربری {txtUserName.Text} یافت نشد"); txtUserName.Focus(); txtUserName.SelectAll(); return; } var ue = new UTF8Encoding(); var bytes = ue.GetBytes(txtPass1.Text.Trim()); var md5 = new MD5CryptoServiceProvider(); var hashBytes = md5.ComputeHash(bytes); var password = System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(hashBytes), "-", "") .ToLower(); if (password != user.Password) { frmNotification.PublicInfo.ShowMessage("رمز عبور اشتباه است"); txtPass1.Focus(); txtPass1.SelectAll(); return; } UserBussines.CurrentUser = user; UserBussines.DateVorrod = DateTime.Now; clsGlobalSetting.LastUser = user.UserName; await UserLogBussines.SaveAsync(EnLogAction.Login, EnLogPart.Login, null); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
public async Task <ReturnedSaveFuncInfo> SaveAsync(UserLogBussines item, SqlTransaction tr) { var res = new ReturnedSaveFuncInfo(); try { var cmd = new SqlCommand("sp_UserLog_Insert", tr.Connection, tr) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@guid", item.Guid); cmd.Parameters.AddWithValue("@userGuid", item.UserGuid); cmd.Parameters.AddWithValue("@date", item.Date); cmd.Parameters.AddWithValue("@action", (short)item.Action); cmd.Parameters.AddWithValue("@part", (short)item.Part); cmd.Parameters.AddWithValue("@desc", item.Description); await cmd.ExecuteNonQueryAsync(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); res.AddReturnedValue(ex); } return(res); }
private void BindList(Guid guid) { try { list = UserLogBussines.GetAll(guid); lstCustomers.Adapter = new UserLogAdapter(this, list.OrderByDescending(q => q.Date).ToList()); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private async Task LoadDataAsync() { try { list = await UserLogBussines.GetAllAsync(userGuid, d1, d2); logBindingSource.DataSource = list.OrderByDescending(q => q.Date).ToSortableBindingList(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private UserLogBussines LoadData(SqlDataReader dr) { var item = new UserLogBussines(); try { item.Guid = (Guid)dr["Guid"]; item.UserGuid = (Guid)dr["UserGuid"]; item.UserName = dr["UserName"].ToString(); item.Date = (DateTime)dr["Date"]; item.Action = (EnLogAction)dr["Action"]; item.Part = (EnLogPart)dr["Part"]; item.Description = dr["Description"].ToString(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } return(item); }
private async void frmMain_FormClosing(object sender, FormClosingEventArgs e) { await UserLogBussines.SaveAsync(EnLogAction.Logout, EnLogPart.Logout, null); }