public async Task <IActionResult> Save(DocViewModel doc)
        {
            if (ModelState.IsValid)
            {
                if (doc == null)
                {
                    return(BadRequest($"{nameof(doc)} cannot be null"));
                }
                else
                {
                    doc.id = Guid.NewGuid().ToString();

                    var docviews = new DocViewModel[]
                    {
                        doc
                    };

                    var batch = IndexBatch.Upload(docviews);

                    try
                    {
                        _indexClient.Documents.Index(batch);
                    }
                    catch (IndexBatchException e)
                    {
                    }
                }

                return(Ok(doc));
            }

            return(BadRequest(ModelState));
        }
Example #2
0
 public async Task <IActionResult> AddDocUser(DocViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.UploadedFile != null)
         {
             // путь к папке Files
             string path = @"\Files\Users\" + model.UploadedFile.FileName;
             // сохраняем файл в папку Files в каталоге wwwroot
             using (var fileStream = new FileStream(_webHostEnvironment.WebRootPath + path, FileMode.Create))
             {
                 await model.UploadedFile.CopyToAsync(fileStream);
             }
             _accountService.AddUserDocument(model.SomethingId, new UserDocDTO
             {
                 Name   = model.UploadedFile.FileName,
                 Path   = path,
                 Date   = DateTime.Now.Date,
                 UserId = model.SomethingId
             });
             return(RedirectToAction("MyDocuments", "Account"));
         }
     }
     return(PartialView(model));
 }
Example #3
0
        public IActionResult AddDocumentCase(int caseid)
        {
            DocViewModel model = new DocViewModel {
                SomethingId = caseid
            };

            return(PartialView(model));
        }
Example #4
0
        public ActionResult Index(DocViewModel docViewModel)
        {
            var navegadorSession = (Navegador)Session["Nav"];



            return(RedirectToAction("Index", "Lista", new { nivel = 3, guid = navegadorSession.PlanilhaEscolhida.GUID }));
        }
Example #5
0
        private void DocumentSaveButton_GotFocus(object sender, RoutedEventArgs e)
        {
            //Will save and close control only if a save can be performed.
            bool didSave = DocViewModel.SaveDialogInfoAsync();

            if (didSave)
            {
                CloseControl();
            }
        }
Example #6
0
        public static IActionResult HandleMeta <T>(DocsController controller, string search, List <T> objects) where T : WebsiteMetaObject
        {
            ThemeHelper.HandleTheme(controller.Request, controller.ViewData);
            search = search?.ToLowerFast().Replace("%2f", "/");
            List <T> toDisplay = search == null ? objects : objects.Where(o => o.MatchesSearch(search)).ToList();

            if (toDisplay.IsEmpty())
            {
                Console.WriteLine($"Search for '{search}' found 0 results");
            }
            T exactMatch = toDisplay.FirstOrDefault(o => o.ObjectGeneric.CleanName == search);

            if (exactMatch != null)
            {
                toDisplay.Clear();
                toDisplay.Add(exactMatch);
            }
            List <string> categories = toDisplay.Select(o => o.GroupingString).Distinct().ToList();
            StringBuilder outText    = new StringBuilder();

            outText.Append("<center>");
            if (categories.Count > 1)
            {
                outText.Append("<h4>Categories:</h4>");
                outText.Append(string.Join(" | ", categories.Select(category =>
                {
                    string linkable = HttpUtility.UrlEncode(category.ToLowerFast());
                    return($"<a href=\"#{linkable}\" onclick=\"doFlashFor('{linkable}')\">{Util.EscapeForHTML(category)}</a>");
                })));
                foreach (string category in categories)
                {
                    string linkable = HttpUtility.UrlEncode(category.ToLowerFast());
                    outText.Append($"<br><hr><br><h4>Category: <a id=\"{linkable}\" href=\"#{linkable}\" onclick=\"doFlashFor('{linkable}')\">{Util.EscapeForHTML(category)}</a></h4><br>");
                    outText.Append(string.Join("\n<br>", toDisplay.Where(o => o.GroupingString == category).Select(o => o.HtmlContent)));
                }
            }
            else
            {
                outText.Append(string.Join("\n<br>", toDisplay.Select(o => o.HtmlContent)));
            }
            outText.Append("</center>");
            DocViewModel model = new DocViewModel()
            {
                IsAll          = search == null,
                CurrentlyShown = toDisplay.Count,
                Max            = objects.Count,
                Content        = new HtmlString(outText.ToString()),
                SearchText     = search
            };

            return(controller.View(model));
        }
