public async Task <DictionaryEntity <int> > ExecuteAsync(DictionaryType dictionaryType, int id)
        {
            var repo = Uow.GetRepository();

            var     entityClrType = repo.GetEntityClrType(dictionaryType.ToString());
            dynamic entity        = Activator.CreateInstance(entityClrType);

            IQueryable dicData = repo.AsQueriable(entity);

            return(await dicData.Cast <DictionaryEntity <int> >().FirstOrDefaultAsync(r => r.Id == id));
        }
        public async Task <List <DictionaryEntity <int> > > ExecuteAsync(DictionaryType dictionaryType, List <string> codes)
        {
            var repo = Uow.GetRepository();

            var     entityClrType = repo.GetEntityClrType(dictionaryType.ToString());
            dynamic entity        = Activator.CreateInstance(entityClrType);

            IQueryable dicData = repo.AsQueriable(entity);

            return(await dicData.Cast <DictionaryEntity <int> >().Where(r => codes.Contains(r.Code)).ToListAsync());
        }
示例#3
0
        /// <summary>
        /// Return the TypeScript type (as a string) for specified type.
        /// </summary>
        /// <param name="type">IType to query</param>
        /// <param name="inModelsModule">Pass true if generating the code for the models module, thus model types don't need a "models." prefix</param>
        /// <returns>TypeScript type string for type</returns>
        public static string TSType(this IType type, bool inModelsModule)
        {
            CompositeType  composite  = type as CompositeType;
            SequenceType   sequence   = type as SequenceType;
            DictionaryType dictionary = type as DictionaryType;
            PrimaryType    primary    = type as PrimaryType;
            EnumType       enumType   = type as EnumType;

            string tsType;

            if (primary != null)
            {
                tsType = primary.PrimaryTSType();
            }
            else if (enumType != null)
            {
                tsType = "string";
            }
            else if (composite != null)
            {
                // ServiceClientCredentials starts with the "msRest." prefix, so strip msRest./msRestAzure. as we import those
                // types with no module prefix needed
                var compositeName = composite.Name;
                if (compositeName.StartsWith("msRest.", StringComparison.Ordinal) || compositeName.StartsWith("msRestAzure.", StringComparison.Ordinal))
                {
                    tsType = compositeName.Substring(compositeName.IndexOf('.') + 1);
                }
                else if (inModelsModule || compositeName.Contains('.'))
                {
                    tsType = compositeName;
                }
                else
                {
                    tsType = "models." + compositeName;
                }
            }
            else if (sequence != null)
            {
                tsType = sequence.ElementType.TSType(inModelsModule) + "[]";
            }
            else if (dictionary != null)
            {
                // TODO: Confirm with Mark exactly what cases for additionalProperties AutoRest intends to handle (what about
                // additonalProperties combined with explicit properties?) and add support for those if needed to at least match
                // C# target level of functionality
                tsType = "{ [propertyName: string]: " + dictionary.ValueType.TSType(inModelsModule) + " }";
            }
            else
            {
                throw new NotImplementedException(string.Format(CultureInfo.InvariantCulture, "Type '{0}' not implemented", type));
            }

            return(tsType);
        }
示例#4
0
 public StringDictionaryArray(int length,
                              int uniqueValues,
                              ArrowBuffer nullBitmapBuffer,
                              ArrowBuffer indices,
                              ArrowBuffer dataBuffer,
                              ArrowBuffer dataOffsets,
                              int nullCount = 0, int offset = 0)
     : this(new ArrayData(DictionaryType.Default(ArrowTypeId.String), length, nullCount, offset,
                          new[] { nullBitmapBuffer, indices, dataBuffer, dataOffsets }), uniqueValues)
 {
 }
示例#5
0
        private void CreateDictionaryType()
        {
            DictionaryType           dictionaryType = new DictionaryType();
            DictionaryTypeEditWindow target         = new DictionaryTypeEditWindow(dictionaryType)
            {
                Owner = this.SourceWindow
            };

            SwitchWindows(target, true);
            this.DictionaryTypeList = ReloadDictionaryTypeList();
        }
