/// <summary>
 /// Create a new TAA_MicrositeLogos object.
 /// </summary>
 /// <param name="logoID">Initial value of the LogoID property.</param>
 /// <param name="micrositeID">Initial value of the MicrositeID property.</param>
 /// <param name="createdOnDate">Initial value of the CreatedOnDate property.</param>
 /// <param name="deleted">Initial value of the Deleted property.</param>
 public static TAA_MicrositeLogos CreateTAA_MicrositeLogos(global::System.Int32 logoID, global::System.Int32 micrositeID, global::System.DateTime createdOnDate, global::System.Boolean deleted)
 {
     TAA_MicrositeLogos tAA_MicrositeLogos = new TAA_MicrositeLogos();
     tAA_MicrositeLogos.LogoID = logoID;
     tAA_MicrositeLogos.MicrositeID = micrositeID;
     tAA_MicrositeLogos.CreatedOnDate = createdOnDate;
     tAA_MicrositeLogos.Deleted = deleted;
     return tAA_MicrositeLogos;
 }
Пример #2
0
        private static void SaveLogo(string sceneServerImage, TAA_Microsite taamicrosite, string logRootPath)
        {
            try
            {
                var newguid = Guid.NewGuid(); // Microsite is not created so make sure Image filenames are unique
                var fileName = Path.GetFileName(sceneServerImage);

                var newPath = Path.Combine(logRootPath, taamicrosite.MicrositeID.ToString());
                if (!Directory.Exists(newPath))
                    Directory.CreateDirectory(newPath);
                var webClient = new WebClient();
                var filepath = string.Format("{0}/{1}~!~{2}", newPath, newguid.ToString(), fileName);
                webClient.DownloadFile(sceneServerImage, filepath);
                var image = Image.FromFile(filepath);
                var header = ImageManipulation.ResizeImage(image, new Size(310, 60)); // site header
                var thumb = ImageManipulation.ResizeImage(image, new Size(82, 64));
                // thumb for microsite search results

                // using ~!~ as delimiter so later we can extract the original filename
                header.Save(newPath + "/header.jpg"); // Microsite Header
                thumb.Save(newPath + "/thumb.jpg"); // Thumbnail used in Search results

                image.Dispose();
                header.Dispose();
                thumb.Dispose();
                if (entity.TAA_MicrositeLogos.Any(p => p.MicrositeID == taamicrosite.MicrositeID))
                    return;
                TAA_MicrositeLogos logo = new TAA_MicrositeLogos();
                logo.CreatedByUserID = -1;
                logo.CreatedOnDate = taamicrosite.CreatedOnDate;
                logo.Logo = fileName;
                logo.LogoName = Path.GetFileNameWithoutExtension(fileName);
                logo.MicrositeID = taamicrosite.MicrositeID;
                logo.Deleted = false;
                entity.TAA_MicrositeLogos.AddObject(logo);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the TAA_MicrositeLogos EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTAA_MicrositeLogos(TAA_MicrositeLogos tAA_MicrositeLogos)
 {
     base.AddObject("TAA_MicrositeLogos", tAA_MicrositeLogos);
 }