Example #1
0
        private static void DoUploads(Library library, bool restricted_metadata_sync, Dictionary <string, string> historical_sync_file, SynchronisationAction synchronisation_action)
        {
            int upload_count = 0;

            StatusManager.Instance.ClearCancelled(StatusCodes.SYNC_META(library));
            foreach (SynchronisationState ss in synchronisation_action.states_to_upload)
            {
                StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(library), String.Format("Uploading metadata to your Web/Intranet Library ({0} to go)", synchronisation_action.states_to_upload.Count - upload_count), upload_count, synchronisation_action.states_to_upload.Count, true);
                ++upload_count;

                // Has the user cancelled?
                if (StatusManager.Instance.IsCancelled(StatusCodes.SYNC_META(library)))
                {
                    Logging.Info("User has cancelled their metadata upload");
                    break;
                }

                // Only do some filetypes if we are in restricted sync (e.g. they haven't paid for a while)
                {
                    if (restricted_metadata_sync)
                    {
                        string extension = ss.extension;
                        extension = extension.ToLower();
                        if (!SynchronisationFileTypes.extensions_restricted_sync.Contains(extension))
                        {
                            Logging.Info("Not syncing {0} because we are on restricted sync", ss.filename);
                            continue;
                        }
                    }
                }

                // Upload the file
                {
                    Logging.Info("+Uploading {0}", ss.filename);

                    // --- TODO: Replace this with a pretty interface class ------------------------------------------------
                    if (false)
                    {
                    }
                    else if (library.WebLibraryDetail.IsIntranetLibrary)
                    {
                        SynchronisationExecutor_Intranet.DoUpload(library, ss);
                    }
                    else
                    {
                        throw new Exception(String.Format("Did not understand how to upload for library {0}", library.WebLibraryDetail.Title));
                    }
                    // -----------------------------------------------------------------------------------------------------

                    Logging.Info("-Uploading {0}");

                    historical_sync_file[ss.filename] = ss.library_item.md5;
                }
            }

            StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(library), String.Format("Uploaded {0} metadata to your Web/Intranet Library", upload_count));
        }
Example #2
0
        private static void DoUploads(WebLibraryDetail web_library_detail, Dictionary <string, string> historical_sync_file, SynchronisationAction synchronisation_action)
        {
            int upload_count = 0;

            StatusManager.Instance.ClearCancelled(StatusCodes.SYNC_META(web_library_detail));
            foreach (SynchronisationState ss in synchronisation_action.states_to_upload)
            {
                StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(web_library_detail), String.Format("Uploading metadata to your Web/Intranet Library ({0} to go)", synchronisation_action.states_to_upload.Count - upload_count), upload_count, synchronisation_action.states_to_upload.Count, true);
                ++upload_count;

                // Has the user canceled?
                if (StatusManager.Instance.IsCancelled(StatusCodes.SYNC_META(web_library_detail)))
                {
                    Logging.Info("User has canceled their metadata upload");
                    break;
                }

                // Upload the file
                {
                    Logging.Info("+Uploading {0}", ss.filename);

                    // TODO: Replace this with a pretty interface class ------------------------------------------------
                    if (web_library_detail.IsIntranetLibrary)
                    {
                        SynchronisationExecutor_Intranet.DoUpload(web_library_detail, ss);
                    }
                    else
                    {
                        throw new Exception(String.Format("Did not understand how to upload for library {0}", web_library_detail.Title));
                    }
                    // -----------------------------------------------------------------------------------------------------

                    Logging.Info("-Uploading {0}");

                    historical_sync_file[ss.filename] = ss.library_item.md5;
                }
            }

            StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(web_library_detail), String.Format("Uploaded {0} metadata to your Web/Intranet Library", upload_count));
        }