示例#1
0
        static void ExportInscrieri(ISheet sheet, string[] columnNames, InscriereDetaliu inscriereD, InscriereDetaliuValidator iDValidator, InscriereActValidator iActValidator, InscriereImobilValidator iImobilValidator, InscriereProprietarValidator iPropValidator, string ruleSet)
        {
            var xPorts = new List <OutputInscriereDetaliu>();

            xPorts.FromPOCO(inscriereD);

            xPorts.ForEach(excelDTO =>
            {
                var row = sheet.CreateRow(excelDTO.RowIndex);

                if (excelDTO.IndexAct.HasValue)
                {
                    var inscriereAct = inscriereD.InscrieriActe.FirstOrDefault(y => y.Index == excelDTO.IndexAct.Value);
                    if (inscriereAct != null)
                    {
                        writeRow(row, columnNames, excelDTO, true, iActValidator.Validate(inscriereAct, ruleSet: ruleSet));
                    }
                }

                if (excelDTO.IndexParcela.HasValue)
                {
                    var inscriereParcela = inscriereD.InscrieriImobile.FirstOrDefault(y => y.Index == excelDTO.IndexParcela.Value);
                    if (inscriereParcela != null)
                    {
                        writeRow(row, columnNames, excelDTO, true, iImobilValidator.Validate(inscriereParcela, ruleSet: ruleSet));
                    }
                }

                if (excelDTO.IndexProprietar.HasValue)
                {
                    var inscriereProprietar = inscriereD.InscrieriProprietari.FirstOrDefault(y => y.Index == excelDTO.IndexProprietar.Value);
                    if (inscriereProprietar != null)
                    {
                        writeRow(row, columnNames, excelDTO, true, iPropValidator.Validate(inscriereProprietar, ruleSet: ruleSet));
                    }
                }
            });

            //validarea de Inscriere Detaliu

            var anotherRow = sheet.GetRow(inscriereD.ExcelRow) ?? sheet.CreateRow(inscriereD.ExcelRow);

            writeRow(anotherRow, columnNames, null, false, iDValidator.Validate(inscriereD, ruleSet: ruleSet));


            //lista de outputinscriereD trecuta printr-un writerow special care sa ia inscrierile de la fiecare dintre cei 3 indecsi, sa le valideze obiectele si sa le scrie in icselß
        }
