Пример #1
0
        private static void ReadWebPartUsageCSV(string sourceWebPartType, string usageFilePath, out IEnumerable <WebpartInput> objWPDInput)
        {
            objWPDInput = null;
            objWPDInput = ImportCSV.ReadMatchingColumns <WebpartInput>(usageFilePath, Constants.CsvDelimeter);

            try
            {
                if (objWPDInput.Any())
                {
                    objWPDInput = from p in objWPDInput
                                  where p.WebPartType.Equals(sourceWebPartType, StringComparison.OrdinalIgnoreCase)
                                  select p;

                    if (objWPDInput.Any())
                    {
                        Logger.LogInfoMessage("Number of Webparts found with WebpartType '" + sourceWebPartType + "' are " + objWPDInput.Count());
                    }
                    else
                    {
                        Logger.LogInfoMessage("No Webparts found with WebpartType '" + sourceWebPartType + "'");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage("[DeleteMissingWebparts: ReadWebPartUsageCSV]. Exception Message: " + ex.Message
                                       + ", Exception Comments: Exception occured while rading input file ", true);
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "Webpart", ex.Message,
                                            ex.ToString(), "ReadWebPartUsageCSV", ex.GetType().ToString(), "Exception occured while rading input file");
            }
        }
Пример #2
0
        private static void ReadWebPartUsageCSV(string sourceWebPartType, string usageFilePath, string outPutFolder, out IEnumerable <WebPartDiscoveryInput> objWPDInput)
        {
            string exceptionCommentsInfo1 = string.Empty;

            Logger.LogInfoMessage("[ReadWebPartUsageCSV] [START] Calling function ImportCsv.ReadMatchingColumns<WebPartDiscoveryInput>");

            objWPDInput = null;
            objWPDInput = ImportCSV.ReadMatchingColumns <WebPartDiscoveryInput>(usageFilePath, Constants.CsvDelimeter);

            Logger.LogInfoMessage("[ReadWebPartUsageCSV] [END] Read all the WebParts Usage Details from Discovery Usage File and saved in List - out IEnumerable<WebPartDiscoveryInput> objWPDInput, for processing.");

            try
            {
                if (objWPDInput.Any())
                {
                    Logger.LogInfoMessage("[START] ReadWebPartUsageCSV - After Loading InputCSV ");

                    objWPDInput = from p in objWPDInput
                                  where p.WebPartType.ToLower() == sourceWebPartType.ToLower()
                                  select p;
                    exceptionCommentsInfo1 = objWPDInput.ToString();

                    Logger.LogInfoMessage("[END] ReadWebPartUsageCSV - After Loading InputCSV");
                }
            }
            catch (Exception ex)
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage("[ReadWebPartUsageCSV] Exception Message: " + ex.Message + ", Exception Comments:" + exceptionCommentsInfo1);
                System.Console.ResetColor();
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "ReplaceWebPart", ex.Message, ex.ToString(), "ReadWebPartUsageCSV()", ex.GetType().ToString(), exceptionCommentsInfo1);
            }
        }