示例#6
0
        public async Task <List <dynamic> > ExecuteAsync(DictionaryType dictionaryType)
        {
            var repo = Uow.GetRepository();

            var     entityClrType = repo.GetEntityClrType(dictionaryType.ToString());
            dynamic entity        = Activator.CreateInstance(entityClrType);

            IQueryable dictionary = repo.AsQueriable(entity);

            return(await dictionary.Cast <dynamic>().ToListAsync());
        }
示例#7
0
        public DictionaryArray(DictionaryType dataType, IArrowArray indicesArray, IArrowArray dictionary) :
            base(new ArrayData(dataType, indicesArray.Length, indicesArray.Data.NullCount, indicesArray.Data.Offset, indicesArray.Data.Buffers, indicesArray.Data.Children, dictionary.Data))
        {
            Data.EnsureBufferCount(2);

            indicesArray.Data.EnsureDataType(dataType.IndexType.TypeId);
            dictionary.Data.EnsureDataType(dataType.ValueType.TypeId);

            Indices    = indicesArray;
            Dictionary = dictionary;
        }
示例#8
0
        /// <summary>
        /// Получение элементов словаря
        /// </summary>
        /// <param name="type">тип словаря</param>
        /// <returns>элементы словаря</returns>
        public IEnumerable <string> GetDictionaryElements(DictionaryType type)
        {
            IEnumerable <string> elements;

            if (!_dictionaryCollection.TryGetValue(type, out elements))
            {
                elements = new string[] { }
            }
            ;
            return(elements);
        }
    }
示例#9
0
 public void Remove(DictionaryType type, int id)
 {
     using (var db = new UserDataContext())
     {
         var history = db.Histories.FirstOrDefault(t => t.Type == type && t.Id == id);
         if (history != null)
         {
             db.Histories.Remove(history);
             db.SaveChanges();
         }
     }
 }
        public ActionResult QueryDictionary(DictionaryType dictionary, int page = 1, int rows = 20)
        {
            var pageInfo = new PageInfo()
            {
                Page = page, Rows = rows
            };
            int           totalCount = 0;
            var           result     = svc.FilterDictionary(dictionary, out totalCount, pageInfo);
            GridJsonModel djson      = new GridJsonModel(totalCount, result);

            return(Json(djson));
        }
示例#11
0
        public async Task <List <DictionaryEntity <int> > > ExecuteAsync(DictionaryType dictionaryType)
        {
            var repo = Uow.GetRepository();

            var     entityClrType = repo.GetEntityClrType(dictionaryType.ToString());
            dynamic entity        = Activator.CreateInstance(entityClrType);

            IQueryable dictionaries = repo.AsQueriable(entity);
            var        query        = await dictionaries.Cast <DictionaryEntity <int> >().AsQueryable().ToListAsync();

            return(query.Where(r => r.GetType().GetProperty("ParentId")?.GetValue(r, null) == null).ToList());
        }
示例#12
0
        private DictionaryMappingConfigurator <TValue> CreateDictionaryConfigurator <TValue>(
            DictionaryType dictionaryType,
            Type sourceType      = null,
            Type sourceValueType = null)
        {
            var configInfo = _configInfo
                             .ForSourceType(sourceType ?? AllTypes)
                             .ForSourceValueType(sourceValueType ?? typeof(TValue))
                             .Set(dictionaryType);

            return(new DictionaryMappingConfigurator <TValue>(configInfo));
        }
