Ejemplo n.º 1
0
        private static DataTable LoadJson <T>(String actionName, PreingestActionModel jsonDataFile)
        {
            string[] messages = jsonDataFile.Properties.Messages == null ? new string[] { } : jsonDataFile.Properties.Messages;
            T[]      data     = jsonDataFile.ActionData == null ? new T[] { } : JsonConvert.DeserializeObject <T[]>(jsonDataFile.ActionData.ToString());

            DataTable table = new DataTable(actionName);
            Type      type  = typeof(T);
            var       names = type.GetProperties().Select(item => new DataColumn {
                ColumnName = item.Name, DataType = typeof(String)
            }).ToArray();

            table.Columns.AddRange(names);

            if (data.Count() == 0)
            {
                DataRow row = table.NewRow();
                row["Resultaat"] = "Geen bijzonderheden gevonden!";
                table.Rows.Add(row);
            }
            else
            {
                FillData <T>(data, table);
            }
            return(table);
        }
Ejemplo n.º 2
0
        public SettingsReader(String dataFolder, Guid guid, String filename = "SettingsHandler.json")
        {
            String jsonFile = Path.Combine(dataFolder, guid.ToString(), filename);

            if (File.Exists(jsonFile))
            {
                string jsonContent = File.ReadAllText(jsonFile);
                _model = JsonConvert.DeserializeObject <PreingestActionModel>(jsonContent);
            }
        }
Ejemplo n.º 3
0
        private static DataTable LoadJson(String actionName, PreingestActionModel jsonDataFile, bool isArrayActionDataType = false, bool newLineSplit = false)
        {
            string[] messages = jsonDataFile.Properties.Messages == null ? new string[] { } : jsonDataFile.Properties.Messages;

            Newtonsoft.Json.Linq.JArray data = Newtonsoft.Json.Linq.JArray.Parse(jsonDataFile.ActionData.ToString());
            DataTable table = new DataTable(actionName);

            table.Columns.Add("Resultaat", typeof(String));

            if (data.Count == 0)
            {
                DataRow row = table.NewRow();
                row["Resultaat"] = "Geen bijzonderheden gevonden!";
                table.Rows.Add(row);
            }

            foreach (var rowContent in data)
            {
                DataRow row  = table.NewRow();
                string  text = string.Empty;

                if (isArrayActionDataType)
                {
                    text = String.Join(Environment.NewLine, rowContent.ToObject <string[]>());
                }
                else
                {
                    text = rowContent.ToObject <string>();
                }

                if (newLineSplit)
                {
                    text = String.Join(Environment.NewLine, text.Split(@"\r", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries));
                }

                row["Resultaat"] = text.Trim();
                table.Rows.Add(row);
            }

            return(table);
        }
Ejemplo n.º 4
0
        private static DataTable LoadSummary(DirectoryInfo targetFolder, List <String> actions, QueryResultAction[] actionArray)
        {
            DataTable table = new DataTable("Summary");

            Type columnNamesResult  = typeof(PreingestResult);
            Type columnNamesSummary = typeof(PreingestStatisticsSummary);
            Type columnNamesProps   = typeof(PreingestProperties);

            table.Columns.AddRange(columnNamesResult.GetProperties().Select(item
                                                                            => new DataColumn(item.Name, typeof(String))).ToArray());
            table.Columns.AddRange(columnNamesProps.GetProperties().Select(item
                                                                           => new DataColumn(item.Name, typeof(String))).ToArray());
            table.Columns.AddRange(columnNamesSummary.GetProperties().Select(item
                                                                             => new DataColumn(item.Name, typeof(String))).ToArray());

            foreach (string actionName in actions)
            {
                var  action  = actionArray.Where(action => action.Name == actionName).LastOrDefault();
                bool hasJson = (action.ResultFiles.LastOrDefault(item => item.EndsWith(".json")) == null);
                ValidationActionType switchResult = (ValidationActionType)Enum.Parse(typeof(ValidationActionType), action.Name);

                if (switchResult == (ValidationActionType.ProfilesHandler | ValidationActionType.ReportingDroidXmlHandler | ValidationActionType.ReportingPdfHandler | ValidationActionType.ReportingPlanetsXmlHandler))
                {
                    continue;
                }
                if (hasJson)
                {
                    continue;
                }

                string jsonFilename = Path.Combine(targetFolder.FullName, action.ResultFiles.LastOrDefault(item => item.EndsWith(".json")));
                string jsonContent  = File.ReadAllText(jsonFilename);

                PreingestActionModel jsonDataFile = JsonConvert.DeserializeObject <PreingestActionModel>(jsonContent);

                var summary = jsonDataFile.Summary;
                var result  = jsonDataFile.ActionResult;
                var props   = jsonDataFile.Properties;

                DataRow row = table.NewRow();

                var resultDataResult = result.GetType().GetProperties().Select(item => new
                {
                    Name      = item.Name,
                    PropValue = item.GetValue(result) == null ? String.Empty : item.GetValue(result).ToString()
                }).ToList();
                resultDataResult.ForEach(item => row[item.Name] = item.PropValue);

                var resultDataProps = props.GetType().GetProperties().Select(item => new
                {
                    Name      = item.Name,
                    PropValue = item.Name.Equals("Messages", StringComparison.InvariantCultureIgnoreCase) ? item.GetValue(props) == null ? String.Empty : String.Join(Environment.NewLine, (item.GetValue(props) as string[])) : item.GetValue(props) == null ? String.Empty : item.GetValue(props).ToString()
                }).ToList();
                resultDataProps.ForEach(item => row[item.Name] = item.PropValue);

                var resultDataSummary = summary.GetType().GetProperties().Select(item => new
                {
                    Name      = item.Name,
                    PropValue = item.GetValue(summary).ToString()
                }).ToList();
                resultDataSummary.ForEach(item => row[item.Name] = item.PropValue);

                table.Rows.Add(row);
            }
            return(table);
        }