Example #7
0
        private void documentBackButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            //Make sure to delete earthmat, station and location records.
            if (isQuickPhoto)
            {
                DocViewModel.DeleteCascadeOnQuickPhoto(parentViewModel);
            }

            //Make sure to delete captured photo if there was one.
            DocViewModel.DeleteCapturePhoto();

            CloseControl();
        }
Example #8
0
        // GET: Doc/Delete/5
        public ActionResult Delete(Guid id)
        {
            var model = new DocViewModel();

            var doc = DocRepository.Read(id);

            var docType = DocTypeRepository.Read(Guid.Parse(doc.type));

            model.MetaTags = MetaTagRepository.ReadMany(docType.MetaTags);
            model.Type     = docType.Name;
            model.TypeId   = docType.Id;

            model.Values = mapMetaTagsAndDocValue(model.MetaTags, doc);
            return(View(model));
        }
Example #9
0
        // GET: Listdoc/Details/5
        public async Task <ActionResult> Details(string firstname)
        {
            var doctor = DS.GetAll().Where(a => a.FirstName.Equals(firstname)).SingleOrDefault();
            //String username = doctor.UserName;
            //User user = await UserManager.FindByEmailAsync(doctor.UserName);

            DocViewModel DocViewModel = new DocViewModel();

            DocViewModel.Id         = doctor.Id;
            DocViewModel.firstname  = doctor.FirstName;
            DocViewModel.lastname   = doctor.LastName;
            DocViewModel.Location   = doctor.HomeAddress;
            DocViewModel.Speciality = doctor.Speciality;


            return(View(DocViewModel));
        }
Example #10
0
        // GET: PegaDoc
        public ActionResult Index()
        {
            Session["ListaVerificacaoVM"] = null;

            _planilha = (PlanilhaLVVM)Session["planilha"];

            DocViewModel docViewModel = new DocViewModel();

            docViewModel.SiglaDisciplina = _planilha.CabecalhoApp.SiglaDisciplina;

            docViewModel.Projeto = ((ProjetoVM)Session["Projeto"]).NUMERO;

            docViewModel.GuidPlanilha = _planilha.GUID;


            return(View(docViewModel));
        }
Example #11
0
        // GET: Listdoc
        public ActionResult Index()
        {
            List <DocViewModel> list = new List <DocViewModel>();

            foreach (var item in DS.GetAll())
            {
                DocViewModel PVM = new DocViewModel();
                PVM.Id         = item.Id;
                PVM.firstname  = item.FirstName;
                PVM.lastname   = item.LastName;
                PVM.Speciality = item.Speciality;
                PVM.Location   = item.HomeAddress;

                list.Add(PVM);
            }

            return(View(list));
        }
Example #12
0
        public ActionResult Index(string guid_planilha)
        {
            string siglaPlanilha = "";

            using (var contextoPlanilha = DIContainer.Instance.AppContainer.Resolve <AppServiceBase <Planilha> >())
            {
                contextoPlanilha.Start();
                var planilha = contextoPlanilha.ReturnByGUID(guid_planilha);
                siglaPlanilha = planilha.Tipo.Configuracao.Disciplina.SIGLA;
            }

            DocViewModel docViewModel = new DocViewModel();

            docViewModel.SiglaDisciplina = siglaPlanilha;

            docViewModel.GuidPlanilha = guid_planilha;

            return(PartialView("Index", docViewModel));
        }
Example #13
0
        // GET: Doc/Create
        public ActionResult Create(Guid type)
        {
            var model   = new DocViewModel();
            var docType = DocTypeRepository.Read(type);

            model.MetaTags = MetaTagRepository.ReadMany(docType.MetaTags);
            model.Type     = docType.Name;

            model.AutoCompletes = new Dictionary <string, List <string> >();

            foreach (var metaTag in model.MetaTags.Where(m => m.DataType == "string").ToList())
            {
                model.AutoCompletes.Add(metaTag.Name, DocRepository.GetUniqueStringValuesByMetaTagName(metaTag.Name));
            }

            model.MostRecentDocuments = DocRepository.GetMostRecentDocumentsForDocType(type, -90);

            return(View(model));
        }