示例#13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string input_term;

            if (PageAssemblyContext.Current.DisplayVersion == DisplayVersions.Web)
            {
                urlArgs    = Request.Url.Query.Substring(1);
                input_term = Strings.Clean(Request.Params["term"]);
                CdrID      = Strings.IfNull(Strings.Clean(Request.Params["id"]), Strings.Clean(Request.Params["cdrid"]));
                AudienceType   audience   = GetAudienceType(Strings.Clean(Request.Params["version"]));
                DictionaryType dictionary = GetDictionaryType(Strings.Clean(Request.Params["dictionary"]));

                //load the definition
                DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager();

                DictionaryTerm dataItem = null;

                if (!string.IsNullOrEmpty(CdrID))
                {
                    CdrID = Regex.Replace(CdrID, "^CDR0+", "", RegexOptions.Compiled);
                    // call appropriate method if dictionary type is known
                    // the language is set to English = en by default
                    if (dictionary == DictionaryType.Unknown)
                    {
                        dataItem = _dictionaryAppManager.GetTermForAudience(Convert.ToInt32(CdrID), dictionaryLanguage, "v1", audience);
                    }
                    else
                    {
                        dataItem = _dictionaryAppManager.GetTerm(Convert.ToInt32(CdrID), dictionary, dictionaryLanguage, "v1", audience);
                    }
                }

                if (dataItem != null && dataItem.Term != null)
                {
                    ActivateDefinitionView(dataItem);
                }
                else
                {
                    phDefinition.Visible = false;
                    phNoResult.Visible   = true;
                }

                // Web Analytics *************************************************
                WebAnalyticsPageLoad webAnalyticsPageLoad = new WebAnalyticsPageLoad();

                webAnalyticsPageLoad.SetChannel("Dictionary of Cancer Terms");
                webAnalyticsPageLoad.SetLanguage("en");

                webAnalyticsPageLoad.AddEvent(WebAnalyticsOptions.Events.event11); // Dictionary Term view (event11)
                litOmniturePageLoad.Text = webAnalyticsPageLoad.Tag();             // Load page load script
                // End Web Analytics *********************************************
            }
        }
        public Command CommandRemove(string command, DictionaryType type = DictionaryType.Unknown)
        {
            Command remove = FindCommand(command, type);

            if (remove == null)
            {
                return(null);
            }

            remove.Remove();

            return(remove);
        }
        public Command CommandAcquire(string command, DictionaryType type = DictionaryType.Unknown)
        {
            Command acquire = FindCommand(command, type);

            if (acquire == null)
            {
                return(null);
            }

            acquire.Acquire();

            return(acquire);
        }
示例#16
0
        /// <summary>
        /// 根据Id获取
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public DictionaryType GetById(int Id)
        {
            DictionaryType obj = NSession.Get <DictionaryType>(Id);

            if (obj == null)
            {
                throw new Exception("返回实体为空");
            }
            else
            {
                return(obj);
            }
        }
        public Command CommandExecute(string command, DictionaryType type = DictionaryType.Unknown)
        {
            Command execute = FindCommand(command, type);

            if (execute == null)
            {
                return(null);
            }

            execute.Execute();

            return(execute);
        }
