Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            s_oauthToken = ConsoleAuthentication.GetOAuthTokenFromFileProvider();
            Debug.Assert(!s_oauthToken.Equals(OAuthToken.Invalid));

            ApiAnalyzer buf  = new ApiAnalyzer(s_oauthToken);
            var         list = new Dictionary <string, string>();

            list = buf.GetBaseUris(Constants.Addresses.SmugMug, "/api/v2");

            for (int i = 0; i < args.Length; i++)
            {
                list.Add("arg" + i, args[i]);
            }

            Dictionary <string, string> uris = new Dictionary <string, string>();

            foreach (var item in list)
            {
                uris.Add(item.Key, Constants.Addresses.SmugMug + item.Value + Constants.RequestModifiers);
            }

            var types = buf.AnalyzeAPIs(uris, Constants.Addresses.SmugMugApi);

            var missingTypes = buf.GetMissingTypes();

            // make sure that we have all the types?
            foreach (var item in missingTypes)
            {
                if (!types.ContainsKey(item))
                {
                    ConsolePrinter.Write(ConsoleColor.Red, "Could not find type {0}", item);
                }
            }

            var jsonSerSettings = new JsonSerializerSettings();

            jsonSerSettings.TypeNameHandling = TypeNameHandling.All;
            jsonSerSettings.Formatting       = Formatting.Indented;
            var jsonSer = Newtonsoft.Json.JsonSerializer.CreateDefault(jsonSerSettings);

            using (StreamWriter sw = new StreamWriter("metadata.json"))
            {
                jsonSer.Serialize(sw, types);
            }

#if DEBUG
            Console.WriteLine("Complete");
            Console.ReadKey();
#endif
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;

            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, error) =>
            {
                Debug.WriteLine(cert.Subject);
                return(cert.Subject == "CN=smugmug.com" || cert.Subject == "CN=khainephotography.co.uk");
            };

            try
            {
                _oauthToken = ConsoleAuthentication.GetOAuthTokenFromProvider(new FileTokenProvider());
                _uploader   = new ImageUploader(_oauthToken);

                UploadFromArchives("2016*", false, true, true);
                UploadFromArchives("2017*", false, true, true);
                UploadFromArchives("2018*", false, true, true);
                UploadFromArchives("2019*", true, true, true);
                UploadFromArchives("2020*", true, true, true);

                //ProcessImages("Wood", "2020-07-26");
                //UploadArchiveFolder(@"\\VMWareHost\b$\KHPArchiveToProcess\2017-02-26_Sharp", false, true, true);
            }
            catch (Exception e)
            {
                ConsolePrinter.Write(ConsoleColor.Red, e.ToString());
            }
            finally
            {
#if DEBUG
                ConsolePrinter.Write(ConsoleColor.Cyan, "Complete");
                Console.ReadKey();
#endif
            }
        }