I need to archive some old forms - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

I need to archive some old forms

Last post 07-09-2010 09:31 AM by Ted Fitch. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-08-2010 05:40 AM

    I need to archive some old forms

     One of our InfoPath libraries has become so large that we need to move it's contents to another infopath library. Obviously moving this many files through windows explorer isn't an option. The "Open forms in windows explorer" just won't cut it for this many files and frankly it crashes far too often.

     I suspect there is a commandline utility like SDSAdmin that will be able to do this for me. I've thought about writing a c# script to do this but frankly after finding loads of methods haven't been implemented properly I don't much fancy wasting time on this. 

    I've also considered using the WSS database to move the files but I don't really want to do this if it can be avoided.

    I want to use a promoted field to find out which field needs moving then move them.  

    Any pointers? The form wasn't created as a content type so I can't use workflow to move these documents and I also don't want to destroy the workflow in place.

  • 07-08-2010 10:58 AM In reply to

    Re: I need to archive some old forms

    Are you really sure you need to move the documents?

    SharePoint can literally store millions of documents in a library, the key though is how many documents are returned in any view and espeically the default view.

    http://technet.microsoft.com/en-us/library/cc262813(office.12).aspx and http://www.sharepointjoel.com/Lists/Posts/Post.aspx?List=0cd1a63d%2D183c%2D4fc2%2D8320%2Dba5369008acb&ID=241

    If you add indexes and manage the size of the default view (keep it under 2000 records returned) and instruct users on how to optimize their views you might find you don't really need to move all those forms!

    Hope that helps a bit

    Ted

  • 07-09-2010 01:51 AM In reply to

    Re: I need to archive some old forms

    There is an Excel service which is run from the sharepoint list and it has thousands of records in. It times out excel while retrieving the data and will shortly reach the maximum number of excel rows. The views aren't a problem. I could split the view into older and newer items but I don't think this is the correct solution as it is referenced by code elsewhere (and I honestly can't work out where).

    I think I'll trigger a custom workflow through c#. I'll write up how I do it

  • 07-09-2010 09:24 AM In reply to

    Re: I need to archive some old forms

    In the end I built a workflow in sharepoint designer to move the forms and triggered it with the code below (A Console App)

     using System;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.SharePoint;
    using System.Text;
    using Microsoft.SharePoint.Workflow;
    using System.Web.Mail;

    namespace TriggerWorkflowManually
    {
        class Program
        {
            static void Main(string[] args)
            {
                if (args.Length != 4)
                {
                    Console.WriteLine("TriggerWorkflowManually requires the following Parameters");
                    Console.WriteLine("Site URL: The URL of the site you want to use");
                    Console.WriteLine("Library Name: The name of the library containing no escape characters");
                    Console.WriteLine("WorkFlow Name: The name of the assosiated workflow you want to trigger");
                    Console.WriteLine("Email: The email you want the report sent to");
                    return;
                }
                else
                {
                    string siteURL = args[0];
                    string libraryName = args[1];
                    string workflow = args[2];
                    string email = args[3];

                    SPSite site = new SPSite(siteURL);

                    // Open Site and find lists
                    SPWeb web = site.OpenWeb();
                    web.AllowUnsafeUpdates = true;
                    SPList list = web.Lists[libraryName];
                    SPFolder folder = web.GetFolder(libraryName);
                    SPFileCollection files = folder.Files;
                    SPListItemCollection collection = list.Items;
                    StringBuilder sb = new StringBuilder();
                    Dictionary<string, string> errorDictionary = new Dictionary<string, string>();
                    Dictionary<string, string> successDictionary = new Dictionary<string, string>();

                    // Loop through the sharepoint list
                    foreach (SPListItem item in collection)
                    {
                        Console.WriteLine("Triggering Item: " + item["Name"]);
                        SPWorkflowAssociation associationTemplate = list.WorkflowAssociations.GetAssociationByName(workflow, new System.Globalization.CultureInfo("en-GB"));
                        try
                        {
                            site.WorkflowManager.StartWorkflow(item, associationTemplate, associationTemplate.AssociationData, true);
                            successDictionary.Add(item["Name"].ToString(), item["GUID"].ToString());
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Problem encountered While Triggering workflow for item:" + item["Name"]);
                            errorDictionary.Add(item["Name"].ToString(), e.ToString());
                            Console.WriteLine(e);
                        }
                    }

                    // Loop through dictionary and mail a report
                    foreach (KeyValuePair<string, string> pair in errorDictionary)
                    {
                        sb.Append('"' + pair.Key + '"' + "," + '"' + pair.Value + '"' + ';');
                    }

                    // Report the number of rows updated and number of errors encountered
                    Console.WriteLine("Total Rows Updated: " + successDictionary.Count);
                    Console.WriteLine("Total Errors Encountered: " + errorDictionary.Count);

                    // Send the user a mail
                    MailMessage objEmail = new MailMessage();
                    objEmail.To = email;
                    objEmail.From = email;
                    objEmail.Subject = "This is your workflow report";
                    objEmail.Body = "Total Rows Updated: " + successDictionary.Count + "\n" + "Total Errors Encountered: " + errorDictionary.Count + "\n" + "Errors: " + sb.ToString();
                    objEmail.Priority = MailPriority.High;
                    SmtpMail.SmtpServer = "mail.servername.com";

                    SmtpMail.Send(objEmail);
                }
            }
        }
    }

  • 07-09-2010 09:31 AM In reply to

    Re: I need to archive some old forms

    That's pretty slick Chris, thanks for sharing!

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.