private long GetSessionID(CaseSession FirstSession)
 {
     return(CaseConfiguration.GetCircuitRolls(FirstSession.Circuit_ID, FirstSession.CaseTypeID)
            .Where(circuitDate => circuitDate.Date == FirstSession.Session_Date)
            .Select(circuitDate => circuitDate.ID)
            .First());
 }
        private ActType FillActType(CaseSessionAct sessionAct, CaseSession session, List <CaseMigration> migrations)
        {
            (var newId, var action) = AppendUpdateIntegrationKeyAction(SourceTypeSelectVM.CaseSessionAct, sessionAct.Id, sessionAct.DateExpired != null);
            if (string.IsNullOrEmpty(newId))
            {
                return(null);
            }

            /*  CdnDownloadResult actFile = cdnService.MongoCdn_Download(new CdnFileSelect()
             * {
             *   SourceType = SourceTypeSelectVM.CaseSessionActDepersonalized,
             *   SourceId = sessionAct.Id.ToString()
             * }).Result; */
            int[] reason = sessionAct.ActISPNDebtorStateId > 0 ?
                           new int[1] {
                sessionAct.ActISPNDebtorStateId ?? 0
            } :
            new int[0];
            return(new ActType()
            {
                act_action = ServiceMethodToAction(action),
                act_date = (session.DateTo ?? session.DateFrom).Date,
                act_id = newId,
                act_kind = GetNomValueInt(EpepConstants.Nomenclatures.ActTypes, sessionAct.ActTypeId),
                act_no = int.Parse(sessionAct.RegNumber),
                act_text = sessionAct.Description,
                act_debtor_status = sessionAct.ActISPNDebtorStateId ?? 0,
                act_reason = reason,
                Appeal = FillAppealArray(sessionAct.CaseSessionActComplains.ToList(),
                                         migrations.Where(x => x.CaseSessionActId == sessionAct.Id).ToList(), sessionAct),
                //act_image = Convert.FromBase64String(actFile.FileContentBase64)
            });
        }
Example #3
0
        private SessionType FillSessionType(CaseSession session, CaseSessionResult sessionResult, ICollection <CaseLawUnit> caseLawUnitsAll, List <CaseMigration> migrations)
        {
            var caseLawUnits = caseLawUnitsAll.Where(x => (x.DateTo ?? session.DateFrom) >= session.DateFrom)
                               .Where(x => x.CaseSessionId == session.Id)
                               .Where(x => x.JudgeRoleId == NomenclatureConstants.JudgeRole.JudgeReporter)
                               .ToList();
            var acts = session.CaseSessionActs.Select(x => FillActType(x, session, migrations)).ToArray();

            (var newId, var action) = AppendUpdateIntegrationKeyAction(SourceTypeSelectVM.CaseSession, session.Id, session.DateExpired != null);
            if (string.IsNullOrEmpty(newId))
            {
                return(null);
            }
            return(new SessionType()
            {
                session_action = ServiceMethodToAction(action),
                Act = acts,
                session_date = (session.DateTo ?? session.DateFrom).Date,
                session_id = newId,
                session_kind = GetNomValueInt(EpepConstants.Nomenclatures.SessionTypes, session.SessionTypeId),
                session_text = session.Description,
                session_time = session.DateTo ?? session.DateFrom,
                session_result = GetNomValueInt(EpepConstants.Nomenclatures.SessionResults, sessionResult.Id), /* nom_session_result */
                Surround = FillSurroundProcessedArray(session.CaseSessionDocs.ToList()),
                Judge = FillJudgeTypeArray(caseLawUnits),
                //extensions =
            });
        }
Example #4
0
        public void DeadLineOpenSessionResult(CaseSession session)
        {
            var deadline = DeadLineOpenSessionResultStart(session);

            SaveDeadLine(deadline);
            // Да се направи work_notification na секретарите
            var oldDeadLine = repo.AllReadonly <CaseDeadline>()
                              .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession &&
                                     x.SourceId == session.Id &&
                                     x.DeadlineTypeId == NomenclatureConstants.DeadlineType.OpenSessionResult)
                              .FirstOrDefault();

            if (oldDeadLine != null && oldDeadLine.Id > 0)
            {
                var workNotifications = workNotificationService.NewWorkNotificationSecretary(oldDeadLine);
                foreach (var notification in workNotifications)
                {
                    notification.CaseDeadlineId = oldDeadLine.Id;
                    if (notification.Id == 0)
                    {
                        repo.Add(notification);
                    }
                    else
                    {
                        repo.Update(notification);
                    }
                }
            }
        }