示例#18
0
 public ActionResult Save(DictionaryType obj)
 {
     try
     {
         NSession.SaveOrUpdate(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
示例#19
0
            public void Visit(DictionaryType type)
            {
                Int32Array.Builder  indicesBuilder = new Int32Array.Builder().Reserve(Length);
                StringArray.Builder valueBuilder   = new StringArray.Builder().Reserve(Length);

                for (int i = 0; i < Length; i++)
                {
                    indicesBuilder.Append(i);
                    valueBuilder.Append($"{i}");
                }

                Array = new DictionaryArray(type, indicesBuilder.Build(), valueBuilder.Build());
            }
示例#20
0
 private IType NormalizeDictionaryType(DictionaryType dictionaryType)
 {
     dictionaryType.ValueType = NormalizeTypeReference(dictionaryType.ValueType);
     if (dictionaryType.ValueType.IsValueType())
     {
         dictionaryType.NameFormat = "System.Collections.Generic.IDictionary<string, {0}?>";
     }
     else
     {
         dictionaryType.NameFormat = "System.Collections.Generic.IDictionary<string, {0}>";
     }
     return(dictionaryType);
 }
 public void UpdateDictionaryType(DictionaryType dictionaryType)
 {
     Check.Argument.IsNotNull(dictionaryType, "字典类型");
     Check.Argument.IsNullOrWhiteSpace(dictionaryType.DicTypeId, "字典类型ID");
     if (_dictionaryTypeRepository.Exists(p => p.DicTypeId == dictionaryType.DicTypeId))
     {
         throw new ArgumentException("该字典类型表:不存在ID为:{0}".FormatWith(dictionaryType.DicTypeId));
     }
     dictionaryType.LastUpdatedBy = _workContext.User.UserUame;
     dictionaryType.LastUpdatedOn = DateTime.Now;
     _dictionaryTypeRepository.Modify(dictionaryType);
     _dictionaryTypeRepository.UnitOfWork.Commit();
 }
示例#22
0
        /// <summary>
        /// Generate code to perform required validation on a type
        /// </summary>
        /// <param name="type">The type to validate</param>
        /// <param name="scope">A scope provider for generating variable names as necessary</param>
        /// <param name="valueReference">A reference to the value being validated</param>
        /// <returns>The code to validate the reference of the given type</returns>
        public static string ValidateType(this IType type, IScopeProvider scope, string valueReference)
        {
            if (scope == null)
            {
                throw new ArgumentNullException("scope");
            }

            CompositeType  model      = type as CompositeType;
            SequenceType   sequence   = type as SequenceType;
            DictionaryType dictionary = type as DictionaryType;

            if (model != null && model.ShouldValidateChain())
            {
                return(CheckNull(valueReference, string.Format(CultureInfo.InvariantCulture,
                                                               "{0}.Validate();", valueReference)));
            }
            if (sequence != null && sequence.ShouldValidateChain())
            {
                var elementVar      = scope.GetVariableName("element");
                var innerValidation = sequence.ElementType.ValidateType(scope, elementVar);
                if (!string.IsNullOrEmpty(innerValidation))
                {
                    var sb = new IndentedStringBuilder();
                    sb.AppendLine("foreach (var {0} in {1})", elementVar, valueReference)
                    .AppendLine("{").Indent()
                    .AppendLine(innerValidation).Outdent()
                    .AppendLine("}");
                    return(CheckNull(valueReference, sb.ToString()));
                }
            }
            else if (dictionary != null && dictionary.ShouldValidateChain())
            {
                var valueVar        = scope.GetVariableName("valueElement");
                var innerValidation = dictionary.ValueType.ValidateType(scope, valueVar);
                if (!string.IsNullOrEmpty(innerValidation))
                {
                    var sb = new IndentedStringBuilder();
                    sb.AppendLine("if ({0} != null)", valueReference)
                    .AppendLine("{").Indent()
                    .AppendLine("foreach (var {0} in {1}.Values)", valueVar, valueReference)
                    .AppendLine("{").Indent()
                    .AppendLine(innerValidation).Outdent()
                    .AppendLine("}").Outdent()
                    .AppendLine("}");

                    return(CheckNull(valueReference, sb.ToString()));
                }
            }

            return(null);
        }
示例#23
0
 public JsonResult DeleteConfirmed(int id)
 {
     try
     {
         DictionaryType obj = GetById(id);
         NSession.Delete(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
示例#24
0
        /// <summary>
        /// Returns serialization settings reference.
        /// </summary>
        /// <param name="serializationType"></param>
        /// <returns></returns>
        public string GetSerializationSettingsReference(IType serializationType)
        {
            SequenceType   sequenceType   = serializationType as SequenceType;
            DictionaryType dictionaryType = serializationType as DictionaryType;

            if (serializationType == PrimaryType.Date ||
                (sequenceType != null && sequenceType.ElementType == PrimaryType.Date) ||
                (dictionaryType != null && dictionaryType.ValueType == PrimaryType.Date))
            {
                return("new DateJsonConverter()");
            }

            return(ClientReference + ".SerializationSettings");
        }
        /// <summary>
        /// Retrieves a single dictionary Term based on its specific Term ID.
        /// </summary>
        /// <param name="termId">The ID of the Term to be retrieved</param>
        /// <param name="dictionary">The dictionary to retreive the Term from.
        ///     Valid values are
        ///        Term - Dictionary of Cancer Terms
        ///        drug - Drug Dictionary
        ///        genetic - Dictionary of Genetics Terms
        /// </param>
        /// <param name="language">The Term's desired language.
        ///     Supported values are:
        ///         en - English
        ///         es - Spanish
        /// </param>
        /// <returns></returns>
        public TermReturn GetTerm(int termId, DictionaryType dictionary, Language language)
        {
            log.DebugFormat("Enter GetTerm( {0}, {1}, {2}).", termId, dictionary, language);

            AudienceType audience = AudienceType.Patient;

            // determine what audience to use based on the dictionary
            DictionaryManager dictionaryManager = new DictionaryManager();

            audience = dictionaryManager.GetDefaultAudienceFromDictionaryType(dictionary);

            // route to GetTerm with all arguments
            return(GetTerm(termId, dictionary, language, audience));
        }
示例#26
0
        public async Task <IActionResult> GetSelectOptions(DictionaryType dictionaryType)
        {
            if (!cache.TryGetValue(dictionaryType, out List <dynamic> dictionaries))
            {
                dictionaries = await _executor.GetQuery <GetDictionaryByEntityNameQuery>().Process(r => r.ExecuteAsync(dictionaryType));

                if (dictionaries != null)
                {
                    cache.Set(dictionaryType, dictionaries, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30)));
                }
            }

            return(Ok((dictionaries ?? throw new InvalidOperationException()).Where(d => d.IsDeleted != true)));
        }
        /// <summary>
        /// Constructs blueprint of the given <paramref name="type"/>.
        /// </summary>
        /// <param name="type">Type for which mapper being generated.</param>
        /// <param name="serializedName">Serialized name to be used.</param>
        /// <param name="parameter">Parameter of the composite type to construct the parameter constraints.</param>
        /// <param name="expandComposite">Expand composite type if <c>true</c> otherwise specify class_name in the mapper.</param>
        /// <returns>Mapper for the <paramref name="type"/> as string.</returns>
        /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception>
        /// <example>
        /// One of the example of the mapper is
        /// {
        ///   required: false,
        ///   serialized_name: 'Fish',
        ///   type: {
        ///     name: 'Composite',
        ///     polymorphic_discriminator: 'fishtype',
        ///     uber_parent: 'Fish',
        ///     class_name: 'Fish',
        ///     model_properties: {
        ///       species: {
        ///         required: false,
        ///         serialized_name: 'species',
        ///         type: {
        ///           name: 'String'
        ///         }
        ///       },
        ///       length: {
        ///         required: true,
        ///         serialized_name: 'length',
        ///         type: {
        ///           name: 'Double'
        ///         }
        ///       },
        ///       siblings: {
        ///         required: false,
        ///         serialized_name: 'siblings',
        ///         type: {
        ///           name: 'Sequence',
        ///           element: {
        ///               required: false,
        ///               serialized_name: 'FishElementType',
        ///               type: {
        ///                 name: 'Composite',
        ///                 polymorphic_discriminator: 'fishtype',
        ///                 uber_parent: 'Fish',
        ///                 class_name: 'Fish'
        ///               }
        ///           }
        ///         }
        ///       }
        ///     }
        ///   }
        /// }
        /// </example>
        public static string ConstructMapper(this IType type, string serializedName, IParameter parameter, bool expandComposite)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            var builder = new IndentedStringBuilder("  ");

            CompositeType  composite  = type as CompositeType;
            SequenceType   sequence   = type as SequenceType;
            DictionaryType dictionary = type as DictionaryType;
            PrimaryType    primary    = type as PrimaryType;
            EnumType       enumType   = type as EnumType;

            if (enumType != null && enumType.ModelAsString)
            {
                primary = new PrimaryType(KnownPrimaryType.String);
            }
            builder.AppendLine("").Indent();

            builder.AppendLine(type.AddMetaData(serializedName, parameter));

            if (primary != null)
            {
                builder.AppendLine(primary.ContructMapperForPrimaryType());
            }
            else if (enumType != null && enumType.Name != null)
            {
                builder.AppendLine(enumType.ContructMapperForEnumType());
            }
            else if (sequence != null)
            {
                builder.AppendLine(sequence.ContructMapperForSequenceType());
            }
            else if (dictionary != null)
            {
                builder.AppendLine(dictionary.ContructMapperForDictionaryType());
            }
            else if (composite != null)
            {
                builder.AppendLine(composite.ContructMapperForCompositeType(expandComposite));
            }
            else
            {
                throw new NotImplementedException(string.Format(CultureInfo.InvariantCulture, "{0} is not a supported Type.", type));
            }
            return(builder.ToString());
        }
示例#28
0
        private static JsonSchema ParseDictionaryType(Property property, DictionaryType dictionaryType, IDictionary <string, JsonSchema> definitions, IEnumerable <CompositeType> modelTypes)
        {
            JsonSchema result = new JsonSchema()
            {
                JsonType             = "object",
                AdditionalProperties = ParseType(null, dictionaryType.ValueType, definitions, modelTypes)
            };

            if (property != null)
            {
                result.Description = RemovePossibleValuesFromDescription(property.Documentation);
            }

            return(result);
        }
示例#29
0
        private DataView GetDataViewForDictionary(View view, string pk, DictionaryType dictionaryType)
        {
            switch (dictionaryType)
            {
            case DictionaryType.PlaceHolders:
                return(GetPlaceHolderDictionary());

            case DictionaryType.InternalNames:
                return(GetInternalNameDictionary(view, null));


            default:
                return(GetDisplayNameDictionary(view, pk));
            }
        }
 //init with an expected size (the larger the size lesser the collission, but memory matters!)
 public AsDictionary(DictionaryType type = DictionaryType.SeparateChaining, int initialBucketSize = 2)
 {
     if (initialBucketSize < 2)
     {
         throw new Exception("Bucket Size must be greater than 2.");
     }
     if (type == DictionaryType.SeparateChaining)
     {
         Dictionary = new SeparateChainingDictionary <K, V>(initialBucketSize);
     }
     else
     {
         Dictionary = new OpenAddressDictionary <K, V>(initialBucketSize);
     }
 }
示例#31
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (String.IsNullOrEmpty(listFormat))
            {
                return;
            }

            if (this.Page.Request["type"] != null)
            {
                dicType = Dictionary.ConvertTypeFromString(this.Page.Request["type"].Trim().ToUpper());
            }

            foreach (DictionaryItem dicItem in Dictionary.List(dicType))
            {
                writer.WriteLine(String.Format(listFormat, dicItem.Type.ToString(), dicItem.Key, dicItem.Value));
            }
        }
示例#32
0
 /// <summary>
 /// ���캯��
 /// </summary>
 /// <param name="type">�ֵ�����</param>
 public DictionaryItem(DictionaryType dicType)
 {
     type = dicType;
     key = "";
     value = "";
     children = new ArrayList();
 }
示例#33
0
 /// <summary>
 /// ���ۺ���
 /// </summary>
 /// <param name="type">�ֵ�����</param>
 /// <param name="key">�ֵ����</param>
 /// <param name="value">�ֵ�ֵ</param>
 /// <param name="dep">���</param>
 public DictionaryItem(DictionaryType dicType, string itemKey, string itemValue,int dep)
 {
     type = dicType;
     key = itemKey;
     value = itemValue;
     depth = dep;
     children = new ArrayList();
 }
示例#34
0
 /// <summary>
 /// �����ݿ�ɾ��һ���ֵ���
 /// </summary>
 /// <param name="type">�ֵ�����</param>
 /// <param name="key">����</param>
 /// <returns></returns>
 public static bool RemoveItem(DictionaryType type, string key)
 {
     /*
      DictDelete
     @type char(1),
     @key varchar(50)
      */
     try
     {
         Database.ExecuteNonQuery(CommandType.StoredProcedure, "DictDelete",
                 new SqlParameter[]{
                      Database.MakeInParam("@type",SqlDbType.Char,1,type.ToString()),
                      Database.MakeInParam("@key",SqlDbType.VarChar,50,key)
                 }
         );
     }
     catch
     {
         return false;
     }
     return true;
 }
示例#35
0
        /// <summary>
        /// �����ݿ��ȡ�ֵ��б�
        /// </summary>
        /// <param name="type">�ֵ�����</param>
        /// <returns>ArrayList</returns>
        public static ArrayList List(DictionaryType type)
        {
            /*
             DictList
             @type char(1)
             */

            ArrayList list = new ArrayList();
            SqlDataReader reader = null;

            try
            {
                DictionaryItem dicItem;
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "DictList",
                                                new SqlParameter[] { Database.MakeInParam("@type", SqlDbType.Char, 1, type.ToString()) });
                while (reader.Read())
                {
                    /*Type, [Key], [Value]*/
                    dicItem = new DictionaryItem(type);
                    dicItem.Key = reader.GetString(1);
                    dicItem.Value = reader.GetString(2);
                    list.Add(dicItem);
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return list;
        }
示例#36
0
        /// <summary>
        /// �����ݿ��ȡһ���ֵ���
        /// </summary>
        /// <param name="type">�ֵ�����</param>
        /// <param name="key">����</param>
        /// <returns></returns>
        public static DictionaryItem GetItem(DictionaryType type, string key)
        {
            /*
             DictGet
            @type char(1),
            @key varchar(50)
             */

            DictionaryItem dic = null;

            SqlDataReader reader = null;

            try
            {
                /*Type, [Key], [Value]*/
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "DictGet",
                                                new SqlParameter[] {
                                                    Database.MakeInParam("@type",SqlDbType.Char,1,type.ToString()),
                                                    Database.MakeInParam("@key",SqlDbType.VarChar,50,key)
                                                });
                if (reader.Read())
                {
                    dic = new DictionaryItem(type);
                    dic.Key = reader.GetString(1);
                    dic.Value = reader.GetString(2);
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return dic;
        }
示例#37
0
        private string GetDictionaryList(DictionaryType t, string items)
        {
            string ret = "";
            switch (t)
            {
                case DictionaryType.A:
                case DictionaryType.I:
                    ret = Dictionary.GetDictionaryNames(t, items.Split(','), ",");
                    break;
                case DictionaryType.N:
                    ret = Dictionary.GetDictionaryName(t, items);
                    break;
            }

            return Util.CutString(ret, 0, 60)+"...";
        }
示例#38
0
 public static string GetDictionaryNames(DictionaryType type, string codes, char spliter, string separator)
 {
     return GetDictionaryNames(type, codes.Split(spliter), separator);
 }
示例#39
0
        public static string GetDictionaryName(DictionaryType type,string code)
        {
            if (String.IsNullOrEmpty(code))
            {
                return "";
            }

            if (type == DictionaryType.A && code == "000000")
            {
                return "ȫ��";
            }

            if (type == DictionaryType.I && code == "000000")
            {
                return "������ҵ";
            }

            string name = "";
            XmlNode node = null;
            switch (type)
            {
                case DictionaryType.A:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='A']//Item[@key='" + code + "']");
                    break;
                case DictionaryType.C:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='C']//Item[@key='" + code + "']");
                    break;
                case DictionaryType.I:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='I']//Item[@key='" + code + "']");
                    break;
                case DictionaryType.L:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='L']//Item[@key='" + code + "']");
                    break;
                case DictionaryType.N:
                    node = DictionaryRootNode.SelectSingleNode("Dictionary[@type='N']//Item[@key='" + code + "']");
                    break;
            }

            if (node != null)
            {
                name = node.Attributes["value"].Value;
            }

            return name;
        }
