Esempio n. 1
0
        public object RecordingData(string value, long siteId)
        {
            var    tenantId      = Sessions.TenantId();
            var    userHash      = SiteInfo.TenantCaches[tenantId].UserHash;
            object recordingData = value;

            if (UserColumn)
            {
                if (SiteUserHash == null)
                {
                    SiteUserHash = SiteInfo.SiteUsers(tenantId, siteId)
                                   .Where(o => userHash.ContainsKey(o))
                                   .ToDictionary(o => userHash[o].Name, o => o);
                }
                recordingData = SiteUserHash.Get(value);
            }
            else if (TypeCs == "Comments")
            {
                return(new Comments().Prepend(value).ToJson());
            }
            else if (HasChoices())
            {
                if (ChoiceValueHash == null)
                {
                    ChoiceValueHash = ChoiceHash
                                      .GroupBy(o => o.Value)
                                      .Select(o => o.First())
                                      .ToDictionary(o => o.Value.Value, o => o.Key);
                }
                recordingData = ChoiceValueHash.Get(value);
            }
            if (recordingData == null)
            {
                return(null);
            }
            switch (TypeName)
            {
            case "bit": return(recordingData.ToBool());

            case "int": return(recordingData.ToInt());

            case "bigint": return(recordingData.ToLong());

            case "float": return(recordingData.ToFloat());

            case "decimal": return(recordingData.ToDecimal());

            case "datetime": return(recordingData.ToDateTime().ToUniversal());

            default: return(recordingData);
            }
        }
Esempio n. 2
0
        public string RecordingData(string value, long siteId)
        {
            var tenantId      = Sessions.TenantId();
            var userHash      = SiteInfo.TenantCaches[tenantId].UserHash;
            var recordingData = value;

            if (UserColumn)
            {
                if (SiteUserHash == null)
                {
                    SiteUserHash = SiteInfo.SiteUsers(tenantId, siteId)
                                   .Where(o => userHash.ContainsKey(o))
                                   .ToDictionary(o => userHash[o].Name, o => o);
                }
                var userId = SiteUserHash.Get(value);
                recordingData = userId != 0
                    ? userId.ToString()
                    : User.UserTypes.Anonymous.ToInt().ToString();
            }
            else if (TypeCs == "Comments")
            {
                return(new Comments().Prepend(value).ToJson());
            }
            else if (HasChoices())
            {
                if (ChoiceValueHash == null)
                {
                    ChoiceValueHash = ChoiceHash
                                      .GroupBy(o => o.Value.Text)
                                      .Select(o => o.First())
                                      .ToDictionary(o => o.Value.Text, o => o.Key);
                }
                recordingData = ChoiceValueHash.Get(value) ?? value;
            }
            return(recordingData ?? string.Empty);
        }
Esempio n. 3
0
        private void SetChoiceHash(
            int tenantId,
            long siteId,
            Dictionary <string, IEnumerable <string> > linkHash,
            IEnumerable <string> searchIndexes,
            int index,
            string line)
        {
            switch (line)
            {
            case "[[Depts]]":
                SiteInfo.TenantCaches[tenantId].DeptHash
                .Where(o => o.Value.TenantId == tenantId)
                .ForEach(o => AddToChoiceHash(
                             o.Key.ToString(),
                             SiteInfo.Dept(o.Key).Name));
                break;

            case "[[Users]]":
                SiteInfo.SiteUsers(tenantId, siteId)
                .ToDictionary(o => o.ToString(), o => SiteInfo.UserName(o))
                .Where(o => searchIndexes?.Any() != true ||
                       searchIndexes.All(p =>
                                         o.Key.Contains(p) ||
                                         o.Value.Contains(p)))
                .ForEach(o => AddToChoiceHash(o.Key, o.Value));
                break;

            case "[[Users*]]":
                SiteInfo.TenantCaches[tenantId].UserHash
                .Where(o => o.Value.TenantId == tenantId)
                .ToDictionary(o => o.Key.ToString(), o => o.Value.Name)
                .Where(o => searchIndexes?.Any() != true ||
                       searchIndexes.All(p =>
                                         o.Key.Contains(p) ||
                                         o.Value.Contains(p)))
                .ForEach(o => AddToChoiceHash(o.Key, o.Value));
                break;

            case "[[TimeZones]]":
                TimeZoneInfo.GetSystemTimeZones()
                .ForEach(o => AddToChoiceHash(
                             o.Id,
                             o.StandardName));
                break;

            default:
                if (linkHash != null && linkHash.ContainsKey(line))
                {
                    linkHash[line].ForEach(value =>
                                           AddToChoiceHash(value));
                }
                else if (TypeName != "bit")
                {
                    if (searchIndexes == null ||
                        searchIndexes.All(o => line.Contains(o)))
                    {
                        AddToChoiceHash(line);
                    }
                }
                else
                {
                    AddToChoiceHash((index == 0).ToOneOrZeroString(), line);
                }
                break;
            }
        }