public void btnSearch_Click(object sender, EventArgs e) { string _rootFolder = string.Empty; string _rootPID = string.Empty; switch(ddlRoot.SelectedValue) { case "0": using (MySiteRepositorySettings ObjSettings = new MySiteRepositorySettings()) { SPListItem settings = ObjSettings.GetRepositorySettings(SPContext.Current.Web.Title); if (ObjSettings != null) { _rootPID = settings["Default Root Object"].ToString(); } } break; case "1": _rootPID = "CLIF:Root"; break; case "2": _rootPID = ddlPublishableLocations.SelectedValue; break; } _rootFolder = ddlRoot.SelectedValue; var nameValues = HttpUtility.ParseQueryString(Request.QueryString.ToString()); nameValues.Set("pid", _rootPID); nameValues.Set("rf", _rootFolder); string url = SPContext.Current.Web.Url + "/" + Request.Url.AbsolutePath; string updatedQueryString = "?" + nameValues.ToString(); Response.Redirect(url + updatedQueryString); }
protected override void OnLoad(EventArgs e) { if (!IsPostBack) { if (Request.QueryString["pid"] != null) { rootobject = Request.QueryString["pid"].ToString(); } else { SPListItem settings = null; using (MySiteRepositorySettings ObjSettings = new MySiteRepositorySettings()) { settings = ObjSettings.GetRepositorySettings(SPContext.Current.Web.Title); if (ObjSettings != null) { rootobject = settings["Default Root Object"].ToString(); } } } litDivTags.Text = "<div id=" + this.ClientID + " class=\"TreeView\" service=" + this.service + ">"; litDivTags.Text += "<div class=\"du\" name=" + rootobject + "><span class=\"ft\">" + rootobject + "</span></div><div class=\"subframe\" style=\"display: none\"><div class='fl'> </div></div>"; litDivTags.Text += "</div>"; } base.OnLoad(e); }
/// <summary> /// This method adds files to the repository /// </summary> /// <param name="Item">SPListItem</param> /// <param name="TargetPID">string</param> public static string AddItemToRepository(SPWeb Web, SPListItem Item, string TargetPID) { string _ObjectPID = string.Empty; SPListItem ObjItem = Item; //Getting the namespace format string Namespace = string.Empty; using (MySiteRepositorySettings ObjSettings = new MySiteRepositorySettings()) { SPListItem settings = ObjSettings.GetRepositorySettings(SPContext.Current.Web.Title); if (settings != null) { Namespace = settings["Namespace Format"].ToString().Replace("{listname}",Item.ParentList.Title.Replace(" ", "")); } } //Add file to the repository -------------------------------------------------------------------------------- SPFile file = ObjItem.File; if (file != null) { //MEtabasepath //string METABASEPATH = "IIS://" + Web.Site.HostName + "/MimeMap"; //URL //string url = Web.Url + '/' + file.Url; //MimeType string mimeType = MimeTypeHelper.GetContentType(file.Name);//MimeType.GetMimeTypeForExtension(METABASEPATH, Path.GetExtension(file.Name)); //Namespace string nameSpace = Web.Title + "-" + ObjItem.ParentList.Title; //Item Title string itemTitle = ObjItem.Name.Trim(); //Skip Virus Scan byte[] content = file.OpenBinary(SPOpenBinaryOptions.SkipVirusScan); string author = "Unknown author"; if ((file.SourceFile != null) && !String.IsNullOrEmpty(file.SourceFile.Name)) { author = file.SourceFile.Name.Trim(); } else if ((file.Author != null) && !String.IsNullOrEmpty(file.Author.Name)) { author = file.Author.Name.Trim(); } HydraServiceFedoraExt hydraService = new HydraServiceFedoraExt(); _ObjectPID = hydraService.DepositSimpleContentObject(Namespace, itemTitle, TargetPID, content, mimeType, author, author); //PolicyDS policyDS = new PolicyDS(); //policyDS.Xml = GetPolicyDS(hydraService.Pid,author); //hydraService.AppendMetaData("POLICY", "XACML Policy Datastream", policyDS); //Updating operation status for the exported list item UpdateSourceItem(ObjItem, Web, _ObjectPID); //Adding an entry in Published Documents Log UpdatePublishedDocumentsLog(Web, _ObjectPID, ObjItem); } return _ObjectPID; }
protected override void OnLoad(EventArgs e) { if (!Page.IsPostBack) { try { string _listId = GetCurrentListID(); int _itemId = GetCurrentListItemID(); SPList ObjCurrentList = SPContext.Current.Web.Lists[new Guid(_listId)]; lstSourceFiles.Items.Clear(); if (Request.QueryString["itemIds"] == null) { pnlSourceFiles.Visible = false; btnBack.Visible = false; SPListItem ObjItem = ObjCurrentList.Items.GetItemById(GetCurrentListItemID()); lblSourceList.Text = ObjCurrentList.Title; lblSourceFileName.Text = ObjItem.File.Name; } else { btnBack.Visible = true; pnlSourceFiles.Visible = true; lblSourceList.Text = ObjCurrentList.Title; string[] _itemIds = Request.QueryString["itemIds"].ToString().Split(','); foreach (string itemid in _itemIds) { if (itemid != "") { lstSourceFiles.Items.Add(new ListItem(ObjCurrentList.Items.GetItemById(Convert.ToInt32(itemid)).File.Name, itemid)); } } } SPListItem settings = null; using (MySiteRepositorySettings ObjSettings = new MySiteRepositorySettings()) { settings = ObjSettings.GetRepositorySettings(SPContext.Current.Web.Title); if (settings != null) { hdnPIDFormat.Value = settings["PID Format"].ToString(); hdnNamespaceFormat.Value = settings["Namespace Format"].ToString(); hdnLabelFormat.Value = settings["Label Format"].ToString(); } else { litMessage.Text = "Could not find default repository destination"; } } //Setting Namespace value if (hdnNamespaceFormat.Value != null) { string _namespaceValue = hdnNamespaceFormat.Value; //Setting {site} value _namespaceValue = _namespaceValue.Replace("{site}", SPContext.Current.Web.Title); //Setting {listname} value _namespaceValue = _namespaceValue.Replace("{listname}", ObjCurrentList.Title.Replace(" ", "")); hdnNamespaceFormat.Value = _namespaceValue; } //Setting ObjectLabel value if (hdnLabelFormat.Value != null) { string _labelValue = hdnLabelFormat.Value; //Setting {listname} value _labelValue = _labelValue.Replace("{listname}", ObjCurrentList.Title.Replace(" ", "")); hdnLabelFormat.Value = _labelValue; } //Setting PID value if (hdnPIDFormat.Value != null) { string _pidValue = hdnPIDFormat.Value; //Setting {listname} value _pidValue = _pidValue.Replace("{listname}", ObjCurrentList.Title.Replace(" ", "")); hdnPIDFormat.Value = _pidValue; } } catch (Exception ex) { litMessage.Text = ex.Message; } } }
public void btnYes_Clicked(Object sender, EventArgs e) { SPWeb ObjWeb = SPContext.Current.Web; ObjWeb.AllowUnsafeUpdates = true; SPList ObjList = ObjWeb.Lists[new Guid(_listId)]; SPListItem item = ObjList.Items.GetItemById(Convert.ToInt32(_itemId)); //Creating Archive Object List SPList ObjArchiveList = ObjWeb.Lists["Archive"]; SPListItem _archive = ObjArchiveList.Items.Add(); _archive["Title"] = item.Title; _archive["Created By"] = SPContext.Current.Web.CurrentUser; if (item["Persistent ID"] == null) { SPListItem settings = null; using (MySiteRepositorySettings ObjSettings = new MySiteRepositorySettings()) { settings = ObjSettings.GetRepositorySettings(SPContext.Current.Web.Title); string _nameSpace = settings["Namespace Format"].ToString(); string _selectedDestinationPID = settings["Archive PID"].ToString(); //Add file to the repository -------------------------------------------------------------------------------- SPFile file = item.File; if (file != null) { SPWeb spWeb = ObjWeb; //MEtabasepath //string METABASEPATH = "IIS://" + spWeb.Site.HostName + "/MimeMap"; //URL //string url = spWeb.Url + '/' + file.Url; //MimeType string mimeType = MimeTypeHelper.GetContentType(file.Name);//MimeType.GetMimeTypeForExtension(METABASEPATH, Path.GetExtension(file.Name)); //Namespace string nameSpace = ObjWeb.Title + "-" + ObjList.Title; //Item Title string itemTitle = item.Title.Trim().Length == 0 ? Path.GetFileNameWithoutExtension(item.Name.Trim()) : item.Title.Trim(); byte[] content = file.OpenBinary(SPOpenBinaryOptions.SkipVirusScan); string author = "Unknown author"; if ((file.SourceFile != null) && !String.IsNullOrEmpty(file.SourceFile.Name)) { author = file.SourceFile.Name.Trim(); } else if ((file.Author != null) && !String.IsNullOrEmpty(file.Author.Name)) { author = file.Author.Name.Trim(); } _nameSpace = _nameSpace.Replace("{listname}", ObjList.Title.Replace(" ", "")); HydraServiceFedoraImpl hydraService = new HydraServiceFedoraImpl(); _archive["Persistent ID"] = hydraService.DepositSimpleContentObject(_nameSpace, itemTitle, _selectedDestinationPID, content, mimeType, author, author); } } } else { _archive["Persistent ID"] = item["Persistent ID"].ToString(); } _archive["Document Library"] = ObjList.Title; _archive["Project Title"] = item["Project Title"]; _archive["Content Subject"] = item["Content Subject"]; _archive["Content MimeType"] = item["Content MimeType"]; _archive["Content Coverage"] = item["Content Coverage"]; _archive.Update(); //Delete item from the "Project Documents" document library ObjList.Items.DeleteItemById(Convert.ToInt32(_itemId)); ObjWeb.AllowUnsafeUpdates = false; Response.Redirect(ObjList.DefaultViewUrl); }