Example #5
0
        private bool sessionHaveResult(CaseSession session, int resultId)
        {
            var caseSessionResults = session.CaseSessionResults;

            if (caseSessionResults == null || !caseSessionResults.Any())
            {
                caseSessionResults = repo.AllReadonly <CaseSessionResult>()
                                     .Where(x => x.IsActive && x.DateExpired == null)
                                     .Where(x => x.CaseSessionId == session.Id)
                                     .ToList();
            }
            return(caseSessionResults.Any(x => x.SessionResultId == resultId));
        }
Example #6
0
        public CaseDeadline DeadLineOpenSessionResultCompleteInit(CaseSessionResult sessionResult)
        {
            CaseSession session  = repo.AllReadonly <CaseSession>().Where(x => x.Id == sessionResult.CaseSessionId).FirstOrDefault();
            var         deadline = repo.AllReadonly <CaseDeadline>()
                                   .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession &&
                                          x.SourceId == session.Id &&
                                          x.DeadlineTypeId == NomenclatureConstants.DeadlineType.OpenSessionResult &&
                                          x.DateComplete == null)
                                   .FirstOrDefault();

            if (deadline == null)
            {
                return(null);
            }
            deadline.DateComplete        = DateTime.Now;
            deadline.CaseSessionResultId = sessionResult.Id;
            return(deadline);
        }
Example #7
0
        public List <CaseDeadline> DeadLineDeclaredForResolveExpire(CaseSessionResult sessionResult)
        {
            CaseSession session = repo.AllReadonly <CaseSession>().Where(x => x.Id == sessionResult.CaseSessionId).FirstOrDefault();
            var         result  = new List <CaseDeadline>();

            if (sessionHaveResult(session, NomenclatureConstants.CaseSessionResult.StopedMoveWithSubstantialReason))
            {
                var deadlines = repo.AllReadonly <CaseDeadline>()
                                .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession &&
                                       x.SourceId <= session.Id &&
                                       x.CaseId == session.CaseId &&
                                       x.DeadlineTypeId == NomenclatureConstants.DeadlineType.DeclaredForResolve &&
                                       x.DateComplete == null &&
                                       x.DateExpired == null)
                                .ToList();
                foreach (var deadline in deadlines)
                {
                    setExpired(deadline);
                    deadline.ResultExpiredId = sessionResult.Id;
                    result.Add(deadline);
                }
            }
            if (!sessionHaveResult(session, NomenclatureConstants.CaseSessionResult.AnnouncedForResolution))
            {
                var deadlines = repo.AllReadonly <CaseDeadline>()
                                .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession &&
                                       x.SourceId == session.Id &&
                                       x.CaseId == session.CaseId &&
                                       x.DeadlineTypeId == NomenclatureConstants.DeadlineType.DeclaredForResolve &&
                                       x.DateComplete == null &&
                                       x.DateExpired == null)
                                .ToList();
                foreach (var deadline in deadlines)
                {
                    setExpired(deadline);
                    deadline.ResultExpiredId = sessionResult.Id;
                    if (!result.Any(x => x.Id == deadline.Id))
                    {
                        result.Add(deadline);
                    }
                }
            }
            return(result);
        }
        private SessionType FillSessionType(CaseSession session, CaseSessionResult sessionResult, ICollection <CaseLawUnit> caseLawUnitsAll, List <CaseMigration> migrations)
        {
            var caseLawUnits = caseLawUnitsAll.Where(x => (x.DateTo ?? session.DateFrom) >= session.DateFrom)
                               .Where(x => x.CaseSessionId == session.Id)
                               .Where(x => x.JudgeRoleId == NomenclatureConstants.JudgeRole.JudgeReporter)
                               .ToList();
            var acts = session.CaseSessionActs
                       .Where(x => x.DateExpired == null &&
                              x.ActDeclaredDate != null &&
                              x.ActTypeId != NomenclatureConstants.ActType.ExecListPrivatePerson &&
                              x.ActTypeId != NomenclatureConstants.ActType.ObezpechitelnaZapoved
                              )
                       .Select(x => FillActType(x, session, migrations)).ToArray();

            //acts = acts.Where(x => x.act_reason.Length > 0 || x.act_debtor_status > 0 || !string.IsNullOrEmpty(x.act_text)).ToArray();
            (var newId, var action) = AppendUpdateIntegrationKeyAction(SourceTypeSelectVM.CaseSession, session.Id, session.DateExpired != null);
            if (string.IsNullOrEmpty(newId))
            {
                return(null);
            }
            int sessionResultIspn = 11004;

            try
            {
                sessionResultIspn = GetNomValueInt(EpepConstants.Nomenclatures.SessionResults, sessionResult.Id); /* nom_session_result */
            } catch
            {
            }
            return(new SessionType()
            {
                session_action = ServiceMethodToAction(action),
                Act = acts,
                session_date = (session.DateTo ?? session.DateFrom).Date,
                session_id = newId,
                session_kind = GetNomValueInt(EpepConstants.Nomenclatures.SessionTypes, session.SessionTypeId),
                session_text = session.Description ?? "",
                session_time = session.DateTo ?? session.DateFrom,
                session_result = sessionResultIspn,
                Surround = FillSurroundProcessedArray(session.CaseSessionDocs.ToList()),
                Judge = FillJudgeTypeArray(caseLawUnits),
                //extensions =
            });
        }
