private List <LinkVM> RetrieveAllLinks(string machine) { var ret = new List <LinkVM>(); var mvm = MachineLink.RetrieveLinks(machine); var mvmdict = new Dictionary <string, bool>(); foreach (var item in mvm) { mvmdict.Add(item.LinkName, true); if (string.Compare(item.Action, LINKACTION.DELETE) != 0) { var templink = new LinkVM(); templink.LinkName = item.LinkName; templink.Link = item.Link; templink.Logo = item.Logo; templink.Comment = item.Comment; ret.Add(templink); } } var vm = LinkVM.RetrieveLinks(); foreach (var item in vm) { if (!mvmdict.ContainsKey(item.LinkName)) { ret.Add(item); } } return(ret); }
public async Task <ActionResult> EditUserLink(LinkVM linkVM) { using (ChekitDB chekitDB = new ChekitDB()) { LinkDTO linkDTO = await chekitDB.Links.FirstOrDefaultAsync(x => x.LinkID == linkVM.LinkID); linkDTO.LinkName = linkVM.LinkName; if (linkVM.PublicStatus == false) { linkDTO.PublicStatus = false; } else { linkDTO.PublicStatus = linkVM.PublicStatus; } linkDTO.LinkDescription = linkVM.LinkDescription; await chekitDB.SaveChangesAsync(); TempData["OK"] = "Закладка отредактирована"; return(RedirectToAction("LinkInfo", new { id = linkVM.LinkID })); } }
public JsonResult AllData() { var vm = new List <LinkVM>(); var ckdict = CookieUtility.UnpackCookie(this); if (!ckdict.ContainsKey("reqmachine")) { string IP = Request.UserHostName; string compName = DetermineCompName(IP); if (!string.IsNullOrEmpty(compName)) { var tempdict = new Dictionary <string, string>(); tempdict.Add("reqmachine", compName); CookieUtility.SetCookie(this, tempdict); } //end if vm = LinkVM.RetrieveLinks(); } //end else { vm = RetrieveAllLinks(ckdict["reqmachine"]); } var res = new JsonResult(); res.Data = new { data = vm }; res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(res); }
public ActionResult AddLinkPost() { var linkname = Request["LinkName"]; var link = Request["UrlAddr"]; var comment = Request["comment"]; var logo = GetLinkLogo(); if (!string.IsNullOrEmpty(linkname) && !string.IsNullOrEmpty(link) && !string.IsNullOrEmpty(logo)) { LinkVM.StoreLink(linkname, link, logo, comment); } return(RedirectToAction("All", "SmartLinks")); }
public JsonResult RemoveCustomLink() { var linkname = Request.Form["link_name"]; var vm = new List <LinkVM>(); var machine = string.Empty; var ckdict = CookieUtility.UnpackCookie(this); if (!ckdict.ContainsKey("reqmachine")) { string IP = Request.UserHostName; string compName = DetermineCompName(IP); if (!string.IsNullOrEmpty(compName)) { var tempdict = new Dictionary <string, string>(); tempdict.Add("reqmachine", compName); machine = compName; CookieUtility.SetCookie(this, tempdict); } //end if vm = LinkVM.RetrieveLinks(); } //end else { vm = RetrieveAllLinks(ckdict["reqmachine"]); machine = ckdict["reqmachine"]; } var validlink = string.Empty; foreach (var item in vm) { if (string.Compare(linkname, item.LinkName) == 0) { validlink = item.Link; if (!string.IsNullOrEmpty(machine)) { MachineLink.RemoveCustomLink(item.LinkName, item.Link, item.Logo, item.Comment, machine); } break; } } var res = new JsonResult(); res.Data = new { success = true }; return(res); }
//информация о закладке public async Task <ActionResult> LinkInfo(int id) { LinkVM linkVM; using (ChekitDB chekitDB = new ChekitDB()) { LinkDTO linkDTO = await chekitDB.Links.FindAsync(id); if (linkDTO == null) { return(View("Error")); } linkVM = new LinkVM(linkDTO); } return(View(linkVM)); }
public List <Card> GetPatientViewInsights(HookRequestVM hookRequest) { HookRequestVM vm = (HookRequestVM)hookRequest; List <Card> cards = new List <Card>(0); using (EaiDBEntities ctx = new EaiDBEntities()) { List <Insight> insights = (from s in ctx.Insight select s).Include(x => x.InsightLink) .ToList(); foreach (Insight site in insights) { Card c2 = new Card(); c2.summary = site.ProviderMessageheadline; c2.indicator = "info"; List <LinkVM> vms = new List <LinkVM>(0); foreach (InsightLink aLink in site.InsightLink.ToList()) { LinkVM lvm = new LinkVM(); lvm.label = aLink.LinkLabel; lvm.type = aLink.Vv_LinkType; lvm.url = aLink.LinkUrl; vms.Add(lvm); } if (vms.Count > 0) { c2.links = vms; } cards.Add(c2); } } return(cards); }
public async Task Update_Links_Success() { // create a new user string userId = Guid.NewGuid().ToString(); var pkUser = await MockHelpers.CreateNewUser(1, userId, "*****@*****.**", "Password@123", _fixture); // get user manager var profContr = CreateAuthenticatedProfileController(pkUser); LinkVM updtModel = new LinkVM() { Type = "Facebook", Url = "https://facebook.com/" }; var result = await profContr.UpdateLinks(pkUser.Id, updtModel) as ObjectResult; var qUsr = result.Value as ArtistDTO; Assert.Equal(StatusCodes.Status200OK, result.StatusCode); Assert.True(qUsr.Links.ContainsKey(updtModel.Type)); Assert.True(qUsr.Links.ContainsValue(updtModel.Url)); LinkVM updtModel2 = new LinkVM() { Type = "Facebook", Url = "https://facebook.com/2" }; var result2 = await profContr.UpdateLinks(pkUser.Id, updtModel2) as ObjectResult; var qUsr2 = result2.Value as ArtistDTO; Assert.True(qUsr2.Links.ContainsValue(updtModel2.Url)); Assert.Equal(StatusCodes.Status200OK, result.StatusCode); }
private void CopyProfilePart(ContentItem src, ContentItem dest) { if ((((dynamic)src).ProfilePart != null) && (((dynamic)dest).ProfilePart != null)) { List <ContentPart> Lcp = new List <ContentPart>(); ContentPart destProfile = (ContentPart)((dynamic)dest).ProfilePart; Lcp.Add(destProfile); foreach (dynamic cf in ((dynamic)src).ProfilePart.Fields) { if (cf is ICustomField) { // laser custom field type var valueList = ((ICustomField)cf).GetFieldValueList(); if (valueList != null) { var destField = (ICustomField)(destProfile.Fields.FirstOrDefault(x => x.Name == cf.Name)); foreach (var val in valueList) { destField.SetFieldValue(val.ValueName, val.Value); } } } else // orchard base field type { object myval; if (cf.FieldDefinition.Name == typeof(DateTimeField).Name) { myval = ((object)(((dynamic)cf).DateTime)); } else if (cf.FieldDefinition.Name == typeof(MediaLibraryPickerField).Name || cf.FieldDefinition.Name == typeof(ContentPickerField).Name) { myval = ((Int32[])cf.Ids).ToList().Select(x => (object)x).ToList(); } else if (cf.FieldDefinition.Name == typeof(TaxonomyField).Name) { List <TaxoVM> second = new List <TaxoVM>(); var selectedTerms = _taxonomyService.GetTermsForContentItem(src.Id, ((ContentField)cf).Name); foreach (TermPart tp in selectedTerms) { TaxoVM tv = new TaxoVM(); tv.Id = tp.Id; tv.flag = true; second.Add(tv); } myval = second; } else if (cf.FieldDefinition.Name == typeof(LinkField).Name) { LinkField linkField = (LinkField)cf; var second = new LinkVM(); second.Url = linkField.Value; second.Text = linkField.Text; myval = second; } else { myval = ((object)(((dynamic)cf).Value)); } _utilsServices.StoreInspectExpandoFields(Lcp, ((string)(cf.Name)), myval); } } } }
//Update the property view after selection changed void UpdatePropertyView() { List <WidgetViewModBase> Widgets = _model.GetSelectionWidget(); Property.ImagePropertyViewModel ImageVM = null; Property.LinkPropertyViewModel LinkVM = null; Property.TextPropertyViewModel LableVM = null; Property.ShapePropertyViewModel ShapeVM = null; Property.GroupPropertyViewModel GroupVM = null; Property.ListBoxPropertyViewModel ListboxVM = null; Property.DropListPropertyViewModel DroplistVM = null; Property.CheckBoxPropertyViewModel CheckboxVM = null; Property.RadioButtonPropertyViewModel RadioButtonVM = null; Property.TextAreaPropertyViewModel TextareaVM = null; Property.TextFieldPropertyViewModel TextFieldVM = null; Property.ButtonPropertyViewModel ButtonVM = null; Property.HamburgerPropertyViewModel HamburgerVM = null; Property.FlickPannelPropertyViewModel FlickpannelVM = null; Property.ToastPropertyViewModel ToastVM = null; Property.SVGPropertyViewModel SVGVM = null; Property.MasterPropertyViewModel MasterVM = null; Items.Clear(); foreach (WidgetViewModBase data in Widgets) { if (data.IsGroup) { if (GroupVM == null) { GroupVM = new Property.GroupPropertyViewModel(); Items.Add(GroupVM); } GroupVM.AddItems(data); } else if (data.WidgetType == WidgetType.Image) { if (ImageVM == null) { ImageVM = new Property.ImagePropertyViewModel(); Items.Add(ImageVM); } ImageVM.AddItems(data); } else if (data.WidgetType == WidgetType.HotSpot) { if (LinkVM == null) { LinkVM = new Property.LinkPropertyViewModel(); Items.Add(LinkVM); } LinkVM.AddItems(data); } else if (data.WidgetType == WidgetType.Shape && data.shapetype == ShapeType.Paragraph) { if (LableVM == null) { LableVM = new Property.TextPropertyViewModel(); Items.Add(LableVM); } LableVM.AddItems(data); } else if (data.WidgetType == WidgetType.ListBox) { if (ListboxVM == null) { ListboxVM = new Property.ListBoxPropertyViewModel(); Items.Add(ListboxVM); } ListboxVM.AddItems(data); } else if (data.WidgetType == WidgetType.DropList) { if (DroplistVM == null) { DroplistVM = new Property.DropListPropertyViewModel(); Items.Add(DroplistVM); } DroplistVM.AddItems(data); } else if (data.WidgetType == WidgetType.Checkbox) { if (CheckboxVM == null) { CheckboxVM = new Property.CheckBoxPropertyViewModel(); Items.Add(CheckboxVM); } CheckboxVM.AddItems(data); } else if (data.WidgetType == WidgetType.RadioButton) { if (RadioButtonVM == null) { RadioButtonVM = new Property.RadioButtonPropertyViewModel(); Items.Add(RadioButtonVM); } RadioButtonVM.AddItems(data); } else if (data.WidgetType == WidgetType.TextArea) { if (TextareaVM == null) { TextareaVM = new Property.TextAreaPropertyViewModel(); Items.Add(TextareaVM); } TextareaVM.AddItems(data); } else if (data.WidgetType == WidgetType.TextField) { if (TextFieldVM == null) { TextFieldVM = new Property.TextFieldPropertyViewModel(); Items.Add(TextFieldVM); } TextFieldVM.AddItems(data); } else if (data.WidgetType == WidgetType.Button) { if (ButtonVM == null) { ButtonVM = new Property.ButtonPropertyViewModel(); Items.Add(ButtonVM); } ButtonVM.AddItems(data); } else if (data.WidgetType == WidgetType.Shape && (data.shapetype == ShapeType.Rectangle || data.shapetype == ShapeType.RoundedRectangle || data.shapetype == ShapeType.Ellipse || data.shapetype == ShapeType.Diamond || data.shapetype == ShapeType.Triangle)) { if (ShapeVM == null) { ShapeVM = new Property.ShapePropertyViewModel(); Items.Add(ShapeVM); } ShapeVM.AddItems(data); } else if (data.WidgetType == WidgetType.HamburgerMenu) { if (HamburgerVM == null) { HamburgerVM = new Property.HamburgerPropertyViewModel(); Items.Add(HamburgerVM); } HamburgerVM.AddItems(data); } else if (data.WidgetType == WidgetType.DynamicPanel) { if (FlickpannelVM == null) { FlickpannelVM = new Property.FlickPannelPropertyViewModel(); Items.Add(FlickpannelVM); } FlickpannelVM.AddItems(data); } else if (data.WidgetType == WidgetType.Toast) { if (ToastVM == null) { ToastVM = new Property.ToastPropertyViewModel(); items.Add(ToastVM); } ToastVM.AddItems(data); } else if (data.WidgetType == WidgetType.SVG) { if (SVGVM == null) { SVGVM = new Property.SVGPropertyViewModel(); items.Add(SVGVM); } SVGVM.AddItems(data); } else if (data is MasterWidgetViewModel) { if (MasterVM == null) { MasterVM = new Property.MasterPropertyViewModel(); items.Add(MasterVM); } MasterVM.AddItems(data); } } FirePropertyChanged("Items"); }
public ActionResult RedirectToLink(string linkname) { var vm = new List <LinkVM>(); var machine = string.Empty; var ckdict = CookieUtility.UnpackCookie(this); if (!ckdict.ContainsKey("reqmachine")) { string IP = Request.UserHostName; string compName = DetermineCompName(IP); if (!string.IsNullOrEmpty(compName)) { var tempdict = new Dictionary <string, string>(); tempdict.Add("reqmachine", compName); machine = compName.ToUpper(); CookieUtility.SetCookie(this, tempdict); } //end if vm = LinkVM.RetrieveLinks(); } //end else { vm = RetrieveAllLinks(ckdict["reqmachine"]); machine = ckdict["reqmachine"].ToUpper(); } var validlink = string.Empty; foreach (var item in vm) { if (string.Compare(linkname, item.LinkName) == 0) { validlink = item.Link; if (!string.IsNullOrEmpty(machine)) { MachineLink.UpdateFrequence(item.LinkName, item.Link, item.Logo, item.Comment, machine); } break; } } if (!string.IsNullOrEmpty(validlink)) { //var logonnames = Request.LogonUserIdentity.Name; //if (!string.IsNullOrEmpty(logonnames)) //{ // var splitnames = logonnames.Split(new string[] { "/", "\\" }, StringSplitOptions.RemoveEmptyEntries); // ViewBag.logonname = splitnames[splitnames.Length - 1]; // LinkVM.UpdateSmartLinkLog(ViewBag.logonname,machine, validlink); //} ViewBag.logonname = machine; var mudict = MachineUserMap.RetrieveUserMap(machine); if (mudict.ContainsKey(machine)) { ViewBag.logonname = mudict[machine]; LinkVM.UpdateSmartLinkLog(ViewBag.logonname, machine, validlink); } if (validlink.Contains("wux-engsys01")) { var now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var timestamp = now + "_joke"; using (MD5 md5Hash = MD5.Create()) { var smartkey1 = GetMd5Hash(md5Hash, timestamp) + "::" + now; var smartkey2 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(smartkey1)); var smartkey = HttpUtility.UrlEncode(smartkey2); return(Redirect(validlink + "?smartkey=" + smartkey)); } } else { return(Redirect(validlink)); } } else { return(RedirectToAction("All", "SmartLinks")); } }