AssetUrlSelector toolpart - c#

What I need to do is quite simple although is causing me lots of trouble.
I need to create programmatically an AssetUrlSelector in a web part that selects a file in sharepoint 2010 and makes its path available to be used elsewhere.
So far I have managed to create the AssetUrlSelector and display the path on a textbox, however I cannot use this as every reference to it will be null.
Have you got any practical example?

Try the Document ID Service. In short this service generates IDs for documents (files) and generates an url with this ID so even if the file is moved the url stays valid and the service returns the document. This service might rely on search functionality unless you implement your custom search. Here is an article on how to configure OOB Doc IDs here. Also you can google further if you're interested.

Related

How to retrieve SharePoint Share Links using CSOM

I am currently developing a program that will upload selected files to a specific folder (and create the folders automatically if necessary) on SharePoint and give access to specific users based on their emails using SharePoint CSOM, however I am unable to retrieve the links for people outside of my domain.
For example, with my current code, I am retrieving links like the following:
https://domain.sharepoint.com/:f:/r/sites/TestSite/Shared%20Documents/2019/11157/Test%20Upload?csf=1
However, the link I am trying to retrieve is like the following:
https://domain.sharepoint.com/:f:/s/TestSite/EmUDng-KzwxEtHKyJ9Okl0MBlS_z8gxGFl4UUjuGXHmR9w
I can retrieve the link above if I go into SharePoint and manually retrieve it (the program makes the links correctly), but that defeats the purpose of my program. The program is supposed to automate the upload and link retrieval of files from within my company's domain.
I do not want the first link because only people who are within my domain can access the file/folder with it. The 2nd link allows for anyone who has been given access (via an email address) to access the file/folder.
I am currently retrieving the first link by using the code from here: https://www.c-sharpcorner.com/article/generating-sharing-links-report-and-removing-sharing-links-using-sharepoint-onli/
I have also tried other suggestions I have found on StackExchange such as: https://sharepoint.stackexchange.com/questions/91451/manage-links-for-shared-files
All examples I have found like the above all result in the incorrect links.
In case it is not clear currently, I am not after an anonymous link or how to create shared links (as I already have this working), I am after the link that would appear here
I managed to find the solution after just randomly trying everything. What you can do is as follows:
First, create the sharing link in the way I was previously:
SharingResult result = context.Web.ShareDocument(site,
email,
ExternalSharingDocumentOption.View,
false,
"Document Shared as test");
Then with the result variable, grab the invitation link of one of the invited users and then modify it to work for any user (as it turns out, specific links are the same for all users other than a parameter on the end)
string link = result.InvitedUsers.FirstOrDefault().
int index = link.IndexOf("?");
if (index > 0) link = link.Substring(0, index);
This results in the correct link I was looking for. I did speak to some people from Microsoft asking about this, so, thanks Microsoft for telling me this was impossible!

What's the best way to create a replication/load balancing module?

We have a sharepoint doucment library, the site consist media files(like images, word document, .psd file) and then we have a local CME (Alterian) which can be integrated to the SharePoint library in order to share the document library but the site needs to be on http// not an https//, coincidentally current sharepoint site is on https//, so we need to figure out a way/write a module which will work as a scheduled job (possibly using SPJobDefination class) and check on https// site for recently modified/added or deleted documents/records and then will copy them/normalize them to a dev site (hosted on http//, replica of the production https// site).
Experts please share your view's to proceed with a best approach to make this happen. (At an initial stage I'll have to copy over all the existing meta-data from the current https// site aswell)
Thanks a lot in advance for the time.
I would use event handlers on the https document library. Please see the SPItemEventReceiver.ItemAdded Method and SPItemEventReceiver.ItemUpdated Method.
So, every time you will add or modify an item, the code inside the methods is triggered. Inside the code, you may take the library document and copy it to the http site.
Regarding the existing items, you could write a simple console application which will copy the items from one list to the other.
Make sure that you make use of the SPListItem.SystemUpdate Method.
Also, the following excerpt from an answer to the question Moving Documents from library to library deletes version history, how do you retain it? could be helpful for starting:
(...) We can get the “SPFile” and the “SPFileVersion” objects from the
original library and add them to another library one by one. After
copying a file or version, get the original custom property form the
source file or version and use the “SPListItem.SystemUpdate(false)”
method to update the target file or version. This workaround can
persist most of the properties except the “modified time” or “modified
by” field. (...)

