Exemple #1
0
 public IPTCViewModel(IIPTCModel mdl)
 {
     if (mdl != null)
     {
         IPTCModel = mdl;
     }
 }
Exemple #2
0
 public IPTCViewModel(IIPTCModel model)
 {
     Keywords        = model.Keywords;
     ByLine          = model.ByLine;
     CopyrightNotice = model.CopyrightNotice;
     Headline        = model.Headline;
     Caption         = model.Caption;
 }
Exemple #3
0
 /// <summary>
 /// Returns a filterd list of Pictures from the directory, based on a database query.
 /// </summary>
 /// <returns></returns>
 public IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts,
                                                IIPTCModel iptcParts, IEXIFModel exifParts)
 {
     if (namePart == null && photographerParts == null && iptcParts == null && exifParts == null)
     {
         return(Pictures);
     }
     return(Pictures.Where(x => x.FileName == namePart));
 }
Exemple #4
0
        public void bl_should_extract_IPTC_Info_from_existing_picture()
        {
            EnsureTestImages();

            IBusinessLayer bl = ueb.GetBusinessLayer();

            AssertNotNull("GetBusinessLayer", bl);

            IIPTCModel iptc = bl.ExtractIPTC("Img1.jpg");

            AssertNotNull("ExtractIPTC", iptc);
        }
 public IPTCViewModel(IIPTCModel mdlIptc)
 {
     if (mdlIptc == null)
     {
         return;
     }
     this.Keywords        = mdlIptc.Keywords;
     this.ByLine          = mdlIptc.ByLine;
     this.Caption         = mdlIptc.Caption;
     this.CopyrightNotice = mdlIptc.CopyrightNotice;
     this.Headline        = mdlIptc.Headline;
 }
Exemple #6
0
        /// <summary>
        /// ctor with model
        /// </summary>
        /// <param name="mdl"></param>
        public IPTCViewModel(IIPTCModel mdl)
        {
            if (mdl == null)
            {
                return;
            }

            ByLine          = mdl.ByLine;
            Caption         = mdl.Caption;
            CopyrightNotice = mdl.CopyrightNotice;
            Headline        = mdl.Headline;
            Keywords        = mdl.Keywords;
        }
Exemple #7
0
        public void IPTCViewModel_should_return_CopyrightNotices()
        {
            IIPTCModel mdl = ueb.GetEmptyIPTCModel();

            AssertNotNull("GetEmptyIPTCModel", mdl);

            IIPTCViewModel vmdl = ueb.GetIPTCViewModel(mdl);

            AssertNotNull("GetIPTCViewModel", vmdl);

            AssertNotNull("GetIPTCViewModel.CopyrightNotices", vmdl.CopyrightNotices);
            AssertTrue("GetIPTCViewModel.CopyrightNotices.Count()  > 2", vmdl.CopyrightNotices.Count() > 2);
        }
Exemple #8
0
        public IPTCViewModel(IIPTCModel mdl)
        {
            Keywords        = mdl.Keywords;
            ByLine          = mdl.ByLine;
            CopyrightNotice = mdl.CopyrightNotice;
            Headline        = mdl.Headline;
            Caption         = mdl.Caption;

            CopyrightNotices = new List <string>();
            ((List <string>)CopyrightNotices).Add("All rights reserved.");
            ((List <string>)CopyrightNotices).Add("CC-BY");
            ((List <string>)CopyrightNotices).Add("CC-BY-SA");
        }
Exemple #9
0
 public void WriteIPTC(string filename, IIPTCModel iptc)
 {
     try
     {
         //FileInformation.WriteIPTC(filename, iptc);
         _dal.Update((IPTCModel)iptc);
     }
     catch (Exception e)
     {
         log.Error(e);
         Console.WriteLine(e);
         throw;
     }
 }
