Exemplo n.º 1
0
        private void WriteRecord(XElement record, XDocument xdoc, string dossierDir)
        {
            var idkenmerkRecord = record.Element(nsArchf + "identificatiekenmerk")?.Value;

            if (!IOUtilities.IsValidDirectoryName(idkenmerkRecord) || !IOUtilities.IsValidDirectoryName(idkenmerkRecord))
            {
                var logmessage = $"De samengestelde mapnaam {dossierDir}\\{idkenmerkRecord} bevat niet-toegestane karakters";
                ErrorMessage.AppendLine(logmessage);
                _logger.Error(logmessage);
                return;
            }

            var recordDir = Path.Combine(dossierDir, idkenmerkRecord);

            _ioUtilities.CreateDirectory(recordDir);
            _ioUtilities.Save(record.Parent, Path.Combine(recordDir, $"{idkenmerkRecord}.metadata"));

            var bestanden = xdoc.Descendants(nsArchf + "bestand")
                            .Where(t => t.Descendants(nsArchf + "relatieID").FirstOrDefault()?.Value == idkenmerkRecord &&
                                   t.Descendants(nsArchf + "aggregatieniveau").FirstOrDefault()?.Value == "Bestand");

            foreach (var bestand in bestanden)
            {
                WriteBestand(bestand, recordDir);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The method validates whether an object is valid.
        /// </summary>
        /// <returns>True - if object is valid, false - if object is invalid.</returns>
        public override bool IsValid()
        {
            bool        result            = false;
            List <bool> validationResults = new List <bool>();

            PropertyInfo[] pi = objectToValidate.GetType().GetProperties();

            foreach (PropertyInfo pInfo in pi)
            {
                object[] attributes = pInfo.GetCustomAttributes(typeof(ValidationAttributeBase), false);

                foreach (var attribute in attributes)
                {
                    ValidationAttributeBase attributeToBeUsed = attribute as ValidationAttributeBase;
                    if (attributeToBeUsed != null)
                    {
                        bool validationIntermediaryResult = attributeToBeUsed.Validate(pInfo.GetValue(objectToValidate));

                        validationResults.Add(validationIntermediaryResult);

                        if (!validationIntermediaryResult)
                        {
                            ErrorMessage.Append(attributeToBeUsed.GetErrorMessage());
                            ErrorMessage.AppendLine();
                        }
                    }
                }
            }

            result = validationResults.All(x => x == true);

            return(result);
        }
Exemplo n.º 3
0
        private void WriteOutputInvoice(List<InvoiceExcel> invoiceExcels)
        {
            string outputDir = Path.Combine(Output_OpenFolder.FileName, "OutputData");
            string path;

            try
            {
                path = Path.Combine(outputDir, "InvoiceInfo.xml");
                XMLHelpper.WriteXML<List<InvoiceExcel>>(path, invoiceExcels);
            }
            catch (Exception ex)
            {
                ErrorMessage.AppendLine(string.Format("Write file fail. =>Err: {0}", ex.Message));
            }

            try
            {
                path = Path.Combine(outputDir, "InvoiceInsertScript.sql");
                if (!Directory.Exists(outputDir))
                {
                    Directory.CreateDirectory(outputDir);
                }
                File.WriteAllText(path, OutputInvoice.ToString());
            }
            catch (Exception ex)
            {
                ErrorMessage.AppendLine(string.Format("Write file fail. =>Err: {0}", ex.Message));
            }
        }
Exemplo n.º 4
0
        private void WriteOutputwarehouseDetail(List <WarehouseDetailE> warehouseDetailEs)
        {
            string outputDir = Path.Combine(Warehouse_openFolder.FileName, "OutputData");
            string path;

            try
            {
                path = Path.Combine(outputDir, "warehouseDetailInfo.xml");
                XMLHelpper.WriteXML <List <WarehouseDetailE> >(path, warehouseDetailEs);
            }
            catch (Exception ex)
            {
                ErrorMessage.AppendLine(string.Format("Write file fail. =>Err: {0}", ex.Message));
            }

            try
            {
                path = Path.Combine(outputDir, "warehouseDetailInsertScript.sql");
                if (!Directory.Exists(outputDir))
                {
                    Directory.CreateDirectory(outputDir);
                }
                File.WriteAllText(path, OutputWarehouseDetail.ToString());
            }
            catch (Exception ex)
            {
                ErrorMessage.AppendLine(string.Format("Write file fail. =>Err: {0}", ex.Message));
            }
        }
Exemplo n.º 5
0
 private static int CheckForNegativesAndBigNumbers(int temp)
 {
     if (temp < 0)
     {
         ErrorMessage.AppendLine(string.Format("Negatives are not allowed: {0}.", temp));
     }
     else if (temp > 1000)
     {
         temp = 0;
     }
     return(temp);
 }
Exemplo n.º 6
0
 private void DrawKeyColumnName(ref MessageType messageType)
 {
     KeysColumnName = EditorGUILayout.TextField("Name of the Column with Keys", KeysColumnName);
     if (string.IsNullOrEmpty(KeysColumnName) == true)
     {
         if (ErrorMessage.Length > 0)
         {
             ErrorMessage.AppendLine();
         }
         ErrorMessage.Append("Name of the Column with Keys must be defined.");
         messageType = MessageType.Error;
     }
 }
Exemplo n.º 7
0
 private void GenerateInsertScriptDetail(List<VoucherDetailE> voucherDetailE)
 {
     if (voucherDetailE == null)
     {
         return;
     }
     int total = voucherDetailE.Count;
     foreach (VoucherDetailE item in voucherDetailE)
     {
         try
         {
             OutputDetail.AppendLine(GetInsertScriptDetail(item));
         }
         catch (Exception ex)
         {
             ErrorMessage.AppendLine(string.Format("Generate Script fail: {0}-{1}-{2}-{3} =>Err: {4}", item.VouchersID, item.VouchersDetailID, item.AccountID, item.AccountDetailID, ex.Message));
         }
     }
 }
Exemplo n.º 8
0
        private void DrawCsvFileName(ref MessageType messageType)
        {
            // Draw the label
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Import From");

            // Draw the text field
            CsvFileName = EditorGUILayout.DelayedTextField(CsvFileName);

            // Draw the browse button
            if (GUILayout.Button("Browse...", BrowseButtonFont, BrowseButtonHeight) == true)
            {
                string newFileName = EditorUtility.OpenFilePanelWithFilters("Import CSV File", "Assets/", CsvFileFilter);
                if (string.IsNullOrEmpty(newFileName) == false)
                {
                    CsvFileName = newFileName;
                }
            }

            // Check if there are any errors
            if (string.IsNullOrEmpty(CsvFileName) == true)
            {
                if (ErrorMessage.Length > 0)
                {
                    ErrorMessage.AppendLine();
                }
                ErrorMessage.Append("Assign a CSV file to import.");
                messageType = MessageType.Info;
            }
            else if (UnityEngine.Windows.File.Exists(CsvFileName) == false)
            {
                if (ErrorMessage.Length > 0)
                {
                    ErrorMessage.AppendLine();
                }
                ErrorMessage.Append("Cannot import file \"");
                ErrorMessage.Append(CsvFileName);
                ErrorMessage.Append("\"!");
                messageType = MessageType.Error;
            }
            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 9
0
        private void WriteBestand(XElement bestand, string recordDir)
        {
            var bestandsNaam = bestand.Descendants(nsArchf + "bestandsnaam").First().Element(nsArchf + "naam")?.Value;

            _ioUtilities.Save(bestand.Parent, Path.Combine(recordDir, $"{bestandsNaam}.metadata"));

            var extension = bestand.Descendants(nsArchf + "bestandsnaam").First().Element(nsArchf + "extensie")?.Value;

            bestandsNaam = bestandsNaam + "." + extension;
            var fileFullSourcePath = Path.Combine(_sourceDirOfSidecarFiles, bestandsNaam);

            if (_ioUtilities.FileExists(Path.Combine(_sourceDirOfSidecarFiles, bestandsNaam)))
            {
                _ioUtilities.FileCopy(fileFullSourcePath, Path.Combine(recordDir, bestandsNaam));
            }
            else
            {
                _logger.Error($"Bestand {fileFullSourcePath} niet gevonden");
                ErrorMessage.AppendLine($"Bestand {fileFullSourcePath} niet gevonden");
            }
        }
Exemplo n.º 10
0
        private void GenerateInsertInvoiceScript(List<InvoiceExcel> invoiceExcels)
        {
            if (invoiceExcels == null)
            {
                return;
            }

            int i = 0;
            int total = invoiceExcels.Count;
            foreach (InvoiceExcel item in invoiceExcels)
            {
                try
                {
                    OutputInvoice.AppendLine(GetInsertInvoiceScript(item));
                }
                catch (Exception ex)
                {
                    ErrorMessage.AppendLine(string.Format("Generate Script fail: {0}-{1}-{2}-{3} =>Err: {4}", item.VouchersID, item.InvoiceNo, item.Description, item.TotalAmount, ex.Message));
                }
            }
        }
Exemplo n.º 11
0
        private void GenerateInsertScript(List<VouchersE> vouchersE)
        {
            if (vouchersE == null)
            {
                return;
            }

            int i = 0;
            int total = vouchersE.Count;
            foreach (VouchersE item in vouchersE)
            {
                try
                {
                    Output.AppendLine(GetInsertScript(item));
                }
                catch (Exception ex)
                {
                    ErrorMessage.AppendLine(string.Format("Generate Script fail: {0}-{1}-{2}-{3} =>Err: {4}", item.VouchersTypeID, item.VoucherNo, item.VouchersID, item.VoucherDate, ex.Message));
                }
            }
        }
Exemplo n.º 12
0
        private void GenerateInsertwarehouseScript(List<WarehouseE> warehouseEs)
        {
            if (warehouseEs == null)
            {
                return;
            }

            int i = 0;
            int total = warehouseEs.Count;
            foreach (WarehouseE item in warehouseEs)
            {
                try
                {
                    OutputWarehouse.AppendLine(GetInsertWarehouseScript(item));
                }
                catch (Exception ex)
                {
                    ErrorMessage.AppendLine(string.Format("Generate Script fail: {0}-{1}-{2}-{3} =>Err: {4}", item.WarehouseID, item.WarehouseListID, item.Type, item.Date, ex.Message));
                }
            }
        }
Exemplo n.º 13
0
        private void GenerateInsertScript()
        {
            if (Vouchers == null)
            {
                return;
            }

            SetProcess("Đang tạo câu lệnh SQL ...");
            int i     = 0;
            int total = Vouchers.Count;

            foreach (Voucher item in Vouchers)
            {
                try
                {
                    SetProcess($"Đang tạo câu lệnh SQL thứ {i}/{total}");
                    Output.AppendLine(GetInsertScript(item));
                }
                catch (Exception ex)
                {
                    ErrorMessage.AppendLine(string.Format("Generate Script fail: {0}-{1}-{2}-{3} =>Err: {4}", item.VoucherType, item.VoucherNo, item.AccountID, item.AccountDetailID, ex.Message));
                }
            }
        }
Exemplo n.º 14
0
        private void LoadInput(FileNameInfo fileNameInfo)
        {
            Excel.Application excel = null;
            Excel.Workbook    wkb   = null;

            try
            {
                excel = new Excel.Application();

                wkb = OpenBook(excel, fileNameInfo.FilePath);
                excel.DisplayAlerts = false;
                Excel.Range xlRange = null;

                if (wkb.Sheets[1] is Excel.Worksheet sheet)
                {
                    xlRange = sheet.UsedRange;
                }

                string a, b, c, d;
                double e, f;
                if (xlRange != null)
                {
                    object[,] values = xlRange.Value2;
                    int row = xlRange.Rows.Count;
                    RecordTotal = row;
                    for (int i = 2; i <= row; i++)
                    {
                        RecordNumber = i;
                        SetProcessReadFile();

                        a = values[i, 1].ToString();
                        b = values[i, 2].ToString();
                        c = values[i, 3].ToString();
                        d = values[i, 4].ToString();
                        d = FontHelper.TCVN3ToUnicode(d);
                        e = Convert.ToDouble(values[i, 5] ?? 0);
                        f = Convert.ToDouble(values[i, 6] ?? 0);

                        Vouchers.Add(new Voucher
                        {
                            VoucherType        = a,
                            VoucherNo          = b,
                            VoucherDate        = c,
                            VoucherDescription = d,
                            PSNo            = e,
                            PSCo            = f,
                            AccountID       = fileNameInfo.AccountID,
                            AccountDetailID = fileNameInfo.AccountDetailID,
                            CustomerID      = fileNameInfo.CustomerID
                        });
                    }
                }

                excel.Quit();
            }
            catch (Exception ex)
            {
                ErrorMessage.AppendLine(string.Format("Load file fail: {0} => Err: {1}", fileNameInfo.FileName, ex.Message));
                Console.WriteLine(ex.Message);
                if (excel != null)
                {
                    excel.Quit();
                }
            }
        }