コード例 #1
0
ファイル: SPCopyClass.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>UploadItemUsingCopyService</c> member function
        /// it calls <c>SPCopyServiceClass.UploadItemUsingCopyService</c> function to uploads the file to mapped sharepoint 2007 document library
        /// </summary>
        /// <param name="uploadData"></param>
        /// <param name="property"></param>
        /// <returns></returns>
        public static bool UploadItemUsingCopyService(UploadItemsData uploadData, CommonProperties property)
        {
            bool result = false;
            try
            {

                // for 2007
                result = SPCopyServiceClass.UploadItemUsingCopyService(uploadData, property);

                //for 2010

            }
            catch (Exception ex)
            {
                result = false;
            }
            return result;
        }
コード例 #2
0
ファイル: SPCopyServiceClass.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>UploadItemUsingCopyService</c> member function
        /// this uploads the file to sharepoint document library
        /// </summary>
        /// <param name="uploadData"></param>
        /// <param name="property"></param>
        /// <returns></returns>
        public static bool UploadItemUsingCopyService(UploadItemsData uploadData, CommonProperties property)
        {
            bool result = false;
            try
            {

                SPCopyService.Copy copyws = new Copy();

                byte[] fileBytes = null;
                string[] destinationUrls = null;

                //Replace "" with empty
                uploadData.UploadFileName = uploadData.UploadFileName.Replace("\"", " ");
                if (uploadData.UploadType == TypeOfUploading.Mail)
                {

                    //Get mail item

                    string tempFilePath = UserLogManagerUtility.RootDirectory + @"\\temp.msg";
                    if (Directory.Exists(UserLogManagerUtility.RootDirectory) == false)
                    {
                        Directory.CreateDirectory(UserLogManagerUtility.RootDirectory);
                    }
                    Outlook.MailItem omail = uploadData.UploadingMailItem;
                    omail.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG);

                    //// load the file into a file stream

                    //Read data to byte
                    fileBytes = File.ReadAllBytes(tempFilePath);
                    uploadData.UploadFileName = uploadData.UploadFileName.Trim() + uploadData.UploadFileExtension;
                }
                else
                {
                    //Set fullname to filename
                    fileBytes = uploadData.AttachmentData;
                    uploadData.UploadFileName = uploadData.UploadFileName.Trim() + uploadData.UploadFileExtension;
                }

                // format the destination URL
                destinationUrls = new string[] { property.LibSite + property.UploadDocLibraryName + "/" + uploadData.UploadFileName };

                // to specify the content type
                FieldInformation ctInformation = new FieldInformation();
                ctInformation.DisplayName = "Content Type";
                ctInformation.InternalName = "ContentType";
                ctInformation.Type = FieldType.Choice;
                ctInformation.Value = "Your content type";

                //FieldInformation[] metadata = { titleInformation };
                FieldInformation[] metadata = { };

                // execute the CopyIntoItems method
                copyws.CopyIntoItemsAsync("OutLook", destinationUrls, metadata, fileBytes, uploadData);

            }
            catch (Exception)
            {
                result = false;
            }
            return result;
        }
コード例 #3
0
ファイル: UploadBrokenUploads.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>MoveItemIsReportItem</c> member function
        /// move reportItem to the sourcefolder if autodelete option is  not checked
        /// </summary>
        /// <param name="Item"></param>
        /// <returns></returns>
        private bool MoveItemIsReportItem(object Item)
        {
            bool isDroppedItemUplaoded = false;
            try
            {

                //////////
                Outlook.ReportItem oMailItem = (Outlook.ReportItem)Item;
                ItemType = TypeOfMailItem.ReportItem;
                parentfolder = (Outlook.MAPIFolder)oMailItem.Parent;
                try
                {

                    mailitemEntryID = oMailItem.EntryID;

                    string strsubject = oMailItem.EntryID;
                    if (string.IsNullOrEmpty(strsubject))
                    {
                        strsubject = "tempomailcopy";
                    }

                    mailitemEntryID = strsubject;

                    string tempFilePath = UserLogManagerUtility.RootDirectory + "\\" + strsubject + ".msg";

                    if (Directory.Exists(UserLogManagerUtility.RootDirectory) == false)
                    {
                        Directory.CreateDirectory(UserLogManagerUtility.RootDirectory);
                    }
                    oMailItem.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG);

                }
                catch (Exception ex)
                {

                }

                string fileName = string.Empty;
                if (!string.IsNullOrEmpty(oMailItem.Subject))
                {
                    //Replce any specila characters in subject
                    fileName = Regex.Replace(oMailItem.Subject, strMailSubjectReplcePattern, " ");
                    fileName = fileName.Replace(".", "_");
                }

                if (string.IsNullOrEmpty(fileName))
                {
                    DateTime dtReceivedDate = Convert.ToDateTime(oMailItem.CreationTime);
                    fileName = "Untitled_" + dtReceivedDate.Day + "_" + dtReceivedDate.Month + "_" + dtReceivedDate.Year + "_" + dtReceivedDate.Hour + "_" + dtReceivedDate.Minute + "_" + dtReceivedDate.Millisecond;
                }

                UploadItemsData newUploadData = new UploadItemsData();
                newUploadData.UploadFileName = fileName;// oMailItem.Subject;
                newUploadData.UploadFileExtension = ".msg";
                newUploadData.UploadingReportItem = oMailItem;
                newUploadData.UploadType = TypeOfUploading.Mail;
                newUploadData.TypeOfMailItem = TypeOfMailItem.ReportItem;
                newUploadData.DisplayFolderName = folderName;
                frmUploadItemsListObject.UploadUsingDelegate(newUploadData);
                //Set dropped items is uploaded
                isDroppedItemUplaoded = true;

            }
            catch (Exception ex) { }
            try
            {

                XMLLogOptions userOptions = UserLogManagerUtility.GetUserConfigurationOptions();
                if (userOptions.AutoDeleteEmails == true)
                {
                    for (int i = 0; i <= parentfolder.Items.Count; i++)
                    {
                        try
                        {
                            Outlook.ReportItem me = (Outlook.ReportItem)parentfolder.Items[i];

                            if (me.EntryID == mailitemEntryID)
                            {
                                parentfolder.Items.Remove(i);

                            }
                        }
                        catch (Exception)
                        {

                        }
                    }
                }

            }
            catch (Exception)
            {

            }

            return isDroppedItemUplaoded;
        }
