Exemple #1
0
 public void AddToDataBase()
 {
     if (NeedToDump && !_dumped)
     {
         PhotoDataUploader.ExecuteNonQuery(GetInsertQuery(Id));
         _dumped = true;
     }
 }
Exemple #2
0
        protected override void AddOneAlbumOverride(string Name, string Month, string Year, string Photo, string Story)
        {
            PhotoDataUploader.Log(1, "Loading Album " + Name + " in " + Month + ", " + Year);
            Album a = new Album(Name, Convert.ToInt32(Month, 10), Convert.ToInt32(Year, 10), Photo, Story);

            PhotoDataUploader.g_AlbumList.Add(a);
            _albumsInFolder.Add(Name, a);
        }
Exemple #3
0
        public void DumpToDataBase()
        {
            foreach (DictionaryEntry aif in _albumsInFolder)
            {
                ((Album)(aif.Value)).AddToDataBase();
            }

            foreach (var qS in _photosInFolder)
            {
                PhotoDataUploader.ExecuteNonQuery(qS);
            }
        }
Exemple #4
0
        public void Add(DataEntry de)
        {
            string key = de.GetKey();

            if (!ContainsKey(key))
            {
                Add(key, de);
                de.NeedToDump = true;
                de.Id         = this.Count;
            }
            else
            {
                de.Id = ((DataEntry)this[key]).Id;
                PhotoDataUploader.Log(0, "Found Item");
            }
        }
Exemple #5
0
        protected override bool AddOnePhotoOverride(string DateStr, string JustTheName, string Title, string People, string AlbumT, string Place, bool NoShow, bool Favorite, string FlickrId, string FlickrSecret, string FlickrOriginalSecret, string FlickrFarm, string FlickrServer, string Rectangles)
        {
            if (FlickrId == "")
            {
                return(false);
            }

            // Add places to the places table
            PhotoDataUploader.g_PlaceList.Add(new Place(Place));

            // Finally add the photo to the list
            string qS = @"Insert into Photos (PhotoId, PhotoTitle, FileName, Path, Favorite, DisableIt, AlbumId, PlaceId, Month_, Date_, Year_, People, FlickrId, FlickrSecret, FlickrOSecret, FlickrFarm, FlickrServer, Rects) Values(";

            g_PhotoCount++;
            qS += g_PhotoCount + ", ";

            //string FullFilename = _abmPath + "\\" + Filename;
            if (Title == "")
            {
                Title = AlbumT;
            }

            // Add in the title
            qS += "'" + DataEntry.Escape(Title, '\'') + "', ";

            // Add in the filename
            qS += "'" + DataEntry.Escape(JustTheName, '\'') + "', ";

            // Add in the path of the image file
            qS += "'" + DataEntry.Escape("Path", '\'') + "', ";

            // Now the date time string
            //qS += "'" + /*DateTimeStr*/ "10/10/96" + "', ";
            //qS += "TO_DATE('10/10/1996', 'MM/DD/YYY'),";

            // Favorite?
            qS += (Favorite ? "true" : "false") + ", ";

            // DisableIt?
            qS += (NoShow ? "true" : "false") + ", ";

            Album a = (Album)(_albumsInFolder[AlbumT]);
            Place p = (Place)(PhotoDataUploader.g_PlaceList[Place]);

            p.AddToDataBase();

            if (a != null && p != null)
            {
                // AlbumId
                qS += a.Id + ", ";

                // PlaceId
                qS += p.Id + ", ";

                if (a.Photo == "")
                {
                    a.Photo = JustTheName;
                }

                if (a.Photo == JustTheName)
                {
                    const string photourl = "http://farm{0}.static.flickr.com/{1}/{2}_{3}{4}.{5}";
                    a.FlickrUrl = string.Format(photourl, FlickrFarm, FlickrServer, FlickrId, FlickrSecret, "_s", "jpg");
                }
            }
            else
            {
                PhotoDataUploader.Log(3, "Not found either the album or the place - data error");
                return(false);
            }

            {
                bool     foundDate = false;
                DateTime dt        = DateTime.Now;

                // Month, Date, Year
                if (DateStr != "")
                {
                    try
                    {
                        dt        = DateTime.Parse(DateStr);
                        foundDate = true;
                    }
                    catch { }

                    if (!foundDate)
                    {
                        try
                        {
                            dt        = DateTime.ParseExact(DateStr, "yyyy:MM:dd HH:mm:ss", CultureInfo.InvariantCulture);
                            foundDate = true;
                        }
                        catch { }
                    }
                }

                if (foundDate)
                {
                    qS += dt.Month + ", " + dt.Day + ", " + dt.Year;
                }
                else
                {
                    qS += a.Month + ", 1, " + a.Year;
                }
            }

            qS += ", '" + DataEntry.Escape(People, '\'') + "'";

            qS += ", '" + FlickrId + "'";
            qS += ", '" + FlickrSecret + "'";
            qS += ", '" + FlickrOriginalSecret + "'";
            qS += ", '" + FlickrFarm + "'";
            qS += ", '" + FlickrServer + "'";
            qS += ", '" + Rectangles + "'";
            qS += ")";

            _photosInFolder.Add(qS);

            return(false);
        }