Exemple #10
0
        /// <summary>
        /// Returns a filterd list of Pictures from the directory, based on a database query.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts,
                                                       IIPTCModel iptcParts, IEXIFModel exifParts)
        {
            Connect();

            var list    = new List <IPictureModel>();
            var command = new SqlCommand(
                @"SELECT Pictures.ID as picture_id, Filename, Make, FNumber, ExposureTime, ISOValue, Flash, ExposureProgram, Keywords, Caption, ByLine, CopyrightNotice, Headline
                FROM Pictures 
                INNER JOIN EXIF 
                ON Pictures.ID = EXIF.ID
                INNER JOIN IPTC
                ON Pictures.ID = IPTC.ID", Connection);
            var reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    //var EXIF = (string)reader["EXIF"];
                    //var IPTC = (string)reader["IPTC"];
                    list.Add(new PictureModel((string)reader["FileName"])
                    {
                        ID   = (int)reader["picture_id"],
                        EXIF = new EXIFModel()
                        {
                            Make            = (string)reader["Make"],
                            FNumber         = (decimal)reader["FNumber"],
                            ExposureTime    = (decimal)reader["ExposureTime"],
                            ISOValue        = (decimal)reader["ISOValue"],
                            Flash           = (bool)reader["Flash"],
                            ExposureProgram = (ExposurePrograms)reader["ExposureProgram"]
                        },
                        IPTC = new IPTCModel()
                        {
                            Keywords        = (string)reader["Keywords"],
                            ByLine          = (string)reader["ByLine"],
                            Caption         = (string)reader["Caption"],
                            CopyrightNotice = (string)reader["CopyrightNotice"],
                            Headline        = (string)reader["Headline"],
                        }
                    });
                }
            }

            Disconnect();

            return(list);
        }
Exemple #11
0
        public void bl_should_extract_fake_IPTC_Info_from_existing_picture()
        {
            EnsureTestImages();

            IBusinessLayer bl = ueb.GetBusinessLayer();

            AssertNotNull("GetBusinessLayer", bl);

            IIPTCModel iptc = bl.ExtractIPTC("Img1.jpg");

            AssertNotNull("ExtractIPTC", iptc);
            AssertNotEmptyOrNull(iptc.ByLine);
            AssertNotEmptyOrNull(iptc.Caption);
            AssertNotEmptyOrNull(iptc.CopyrightNotice);
            AssertNotEmptyOrNull(iptc.Headline);
            AssertNotEmptyOrNull(iptc.Keywords);
        }
Exemple #12
0
        public void IPTCViewModel_should_reflect_Model()
        {
            IIPTCModel mdl = ueb.GetEmptyIPTCModel();

            AssertNotNull("GetEmptyIPTCModel", mdl);

            mdl.ByLine          = "me";
            mdl.Caption         = "Very cool!";
            mdl.CopyrightNotice = "all rights reverved";
            mdl.Headline        = "Cool!";
            mdl.Keywords        = "cool, nice, great";

            IIPTCViewModel vmdl = ueb.GetIPTCViewModel(mdl);

            AssertNotNull("GetIPTCViewModel", vmdl);
            AssertEquals("me", vmdl.ByLine);
            AssertEquals("Very cool!", vmdl.Caption);
            AssertEquals("all rights reverved", vmdl.CopyrightNotice);
            AssertEquals("Cool!", vmdl.Headline);
            AssertEquals("cool, nice, great", vmdl.Keywords);
        }
