-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
executable file
·156 lines (153 loc) · 8.15 KB
/
Program.cs
File metadata and controls
executable file
·156 lines (153 loc) · 8.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Drawing;
using ImageDraw = System.Drawing.Image;
using System.Threading;
using ImageVerifier.MVAProxy;
using System.Net;
using ImageVerifier.ImageManagement;
using System.Web;
using System.Collections;
namespace ImageVerifier
{
class Program
{
/// <summary>
/// Main entry point for ImageVerifier application
/// </summary>
/// <param name="args">Represents path to tab delimited file or a single ImageID GUID</param>
/// **TBD** Needs to be refactored to several classes. Option to compare images for a single imageId
///
static void Main(string[] args)
{
List<string> imageIDs = new List<string>();
string line = null;
//using (StreamReader file = new StreamReader(@"C:\Users\V-saeld\Desktop\Image\ImageID.txt"))
using (StreamReader file = new StreamReader(@"..\..\999.txt"))
{
while ((line = file.ReadLine()) != null)
{
char[] delimiters = new char[] { '\t' };
string[] parts = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < parts.Length; i++)
{
imageIDs.Add(parts[i]);
}
}
file.Close();
}
string results = @"C:\Users\v-saeld\Desktop\results.log";
using (StreamWriter logWriter = new StreamWriter(results))
{
foreach (string imageID in imageIDs)
{
logWriter.WriteLine("ImageID: {0}", imageID);
Console.WriteLine("ImageID: {0}", imageID);
CatalogServices cs = Constants.Proxy;
ImageSearchRequest imageSearchRequest = new ImageSearchRequest();
List<ImageVerifier.ImInstDisplay> list = new List<ImageVerifier.ImInstDisplay>();
Dictionary<Guid, string> dictUrl = new Dictionary<Guid, string>();
ImageVerifier.MVAProxy.Image image = null;
ImageVerifier.ImInstDisplay im = new ImageVerifier.ImInstDisplay();
im.ImageID = new Guid(imageID);
image = cs.GetImage(im.ImageID);
int OriginalImageSizeID = 0;
int ThumbnailImageSizeID = 4;
List<ImageVerifier.MVAProxy.ImageSize> imageSizes = ImageVerifier.MVAProxy.ImageSize.Get();
ImageVerifier.ImInstDisplay imInstDisplay = new ImageVerifier.ImInstDisplay();
int originalImageFileWidth = 0, originalImageFileHeight = 0, originalImageFileSize = 0;
string originalImageFileExtension = string.Empty;
bool originalFileAvailable = false;
bool originalFileinSanAvailable = true;
foreach (ImageInstance iminst in image.Instances)
{
if (iminst.ImageSizeId == OriginalImageSizeID)
{
im.OriginalFileGuid = iminst.Id;
ImageFileHandler.GetImageFileProperty(iminst.Id, out originalImageFileWidth, out originalImageFileHeight, out originalImageFileSize, out originalImageFileExtension);
if (originalImageFileWidth == 0 && originalImageFileHeight == 0 && originalImageFileSize == 0)
{
Console.WriteLine("ImageID: {0} - There is no image in San folder-{1}.", imageID, originalImageFileExtension);
logWriter.WriteLine("ImageID: {0} - There is no image in San folder-{1}.", imageID, originalImageFileExtension);
originalFileinSanAvailable = false;
break;
}
else
{
originalFileAvailable = true;
continue;
}
}
else if (iminst.ImageSizeId == ThumbnailImageSizeID)
{
continue;
}
else
{
imInstDisplay.LiveURL = iminst.FileUrl;
dictUrl.Add(iminst.Id, imInstDisplay.LiveURL.ToString());
}
}
Hashtable propImageList = new Hashtable();
foreach (ImageInstance iminst in image.Instances)
{
if (!originalFileinSanAvailable)
{ break; }
string sourceImageFileExtension = string.Empty;
int sourceImageFileWidth = 0, sourceImageFileHeight = 0, sourceImageFileSize = 0;
int thumbNailImageSizeID = 4;
if (!originalFileAvailable)
{
logWriter.WriteLine("ImageID: {0}-There is no original image.", imageID);
Console.WriteLine("ImageID: {0}-There is no original image.", imageID);
break;
}
ImageFileHandler.GetImageFileProperty(iminst.Id, out sourceImageFileWidth, out sourceImageFileHeight, out sourceImageFileSize, out sourceImageFileExtension);
if (iminst.ImageSizeId == OriginalImageSizeID || iminst.ImageSizeId == thumbNailImageSizeID)
{ continue; }
ImageSize imSize1 = new ImageSize();
imSize1.Id = iminst.ImageSizeId;
imSize1.Width = sourceImageFileWidth;
imSize1.Height = sourceImageFileHeight;
propImageList.Add(iminst.Id, imSize1);
}
if (originalFileAvailable && originalFileinSanAvailable)
{
Dictionary<Guid, System.Drawing.Image> dictDestImages = ImageFileHandler.PropImage(image, propImageList, im.OriginalFileGuid);
Dictionary<Guid, System.Drawing.Image> dictImages = new Dictionary<Guid, System.Drawing.Image>();
foreach (var pair in dictUrl)
{
System.Drawing.Image ima = ImageUtil.DownloadImage(pair.Value);
dictImages.Add(pair.Key, ima);
}
foreach (KeyValuePair<Guid, System.Drawing.Image> Origkvp in dictImages)
{
foreach (KeyValuePair<Guid, System.Drawing.Image> kvp in dictDestImages)
{
if (Origkvp.Key == kvp.Key)
{
bool IsImageSame = ImageUtil.DiffImages(kvp.Value, Origkvp.Value);
if (!IsImageSame)
{
logWriter.WriteLine("InstanceID: {0} Different image.", kvp.Key);
Console.WriteLine("InstanceID: {0} Different image.", kvp.Key);
}
else
{
logWriter.WriteLine("InstanceID: {0} Same image.", kvp.Key);
Console.WriteLine("InstanceID: {0} Same image.", kvp.Key);
}
}
}
}
}
}
Console.ReadLine();
}
}
}
}