public int?createMeeting(NewMeetingDto imputed)
        {
            int?result = null;

            using (var db = FactoryConn.GetConn()) {
                try {
                    db.CreateTable <User> ();
                    var  usrList  = db.Table <User> ().ToList();
                    User reviewer = usrList.FirstOrDefault();
                    int  revId    = 0;
                    if (reviewer != null && reviewer.Id != 0)
                    {
                        revId = reviewer.Id;
                    }

                    Case    caseDetention = new Case();
                    Imputed newImputed    = new Imputed();
                    newImputed.Name          = imputed.Name.Trim();
                    newImputed.LastNameP     = imputed.LastNameP.Trim();
                    newImputed.LastNameM     = imputed.LastNameM.Trim();
                    newImputed.FoneticString = services.getFoneticByName(imputed.Name, imputed.LastNameP, imputed.LastNameM);
                    newImputed.Gender        = imputed.Gender.GetValueOrDefault();
                    newImputed.BirthDate     = imputed.DateBirth.GetValueOrDefault();

                    var reincident = db.Table <Imputed> ().Where(impu => impu.LastNameM == newImputed.LastNameM &&
                                                                 impu.LastNameP == newImputed.LastNameP && impu.Name == newImputed.Name &&
                                                                 impu.BirthDate == newImputed.BirthDate).ToList();
                    if (reincident != null && reincident.Count > 0)
                    {
                        caseDetention.Recidivist = true;
                    }
                    else
                    {
                        caseDetention.Recidivist = false;
                    }

//					caseDetention.Status = services.statusCasefindByCode (Constants.CASE_STATUS_MEETING);

                    caseDetention.HasNegation = imputed.HasNegation ?? false;
                    if (caseDetention.HasNegation == true)
                    {
                        caseDetention.StatusCaseId     = services.statusCasefindByCode(Constants.CASE_STATUS_NOT_PROSECUTE).Id;
                        caseDetention.DateNotProsecute = DateTime.Now;
                    }
                    else
                    {
                        caseDetention.StatusCaseId = services.statusCasefindByCode(Constants.CASE_STATUS_MEETING).Id;
                    }
                    caseDetention.IdFolder   = imputed.IdFolder;
                    caseDetention.DateCreate = DateTime.Today;
                    //caseDetention.setChangeArrangementType(false);
                    // se agrega para poder contar si un caso cambia de MC a SCPP en algun formato de audiencia
                    //caseDetention = caseRepository.save(caseDetention);
                    db.Insert(caseDetention);
                    Meeting meeting = new Meeting();
                    meeting.MeetingType     = Constants.MEETING_PROCEDURAL_RISK;
                    meeting.CaseDetentionId = caseDetention.Id;
                    meeting.District        = imputed.District ?? 1;
//					meeting.CaseDetention = caseDetention;
                    if (caseDetention.HasNegation == true)
                    {
                        StatusMeeting statusMeeting = services.statusMeetingfindByCode(Constants.S_MEETING_DECLINE);
                        meeting.StatusMeetingId = statusMeeting.Id;
                        meeting.DeclineReason   = imputed.Reason;
                        meeting.DateTerminate   = imputed.Terminate;
                    }
                    else
                    {
                        StatusMeeting statusMeeting = services.statusMeetingfindByCode(Constants.S_MEETING_INCOMPLETE);
                        meeting.StatusMeetingId = statusMeeting.Id;
                    }
//					meeting.StatusMeeting = statusMeeting;
                    meeting.ReviewerId = revId;
//					meeting.Reviewer = reviewer;
                    meeting.DateCreate = DateTime.Today;
                    db.Insert(meeting);
                    newImputed.MeetingId = meeting.Id;
//					newImputed.Meeting = meeting;
                    db.Insert(newImputed);
                    db.Update(meeting);
                    db.Update(caseDetention);
                    //				imputedRepository.save(imputed);
                    result = caseDetention.Id;
                } catch (Exception e) {
                    Console.WriteLine("e.Message>" + e.Message + "<< createMeeting");
                }
                db.Close();
            }
            return(result);
        }
