http://vstoolsforum.com/blogs/sqlserver/archive/2007/05/11/setting-the-recovery-model-of-a-database-to-simple.aspx
Simple and works perfectly.
Tuesday, June 14, 2011
Tuesday, May 3, 2011
GAC (Global Assebly Folder) empty- Trick to reenable
As my work is, I have to deploy x-times some assembly in my GAC and test it.
Well once in a while my assembly folder just seems empty, And then I can't build / deploy my solution anymore.
Here is the trick: (It is not mine.. but the more places it is published, the easier you guy find it:)
Start your windows services management console (services.msc) and restart the Indexing Service and everything is back to normal.!
Cool... once agian.. it was not our fault... we where just working!
Well once in a while my assembly folder just seems empty, And then I can't build / deploy my solution anymore.
Here is the trick: (It is not mine.. but the more places it is published, the easier you guy find it:)
Start your windows services management console (services.msc) and restart the Indexing Service and everything is back to normal.!
Cool... once agian.. it was not our fault... we where just working!
Tuesday, April 19, 2011
Faster VMWare
I was struggeling with the slowliness of my VMWare Workstation machine. I gave it 12 GB ram and 4 core processors
.
Well it turned out that assigning it more processors, actually made it slower. I reduced the processor to 1
installerDefaults.autoSoftwareUpdateEnabled = "yes"
installerDefaults.componentDownloadEnabled = "yes"
installerDefaults.dataCollectionEnabled = "no"
mks.ctlAltDel.ignore = "TRUE"
host.cpukHz = "3000000"
host.noTSC = "TRUE"
ptsc.noTSC = "TRUE"
prefvmx.minVmMemPct = "100"
datastore.name = "local"
defaultVMPath = "E:\DEV_Image"
datastore.localpath = "E:\DEV_Image\"
sched.mem.pshare.enable = "FALSE"
prefvmx.useRecommendedLockedMemSize = "TRUE"
prefvmx.minVmMemPct = "100"
priority.grabbed = "normal"
priority.ungrabbed = "normal"
security.host.ruissl = "FALSE"
mainMem.partialLazySave = "FALSE"
mainMem.partialLazyRestore = "FALSE"
mainMem.useNamedFile = "FALSE"
Isolation.tools.copy.enable = "true"
Isolation.tools.paste.enable = "true"
Isolation.tools.HGFS.disable = "false"
What these settings mean and what they are for you can look up here
http://sanbarrow.com/vmx/vmx-config-ini.html
.
Well it turned out that assigning it more processors, actually made it slower. I reduced the processor to 1
Cool explanation http://serverfault.com/questions/89057/vmware-7-processors-vs-cores
I also modified some settings in the config.ini located in c:\programmdata\vmware\vmware workstation\
(This file might not exist if you have the default settings, so make any kind of settings in the VMWare to make the file appear)
installerDefaults.componentDownloadEnabled = "yes"
installerDefaults.dataCollectionEnabled = "no"
mks.ctlAltDel.ignore = "TRUE"
host.cpukHz = "3000000"
host.noTSC = "TRUE"
ptsc.noTSC = "TRUE"
prefvmx.minVmMemPct = "100"
datastore.name = "local"
defaultVMPath = "E:\DEV_Image"
datastore.localpath = "E:\DEV_Image\"
sched.mem.pshare.enable = "FALSE"
prefvmx.useRecommendedLockedMemSize = "TRUE"
prefvmx.minVmMemPct = "100"
priority.grabbed = "normal"
priority.ungrabbed = "normal"
security.host.ruissl = "FALSE"
mainMem.partialLazySave = "FALSE"
mainMem.partialLazyRestore = "FALSE"
mainMem.useNamedFile = "FALSE"
Isolation.tools.copy.enable = "true"
Isolation.tools.paste.enable = "true"
Isolation.tools.HGFS.disable = "false"
What these settings mean and what they are for you can look up here
http://sanbarrow.com/vmx/vmx-config-ini.html
Thursday, April 14, 2011
Sharepoint 2010 Rename Assembly of WebPart
I came across of a new issue in SharePoint 2010 today. My client wished the web parts assembly name changed from some name A to some name B.
Well I thought easy, rebuild the web part, verify that the web part file is correct, retract old solution, deploy new solution (Web part is deployed as feature).
Well... When I inserted the web part with the new name everything worked. but all the pages that had the web part already inserted stopped working, saying that the type was not found.
The old web parts where trying to load the old assembly.
After looking and "googling" I didn't find any solution.. So my last resource... change the entry on the Content DB. Here is the script
UPDATE
[SiteCollection_Content_DB].[dbo].[AllWebParts]SET [tp_WebPartTypeId] ='NewWebPartTypeId',[tp_Assembly] = 'NewAssemblyBaseNamespace, Version=NewVersion, Culture=neutral, PublicKeyToken=newtoken',[tp_Class] = 'NewCompleteClassNameWithNamespace'
[tp_Class] WHERE [tp_Assembly] = 'OldAssemblyBaseNamespace, Version=OldVersion, Culture=neutral, PublicKeyToken=oldtoken' and = 'OldCompleteClassNameWithNamespace' and[tp_WebPartTypeId] ='OldWebPartTypeId'
To know the new values I just inserted one web part with the new dll and copied the values form the record I found on the AllWebParts table .
Well I thought easy, rebuild the web part, verify that the web part file is correct, retract old solution, deploy new solution (Web part is deployed as feature).
Well... When I inserted the web part with the new name everything worked. but all the pages that had the web part already inserted stopped working, saying that the type was not found.
The old web parts where trying to load the old assembly.
After looking and "googling" I didn't find any solution.. So my last resource... change the entry on the Content DB. Here is the script
UPDATE
[SiteCollection_Content_DB].[dbo].[AllWebParts]SET [tp_WebPartTypeId] ='NewWebPartTypeId',[tp_Assembly] = 'NewAssemblyBaseNamespace, Version=NewVersion, Culture=neutral, PublicKeyToken=newtoken',[tp_Class] = 'NewCompleteClassNameWithNamespace'
[tp_Class] WHERE [tp_Assembly] = 'OldAssemblyBaseNamespace, Version=OldVersion, Culture=neutral, PublicKeyToken=oldtoken' and = 'OldCompleteClassNameWithNamespace' and[tp_WebPartTypeId] ='OldWebPartTypeId'
To know the new values I just inserted one web part with the new dll and copied the values form the record I found on the AllWebParts table .
I strongly recommend though to make a backup of your DB!
I actually never touch the DB of SharePoint. I even convinced my client not to change the Assembly name... But still I tried the script in my Dev environment and it seemed to work.
UPDATE: Wow.. why do it the Unsupported way!... there is the supported way: Open your webApplication, loop through all of your sites & webs. Open each page, check if the webpart's in it, if so get the position(s) of the current web part(s). remove it (them) and insert the new webpart(s) with the new definition in the position(s) fetched.
UPDATE: Wow.. why do it the Unsupported way!... there is the supported way: Open your webApplication, loop through all of your sites & webs. Open each page, check if the webpart's in it, if so get the position(s) of the current web part(s). remove it (them) and insert the new webpart(s) with the new definition in the position(s) fetched.
Monday, April 11, 2011
Powershell Script to insert large amount of ListItems in Sharepoint List
A small script I wrote to insert a large amount of items in a custom list. It is just for testing purposes, so I can learn a little bit more about optimizing SPQueries and about ListView thresholds.
if((Get-PSSnapin -Name Microsoft.Sharepoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin Microsoft.Sharepoint.PowerShell
}
clear
#Get-Command -Module Microsoft.Sharepoint.PowerShell
$assignment = Start-SPAssignment
$webUrl="http://myweburl/"
$listName = "OneMillionRecords"
$spWeb = Get-SPWeb -Identity $webUrl -AssignmentCollection $assignment
$template = $spWeb.ListTemplates["Custom List"]
$listId=$spWeb.Lists.Add($listName,"List with one million records",$template)
$spNewList = $spWeb.Lists[$listName]
$spFieldTypeText = [Microsoft.SharePoint.SPFieldType]::Note
$spFieldTypeNumber = [Microsoft.SharePoint.SPFieldType]::Number
$spNewList.Fields.Add(“Description”,$spFieldTypeText,$false)
$spNewList.Fields.Add(“ItemNr”,$spFieldTypeNumber,$false)
$i =1
$max = 1000000
while ($i -le $max) {
$j=$i.ToString()
$title="Item $j"
$itemNr=$i
$description="The Item is called Item $j and is stored with some useless text"
$newItem=$spNewList.items.Add()
$newItem["Title"] = $title
$newItem["ItemNr"] = $itemNr
$newItem["Description"]=$description
$newitem.Update()
Write-Host $title
$i=$i+1
}
#Dispose all objects
Stop-SPAssignment $assignment
if((Get-PSSnapin -Name Microsoft.Sharepoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin Microsoft.Sharepoint.PowerShell
}
clear
#Get-Command -Module Microsoft.Sharepoint.PowerShell
$assignment = Start-SPAssignment
$webUrl="http://myweburl/"
$listName = "OneMillionRecords"
$spWeb = Get-SPWeb -Identity $webUrl -AssignmentCollection $assignment
$template = $spWeb.ListTemplates["Custom List"]
$listId=$spWeb.Lists.Add($listName,"List with one million records",$template)
$spNewList = $spWeb.Lists[$listName]
$spFieldTypeText = [Microsoft.SharePoint.SPFieldType]::Note
$spFieldTypeNumber = [Microsoft.SharePoint.SPFieldType]::Number
$spNewList.Fields.Add(“Description”,$spFieldTypeText,$false)
$spNewList.Fields.Add(“ItemNr”,$spFieldTypeNumber,$false)
$i =1
$max = 1000000
while ($i -le $max) {
$j=$i.ToString()
$title="Item $j"
$itemNr=$i
$description="The Item is called Item $j and is stored with some useless text"
$newItem=$spNewList.items.Add()
$newItem["Title"] = $title
$newItem["ItemNr"] = $itemNr
$newItem["Description"]=$description
$newitem.Update()
Write-Host $title
$i=$i+1
}
#Dispose all objects
Stop-SPAssignment $assignment
Saturday, April 9, 2011
PowerShell: Create Users in active directory and Sharpoint 2010
Small powerschell script that creates an amount of users in the Active Directory and inserts them in the Sharepoint 2010
Import-Module ActiveDirectory
if((Get-PSSnapin -Name Microsoft.Sharepoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin Microsoft.Sharepoint.PowerShell
}
#Get-Command -Module ActiveDirectory
clear
$i =3
while ($i -le 100000) {
$j=$i.ToString()
$username="Dev$j"
$webUrl="http://sharepoint website url/"
$group="Development Owners"
New-ADUser -SamAccountName $username -Name $username -UserPrincipalName "$username@domain.com" -DisplayName "$username User" -GivenName $username -Surname "User" -AccountPassword (ConvertTo-SecureString -AsPlainText "pass@word1" -Force) -Enabled $true -PasswordNeverExpires $false -Path 'CN=Users,DC=Domain,DC=com'
New-SPUser -UserAlias "Domain\$username" -Web $webUrl -DisplayName "$username User" -Group $group
Set-SPUser -Identity "Domain\$username" -Web $webUrl -SyncFromAD:$true
$i=$i+1
}
Thursday, March 31, 2011
Sharepoint 2010 Creating Colleagues (bidirectional) by code
This is a sample how impersonating the System Account a two way colleagues relationship can be established by code:
Thanks to the replies of Tony for error-when-trying-to-add-a-colleague-to-a-user-profile
Problem was that I actually got an error if I run his code with elevetad privilege, so slightly modified his solution.
using System;
.Hope it works for you guys too
Thanks to the replies of Tony for error-when-trying-to-add-a-colleague-to-a-user-profile
Problem was that I actually got an error if I run his code with elevetad privilege, so slightly modified his solution.
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
namespace SharePointProject1.VisualWebPart1
{
public partial class VisualWebPart1UserControl : UserControl
{
protected void AddUser_Click(object sender, EventArgs e) {
using (SPSite siteCol = new SPSite("MySiteUrl"))
{
//Open the Site with the SystemAccount
using (SPSite siteAdmin = new SPSite(siteCol.ID,siteCol.SystemAccount.UserToken))
{
try
{
//This is really needed, else you get an exception
siteAdmin.AllowUnsafeUpdates = true; using (SPWeb spwebAdmin = siteAdmin.OpenWeb())
{
//I didn't test if this 3 line are really needed
SPUser inviter = spwebAdmin.EnsureUser(@"Domain\User1");
SPUser invited = spwebAdmin.EnsureUser(@"Domain\User2");
spwebAdmin.Update();
SPServiceContext ctx = SPServiceContext.GetContext(siteAdmin);
//Get the user'sprofilemanager from the current context and ignore privacy
UserProfileManager upcm = new UserProfileManager(ctx, true);
//Gettheuserprofile
UserProfile userInvitee = upcm.GetUserProfile(@"Domain \User1");
UserProfile userInviter = upcm.GetUserProfile(@"Domain \User2");
//updateinviter
if (!userInviter.Colleagues.IsColleague(userInvitee.ID))
{
Colleague newColleague = userInviter.Colleagues.Create(userInvitee,ColleagueGroupType.General,"General", false,
Privacy.Public);
newColleague.Commit();
userInviter.Commit();
}
//updateinvitee
if (!userInvitee.Colleagues.IsColleague(userInviter.ID))
{
Colleague newColleague = userInvitee.Colleagues.Create(userInviter,ColleagueGroupType.General,"General", false,Privacy.Public);
newColleague.Commit();
userInvitee.Commit();
}
}
}
finally
{
siteAdmin.AllowUnsafeUpdates = false;
}
}
}
}
}
}
.Hope it works for you guys too
Subscribe to:
Posts (Atom)