コード例 #4
0
ファイル: UploadBrokenUploads.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// code written by Joy
        /// excutes ansd the start the timer upload process when the backgoundworkers's do work event fires
        /// </summary>
        /// <param name="Item"></param>
        void doBackGroundUpload(object Item)
        {
            try
              {

              Globals.ThisAddIn.isTimerUploadRunning = true;
              OutlookObj = Globals.ThisAddIn.Application;
              outlookNameSpace = OutlookObj.GetNamespace("MAPI");
              Outlook.MAPIFolder oInBox = outlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
              Outlook.MAPIFolder olMailRootFolder = (Outlook.MAPIFolder)oInBox.Parent;
              oMailRootFolders = olMailRootFolder.Folders;
              Outlook.MailItem moveMail = (Outlook.MailItem)Item;
              string newCatName = "Successfully Uploaded";
              if (Globals.ThisAddIn.Application.Session.Categories[newCatName] == null)
              {
                  outlookNameSpace.Categories.Add(newCatName, Outlook.OlCategoryColor.olCategoryColorDarkGreen, Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone);
              }

              XmlNode uploadFolderNode = UserLogManagerUtility.GetSPSiteURLDetails("", folderName);

              if (uploadFolderNode != null)
              {
                  bool isDroppedItemUplaoded = false;

                  addinExplorer = ThisAddIn.OutlookObj.ActiveExplorer();

                  //Check the folder mapping with documnet library

                  if (isUserDroppedItemsCanUpload == false)
                  {
                      //Show message
                      try
                      {

                          Outlook.MailItem m = (Outlook.MailItem)Item;
                          mailitemEntryID = m.EntryID;

                          try
                          {
                              mailitem = m;

                              mailitemEntryID = m.EntryID;

                              string strsubject = m.EntryID;
                              if (string.IsNullOrEmpty(strsubject))
                              {
                                  strsubject = "tempomailcopy";
                              }

                              mailitemEntryID = strsubject;

                              string tempFilePath = UserLogManagerUtility.RootDirectory + "\\" + strsubject + ".msg";

                              if (Directory.Exists(UserLogManagerUtility.RootDirectory) == false)
                              {
                                  Directory.CreateDirectory(UserLogManagerUtility.RootDirectory);
                              }
                              m.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG);

                          }
                          catch (Exception ex)
                          {

                          }

                          Outlook.MAPIFolder fp = (Outlook.MAPIFolder)m.Parent;
                          DoNotMoveInNonDocLib(mailitemEntryID, fp);

                      }
                      catch (Exception)
                      {
                          NonDocMoveReportItem(Item);
                      }

                      MessageBox.Show("You are attempting to move files to a non document library. This action is not supported.", "ITOPIA", MessageBoxButtons.OK, MessageBoxIcon.Information);

                      return;

                  }

                  if (frmUploadItemsListObject == null || (frmUploadItemsListObject != null && frmUploadItemsListObject.IsDisposed == true))
                  {
                      //frmUploadItemsListObject = new frmUploadItemsList();

                      // myCustomTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(frmUploadItemsListObject, "ITOPIA");
                      //myCustomTaskPane.Visible = true;

                      IAddCustomTaskPane();

                  }
                  //frmUploadItemsListObject.TopLevel = true;
                  //frmUploadItemsListObject.TopMost = true;

                  ////////////////////// frmUploadItemsListObject.Show();

                  try
                  {

                      //////
                      //////////
                      Outlook.MailItem oMailItem = (Outlook.MailItem)Item;
                      parentfolder = (Outlook.MAPIFolder)oMailItem.Parent;
                      try
                      {
                          mailitem = oMailItem;

                          mailitemEntryID = oMailItem.EntryID;

                          string strsubject = oMailItem.EntryID;
                          if (string.IsNullOrEmpty(strsubject))
                          {
                              strsubject = "tempomailcopy";
                          }

                          mailitemEntryID = strsubject;

                          string tempFilePath = UserLogManagerUtility.RootDirectory + "\\" + strsubject + ".msg";

                          if (Directory.Exists(UserLogManagerUtility.RootDirectory) == false)
                          {
                              Directory.CreateDirectory(UserLogManagerUtility.RootDirectory);
                          }
                          oMailItem.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG);

                      }
                      catch (Exception ex)
                      {

                      }

                      string fileName = string.Empty;
                      if (!string.IsNullOrEmpty(oMailItem.Subject))
                      {
                          //Replce any specila characters in subject
                          fileName = Regex.Replace(oMailItem.Subject, strMailSubjectReplcePattern, " ");
                          fileName = fileName.Replace(".", "_");
                      }

                      if (string.IsNullOrEmpty(fileName))
                      {
                          DateTime dtReceivedDate = Convert.ToDateTime(oMailItem.ReceivedTime);
                          fileName = "Untitled_" + dtReceivedDate.Day + "_" + dtReceivedDate.Month + "_" + dtReceivedDate.Year + "_" + dtReceivedDate.Hour + "_" + dtReceivedDate.Minute + "_" + dtReceivedDate.Millisecond;
                      }

                      UploadItemsData newUploadData = new UploadItemsData();
                      newUploadData.ElapsedTime = DateTime.Now;
                      newUploadData.UploadFileName = fileName;// oMailItem.Subject;
                      newUploadData.UploadFileExtension = ".msg";
                      newUploadData.UploadingMailItem = oMailItem;
                      newUploadData.UploadType = TypeOfUploading.Mail;
                      newUploadData.DisplayFolderName = folderName;
                      frmUploadItemsListObject.UploadUsingDelegate(newUploadData);
                      //Set dropped items is uploaded
                      /////////////////////////updated by Joy on 25.07.2012/////////////////////////////////
                      bool uploadStatus = frmUploadItemsListObject.IsSuccessfullyUploaded;
                      XMLLogOptions userOption = UserLogManagerUtility.GetUserConfigurationOptions();
                      if (uploadStatus == true)
                      {
                          // Globals.ThisAddIn.isTimerUploaded = true;
                          isDroppedItemUplaoded = true;

                          for (int i = 0; i <= activeDroppingFolder.Items.Count; i++)
                          {
                              try
                              {
                                  Outlook.MailItem me = (Outlook.MailItem)activeDroppingFolder.Items[i];

                                  if (me.EntryID == mailitemEntryID)
                                  {
                                      me.Categories.Remove(0);
                                      me.Categories = newCatName;
                                      me.Save();

                                      if (userOption.AutoDeleteEmails == true)
                                      {
                                          UserMailDeleteOption(mailitemEntryID, parentfolder);
                                      }
                                  }
                              }
                              catch (Exception ex)
                              {

                              }
                          }

                          frmUploadItemsListObject.lblPRStatus.Invoke(new updateProgresStatus(() =>
                          {
                              frmUploadItemsListObject.lblPRStatus.Text = Globals.ThisAddIn.no_of_t_item_uploaded.ToString() + " " + "of" + " " + Globals.ThisAddIn.no_of_pending_items_to_be_uploaded.ToString() + " " + "Uploaded";
                          }));
                          frmUploadItemsListObject.progressBar1.Invoke(new updateProgessBar(() =>
                          {
                              frmUploadItemsListObject.progressBar1.Value = (((Globals.ThisAddIn.no_of_t_item_uploaded * 100 / Globals.ThisAddIn.no_of_pending_items_to_be_uploaded)));
                          }));

                      }
                      else
                      {
                          isDroppedItemUplaoded = false;
                      }

                      /////////////////////////updated by Joy on 25.07.2012/////////////////////////////////
                  }
                  catch (Exception ex)
                  {
                      isDroppedItemUplaoded = MoveItemIsReportItem(Item);
                  }

                  try
                  {
                      if (isDroppedItemUplaoded == false)
                      {
                          //string tempName = oDocItem.Subject;
                          string tempName = string.Empty;
                          Outlook.DocumentItem oDocItem = (Outlook.DocumentItem)Item;

                          try
                          {

                              Outlook._MailItem myMailItem = (Outlook.MailItem)addinExplorer.Selection[1];
                              foreach (Outlook.Attachment oAttachment in myMailItem.Attachments)
                              {
                                  if (oAttachment.FileName == oDocItem.Subject)
                                  {
                                      tempName = oAttachment.FileName;
                                      tempName = tempName.Substring(tempName.LastIndexOf("."));
                                      oAttachment.SaveAsFile(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName);

                                      //Read file data to bytes
                                      //byte[] fileBytes = File.ReadAllBytes(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName);
                                      System.IO.FileStream Strm = new System.IO.FileStream(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                                      System.IO.BinaryReader reader = new System.IO.BinaryReader(Strm);
                                      byte[] fileBytes = reader.ReadBytes(Convert.ToInt32(Strm.Length));
                                      reader.Close();
                                      Strm.Close();

                                      //Replace any special characters are there in file name
                                      string fileName = Regex.Replace(oAttachment.FileName, strAttachmentReplacePattern, " ");

                                      //Add uplaod attachment item data to from list.
                                      UploadItemsData newUploadData = new UploadItemsData();
                                      newUploadData.UploadType = TypeOfUploading.Attachment;
                                      newUploadData.AttachmentData = fileBytes;
                                      newUploadData.DisplayFolderName = activeDroppingFolder.Name;

                                      if (fileName.Contains("."))
                                      {
                                          newUploadData.UploadFileName = fileName.Substring(0, fileName.LastIndexOf("."));
                                          newUploadData.UploadFileExtension = fileName.Substring(fileName.LastIndexOf("."));

                                          if (string.IsNullOrEmpty(newUploadData.UploadFileName.Trim()))
                                          {
                                              //check file name conatins empty add the date time
                                              newUploadData.UploadFileName = "Untitled_" + DateTime.Now.ToFileTime();

                                          }
                                      }

                                      //Add to form
                                      frmUploadItemsListObject.UploadUsingDelegate(newUploadData);
                                      //Set dropped mail attachment items is uploaded.
                                      isDroppedItemUplaoded = true;
                                      newUploadData = null;
                                      //oDocItem.Delete();
                                      break;
                                  }
                              }
                          }
                          catch (InvalidCastException ex)
                          {
                              //Set dropped mail attachment items is uploaded to false
                              isDroppedItemUplaoded = false;
                          }

                          if (isDroppedItemUplaoded == false)
                          {
                              tempName = oDocItem.Subject;
                              tempName = tempName.Substring(tempName.LastIndexOf("."));
                              oDocItem.SaveAs(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName, Type.Missing);

                              System.IO.FileStream Strm = new System.IO.FileStream(UserLogManagerUtility.RootDirectory + @"\tempattachment" + tempName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                              System.IO.BinaryReader reader = new System.IO.BinaryReader(Strm);
                              byte[] fileBytes = reader.ReadBytes(Convert.ToInt32(Strm.Length));
                              reader.Close();
                              Strm.Close();

                              //Replace any special characters are there in file name
                              string fileName = Regex.Replace(oDocItem.Subject, strAttachmentReplacePattern, " ");

                              //Add uplaod attachment item data to from list.
                              UploadItemsData newUploadData = new UploadItemsData();
                              newUploadData.UploadType = TypeOfUploading.Attachment;
                              newUploadData.AttachmentData = fileBytes;
                              newUploadData.DisplayFolderName = activeDroppingFolder.Name;

                              if (fileName.Contains("."))
                              {
                                  newUploadData.UploadFileName = fileName.Substring(0, fileName.LastIndexOf("."));
                                  newUploadData.UploadFileExtension = fileName.Substring(fileName.LastIndexOf("."));

                                  if (string.IsNullOrEmpty(newUploadData.UploadFileName.Trim()))
                                  {
                                      //check file name conatins empty add the date time
                                      newUploadData.UploadFileName = "Untitled_" + DateTime.Now.ToFileTime();

                                  }
                              }

                              //Add to form
                              frmUploadItemsListObject.UploadUsingDelegate(newUploadData);
                              newUploadData = null;
                              //oDocItem.Delete();
                          }

                      }
                  }
                  catch (Exception ex)
                  {
                      //throw ex;
                      //////////////////////////////updated by Joy on 28.07.2012///////////////////////////////////
                      //  EncodingAndDecoding.ShowMessageBox("FolderItem Add Event_DocItem Conv", ex.Message, MessageBoxIcon.Error);
                      //////////////////////////////updated by Joy on 28.07.2012///////////////////////////////////
                  }

                  try
                  {
                      XMLLogOptions userOptions = UserLogManagerUtility.GetUserConfigurationOptions();

                      for (int i = 0; i <= parentfolder.Items.Count; i++)
                      {
                          try
                          {
                              Outlook.MailItem me = (Outlook.MailItem)parentfolder.Items[i];

                              if (me.EntryID == mailitemEntryID)
                              {
                                  ///////////////////////////modified by Joy on 10.08.2012////////////////////////////////////

                                  if (isDroppedItemUplaoded == true)
                                  {

                                      me.Categories.Remove(0);
                                      me.Categories = newCatName;
                                      me.Save();
                                      if (userOptions.AutoDeleteEmails == true)
                                      {
                                          UserMailDeleteOption(mailitemEntryID, parentfolder);
                                      }
                                      //parentfolder.Items.Remove(i);
                                  }
                                  ///////////////////////////modified by Joy on 10.08.2012////////////////////////////////////

                              }
                          }
                          catch (Exception)
                          {

                          }
                      }
                  }

                  catch (Exception)
                  {

                  }
                  if (!string.IsNullOrEmpty(mailitemEntryID))
                  {
                      if (ItemType == TypeOfMailItem.ReportItem)
                      {
                          UserReportItemDeleteOption(mailitemEntryID, parentfolder);
                      }
                      else
                      {
                          ///////////////////////////Updated by Joy on 16.08.2012....to be updated later///////////////////////////////
                          // UserMailDeleteOption(mailitemEntryID, parentfolder);
                          ///////////////////////////Updated by Joy on 16.08.2012....to be updated later///////////////////////////////
                      }
                  }

              }

              }
              catch (Exception ex)
              {
              EncodingAndDecoding.ShowMessageBox("Folder Item Add Event", ex.Message, MessageBoxIcon.Error);

              }

              //AddToUploadList(Item);
        }
