Change SiteLogo via csom in SharePoint 2013 [closed] - sharepoint

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Regarding to this Question link.
How can i change the siteLogo to a new one?
Is it even possible to do it from a ConsoleApplication via CSOM?

It looks like there are no hooks to the site logo in the client object model like there is in the regular object model. (site.RootWeb.SiteLogoUrl = pictureUrl;)

I couldn't find a way to do it using the CSOM but you can create a new site collection scoped (for SharePoint Online) feature with an event receiver and deploy it as a solution. It worked for me and saved me manually updating 380 sites. I had the FeatureActivated method recursively set the logo on the root web of the site collection and all of the sub webs. Here is the code:
public class Feature1EventReceiver : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
if (site != null)
{
SPWeb web = site.RootWeb;
SetLogo(web);
}
}
private void SetLogo(SPWeb web) {
web.SiteLogoUrl = "/SiteAssets/logo.png";
web.Update();
foreach (SPWeb subweb in web.Webs)
{
SetLogo(subweb);
}
}
}

Related

How #WebAppConfiguration works without servlet or application container? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am using spring 4 and testng. How #WebAppConfiguration loads the WebApplicationContext and servlets without error when I did not install servlet containers like tomcat at all. Is it possible to access the servlets by url in this situation or must install the web server?
You don't need to install a real servlet container. You can think that the servlet container created by the #WebAppConfiguration is just a fake and in-memory based servlet container but not a real container like Tomcat. It can only work by programatically invoking its method and cannot invoked by an URL.
The actual implementation of this fake Servlet container consist of MockServletContext , MockHttpServletRequest , MockHttpServletResponse , MockHttpSession and MockServletConfig etc...
The idea is that to test a HttpServlet , we first configure the HTTP request by the setting the related status of MockHttpServletRequest , then programatically invoke HttpServlet under test , and verify the result from the MockHttpServletResponse:
#ContextConfiguration
#WebAppConfiguration
public class FooServletTest {
#Autowired MockHttpServletRequest request;
#Autowired MockHttpServletResponse response;
#Test
public void test1(){
request.setParameter("user", "enigma");
//blablab.
FooServlet sut = new FooServlet();
sut.doGet(request, response);
//Then assert the response is correct by checking its status
}
}
See docs for more details.

what is difference between spweb and spcontext in sharepoint?

what is the difference spweb and spcontext when we need to use webcontext
Plese anyone can answer me.
spweb web =spcontext.current.web;
and
using(spsite site= new spsite(""))
{
using(spweb web=site.openweb(""))
{
}
}
In it's simplistic terms
using(spsite site= new spsite(""))
{
using(spweb web=site.openweb(""))
{
}
}
The above is pretty much the same as
spweb web =spcontext.current.web;
However the top code snippet you need to justify a URL to get your site object and by using the
using(){
}
You are automatically disposing of the objects site and web object.
The
spweb web =spcontext.current.web;
Get the context of the current web that the code is running in. It is essential that you do NOT dispose of this object.
It all depends if your code is running in the context of the site that you need a web or site object of.

Collaboration portal approval workflow

The company I work for has recently taken over a SharePoint 2007 project form another company. The other company created a site using the Collaboration Portal Publishing template. Since this is an internet web site, this is causing me a couple of problems.
By default the approval workflow is not activated on the Pages Libraries of the site, and the client requires the workflow to be active on all of the Pages Libraries. The problem is that the site is massive, and doing this manually will take too long, and because it’s such a large site I can’t recreate it from scratch.
Is there a way I can activate the approval workflow on all the Pages Libraries of the site? Could I maybe change something in the site definition? Or is there a way to activate it programmatically? Then I could create a console app that will recursively iterate through the sites and attach the workflow to the Pages Libraries?
Your can try with this code :
using (MossFramework.DocumentLibraryHelper docLibraryHelper = new MossFramework.DocumentLibraryHelper("SITENAME"))
{
using (SPSite site = new SPSite(docLibraryHelper.MossSiteAddress))
{
SPWeb siteCollection = site.OpenWeb();
siteCollection.AllowUnsafeUpdates = true;
SPFolder folder = siteCollection.GetFolder("Document Centre");
SPList list = siteCollection.Lists["Document Centre"];
Guid wfBaseId = new Guid("{5703E6AC-1C65-440F-88DC-EB65F2C6DF82}");
SPWorkflowAssociation wrkFl = list.WorkflowAssociations.GetAssociationByBaseID(wfBaseId);
foreach (SPListItem spListItem in list.Items)
{
site.WorkflowManager.StartWorkflow(spListItem, wrkFl, wrkFl.AssociationData);
// Error occurs here
}
site.Close();
}
}
or
You can try with this
I hope that helps

