public async Task SendNotification(string userId, string subject, string content, string url, string imageUrl) { var profile = await Repository.AspNetUsers.AspNetUserProfilesGetByUserId(userId); if (profile != null) { //save in user noti var model = new UserNotify(); model.AspNetUsersId = userId; model.Subject = subject; model.Content = content; model.Url = url; model.ImageUrl = imageUrl; await Repository.UserNoti.UserNotiCreateNew(model); if ((bool)profile.AllowNotifyApp) { await Clients.Caller.SendAsync("ReceiveMessage", userId, subject); } if ((bool)profile.AllowNotifyEmail) { await Repository.Setting.SendMail("Thông báo từ hệ thống", profile.Email, profile.FullName, subject, content); } if ((bool)profile.AllowNotifySms) { } } }
private UserNotify ConvertDataRowToUserNotify(DataRow row) { var obj = new UserNotify(); obj.Id = row["ins_id"] == DBNull.Value ? -1 : int.Parse(row["ins_id"].ToString()); obj.CreatedOn = row["createdon"] == DBNull.Value ? DateTime.MinValue : DateTime.Parse(row["createdon"].ToString()); obj.Content = row["content"] == DBNull.Value ? string.Empty : row["content"].ToString(); obj.Subject = row["subject"] == DBNull.Value ? string.Empty : row["subject"].ToString(); obj.Priority.Id = row["priority"] == DBNull.Value ? string.Empty : row["priority"].ToString(); obj.Priority.Name = row["priority_name"] == DBNull.Value ? string.Empty : row["priority_name"].ToString(); obj.Status.Id = row["status"] == DBNull.Value ? string.Empty : row["status"].ToString(); obj.Status.Name = row["status_name"] == DBNull.Value ? string.Empty : row["status_name"].ToString(); obj.StatusOn = row["status_time"] == DBNull.Value ? DateTime.MinValue : DateTime.Parse(row["status_time"].ToString()); obj.CreatedBy.Id = row["createdbyid"] == DBNull.Value ? string.Empty : row["createdbyid"].ToString(); obj.CreatedBy.Account = row["createdbyacc"] == DBNull.Value ? 0 : int.Parse(row["createdbyacc"].ToString()); obj.CreatedBy.Name = row["createdby_name"] == DBNull.Value ? string.Empty : row["createdby_name"].ToString(); obj.ExpireOn = row["expire_time"] == DBNull.Value ? DateTime.MinValue : DateTime.Parse(row["expire_time"].ToString()); obj.NotifyToList = GetUserNotifyToList(obj.Id); if (obj.Status.Id == "post") { obj.UserNotifyHistoryCount = new UserNotifyHistoryRepo(db).GetUserNotifyHisCount(obj.Id); } else { obj.UserNotifyHistoryCount = 0; } return(obj); }
public OpertionResult Create(UserNotify obj, bool thenPostIt = false) { try { #region Parameters var parameters = new List <OracleParameter> { new OracleParameter { ParameterName = "retVal", OracleDbType = OracleDbType.Int32, Direction = ParameterDirection.ReturnValue }, new OracleParameter { ParameterName = "v_subject", OracleDbType = OracleDbType.NVarchar2, Value = obj.Subject }, new OracleParameter { ParameterName = "v_content", OracleDbType = OracleDbType.NVarchar2, Value = obj.Content }, new OracleParameter { ParameterName = "v_priority", OracleDbType = OracleDbType.Varchar2, Value = obj.Priority.Id }, new OracleParameter { ParameterName = "v_createdbyid", OracleDbType = OracleDbType.Varchar2, Value = obj.CreatedBy.Id }, new OracleParameter { ParameterName = "v_expire_time", OracleDbType = OracleDbType.Date, Value = obj.ExpireOn }, new OracleParameter { ParameterName = "v_post_it", OracleDbType = OracleDbType.Int32, Value = thenPostIt ? 1 : 0 } }; #endregion db.ExecuteStoredProc("pk_infra.fn_create_usersinstruct", parameters); var result = int.Parse(parameters.Find(x => x.ParameterName == "retVal").Value.ToString()); if (result > 0) { foreach (var item in obj.NotifyToList) { item.UserNotifyId = result; CreateUserNotifyTo(item); } return(new OpertionResult { AffectedCount = result, Success = true, Error = string.Empty }); } else { return(new OpertionResult { AffectedCount = result, Success = false, Error = string.Empty }); } } catch (Exception ex) { return(new OpertionResult { AffectedCount = -1, Success = false, Error = ex.Message }); } }
public IActionResult Create(UserNotifyDto model) { var currentRoleId = partnerManager.GetCurrentUserRole(this.HttpContext); var permission = partnerActivity.GetPartAct("UserNotify.Create", currentRoleId); if (permission == null) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } if (model.Id > 0) { toastNotification.AddErrorToastMessage("تم الحفظ مسبقا", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } if (ModelState.IsValid) { var created = new UserNotify(); created.Content = model.Content; created.Subject = model.Subject; created.ExpireOn = model.ExpireOn; created.Priority.Id = model.PriorityId; created.CreatedBy.Id = partnerManager.GetCurrentUserId(this.HttpContext); created.CreatedBy.Account = partnerManager.GetCurrentUserAccount(this.HttpContext); if (!string.IsNullOrEmpty(model.SelectedRoles)) { var roles = model.SelectedRoles.Split(','); foreach (string item in roles) { var notifyTo = new UserNotifyTo(); notifyTo.Role.Id = int.Parse(item); created.NotifyToList.Add(notifyTo); } } var result = new UserNotifyRepo(db).Create(created); if (result.AffectedCount > 0) { toastNotification.AddSuccessToastMessage("تم اضافة التعميم بنجاح", new ToastrOptions { Title = "" }); ModelState.Clear(); model.Id = result.AffectedCount; } } model.Priorities = new CommonCodeRepo(db).GetCodesByType("priority"); model.Roles = new RoleRepo(db, partnerActivity).GetAuthorizedRoles("UserNotify.Create", currentRoleId); return(View(model)); }
protected void LoginUser_LoggingIn(object sender, LoginCancelEventArgs e) { MembershipUser user = Membership.GetUser(LoginUser.UserName); if (user != null) { if (user.IsApproved == false) { LoginUser.FailureText = "Your account is disabled. Please contact administrator"; } } UserNotify test = new UserNotify("Have Fun !!"); ShoppingCart.GetShoppingCart(LoginUser.UserName); }
protected void Page_Load(object sender, EventArgs e) { // Get the upc, item name and discount price from the query string. UserNotify test = new UserNotify("Have Fun !!"); string connectionString = "AsiaWebShopDBConnectionString"; string userName = User.Identity.Name; //string OrderNum = GetOrderNumber(connectionString, userName); int OrderNum = GenericQuery.GetOrderNumber(connectionString, userName); string upc = Request.QueryString["upc"].Trim(); string name = Request.QueryString["name"].Trim(); decimal discountPrice = Convert.ToDecimal(Request.QueryString["discountPrice"].Trim()); decimal amountSavedForOne = Convert.ToDecimal(Request.QueryString["normalPrice"].Trim()) - discountPrice; // Add the item to the shopping cart with default quantity = 1. if (upc != "") { ShoppingCart cart = ShoppingCart.GetShoppingCart(userName); CartItem temp = new CartItem(upc); if (GenericQuery.CheckItemStock(connectionString, temp, 0)) { cart.AddItem(upc, name, discountPrice, 1, false); GenericQuery.InsertToShoppingCart(connectionString, 1, OrderNum, upc, name, discountPrice, amountSavedForOne); HttpContext.Current.Session["MyShoppingCart"] = cart; // View the shopping cart. Response.Redirect("~/MemberOnly/ViewShoppingCart.aspx"); } else { UserNotify.add = "no"; Response.Redirect("~/ItemSearch.aspx"); } ///TODO: Add the item to the shopping cart in the database. // Save the shopping cart in the Session variable "MyShoppingCart". } else { Debug.Fail("ERROR : We should never get to AddToCart.aspx without a UPC."); throw new Exception("ERROR : It is illegal to load AddToCart.aspx without setting a UPC."); } }
public async Task SendNotification(string userId, string subject, string content, string url, string imageUrl) { var userIdentifier = (from _connectedUser in connectedUsers where _connectedUser.Name == userId select _connectedUser.UserIdentifier).FirstOrDefault(); var profile = await Repository.AspNetUsers.AspNetUserProfilesGetByUserId(userId); if (profile != null) { //save in user noti var model = new UserNotify(); model.AspNetUsersId = userId; model.Subject = subject; model.Content = content; model.Url = url; model.ImageUrl = imageUrl; await Repository.UserNoti.UserNotiCreateNew(model); if ((bool)profile.AllowNotifyApp) { try { await Clients.User(userIdentifier).SendAsync("ReceiveMessage", userId, subject, content, url, imageUrl); } catch (Exception ex) { } } if ((bool)profile.AllowNotifyEmail) { await Repository.Setting.SendMail("Thông báo từ hệ thống", profile.Email, profile.FullName, subject, content); } if ((bool)profile.AllowNotifySms) { } } }