Exemple #13
0
        // ReSharper disable once InconsistentNaming
        public static void WriteIPTC(string filename, IIPTCModel iptc)
        {
            Console.WriteLine($"{iptc.ByLine} {iptc.Caption} {iptc.CopyrightNotice} {iptc.Headline} {iptc.Keywords}");

            string filePath = Path.Combine(Constants.PicPath, filename);

            using (Stream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                JpegBitmapDecoder decoder = new JpegBitmapDecoder(fs, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                BitmapFrame       frame   = decoder.Frames[0];
                var metadata = frame.Metadata.Clone() as BitmapMetadata;
                InPlaceBitmapMetadataWriter jpgInPlace = frame.CreateInPlaceBitmapMetadataWriter();
                if (jpgInPlace != null)
                {
                    jpgInPlace.SetQuery(@"/app13/irb/8bimiptc/iptc/caption", iptc.Caption);
                    jpgInPlace.SetQuery(@"/app13/irb/8bimiptc/iptc/keywords", iptc.Keywords);
                    jpgInPlace.SetQuery(@"/app13/irb/8bimiptc/iptc/by-line", iptc.ByLine);
                    jpgInPlace.SetQuery(@"/app13/irb/8bimiptc/iptc/copyright notice", iptc.CopyrightNotice);
                    jpgInPlace.SetQuery(@"/app13/irb/8bimiptc/iptc/headline", iptc.Headline);
                }
                fs.Close();
            }
        }
Exemple #14
0
        public virtual IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts, IIPTCModel iptcParts, IEXIFModel exifParts)
        {
            var output = "Search Pictures";

            Console.WriteLine(output);

            var pictures = new List <IPictureModel>();

            try
            {
                PS.GetSearchPictures.Parameters["@namePart"].Value = (object)namePart ?? DBNull.Value;

                // Photographer
                if (photographerParts?.ID == 0 || photographerParts?.ID == null)
                {
                    PS.GetSearchPictures.Parameters["@PG_PG_ID"].Value = DBNull.Value;
                }
                else
                {
                    PS.GetSearchPictures.Parameters["@PG_PG_ID"].Value = (object)photographerParts.ID;
                }
                PS.GetSearchPictures.Parameters["@PG_Birthday"].Value  = (object)photographerParts?.BirthDay ?? DBNull.Value;
                PS.GetSearchPictures.Parameters["@PG_FirstName"].Value = (object)photographerParts?.FirstName ?? DBNull.Value;
                PS.GetSearchPictures.Parameters["@PG_LastName"].Value  = (object)photographerParts?.LastName ?? DBNull.Value;
                PS.GetSearchPictures.Parameters["@PG_Notes"].Value     = (object)photographerParts?.Notes ?? DBNull.Value;

                // IPTC
                if (iptcParts?.Keywords == "" || iptcParts?.Keywords == null)
                {
                    PS.GetSearchPictures.Parameters["@IPTC_Keywords"].Value = DBNull.Value;
                }
                else
                {
                    PS.GetSearchPictures.Parameters["@IPTC_Keywords"].Value = iptcParts.Keywords;
                }

                if (iptcParts?.ByLine == "" || iptcParts?.ByLine == null)
                {
                    PS.GetSearchPictures.Parameters["@IPTC_ByLine"].Value = DBNull.Value;
                }
                else
                {
                    PS.GetSearchPictures.Parameters["@IPTC_ByLine"].Value = iptcParts.ByLine;
                }

                if (iptcParts?.CopyrightNotice == "" || iptcParts?.CopyrightNotice == null)
                {
                    PS.GetSearchPictures.Parameters["@IPTC_CopyrightNotice"].Value = DBNull.Value;
                }
                else
                {
                    PS.GetSearchPictures.Parameters["@IPTC_CopyrightNotice"].Value = iptcParts.CopyrightNotice;
                }

                if (iptcParts?.Headline == "" || iptcParts?.Headline == null)
                {
                    PS.GetSearchPictures.Parameters["@IPTC_Headline"].Value = DBNull.Value;
                }
                else
                {
                    PS.GetSearchPictures.Parameters["@IPTC_Headline"].Value = iptcParts.Headline;
                }

                if (iptcParts?.Caption == "" || iptcParts?.Caption == null)
                {
                    PS.GetSearchPictures.Parameters["@IPTC_Caption"].Value = DBNull.Value;
                }
                else
                {
                    PS.GetSearchPictures.Parameters["@IPTC_Caption"].Value = iptcParts.Caption;
                }

                /*PS.GetSearchPictures.Parameters["@IPTC_Keywords"].Value = (object)iptcParts?.Keywords ?? DBNull.Value;
                 * PS.GetSearchPictures.Parameters["@IPTC_ByLine"].Value = (object)iptcParts?.ByLine ?? DBNull.Value;
                 * PS.GetSearchPictures.Parameters["@IPTC_CopyrightNotice"].Value = (object)iptcParts?.CopyrightNotice ?? DBNull.Value;
                 * PS.GetSearchPictures.Parameters["@IPTC_Headline"].Value = (object)iptcParts?.Headline ?? DBNull.Value;
                 * PS.GetSearchPictures.Parameters["@IPTC_Caption"].Value = (object)iptcParts?.Caption ?? DBNull.Value;*/

                // EXIF
                PS.GetSearchPictures.Parameters["@EXIF_Make"].Value = (object)exifParts?.Make ?? DBNull.Value;
                //TODO cant search for value 0 because of interface, what to do?
                PS.GetSearchPictures.Parameters["@EXIF_FNumber"].Value =
                    exifParts?.FNumber == 0 || exifParts?.FNumber == null
                        ? DBNull.Value
                        : (object)exifParts.FNumber; //(object)exifParts?.FNumber ?? DBNull.Value;
                PS.GetSearchPictures.Parameters["@EXIF_ExposureTime"].Value =
                    exifParts?.ExposureTime == 0 || exifParts?.ExposureTime == null
                        ? DBNull.Value
                        : (object)exifParts.ExposureTime; //(object)exifParts?.ExposureTime ?? DBNull.Value;
                PS.GetSearchPictures.Parameters["@EXIF_ISOValue"].Value =
                    exifParts?.ISOValue == 0 || exifParts?.ISOValue == null
                        ? DBNull.Value
                        : (object)exifParts.ISOValue; //(object)exifParts?.ISOValue ?? DBNull.Value;
                PS.GetSearchPictures.Parameters["@EXIF_Flash"].Value           = (object)exifParts?.Flash ?? DBNull.Value;
                PS.GetSearchPictures.Parameters["@EXIF_ExposureProgram"].Value = (object)exifParts?.ExposureProgram ?? DBNull.Value;

                Conn.Open();
                using (var reader = PS.GetSearchPictures.ExecuteReader())
                {
                    Console.WriteLine("FieldCount" + reader.FieldCount);
                    while (reader.Read())
                    {
                        pictures.Add(DTOParser.ParsePictureModel(RecordToDictionary(reader)));
                    }
                }
                Conn.Close();
                return(pictures);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw new Exception(output, e);
            }
            finally
            {
                Conn.Close();
            }
        }
