예제 #1
0
        private void readReportImages(DataTable dstDT, DataTable dtReportInfo, string reportID, C1Report c1rpt, string domain)
        {
            List <string> listTmpFile = getFTPFiles(dtReportInfo, reportID, domain);

            int idx = 0;

            foreach (Field fld in c1rpt.Fields)
            {
                if (fld.Picture != null)
                {
                    C1.C1Report.Util.PictureHolder ph = fld.Picture as C1.C1Report.Util.PictureHolder;

                    if (ph != null && ph.IsBound)
                    {
                        if (string.Compare(ph.FieldName, ReportCommon.FIELDNAME_CREATORSIGNIMAGE, true) == 0)
                        {
                            string creater = ReportUtils.GetStringFromDataTable(dtReportInfo, ReportCommon.FIELDNAME_tbReport__Creater);
                            if (!string.IsNullOrEmpty(creater))
                            {
                                User user = _dbContext.Set <User>().Where(u => u.UniqueID == creater).FirstOrDefault();
                                if (user != null)
                                {
                                    dstDT.Rows[0][ph.FieldName] = user.SignImage;
                                }
                            }
                        }
                        else if (string.Compare(ph.FieldName, ReportCommon.FIELDNAME_FIRSTAPPROVERSIGNIMAGE, true) == 0)
                        {
                            string approver = ReportUtils.GetStringFromDataTable(dtReportInfo, ReportCommon.FIELDNAME_tbReport__FirstApprover);
                            if (!string.IsNullOrEmpty(approver))
                            {
                                User user = _dbContext.Set <User>().Where(u => u.UniqueID == approver).FirstOrDefault();
                                if (user != null)
                                {
                                    dstDT.Rows[0][ph.FieldName] = user.SignImage;
                                }
                            }
                        }
                        else if (string.Compare(ph.FieldName, ReportCommon.FIELDNAME_SUBMITTERSIGNIMAGE, true) == 0)
                        {
                            string submitter = ReportUtils.GetStringFromDataTable(dtReportInfo, ReportCommon.FIELDNAME_tbReport__Submitter);
                            if (!string.IsNullOrEmpty(submitter))
                            {
                                User user = _dbContext.Set <User>().Where(u => u.UniqueID == submitter).FirstOrDefault();
                                if (user != null)
                                {
                                    dstDT.Rows[0][ph.FieldName] = user.SignImage;
                                }
                            }
                        }
                        else if (dstDT.Columns.Contains(ph.FieldName) && idx < listTmpFile.Count)
                        {
                            dstDT.Rows[0][ph.FieldName] = File.ReadAllBytes(listTmpFile[idx]);

                            ++idx;
                        }
                    }
                }
            }
        }
예제 #2
0
        private void SetExamNumber(DataTable dataSrc)
        {
            if (!dataSrc.Columns.Contains(ReportCommon.FIELDNAME_EXAMNUMBER))
            {
                return;
            }

            string strPatientID = ReportUtils.GetStringFromDataTable(dataSrc, ReportCommon.FIELDNAME_PATIENTID);
            string strOrderGuid = ReportUtils.GetStringFromDataTable(dataSrc, ReportCommon.FIELDNAME_ORDERGUID);

            if (string.IsNullOrEmpty(strPatientID) || string.IsNullOrEmpty(strOrderGuid))
            {
                return;
            }

            int examNo = GetPatientExamNo(strPatientID, strOrderGuid);

            if (examNo == 0)
            {
                return;
            }

            foreach (DataRow dr in dataSrc.Rows)
            {
                dr[ReportCommon.FIELDNAME_EXAMNUMBER] = examNo;
            }
        }
예제 #3
0
        private List <string> getFTPFiles(DataTable dtReportInfo, string reportID, string domain)
        {
            List <string>     listTmpFile    = new List <string>();
            List <ReportFile> reportFileList = _dbContext.Set <ReportFile>().Where(p => p.ReportID == reportID).OrderBy(p => p.ImagePosition).ToList();

            try
            {
                if (reportFileList == null || reportFileList.Count < 1)
                {
                    return(listTmpFile);
                }

                string tmpFolder = GenerateTempSaveFolder();

                string accNo      = ReportUtils.GetStringFromDataTable(dtReportInfo, ReportCommon.FIELDNAME_ACCNO);
                string reportGuid = ReportUtils.GetStringFromDataTable(dtReportInfo, ReportCommon.FIELDNAME_tbReport__ReportGuid);
                string tmpPath    = System.IO.Path.Combine(tmpFolder, "images");

                if (!System.IO.Directory.Exists(tmpPath))
                {
                    System.IO.Directory.CreateDirectory(tmpPath);
                }

                //
                // Start to Ftp
                FtpClient ftpClient = getFTPObject(domain);
                if (ftpClient != null)
                {
                    foreach (ReportFile reportFile in reportFileList)
                    {
                        string fguid         = reportFile.UniqueID;
                        string fname         = reportFile.FileName;
                        string rpath         = reportFile.RelativePath;
                        int    fType         = reportFile.fileType.Value;
                        int    showWidth     = reportFile.ShowWidth.Value;
                        int    showHeight    = reportFile.ShowHeight.Value;
                        int    imageposition = reportFile.ImagePosition.Value;

                        if (1 == fType)
                        {
                            string localFilePath = tmpPath + "\\" + fname;

                            if (!File.Exists(localFilePath))
                            {
                                ftpClient.DownloadFile(rpath + "\\" + fname, localFilePath);
                            }
                            if (System.IO.File.Exists(localFilePath))
                            {
                                listTmpFile.Add(localFilePath);
                            }
                        }
                    }

                    ftpClient.Close();
                }
            }
            catch (Exception ex)
            {
                string msg = "Fail to get the images from FTP server! Message=" + ex.Message;
            }

            return(listTmpFile);
        }