Example #14
0
        public ActionResult Docs(uint userId)
        {
            var model = new DocViewModel();

            if (IsPost)
            {
                if (TryUpdateModel(model))
                {
                    var docsCount = DbSession.CreateSQLQuery(@"
insert into Logs.DocumentSendLogs(UserId, DocumentId)
select :userId, d.RowId
from (
	select l.RowId
	from Logs.Document_logs l
		join Customers.UserAddresses ua on ua.AddressId = l.AddressId
			join Customers.Addresses a on a.Id = ua.AddressId
		left join Logs.DocumentSendLogs sl on sl.DocumentId = l.RowId and sl.UserId = :userId
	where a.Enabled = 1
		and ua.UserId = :userId
		and sl.Id is null
		and l.LogTime > :begin
		and l.LogTime < :end
) as d")
                                    .SetParameter("begin", model.Begin)
                                    .SetParameter("end", model.End.AddDays(1))
                                    .SetParameter("userId", userId)
                                    .ExecuteUpdate();
                    if (docsCount > 0)
                    {
                        Notify($"Доступно к загрузке новых документов {docsCount}");
                    }
                    else
                    {
                        Warn("Документов не найдено");
                    }
                    return(RedirectToAction(nameof(Docs), new { userId }));
                }
            }
            ViewBag.User = DbSession.Load <User>(userId);
            return(View(model));
        }
Example #15
0
        // GET: Doc/Details/5
        public ActionResult Details(Guid id, string format)
        {
            var model = new DocViewModel();

            var doc = DocRepository.Read(id);

            var docType = DocTypeRepository.Read(Guid.Parse(doc.type));

            model.MetaTags = MetaTagRepository.ReadMany(docType.MetaTags);
            model.Id       = Guid.Parse(doc.id);
            model.Type     = docType.Name;
            model.TypeId   = docType.Id;

            model.Values = mapMetaTagsAndDocValue(model.MetaTags, doc);

            if (format != null && format == "json")
            {
                return(Json(model, JsonRequestBehavior.AllowGet));
            }

            return(View(model));
        }
Example #16
0
 public IActionResult AddDocUser()
 {
     try
     {
         string login = User.Identity.Name;
         if (login != null)
         {
             UserDTO      user  = _accountService.GetUser(login);
             DocViewModel model = new DocViewModel {
                 SomethingId = user.Id
             };
             return(PartialView(model));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     catch (ValidationException ex)
     {
         ModelState.AddModelError(ex.Property, ex.Message);
     }
     return(RedirectToAction("Index", "Home"));
 }
Example #17
0
        // GET: Doc/Edit/5
        public ActionResult Edit(Guid id)
        {
            var model = new DocViewModel();

            var doc = DocRepository.Read(id);

            var docType = DocTypeRepository.Read(Guid.Parse(doc.type));

            model.MetaTags = MetaTagRepository.ReadMany(docType.MetaTags);
            model.Id       = Guid.Parse(doc.id);
            model.Type     = docType.Name;
            model.TypeId   = docType.Id;

            model.Values = mapMetaTagsAndDocValue(model.MetaTags, doc);

            model.AutoCompletes = new Dictionary <string, List <string> >();

            foreach (var metaTag in model.MetaTags.Where(m => m.DataType == "string").ToList())
            {
                model.AutoCompletes.Add(metaTag.Name, DocRepository.GetUniqueStringValuesByMetaTagName(metaTag.Name));
            }

            return(View(model));
        }
Example #18
0
        public ActionResult Salva(DocViewModel docViewModel)
        {
            //if (ModelState.IsValid)
            //{



            var p_guid_planilha = docViewModel.GuidPlanilha;
            var p_projeto       = docViewModel.Projeto;
            var p_os            = docViewModel.OS;
            var p_area          = docViewModel.Area;
            var p_disciplina    = docViewModel.SiglaDisciplina;
            var p_tipodoc       = docViewModel.TipoDocumento;
            var p_sequencial    = docViewModel.Sequencial;



            bool   documentoContemRevisoes       = false;
            bool   existemRevisoesNaoConfirmadas = false;
            string docGuid = "";

            var validador = new DocViewModelValidator();

            var result = validador.Validate(docViewModel);


            if (!result.IsValid)
            {
                //return View(docViewModel);
                //return View("MsgDocIndefinido");
                //return Json(new
                //{
                //    status = "failure"
                //});
                return(Content(""));
            }
            else
            {
                if (_passou == false)
                {
                    var numeroDocSNCLavalin =
                        new NumeroDocSNCLavalin(
                            p_projeto,
                            p_os,
                            p_area,
                            p_disciplina,
                            p_tipodoc,
                            p_sequencial);

                    TempData["IsVerificador"] = true;

                    string numeroDesenho = numeroDocSNCLavalin.ToString();



                    ListaVerificacao documento = null;

                    using (var contextoDocumento = DIContainer.Instance.AppContainer.Resolve <AppServiceBase <ListaVerificacao> >())
                    {
                        contextoDocumento.Start();
                        documento = contextoDocumento.GetByProperty("DOC_VERIFICADO", numeroDesenho).FirstOrDefault();

                        Projeto projeto = null;

                        if (documento == null)
                        {
                            using (var contextoProjeto = DIContainer.Instance.AppContainer.Resolve <AppServiceBase <Projeto> >())
                            {
                                contextoProjeto.Start();

                                var listaProjetos = contextoProjeto.GetByProperty("NUMERO", p_projeto).ToList();

                                if (listaProjetos.Count > 0 && listaProjetos.Count < 2)
                                {
                                    projeto = listaProjetos.FirstOrDefault();

                                    if (projeto.ListaOSs.FirstOrDefault(x => x.NUMERO == numeroDocSNCLavalin.OS) == null)
                                    {
                                        projeto.AddOS(new OS()
                                        {
                                            GUID    = Guid.NewGuid().ToString(),
                                            NUMERO  = numeroDocSNCLavalin.OS,
                                            Projeto = projeto
                                        });
                                    }

                                    if (projeto.ListaAreas.FirstOrDefault(x => x.NUMERO == numeroDocSNCLavalin.AREA) == null)
                                    {
                                        projeto.AddArea(new Area()
                                        {
                                            GUID    = Guid.NewGuid().ToString(),
                                            NUMERO  = numeroDocSNCLavalin.AREA,
                                            Projeto = projeto
                                        });
                                    }

                                    contextoProjeto.Update(projeto);
                                    contextoProjeto.Commit();
                                }
                                else
                                {
                                    projeto = new Projeto()
                                    {
                                        GUID   = Guid.NewGuid().ToString(),
                                        NUMERO = numeroDocSNCLavalin.PROJETO
                                    };

                                    projeto.AddOS(new OS()
                                    {
                                        GUID    = Guid.NewGuid().ToString(),
                                        NUMERO  = numeroDocSNCLavalin.OS,
                                        Projeto = projeto
                                    });

                                    projeto.AddArea(new Area()
                                    {
                                        GUID    = Guid.NewGuid().ToString(),
                                        NUMERO  = numeroDocSNCLavalin.AREA,
                                        Projeto = projeto
                                    });


                                    contextoProjeto.Insert(projeto);
                                    contextoProjeto.Commit();
                                }
                            }

                            docGuid = Guid.NewGuid().ToString();


                            Planilha planilha = null;

                            using (var contextoPlanilha = DIContainer.Instance.AppContainer.Resolve <AppServiceBase <Planilha> >())
                            {
                                contextoPlanilha.Start();
                                planilha = contextoPlanilha.ReturnByGUID(p_guid_planilha);
                            }

                            documento = new ListaVerificacao()
                            {
                                GUID           = docGuid,
                                NUMERO         = "1",
                                DOC_VERIFICADO = numeroDocSNCLavalin.ToString(),
                                Planilha       = planilha,
                                Projeto        = projeto,
                                OS             = projeto.ListaOSs.Last(),
                                Area           = projeto.ListaAreas.Last()
                            };

                            contextoDocumento.Insert(documento);
                            contextoDocumento.Commit();

                            numeroDocSNCLavalin.GUID = docGuid;
                            using (var contextoNumeroDocSNCLavalin = DIContainer.Instance.AppContainer.Resolve <AppServiceBase <NumeroDocSNCLavalin> >())
                            {
                                contextoNumeroDocSNCLavalin.Start();
                                contextoNumeroDocSNCLavalin.Insert(numeroDocSNCLavalin);
                                contextoNumeroDocSNCLavalin.Commit();
                            }

                            _passou = true;

                            docViewModel.GuidDocumento = docGuid;
                            Session["GuidDoc"]         = docGuid;
                        }
                        else
                        {
                            docGuid = documento.GUID;

                            Session["GuidDoc"] = docGuid;

                            var listaRevisoes = documento.ListaRevisoes.Distinct().ToList();
                            documentoContemRevisoes = listaRevisoes.Count > 0;

                            existemRevisoesNaoConfirmadas = listaRevisoes.Exists(x => x.CONFIRMADO == 0);

                            _passou = true;
                        }
                    }
                }

                string guid_logPC   = HttpContext.User.Identity.Name.Split('\\')[1].ToUpper();
                bool   isVerficador = getUsuario(guid_logPC).GetBoolIsVerificador();

                if (!isVerficador)
                {
                    TempData["LayoutUsuario"] = "_LayoutNoVerificador";
                }
                else
                {
                    if (documentoContemRevisoes)
                    {
                        if (existemRevisoesNaoConfirmadas)
                        {
                            TempData["LayoutUsuario"] = "_LayoutAddRevisao";
                        }
                        else
                        {
                            TempData["LayoutUsuario"] = "_LayoutNoConfirm";
                        }
                    }
                    else
                    {
                        TempData["LayoutUsuario"] = "_LayoutDocumentoNovo";
                    }
                }



                if (_passou == true)
                {
                    var urlBuilder = new UriBuilder(Request.Url.AbsoluteUri)
                    {
                        Path  = Url.Action("IndexLD", "ListaDocumento"),
                        Query = null,
                    };

                    //Uri uri = urlBuilder.Uri;
                    string url = urlBuilder.ToString();

                    string env = url + "?guidDocumento=" + docGuid;
                    return(Content(env));
                }

                return(Content("Preenchimento inadequado."));
            }
        }
Example #19
0
        public ActionResult Index(DocViewModel docViewModel)
        {
            if (ModelState.IsValid)
            {
                QryBuscaNumeroDoc qryBuscaNumeroDoc = new QryBuscaNumeroDoc();

                NumeroDocSNCLavalin numero = new NumeroDocSNCLavalin(
                    docViewModel.Projeto,
                    docViewModel.OS,
                    docViewModel.Area,
                    docViewModel.SiglaDisciplina,
                    docViewModel.TipoDocumento,
                    docViewModel.Sequencial
                    );

                var num = qryBuscaNumeroDoc.VerificaNumeroNoBanco(numero.ToString());

                //QryListaVerificacao qryListaVerificacao = QryListaVerificacao.Instancia(_baseUrl, docViewModel.GuidDocumento);

                if (num != null)
                {
                    var lvLocal = new LV_NoSQL().BuscarLV_ViewModel(num.GUID_LV);
                    if (lvLocal == null)
                    {
                        var lv = MySQLConsultaListaVerificacao.ObtemListaSimples(num);
                        if (lv != null)
                        {
                            var estado = QryListaVerificacao.Instancia(lv.GUID).ObtemEstadoRevisoes();

                            Session["PossuiRevisoes"] = estado.ExistemRevisoesNesteDocumento;
                            Session["ExistemRevisoesNaoConfirmadas"] = estado.PossuiRevisoesNaoConfirmadas;

                            Session["AbriuNaoConfirmouAinda"] = true;
                            return(RedirectToAction("ListaDoc", "Lista", new { id = lv.GUID }));
                        }

                        return(View());
                    }
                    else
                    {
                        var estado = QryListaVerificacao.Instancia(docViewModel.GuidDocumento).ObtemEstadoRevisoes();

                        Session["PossuiRevisoes"] = estado.ExistemRevisoesNesteDocumento;
                        Session["ExistemRevisoesNaoConfirmadas"] = estado.PossuiRevisoesNaoConfirmadas;

                        Session["AbriuNaoConfirmouAinda"] = true;
                        return(RedirectToAction("ListaDoc", "Lista", new { id = num.GUID_LV }));
                    }
                }
                else
                {
                    string novoGuid = Guid.NewGuid().ToString();

                    ValoresComandoCriaLV valor = new ValoresComandoCriaLV()
                    {
                        NovoGuidLV   = novoGuid,
                        GuidPlanilha = docViewModel.GuidPlanilha,
                        NumeroSNC    = numero.ToString()
                    };

                    new CmdSalvaListaVerificacao().SalvaLV(valor);//(_baseUrl).SalvaLV(valor);



                    Session["PossuiRevisoes"] = false;

                    Session["AbriuNaoConfirmouAinda"] = true;
                    TempData["DocumentoNovo"]         = true;
                    Session["Projeto"] = new QryProjetos().GetProjetoApp(((ProjetoVM)Session["Projeto"]).GUID);
                    return(RedirectToAction("ListaDoc", "Lista", new { id = novoGuid }));
                }
            }



            return(View());
        }
Example #20
0
        // GET: Doc
        public ActionResult Index(string query, string docType, string from, string to)
        {
            var model = new DocIndexViewModel();

            model.Query   = (query != null) ? query : "";
            model.DocType = docType;
            model.From    = from;
            model.To      = to;

            bool docTypeIsSet = (docType != null && docType.Length > 0);

            var queryWithFilters = model.Query;

            queryWithFilters += (docTypeIsSet && queryWithFilters.Length > 0) ? ", " : "";
            queryWithFilters += (docTypeIsSet) ? " type:" + docType : "";

            DateTime fromDate;
            DateTime toDate;
            int?     diffFomDays = null;
            int?     diffToDays  = null;

            if (DateTime.TryParse(from, out fromDate))
            {
                diffFomDays = (fromDate - DateTime.Now.Date).Days;
            }

            if (DateTime.TryParse(to, out toDate))
            {
                diffToDays = (toDate - DateTime.Now.Date).Days;
            }

            var docs = new List <dynamic>();

            if (queryWithFilters.Length > 0 || diffFomDays.HasValue || diffToDays.HasValue)
            {
                docs = DocRepository.Search(queryWithFilters, diffFomDays, diffToDays, 50);
            }
            else
            {
                docs = DocRepository.Index();
            }

            var list = new List <DocViewModel>();

            foreach (dynamic doc in docs)
            {
                var     docModel = new DocViewModel();
                DocType type     = DocTypeRepository.Read(Guid.Parse(doc.type));
                docModel.Id   = Guid.Parse(doc.id);
                docModel.Type = type.Name;
                try
                {
                    docModel.Name = doc.name;
                } catch (Exception e)
                {
                    docModel.Name = "";
                }

                docModel.MetaTags = MetaTagRepository.ReadMany(type.MetaTags);
                list.Add(docModel);
            }
            model.Docs = list;

            model.DocTypes = DocTypeRepository.Index();

            return(View(model));
        }
Example #21
0
        public IActionResult Search([Bind] string id)
        {
            ThemeHelper.HandleTheme(Request, ViewData);
            string search = id?.ToLowerFast().Replace("%2f", "/");

            if (string.IsNullOrWhiteSpace(search))
            {
                search = "Nothing";
            }
            List <WebsiteMetaObject> best       = new List <WebsiteMetaObject>();
            List <WebsiteMetaObject> additional = new List <WebsiteMetaObject>();

            foreach (WebsiteMetaObject obj in MetaSiteCore.AllObjects)
            {
                if (obj.MatchesSearch(search))
                {
                    best.Add(obj);
                }
                else if (obj.AllSearchableText.Contains(search))
                {
                    additional.Add(obj);
                }
            }
            best       = best.OrderBy(obj => obj.ObjectGeneric.Type.Name).ToList();
            additional = additional.OrderBy(obj => obj.ObjectGeneric.Type.Name).ToList();
            StringBuilder outText = new StringBuilder();

            outText.Append("<center>");
            if (best.Count > 0)
            {
                string lastType = "";
                outText.Append("<h4>Best Results</h4>");
                foreach (WebsiteMetaObject obj in best)
                {
                    if (obj.ObjectGeneric.Type.Name != lastType)
                    {
                        lastType = obj.ObjectGeneric.Type.Name;
                        outText.Append($"<br><h4>{lastType}</h4><br>");
                    }
                    outText.Append(obj.HtmlContent);
                }
            }
            if (additional.Count > 0)
            {
                if (best.Count > 0)
                {
                    outText.Append("<br><hr><br>");
                }
                string lastType = "";
                outText.Append("<h4>Imperfect Results</h4>");
                foreach (WebsiteMetaObject obj in additional)
                {
                    if (obj.ObjectGeneric.Type.Name != lastType)
                    {
                        lastType = obj.ObjectGeneric.Type.Name;
                        outText.Append($"<br><h4>{lastType}</h4><br>");
                    }
                    outText.Append(obj.HtmlContent);
                }
            }
            outText.Append("</center>");
            DocViewModel model = new DocViewModel()
            {
                IsAll          = search == null,
                CurrentlyShown = best.Count + additional.Count,
                Max            = MetaSiteCore.AllObjects.Count,
                Content        = new HtmlString(outText.ToString()),
                SearchText     = search
            };

            return(View(model));
        }
        public void Render(FlowDocument FlowDoc, string Caption, string DateStr, MemoryStream UserHeadStream, Lib.MemberInfoEntity PCurMember)
        {
            if (PCurMember == null)
            {
                return;
            }

            DocVM = new DocViewModel
            {
                CurMember = PCurMember
            };

            //设置标题

            if (string.IsNullOrWhiteSpace(Caption))
            {
                DocVM.Caption = "事 业 编 制 人 员 基 本 情 况 表";
            }
            else
            {
                DocVM.Caption = Caption;
            }
            DocVM.DateStr = DateStr;

            //设置员工头像
            if (UserHeadStream != null)
            {
                //TableCell Cell_UserPhoto = FlowDoc.FindName("UserPhotoCell") as TableCell;
                //Paragraph TParagraph = new Paragraph
                //{
                //    TextAlignment = TextAlignment.Center
                //};
                //ImageSourceConverter imageSourceConverter = new ImageSourceConverter();
                //ImageBrush HeadImgBrush = new ImageBrush((ImageSource)imageSourceConverter.ConvertFrom(UserHeadStream));
                //Border HeadImg = new Border
                //{
                //    Width = 120,
                //    Height = 170,
                //    Background = HeadImgBrush
                //};
                //TParagraph.Inlines.Add(HeadImg);
                //Cell_UserPhoto.Blocks.Add(TParagraph);
            }
            //填充职工简历
            var TempResumes = DataMemberResumeRepository.GetRecords(new Lib.MemberResumeSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = DocVM.CurMember.Id
            }).Result;
            TableCell Cell_Resume = FlowDoc.FindName("Cell_Resume") as TableCell;

            if (TempResumes != null && TempResumes.Count() > 0)
            {
                List <Lib.MemberResume> MemberResumes = TempResumes.OrderBy(x => x.BeginDate).ToList();
                for (int i = 0; i < MemberResumes.Count; i++)
                {
                    Paragraph TParagraph = new Paragraph();
                    TParagraph.TextAlignment = TextAlignment.Left;
                    TParagraph.Inlines.Add(new Run(MemberResumes[i].BeginDate.ToString("yyyy年MM月—")));
                    TParagraph.Inlines.Add(new Run(MemberResumes[i].EndDate.ToString("yyyy年MM月")));
                    TParagraph.Inlines.Add(new Run(MemberResumes[i].Content));
                    if (!string.IsNullOrWhiteSpace(MemberResumes[i].Remark))
                    {
                        TParagraph.Inlines.Add(new Run($"({MemberResumes[i].Remark})"));
                    }
                    Cell_Resume.Blocks.Add(TParagraph);
                }
            }
            else
            {
                Paragraph TParagraph = new Paragraph();
                TParagraph.TextAlignment = TextAlignment.Left;
                TParagraph.Inlines.Add(new TextBlock()
                {
                    Height = 400
                });
                Cell_Resume.Blocks.Add(TParagraph);
            }
            //填充职工奖惩信息
            var TempPrizePunish = DataMemberPrizePunishRepository.GetRecords(new Lib.MemberPrizePunishSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = DocVM.CurMember.Id
            }).Result;

            if (TempPrizePunish != null && TempPrizePunish.Count() > 0)
            {
                TableCell Cell_PrizePunish = FlowDoc.FindName("Cell_PrizePunish") as TableCell;
                List <Lib.MemberPrizePunishEntity> MemberPrizePunishs = TempPrizePunish.OrderByDescending(x => x.PrizrOrPunishType).ToList();
                for (int i = 0; i < MemberPrizePunishs.Count; i++)
                {
                    Paragraph TParagraph = new Paragraph();
                    TParagraph.TextAlignment = TextAlignment.Left;
                    TParagraph.Inlines.Add(new Run(MemberPrizePunishs[i].OccurDate.ToString("yyyy年MM月")));
                    TParagraph.Inlines.Add(new Run(MemberPrizePunishs[i].PrizrOrPunishName));
                    TParagraph.Inlines.Add(new Run(MemberPrizePunishs[i].PrizrOrPunishUnit));
                    if (!string.IsNullOrWhiteSpace(MemberPrizePunishs[i].Remark))
                    {
                        TParagraph.Inlines.Add(new Run($"({MemberPrizePunishs[i].Remark})"));
                    }
                    Cell_PrizePunish.Blocks.Add(TParagraph);
                }
            }
            //填充职工年度考核信息
            var TempAppraise = DataMemberAppraiseRepository.GetRecords(new Lib.MemberAppraiseSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = DocVM.CurMember.Id
            }).Result;

            if (TempAppraise != null && TempAppraise.Count() > 0)
            {
                TableCell Cell_Appraise = FlowDoc.FindName("Cell_Appraise") as TableCell;
                List <Lib.MemberAppraise> MemberAppraises = TempAppraise.OrderByDescending(x => x.Year).ToList();
                for (int i = 0; i < MemberAppraises.Count; i++)
                {
                    Paragraph TParagraph = new Paragraph();
                    TParagraph.TextAlignment = TextAlignment.Left;
                    TParagraph.Inlines.Add(new Run(MemberAppraises[i].Year));
                    TParagraph.Inlines.Add(new Run(MemberAppraises[i].Result));
                    if (!string.IsNullOrWhiteSpace(MemberAppraises[i].Remark))
                    {
                        TParagraph.Inlines.Add(new Run($"({MemberAppraises[i].Remark})"));
                    }
                    Cell_Appraise.Blocks.Add(TParagraph);
                }
            }
            //填充职工社会关系
            var TempRelations = DataMemberRelationsRepository.GetRecords(new Lib.MemberRelationsSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = DocVM.CurMember.Id
            }).Result;

            if (TempRelations != null && TempRelations.Count() > 0)
            {
                TableCell Cell_Appraise = FlowDoc.FindName("Cell_Relations") as TableCell;
                List <Lib.MemberRelations> MemberRelationses = TempRelations.OrderBy(x => x.OrderIndex).ToList();
                for (int i = 0; i < MemberRelationses.Count; i++)
                {
                    Paragraph TParagraph = new Paragraph();
                    TParagraph.TextAlignment = TextAlignment.Left;
                    TParagraph.Inlines.Add(new Run(MemberRelationses[i].Relation));
                    TParagraph.Inlines.Add(new Run(MemberRelationses[i].Name));
                    TParagraph.Inlines.Add(new Run(MemberRelationses[i].UnitName));
                    TParagraph.Inlines.Add(new Run(MemberRelationses[i].Role));
                    if (!string.IsNullOrWhiteSpace(MemberRelationses[i].Remark))
                    {
                        TParagraph.Inlines.Add(new Run($"({MemberRelationses[i].Remark})"));
                    }
                    Cell_Appraise.Blocks.Add(TParagraph);
                }
            }

            FlowDoc.DataContext = DocVM;
        }
