コード例 #1
0
ファイル: Program.cs プロジェクト: vinnj/SPDownloader-
        static int SomeMain(string[] args)
        {
            SPAttachmentDownloader downloader = new SPAttachmentDownloader();

            downloader.DownloadAttachments();

            SiteUrl  = "https://tridentcrm1.sharepoint.com";
            UserName = "******";

            args = new string[] { "https://tridentcrm1.sharepoint.com", "*****@*****.**",
                                  "Arch*05012013", @"C:\Users\vinn\Documents\sharepointdocs", "Custom List" };

            try
            {
                if (!ReadArguments(args))
                {
                    return(1);
                }
                // Starting with context, the constructor requires a URL to the
                // server running SharePoint.
                using (ClientContext context = new ClientContext(SiteUrl))
                {
                    context.Credentials = new SharePointOnlineCredentials(UserName, Password);

                    //Load Libraries from SharePoint
                    context.Load(context.Web.Lists);
                    context.ExecuteQuery();
                    log.InfoFormat("Found {0} lists", context.Web.Lists.Count);

                    foreach (List list in context.Web.Lists)
                    {
                        log.InfoFormat("Processing list {0}", list.Title);

                        if (list.Title == ListName)
                        {
                            //bool docLib = (list.BaseType == BaseType.DocumentLibrary);

                            LocalList localList = new LocalList();
                            localList.Title = list.Title;

                            FillLocalList(context, list, localList);
                            log.InfoFormat("Downloaded listdata. Found {0} list items", localList.Items.Count);

                            string localFilePath = LocalFileLocation(list.ParentWebUrl, false);

                            localFilePath = Path.Combine(localFilePath, localList.Title + ".csv");

                            SaveLocalListToCSV(localList, true, localFilePath);
                            log.InfoFormat("Saved CSV {0}", localFilePath);


                            log.Info("Downloading doclib items");
                            SaveFilesFromList(context, localList, LocalRootFolder);
                            log.Info("Downloading doclib items done!");
                        }
                        //log.InfoFormat("Processing list {0}", list.Title);
                    }
                }
                log.InfoFormat("Finished successful for site {0}", SiteUrl);
                return(0);
            }
            catch (Exception ex)
            {
                log.Error("Terminated with error for site " + SiteUrl, ex);
                return(2);
            }
        }
コード例 #2
0
ファイル: EntryPoint.cs プロジェクト: vinnj/SPDownloader-
        static void Main(string[] args)
        {
            SPAttachmentDownloader downloader = new SPAttachmentDownloader();

            downloader.DownloadAttachments();
        }