Set Default Directory for Lotus Notes File Upload Control

I have a lotus notes web form in which computer-illiterate customers will use to attach Excel files and submit them to our company. I am using a Lotus Notes File Upload Control to allow them to do this, however, I need to default this File Upload Control to a certain directory location. I have already created a C# application the customers will be using, which places all of these excel files in a certain directory location, hence the reason I need to focus this File Upload Control. Unfortunately, some of the customers are computer challenged enough to not know how to navigate to these files on their own. Is this possible at all?
I'm assuming the users will be visiting a web page with the File Upload control, yes? If I'm misunderstanding please let me know and I'll delete this answer.
The simple answer is it isn't possible. The problem is that the browser can't know anything about the file structure of the clients that visit the site, so a "default path" property doesn't really make sense. It would likely only work in very specific environments (which is maybe true in your case, but not across the web in general)
I would investigate using the Notes API to have the C# program handle the upload without involving the browser client use of the file upload control. I don't know enough Java to be sure, but perhaps that might also be an option -- basically writing your own custom upload control that only asks the user for the filename.
You may also be seriously underestimating the ability of the users to follow directions. If your page identifies which directory the file will be found in, I expect most users will be able to follow the directions and upload from the correct directory.
So, I'm sure that accomplishing what you want to accomplish is possible in Notes, just not as simply as adding a default directory to the File Upload Control.

Accessing Sharepoint from a WebApplication

I'm currently investigating SharePoint for our company as a means to make Excel processing accessible through our web application without relying on the Office Interop DLL files. (our sysadmin doesnt want to install Office on the production server, for good reason)
I'm aware that Sharepoint has an Excel Webservice that can be enabled and used by the application. The problem, if it is a problem, is that I need to make a class that wraps all the logic for transforming an Excel into HTML.
So I need to add the references to this webservice to the application.
But what if we need to deploy the application with a customer that has no SharePoint server available, will this cause a problem in the application? We will use checks to make stuff visible and invisible depending on whether a parameter is set, but I'm looking for a means to ensure that I can for example add the required references at runtime when I need them for Sharepoint.
I hope the question is clear.
I'm not sure I understand you completely, but if you're just wondering about changing the URL of a web service(From say http://companyA.co/service.svc?wsdl to http://compB.co/serv.svc?wsdl), depending on where it is, that's easy as pie in .Net, basically just:
service.URL = "http://localhost:51112/Service1.svc?wsdl";

Upload File to Website Using Save/As From Software Application

We all know that it is possible to "open" a Word document (or file from any arbitrary application) by clicking on a website link and then clicking the Open button.
I also know that, if I want to upload an application document to a web server, I must first save the document to my computer, and then go to an upload page, click a file/open button, find my saved file and upload it.
But is it possible to save a document to a website location or Url, effectively skipping the first save step and uploading the file to the web server through the Save dialog of the application, directly?
How would this be done in ASP.NET MVC?
It really depends on how complex you want to make it. This is pretty much what "web folders" offered (via WebDAV), but in general it creates more problems than it will ever fix. I don't recommend this approach.
Your best bet to make this simple is a dedicated client app - perhaps (although this is a dubious example) how Office talks to sharepoint. In a simpler example, you could create a silverlight out-of-browser application that saved via a web-service to a site using WCF or similar.
I think there is some creedence in what #Marc says. Personally I'd probably map a drive to the web site in question, if that's possible, and have a folder to upload to.
Then I'd have .Net check changes to the folder and take those files and import them into the repository, whatever that may be.
It's still an imperfect solution and I'm not sure there is a correct solution as yet.
I guess you could always write, and I can't believe I'm writing this, macros to save to the ftp location.
I'd guess you have a few choices, in no particular order:
Web service that the application can reference and upload through.
REST service (WCF or otherwise) that the application can POST to.
HttpHandler or MVC controller action that the application can POST to.
WebDAV directly to the server.
Number 3 sounds like it's closest to what you were looking for ("How would this be done in ASP.NET MVC?"). Scott Hanselman has a good article on handling file uploads in MVC on his blog.
When you implement the client, there's a little bit of a trick to that, too, since you can't just POST like usual; you have to post in multipart/form-data format. I posted a blog entry with some sample code on how to do that.

Categories