Biztalk Log4Net [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Has anyone used log4net with Biztalk? We are currently looking into using it and are trying to access pros/cons, and whether or not it would meet our needs.
I have used Log4Net with BizTalk, but i will say that out of the box i ran into issues. Every call out of BizTalk results in the current orchestration getting dehydrated (serialized) so any type you use in BizTalk would have to be serializable and the log4net logger was not.
If you absolutely have to use log4net there is a wrapper that Scott Colestock wrote here.
Assuming you are not locked in, i would just use Enterprise Logging, it offers almost the same functionality as log4net and works out of the box with BizTalk. You can find it here.
For pros and cons, i will say that offer almost exact functionality, I actually ended up creating a wrapper utility that made the Enterprise Library Logging Block look more like log4net.
public static class Logging
{
public static void LogMessage(TraceEventType eventType, string category, string message)
{
LogEntry logEntry = new LogEntry();
logEntry.Severity = eventType;
logEntry.Priority = 1;
logEntry.Categories.Add(category);
logEntry.Message = message;
Logger.Write(logEntry);
}
public static void LogError(string category, string message)
{
LogMessage(TraceEventType.Error, category,message);
}
public static void LogInfo(string category, string message)
{
LogMessage(TraceEventType.Information, category, message);
}
public static void LogVerbose(string category, string message)
{
LogMessage(TraceEventType.Verbose, category, message);
}
}
And if you need more look here .
Have you considered using ETW. This in my opinion is the way to go for instrumenting BizTalk. http://blogs.msdn.com/b/asgisv/archive/2010/05/11/best-practices-for-instrumenting-high-performance-biztalk-solutions.aspx
One of the drawbacks of using both log4net and Enterprise Logging is you need config to enable it. So you have to manage the btsntsvc.exe.config files on all servers in your biztalk group which can be an overhead.
ETW is zero config.
I've got to say that after using both log4net and MS Enterprise Library for application logging on different projects, I prefer log4net. I particularly like the way that with log4net you can centralise the configuration in a single place (e.g. database), rather than having to rely on local server app.config for the btsntsvc.exe.
This is particularly useful if you need to spin out new server instances to add to your farm - you've got enough to do without worrying about logging config. I've used log4net with both BTS2004 and BTS2006R2 and been satisfied. One thing I would recommend whichever logging framework you go with, don't fall into the trap of using the Event Log as a sink - when you scale out across 10 BTS app servers, it is a time consuming process to track errors, particularly as orchestration instances have no affinity to an app server and tend to move across your estate! Keep the event log for crucial OS and BTS service issues, rather than custom application errors - makes SCOM monitoring a lot less painless.
FYI - I too use log4net with Colestock's serializable wrapper, albeit with a few tweaks.

No current context when creating a sharepoint site

I've added a feature to my onet.xml file which gets activated whenever a site gets created. However, that feature needs to know the url of the site being created. I thought I could figure that out from the current SPContext within the activation event of the feature, but when I created the site I got a null reference on SPContext.Current.
Is that to be expected, or have I done something wrong? If that is the case, does anyone have any suggestions how I can dynamically learn the URL of the site being created?
Thanks
It seems like you have created a feature receiver? They don't use SPContext but find the site they have been activated on through the properties, like so:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb web = properties.Feature.Parent as SPWeb)
{...}
}

Resources