コード例 #1
0
        public static ValueHelpViewModel GetValueHelpTextDis(string valueType, string valueText, string status = "")
        {
            ValueHelpViewModel valueHelp = new ValueHelpViewModel();

            try
            {
                valueHelp = ValueHelpService.GetValueHelp(valueType, status).Single(m => m.ValueText == valueText);
            }
            catch (Exception ex)
            {
            }

            return(valueHelp);
        }
コード例 #2
0
        public static List <AttachmentViewModel> GetAttachmentList(AttachmentViewModel option)
        {
            List <AttachmentViewModel> attachmentViewModelList = new List <AttachmentViewModel>();

            try
            {
                var documentTypeValueHelp = new List <ValueHelpViewModel>();

                if (!string.IsNullOrEmpty(option.DocumentTypeValueType))
                {
                    documentTypeValueHelp = ValueHelpService.GetValueHelp(option.DocumentTypeValueType);
                }

                using (var context = new PYMFEEEntities())
                {
                    List <Attachment> attachmentList = new List <Attachment>();

                    //if(option.DataID != 0)
                    //{
                    //    attachmentList = (from m in context.Attachments where m.ProcessCode == option.ProcessCode && m.DataID == option.DataID select m).OrderBy(m => m.ID).ToList();
                    //}

                    if (!string.IsNullOrEmpty(option.DataKey))
                    {
                        attachmentList = (from m in context.Attachments where m.ProcessCode == option.ProcessCode && m.DataKey == option.DataKey select m).OrderBy(m => m.ID).ToList();
                    }

                    foreach (var attachment in attachmentList)
                    {
                        if (!string.IsNullOrEmpty(option.AttachmentGroup))
                        {
                            if (!string.Equals(attachment.AttachmentGroup, option.AttachmentGroup, StringComparison.OrdinalIgnoreCase))
                            {
                                continue;
                            }
                        }

                        AttachmentViewModel attachmentViewModel = new AttachmentViewModel();

                        MVMMappingService.MoveData(attachment, attachmentViewModel);

                        //Download url
                        UrlHelper helper        = new UrlHelper(HttpContext.Current.Request.RequestContext);
                        string    downloadUrl   = helper.Action("DownloadFile", "Attachment", new { Area = "Shared" });
                        string    downloadParam = option.DocumentFilePath + "/" + attachment.SavedFileName;

                        //Encoding parameter
                        var plainTextBytes = System.Text.Encoding.Unicode.GetBytes(downloadParam);
                        var encodedParam   = System.Convert.ToBase64String(plainTextBytes);

                        downloadUrl = downloadUrl + "?downloadParam=" + encodedParam;

                        attachmentViewModel.DownloadURL           = downloadUrl;
                        attachmentViewModel.DocumentTypeValueHelp = documentTypeValueHelp;

                        attachmentViewModelList.Add(attachmentViewModel);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(attachmentViewModelList);
        }