示例#2
0
        /// <summary>
        /// Tiganie
        /// </summary>
        /// <returns>The dto.</returns>
        /// <param name="outputInscriereD">Output inscriere d.</param>
        /// <param name="proprietari">Proprietari.</param>
        /// <param name="acte">Acte.</param>
        /// <param name="parcele">Parcele.</param>
        public static IEnumerable <InscriereDetaliu> FromDTO(List <OutputInscriereDetaliu> outputInscriereD, IQueryable <Proprietar> proprietari, IQueryable <ActProprietate> acte, IQueryable <Parcela> parcele, IEnumerable <ModDobandire> moduriDobandire, IEnumerable <TipDrept> tipuriDrept, IEnumerable <TipInscriere> tipuriInscriere)
        {
            cazuri caz          = cazuri.nustim;
            string cotaGenerala = string.Empty;

            var excelRow = outputInscriereD.Min(x => x.RowIndex);

            var modDobandire = outputInscriereD.Select(x => x.ModDobandire).FirstOrDefault(x => !string.IsNullOrEmpty(x));
            var tipInscriere = outputInscriereD.Select(x => x.TipInscriere).FirstOrDefault(x => !string.IsNullOrEmpty(x));
            var tipDrept     = outputInscriereD.Select(x => x.TipDrept).FirstOrDefault(x => !string.IsNullOrEmpty(x));
            var parteaCF     = outputInscriereD.Select(x => x.ParteaCF).FirstOrDefault(x => x.HasValue);
            var nota         = outputInscriereD.Select(x => x.Nota).FirstOrDefault(x => !string.IsNullOrEmpty(x));
            var observatii   = outputInscriereD.Select(x => x.Observatii).FirstOrDefault(x => !string.IsNullOrEmpty(x));
            var detaliiDrept = outputInscriereD.Select(x => x.DetaliiDrept).FirstOrDefault(x => !string.IsNullOrEmpty(x));
            var numarCerere  = outputInscriereD.Select(x => x.NumarCerere).FirstOrDefault(x => x.HasValue);
            var dataCerere   = outputInscriereD.Select(x => x.DataCerere).FirstOrDefault(x => x.HasValue);

            var indexParcela       = outputInscriereD.FirstOrDefault(x => x.IndexParcela.HasValue).IndexParcela.Value;
            var indexAct           = outputInscriereD.FirstOrDefault(x => x.IndexAct.HasValue).IndexAct.Value;
            var indecsiProprietari = outputInscriereD.Where(x => x.IndexProprietar.HasValue).Select(x => new { index = x.IndexProprietar.Value, cota = x.CotaParte }).Distinct().ToList();

            caz = cazuri.sparge;

            // daca e doar o cota in excel fa o singura inscriere
            if (indecsiProprietari.Count(x => !string.IsNullOrEmpty(x.cota)) == 1)
            {
                caz          = cazuri.nusparge;
                cotaGenerala = indecsiProprietari.Single(x => !string.IsNullOrEmpty(x.cota)).cota;
            }

            if (indecsiProprietari.All(x => string.IsNullOrEmpty(x.cota)))
            {
                caz = cazuri.nusparge;
            }

            //if (indecsiProprietari.Count == 0)
            //{
            //    caz = cazuri.titlu;
            //}

            var parcela = parcele.FirstOrDefault(y => y.Index == indexParcela);

            var act = acte.FirstOrDefault(y => y.Index == indexAct);

            var modDobandireId = string.IsNullOrEmpty(modDobandire) ? act?.TipActProprietate?.ModDobandireId : moduriDobandire.FirstOrDefault(x => string.Equals(modDobandire, x.Denumire, StringComparison.InvariantCultureIgnoreCase))?.Id;
            var parteaCFId     = parteaCF.HasValue ? parteaCF : act?.TipActProprietate?.ParteaCF;
            var tipDreptId     = string.IsNullOrEmpty(tipDrept) ? act?.TipActProprietate?.TipDreptId : tipuriDrept.FirstOrDefault(x => string.Equals(tipDrept, x.Denumire, StringComparison.InvariantCultureIgnoreCase))?.Id;
            var tipInscriereId = !string.IsNullOrEmpty(nota) ?
                                 tipuriInscriere.FirstOrDefault(x => x.Denumire == "NOTATION").Id :
                                 string.IsNullOrEmpty(tipInscriere) ?
                                 act?.TipActProprietate?.TipInscriereId : tipuriInscriere.FirstOrDefault(x => string.Equals(tipInscriere, x.Denumire, StringComparison.InvariantCultureIgnoreCase))?.Id;

            var inscriereD = getInscriereDetaliu();

            if (caz == cazuri.nusparge)
            {
                inscriereD.Cota = cotaGenerala;
            }

            for (var i = 0; i < indecsiProprietari.Count; i++)
            {
                var x                   = indecsiProprietari[i];
                var proprietar          = proprietari.FirstOrDefault(y => y.Index == x.index);
                var inscriereProprietar = new InscriereProprietar()
                {
                    Index      = x.index,
                    ExcelRow   = excelRow + i,
                    Proprietar = proprietar
                };

                inscriereD.InscrieriProprietari.Add(inscriereProprietar);

                if (caz == cazuri.sparge)
                {
                    inscriereD.Cota     = x.cota;
                    inscriereD.ExcelRow = excelRow + i;
                    yield return(inscriereD);

                    inscriereD = getInscriereDetaliu();
                }
            }

            if (caz == cazuri.nusparge)
            {
                yield return(inscriereD);
            }

            InscriereImobil getInscriereImobil() =>
            new InscriereImobil()
            {
                Index    = indexParcela,
                ExcelRow = excelRow,
                Imobil   = parcela?.Imobil
            };

            InscriereAct getInscriereAct() =>
            new InscriereAct()
            {
                Index          = indexAct,
                ExcelRow       = excelRow,
                ActProprietate = act
            };

            InscriereDetaliu getInscriereDetaliu()
            {
                var id = new InscriereDetaliu()
                {
                    ModDobandireId = modDobandireId,
                    ParteaCF       = parteaCFId,
                    TipDreptId     = tipDreptId,
                    TipInscriereId = tipInscriereId,
                    Observatii     = observatii,
                    Nota           = nota,
                    DetaliiDrept   = detaliiDrept,
                    NumarCerere    = numarCerere,
                    DataCerere     = dataCerere
                };

                var iImobil = getInscriereImobil();

                id.InscrieriImobile.Add(iImobil);
                id.InscrieriActe.Add(getInscriereAct());
                id.ImobilReferinta = iImobil.Imobil;

                return(id);
            }

            //adauga imobil referinta, ExcelRow+indexul din indecsiProp la inscriereD
        }
