Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="src"></param>
        /// <returns></returns>
        public static string LocalizeCurrentAge(string src, IEnumerable <DictionaryDto> dictionaries)
        {
            if (src == null)
            {
                return("");
            }

            try
            {
                string   strTemp = src;
                string[] split   = strTemp.Split(new Char[] { ' ' });
                if (split.Length < 2)
                {
                    throw new Exception("Invalid current age");
                }

                //src = split[0] + GetLanguage(split[1]);
                //src = split[0] + DictionaryManager.Instance.GetText((int)DictionaryTag.AgeUnit, split[1]);
                src = split[0] + ReportUtils.GetDictionaryText(dictionaries, (int)DictionaryTag.AgeUnit, split[1]);;
            }
            catch (Exception ex)
            {
                //  logger.Error((long)ModuleEnum.Register_Client, ModuleInstanceName.Registration, 53, ex.Message, Application.StartupPath.ToString(), (new System.Diagnostics.StackFrame(true)).GetFileName(),

                //   (new System.Diagnostics.StackFrame(true)).GetFileLineNumber());
            }

            return(src);
        }
Esempio n. 2
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);
        }