コード例 #5
0
ファイル: frmUploadItemsList.cs プロジェクト: imysecy/SPLINK
        //private Boolean GetSPListName()
        //{
        //    XmlNode listResponse = null;
        //    try
        //    {
        //        //Get the list details by its name
        //        listResponse = listService.GetList(m_uploadDocLibraryName);
        //    }
        //    catch (Exception ex)
        //    {
        //        m_uploadDocLibraryName = string.Empty;
        //        if (ex.Message.Contains("HTTP status 401: Unauthorized."))
        //        {
        //            return false;
        //        }
        //        else
        //        {
        //            try
        //            {
        //                //If it get exception get all lists information and then get the list
        //                //using its comparision method.
        //                XmlNode allLists = listService.GetListCollection();
        //                XmlDocument allListsDoc = new XmlDocument();
        //                allListsDoc.LoadXml(allLists.OuterXml);
        //                // allListsDoc.Save(@"c:\allListsDoc.xml"); // for debug
        //                XmlNamespaceManager ns = new XmlNamespaceManager(allListsDoc.NameTable);
        //                ns.AddNamespace("d", allLists.NamespaceURI);
        //                // now get the GUID of the document library we are looking for
        //                //XmlNode dlNode = allListsDoc.SelectSingleNode("/d:Lists/d:List[@Title='" + documentLibraryName + "']", ns);
        //                //Employee[starts-with(FirstName,'Kl')]"
        //                XmlNodeList xlist = allListsDoc.SelectNodes("/d:Lists/d:List[starts-with(@DefaultViewUrl,'" + m_uploadFolderNode.ChildNodes[11].InnerText + "')]", ns);
        //                if (xlist.Count > 0)
        //                {
        //                    string viewURL = xlist[0].Attributes["DefaultViewUrl"].Value;
        //                    if (viewURL.StartsWith(m_uploadFolderNode.ChildNodes[11].InnerText))
        //                    {
        //                        m_uploadDocLibraryName = xlist[0].Attributes["Title"].Value;
        //                        //m_uploadLibNameFromAllLists = xlist[0].Attributes["Title"].Value;
        //                    }
        //                }
        //            }
        //            catch (Exception ex1)
        //            {
        //            }
        //        }
        //    }
        //    if (string.IsNullOrEmpty(m_uploadDocLibraryName))
        //    {
        //        //ShowMessageBox("Unable to find document library name.", MessageBoxIcon.Warning);
        //        return false;
        //    }
        //    return true;
        //}
        /// <summary>
        /// <c>UploadUsingDelegate</c> event handler 
        /// invokes <c>UploadItemUsingWebClientAPI</c> member function to start 
        /// uploading files to sharepoint mapped document library
        /// code written by Joy
        /// </summary>
        /// <param name="uploadData"></param>
        public void UploadUsingDelegate(UploadItemsData uploadData)
        {
            // HideProgressPanel(false);
            //BackgroundWorker bw = new BackgroundWorker();
            //bw.DoWork += delegate(object sender, DoWorkEventArgs e) { bw_DoWork(sender, e, uploadData); };
            //bw.RunWorkerAsync();
            bool successfullyuploaded;

            //DelegateUploadItemUsingCopyService pdSteps = new DelegateUploadItemUsingCopyService(UploadItemUsingWebClientAPI);

            //this.Invoke(pdSteps, new object[] { uploadData });
            UploadItemUsingWebClientAPI(uploadData);

            //Timer ti = new Timer();
            //ti.Interval = 5000;
            //ti.Start();
            //ti.Tick += new EventHandler(ti_tick);
        }
