Wednesday, August 22, 2012

Update Modified / Created in List Item

I would like to migrate a site to another SharePoint Server as a site collection. Unfortunately, I cannot export the site using "Save site as template" (many issues needed to be solved, such as MaxTemplateDocumentSize). 

Apart from "Save site as template", I can choose between site collection backup and export site. For site collection, it includes fields Modified By, Created By, Created and Modified which are absent in site (*.cmp) file. In fact, I cannot move a site up one level without importing site file(*.cmp). Here is a method to update those fields programatically:

            SPListItem item = workflowProperties.Item;
            SPUser user = workflowProperties.Web.AllUsers[@"Test\wawa"];
            SPFieldUserValue currentUser = new SPFieldUserValue(workflowProperties.Web, user.ID, user.LoginName);
            item["Author"] = currentUser;
            item["Editor"] = currentUser;
            item.UpdateOverwriteVersion();

Monday, August 6, 2012

Custom DLL in SharePoint Solution 2010

I reference a custom DLL to a SharePoint Event Receiver solution. But, the event is not triggered when adding a list item. In the log file, an error log can be found:

Could not load type 'SAFP.SharedMethods' from assembly 'SharedMethods, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5e96847a5abc7fb4'

As I have deployed the DLL to GAC already and included the assembly in web.config SafeControl, I have no idea what am I missing.

After asking my friend "Google", it tells me that something should be done on package inside SharePoint Project.

1. Click Package and then click Advanced button
2. Add additonal assmeblies

 
Then I upgrade the solution and everything works fine.

Tuesday, May 29, 2012

Setting NFS Client in Windows 2008 R2

Here are steps needed to be configure:

(1) Server Manager-> Add Role -> File Services

Thursday, April 12, 2012

Https Web Service Client

I run a Web Service Client in Java and then a exception is shown:

"PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"

Based on the above error mesage, it seems related to SSL certificate. Then, I do the following step:

(1) Download the Web Service certificate



(2) Install the certificate



After I install the certificate to JRE, the issue is solved.

If I install the cert in Java\jre6, tomcat under eclipse runs fine.
If I install the cert in Java\jdk\jre, tomcat runs fine.

Reference:
keytool reference



Tuesday, March 13, 2012

Setting NFS Client in Windows 7

I need to map a network drive to a NFS Server in CentOS 5.5 and the steps are shown below:

 1. Go to Control Panel => Programs and Features => Turn Windows features on or off and enable Services for NFS

 2. If you want to connect to NFS as root, go to regedit and edit HKKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default\RegNotify.

     AnonymousGid: root
     AnonymousUid: root

3. Restart service of "Client for NFS"

4. Map network drive

Thursday, February 16, 2012

CTI Client in C#

I try set agent desktop state through a custom CTI Client in C#.

The code is shown below:

 
   public static void Main(string[] args)
        {
            Int32 port = 12028;
            String server = "127.0.0.1";

            TcpClient client = new TcpClient(server, port);
            NetworkStream stream = client.GetStream();

            byte[] message = new byte[ 8 + 17 + extension.Length + 3 + agentID.Length + 3];

            int len = 0;
            //header 
            UInt32[] length = { IntToNetworkOrder(34) };
            Buffer.BlockCopy(length, 0, message, len, sizeof(UInt32));
            len += sizeof(UInt32);

            UInt32[] msgTypeID = { IntToNetworkOrder(38) };
            Buffer.BlockCopy(msgTypeID, 0, message, len, sizeof(UInt32));
            len += sizeof(UInt32);

            //fix part (17)
            UInt32[] invokeID = { IntToNetworkOrder(100) };
            Buffer.BlockCopy(invokeID, 0, message, len, sizeof(UInt32));
            len += sizeof(UInt32);

            UInt32[] reserved1 = { IntToNetworkOrder(1) };
            Buffer.BlockCopy(reserved1, 0, message, len, sizeof(UInt32));
            len += sizeof(UInt32);

            ushort[] agentState = { ShortToNetworkOrder(3) };
            Buffer.BlockCopy(agentState, 0, message, len, sizeof(ushort));
            len += sizeof(ushort);

            ushort[] reserved2 = { ShortToNetworkOrder(0) };
            Buffer.BlockCopy(reserved2, 0, message, len, sizeof(ushort));
            len += sizeof(ushort);

            ushort[] reserved3 = { ShortToNetworkOrder(0) };
            Buffer.BlockCopy(reserved3, 0, message, len, sizeof(ushort));
            len += sizeof(ushort);

            ushort[] eventReasonCode = { ShortToNetworkOrder(32760) };
            Buffer.BlockCopy(eventReasonCode, 0, message, len, sizeof(ushort));
            len += sizeof(ushort);

            byte[] forcedFlag = new byte[] { 0 };
            Buffer.BlockCopy(forcedFlag, 0, message, len, sizeof(byte));
            len += sizeof(byte);

            //floating part
            //agent instrument
            byte[] agentInstrumentID = new byte[] { 6 };
            Buffer.BlockCopy(agentInstrumentID, 0, message, len, sizeof(byte));
            len += sizeof(byte);

            byte[] agentInstrumentLen = new byte[] { (byte)(extension.Length + 1) };
            Buffer.BlockCopy(agentInstrumentLen, 0, message, len, sizeof(byte));
            len += sizeof(byte);

            byte[] agentInstrumentData = System.Text.Encoding.ASCII.GetBytes(extension);
            Buffer.BlockCopy(agentInstrumentData, 0, message, len, agentInstrumentData.Length);
            len += agentInstrumentData.Length;

            Buffer.BlockCopy(forcedFlag, 0, message, len, sizeof(byte));
            len += sizeof(byte);

            //agent id
            byte[] agentIdID = new byte[] { 194 };
            Buffer.BlockCopy(agentIdID, 0, message, len, sizeof(byte));
            len += sizeof(byte);

            byte[] agentIdLen = new byte[] { (byte)(agentID.Length + 1) };
            Buffer.BlockCopy(agentIdLen, 0, message, len, sizeof(byte));
            len += sizeof(byte);

            byte[] agentIdData = System.Text.Encoding.ASCII.GetBytes(agentID);
            Buffer.BlockCopy(agentIdData, 0, message, len, agentIdData.Length);
            len += (agentIdData.Length);

            Buffer.BlockCopy(forcedFlag, 0, message, len, sizeof(byte));
            len += sizeof(byte);

            stream.Write(message, 0, message.Length);

            stream.Close();
            client.Close();
        }

        public static UInt32 IntToNetworkOrder(UInt32 source)
        {
            if (BitConverter.IsLittleEndian)
            {
                return (uint)(source >> 24) |
                             ((source << 8) & 0x00FF0000) |
                             ((source >> 8) & 0x0000FF00) |
                              (source << 24);
            }

            return source;
        }

        public static ushort ShortToNetworkOrder(ushort source)
        {
            if (BitConverter.IsLittleEndian)
            {
                return (ushort)(source >> 8 | source << 8);
            }
            return source;
        }

Saturday, February 4, 2012

CTI Protocol: Set Agent Desktop State

I try to use CTI protocol to update state of agent desktop and download a sample client which written in C++ from  http://developer.cisco.com/c/portal/agreement?fileEntryId=147817.

Then, I run cticlient\msclient\Debug\msclient.exe with following commands:

1. Open socket
    connect -s 172.20.32.144 -n 12028

2. Set agent state ready
    setagentstatereq -s 3 -e 32760 -f 0 -p 112233 -c Testing_CSQ -d agent11  -a 2011


References: