public JsonResult SendNewEventEmailToSubscribers() { List <EventDataModal> eventdata = _EventService.GetAllNewEvents(); List <EventViewModal> events = Mapper.Map <List <EventDataModal>, List <EventViewModal> >(eventdata); List <EmailSubscriberDataModal> subscribers = _SubscribeService.GetAllEmailSubscriber(); string MailUserName = ConfigurationManager.AppSettings["MailUserName"] != null ? ConfigurationManager.AppSettings["MailUserName"].ToString() : ""; string NewEventMailSubject = ConfigurationManager.AppSettings["NewEventMailSubject"] != null ? ConfigurationManager.AppSettings["NewEventMailSubject"].ToString() : "Checkout our new Event!"; List <int> eventids = new List <int>(); foreach (EventViewModal evt in events) { bool isError = false; String emailhtml = MvcHelpers.RenderViewToString(this.ControllerContext, "~/Views/Subscribe/NewEventEmail.cshtml", evt); foreach (EmailSubscriberDataModal sb in subscribers) { isError = EmailHelper.SendEmail(MailUserName, sb.Email, NewEventMailSubject, emailhtml, null, "", true); } if (isError) { eventids.Add(evt.EventID); } } _EventService.SetEmailSentFlag(eventids); return(Json(new { Code = 1, Message = "Success!" }, JsonRequestBehavior.AllowGet)); }
protected bool SetViewBagGlobalPermissionAndCheckAny(params ActionEnum[] action) { var permissions = SetViewBagGlobalPermission(action); var someTrue = MvcHelpers.CheckSomeRoles(permissions, action); return(someTrue); }
public List <SelectListItem> GetCountryOrRelated(string operationNumber, string lang, string type) { var responseCountries = _correspondenceService.GetRegionalCountry(operationNumber, lang); var list = new List <SelectListItem>(); var listRepository = _catalogService.GetMasterDataListByTypeCode(typeCodes: type); if (!string.IsNullOrWhiteSpace(operationNumber)) { var operation = SiscorHelper.GetOperation(operationNumber); if (operation.CountryRelated.Count > 0) { var rolAdminId = _catalogService.GetConvergenceMasterDataIdByCode("CTY_ADMIN", "CTY_ROLE").Id; var countryAdmin = operation.CountryRelated.Where(c => c.RoleId == rolAdminId).FirstOrDefault(); list = responseCountries.RegionalCountries.Select(o => new SelectListItem { Selected = o.Code == countryAdmin.Country.Code, Value = _correspondenceService.GetCountryCode(o.Code), Text = MvcHelpers.GetItemName(o, Localization.CurrentLanguage), }).ToList(); } else { list = responseCountries.RegionalCountries.Select(o => new SelectListItem { Selected = false, Value = _correspondenceService.GetCountryCode(o.Code), Text = MvcHelpers.GetItemName(o, Localization.CurrentLanguage), }).ToList(); } } return(list); }
public override string Render() { this.InitPager(); var wrapper = new TagBuilder("div"); wrapper.MergeAttribute("data-tabid", this.Builder.Uid.ToString()); if (this.Builder.ConnectsWithIds != null) { wrapper.MergeAttribute("data-connectswith", MvcHelpers.Serialize(this.Builder.ConnectsWithIds)); } wrapper.MergeAttribute("data-editable", MvcHelpers.Serialize(this.Builder.IsEditable)); wrapper.MergeAttribute("data-readonly", MvcHelpers.Serialize(this.Builder.IsReadonly)); wrapper.MergeAttribute("data-loaded", MvcHelpers.Serialize(this.Builder.HasModel)); if (!this.Builder.selected) { wrapper.MergeAttribute("style", "display: none;"); } wrapper.InnerHtml += this.RenderContent(); return(wrapper.ToString()); }
private static List <SelectListItem> GetListItems( IEnumerable <MasterDataViewModel> masterData, string type, string language) { if (type == MonitoringReportType.Country) { masterData = masterData.Where(x => x.Code != CountryCode.UND && x.Code != CountryCode.IDB && (!x.ExpirationDate.HasValue || x.ExpirationDate.Value > DateTime.Today) && x.TypeName == type); } var listItem = (from item in masterData where item.TypeName == type select new SelectListItem { Selected = false, Text = MvcHelpers.GetItemName(item, language), Value = item.MasterId.ToString(), Group = new SelectListGroup { Name = item.ParentMasterId.ToString() } }).OrderBy(o => o.Text).ToList(); return(listItem); }
public void Should_set_the_result_of_the_filtercontext() { // Arrange SecurityConfigurator.Configure(policy => { policy.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsTrue); policy.For <BlogController>(x => x.Index()).DenyAnonymousAccess(); }); var expectedResult = new ViewResult { ViewName = "SomeViewName" }; var securityHandler = new Mock <ISecurityHandler>(); securityHandler.Setup(x => x.HandleSecurityFor(typeof(BlogController).FullName, "Index", It.IsAny <ISecurityContext>())).Returns(expectedResult); var handleSecurityAttribute = new HandleSecurityAttribute(securityHandler.Object); var filterContext = MvcHelpers.GetAuthorizationContextFor <BlogController>(x => x.Index()); // Act handleSecurityAttribute.OnAuthorization(filterContext); // Assert Assert.That(filterContext.Result, Is.EqualTo(expectedResult)); }
public void Should_set_the_result_of_the_filtercontext() { // Arrange SecurityConfigurator.Configure(policy => { policy.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsTrue); policy.For <BlogController>(x => x.Index()).DenyAnonymousAccess(); }); var expectedResult = new ViewResult { ViewName = "SomeViewName" }; var securityHandler = MockRepository.GenerateMock <ISecurityHandler>(); securityHandler.Expect(x => x.HandleSecurityFor(typeof(BlogController).FullName, "Index")).Repeat.Once().Return(expectedResult); securityHandler.Replay(); var handleSecurityAttribute = new HandleSecurityAttribute(securityHandler); var filterContext = MvcHelpers.GetFilterContextFor <BlogController>(x => x.Index()); // Act handleSecurityAttribute.OnActionExecuting(filterContext); // Assert Assert.That(filterContext.Result, Is.EqualTo(expectedResult)); securityHandler.VerifyAllExpectations(); }
public string RenderMoveToGroups() { if (!this.Builder.isReadonly && this.Builder.GroupConfigurator.Groups.Any()) { var button = new TagBuilder("button"); var glyph = GetGlyphiconTag(Glyphicon.ShareAlt); if (this.Builder.GroupConfigurator.Groups.Count > 1) { var divContainer = new TagBuilder("div"); divContainer.AddCssClass("btn-white btn pull-right bs-bulkGroupMove"); var dropdownA = new TagBuilder("a"); dropdownA.MergeAttribute("data-toggle", "dropdown"); dropdownA.MergeAttribute("href", "#"); dropdownA.InnerHtml += BsResourceManager.Resource("GroupEditorMoveToGroups"); dropdownA.InnerHtml += glyph; var dropdownUl = new TagBuilder("ul"); dropdownUl.AddCssClass("dropdown-menu"); dropdownUl.MergeAttribute("style", "top:auto"); foreach (var group in this.Builder.GroupConfigurator.Groups) { var li = new TagBuilder("li"); var a = new TagBuilder("a"); a.MergeAttribute("href", "#"); a.MergeAttribute("class", "bs-moveToGroupBtn"); a.MergeAttribute("data-groupid", MvcHelpers.Serialize(group.Value.Uid)); a.InnerHtml += group.Value.Name; li.InnerHtml += a; dropdownUl.InnerHtml += li; } divContainer.InnerHtml += dropdownA; divContainer.InnerHtml += dropdownUl; return(divContainer.ToString()); } else { button.AddCssClass("btn-white btn pull-right bs-bulkGroupMove"); button.InnerHtml += BsResourceManager.Resource("GroupEditorMoveToGroups"); button.InnerHtml += glyph; button.AddCssClass("bs-moveToGroupBtn"); button.MergeAttribute("data-groupid", MvcHelpers.Serialize(this.Builder.GroupConfigurator.Groups.First().Value.Uid)); return(button.ToString()); } } return(string.Empty); }
protected void SetViewBagPermissionAndCheckAny(string operationNumber, params ActionEnum[] action) { var permissions = SetViewBagPermission(operationNumber, action); var someTrue = MvcHelpers.CheckSomeRoles(permissions, action); if (!someTrue) { throw new Exception(Localization.GetText(FRIENDLY_PERMISSION_ERROR)); } }
private static List <SelectListItem> GetListItemsCountryDepartments(List <ConvergenceMasterData> countryDepartments, string language) { var listItem = (from item in countryDepartments select new SelectListItem { Selected = false, Text = MvcHelpers.GetItemName(item, language), Value = item.ConvergenceMasterDataId.ToString() }).OrderBy(o => o.Text).ToList(); return(listItem); }
public FileResult TORG12(Guid id) { var client = new WebClient(); var t = db.Orders.First(x => x.Id == id); client.Encoding = Encoding.UTF8; var p = MvcHelpers.RenderViewToString(this.ControllerContext, "TORG12View", t); var workStream = new MemoryStream(); using (var writer = new PdfWriter(workStream)) { PdfDocument pdf = new PdfDocument(writer); pdf.SetTagged(); PageSize pageSize = PageSize.A4; pdf.SetDefaultPageSize(pageSize); ConverterProperties properties = new ConverterProperties(); writer.SetCloseStream(false); using (var document = HtmlConverter.ConvertToDocument(p, pdf, properties)) { } } workStream.Position = 0; var doc_guid = Guid.NewGuid(); t.OrderTransferDoc = new DB.OrderTransferDoc { User_Id = db.AspNetUsers.First(x => x.UserName == User.Identity.Name).Id, OperDate = DateTime.Now, DocDate = t.DocDate, DocNumber = t.DocNumber.ToString(), Id = doc_guid, }; db.SaveChanges(); foreach (var pos in t.OrderPositions) { db.WarehouseItems.Add(new DB.WarehouseItem { Count = -pos.Count, Id = Guid.NewGuid(), Material_Id = pos.Material_Id, VATRate_Id = (int)pos.VATRate_Id, Price = pos.Price, OrderTransferDoc_Id = doc_guid, OrderInvoiceDate = DateTime.Today, }); db.SaveChanges(); } return(File(workStream, "application/pdf")); }
public ListCountryResponse GetCountryList() { var response = new ListCountryResponse(); var countryList = _catalogService.GetMasterDataListByTypeCode(true, MasterType.COUNTRY_ASSOCIATED); response.CountryList = countryList.MasterDataCollection.Select(o => new ListItemViewModel { Value = o.MasterId.ToString(), Text = MvcHelpers.GetItemName(o, Localization.CurrentLanguage) }).OrderBy(x => x.Text).ToList(); return(response); }
public SelectListItem GetOrganizationalUnitForCode(string code) { var result = new SelectListItem(); var OrgUnit = _missionService.GetOrganizationalUnitForCode(code).FirstOrDefault(); if (OrgUnit != null) { result.Selected = false; result.Value = OrgUnit.MasterId.ToString(); result.Text = MvcHelpers.GetItemName(OrgUnit, Localization.CurrentLanguage); } return(result); }
public void Should_call_HandleSecurityFor_with_the_controllername_Blog_and_actionname_Index_passing_the_current_security_context() { // Arrange var securityHandler = new Mock <ISecurityHandler>(); var handleSecurityAttribute = new HandleSecurityAttribute(securityHandler.Object); var filterContext = MvcHelpers.GetFilterContextFor <BlogController>(x => x.Index()); // Act handleSecurityAttribute.OnActionExecuting(filterContext); // Assert Assert.That(filterContext.Result, Is.Null); securityHandler.Verify(x => x.HandleSecurityFor(typeof(BlogController).FullName, "Index", _securityContext), Times.Exactly(1)); }
public void Should_add_route_values_to_current_security_context() { // Arrange var securityHandler = new Mock <ISecurityHandler>(); var handleSecurityAttribute = new HandleSecurityAttribute(securityHandler.Object); var filterContext = MvcHelpers.GetFilterContextFor <BlogController>(x => x.Index()); // Act handleSecurityAttribute.OnActionExecuting(filterContext); // Assert Assert.That(_securityContext.Data.RouteValues, Is.Not.Null); Assert.That(_securityContext.Data.RouteValues, Is.EqualTo(filterContext.RouteData.Values)); }
public virtual TagBuilder GetContainer(out TagBuilder body) { var container = new TagBuilder("div"); container.MergeAttributes(this.Builder.htmlAttributes, true); if (!String.IsNullOrEmpty(this.Builder.editableUrl)) { container.MergeAttribute("data-editableurl", this.Builder.editableUrl); } if (!String.IsNullOrEmpty(this.Builder.readonlyUrl)) { container.MergeAttribute("data-readonlyurl", this.Builder.readonlyUrl); } if (!String.IsNullOrEmpty(this.Builder.saveUrl)) { container.MergeAttribute("data-saveurl", this.Builder.saveUrl); } container.MergeAttribute("data-settings", HtmlHelper.AnonymousObjectToHtmlAttributes(new { loaded = this.Builder.isLoaded, initialReadonly = this.Builder.initialReadonly, editable = this.Builder.isEditable, isEditableBtnVisible = this.Builder.isEditableBtnVisible }).ToJsonString()); if (this.Builder.id != null) { container.MergeAttribute("data-component", MvcHelpers.Serialize(this.Builder.id)); } container.AddCssClass("panel"); container.AddCssClass(this.GetThemeClass()); if (this.Builder.objId != null) { container.MergeAttribute("data-objid", MvcHelpers.Serialize(this.Builder.objId)); } body = container; return(container); }
public List <SelectListItem> GetListMasterDataStage(string type, string stage) { var list = new List <SelectListItem>(); var listRepository = _catalogService.GetMasterDataListByTypeCode(typeCodes: type); if (listRepository != null && listRepository.MasterDataCollection != null && listRepository.MasterDataCollection.Count > 0) { list = listRepository.MasterDataCollection.Where(x => x.Code.IndexOf(stage, StringComparison.OrdinalIgnoreCase) >= 0).Select(o => new SelectListItem { Selected = false, Value = o.MasterId.ToString(), Text = MvcHelpers.GetItemName(o, Localization.CurrentLanguage), }).ToList(); } return(list); }
public List <SelectListItem> GetListMasterData(int type) { var list = new List <SelectListItem>(); var listRepository = _catalogService.GetMasterDataListByTypeId(masterTypeIds: type); if (listRepository != null && listRepository.MasterDataCollection.Count > 0) { list = listRepository.MasterDataCollection.Select(o => new SelectListItem { Selected = false, Value = o.MasterId.ToString(), Text = MvcHelpers.GetItemName(o, Localization.CurrentLanguage), }).ToList(); } return(list); }
public FileResult OplataCount(Guid id) { var client = new WebClient(); client.Encoding = Encoding.UTF8; var p = MvcHelpers.RenderViewToString(this.ControllerContext, "OplataCountView", db.Orders.First(x => x.Id == id)); var workStream = new MemoryStream(); using (var pdfWriter = new PdfWriter(workStream)) { pdfWriter.SetCloseStream(false); using (var document = HtmlConverter.ConvertToDocument(p, pdfWriter)) { } } workStream.Position = 0; return(File(workStream, "application/pdf")); }
public List <SelectListItem> GetMissionTypeListFiltered(string operationNumber) { var list = new List <SelectListItem>(); var listRepository = _missionService.GetTypeMissions(operationNumber); if (listRepository != null && listRepository.Count > 0) { list = listRepository.Select(o => new SelectListItem { Selected = false, Value = o.MasterId.ToString(), Text = MvcHelpers.GetItemName(o, Localization.CurrentLanguage), }).ToList(); } return(list); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (!filterContext.IsChildAction) { //validate IP address if (ValidateIpAddress()) { // check user login? User user = WorkContext.CurrentUser; if (user == null) { //Logger.Error("Access denied to anonymous user"); filterContext.Result = RedirectToAction("index", new { area = "CoreModules", controller = "Login", returnUrl = filterContext.HttpContext.Request.RawUrl }); } else { // check permission? string area = MvcHelpers.GetAreaName(filterContext.RouteData); string controller = MvcHelpers.GetControllerName(filterContext.RouteData); string action = MvcHelpers.GetActionName(filterContext.RouteData); if (user.Id != 1 && !_authorizationService.isAllowed(user, area + "/" + controller, action)) { //Logger.Error("Access denied to this user: "******"ReturnUrl"]); filterContext.Result = RedirectToAction("AccessDenied", new { area = "Users", controller = "Users" }); } else { //Set default Title for page Title = action + " | " + controller; if (area != "" && controller != area) { Title += " | " + area; } } } } else { filterContext.Result = RedirectToAction("AccessDenied", new { area = "Users", controller = "Users" }); } } base.OnActionExecuting(filterContext); }
public ActionResult Play(DecodedMessage msg) { var m = db.Messages.Where(ms => ms.Id == msg.MessageId).FirstOrDefault(); DecodeResult dr = new DecodeResult(); if (m != null) { double concordance = 0; if (!string.IsNullOrWhiteSpace(msg.OriginalMessage)) { concordance = m.Text.FuzzyCompare(msg.OriginalMessage); } dr.Fitness = concordance; dr.Score = msg.Score; if (concordance > 0.85) { dr.IsCorrect = true; } else { dr.IsCorrect = false; } } else { dr.IsCorrect = false; } var login = MvcHelpers.GetUsername(); var user = db.Users.Where(a => a.Username == login).First(); ViewBag.User = login; user.Score = (user.Score ?? 0) + (dr.IsCorrect ? msg.Score : -1); user.Complexity = Math.Max(msg.Complexity, user.Complexity ?? 0) + (dr.IsCorrect ? 1 : 0); user.LastAttempt = DateTime.Now; user.Attempted = (user.Attempted ?? 0) + 1; user.Deciphered = (user.Deciphered ?? 0) + (dr.IsCorrect ? 1 : 0); db.SubmitChanges(); dr.TotalScore = user.Score ?? 0; return(View("Result", dr)); }
public List <SelectListItem> AddOptionsDocumentsDropDown(string language) { var documentsList = new List <SelectListItem>(); var descriptionsList = _catalogService .GetMasterDataListByTypeCode(true, typeCodes: PCRIDBDocumentList); if (descriptionsList != null) { documentsList.AddRange(descriptionsList.MasterDataCollection.Select(t => new SelectListItem { Selected = false, Text = MvcHelpers.GetItemName(t, language), Value = t.MasterId.ToString() })); } return(documentsList); }
public string GetStatusDrafMasterData(string type, string codStatus) { string status = string.Empty; var listRepository = _catalogService.GetMasterDataListByTypeCode(true, typeCodes: type); if (listRepository != null && listRepository.MasterDataCollection != null && listRepository.MasterDataCollection.Count > 0) { status = listRepository.MasterDataCollection.Where(a => a.Code.Equals(codStatus)).Select(o => new SelectListItem { Selected = false, Value = o.MasterId.ToString(), Text = MvcHelpers.GetItemName(o, Localization.CurrentLanguage), }).ToList().FirstOrDefault().Text.ToString(); } return(status); }
public List <SelectListItem> GetListMaster(string type) { var list = new List <SelectListItem>(); var listRepository = _catalogService.GetMasterDataListByTypeCode(true, type); if (listRepository != null && listRepository.MasterDataCollection != null && listRepository.MasterDataCollection.Count > 0) { list = listRepository.MasterDataCollection.Select(o => new SelectListItem { Selected = false, Value = o.Code.ToString(), Text = MvcHelpers.GetItemName(o, Localization.CurrentLanguage) }).OrderByDescending(o => o.Text).ToList(); } return(list); }
public virtual TagBuilder GetContainer(out TagBuilder body) { var container = new TagBuilder("div"); container.MergeAttributes(this.Builder.htmlAttributes, true); if (!String.IsNullOrEmpty(this.Builder.editableUrl)) { container.MergeAttribute("data-editableurl", this.Builder.editableUrl); } if (!String.IsNullOrEmpty(this.Builder.readonlyUrl)) { container.MergeAttribute("data-readonlyurl", this.Builder.readonlyUrl); } if (!String.IsNullOrEmpty(this.Builder.saveUrl)) { container.MergeAttribute("data-saveurl", this.Builder.saveUrl); } container.MergeAttribute("data-settings", HtmlHelper.AnonymousObjectToHtmlAttributes(new { loaded = this.Builder.isLoaded, initialReadonly = this.Builder.initialReadonly, headerToggle = !this.Builder.mode.HasValue || this.Builder.mode.Value == BsPanelMode.Both, editable = this.Builder.isEditable && ((!this.Builder.mode.HasValue || (this.Builder.mode.Value == BsPanelMode.Editable || this.Builder.mode.Value == BsPanelMode.Both))) }).ToJsonString()); if (this.Builder.id != null) { container.MergeAttribute("data-component", MvcHelpers.Serialize(this.Builder.id)); } if (this.Builder.objId != null) { container.MergeAttribute("data-objid", MvcHelpers.Serialize(this.Builder.objId)); } body = container; return(container); }
public List <SelectListItem> GetListNationality(string type) { var types = new string[] { type, TCMGlobalValues.NATIONALITY_ALL }; var list = new List <SelectListItem>(); var listRepository = _catalogService.GetMasterDataListByTypeCode(true, types); if (listRepository != null && listRepository.MasterDataCollection != null && listRepository.MasterDataCollection.Count > 0) { list = listRepository.MasterDataCollection.Where(o => o.Code != "UND" && o.Code != "AC" && o.NameEn != "HQ" && o.NameEn != "IDB" && o.NameEn != "HEADQUARTERS WASH. D.C.").Select(o => new SelectListItem { Selected = false, Value = o.MasterId.ToString(), Text = MvcHelpers.GetItemName(o, Localization.CurrentLanguage) }).Distinct().ToList(); } return(list); }
public FileResult Akt() { var client = new WebClient(); Guid id = Guid.Parse("435A000D-AC32-4C50-ACDD-2BB31CCA76F0"); //client.Encoding = Encoding.UTF8; //var p = client.DownloadString(Request.Url.ToString().Replace("Akt", "AktView")); var p = MvcHelpers.RenderViewToString(this.ControllerContext, "AktView", db.Orders.First(x => x.Id == id)); var workStream = new MemoryStream(); using (var pdfWriter = new PdfWriter(workStream)) { pdfWriter.SetCloseStream(false); using (var document = HtmlConverter.ConvertToDocument(p, pdfWriter)) { } } workStream.Position = 0; return(File(workStream, "application/pdf")); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { // only process for main action, not for Child Action if (!filterContext.IsChildAction) { //string ip = GetRemoteIP(); //check licence when application run online //string serverName = GetServerName(); //if (EngineContext.Current.CheckLicense()) //IsPrivateIP(ip) || //{ if (string.IsNullOrEmpty(Title)) { //Set default Title for page string area = MvcHelpers.GetAreaName(filterContext.RouteData); string controller = MvcHelpers.GetControllerName(filterContext.RouteData); string action = MvcHelpers.GetActionName(filterContext.RouteData); //Set default Title for page Title = action + " | " + controller; if (area != "" && controller != area) { Title += " | " + area; } } if (string.IsNullOrEmpty(MetaDescription)) { MetaDescription = systemSettingService.Get("MetaDescription"); } if (string.IsNullOrEmpty(MetaKeyword)) { MetaKeyword = systemSettingService.Get("MetaKeyword"); } //} //else //{ // //Show Invalid Licence // filterContext.Result = RedirectToAction("Invalid", new { area = "Users", controller = "Licence" }); //} } base.OnActionExecuting(filterContext); }
public FileResult FactSchet(Guid id) { var client = new WebClient(); client.Encoding = Encoding.UTF8; var p = MvcHelpers.RenderViewToString(this.ControllerContext, "FactSchetView", db.Orders.First(x => x.Id == id)); var workStream = new MemoryStream(); using (var writer = new PdfWriter(workStream)) { PdfDocument pdf = new PdfDocument(writer); pdf.SetTagged(); PageSize pageSize = PageSize.A4.Rotate(); pdf.SetDefaultPageSize(pageSize); ConverterProperties properties = new ConverterProperties(); writer.SetCloseStream(false); using (var document = HtmlConverter.ConvertToDocument(p, pdf, properties)) { } } workStream.Position = 0; return(File(workStream, "application/pdf")); }