Пример #3
0
        public static void DoWork()
        {
            Logger.OpenLog("DeleteMissingEventReceivers");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            string inputFileSpec = Environment.CurrentDirectory + "\\" + Constants.MissingEventReceiversInputFileName;
            //Read Input file
            IEnumerable <MissingEventReceiversInput> objInputMissingEventReceivers = ImportCSV.ReadMatchingColumns <MissingEventReceiversInput>(inputFileSpec, Constants.CsvDelimeter);

            if (objInputMissingEventReceivers != null)
            {
                try
                {
                    Logger.LogInfoMessage(String.Format("Preparing to delete a total of {0} event receivers ...", objInputMissingEventReceivers.Cast <Object>().Count()), true);

                    foreach (MissingEventReceiversInput MissingEventReceiver in objInputMissingEventReceivers)
                    {
                        DeleteMissingEventReceiver(MissingEventReceiver);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("DeleteMissingEventReceivers() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("There is nothing to delete from the '" + inputFileSpec + "' File ", true);
            }
            Logger.CloseLog();
        }
        public static void DoWork()
        {
            string timeStamp      = DateTime.Now.ToString("yyyyMMdd_hhmmss");
            string setupInputFile = string.Empty;

            Logger.OpenLog("DeleteSetupFiles", timeStamp);

            //if (!ShowInformation())
            //    return;

            if (!ReadInputFile(ref setupInputFile))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage("Setup Files input file is not valid or available. So, Operation aborted!");
                Logger.LogErrorMessage("Please enter path like: E.g. C:\\<Working Directory>\\<InputFile>.csv");
                System.Console.ResetColor();
                return;
            }

            string inputFileSpec = setupInputFile;

            if (System.IO.File.Exists(inputFileSpec))
            {
                Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
                IEnumerable <MissingSetupFilesInput> objInputMissingSetupFiles = ImportCSV.ReadMatchingColumns <MissingSetupFilesInput>(inputFileSpec, Constants.CsvDelimeter);
                if (objInputMissingSetupFiles != null && objInputMissingSetupFiles.Any())
                {
                    try
                    {
                        string csvFile = Environment.CurrentDirectory + @"\" + Constants.DeleteSetupFileStatus + timeStamp + Constants.CSVExtension;
                        if (System.IO.File.Exists(csvFile))
                        {
                            System.IO.File.Delete(csvFile);
                        }
                        Logger.LogInfoMessage(String.Format("Preparing to delete a total of {0} files ...", objInputMissingSetupFiles.Cast <Object>().Count()), true);

                        foreach (MissingSetupFilesInput missingFile in objInputMissingSetupFiles)
                        {
                            DeleteMissingFile(missingFile, csvFile);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogErrorMessage(String.Format("[DeleteSetupFiles: DoWork] failed: Error={0}", ex.Message), true);
                        ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SetupFile", ex.Message,
                                                    ex.ToString(), "DoWork", ex.GetType().ToString(), "Exception occured while reading input file");
                    }
                }
                else
                {
                    Logger.LogInfoMessage("There is nothing to delete from the '" + inputFileSpec + "' File ", true);
                }
                Logger.LogInfoMessage(String.Format("Scan Completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogErrorMessage(String.Format("[DeleteSetupFiles: DoWork]: Input file {0} is not available", inputFileSpec), true);
            }
            Logger.CloseLog();
        }
        public static void DoWork(string inputFileSpec)
        {
            Logger.OpenLog("CommentUDCXFileNodes");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
            Logger.LogInfoMessage(inputFileSpec, true);

            List <UdcxReportOutput> _WriteUDCList = null;

            Logger.LogInfoMessage(String.Format("AppSettings:"), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UseAppModel] = {0}", Program.UseAppModel), true);
            if (Program.UseAppModel == true)
            {
                Logger.LogInfoMessage(String.Format("- AppId = {0}", ConfigurationManager.AppSettings["ClientId"].ToString()), true);
            }
            else
            {
                string adminUsername = String.Format("{0}{1}", (String.IsNullOrEmpty(Program.AdminDomain) ? "" : String.Format("{0}\\", Program.AdminDomain)), Program.AdminUsername);
                Logger.LogInfoMessage(String.Format("- Admin Username = {0}", adminUsername), true);
            }

            IEnumerable <UdcxReportInput> udcxCSVRows = ImportCSV.ReadMatchingColumns <UdcxReportInput>(inputFileSpec, Constants.CsvDelimeter);

            if (udcxCSVRows != null)
            {
                try
                {
                    var authRows = udcxCSVRows.Where(x => x.Authentication != null && x.Authentication != Constants.ErrorStatus && x.Authentication.Length > 0);
                    if (authRows != null && authRows.Count() > 0)
                    {
                        _WriteUDCList = new List <UdcxReportOutput>();
                        Logger.LogInfoMessage(String.Format("Preparing to process a total of {0} Udcx Files ...", authRows.Count()), true);

                        foreach (UdcxReportInput udcxFileInput in authRows)
                        {
                            CommentUDCXFileNode(udcxFileInput, _WriteUDCList);
                        }

                        GenerateStatusReport(_WriteUDCList);
                    }
                    else
                    {
                        Logger.LogInfoMessage("No UDCX File records with authentication nodes found in '" + inputFileSpec + "' File ", true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("CommentUDCXFileNode() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("No UDCX File records found in '" + inputFileSpec + "' File ", true);
            }

            Logger.CloseLog();
        }
        public static void DoWork()
        {
            string timeStamp = DateTime.Now.ToString("yyyyMMdd_hhmmss");

            csvOutputFileSpec      = Environment.CurrentDirectory + "\\ResetDeviceChannelMappingFiles-" + timeStamp + Constants.CSVExtension;
            csvOutputFileHasHeader = System.IO.File.Exists(csvOutputFileSpec);

            Logger.OpenLog("ResetDeviceChannelMappingFiles", timeStamp);
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            string inputFileSpec = String.Empty;

            if (!ReadInputFile(ref inputFileSpec))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage(String.Format("Input file [{0}] does not exist.", inputFileSpec), true);
                Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                Logger.CloseLog();
                System.Console.ResetColor();
                return;
            }

            // The Locked Master Pages input file is essentially a filtered instance of the Missing Setup Files input file.
            IEnumerable <LockedMasterPageFilesInput> objInputLockedMasterPageFiles = ImportCSV.ReadMatchingColumns <LockedMasterPageFilesInput>(inputFileSpec, Constants.CsvDelimeter);

            if (objInputLockedMasterPageFiles == null || objInputLockedMasterPageFiles.Count() == 0)
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage(String.Format("Input file [{0}] is empty.", inputFileSpec), true);
                Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                Logger.CloseLog();
                System.Console.ResetColor();
                return;
            }

            Logger.LogInfoMessage(String.Format("Preparing to process a total of {0} master page files ...", objInputLockedMasterPageFiles.Count()), true);
            try
            {
                foreach (LockedMasterPageFilesInput masterPageFile in objInputLockedMasterPageFiles)
                {
                    ResetMappingFile(masterPageFile);
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage(String.Format("ResetDeviceChannelMappingFiles() failed: Error={0}", ex.Message), true);
                ExceptionCsv.WriteException(
                    Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable,
                    "MappingFile",
                    ex.Message, ex.ToString(), "DoWork", ex.GetType().ToString(),
                    "Exception occured while processing input file."
                    );
            }

            Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            Logger.CloseLog();
        }
Пример #7
0
        public void ImportWrongClassThrowsException()
        {
            //Arrange
            var import = new ImportCSV("SchoolTest.csv");

            //Act and Assert
            var ex = Assert.ThrowsException <ArgumentException>(() => import.getDataFromCSV <BlankClass>());

            Assert.AreEqual("Model name does not exist", ex.Message);
        }
Пример #8
0
        public void ImportSchoolResultData()
        {
            //Arrange
            var import = new ImportCSV("SchoolResultTest.csv");

            //Act
            var data = import.getDataFromCSV <SchoolResult>();

            //Assert
            Assert.AreEqual(_data["SchoolResultTest"].Count(), data.Count());
        }
Пример #9
0
        public void ImportSchoolDataExcludesFieldsNotInMap()
        {
            //Arrange
            var import = new ImportCSV("SchoolTestExtraFields.csv");

            //Act
            var data = import.getDataFromCSV <School>();

            //Assert
            Assert.AreEqual(_data["SchoolTestExtraFields"].Count(), data.Count());
        }
Пример #10
0
        public void ImportSchoolDataWithNullRecords()
        {
            //Arrange
            var import = new ImportCSV("SchoolTestNullRecords.csv");

            //Act
            var data = import.getDataFromCSV <School>();

            //Assert
            Assert.AreEqual(_data["SchoolTestNullRecords"].Count(), data.Count());
        }
Пример #11
0
        public void FileDoesNotExistException()
        {
            //Arrange
            var import = new ImportCSV("FileDoesNotExist.csv");


            //Act and Assert
            var ex = Assert.ThrowsException <FileNotFoundException>(() => import.getDataFromCSV <School>());

            Assert.AreEqual("CSV file does not exist", ex.Message);
        }
Пример #12
0
        public void ImportSchoolContextualDataIncludesNATData()
        {
            //Arrange
            var import = new ImportCSV("SchoolContextualTestNAT.csv");

            //Act
            var data = import.getDataFromCSV <SchoolContextual>();

            //Assert
            Assert.AreEqual(_data["SchoolContextualTestNAT"].Count(), data.Count());
        }
Пример #13
0
        public void ImportSchoolResultIgnoreRecordsWithAllNullResults()
        {
            //Arrange
            var import = new ImportCSV("SchoolResultTestAllNullRecords.csv");

            //Act
            var data = import.getDataFromCSV <SchoolResult>();

            //Assert
            Assert.AreEqual(_data["SchoolResultTestAllNullRecords"].Count() - 1, data.Count());
        }
Пример #14
0
        public void ImportSchoolDataIgnoreRowsWithTwoOrLessFields()
        {
            //Arrange
            var import = new ImportCSV("SchoolTestDifferentRowLength.csv");

            //Act
            var data = import.getDataFromCSV <School>();

            //Assert

            //Checks the data omits the 1 row that has only 2 fields
            Assert.AreEqual(_data["SchoolTestDifferentRowLength"].Count() - 1, data.Count());
        }
Пример #15
0
        private void OnImportCSVFileCommand(object obj)
        {
            CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg = false;

            var fileDialog = new Microsoft.Win32.OpenFileDialog();

            fileDialog.CheckFileExists = true;
            fileDialog.CheckPathExists = true;
            fileDialog.Filter          = "csv files|*.csv";

            var result = fileDialog.ShowDialog();

            if (result.HasValue && result.Value == true)
            {
                // attemp to import
                var fieldVM = new SelectCoordinateFieldsViewModel();

                var headers = ImportCSV.GetHeaders(File.OpenRead(fileDialog.FileName));
                foreach (var header in headers)
                {
                    fieldVM.AvailableFields.Add(header);
                    Console.WriteLine("header : {0}", header);
                }

                var dlg = new SelectCoordinateFieldsView();
                dlg.DataContext = fieldVM;
                if (dlg.ShowDialog() == true)
                {
                    var lists = ImportCSV.Import <ImportCoordinatesList>(File.OpenRead(fileDialog.FileName), fieldVM.SelectedFields.ToArray());

                    var coordinates = new List <string>();

                    foreach (var item in lists)
                    {
                        var sb = new StringBuilder();
                        sb.Append(item.lat.Trim());
                        if (fieldVM.UseTwoFields)
                        {
                            sb.Append(string.Format(" {0}", item.lon.Trim()));
                        }

                        coordinates.Add(sb.ToString());
                    }

                    Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.IMPORT_COORDINATES, coordinates);
                }
            }

            CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg = true;
        }
Пример #16
0
        public static void DoWork(string inputFileSpec)
        {
            Logger.OpenLog("PeoplePickerRemediation");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
            Logger.LogInfoMessage(inputFileSpec, true);
            List <PeoplePickerListOutput> _WriteUDCList = null;

            IEnumerable <PeoplePickerListsInput> pprCSVRows = ImportCSV.ReadMatchingColumns <PeoplePickerListsInput>(inputFileSpec, Constants.CsvDelimeter);

            if (pprCSVRows != null)
            {
                try
                {
                    var lists = pprCSVRows.Where(x => x.ListName != null && x.WebUrl != null);
                    if (lists != null && lists.Count() > 0)
                    {
                        _WriteUDCList = new List <PeoplePickerListOutput>();
                        Logger.LogInfoMessage(String.Format("Preparing to process a total of {0} PeoplePicker InfoPath Forms ...", lists.Count()), true);
                        PeoplePickerListOutput ps = new PeoplePickerListOutput();
                        foreach (PeoplePickerListsInput pprFileInput in lists)
                        {
                            ReadFormLibUsingAppOnlyAndCredentials(pprFileInput, ref _WriteUDCList);
                        }

                        if (_WriteUDCList != null && _WriteUDCList.Any())
                        {
                            GenerateStatusReport(_WriteUDCList);
                            _WriteUDCList = null;
                        }
                    }
                    else
                    {
                        Logger.LogInfoMessage("No valid authentication records found in '" + inputFileSpec + "' File ", true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("PeoplePickerRemediation:DoWork() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("No records found in '" + inputFileSpec + "' File ", true);
            }

            Logger.CloseLog();
        }
        private static void ProcessInputFile(string masterPageInputFile, bool replaceMasterUrl, bool replaceCustomMasterUrl, bool replaceBothMaserUrls, string outputDirectory)
        {
            DataTable dtMasterPagesInput = new DataTable();

            try
            {
                dtMasterPagesInput = ImportCSV.Read(masterPageInputFile, Constants.CsvDelimeter);

                List <string> lstWebUrls = dtMasterPagesInput.AsEnumerable()
                                           .Select(r => r.Field <string>("WebUrl"))
                                           .ToList();
                lstWebUrls = lstWebUrls.Distinct().ToList();
                foreach (string webUrl in lstWebUrls)
                {
                    string webApplicationUrl = string.Empty;
                    try
                    {
                        Logger.LogInfoMessage("[ReplaceMasterPage: ProcessInputFile] Processing the Site: " + webUrl, true);
                        if (ProcessWebUrl(webUrl, null, replaceMasterUrl, replaceCustomMasterUrl, replaceBothMaserUrls))
                        {
                            Logger.LogSuccessMessage("[ReplaceMasterPage:ProcessInputFile]successfully replaced master page for the site " + webUrl + "  and output file is present in the path: " + outputDirectory, true);
                        }
                        else
                        {
                            Logger.LogErrorMessage("[ReplaceMasterPage: ProcessInputFile] Replacing Custom Master Page with OOB Master Page is failed for the site " + webUrl);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogErrorMessage("[ReplaceMasterPage: ProcessInputFile]. Exception Message: " + ex.Message, true);
                        ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "ReplaceMasterPage", ex.Message, ex.ToString(), "ProcessInputFile()", ex.GetType().ToString());
                    }
                }
                System.Console.ForegroundColor = System.ConsoleColor.Green;
                Logger.LogSuccessMessage("[ReplaceMasterPage: DoWork] Successfully processed all sites and output file is present in the path: "
                                         + outputPath, true);
                System.Console.ResetColor();
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage("[ReplaceMasterpage: ProcessInputFile]. Exception Message: " + ex.Message, true);
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "ReplaceMasterPage", ex.Message, ex.ToString(), "ProcessInputFile()", ex.GetType().ToString());
            }
            finally
            {
                dtMasterPagesInput.Dispose();
            }
        }
Пример #18
0
        public static void DoWork(string inputFileSpec)
        {
            Logger.OpenLog("CommentUDCXFileNodes");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
            Logger.LogInfoMessage(inputFileSpec, true);

            List <UdcxReportOutput> _WriteUDCList = null;

            IEnumerable <UdcxReportInput> udcxCSVRows = ImportCSV.ReadMatchingColumns <UdcxReportInput>(inputFileSpec, Constants.CsvDelimeter);

            if (udcxCSVRows != null)
            {
                try
                {
                    var authRows = udcxCSVRows.Where(x => x.Authentication != null && x.Authentication != Constants.ErrorStatus && x.Authentication.Length > 0);
                    if (authRows != null && authRows.Count() > 0)
                    {
                        _WriteUDCList = new List <UdcxReportOutput>();
                        Logger.LogInfoMessage(String.Format("Preparing to comment a total of {0} Udcx Files Nodes ...", authRows.Count()), true);

                        foreach (UdcxReportInput udcxFileInput in authRows)
                        {
                            CommentUDCXFileNode(udcxFileInput, _WriteUDCList);
                        }

                        GenerateStatusReport(_WriteUDCList);
                    }
                    else
                    {
                        Logger.LogInfoMessage("No valid authentication records found in '" + inputFileSpec + "' File ", true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("CommentUDCXFileNode() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("No records found in '" + inputFileSpec + "' File ", true);
            }

            Logger.CloseLog();
        }
Пример #19
0
        public ImportSummary ImportFileData(Stream inputStream)
        {
            var fileData = ImportCSV.Parse(inputStream);

            var csvColumns = GetColumnSpec(CultureInfo.CurrentCulture.Name);

            //if (!PreValidate(csvColumns, fileData))
            if (!PreValidate(csvColumns, fileData))
            {
                IList <ImportError> importErrors = new List <ImportError>();
                try
                {
                    var rowCount  = 0;
                    var strErrors = "";
                    foreach (var deal in fileData.DealData.Where(l => l.Status == ImportDealStatus.Validation))
                    {
                        rowCount++;
                        strErrors = deal.Disposition.Aggregate(strErrors,
                                                               (current, disposition) => current + ". " + disposition);
                    }

                    ImportHelpers.AddImportErrorToList(ref importErrors, rowCount, "Import", strErrors);
                }
                catch (Exception e)
                {
                    LogManager.WriteLog("Error adding import validation erros", e);
                    ImportHelpers.AddImportErrorToList(ref importErrors, 0, "Import", e.Message);
                }

                var importSummary = new ImportSummary {
                    ImportErrors = importErrors
                };
                return(importSummary);
            }
            else
            {
                var importSummary = ImportCSV.ImportFileData(fileData);
                importSummary.Summary = GetImportDBSummary(importSummary.ImportResults);
                return(importSummary);
            }
        }
Пример #20
0
        public ActionResult GetWaterChemical()
        {
            try
            {
                var directoryInfo = new DirectoryInfo(StaticFilePath.LocalFilePath);
                var fileInfo      = directoryInfo.GetFiles().FirstOrDefault(x => x.Name.Equals("Melbourne_water_chemical.csv"));
                if (fileInfo == null)
                {
                    return(Content(JsonConvert.SerializeObject(new { isSuccess = false, Message = "No Data" }), "application/json"));
                }

                var process = new ImportCSV($@"{fileInfo.DirectoryName}\", fileInfo.Name);
                var data    = process.ReadCsvFileToTable();

                return(Content(JsonConvert.SerializeObject(new { isSuccess = true, Data = data }), "application/json"));
            }
            catch (Exception e)
            {
                return(Content(JsonConvert.SerializeObject(new { isSuccess = false, Message = e.Message }), "application/json"));
            }
        }
Пример #21
0
        private void BtnImport_Click(object sender, RoutedEventArgs e)
        {
            string SourcePath, msgImport;

            SourcePath = TxtSource.Text;
            if (File.Exists(SourcePath))
            {
                if (SourcePath.Substring(SourcePath.Length - 4, 4) == ".csv")
                {
                    msgImport = ImportCSV.importTable(Application.Current.Resources["ProjectPrefix"].ToString(), SourcePath);
                    MessageBox.Show(msgImport);
                    Switcher.Switch(new ProjectPage(5));
                }
                else
                {
                    MessageBox.Show("Type of file must be a .csv!");
                }
            }
            else
            {
                MessageBox.Show("File doesn't exists!");
            }
        }
        public static void DoWork()
        {
            string timeStamp    = DateTime.Now.ToString("yyyyMMdd_hhmmss");
            string CTCFFileName = outputPath + @"\" + Constants.ContentTypeAndCustomFieldFileName + timeStamp + Constants.CSVExtension;

            Logger.OpenLog("GenerateColumnORFieldAndTypeUsageReport", timeStamp);
            if (!ShowInformation())
            {
                return;
            }
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            string contentTypesInputFileSpec    = Environment.CurrentDirectory + "\\" + Constants.ContentTypeInput;
            List <ContentTypeSpec> contentTypes = new List <ContentTypeSpec>();

            if (System.IO.File.Exists(contentTypesInputFileSpec))
            {
                IEnumerable <InputContentTypeBase> objInputContentType = ImportCSV.ReadMatchingColumns <InputContentTypeBase>(contentTypesInputFileSpec, Constants.CsvDelimeter);
                Logger.LogInfoMessage(String.Format("Loaded {0} content type definitions ...", objInputContentType.Count()), true);
                foreach (InputContentTypeBase s in objInputContentType)
                {
                    contentTypes.Add(new ContentTypeSpec(s.ContentTypeID, s.ContentTypeName));
                }
            }
            else
            {
                Logger.LogErrorMessage(String.Format("[GenerateColumnORFieldAndTypeUsageReport] Input file {0} is not available", contentTypesInputFileSpec), true);
            }

            string customFieldsInputFileSpec = Environment.CurrentDirectory + "\\" + Constants.CustomFieldsInput;

            List <SiteColumnSpec> customFields = new List <SiteColumnSpec>();

            if (System.IO.File.Exists(customFieldsInputFileSpec))
            {
                IEnumerable <InputCustomFieldBase> objInputCustomField = ImportCSV.ReadMatchingColumns <InputCustomFieldBase>(customFieldsInputFileSpec, Constants.CsvDelimeter);
                Logger.LogInfoMessage(String.Format("Loaded {0} site column/custom field definitions ...", objInputCustomField.Count()), true);
                foreach (InputCustomFieldBase s in objInputCustomField)
                {
                    customFields.Add(new SiteColumnSpec(s.ID, s.Name));
                }
            }
            else
            {
                Logger.LogErrorMessage(String.Format("[GenerateColumnORFieldAndTypeUsageReport] Input file {0} is not available", customFieldsInputFileSpec), true);
            }

            if (!System.IO.File.Exists(CTCFFileName))
            {
                headerContentType = false;
            }
            else
            {
                headerContentType = true;
            }

            string inputFileSpec = Environment.CurrentDirectory + "\\" + Constants.UsageReport_SitesInputFileName;

            if (System.IO.File.Exists(inputFileSpec))
            {
                string[] siteUrls = Helper.ReadInputFile(inputFileSpec, false);
                Logger.LogInfoMessage(String.Format("Preparing to scan a total of {0} sites ...", siteUrls.Length), true);

                foreach (string siteUrl in siteUrls)
                {
                    ProcessSite(siteUrl, contentTypes, customFields, CTCFFileName);
                }
                Logger.LogSuccessMessage(String.Format("[GenerateColumnORFieldAndTypeUsageReport] Usage report is exported to the file {0} ", CTCFFileName), true);
            }
            else
            {
                Logger.LogErrorMessage(String.Format("[GenerateColumnORFieldAndTypeUsageReport] Input file {0} is not available", inputFileSpec), true);
            }

            Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            Logger.CloseLog();
        }
Пример #23
0
        public static void DoWork()
        {
            try
            {
                Logger.OpenLog("DeleteMissingWorkflowAssociations");
                System.Console.WriteLine("Enter the path of input file PreMT_MissingWorkflowAssociations.csv");
                string filePath = System.Console.ReadLine();
                if (string.IsNullOrEmpty(filePath) || !System.IO.Directory.Exists(filePath))
                {
                    Logger.LogWarningMessage("Input FilePath '" + filePath + "' is not valid", true);
                    filePath = Environment.CurrentDirectory;
                    Logger.LogInfoMessage("Correct Input FilePath is not provided so it changed to current environment '" + filePath + "'", true);
                }

                Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
                string inputFileSpec = filePath + "\\" + Constants.MissingWorkflowAssociationsInputFileName;
                if (System.IO.File.Exists(inputFileSpec))
                {
                    IEnumerable <MissingWorkflowAssociationsInput> objInputMissingWorkflowAssociations = ImportCSV.ReadMatchingColumns <MissingWorkflowAssociationsInput>(inputFileSpec, Constants.CsvDelimeter);
                    if (objInputMissingWorkflowAssociations != null)
                    {
                        try
                        {
                            Logger.LogInfoMessage(String.Format("\nPreparing to delete a total of {0} files ...", objInputMissingWorkflowAssociations.Cast <Object>().Count()), true);

                            foreach (MissingWorkflowAssociationsInput missingFile in objInputMissingWorkflowAssociations)
                            {
                                DeleteMissingFile(missingFile);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogErrorMessage(String.Format("DeleteMissingWorkflowAssociationFiles() failed: Error={0}", ex.Message), true);
                        }
                        Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
                    }
                    else
                    {
                        Logger.LogInfoMessage("There is nothing to delete from the '" + inputFileSpec + "' File ", true);
                    }
                }
                else
                {
                    Logger.LogErrorMessage("The input file " + inputFileSpec + " is not present", true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage(String.Format("DeleteMissingWorkflowAssociationFiles() failed: Error={0}", ex.Message), true);
            }
            Logger.CloseLog();
        }
Пример #24
0
 public async Task Insert(ImportCSV model)
 {
     await ImportCollection.InsertOneAsync(model);
 }
 public GetGarantiList()
 {
     importCSV = new ImportCSV();
 }
Пример #26
0
        public static void DoWork()
        {
            outputPath = Environment.CurrentDirectory;
            string webPartsInputFile = string.Empty;
            string webpartType       = string.Empty;
            IEnumerable <WebpartInput> objWPDInput;
            string timeStamp = DateTime.Now.ToString("yyyyMMdd_hhmmss");

            //Trace Log TXT File Creation Command
            Logger.OpenLog("DeleteWebparts", timeStamp);

            if (!ReadInputFile(ref webPartsInputFile))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage("Webparts input file is not valid or available. So, Operation aborted!");
                Logger.LogErrorMessage("Please enter path like: E.g. C:\\<Working Directory>\\<InputFile>.csv");
                System.Console.ResetColor();
                return;
            }

            System.Console.ForegroundColor = System.ConsoleColor.Cyan;
            Logger.LogMessage("Please enter Webpart Type (enter 'all' to delete all webparts):");
            System.Console.ResetColor();
            webpartType = System.Console.ReadLine().ToLower();

            try
            {
                string csvFile = outputPath + @"/" + Constants.DeleteWebpartStatus + timeStamp + Constants.CSVExtension;
                if (System.IO.File.Exists(csvFile))
                {
                    System.IO.File.Delete(csvFile);
                }

                if (System.IO.File.Exists(webPartsInputFile))
                {
                    if (String.Equals(Constants.WebpartType_All, webpartType, StringComparison.CurrentCultureIgnoreCase))
                    {
                        //Reading Input File
                        objWPDInput = ImportCSV.ReadMatchingColumns <WebpartInput>(webPartsInputFile, Constants.CsvDelimeter);

                        if (objWPDInput.Any())
                        {
                            IEnumerable <string> webPartTypes = objWPDInput.Select(x => x.WebPartType);

                            webPartTypes = webPartTypes.Distinct();
                            Logger.LogInfoMessage(String.Format("Preparing to delete a total of {0} webparts ...", webPartTypes.Count()), true);

                            foreach (string webPartType in webPartTypes)
                            {
                                try
                                {
                                    DeleteWebPart_UsingCSV(webPartType, webPartsInputFile, csvFile);
                                }
                                catch (Exception ex)
                                {
                                    Logger.LogErrorMessage("[DeleteMissingWebparts: DoWork]. Exception Message: " + ex.Message, true);
                                    ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "Webpart", ex.Message,
                                                                ex.ToString(), "DoWork", ex.GetType().ToString(), Constants.NotApplicable);
                                }
                            }
                            webPartTypes = null;
                        }
                        else
                        {
                            Logger.LogInfoMessage("There is nothing to delete from the '" + webPartsInputFile + "' File ", true);
                        }
                    }
                    else
                    {
                        DeleteWebPart_UsingCSV(webpartType, webPartsInputFile, csvFile);
                    }
                    Logger.LogInfoMessage("Processing input file has been comepleted...");
                }
                else
                {
                    Logger.LogErrorMessage("[DeleteMissingWebparts: DoWork]The input file " + webPartsInputFile + " is not present", true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage("[DeleteMissingWebparts: DoWork]. Exception Message: " + ex.Message, true);
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "Webpart", ex.Message,
                                            ex.ToString(), "DoWork", ex.GetType().ToString(), Constants.NotApplicable);
            }
            finally
            {
                objWPDInput = null;
            }

            Logger.CloseLog();
        }
        public static void DoWork(string inputFileSpec)
        {
            Logger.OpenLog("PeoplePickerRemediation");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
            Logger.LogInfoMessage(inputFileSpec, true);
            List <PeoplePickerListOutput> _WriteUDCList = null;

            Logger.LogInfoMessage(String.Format("AppSettings:"), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UseAppModel] = {0}", Program.UseAppModel), true);
            if (Program.UseAppModel == true)
            {
                Logger.LogInfoMessage(String.Format("- AppId = {0}", ConfigurationManager.AppSettings["ClientId"].ToString()), true);
            }
            else
            {
                string adminUsername = String.Format("{0}{1}", (String.IsNullOrEmpty(Program.AdminDomain) ? "" : String.Format("{0}\\", Program.AdminDomain)), Program.AdminUsername);
                Logger.LogInfoMessage(String.Format("- Admin Username = {0}", adminUsername), true);
            }
            Logger.LogInfoMessage(String.Format("- AppSettings[LocalAdLdapQuery] = {0}", ConfigurationManager.AppSettings["LocalAdLdapQuery"].ToString()), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UpnPrefix] = {0}", ConfigurationManager.AppSettings["UpnPrefix"].ToString()), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UpdateUserInfoEvenIfEventReceiversEnabled] = {0}", ConfigurationManager.AppSettings["UpdateUserInfoEvenIfEventReceiversEnabled"].ToString()), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UpdateUserInfoEvenIfWorkflowsEnabled] = {0}", ConfigurationManager.AppSettings["UpdateUserInfoEvenIfWorkflowsEnabled"].ToString()), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[CamlQueryRowLimit] = {0}", ConfigurationManager.AppSettings["CamlQueryRowLimit"].ToString()), true);

            IEnumerable <PeoplePickerListsInput> pprCSVRows = ImportCSV.ReadMatchingColumns <PeoplePickerListsInput>(inputFileSpec, Constants.CsvDelimeter);

            if (pprCSVRows != null)
            {
                try
                {
                    var lists = pprCSVRows.Where(x => x.ListName != null && x.WebUrl != null);
                    if (lists != null && lists.Count() > 0)
                    {
                        _WriteUDCList = new List <PeoplePickerListOutput>();
                        Logger.LogInfoMessage(String.Format("Preparing to process a total of {0} PeoplePicker InfoPath Form Libraries ...", lists.Count()), true);
                        PeoplePickerListOutput ps = new PeoplePickerListOutput();
                        foreach (PeoplePickerListsInput pprFileInput in lists)
                        {
                            ReadFormLibUsingAppOnlyAndCredentials(pprFileInput, ref _WriteUDCList);
                        }

                        if (_WriteUDCList != null && _WriteUDCList.Any())
                        {
                            GenerateStatusReport(_WriteUDCList);
                            _WriteUDCList = null;
                        }
                    }
                    else
                    {
                        Logger.LogInfoMessage("No valid PeoplePicker InfoPath Form Library records found in '" + inputFileSpec + "' File ", true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("PeoplePickerRemediation:DoWork() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("No PeoplePicker InfoPath Form Library records found in '" + inputFileSpec + "' File ", true);
            }

            Logger.CloseLog();
        }