Ejemplo n.º 1
0
        private string uploadPicture(DateTime dateTaken, string newPath, string fileName, string ext)
        {
            DateTimeFormatInfo mfi       = new DateTimeFormatInfo();
            string             monthName = mfi.GetMonthName(dateTaken.Month).ToString();

            return(ShutterflyUpload.Upload(sfAuthID, _secrets.SFAppID, monthName, dateTaken.Year.ToString(), newPath, fileName + ext));
        }
Ejemplo n.º 2
0
        public void RunImport()
        {
            if (Directory.Exists(_configs.ImportDir))
            {
                if (!Directory.Exists(_configs.PicDestinationDir))
                {
                    Directory.CreateDirectory(_configs.PicDestinationDir);
                }

                if (!Directory.Exists(_configs.VideoDestinationDir))
                {
                    Directory.CreateDirectory(_configs.VideoDestinationDir);
                }

                //Initialize Shutterfly
                if (_configs.ShutterflyUpload)
                {
                    if (_secrets.SFAppID != "" && _secrets.SFSharedSecret != "" && _secrets.SFUsername != "" && _secrets.SFPassword != "")
                    {
                        string authenticationID = ShutterflyUpload.GetAuthenticationID(_secrets.SFUsername, _secrets.SFPassword, _secrets.SFAppID, _secrets.SFSharedSecret);
                        if (!authenticationID.StartsWith("Failed:"))
                        {
                            sfAuthID = authenticationID;
                        }
                    }
                }

                FileInfo[] Pictures = (from fi in new DirectoryInfo(_configs.ImportDir).GetFiles("*.*", SearchOption.AllDirectories)
                                       where !videoExts.Contains(fi.Extension.ToLower())
                                       select fi)
                                      .ToArray();

                FileInfo[] Videos = (from fi in new DirectoryInfo(_configs.ImportDir).GetFiles("*.*", SearchOption.AllDirectories)
                                     where videoExts.Contains(fi.Extension.ToLower())
                                     select fi)
                                    .ToArray();

                List <string> moveErrors   = new List <string>();
                List <string> uploadErrors = new List <string>();

                foreach (FileInfo pictureFile in Pictures)
                {
                    ProcessPicture(pictureFile, ref moveErrors, ref uploadErrors);
                }

                foreach (FileInfo videoFile in Videos)
                {
                    processVideo(videoFile, ref moveErrors);
                }

                if (moveErrors.Count > 0 || uploadErrors.Count > 0)
                {
                    //sendEmail(moveErrors, uploadErrors);
                }

                CleanUp();
            }
            else
            {
                string error = "Import directory does not exist. Check your settings.";
            }
        }