public void AllowHttpsUrl() { using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage, cache)) { var model = new Data.Alias() { SiteId = SITE_ID, AliasUrl = "/the-alias-url-4", RedirectUrl = "https://redirect.com" }; api.Aliases.Save(model); Assert.Equal("https://redirect.com", model.RedirectUrl); } }
public void FixRedirectUrl() { using (var api = new Api(GetDb(), storage, cache)) { var model = new Data.Alias() { SiteId = SITE_ID, AliasUrl = "/the-alias-url-2", RedirectUrl = "the-redirect-2" }; api.Aliases.Save(model); Assert.Equal("/the-redirect-2", model.RedirectUrl); } }
public void FixAliasUrl() { using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage, cache)) { var model = new Data.Alias() { SiteId = SITE_ID, AliasUrl = "the-alias-url-1", RedirectUrl = "/the-redirect-1" }; api.Aliases.Save(model); Assert.Equal("/the-alias-url-1", model.AliasUrl); } }
private void lladd_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { if (items == null || cbadd.SelectedIndex < 0) { return; } Data.Alias a = cbadd.SelectedItem as Data.Alias; SimMemoryType smt = (SimMemoryType)a.Id; int index = this.NextItemIndex(true); NgbhItem item = items.InsertNew(index, smt); item.SetInitialGuid(smt); InsertItemToList(index, item); lv.Items[index].Selected = true; lv.Items[index].EnsureVisible(); }
/// <summary> /// Adds or updates the given model in the database /// depending on its state. /// </summary> /// <param name="model">The model</param> public async Task Save(Alias model) { var alias = await _db.Aliases .FirstOrDefaultAsync(p => p.Id == model.Id); if (alias == null) { alias = new Data.Alias { Id = model.Id != Guid.Empty ? model.Id : Guid.NewGuid(), Created = DateTime.Now }; await _db.Aliases.AddAsync(alias).ConfigureAwait(false); } alias.SiteId = model.SiteId; alias.AliasUrl = model.AliasUrl; alias.RedirectUrl = model.RedirectUrl; alias.Type = model.Type; alias.LastModified = DateTime.Now; await _db.SaveChangesAsync().ConfigureAwait(false); }
/// <summary> /// Is called by SimPe (through the Wrapper) when the Panel is going to be displayed, so /// you should updatet the Data displayed by the Panel with the Attributes stored in the /// passed Wrapper. /// </summary> /// <param name="wrapper">The Attributes of this Wrapper have to be displayed</param> public void UpdateGUI(IFileWrapper wrapper) { form.wrapper = (IFileWrapperSaveExtension)wrapper; Ngbh wrp = (Ngbh)wrapper; form.lv.BeginUpdate(); form.lv.Items.Clear(); form.ilist.Images.Clear(); form.cbsub.Items.Clear(); form.cbown.Items.Clear(); form.gbmem.Enabled = false; form.lbmem.Items.Clear(); Interfaces.Files.IPackedFileDescriptor[] pfds = wrp.Package.FindFiles(Data.MetaData.SIM_DESCRIPTION_FILE); form.cbsub.Items.Add(new Data.Alias(0, "---", "{name}")); form.cbsub.Sorted = false; form.cbown.Items.Add(new Data.Alias(0, "---", "{name}")); form.cbown.Sorted = false; foreach (Interfaces.Files.IPackedFileDescriptor spfd in pfds) { PackedFiles.Wrapper.SDesc sdesc = new SimPe.PackedFiles.Wrapper.SDesc(wrp.Provider.SimNameProvider, wrp.Provider.SimFamilynameProvider, null); Wait.SubStart(); sdesc.ProcessData(spfd, wrp.Package); ListViewItem lvi = new ListViewItem(); lvi.Text = sdesc.SimName + " " + sdesc.SimFamilyName; #if DEBUG Data.Alias a = new Data.Alias(sdesc.SimId, lvi.Text); lvi.Text += " (0x" + Helper.HexString(sdesc.Instance) + ")"; #else Data.Alias a = new Data.Alias(sdesc.SimId, lvi.Text, "{name}"); #endif lvi.Tag = sdesc; a.Tag = new object[1]; a.Tag[0] = sdesc.Instance; form.cbsub.Items.Add(a); form.cbown.Items.Add(a); if (sdesc.HasImage) { /*if (sdesc.Unlinked!=0x00) * { * Image img = (Image)sdesc.Image.Clone(); * System.Drawing.Graphics g = Graphics.FromImage(img); * g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; * g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; * * Pen pen = new Pen(Color.FromArgb(0xD0, Color.DarkGreen), 3); * * g.FillRectangle(pen.Brush, 0, 0, img.Width, img.Height); * * form.ilist.Images.Add(img); * } */ if ((sdesc.Unlinked != 0x00) || (!sdesc.AvailableCharacterData)) { Image img = (Image)sdesc.Image.Clone(); System.Drawing.Graphics g = Graphics.FromImage(img); g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; Pen pen = new Pen(Data.MetaData.SpecialSimColor, 3); g.FillRectangle(pen.Brush, 0, 0, img.Width, img.Height); int pos = 2; if (sdesc.Unlinked != 0x00) { g.FillRectangle(new Pen(Data.MetaData.UnlinkedSim, 1).Brush, pos, 2, 25, 25); pos += 28; } if (!sdesc.AvailableCharacterData) { g.FillRectangle(new Pen(Data.MetaData.InactiveSim, 1).Brush, pos, 2, 25, 25); pos += 28; } form.ilist.Images.Add(img); } else { form.ilist.Images.Add(sdesc.Image); } lvi.ImageIndex = form.ilist.Images.Count - 1; } form.lv.Items.Add(lvi); } form.cbsub.Sorted = true; form.cbown.Sorted = true; form.lv.Sort(); form.lv.EndUpdate(); Wait.SubStop(); }
internal static bool DoConsume(Object o, ObjectLoader.LoadItemHandler LoadedItem, SimPe.Data.MetaData.Languages deflang) { SimPe.Cache.ObjectCacheItem oci = (SimPe.Cache.ObjectCacheItem)o; Interfaces.Scenegraph.IScenegraphFileIndexItem nrefitem = (Interfaces.Scenegraph.IScenegraphFileIndexItem)oci.Tag; //this item is new to the cache, so load the Data if ((!oci.Useable || oci.ObjectVersion != SimPe.Cache.ObjectCacheItemVersions.DockableOW) && nrefitem.FileDescriptor.Type == Data.MetaData.OBJD_FILE) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); nrefitem.FileDescriptor.UserData = nrefitem.Package.Read(nrefitem.FileDescriptor).UncompressedData; objd.ProcessData(nrefitem); oci.FileDescriptor = nrefitem.FileDescriptor; oci.LocalGroup = nrefitem.LocalGroup; oci.ObjectType = objd.Type; oci.ObjectFunctionSort = (uint)objd.FunctionSubSort; oci.ObjectFileName = objd.FileName; oci.Useable = true; oci.Class = SimPe.Cache.ObjectClass.Object; //this is needed, so that objects get sorted into the right categories /*if (objd.Type == Data.ObjectTypes.Normal && objd.CTSSInstance==0) * { * oci.Useable = false; * return true; * }*/ //Get the Name of the Object Interfaces.Scenegraph.IScenegraphFileIndexItem[] ctssitems = FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, nrefitem.LocalGroup); if (ctssitems.Length > 0) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(ctssitems[0]); SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(deflang); if (items.Length > 0) { oci.Name = items[0].Title; } else { items = str.LanguageItems(1); if (items.Length > 0) { oci.Name = items[0].Title; } else { oci.Name = ""; } } } else { oci.Name = ""; } if (oci.Name == "") { oci.Name = objd.FileName; } //now the ModeName File Interfaces.Scenegraph.IScenegraphFileIndexItem[] txtitems = FileTable.FileIndex.FindFile(Data.MetaData.STRING_FILE, nrefitem.LocalGroup, 0x85, null); if (txtitems.Length > 0) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(2); str.ProcessData(txtitems[0]); SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(1); if (items.Length > 1) { oci.ModelName = items[1].Title; } } ObjectReader.changedcache = true; } //if not loaded from objd if ((!oci.Useable || oci.ObjectVersion != SimPe.Cache.ObjectCacheItemVersions.DockableOW) && nrefitem.FileDescriptor.Type != Data.MetaData.OBJD_FILE) { ConsumeFromXobj(oci, nrefitem, deflang); } if (oci.Thumbnail == null) { oci.Thumbnail = ObjectPreview.GetThumbnail(nrefitem.FileDescriptor.Group, oci.ModelName); if (oci.Thumbnail != null) { Wait.Image = oci.Thumbnail; ObjectReader.changedcache = true; } } #if DEBUG Data.Alias a = new Data.Alias(oci.FileDescriptor.Group, "---"); //, "{name} ({id}: {1}, {2}) "); #else Data.Alias a = new Data.Alias(oci.FileDescriptor.Group, "---"); //, "{name} ({id}: {1}) "); #endif object[] os = new object[4]; os[0] = nrefitem.FileDescriptor; os[1] = nrefitem.LocalGroup; os[2] = oci.ModelName; os[3] = oci; a.Tag = os; if (Helper.WindowsRegistry.ShowObjdNames) { a.Name = oci.ObjectFileName; } else { a.Name = oci.Name; } a.Name += " (cached)"; Image img = oci.Thumbnail; if (LoadedItem != null) { LoadedItem(oci, nrefitem, a); } return(true); }