Пример #1
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");
     }
 }
Пример #2
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);
        }