Ejemplo n.º 5
0
        public static FileInfo BuildExcel(DirectoryInfo targetFolder, QueryResultAction[] actionArray)
        {
            Dictionary <String, DataTable> content = new Dictionary <string, DataTable>();

            var  distinctActionNames = actionArray.Select(item => item.Name).Distinct().ToList();
            bool alreadyAnExcel      = (distinctActionNames.Contains(ValidationActionType.IndexMetadataHandler.ToString()));

            //create new excel or use existing and make a copy
            FileInfo indexingMetadataExcelFile     = null;
            string   indexingMetadataExcelFilename = Path.Combine(targetFolder.FullName, String.Concat(ValidationActionType.IndexMetadataHandler.ToString(), ".xlsx"));
            bool     exists = File.Exists(indexingMetadataExcelFilename) && distinctActionNames.Contains(ValidationActionType.IndexMetadataHandler.ToString());

            if (exists)
            {
                indexingMetadataExcelFile = new FileInfo(indexingMetadataExcelFilename);
            }

            int i = 1;

            DataTable summaryTable = LoadSummary(targetFolder, distinctActionNames, actionArray);

            content.Add(String.Format("P{0} - Overzicht", i.ToString("D2")), summaryTable);

            distinctActionNames.ForEach(item =>
            {
                var action = actionArray.Where(action => action.Name == item).LastOrDefault();

                bool hasJson = (action.ResultFiles.LastOrDefault(item => item.EndsWith(".json")) == null);

                ValidationActionType switchResult = (ValidationActionType)Enum.Parse(typeof(ValidationActionType), action.Name);

                if (switchResult == (ValidationActionType.ProfilesHandler | ValidationActionType.ReportingDroidXmlHandler | ValidationActionType.ReportingPdfHandler | ValidationActionType.ReportingPlanetsXmlHandler))
                {
                    return;
                }
                if (hasJson)
                {
                    return;
                }

                string jsonFilename = Path.Combine(targetFolder.FullName, action.ResultFiles.LastOrDefault(item => item.EndsWith(".json")));
                string jsonContent  = File.ReadAllText(jsonFilename);

                PreingestActionModel jsonDataFile = JsonConvert.DeserializeObject <PreingestActionModel>(jsonContent);

                switch (switchResult)
                {
                case ValidationActionType.ContainerChecksumHandler:
                case ValidationActionType.SettingsHandler:
                case ValidationActionType.IndexMetadataHandler:
                    {
                        if (ValidationActionType.SettingsHandler == switchResult)
                        {
                        }
                        if (ValidationActionType.ContainerChecksumHandler == switchResult)
                        {
                        }
                        if (ValidationActionType.IndexMetadataHandler == switchResult)
                        {
                        }
                    }
                    break;

                case ValidationActionType.UnpackTarHandler:
                    {
                        DataTable table = LoadJson(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Uitpakken", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.ScanVirusValidationHandler:
                    {
                        DataTable table = LoadJson <VirusScanItem>(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Virus scan", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.PrewashHandler:
                    {
                        DataTable table = LoadJson <WashedItem>(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Voorbewerkingen", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.NamingValidationHandler:
                    {
                        DataTable table = LoadJson <NamingItem>(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Tekens & karakters", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.SidecarValidationHandler:
                    {
                        DataTable table = LoadJson(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Structuur", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.GreenListHandler:
                    {
                        DataTable table = LoadJson <DataItem>(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Voorkeursbestanden", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.EncodingHandler:
                    {
                        DataTable table = LoadJson <EncodingItem>(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Coderingen", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.MetadataValidationHandler:
                    {
                        DataTable table = LoadJson <MetadataValidationItem>(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Validaties", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.FilesChecksumHandler:
                    {
                        DataTable table = LoadJson(action.Name, jsonDataFile, true, false);
                        content.Add(String.Format("P{0} - Controle getallen", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.BuildOpexHandler:
                    {
                        DataTable table = LoadJson(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - OPEX construeren", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.PolishHandler:
                    {
                        DataTable table = LoadJson(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - OPEX bijwerken", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.ClearBucketHandler:
                    {
                        DataTable table = LoadJson(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Opschonen (bucket)", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.ShowBucketHandler:
                    {
                        DataTable table = LoadJson(action.Name, jsonDataFile);
                        content.Add(String.Format("P{0} - Raadplegen (bucket)", i.ToString("D2")), table);
                    }
                    break;

                case ValidationActionType.UploadBucketHandler:
                    {
                        DataTable table = LoadJson(action.Name, jsonDataFile, false, true);
                        content.Add(String.Format("P{0} - Upload (bucket)", i.ToString("D2")), table);
                    }
                    break;

                default:
                    { }
                    break;
                }
                i++;
            });

            FileInfo tmpResultFile = ExportToExcel(content, indexingMetadataExcelFile);

            string outputFilename = Path.Combine(targetFolder.FullName, String.Concat(ValidationActionType.ExcelCreatorHandler.ToString(), ".xlsx"));

            tmpResultFile.MoveTo(outputFilename, true);

            return(new FileInfo(outputFilename));
        }