public Guid GetDynamicID(string originalPath) { Guid id = Guid.Empty; string relativePath = Converter.ToRelative(originalPath); string[] parts = relativePath.Trim('/').Split('/'); if (parts.Length >= 2) { string idString = parts[1]; // If the id string contains a dot then it's a file name and needs to be fixed if (idString.IndexOf('.') > -1) { idString = Path.GetFileNameWithoutExtension(idString); } if (GuidValidator.IsValidGuid(idString)) { id = GuidValidator.ParseGuid(idString); } } return(id); }
/// <summary> /// Selects the appropriate items depending on the SelectedEntityIDs. /// </summary> protected void SelectItems() { using (LogGroup logGroup = LogGroup.Start("Selecting the items that match the info specified.", NLog.LogLevel.Debug)) { Guid[] selectedEntityIDs = new Guid[] {}; if (ViewState["SelectedEntityIDs"] != null) { LogWriter.Debug("ViewState[\"SelectedEntityIDs\"] != null"); selectedEntityIDs = (Guid[])ViewState["SelectedEntityIDs"]; } else { LogWriter.Debug("ViewState[\"SelectedEntityIDs\"] == null"); } LogWriter.Debug("# of selected entities: " + selectedEntityIDs.Length.ToString()); foreach (ListItem item in Items) { using (LogGroup logGroup2 = LogGroup.Start("Selecting/deselecting item.", NLog.LogLevel.Debug)) { Guid id = Guid.Empty; if (GuidValidator.IsValidGuid(item.Value)) { id = GuidValidator.ParseGuid(item.Value); } LogWriter.Debug("item.Text: " + item.Text); LogWriter.Debug("item.Value: " + item.Value); item.Selected = (Array.IndexOf(selectedEntityIDs, id) > -1); LogWriter.Debug("item.Selected: " + item.Selected.ToString()); } } } }