/// <summary> /// برای ثبت بازدید وبسایت /// </summary> protected void Session_Start() { NetworkOperation objNetworkOperation = new NetworkOperation(); VisitWebsiteLog objVisitWebsiteLog = new VisitWebsiteLog(); string CurrentClientIP = objNetworkOperation.ClientIPaddress(); try { objVisitWebsiteLog.StartOperation(CurrentClientIP); } catch (Exception) { } //} }
public async Task <ActionResult> AddComment(vmComment input) { if (!ModelState.IsValid) { foreach (var item in ModelState) { var errors = item.Value.Errors.ToList(); } return(Json("null")); } if (input.CaptchaText.ToLower() == HttpContext.Session["captchastring"].ToString().ToLower()) { Session.Remove("captchastring"); NetworkOperation objNetworkOperation = new NetworkOperation(); VisitWebsiteLog visitWebsiteLog = new VisitWebsiteLog(); string CurrentClientIP = null; CurrentClientIP = objNetworkOperation.ClientIPaddress(); IpInformation IpInfo = visitWebsiteLog.GetLocationIPINFO(CurrentClientIP); var _objEntityMessage = new RepositoryPattern <PostComment>(new ApplicationDbContext()); var NewItem = new PostComment { PostID = input.PostID, FullName = input.FullName, Comment = input.Comment, Email = input.Email, SendDate = DateConvertor.DateToNumber(DateConvertor.TodayDate()), SendTime = DateConvertor.TimeNow(), Browser = objNetworkOperation.ClientBrowser(), DeviceInfo = objNetworkOperation.ClientDeviceType(), IP_Address = CurrentClientIP, HostName = objNetworkOperation.ClientHostName(), country = IpInfo.country, city = IpInfo.city, countryCode = IpInfo.countryCode, org = IpInfo.org, region = IpInfo.region, regionName = IpInfo.regionName, status = IpInfo.status, timezone = IpInfo.timezone, mobile = IpInfo.mobile == true ? true :false, Is_Active = "1" }; _objEntityMessage.Insert(NewItem); _objEntityMessage.Save(); _objEntityMessage.Dispose(); try { var _objEntityPost = new RepositoryPattern <Post>(new ApplicationDbContext()); OpratingClasses.EmailService emailService = new OpratingClasses.EmailService(); var strSubject = " نام و نام خانوادگی : " + NewItem.FullName; var strMessage = " ديدگاه كاربر راجع به پست : " + _objEntityPost.GetByPredicate(X => X.ID == NewItem.PostID).Title.Trim() + " <br /> " + NewItem.Comment + " <br /> " + " ایمیل : " + NewItem.Email + " <br /> " + " ساير اطلاعات : " + NewItem.DeviceInfo + " - " + NewItem.country + NewItem.city + " <br /> " + " تاریخ و ساعت ارسال : " + NewItem.SendDate + " - " + NewItem.SendTime; //" <br /> <p styel=\"font-family:\"Tahoma;\"\">" + NewItem.Comment + await emailService.SendMail(strSubject, strMessage); } catch (Exception) { } return(PartialView("_PartialPageComment", NewItem)); } else { return(Json("CaptchaTextMistake")); //ViewBag.Message = "CAPTCHA verification failed!"; } }