Exemple #15
0
 public void WriteIPTC(string filename, IIPTCModel iptc)
 {
     _dal.Save(filename, iptc);
 }
Exemple #16
0
        /// <summary>
        /// Returns a filterd list of Pictures from the directory, based on a database query.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts, IIPTCModel iptcParts,
                                                       IEXIFModel exifParts)
        {
            var queryString =
                $"Select ID, FileName, fk_IPTC, fk_EXIF, fk_Camera, fk_Photographer from PictureModel";
            var liste = new List <IPictureModel>();

            using (var connection = new SqlConnection(ConnectionString))
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = queryString;

                    connection.Open();

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var model = new PictureModel();
                            int.TryParse(reader["ID"].ToString(), out var tempInt);
                            model.ID           = tempInt;
                            model.FileName     = reader["FileName"].ToString();
                            model.IPTC         = new IPTCModel();
                            model.EXIF         = new EXIFModel();
                            model.Camera       = reader["fk_Camera"] == DBNull.Value ? null : new CameraModel();
                            model.Photographer = reader["fk_Photographer"] == DBNull.Value ? null : new PhotographerModel();
                            liste.Add(model);
                        }
                    }
                }
            return(liste);
        }
Exemple #17
0
        public IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts, IIPTCModel iptcParts, IEXIFModel exifParts)
        {
            if (namePart != null && namePart != string.Empty)
            {
                List <IPictureModel> filteredPictures = new List <IPictureModel>();

                foreach (KeyValuePair <int, IPictureModel> item in pictures)
                {
                    if (item.Value.FileName.ToLower().Contains(namePart))
                    {
                        filteredPictures.Add(item.Value);
                    }
                }
                return(filteredPictures);
            }

            return(new List <IPictureModel>(pictures.Values));
        }