示例#40
0
 public static void DepotDictionaryRemove(this DepotEntities db, Guid depotId, DictionaryType type, string name)
 {
     var dictionary = db.DepotDictionaryLoad(depotId, type).SingleOrDefault(o => o.Name == name);
     if (dictionary != null)
     {
         db.DepotDictionary.Remove(dictionary);
         db.SaveChanges();
     }
 }
示例#41
0
 public static IQueryable<DepotDictionary> DepotDictionaryLoad(this DepotEntities db, Guid depotId, DictionaryType type)
 {
     return db.DepotDictionary.Where(o => o.DepotId == depotId && o.Type == type).OrderBy(o => o.Name);
 }
示例#42
0
        /// <summary>
        /// �ݹ�XML�ڵ㵽ָ������
        /// </summary>
        /// <param name="list">ָ������</param>
        /// <param name="pNode">���ڵ�</param>
        /// <param name="depth">�ڵ����</param>
        private static void LoopNodes(ArrayList list,DictionaryType type, XmlNode pNode, int depth)
        {
            DictionaryItem item;

            foreach (XmlNode node in pNode.SelectNodes("Item"))
            {
                item = new DictionaryItem(type,node.Attributes["key"].Value, node.Attributes["value"].Value, depth);
                list.Add(item);

                if (node.HasChildNodes)
                {
                    depth++;
                    LoopNodes(item.Children,type,node, depth);
                    depth--;
                }
            }
        }
