Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

Liedong(Ken) Zheng, Senior SharePoint Developer at SIMPLOT

Archive for October 22nd, 2008

SPSolution named “SolutionPackageName” already exists under the parent Microsoft .SharePoint.Administration.SPFarm

Posted by ken zheng on October 22, 2008

If you encounter an error of type “Error 102 An object of the type Microsoft.SharePoint.Administration.SPSolution named “SolutionPackageName” already exists under the parent Microsoft.SharePoint.Administration.SPFarm named “SharePointContentDBName”. Rename your object or delete the existing object”, then even though if you remove the references of the solution in the sites, SharePoint will not allow to redeploy the solution.

The issue can be solved by, browse to the Central Administration -> Operations -> Solution Management and then delete the wsp file that caused the error and then redeploy the file again.

or run

%stsadm% -o retractsolution -name sharepointrandomimagewebpart.wsp -url “http://app01:17768/sites/infoservice” -immediate

wait a minute then run

%STSADM% -o deletesolution -name sharepointrandomimagewebpart.wsp

Posted in Sharepoint | Tagged: , | 3 Comments »

Updating daylight savings time zone information for Sharepoint

Posted by ken zheng on October 22, 2008

Please keep in mind, that if it is not updated, all items which require a date time stamp reference will be out by 1 hour.

If necessary, time zone information for Sharepoint can be manually updated, as per the following KB:
http://support.microsoft.com/kb/888253

This involves editing the timezone.xml file, located at
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\CONFIG

Example
In the following example, the end time for daylight savings is set to the first week in April, and the start time for daylight savings is set to the first week in October.
Note that the section refers to the week in the month. If this is set to 5, that means the last week.

<TimeZone ID="76" Name="(GMT+10:00) Canberra, Melbourne, Sydney" Hidden="FALSE">
        <Bias>-600</Bias>
        <StandardTime>
            <Bias>0</Bias>
            <Date>
                <Month>4</Month>
                <Day>1</Day>
                <Hour>3</Hour>
            </Date>
        </StandardTime>
        <DaylightTime>
            <Bias>-60</Bias>
            <Date>
                <Month>10</Month>
                <Day>1</Day>
                <Hour>2</Hour>
            </Date>
        </DaylightTime>
    </TimeZone>

Posted in Sharepoint | Tagged: | Leave a Comment »

Item-level permissions on document libraries and issue lists in WSS 3.0

Posted by ken zheng on October 22, 2008

A little tool you can set your document libraries to have read/write access to the item in document library like list.

http://homercles.wordpress.com/2008/10/21/item-level-permissions-on-document-libraries/

http://blogs.pointbridge.com/Blogs/morse_matt/Pages/Post.aspx?_ID=8

Posted in Sharepoint | Tagged: | Leave a Comment »

Random Image Web Part

Posted by ken zheng on October 22, 2008

Here is the simple custom webpart which random displays the image from picture library.

You can edit the web part by change the URL and picture library name
Random Image Web Part

public class RandomImage : System.Web.UI.WebControls.WebParts.WebPart
    {
        string _SiteURL = SPContext.Current.Web.Url;
        string _PicLibName = "Pic Lib";

        [WebBrowsable(true),
        Personalizable(PersonalizationScope.Shared),
        FriendlyName("The Site URL of Picture Library")]
        public string SiteURL
        {
            get
            {
                return _SiteURL;
            }
            set
            {
                _SiteURL = value;
            }
        }

        [WebBrowsable(true),
        Personalizable(PersonalizationScope.Shared),
        FriendlyName("The Name of Picture Library")]
        public string PicLibName
        {
            get
            {
                return _PicLibName;
            }
            set
            {
                _PicLibName = value;
            }
        }

        Image myimage = new Image();
        protected override void CreateChildControls()
        {
            myimage.Height = 256;
            myimage.Width = 256;
            try
            {
                using (SPSite mysite = new SPSite(SiteURL))
                {
                    //mysite = SPControl.GetContextSite(Context);

                    using (SPWeb myweb = mysite.OpenWeb())
                    {
                        SPList mylist = myweb.Lists[PicLibName];
                        SPQuery myquery = new SPQuery();
                        myquery.Query = "";

                        string serverpath = mysite.Url.ToString() + "/";
                        SPListItemCollection mylistitem = mylist.GetItems(myquery);
                        if (mylistitem.Count > 0)
                        {
                            System.Random RandNum = new System.Random();
                            int MyRandomNumber = RandNum.Next(mylistitem.Count);
                            myimage.ImageUrl = serverpath + mylistitem[MyRandomNumber].Url.ToString();
                        }
                        else
                        {
                            this.Page.Response.Write("No image found");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Controls.Clear();
                Label errorMessage = new Label();
                errorMessage.Text = "There was an error in the code.  Please contact your system administrator and rely the following " +
                    "message: " + ex.Message;
                Controls.Add(errorMessage);
            }

            base.CreateChildControls();
        }
        protected override void Render(HtmlTextWriter writer)
        {
            myimage.RenderControl(writer);
            // TODO: add custom rendering code here.
            // writer.Write("Output HTML");
        }
    }

Posted in Sharepoint | Tagged: | 2 Comments »