Example #9
0
 public void DeadLineOnSession(CaseSession session)
 {
     DeadLineOpenSessionResult(session);
     if (session.DateExpired != null)
     {
         repo.SaveChanges();
         var deadlines = repo.AllReadonly <CaseDeadline>()
                         .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession &&
                                x.SourceId == session.Id &&
                                x.DateExpired == null)
                         .ToList();
         SaveDeadLineExpired(deadlines);
         repo.SaveChanges();
         var caseSessionAct = repo.AllReadonly <CaseSessionAct>()
                              .Where(x => x.CaseSessionId == session.Id);
         deadlines = repo.AllReadonly <CaseDeadline>()
                     .Where(x => x.SourceType == SourceTypeSelectVM.CaseSessionAct &&
                            caseSessionAct.Any(sa => x.SourceId == sa.Id) &&
                            x.DateExpired == null)
                     .ToList();
         SaveDeadLineExpired(deadlines);
     }
 }
Example #10
0
        public List <CaseDeadline> DeadLineDeclaredForResolveExpireOnSession(CaseSession session)
        {
            var result = new List <CaseDeadline>();

            if (!sessionHaveResult(session, NomenclatureConstants.CaseSessionResult.AnnouncedForResolution) ||
                session.DateExpired != null)
            {
                var deadlines = repo.AllReadonly <CaseDeadline>()
                                .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession &&
                                       x.SourceId == session.Id &&
                                       x.CaseId == session.CaseId &&
                                       x.DeadlineTypeId == NomenclatureConstants.DeadlineType.DeclaredForResolve &&
                                       x.DateComplete == null &&
                                       x.DateExpired == null)
                                .ToList();
                foreach (var deadline in deadlines)
                {
                    setExpired(deadline);
                    result.Add(deadline);
                }
            }
            return(result);
        }
Example #11
0
 /// <summary>
 /// Връща инфо на заседание тип заседание/дата от
 /// </summary>
 /// <param name="model">Обект CaseSession с изчетен SessionType</param>
 /// <returns></returns>
 public static string GetCaseSessionNameBreadcrumbs(CaseSession model)
 {
     return(((model.SessionType != null) ? model.SessionType.Label + " " : string.Empty) + model.DateFrom.ToString("dd.MM.yyyy"));
 }