示例#43
0
 public DictionaryList()
     : base()
 {
     dicType = DictionaryType.A;
     listFormat = "";
 }
示例#44
0
 public static string GetDictionaryNames(DictionaryType type, string[] codes,string separator)
 {
     string[] names = new string[codes.Length];
     for (int i=0;i<codes.Length;i++)
     {
         names[i] = GetDictionaryName(type, codes[i]);
     }
     return String.Join(separator, names);
 }
示例#45
0
            private bool FindDictcnResult( QueryResult queryResult, DictionaryType targetType, out DictResult dictResult )
            {
                bool hasFound = false;
                dictResult = null;
                if ( queryResult != null )
                {
                    if ( queryResult.DictResultItems != null )
                    {

                        foreach ( DictResult resultItem in queryResult.DictResultItems )
                        {
                            if ( resultItem != null && resultItem.DictionaryType == targetType )
                            {
                                dictResult = resultItem;
                                hasFound = true;
                                break;
                            }
                        }
                    }
                }
                return hasFound;
            }
示例#46
0
 public static DictionaryItem AddItem(DictionaryType type, string key, string value)
 {
     DictionaryItem item = new DictionaryItem(type, key, value);
     if (item.Save())
     {
         return item;
     }
     return null;
 }
示例#47
0
 public static void DepotDictionaryAdd(this DepotEntities db, Guid depotId, DictionaryType type, string name)
 {
     if (name.None())
         return;
     var count = db.DepotDictionaryLoad(depotId, type).Count(o => o.Name == name);
     if (count == 0)
     {
         var dictionary = new DepotDictionary
         {
             DepotId = depotId,
             Type = type,
             Name = name,
             PinYin = db.ToPinYin(name).Single()
         };
         db.DepotDictionary.Add(dictionary);
         db.SaveChanges();
     }
 }
示例#48
0
 /// <summary>
 /// ���´ʵ��ļ�
 /// </summary>
 /// <param name="type"></param>
 /// <param name="parentKey"></param>
 /// <param name="item"></param>
 public static void UpdateDictionaryFile(DictionaryType type,string parentKey,DictionaryItem item)
 {
 }