예제 #4
0
        private string GetStringForPrinting(DataTable dt, string colName)
        {
            if (dt == null || dt.Rows.Count < 1 || !dt.Columns.Contains(colName) ||
                colName == null || colName.Length < 1)
            {
                System.Diagnostics.Debug.Assert(false);

                return("");
            }

            string key = colName.ToUpper().Trim();
            string ret = "";

            object objValue = dt.Rows[0][key];
            string fldValue = "";

            var dictionaries = _dbContext.Set <Dictionary>().ToList()
                               .Select(d => Mapper.Map <Dictionary, DictionaryDto>(d)).ToList();
            var groupedDVs = _dbContext.Set <DictionaryValue>().ToList()
                             .Select(dv => Mapper.Map <DictionaryValue, DictionaryValueDto>(dv)).GroupBy(d => d.Tag).ToList();

            dictionaries.ForEach(d =>
            {
                var group = groupedDVs.FirstOrDefault(g => g.Key == d.Tag);
                if (group != null)
                {
                    d.Values = group.Select(g => g).ToList();
                }
            });

            if (objValue.GetType() == System.Type.GetType("System.Byte[]"))
            {
                Byte[] buff = objValue as Byte[];

                fldValue = ReportUtils.GetStringFromBytes(buff);
            }
            if (objValue.GetType() == System.Type.GetType("System.DateTime"))
            {
                DateTime dateTime = Convert.ToDateTime(objValue);

                fldValue = dateTime.ToString("yyyy/MM/dd HH:mm:ss");
            }
            else
            {
                fldValue = objValue.ToString();
            }

            if (objValue.GetType() != System.Type.GetType("System.DateTime") &&
                (key.StartsWith("tbProcedureCode") || key.StartsWith("tbProcedureCode")))
            {
                ret = ReportUtils.GetStringFromDataTable(dt, colName);
                if (ReportUtils.isNeedLocalizationAsUserName(colName))
                {
                    UserDto userDto = null;
                    var     user    = _dbContext.Set <User>().Where(p => p.UniqueID == fldValue).FirstOrDefault();
                    if (user != null)
                    {
                        userDto = Mapper.Map <User, UserDto>(user);
                    }
                    if (userDto != null)
                    {
                        ret = userDto.LocalName;
                    }
                    else
                    {
                        ret = fldValue;
                    }
                }
            }
            else if (key.EndsWith("SITE"))
            {
                var siteDto = _dbContext.Set <Site>().Where(p => p.SiteName.Equals(fldValue, StringComparison.OrdinalIgnoreCase))
                              .ToList().Select(d => Mapper.Map <Site, SiteDto>(d)).FirstOrDefault();
                if (siteDto != null)
                {
                    ret = siteDto.Alias;
                }
                else
                {
                    ret = fldValue;
                }
            }
            else if (key.EndsWith("CURRENTAGE"))
            {
                ret = ReportUtils.LocalizeCurrentAge(fldValue, dictionaries);
            }
            else if (ReportUtils.isNeedLocalizationAsUserName(colName))
            {
                UserDto userDto = null;
                var     user    = _dbContext.Set <User>().Where(p => p.UniqueID == fldValue).FirstOrDefault();
                if (user != null)
                {
                    userDto = Mapper.Map <User, UserDto>(user);
                }
                if (userDto != null)
                {
                    ret = userDto.LocalName;
                }
                else
                {
                    ret = fldValue;
                }
            }
            else if (key.EndsWith("BEDSIDE") || key.EndsWith("THREEDREBUILD"))
            {
                ret = ReportUtils.GetDictionaryText(dictionaries, (int)DictionaryTag.YesNo, fldValue);
            }
            else if (key.EndsWith("ISPOSITIVE"))
            {
                ret = ReportUtils.GetDictionaryText(dictionaries, (int)DictionaryTag.Positive, fldValue);
            }
            else
            {
                ret = fldValue;
            }

            return(ret);
        }