Example #12
0
        public CaseDeadline DeadLineOpenSessionResultStart(CaseSession session)
        {
            var aSessionType = session.SessionType;

            if (aSessionType == null)
            {
                aSessionType = repo.AllReadonly <SessionType>()
                               .Where(x => x.Id == session.SessionTypeId)
                               .FirstOrDefault();
            }
            if (aSessionType == null)
            {
                return(null);
            }
            if (aSessionType.SessionTypeGroup == NomenclatureConstants.CaseSessionTypeGroup.PrivateSession)
            {
                return(null);
            }
            if (session.SessionStateId != NomenclatureConstants.SessionState.Provedeno)
            {
                return(null);
            }
            var deadline = repo.AllReadonly <CaseDeadline>()
                           .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession &&
                                  x.SourceId == session.Id &&
                                  x.DeadlineTypeId == NomenclatureConstants.DeadlineType.OpenSessionResult)
                           .FirstOrDefault();

            if (session.DateExpired != null)
            {
                if (deadline != null && deadline.DateExpired == null)
                {
                    setExpired(deadline);
                    return(deadline);
                }
                return(null);
            }
            var aCase = session.Case;

            if (aCase == null)
            {
                aCase = repo.AllReadonly <Case>().Where(x => x.Id == session.CaseId).FirstOrDefault();
            }

            var deadlineType = repo.AllReadonly <DeadlineType>().Where(x => x.Id == NomenclatureConstants.DeadlineType.OpenSessionResult).FirstOrDefault();

            var sessionMeeting = repo.AllReadonly <CaseSessionMeeting>()
                                 .Where(x => x.CaseSessionId == session.Id)
                                 .OrderBy(x => x.DateTo)
                                 .LastOrDefault();
            var startDate = (sessionMeeting?.DateTo ?? session.DateTo) ?? DateTime.Now;

            startDate = startDate.AddDays(1);
            if (deadline != null)
            {
                if (deadline.StartDate.Date != startDate.Date || deadline.DateExpired != null)
                {
                    setUnExpired(deadline);
                    deadline.StartDate = startDate;
                    setDateEnd(deadline, deadlineType);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                deadline                 = new CaseDeadline();
                deadline.CaseId          = aCase.Id;
                deadline.SourceType      = SourceTypeSelectVM.CaseSession;
                deadline.SourceId        = session.Id;
                deadline.DeadlineTypeId  = NomenclatureConstants.DeadlineType.OpenSessionResult;
                deadline.DeadlineGroupId = deadlineType.DeadlineGroupId;
                deadline.StartDate       = startDate;
                setDateEnd(deadline, deadlineType);
            }
            return(deadline);
        }
Example #13
0
        public CaseDeadline DeadLineDeclaredForResolveStart(CaseSessionResult sessionResult)
        {
            CaseSession session = repo.AllReadonly <CaseSession>().Where(x => x.Id == sessionResult.CaseSessionId).FirstOrDefault();

            if (session == null)
            {
                return(null);
            }
            var deadline = repo.AllReadonly <CaseDeadline>()
                           .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession &&
                                  x.SourceId == session.Id &&
                                  x.CaseSessionResultId == sessionResult.Id &&
                                  x.DeadlineTypeId == NomenclatureConstants.DeadlineType.DeclaredForResolve)
                           .FirstOrDefault();
            var aCase = session.Case;

            if (aCase == null)
            {
                aCase = repo.AllReadonly <Case>().Where(x => x.Id == session.CaseId).FirstOrDefault();
            }
            var  deadlineType = repo.AllReadonly <DeadlineType>().Where(x => x.Id == NomenclatureConstants.DeadlineType.DeclaredForResolve).FirstOrDefault();
            bool isSet        = false;

            if (deadline != null)
            {
                if (sessionResult.SessionResultId == NomenclatureConstants.CaseSessionResult.AnnouncedForResolution ||
                    sessionResult.DateExpired != null)
                {
                    if (deadline.DateExpired != null)
                    {
                        setUnExpired(deadline);
                        isSet = true;
                    }
                    if (deadline.StartDate != session.DateTo && session.DateTo != null)
                    {
                        deadline.StartDate = session.DateTo ?? deadline.StartDate;
                        setDateEnd(deadline, deadlineType);
                        isSet = true;
                    }
                }
                else
                {
                    setExpired(deadline);
                    isSet = true;
                }
            }
            else
            {
                if (sessionResult.SessionResultId == NomenclatureConstants.CaseSessionResult.AnnouncedForResolution)
                {
                    deadline                     = new CaseDeadline();
                    deadline.CaseId              = session.CaseId;
                    deadline.SourceType          = SourceTypeSelectVM.CaseSession;
                    deadline.SourceId            = session.Id;
                    deadline.DeadlineTypeId      = NomenclatureConstants.DeadlineType.DeclaredForResolve;
                    deadline.DeadlineGroupId     = deadlineType.DeadlineGroupId;
                    deadline.CaseSessionResultId = sessionResult.Id;
                    deadline.StartDate           = session.DateTo ?? DateTime.Now;
                    setDateEnd(deadline, deadlineType);
                    isSet = true;
                }
            }
            if (deadline != null && isSet)
            {
                return(deadline);
            }
            else
            {
                return(null);
            }
        }