Example #23
0
        public static List <DocViewModel> GetMostRecentDocumentsForDocType(Guid docType, int diffDays)
        {
            // Filter: type
            var queryBase = new Nest.MatchQuery();

            queryBase.Field      = new Nest.Field();
            queryBase.Field.Name = "type";
            queryBase.Query      = docType.ToString();

            var queries = new List <Nest.QueryContainer>();

            queries.Add(new Nest.QueryContainer(queryBase));

            // Filter: DateRange
            var queryRange = new Nest.DateRangeQuery();

            queryRange.Field                = new Nest.Field();
            queryRange.Field.Name           = "datum";
            queryRange.GreaterThanOrEqualTo = DateTime.Now.ToUniversalTime().Date.AddDays(diffDays);
            queryRange.LessThanOrEqualTo    = DateTime.Now.ToUniversalTime().Date.AddDays(0);

            queries.Add(new Nest.QueryContainer(queryRange));

            var res = ElasticClientFactory.Client.Search <ExpandoObject>(s => s
                                                                         .Index("docs")
                                                                         .From(0)
                                                                         .Size(1000)
                                                                         .Query(q => q
                                                                                .Bool(b => b
                                                                                      .Must(queries.ToArray())
                                                                                      )
                                                                                )
                                                                         .Aggregations(a =>
                                                                                       a.Terms("tagcloud", ta => ta.Field("name"))
                                                                                       )
                                                                         );

            var list = new List <dynamic>();

            if (res.Total > 0)
            {
                list = res.Hits.Select(h => h.Source as dynamic).ToList();
            }

            var docViewModelList = new List <DocViewModel>();

            foreach (dynamic doc in list)
            {
                var     docModel = new DocViewModel();
                DocType type     = DocTypeRepository.Read(Guid.Parse(doc.type));
                docModel.Id   = Guid.Parse(doc.id);
                docModel.Type = type.Name;
                try
                {
                    docModel.Name = doc.name;
                }
                catch (Exception e)
                {
                    docModel.Name = "";
                }

                docModel.MetaTags = MetaTagRepository.ReadMany(type.MetaTags);
                docViewModelList.Add(docModel);
            }

            var docsPerNameList = new Dictionary <string, long>();

            foreach (var tag in (res.Aggregations["tagcloud"] as Nest.BucketAggregate).Items)
            {
                var nestTag = tag as Nest.KeyedBucket;
                docsPerNameList.Add(nestTag.Key, nestTag.DocCount.Value);
            }

            var rankedList = new List <DocViewModel>();
            var i          = 0;

            foreach (var docName in docsPerNameList.Keys)
            {
                if (i < 10)
                {
                    var doc = docViewModelList.FirstOrDefault(d => d.Name == docName);
                    doc.DocCountInDb = (int)docsPerNameList[docName];
                    rankedList.Add(doc);
                }
                else
                {
                    break;
                }
            }

            return(rankedList);
        }
Example #24
0
 /// <summary>
 /// Will start camera app to take pictures.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void documentPhotoButton_TappedAsync(object sender, TappedRoutedEventArgs e)
 {
     DocViewModel.TakeSnapshotAsync();
 }