Пример #2
0
        public void ValidationMeetingBySource(int idSource)
        {
            using (var db = FactoryConn.GetConn()) {
                var     source       = db.Table <SourceVerification> ().Where(sv => sv.Id == idSource).FirstOrDefault();
                int     idCase       = (int)source.CaseRequestId;
                User    Reviewer     = db.Table <User> ().First();
                Case    cs           = db.Table <Case> ().Where(cas => cas.Id == idCase).ToList().First();
                Meeting baseMe       = db.Table <Meeting> ().Where(meet => meet.CaseDetentionId == cs.Id).First();
                Imputed baseImp      = db.Table <Imputed> ().Where(imput => imput.MeetingId == baseMe.Id).First();
                var     verification = db.Table <Verification> ().Where(ver => ver.CaseDetentionId == idCase).FirstOrDefault();
                var     result       = new VerificationMeetingSourceDto();
                result.IdFolder           = cs.IdFolder;
                result.ImputedId          = baseImp.Id;
                result.Name               = baseImp.Name;
                result.LastNameP          = baseImp.LastNameP;
                result.LastNameM          = baseImp.LastNameM;
                result.BirthDate          = baseImp.BirthDate;
                result.Gender             = baseImp.Gender;
                result.FoneticString      = baseImp.FoneticString;
                result.CelPhone           = baseImp.CelPhone;
                result.YearsMaritalStatus = baseImp.YearsMaritalStatus;
                result.MaritalStatusId    = baseImp.MaritalStatusId;
                result.Boys               = baseImp.Boys;
                result.DependentBoys      = baseImp.DependentBoys;
//				result.Location = baseImp.Location;
                result.LocationId        = baseImp.LocationId;
                result.BirthLocation     = baseImp.BirthLocation;
                result.BirthCountry      = baseImp.BirthCountry;
                result.BirthState        = baseImp.BirthState;
                result.BirthMunicipality = baseImp.BirthMunicipality;
                result.Nickname          = baseImp.Nickname;
                result.BirthInfoId       = baseImp.BirthInfo;

                result.MeetingId        = baseMe.Id;
                result.ReviewerId       = Reviewer.Id;
                result.StatusMeetingId  = baseMe.StatusMeetingId;
                result.CommentReference = baseMe.CommentReference;
                result.CommentCountry   = baseMe.CommentCountry;
                result.CommentDrug      = baseMe.CommentDrug;
                result.CommentHome      = baseMe.CommentHome;
                result.CommentJob       = baseMe.CommentJob;
                result.CommentSchool    = baseMe.CommentSchool;
                result.DateCreate       = baseMe.DateCreate;
                result.DateTerminate    = baseMe.DateTerminate;


                result.CaseId = idCase;

                result.ageString = services.calculateAge(result.BirthDate);

                var parantesco = db.Table <Relationship> ().ToList();
                result.ListaDeRelaciones = parantesco;
                var elecciones = db.Table <Election> ().ToList();
                result.ListaDeElection = elecciones;
                var documentosIdentificacion = db.Table <DocumentType> ().ToList();
                result.ListaDeIdentificaciones = documentosIdentificacion;
                var drogasCatalog = db.Table <DrugType> ().ToList();
                result.ListaDeDrogas = drogasCatalog;
                var periodoCatalog = db.Table <Periodicity> ().ToList();
                result.ListaDePeriodicidad = periodoCatalog;
                var registerCatalog = db.Table <RegisterType> ().ToList();
                result.ListaDeRegisterType = registerCatalog;

                result.JsonDomicilios = new List <DomiciliosVerificationDto> ();
                var domiciliosImputado = db.Table <ImputedHome> ().Where(im => im.MeetingId == result.MeetingId).ToList();
                if (domiciliosImputado != null && domiciliosImputado.Count > 0)
                {
                    var domVerified = new List <DomiciliosVerificationDto> ();
                    foreach (ImputedHome i in domiciliosImputado)
                    {
                        var home = new DomiciliosVerificationDto(i);
                        if (i.webId != null && i.webId != 0L)
                        {
                            home.Id = (int)i.webId;
                        }
                        home.ScheduleList = db.Table <Schedule> ().Where(xywz => xywz.ImputedHomeId == i.Id).ToList();
                        domVerified.Add(home);
                    }
                    result.JsonDomicilios = domVerified;
                }

                foreach (DomiciliosVerificationDto h in result.JsonDomicilios)
                {
                    h.Schedule = "";
                    var horario = db.Table <Schedule> ().Where(sche => sche.ImputedHomeId == h.Id).ToList();
                    if (horario != null && horario.Count > 0)
                    {
                        foreach (Schedule skdl in horario)
                        {
                            h.Schedule += "<tr>";
                            h.Schedule += "<td>" + skdl.Day + "</td>";
                            h.Schedule += "<td>" + skdl.Start + "</td>";
                            h.Schedule += "<td>" + skdl.End + "</td>";
                            h.Schedule += "</ tr>";
                        }
                    }
                }

                var SE = db.Table <SocialEnvironment> ().Where(s => s.MeetingId == result.MeetingId).FirstOrDefault();
                if (SE != null)
                {
                    result.PhysicalCondition = SE.physicalCondition;
                    result.comment           = SE.comment;
                    var ActList = db.Table <RelActivity> ().Where(s => s.SocialEnvironmentId == SE.Id).ToList();
                    if (ActList != null && ActList.Count > 0)
                    {
                        result.Activities = JsonConvert.SerializeObject(ActList);
                    }
                }
                //socialNetworkComment
                var socialNetComent = db.Table <SocialNetwork> ().Where(s => s.MeetingId == result.MeetingId).FirstOrDefault();
                if (socialNetComent != null)
                {
                    result.CommentSocialNetwork = socialNetComent.Comment;
                }
                else
                {
                    socialNetComent           = new SocialNetwork();
                    socialNetComent.Comment   = "";
                    socialNetComent.MeetingId = result.MeetingId ?? 0;
                    db.Insert(socialNetComent);
                }

                //PersonSocialNetwork
                var personsSocNet = db.Table <PersonSocialNetwork> ().Where(sn => sn.SocialNetworkId == socialNetComent.Id).ToList();
                if (personsSocNet != null && personsSocNet.Count > 0)
                {
                    var socialList = new List <PersonSocialNetworkVerificationDto> ();
                    foreach (PersonSocialNetwork psn in personsSocNet)
                    {
                        var nuev = new PersonSocialNetworkVerificationDto(psn);
                        if (psn.webId != null && psn.webId != 0L)
                        {
                            nuev.Id = (int)psn.webId;
                        }

                        socialList.Add(nuev);
                    }
                    result.JsonPersonSN = socialList;
                }
                else
                {
                    result.JsonPersonSN = null;
                }

                //Reference
                var references = db.Table <Reference> ().Where(sn => sn.MeetingId == result.MeetingId).ToList();
                if (references != null && references.Count > 0)
                {
                    for (var cont = 0; cont < references.Count; cont++)
                    {
                        if (references [cont].webId != null && references [cont].webId != 0L)
                        {
                            references [cont].Id = (int)references [cont].webId;
                        }
                    }
                    result.JsonReferences = references;
                }
                else
                {
                    result.JsonReferences = null;
                }

                //Laboral History
                var trabajos = db.Table <Job> ().Where(sn => sn.MeetingId == result.MeetingId).ToList();
                if (trabajos != null && trabajos.Count > 0)
                {
                    var dtojob = new List <JobVerificationDto> ();
                    foreach (Job j in trabajos)
                    {
                        var trabajo = new JobVerificationDto(j);
                        if (j.webId != null && j.webId != 0L)
                        {
                            trabajo.Id = (int)j.webId;
                        }
                        trabajo.ScheduleList = db.Table <Schedule> ().Where(trbjao => trbjao.JobId == j.Id).ToList() ?? new List <Schedule> ();
                        dtojob.Add(trabajo);
                    }
                    result.JsonJobs = dtojob;
                }
                else
                {
                    result.JsonJobs = null;
                }

                //school history
                var escuelaUtlActual = db.Table <School> ().Where(sc => sc.MeetingId == result.MeetingId).FirstOrDefault();
                if (escuelaUtlActual != null)
                {
                    result.SchoolAddress       = escuelaUtlActual.Address;
                    result.SchoolBlock         = escuelaUtlActual.block;
                    result.SchoolDegreeId      = escuelaUtlActual.DegreeId.GetValueOrDefault();
                    result.SchoolName          = escuelaUtlActual.Name;
                    result.SchoolPhone         = escuelaUtlActual.Phone;
                    result.SchoolSpecification = escuelaUtlActual.Specification;
                }

                if (escuelaUtlActual != null)
                {
                    result.SchoolId = escuelaUtlActual.Id;
                    var schedule = db.Table <Schedule> ().Where(scular => scular.SchoolId == escuelaUtlActual.Id).ToList();
                    if (schedule != null)
                    {
                        result.ScheduleSchool = schedule;
                    }
                }

                //DROGAS
                var drogas = db.Table <Drug> ().Where(sn => sn.MeetingId == result.MeetingId).ToList();
                if (drogas != null && drogas.Count > 0)
                {
                    for (var cont2 = 0; cont2 < drogas.Count; cont2++)
                    {
                        if (drogas [cont2].webId != null && drogas [cont2].webId != 0L)
                        {
                            drogas [cont2].Id = (int)drogas [cont2].webId;
                        }
                    }
                    result.JsonDrugs = drogas;
                }
                else
                {
                    result.JsonDrugs = null;
                }



                //leave country
                var leaveActual = db.Table <LeaveCountry> ().Where(lv => lv.MeetingId == result.MeetingId).FirstOrDefault();
                if (leaveActual != null)
                {
                    result.OfficialDocumentationId = leaveActual.OfficialDocumentationId;
                    result.LivedCountryId          = leaveActual.LivedCountryId;
                    result.timeAgo = leaveActual.timeAgo;
                    result.Reason  = leaveActual.Reason;
                    result.FamilyAnotherCountryId = leaveActual.FamilyAnotherCountryId;
                    result.CountryId                 = leaveActual.CountryId;
                    result.State                     = leaveActual.State;
                    result.Media                     = leaveActual.Media;
                    result.Address                   = leaveActual.Address;
                    result.ImmigrationDocumentId     = leaveActual.ImmigrationDocumentId;
                    result.RelationshipId            = leaveActual.RelationshipId;
                    result.TimeResidence             = leaveActual.TimeResidence;
                    result.SpecficationImmigranDoc   = leaveActual.SpecficationImmigranDoc;
                    result.SpecificationRelationship = leaveActual.SpecificationRelationship;
                    result.CommunicationFamilyId     = leaveActual.CommunicationFamilyId;
                }
                //End leave country


                string output = JsonConvert.SerializeObject(result);
                result.JsonMeeting = output;


                result.JsonCountrys     = this.JsonCountrys;
                result.JsonStates       = this.JsonStates;
                result.JsonMunycipality = this.JsonMunycipality;
                result.JsonElection     = this.JsonElection;
                result.JsonActivities   = this.JsonActivities;

                //result source
                result.SourceAddress = source.Address;
                result.SourceAge     = source.Age;
                result.SourceId      = source.Id;
                result.SourceName    = source.FullName;
                result.SourcePhone   = source.Phone;
                var SourceRelationship = db.Table <Relationship> ().Where(sore => sore.Id == source.RelationshipId).FirstOrDefault();
                if (SourceRelationship.Equals(null))
                {
                    result.SourceRelationshipString = "";
                }
                else
                {
                    result.SourceRelationshipString = SourceRelationship.Name;
                }

                var temp = new VerificacionInterview {
                    Model = result
                };
                //			var temp = new NewMeeting{Model = new EntrevistaTabla{Name="nombre" , DateBirthString=DateTime.Today.ToString("yyyy/mm/dd")} };
                var pagestring = "nada que ver";
                pagestring = temp.GenerateString();
                webView.LoadHtmlString(pagestring);
                db.Close();
            }
        }