示例#3
0
        //include toate tipurile de inscrieri si entitatile asociate + asocierile lor :D
        // calculeaza pozitia
        // TipDrept
        // InscrieriProprietari, Proprietar
        // InscrieriActeProprietate, ActProprietate
        static List <string> ExportInscriere(InscriereDetaliu inscriereD, IEnumerable <Proprietar> proprietariImobil, IMatcher matcher, IMatchProcessor matchProcessor)
        {
            StringBuilder builder1 = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();

            var clasTipDocument = new List <Classification>()
            {
                new Classification(0, "root"),
                new Classification(1, "TipDocument")
            };

            var clasModDobandire = new List <Classification>()
            {
                new Classification(0, "root"),
                new Classification(1, "ModDobandire")
            };

            var clasTipInscriere = new List <Classification>()
            {
                new Classification(0, "root"),
                new Classification(1, "TipInscriere")
            };

            var clasTipDreptParte2 = new List <Classification>()
            {
                new Classification(0, "root"),
                new Classification(1, "TipDrept"),
                new Classification(2, "Parte2")
            };

            var clasTipDreptParte3 = new List <Classification>()
            {
                new Classification(0, "root"),
                new Classification(1, "TipDrept"),
                new Classification(2, "Parte3")
            };

            switch (inscriereD.ParteaCF)
            {
            case 2:
                builder1.Append("#05#T").Append(' ', 6);
                break;

            case 3:
                builder1.Append("#06#T").Append(' ', 6);
                break;
            }


            //moved to importer
            //if (inscriereD.TipInscriere.Denumire == "NOTATION")
            //{
            //    inscriereD.TipDrept = null;
            //    inscriereD.ModDobandire = null;
            //    inscriereD.Cota = string.Empty;
            //    inscriereD.Moneda = string.Empty;
            //    inscriereD.Valoarea = string.Empty;
            //    inscriereD.DetaliiDrept = string.Empty;
            //}


            builder1.Append(inscriereD.TipInscriere?.Descriere).Append(' ', 6);

            //if (inscriereD.TipDrept!=null) //maybe not this
            //{
            builder1.Append(inscriereD.TipDrept?.Denumire.ToUpper()).Append(' ', 6);
            //}

            if (!string.IsNullOrEmpty(inscriereD.Cota))
            {
                builder1.Append(inscriereD.Cota).Append(' ', 6);
            }

            inscriereD.InscrieriProprietari.ToList().ForEach(x =>
            {
                switch (x.Proprietar.TipPersoana)
                {
                case TipPersoana.F:
                    builder1.Append(x.Proprietar.Nume.Trim().ToUpper()).Append(' ').Append(x.Proprietar.Prenume.Trim().ToUpper());
                    break;

                case TipPersoana.J:
                    builder1.Append(x.Proprietar.Nume.ToUpper());
                    break;

                case TipPersoana.N:
                    builder1.Append("NEIDENTIFICAT");
                    break;
                }
                builder1.Append('.');
            });

            if (inscriereD.InscrieriProprietari.Count > 1)
            {
                builder1.Remove(builder1.Length - 1, 1); //ultimul punct
            }

            switch (inscriereD.ParteaCF)
            {
            case 2:
                builder2.Append("#55#");
                break;

            case 3:
                builder2.Append("#66#");
                break;
            }

            var act = inscriereD.InscrieriActe.FirstOrDefault().ActProprietate;

            builder2.Append(act.Numar).Append('|');
            builder2.Append(act.Data.HasValue ? act?.Data.Value.ToString("dd/MM/yyyy") : "").Append('|');

            var matchTipDocument = matcher.Match(clasTipDocument, act.TipActProprietate.TipDocumentId.ToString(), matchProcessor);

            builder2.Append(matchTipDocument.Count > 0 ? matchTipDocument[0].Name : "0").Append('|');
            builder2.Append(act.Emitent);
            //if (inscriereD.TipInscriere.Denumire == "NOTATION")
            //{
            //    builder2.Append("[NOTARE]");
            //}
            builder2.Append('|');           //observatii
            builder2.Append(0).Append('|'); // no f*****g clue

            var matchTipInscriere = matcher.Match(clasTipInscriere, inscriereD.TipInscriere?.Denumire, matchProcessor);

            builder2.Append(matchTipInscriere.Count > 0 ? matchTipInscriere[0].Name : "").Append('|');

            List <Classification> matchTipDrept = new List <Classification>();

            switch (inscriereD.ParteaCF)
            {
            case 2:
                matchTipDrept = matcher.Match(clasTipDreptParte2, inscriereD.TipDrept != null ? inscriereD.TipDrept.Id.ToString() : "", matchProcessor);
                break;

            case 3:
                matchTipDrept = matcher.Match(clasTipDreptParte3, inscriereD.TipDrept != null ? inscriereD.TipDrept.Id.ToString() : "", matchProcessor);
                break;
            }
            builder2.Append(matchTipDrept.Count > 0 ? matchTipDrept[0].Name : "0").Append('|');

            var matchModDobandire = matcher.Match(clasModDobandire, inscriereD.ModDobandire?.Denumire, matchProcessor);

            builder2.Append(matchModDobandire.Count > 0 ? matchModDobandire[0].Name : "0").Append('|');

            builder2.Append(inscriereD.Cota).Append('|');
            builder2.Append(inscriereD.Nota).Append('|');

            var propIndexes = inscriereD.InscrieriProprietari.ToList().Select(x => proprietariImobil.ToList().IndexOf(x.Proprietar));

            builder2.Append(string.Join(' ', propIndexes)).Append('|');

            builder2.Append(0).Append('|'); //moneda

            builder2.Append('|');           //valoare

            builder2.Append(inscriereD.DetaliiDrept).Append('|');
            builder2.Append(inscriereD.NumarCerere).Append('|');
            builder2.Append(inscriereD.DataCerere.HasValue ? inscriereD.DataCerere.Value.ToString("yyyy-MM-dd") + "T00:00:00+02:00" : "").Append('|');
            builder2.Append(inscriereD.Observatii).Append('|');
            builder2.Append("poz#").Append(inscriereD.Pozitia).Append('|');

            return(new List <string>
            {
                builder1.ToString(),
                builder2.ToString()
            });
        }