コード例 #6
0
ファイル: frmUploadItemsList.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>UpdataGridRows</c> member function
        /// Method to add uploaded items to grid along with their status whether they are uploaded 
        /// to sharepoint mapped document library not not.
        /// </summary>
        /// <param name="uploadResult"></param>
        /// <param name="outMessage"></param>
        /// <param name="outURL"></param>
        /// <param name="currentItem"></param>
        public void UpdataGridRows(bool uploadResult, string outMessage, string outURL, UploadItemsData currentItem)
        {
            try
            {
                ThisAddIn.IsMailItemUploaded = uploadResult;

                DateTime dtStart = DateTime.Now;
                //Add item to grid
                //code written by Joy]
                //invoke is used to avoid error-cross thread operation not valid
                this.dgvUploadImages.Invoke(new UIUpdaterDelegate(()=>
               {
                      currentRowIndex = this.dgvUploadImages.Rows.Add(SharePoint_Link.Properties.Resources.PROCESS_READY, "", "Waiting....", currentItem.UploadFileName, 0, currentItem.DisplayFolderName);
                }));

                //simulate two states of current step: success or failure
                if (uploadResult == true)
                {
                    //code written by Joy]
                    //invoke is used to avoid error-cross thread operation not valid
                     this.Invoke(new MethodInvoker(delegate

                    {

                        lblPleaseWaitMessage.Text = "Upload completed for " + currentItem.UploadFileName;

                    }));

                     //code written by Joy]
                     //invoke is used to avoid error-cross thread operation not valid

                         this.dgvUploadImages.Invoke(new UIUpdaterDelegate(()=>
               {
                    this.dgvUploadImages.Rows[currentRowIndex].Cells["colStatusImage"].Value = SharePoint_Link.Properties.Resources.ok_16;
               }));
                   if (string.IsNullOrEmpty(outMessage))
                    {
                        //code written by Joy]
                        //invoke is used to avoid error-cross thread operation not valid
                        this.dgvUploadImages.Invoke(new UIUpdaterDelegate(()=>
                            {
                        this.dgvUploadImages.Rows[currentRowIndex].Cells["colCurrentStatus"].Value = "" +
                            "Unable to read uploaded item inforamtion from list." +
                            "List Name contains special characters.";

                        //Uploading completed sucessfully.There is a problem with reading item from list.";
                        this.dgvUploadImages.Rows[currentRowIndex].Cells["colEdit"].Value = "View";
                        this.dgvUploadImages.Rows[currentRowIndex].Cells["colEdit"].Tag = outURL;
                            }));

                    }
                    else
                    {
                        //code written by Joy]
                        //invoke is used to avoid error-cross thread operation not valid
                         this.dgvUploadImages.Invoke(new UIUpdaterDelegate(()=>
                            {
                        this.dgvUploadImages.Rows[currentRowIndex].Cells["colCurrentStatus"].Value = "Upload Completed.";
                        this.dgvUploadImages.Rows[currentRowIndex].Cells["colEdit"].Value = "MetaTags";
                        this.dgvUploadImages.Rows[currentRowIndex].Cells["colEdit"].Tag = outURL;
                            }));
                    }
                    //Change the file name with modified file name
                    if (currentItem.UploadType == TypeOfUploading.Attachment)
                    {
                        //code written by Joy]
                        //invoke is used to avoid error-cross thread operation not valid
                         this.dgvUploadImages.Invoke(new UIUpdaterDelegate(()=>
                            {
                        this.dgvUploadImages.Rows[currentRowIndex].Cells["colMailSubject"].Value = currentItem.UploadFileName;// currentItem.UploadFileName;
                            }));
                         }
                    else
                    {
                        //code written by Joy]
                        //invoke is used to avoid error-cross thread operation not valid
                          this.dgvUploadImages.Invoke(new UIUpdaterDelegate(()=>
                            {
                        this.dgvUploadImages.Rows[currentRowIndex].Cells["colMailSubject"].Value = currentItem.MailSubject;// currentItem.UploadFileName;
                            }));
                            }

                    //Update uploaded time in xml file
                    UserLogManagerUtility.UpdateFolderConfigNodeDetails(currentItem.DisplayFolderName, "LastUpload", DateTime.Now.ToString());
                }
                else
                {
                    //code written by Joy]
                    //invoke is used to avoid error-cross thread operation not valid
                   // lblPleaseWaitMessage.Text = "Upload failed for " + currentItem.UploadFileName;
                    this.dgvUploadImages.Invoke(new UIUpdaterDelegate(()=>
                            {
                    this.dgvUploadImages.Rows[currentRowIndex].Cells["colStatusImage"].Value = SharePoint_Link.Properties.Resources.exclamation_red;
                    this.dgvUploadImages.Rows[currentRowIndex].Cells["colCurrentStatus"].Value = "Error ::" + outMessage;
                            }));
                }
                //code written by Joy]
                //invoke is used to avoid error-cross thread operation not valid
                this.dgvUploadImages.Invoke(new UIUpdaterDelegate(()=>
                            {
                this.dgvUploadImages.Rows[currentRowIndex].Cells["colElapsedTime"].Value = ((TimeSpan)(DateTime.Now - currentItem.ElapsedTime)).TotalSeconds.ToString("#,##0.00");// +" secs";// ((TimeSpan)(DateTime.Now - dtStart)).TotalSeconds.ToString("#,##0.00") + " secs";
                            }));
                 this.Invoke(new MethodInvoker(delegate
                  {
                this.Refresh();
                  }));
                float elapsedtime = 0.0F;
                //code written by Joy]
                //invoke is used to avoid error-cross thread operation not valid
                 this.Invoke(new MethodInvoker(delegate
                  {
                foreach (DataGridViewRow row in dgvUploadImages.Rows)
                {
                    try
                    {
                        elapsedtime += float.Parse(row.Cells["colElapsedTime"].FormattedValue.ToString());
                    }
                    catch (Exception)
                    {

                    }

                }
                  }));
                  this.Invoke(new MethodInvoker(delegate

                    {

                lblTimeElapsed.Text = "Time Elapsed: " + elapsedtime.ToString();
                    }));
            }

            catch (Exception ex)
            {
                EncodingAndDecoding.ShowMessageBox("UpdateGridRow", ex.Message, MessageBoxIcon.Error);
            }

            if (SPVersionClass.SPSiteVersion != SPVersionClass.SiteVersion.SP2010.ToString())
            {

                if (receivingRequestCount == sendingRequestCount && m_isUploadingCompleted == true)
                {
                    DelegateHidePanel phide = new DelegateHidePanel(HideProgressPanel);
                    this.Invoke(phide, new object[] { m_isUploadingCompleted });
                }

            }
        }
