How do I make a webpart's settings configurable in Sharepoint? - c#

I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise. I am publishing a portal template.
I want to develop a WebPart and make some settings configurable (just like we can configure parameters for a console application in app.config)
For example, authorized users could set parameters of WebPart in Edit Page (from browser based UI interface), then Select -> Modify WebPart properties, or edit parameters in SharePoint Designer.
The parameters would be application specific parameters.
How do I go about doing this?

You can make your properties on the webpart and add attributes like so....
[WebBrowsable(true),Category("Calendar Setup"),
WebDisplayName("Starting Date Column"),
WebDescription("column that contains item starting date"),
Personalizable(PersonalizationScope.Shared)]
public DateTime StartDate { get; set; }
You should check here for a full list and a good article on the subject.

Check and see of this helps
Writing custom editors for Sharepoint 2007 and ASP.NET 2.0 WebParts

Related

Dynamic CRM new fields

Some new fields were create in Dynamics CRM.
Now need to push some data to those new fields from asp.net website.
Need to add those new fields to:
[assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]
namespace Xrm
how should this be done? I read that these is a tool that generates this class file (CrmSvcUtil.exe).
But I do not understand how this would work.
Is this something that need to be done through Dynamics CRM admin?
Please advise.
Thanks
This should be done by user which has System Administrator or System Customizer, because this user has to have access to all entities metadata.
Basically you should start with downloading CRM SDK, for your version of CRM. For example the latest SDK can be found here:
https://www.microsoft.com/en-us/download/details.aspx?id=50032
Install the SDK and go to the bin folder inside the folder where you installed it. There you can find crmsvcutil.exe. This tool is something like svcutil.exe - it simply generates proxy classes using CRM metadata service. So instead of referring to Account entity like that:
var account = new Entity("account")
you can simply do:
var account = new Account();
and you will have all the properties that account in your system has.
In order to generate this classes just run crmsvcutil.exe using windows command line with proper credentials (it's very well documented if you run it without any parameters). example usage would be:
crmsvcutil /url:https://orgname.api.crm4.dynamics.com/XRMServices/2011/Organization.svc /u:user#orgname.onmicrosoft.com /p:password /serviceContextName:XrmServiceContext /out:Proxies.cs /n:Xrm
this would generate file Proxies.cs, containing namespace Xrm (the one you have posted in your question) with all the entities and fields. Of course the parameters may vary based on what type of organization you are connecting to. If you have problems with specifying proper values then simply put /il as last command line parameter - it will open an interactive login form, that would make it simpler for you to pass proper connection data.

Sharepoint Provider Hosted User Permissions

I'm building a business app where read and write access permissions are important.
The project is a Provider hosted MVC 5 / SharePoint app built in Visual Studio 2012.
Johnny needs to be able to Read and Write content on SharePoint App A AND SharePoint App B
Dave needs to only be able to Read content on SharePoint App A
I've looked over a lot of documentation including this tutorial:
http://www.itunity.com/article/sharepoint-permissions-manage-access-sql-data-709
The problem is if I give Dave Read access at the site level he is allowed to access SharePoint App A but also SharePoint App B.
How do I effectively use SharePoint permissions to stop this unintended behaviour?
Should I even be using SharePoint permissions?
2nd example:
I am building an app for project management, there will be an Engineer who is able to create, read and edit projects, there is also an Accountant who views the projects billables.
If I give Read permissions to Engineer and Read permissions to Accountant, how do I know which can view the project details and which can view the project's billables?
I read the article you linked to, and I am not sure that this is "authorization", the right word is "authentication", in sharepoint you set what a user can do, authorization means- which data user can read or write
so a simple solution for you is creating Group in sharepoint, for any authorization type you have, for example, a group called "Engineer", and gives it the permissions you need, your engineers will be members in this group.
in your MVC attribute, accept the group as parameter and check if user is member in this group, show the user the relevant data according to its group
public SharePointPermissionsAuthorizationAttribute( params string group) { _groups = groups; }
[SharePointEffectivePermissionsFilter("Engineer"]
public ActionResult Index() { ... } }

How to config Web References in Visual Studio for production environment

I'm developing an application which will upload documents to a sharepoint folder. Because my application will not run on a server environment, but in client machines, I decided to user the Web Services provided by Sharepoint to upload the documents (my sharepoint address + _vti_bin/copy.asmx) and check in the uploaded files (my sharepoint address + /_vti_bin/Lists.asmx).
My problem is with the my sharepoint address part. The Sharepoint I am using for development is of course different from the that the clients use. Since I have to add the Web References for the service at developing time in order to use it in the C# code, how should I approach?
I will have to obtain at least obtain the main parte of the sharepoint address - say https://sharepoint/projects/ProjectX/and declare my WS with it?
If it makes different, I am using WiX to deploy my application in the end, generating a .msi executable. My sharepoint is 2010 and I'm writing my application in VS2010 using .NET 4.0.
Thank you in advance
Thats Correct Pedro.
You should point my sharepoint address to the url of the website, not root site collection, but website you want to access the services.
You have then 2 options, you can change the address on the configuration file that the visual studio proxy generates as part of the build scripts (sorry dont know Wix, but I bet it can be done)
Or you can then set the url at runtime, it will ignore the one in the config file generated by Visual Studio:
WSS.Lists svc = new WSS.Lists();
svc.Url = my sharepoint address + "/_vti_bin/Lists.asmx"
Luis's answer is pretty much correct. Another approach you can do is create proxy classes using wsdl.exe. This creates a class instance which you can use in your project. Once you have the file you can just update the value of the variable URL so that it matches your sharepoint URL.
You can also update the constructor like below:
public Lists(string SERVER)
{
this.Url = "http://" + SERVER + "/_vti_bin/Lists.asmx";
}
This makes sure that you can use whatever SharePoint site you want or place it in configuration files too.

Custom Alerts SharePoint 2010 (KB 948321)

I've been trying to create a custom alert for SharePoint 2010 using the following guidelines : http://support.microsoft.com/kb/948321/en-us
At this point I haven't succeeded in getting the alert to work. I was wondering of this guide also applies for SharePoint 2010. Because at the button of the article is clearly states:
APPLIES TO
Microsoft Office SharePoint Server 2007
Microsoft Office SharePoint Server 2007 for Search (Enterprise Edition)
Microsoft Office SharePoint Server 2007 for Search (Standard Edition)
Can anyone enlighten me?
Kind regards
Oxillery
I have it working in 2010.
A new Alert Template.
a.Original is found here:
\14\TEMPLATE\XML\alerttemplates.xml
b.The custom templates are found in this file which has the original definitions plus the custom definitions.
CCPersonalAlertTemplates.xml
c.Load them with stsadm
stsadm.exe -o updatealerttemplates -url "http://Beefy.com/Sites/my_name" -filename " \CCPersonalAlertTemplates.xml"
d.Every out of the box solution has a matching custom template.
The custom templates have a .ext at the end of their name.
The custom features also call a custom NotificationHandlerAssembly like this:
<Properties>
<NotificationHandlerAssembly>Shared.CCPersonalEmail, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5694e116d3fc8c0c</NotificationHandlerAssembly>
<NotificationHandlerClassName>Shared.CCPersonalEmail.CCPersonalClass
</NotificationHandlerClassName>
<NotificationHandlerProperties />
</Properties>
Custom Notification Handler assembly
a.IAlertNotifyHandler that implements an OnNotification method
- Attempts to send the custom alert (if it fails send normal alert.)
Custom alert:
Gets the PersonalEmail field data from the User Information List
If Personal Email is empty it just sends normal alert
If personal email is populated
Send normal email to internal email
Send reduced email to external address
Replace http:// with external address http://extranet-
Regex replace (keep content data from being sent)
<td class=\"formlabel\">.*<td class=\"altvb\"> </td>
Make all the alerts use the external template
Existing alerts:
Site.allwebs.alerts get flipped to the same template name they had with .ext appended
Future alerts:
Site.allwebs.lists flipped the attached alerttemplates to their .ext counterpart
Future webs and their Future lists
SPListEventReceiver ListAdded() event flips the template on all lists created in the site collection
Housekeeping
a.During feature activation
create a PersonalEmail field on the rootweb’s User Information List (This becomes content so it is not removed upon deactivation)
flip all lists and alerts to the custom alert templates.
During feature deactivation
Flip all lists and alerts back to their respective out of box alert templates

User settings disappear on outlook upgrades

i'm developing an outlook plug in where users set a list of settings like credentials and site url...
I'am saving this settings in settings.settings in my windows application project.
after installing the add in the config file is set under C:\Users\ user \AppData\Local\Microsoft_Corporation\ project name \ * < outlook Version> * \user.config.
My problem is when performing update for the microsoft office outlook the outlook version changed so my add in will not be able to find the user settings.
How can i pass this problem???
Is it the best practice to save the user settings in settings.settings file?
When I ran into a similar problem a while back, I found this page helpful: http://www.devx.com/dotnet/Article/33944/0/page/4.
It basically requires calling:
<your assembly>.Properties.Settings.Default.Upgrade();
I remember that there is a My.Settings.Upgrade method, which transfers settings between assembly updates. I'd rather use an own settings class and a path about which I decide.
You can also decide to write your own upgrade routine in the case of an major application update.

Categories

Resources