示例#4
0
        public static void FromPOCO(this List <OutputInscriereDetaliu> outputInscrieriD, InscriereDetaliu inscriereD)
        {
            var max = new[] { inscriereD.InscrieriActe.Count, inscriereD.InscrieriImobile.Count, inscriereD.InscrieriProprietari.Count }.Max();

            for (var index = 0; index < max; index++)
            {
                var item = new OutputInscriereDetaliu()
                {
                    CotaParte    = inscriereD.Cota,
                    ModDobandire = inscriereD.ModDobandire.Denumire,
                    ParteaCF     = inscriereD.ParteaCF,
                    TipDrept     = inscriereD.TipDrept.Denumire,
                    TipInscriere = inscriereD.TipInscriere.Denumire,
                    Observatii   = inscriereD.Observatii,
                    Nota         = inscriereD.Nota,
                    DetaliiDrept = inscriereD.DetaliiDrept,
                    NumarCerere  = inscriereD.NumarCerere,
                    DataCerere   = inscriereD.DataCerere
                };

                if (inscriereD.InscrieriActe.Count > index)
                {
                    item.IndexAct = inscriereD.InscrieriActe.ElementAt(index).Index;
                }

                if (inscriereD.InscrieriImobile.Count > index)
                {
                    item.IndexParcela = inscriereD.InscrieriImobile.FirstOrDefault().Index;
                }

                if (inscriereD.InscrieriProprietari.Count > index)
                {
                    item.IndexProprietar = inscriereD.InscrieriProprietari.ElementAt(index).Index;
                }

                item.RowIndex = inscriereD.ExcelRow + index;
                outputInscrieriD.Add(item);
            }
        }