コード例 #7
0
ファイル: frmUploadItemsList.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>ListItemCompleted</c> function
        /// gets uploaded file  url and calls <c>UpdataGridRows</c> method to  add new row in grid.
        /// </summary>
        /// <param name="ndvolListItem"></param>
        /// <param name="uitemdata"></param>
        public void ListItemCompleted(XmlNode ndvolListItem, UploadItemsData uitemdata)
        {
            try
            {

                XmlNode ndVolunteerListItems = ndvolListItem;
                string test = uitemdata.UploadFileName;
                if (ndVolunteerListItems != null)
                {
                    if (ndVolunteerListItems.ChildNodes.Count == 3)
                    {
                        if (ndVolunteerListItems.ChildNodes[1].ChildNodes.Count > 1)
                        {
                            string id = Convert.ToString(ndVolunteerListItems.ChildNodes[1].ChildNodes[1].Attributes["ows_ID"].Value);
                            //////////

                            UpdateItemAttributes(id, uitemdata);

                            //////////

                            string sucessURL1 = m_LibSite + m_uploadFolderNode.ChildNodes[3].InnerText + "/Forms/EditForm.aspx?ID=" + id + "&UpFName=" + uitemdata.UploadFileName; ;
                            m_isUploadingCompleted = true;
                            DelegateUpdateGridRow pdSteps = new DelegateUpdateGridRow(UpdataGridRows);
                            this.Invoke(pdSteps, new object[] { true, "Success", sucessURL1, uitemdata });
                            UploadItemsData item = uitemdata; //(UploadItemsData)e.UserState;

                            //try
                            //{
                            //    string fileCheckin = m_sharepointLibraryURL.Substring(0, m_sharepointLibraryURL.LastIndexOf("Forms")) + item.UploadFileName;
                            //    bool b = listService.CheckInFile(fileCheckin, "Uplaod Completed.", "1");
                            //}
                            //catch (Exception ex)
                            //{
                            //}
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string outMessage1 = ex.Message;
                if (ex.InnerException != null)
                {
                    outMessage1 = ex.InnerException.Message;
                }
                m_isUploadingCompleted = true;
                DelegateUpdateGridRow pdSteps = new DelegateUpdateGridRow(UpdataGridRows);
                this.Invoke(pdSteps, new object[] { false, "Exception in GetListItemsCompleted Event." + outMessage1, " ", uitemdata });
            }
        }
コード例 #8
0
ファイル: frmUploadItemsList.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// Copy web serice UplaoddataCOmpleted Async event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //void copyws_CopyIntoItemsCompleted(object sender, CopyIntoItemsCompletedEventArgs e)
        //{
        //    try
        //    {
        //        UploadItemsData uploaditemdata = (UploadItemsData)e.UserState;
        //        CopyResult[] result = e.Results;
        //        int resultlength = result.Length;
        //        string outMessage = null;
        //        if (result.Length > 0)
        //        {
        //            if (result[0].ErrorMessage != null)
        //            {
        //                if (Convert.ToString(result[0].ErrorMessage) == "Object reference not set to an instance of an object.")
        //                {
        //                    outMessage = "Cause :: No prermission to access the List.(OR) List or Library is deleted or moved";
        //                }
        //                else if (Convert.ToString(result[0].ErrorCode) == "InvalidUrl")
        //                {
        //                    outMessage = "Upload Falied.Filename contains some special characters." + result[0].DestinationUrl;
        //                }
        //                else
        //                {
        //                    outMessage = result[0].ErrorMessage;
        //                }
        //            }
        //        }
        //        CopyIntoItemCompleted(uploaditemdata, resultlength, outMessage);
        //    }
        //    catch (Exception)
        //    {
        //    }
        //}
        /// <summary>
        /// <c>CopyIntoItemCompleted</c> member function
        /// calls <c>UpdataGridRows</c> method to update rows in datagrid.
        /// and calls <c>GetListItemsAsyncWrapper</c> method to complete uploading process
        /// </summary>
        /// <param name="uploaditemdata"></param>
        /// <param name="resultlength"></param>
        /// <param name="oMessage"></param>
        public void CopyIntoItemCompleted(UploadItemsData uploaditemdata, int resultlength, string oMessage)
        {
            try
            {

                string outMessage = string.Empty;
                string sucessURL = string.Empty;
                UploadItemsData uploadData = uploaditemdata;
                try
                {
                    receivingRequestCount++;

                    // execute the CopyIntoItems method

                    if (resultlength > 0)
                    {
                        //Set the file name to global variable
                        m_uploadingFileName = uploadData.UploadFileName;
                        if (oMessage != null)
                        {

                            outMessage = oMessage;

                            m_isUploadingCompleted = true;
                            UpdataGridRows(false, outMessage, sucessURL, uploadData);

                            //return false;
                        }
                        else
                        {

                            XmlDocument xmlDoc = new XmlDocument();
                            XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");

                            XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
                            XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");

                            ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
                                "<DateInUtc>TRUE</DateInUtc>";
                            //send required fields information
                            ndViewFields.InnerXml = "<FieldRef Name='ID'/> <FieldRef Name='LinkTitle'/>";

                            ndQuery.InnerXml = "<Where><Eq><FieldRef Name='FileLeafRef'></FieldRef><Value Type='Text'>" + uploadData.UploadFileName + "</Value></Eq></Where>";

                            //   lstwebclass.GetListItemsAsync(m_uploadDocLibraryName, null, ndQuery, ndViewFields, "2", ndQueryOptions, null, uploadData, cmproperties);

                            if (SPVersionClass.SPSiteVersion == SPVersionClass.SiteVersion.SP2007.ToString())
                            {
                                GetListItemsAsyncWrapper(m_uploadDocLibraryName, null, ndQuery, ndViewFields, "2", ndQueryOptions, null, uploadData, cmproperties);
                            }
                            m_isUploadingCompleted = false;

                        }
                    }
                }
                catch (Exception ex)
                {
                    outMessage = ex.Message;
                    if (ex.InnerException != null)
                    {
                        outMessage = ex.InnerException.Message;
                    }
                    m_isUploadingCompleted = true;
                    UpdataGridRows(false, "Exception in CopyIntoItemsCompleted Event." + outMessage, sucessURL, uploadData);

                    // ShowMessageBox(ex.Message, MessageBoxIcon.Error);
                }

            }
            catch (Exception ex)
            {
                EncodingAndDecoding.ShowMessageBox("CopyAsyncCompleted", ex.Message, MessageBoxIcon.Error);
            }
        }
コード例 #9
0
ファイル: frmUploadItemsList.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>UploadItemUsingWebClientAPI</c> member function
        ///finds uploading file properties and call methods to upload file to sharepoint mapped document library.
        /// Upload items using WEBClinet API
        /// </summary>
        /// <param name="uploadData"></param>
        private void UploadItemUsingWebClientAPI(UploadItemsData uploadData)
        {
            try
            {

                System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();

                m_WC = new WebClient();
                m_WC.UploadDataCompleted += new UploadDataCompletedEventHandler(m_WC_UploadDataCompleted);
                m_isUploadingCompleted = false;
                m_WC.Credentials = cmproperties.Credentionals;// listService.Credentials;
                byte[] fileBytes = null;

                //Replace "" with empty
                uploadData.UploadFileName = uploadData.UploadFileName.Replace("\"", " ");

                if (uploadData.UploadType == TypeOfUploading.Mail)
                {

                    //Get mail item

                    string tempFilePath = UserLogManagerUtility.RootDirectory + @"\\temp.msg";

                    if (Directory.Exists(UserLogManagerUtility.RootDirectory) == false)
                    {
                        Directory.CreateDirectory(UserLogManagerUtility.RootDirectory);

                    }
                    string msgbody = "";
                    if (uploadData.TypeOfMailItem == TypeOfMailItem.ReportItem)
                    {
                        Outlook.ReportItem omail = uploadData.UploadingReportItem;
                        omail.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG);
                        msgbody = omail.CreationTime.ToString();
                    }
                    else
                    {

                        Outlook.MailItem omail = uploadData.UploadingMailItem;

                        omail.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG);
                        msgbody = omail.SentOn.ToString();

                    }

                    //// load the file into a file stream
                    //FileStream inStream = File.OpenRead(sourcePath);
                    //byte[] fileBytes = new byte[inStream.Length];
                    //inStream.Read(fileBytes, 0, fileBytes.Length);

                    //Read data to byte
                    fileBytes = File.ReadAllBytes(tempFilePath);

                    ListWebClass.ComputeHashSP07(fileBytes, msgbody);

                    uploadData.MailSubject = HashingClass.Mailsubject;

                    uploadData.UploadFileName = HashingClass.Hashedemailbody.ToString().Trim() + uploadData.UploadFileExtension; // uploadData.UploadFileName.Trim()

                }
                else
                {
                    //Set fullname to filename

                    fileBytes = uploadData.AttachmentData;

                    uploadData.UploadFileName = uploadData.UploadFileName.Trim() + uploadData.UploadFileExtension;

                }

                //string destinationUrls = m_LibSite + m_uploadDocLibraryName + "/" + uploadData.UploadFileName;
                string destinationUrls = m_sharepointLibraryURL.Substring(0, m_sharepointLibraryURL.LastIndexOf("Forms")) + uploadData.UploadFileName;

                cmproperties.LibSite = m_LibSite;

                cmproperties.UploadDocLibraryName = m_uploadDocLibraryName;

                cmproperties.FileBytes = fileBytes;

                cmproperties.UserName = m_userName;

                cmproperties.Password = m_password;

                ///Upload Files to Sharepoint site
                if (SPVersionClass.SPSiteVersion == SPVersionClass.SiteVersion.SP2010.ToString())
                {

                    //for SharePoint2010
                    bool docuploaded = false;

                    string libsitestr = cmproperties.LibSite;

                    docuploaded = ListWebClass.uploadFilestoLibraryUsingClientOM(uploadData, cmproperties);

                    //HideProgressPanel(false);
                    if (docuploaded == true)
                    {

                        m_isUploadingCompleted = true;
                        string pth = libsitestr + cmproperties.UploadDocLibraryName + "/Forms/EditForm.aspx?ID=" + ListWebClass.FileID + "&IsDlg=1&UpFName=" + uploadData.UploadFileName;
                        //DelegateUpdateGridRow pdSteps = new DelegateUpdateGridRow();
                        UpdataGridRows(true, "Success", pth, uploadData);
                        //this.Invoke(pdSteps, new object[] { true, "Success", pth, uploadData });
                        //////////////////////////modified by joy on 27.07.2012////////////////////////////////////////
                        isSuccessfullyCompleted = true;
                        //code written by Joy
                        //increments the no of uploaded items
                        Globals.ThisAddIn.no_of_items_copied++;
                        Globals.ThisAddIn.no_of_moved_item_uploaded++;
                        Globals.ThisAddIn.no_of_copied_item_uploaded++;
                        Globals.ThisAddIn.no_of_t_item_uploaded++;

                    }
                    else
                    {
                        //////////////////////////modified by joy on 27.07.2012////////////////////////////////////////

                        m_isUploadingCompleted = false;
                        UpdataGridRows(false, "Exception While Uploading." + UpLoadErrorMessage, " ", uploadData);

                        //////////////////////////modified by joy on 27.07.2012////////////////////////////////////////

                        isSuccessfullyCompleted = false;

                    }

                    //////////////////////////modified by joy on 30.07.2012////////////////////////////////////////
                    Timer ti = new Timer();
                    ti.Interval = 2000;
                    ti.Start();
                    //code written by Joy]
                    //invoke is used to avoid error-cross thread operation not valid
                     this.Invoke(new MethodInvoker(delegate

                    {
                    lblPleaseWaitMessage.Text = "  Upload completed  ";
                    }));
                    ti.Tick += new EventHandler(ti_tick);
                    HideProgressPanel(true);
                    //////////////////////////modified by joy on 30.07.2012////////////////////////////////////////

                }
                else
                {
                    if (SPVersionClass.SPSiteVersion == SPVersionClass.SiteVersion.SP2007.ToString())
                    {
                        // for sharepoint2007

                        uploadData.MailSubject = HashingClass.Mailsubject;
                        uploadData.ModifiedDate = HashingClass.Modifieddate;
                        m_WC.UploadDataAsync(new Uri(destinationUrls), "PUT", fileBytes, uploadData);

                    }
                    else
                    {
                        EncodingAndDecoding.ShowMessageBox("Version Conflick", "Cannot detect Sharepoint version", MessageBoxIcon.Error);
                        HideProgressPanel(true);
                    }
                }

                //try
                //{
                //    bool result = listService.CheckInFile(destinationUrls, "", "0");
                //}
                //catch { }

                sendingRequestCount++;

            }
            catch (Exception ex)
            {

                if (ex.Message.Contains("401: Unauthorized") == true)
                {
                    string outMessage = ex.Message + "\r\nYou may get this error if the provided credentails to the folder are wrong.";
                    EncodingAndDecoding.ShowMessageBox("WebClient API Calling", outMessage, MessageBoxIcon.Information);
                }
                else
                {
                    EncodingAndDecoding.ShowMessageBox("WebClient API Calling", ex.Message, MessageBoxIcon.Error);
                }

            }
        }
コード例 #10
0
ファイル: frmUploadItemsList.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>UploadItemUsingCopyService</c>
        /// Upload Items using copy web service API
        /// calls <c>SPCopyClass.UploadItemUsingCopyService(</c> method to start uploading file to sharepoint 2007 mappped sharepoint
        /// document library.
        /// </summary>
        /// <param name="uploadData"></param>
        private void UploadItemUsingCopyService(UploadItemsData uploadData)
        {
            try
            {
                System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();

                CommonProperties comproperties = new CommonProperties();
                comproperties.LibSite = m_LibSite;
                comproperties.UploadDocLibraryName = m_uploadDocLibraryName;

                m_isUploadingCompleted = false;

                //oldcode//
                //byte[] fileBytes = null;
                //string[] destinationUrls = null;

                ////Replace "" with empty
                //uploadData.UploadFileName = uploadData.UploadFileName.Replace("\"", " ");
                //if (uploadData.UploadType == TypeOfUploading.Mail)
                //{

                //    //Get mail item

                //    string tempFilePath = UserLogManagerUtility.RootDirectory + @"\\temp.msg";
                //    if (Directory.Exists(UserLogManagerUtility.RootDirectory) == false)
                //    {
                //        Directory.CreateDirectory(UserLogManagerUtility.RootDirectory);
                //    }
                //    Outlook.MailItem omail = uploadData.UploadingMailItem;
                //    omail.SaveAs(tempFilePath, Outlook.OlSaveAsType.olMSG);

                //    //// load the file into a file stream

                //    //Read data to byte
                //    fileBytes = File.ReadAllBytes(tempFilePath);
                //    uploadData.UploadFileName = uploadData.UploadFileName.Trim() + uploadData.UploadFileExtension;
                //}
                //else
                //{
                //    //Set fullname to filename
                //    fileBytes = uploadData.AttachmentData;
                //    uploadData.UploadFileName = uploadData.UploadFileName.Trim() + uploadData.UploadFileExtension;
                //}

                //// format the destination URL
                //destinationUrls = new string[] { m_LibSite + m_uploadDocLibraryName + "/" + uploadData.UploadFileName };
                ////destinationUrls = new string[] { m_sharepointLibraryURL.Substring(0,m_sharepointLibraryURL.LastIndexOf("Forms")-1)  + "/" + uploadData.UploadFileName };

                //// to specify the content type
                //FieldInformation ctInformation = new FieldInformation();
                //ctInformation.DisplayName = "Content Type";
                //ctInformation.InternalName = "ContentType";
                //ctInformation.Type = FieldType.Choice;
                //ctInformation.Value = "Your content type";

                ////FieldInformation[] metadata = { titleInformation };
                //FieldInformation[] metadata = { };

                //// execute the CopyIntoItems method
                //copyws.CopyIntoItemsAsync("OutLook", destinationUrls, metadata, fileBytes, uploadData);
                //// End of oldcode//
                if (SPCopyClass.UploadItemUsingCopyService(uploadData, comproperties))
                {
                    sendingRequestCount++;
                }

            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("401: Unauthorized") == true)
                {
                    string outMessage = ex.Message + "\r\nYou may get this error if the provided credentails to the folder are wrong.";
                    EncodingAndDecoding.ShowMessageBox("UploadCopyCalling", outMessage, MessageBoxIcon.Information);
                }
                else
                {
                    EncodingAndDecoding.ShowMessageBox("UploadCopyCalling", ex.Message, MessageBoxIcon.Error);
                }

            }
        }
コード例 #11
0
ファイル: frmUploadItemsList.cs プロジェクト: imysecy/SPLINK
        /// <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
                { }
            }
        }