Пример #1
0
        /// ///////////////////////////////////////////////////////////////
        /// ///////////////Modified code by Joy on 20.07.2012////////////// 
        /// ///////////////////////////////////////////////////////////////
        /// <summary>
        /// <c>GetListItemsAsyncWrapper</c> wrapper function
        /// assign properties to  <c>ListWebService.Lists</c> class object
        /// and Register <c>GetListItemsCompleted</c> event of object
        /// it finally calls <c> listService.GetListItemsAsyn</c> function to sync uploading file
        /// </summary>
        /// <param name="m_uploadDocLibraryName"></param>
        /// <param name="viewname"></param>
        /// <param name="ndQuery"></param>
        /// <param name="ndViewFields"></param>
        /// <param name="rowlimit"></param>
        /// <param name="ndQueryOptions"></param>
        /// <param name="webid"></param>
        /// <param name="uploadData"></param>
        /// <param name="property"></param>
        private void GetListItemsAsyncWrapper(string m_uploadDocLibraryName, string viewname, XmlNode ndQuery, XmlNode ndViewFields, string rowlimit, XmlNode ndQueryOptions, string webid, object uploadData, CommonProperties property)
        {
            try
            {

                // for 2007//
                ListWebService.Lists listService = new ListWebService.Lists();
                listService.Credentials = property.Credentionals;
                listService.Url = property.CopyServiceURL;
                listService.GetListItemsCompleted += new ListWebService.GetListItemsCompletedEventHandler(listService_GetListItemsCompleted);
                // listService.GetListItemsAsync(m_uploadDocLibraryName, null, ndQuery, ndViewFields, "2", ndQueryOptions, null, uploadData);

                XmlNode n = listService.GetListCollection();

                string urlroot = property.LibSite.Remove(property.LibSite.Length - 1);
                foreach (XmlNode item in n.ChildNodes)
                {
                    string strcompare = urlroot + item.Attributes["DefaultViewUrl"].Value;
                    if (strcompare == property.CompletedoclibraryURL)
                    {
                        m_uploadDocLibraryName = item.Attributes["Title"].Value;
                        cmproperties.UploadDocLibraryName = m_uploadDocLibraryName;
                        break;

                    }

                }
                listService.GetListItemsAsync(m_uploadDocLibraryName, null, ndQuery, ndViewFields, "2", ndQueryOptions, null, uploadData);

            }
            catch (Exception ex)
            {
            }
        }
Пример #2
0
        /// <summary>
        /// <c>UpdateItemAttributes</c> member function 
        /// updates metatags information of file uploaded to sharepoint 2007 mapped document library.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="uitemdata"></param>
        private void UpdateItemAttributes(string id, UploadItemsData uitemdata)
        {
            try
            {

                ListWebService.Lists listService = new ListWebService.Lists();

                listService.Credentials = cmproperties.Credentionals;
                listService.Url = cmproperties.CopyServiceURL;
                XmlDocument doc = new XmlDocument();
                XmlNode docnode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                XmlElement batch_Element = doc.CreateElement("Batch");

                string itm = "<Method ID='1' Cmd='Update'>" + "<Field Name='ID'>" + id + "</Field>" + "<Field Name='Title'>" + uitemdata.MailSubject + "</Field>";
                itm += " </Method>";
                batch_Element.InnerXml = itm;
                try
                {
                    listService.UpdateListItems(cmproperties.UploadDocLibraryName, batch_Element);
                }
                catch (Exception)
                { }

                itm = "";
                itm = "<Method ID='1' Cmd='Update'>" + "<Field Name='ID'>" + id + "</Field>" + "<Field Name='Title'>" + uitemdata.MailSubject + "</Field>";
                itm += "<Field Name='ModifiedDate'>" + uitemdata.ModifiedDate + "</Field></Method>";

                XmlDocument docc = new XmlDocument();
                XmlElement bat_Element = docc.CreateElement("Batch");
                bat_Element.InnerXml = itm;
                listService.UpdateListItems(cmproperties.UploadDocLibraryName, bat_Element);

            }
            catch (Exception ex)
            {
                try
                {
                    ListWebService.Lists listService = new ListWebService.Lists();
                    listService.Credentials = cmproperties.Credentionals;
                    listService.Url = cmproperties.CopyServiceURL;
                    XmlDocument doc = new XmlDocument();
                    XmlNode docnode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                    XmlElement batch_Element = doc.CreateElement("Batch");

                    XmlNode FieldNode = doc.CreateElement("Method");
                    XmlAttribute productAttribute = doc.CreateAttribute("ID");
                    productAttribute.Value = "1";
                    FieldNode.Attributes.Append(productAttribute);
                    productAttribute = doc.CreateAttribute("Cmd");
                    productAttribute.Value = "Update";
                    FieldNode.Attributes.Append(productAttribute);

                    XmlNode fnode = doc.CreateElement("Field");
                    XmlAttribute fattribute = doc.CreateAttribute("Name");
                    fattribute.Value = "ID";
                    fnode.InnerText = id;
                    fnode.Attributes.Append(fattribute);
                    FieldNode.AppendChild(fnode);
                    /////////////
                    XmlNode fnodetitle = doc.CreateElement("Field");
                    XmlAttribute fattributetitle = doc.CreateAttribute("Name");
                    fattributetitle.Value = "Title";
                    fnodetitle.InnerText = uitemdata.MailSubject;
                    fnodetitle.Attributes.Append(fattributetitle);
                    FieldNode.AppendChild(fnodetitle);
                    /////////////
                    XmlNode fnodeDate = doc.CreateElement("Field");
                    XmlAttribute dateattribute = doc.CreateAttribute("Name");
                    dateattribute.Value = "ModifiedDate";
                    fnodeDate.InnerText = uitemdata.ModifiedDate;
                    fnodeDate.Attributes.Append(dateattribute);
                    FieldNode.AppendChild(fnodeDate);
                    ///////////

                    batch_Element.AppendChild(FieldNode);
                    doc.AppendChild(batch_Element);

                    try
                    {
                        listService.UpdateListItems(cmproperties.UploadDocLibraryName, batch_Element);
                    }
                    catch
                    { }

                }
                catch
                { }
            }
        }