Exemple #18
0
 public override IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts, IIPTCModel iptcParts,
                                                         IEXIFModel exifParts)
 {
     if (namePart == "blume")
     {
         return new List <IPictureModel>()
                {
                    new PictureModel()
                }
     }
     ;
     return(_mockPictureModelList);
 }
Exemple #19
0
 public void WriteIPTC(string filename, IIPTCModel iptc)
 {
     throw new NotImplementedException();
 }
Exemple #20
0
        public void Hello_Empty_IPTCModel()
        {
            IIPTCModel obj = ueb.GetEmptyIPTCModel();

            AssertNotNull("GetEmptyIPTCModel", obj);
        }
 public IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts, IIPTCModel iptcParts, IEXIFModel exifParts)
 {
     throw new NotImplementedException();
 }
Exemple #22
0
 public IIPTCViewModel GetIPTCViewModel(IIPTCModel mdl)
 {
     return(new IPTCViewModel((IPTCModel)mdl));
 }
Exemple #23
0
 public IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts, IIPTCModel iptcParts, IEXIFModel exifParts)
 {
     try
     {
         return(_dal.GetPictures(namePart, photographerParts, iptcParts, exifParts));
     }
     catch (Exception e)
     {
         log.Error(e);
         Console.WriteLine(e);
         throw;
     }
 }
Exemple #24
0
        public IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts, IIPTCModel iptcParts, IEXIFModel exifParts)
        {
            if (pictureTable.Count == 0)
            {
                PictureModel newPicture0;

                if (string.IsNullOrWhiteSpace(namePart))
                {
                    newPicture0 = new PictureModel("");
                }
                else
                {
                    newPicture0 = new PictureModel(namePart);
                }


                newPicture0.ID = 1;


                pictureTable.Add(newPicture0);
            }


            return(pictureTable);
        }
 /// <summary>
 /// Writes IPTC information back to a picture. NOTE: You may simulate the action.
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="iptc"></param>
 public void WriteIPTC(string filename, IIPTCModel iptc)
 {
 }
        public IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts, IIPTCModel iptcParts, IEXIFModel exifParts)
        {
            //    DataTable pictures = new DataTable();

            //    cnn.Open();
            //    SqlCommand getPicture = new SqlCommand("Select * From Pictures Where id = @id", cnn);
            //    getPicture.Parameters.Add(new SqlParameter("@id", ID));
            //    SqlDataAdapter phapher = new SqlDataAdapter(getPicture);
            //    phapher.Fill(pictures);
            //    cnn.Close();

            //    IPictureModel picture = new PictureModel();

            //    var row = pictures.Rows[0];
            //    picture.ID = Int32.Parse(row[0].ToString());
            //    picture.FileName = row[1].ToString();

            //    return picture;
            throw new NotImplementedException();
        }
 //TODO Search for names
 //TODO Search for photographers
 //TODO Search for IPTC
 //TODO Search for EXIF
 /// <summary>
 /// Returns a filterd list of Pictures from the directory, based on a database query.
 /// </summary>
 /// <returns></returns>
 public IEnumerable <IPictureModel> GetPictures(string namePart, IPhotographerModel photographerParts,
                                                IIPTCModel iptcParts, IEXIFModel exifParts)
 {
     return(Dal.GetPictures(namePart, photographerParts, iptcParts, exifParts));
 }
Exemple #28
0
 public IPTCModel(IIPTCModel mdl)
 {
     this.mdl = mdl;
 }
Exemple #29
0
 public IPTCViewModel(IIPTCModel im)
 {
     _IPTCModel = im;
 }
Exemple #30
0
        public IIPTCViewModel GetIPTCViewModel(IIPTCModel mdl)
        {
            IIPTCViewModel iptcvm = new IPTCViewModel(mdl);

            return(iptcvm);
        }