示例#1
0
        public IEnumerable <object> GetProperDictionaryByName(string DictionaryName)
        {
            var dbSet = context.GetType().GetProperty(DictionaryName).GetGetMethod();
            IQueryable <object> result = dbSet.Invoke(context, null) as IQueryable <object>;

            if (result.Count() != 0)
            {
                var item = result.FirstOrDefault();

                foreach (PropertyInfo property in item.GetType().GetProperties())
                {
                    if (property.MemberType == MemberTypes.Property)
                    {
                        var type = property.PropertyType;
                        if (!(type.IsPrimitive ||
                              type.Equals(typeof(string))))
                        {
                            DictionaryHelper.Set(context, type).Load();
                        }
                    }
                }
            }
            result = dbSet.Invoke(context, null) as IQueryable <object>;

            return(result.AsEnumerable <object>());
        }
示例#2
0
        public dynamic ListDictItem(string dictName)
        {
            var helper   = DictionaryHelper.GetHelper();
            var DictType = helper.GetTypeFromName(dictName);

            return(_tableRepository.GetType().GetMethod("LoadAllItems").MakeGenericMethod(DictType).Invoke(_tableRepository, null));
        }
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, System.Web.Script.Serialization.JavaScriptSerializer serializer)
        {
            WfActivityAssigneesResourceDescriptor activityAssigneesResDesp = (WfActivityAssigneesResourceDescriptor)base.Deserialize(dictionary, type, serializer);

            activityAssigneesResDesp.ActivityKey = DictionaryHelper.GetValue(dictionary, "ActivityKey", string.Empty);
            return(activityAssigneesResDesp);
        }
示例#4
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            WfActivityDescriptor actDesp = (WfActivityDescriptor)obj;

            IDictionary <string, object> dictionary = base.Serialize(obj, serializer);

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "AllowEmptyCandidates", actDesp.Properties.GetValue("AllowEmptyCandidates", false));
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "AllowInvalidCandidates", actDesp.Properties.GetValue("AllowInvalidCandidates", false));

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "ActivityType", actDesp.ActivityType);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "CodeName", actDesp.CodeName);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Url", actDesp.Url);

            dictionary.Add("Variables", actDesp.Variables);
            dictionary.Add("Condition", actDesp.Condition);
            dictionary.Add("BranchProcessTemplates", actDesp.BranchProcessTemplates);
            dictionary.Add("Resources", actDesp.Resources);
            dictionary.Add("RelativeLinks", actDesp.RelativeLinks);
            dictionary.Add("EnterEventReceivers", actDesp.EnterEventReceivers);
            dictionary.Add("LeaveEventReceivers", actDesp.LeaveEventReceivers);
            dictionary.Add("InternalRelativeUsers", actDesp.InternalRelativeUsers);
            dictionary.Add("ExternalUsers", actDesp.ExternalUsers);

            dictionary.Add("EnterEventExecuteServices", actDesp.EnterEventExecuteServices);
            dictionary.Add("LeaveEventExecuteServices", actDesp.LeaveEventExecuteServices);

            dictionary.Add("WithdrawExecuteServices", actDesp.WithdrawExecuteServices);
            dictionary.Add("BeWithdrawnExecuteServices", actDesp.BeWithdrawnExecuteServices);

            return(dictionary);
        }
示例#5
0
        public ActionResult CreateHoliday([DataSourceRequest] DataSourceRequest request, HolidayModel holiday, string employeId)
        {
            Guid id;

            if (holiday != null && ModelState.IsValid && Guid.TryParse(employeId, out id) && db.Employees.FirstOrDefault(x => x.Id == id) != null)
            {
                Holiday h = new Holiday {
                    EmployeeId                 = employeId,
                    EmployeeValue              = db.Employees.FirstOrDefault(x => x.Id == id).DisplayName,
                    DateEnd                    = holiday.DateEnd,
                    DateStart                  = holiday.DateStart,
                    PeriodEnd                  = holiday.PeriodEnd,
                    PeriodStart                = holiday.PeriodStart,
                    DocumentId                 = DictionaryHelper.GetItemsId(holiday.DocumentId),
                    DocumentValue              = DictionaryHelper.GetItemsName(holiday.DocumentId),
                    HolidayTypeDictionaryId    = DictionaryHelper.GetItemsId(holiday.HolidayTypeDictionaryId),
                    HolidayTypeDictionaryValue = DictionaryHelper.GetItemsName(holiday.HolidayTypeDictionaryId),
                    Note  = holiday.Note,
                    Count = holiday.Count
                };
                db.Holidays.Add(h);
                db.SaveChanges();
                holiday.Id = h.Id;
            }

            return(Json(new[] { holiday }.ToDataSourceResult(request, ModelState)));
        }
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Minion" && playerController.normalAttack == true)
        {
            //Debug.Log(this.name + " Hit " + other.gameObject.name);

            //Find Minion and Minion GO
            Minion     m    = DictionaryHelper.KeyByValue <Minion, GameObject>(cgc.minionGameObjectMap, other.gameObject);
            GameObject m_go = cgc.minionGameObjectMap[m];

            // Calculate DMG
            m.MinionGethit();
            if (m.canTakeDMG == true)
            {
                FloatingTextController.CreateFloatingDMG(m.CalAndTakeDamage(), other.transform);
            }

            // Update Health Bar
            GameObject m_canvas = m_go.transform.Find("CharCanvas").gameObject;
            if (m_canvas.activeSelf == false)
            {
                m_canvas.SetActive(true);
            }
            HealthBar hb = m_canvas.GetComponentInChildren <HealthBar>();
            hb.HealthBarChange(m.HP, m.MaxHP);
        }
    }
        public void DictionaryInterface()
        {
            // Arrange
            DictionaryHelper <string, ValueProviderResult> helper = new DictionaryHelper <
                string,
                ValueProviderResult
                >()
            {
                Creator      = () => new ValueProviderDictionary(null),
                Comparer     = StringComparer.OrdinalIgnoreCase,
                SampleKeys   = new string[] { "foo", "bar", "baz", "quux", "QUUX" },
                SampleValues = new ValueProviderResult[]
                {
                    new ValueProviderResult(null, null, null),
                    new ValueProviderResult(null, null, null),
                    new ValueProviderResult(null, null, null),
                    new ValueProviderResult(null, null, null),
                    new ValueProviderResult(null, null, null)
                },
                ThrowOnKeyNotFound = false
            };

            // Act & assert
            helper.Execute();
        }
示例#8
0
 public UnitModel(Unit unit)
 {
     Id        = unit.Id;
     Code      = unit.Code;
     Name      = unit.Name;
     NameKz    = unit.NameKz;
     ShortName = unit.ShortName;
     UnitTypeDictionaryValue = unit.UnitTypeDictionaryValue;
     Type                 = unit.Type;
     Rank                 = unit.Rank;
     NameFull             = LocalizationHelper.GetString(unit.Name, unit.NameKz);
     PositionState        = unit.PositionState;
     Email                = unit.Email;
     ParentId             = unit.ParentId;
     UnitTypeDictionaryId = DictionaryHelper.GetItems(unit.UnitTypeDictionaryId, unit.UnitTypeDictionaryValue);
     BossId               = DictionaryHelper.GetItems(unit.BossId, unit.BossValue);
     ManagerId            = DictionaryHelper.GetItems(unit.ManagerId, unit.ManagerValue);
     SecretaryId          = DictionaryHelper.GetItems(unit.SecretaryId, unit.SecretaryValue);
     ChancelleryId        = DictionaryHelper.GetItems(unit.ChancelleryId, unit.ChancelleryValue);
     CuratorId            = DictionaryHelper.GetItems(unit.CuratorId, unit.CuratorValue);
     Category             = unit.UnitTypeDictionaryId;
     PositionType         = unit.PositionType;
     PositionStaff        = unit.PositionStaff;
     AccreditationData    = unit.AccreditationData;
     AccreditationTerm    = unit.AccreditationtTerm;
 }
示例#9
0
 string GetDefaultAspectFromVersion9(SerializableDictionary<string, string> serializableDictionary, List<string> aspects, string defaultAspect) {
     if (serializableDictionary.ContainsKey("Schema")){
         var helper = new DictionaryHelper();
         defaultAspect = helper.GetAspectFromXml(aspects, defaultAspect);
     }
     return defaultAspect;
 }
示例#10
0
        public FastDictionary(int initialBucketCount)
        {
            Contract.Ensures(this.Capacity >= initialBucketCount);
            Contract.EndContractBlock();

            // Calculate the next power of 2.
            var newCapacity = initialBucketCount >= DictionaryHelper.MinBuckets
                ? initialBucketCount
                : DictionaryHelper.MinBuckets;

            newCapacity = DictionaryHelper.NextPowerOf2(newCapacity);

            this.initialCapacity = newCapacity;

            // Initialization
            this.entries = new Entry[newCapacity];
            BlockCopyMemoryHelper.Memset(this.entries, new Entry(UnusedHash, default(TKey), default(TValue)));

            this.Capacity = newCapacity;

            this.numberOfUsed    = 0;
            this.numberOfDeleted = 0;
            this.Count           = 0;

            this.nextGrowthThreshold = this.Capacity * 4 / LoadFactor;
        }
        private void EditCateDialogClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
        {
            if (eventArgs.Parameter is bool parameter &&
                parameter == false)
            {
                return;
            }

            var tempIndex = this.SelectedIndex;

            using (var db = new CAKESTOREEntities())
            {
                var modifiedCate = this._categoryDialogViewModel.SelectedCakeType;
                var cate         = db.CAKE_TYPE.Find(modifiedCate.TYPE_ID);
                var cateFromDic  = CakeCategories.FirstOrDefault(c => c.Key.TYPE_ID == cate.TYPE_ID).Key;

                var tryUpdateKey = DictionaryHelper.UpdateKey(CakeCategories, cateFromDic, modifiedCate);

                if (tryUpdateKey)
                {
                    cate.TYPE_NAME = modifiedCate.TYPE_NAME;
                    db.SaveChanges();

                    GetCakeCategories(tempIndex);
                }
                else
                {
                    MessageBox.Show("Error");
                }
            };
            MainWindowViewModel.Instance.GetAutocompleteSource();
        }
示例#12
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();
            PropertyValue prop = (PropertyValue)obj;

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "name", prop.Definition.Name);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "displayName", prop.Definition.DisplayName);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "category", prop.Definition.Category);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "defaultValue", prop.Definition.DefaultValue);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "dataType", prop.Definition.DataType);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "description", prop.Definition.Description);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "readOnly", prop.Definition.ReadOnly);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "visible", prop.Definition.Visible);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "editorKey", prop.Definition.EditorKey);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "persisterKey", prop.Definition.PersisterKey);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "isRequired", prop.Definition.IsRequired);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "showTitle", prop.Definition.ShowTitle);

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "editorParamsSettingsKey", prop.Definition.EditorParamsSettingsKey);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "editorParams", prop.Definition.EditorParams);
            if (prop.Definition.Validators.Count > 0)
            {
                string jsonStr = JSONSerializerExecute.Serialize(prop.Definition.Validators);
                DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "validators", jsonStr);
                DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "clientVdtData", prop.Definition.GetPropertyValidator());
            }

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "maxLength", prop.Definition.MaxLength);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "sortOrder", prop.Definition.SortOrder);

            dictionary.Add("value", prop.StringValue);

            return(dictionary);
        }
示例#13
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            PropertyDefine pd = new PropertyDefine();

            pd.Name                    = DictionaryHelper.GetValue(dictionary, "name", string.Empty);
            pd.DisplayName             = DictionaryHelper.GetValue(dictionary, "displayName", string.Empty);
            pd.Category                = DictionaryHelper.GetValue(dictionary, "category", string.Empty);
            pd.DefaultValue            = DictionaryHelper.GetValue(dictionary, "defaultValue", string.Empty);
            pd.DataType                = DictionaryHelper.GetValue(dictionary, "dataType", PropertyDataType.String);
            pd.Description             = DictionaryHelper.GetValue(dictionary, "description", string.Empty);
            pd.ReadOnly                = DictionaryHelper.GetValue(dictionary, "readOnly", false);
            pd.Visible                 = DictionaryHelper.GetValue(dictionary, "visible", true);
            pd.EditorKey               = DictionaryHelper.GetValue(dictionary, "editorKey", string.Empty);
            pd.PersisterKey            = DictionaryHelper.GetValue(dictionary, "persisterKey", string.Empty);
            pd.EditorParamsSettingsKey = DictionaryHelper.GetValue(dictionary, "editorParamsSettingsKey", string.Empty);
            pd.EditorParams            = DictionaryHelper.GetValue(dictionary, "editorParams", string.Empty);
            pd.SortOrder               = DictionaryHelper.GetValue(dictionary, "sortOrder", 0xFFFF);
            pd.MaxLength               = DictionaryHelper.GetValue(dictionary, "maxLength", 0xFFFF);
            pd.IsRequired              = DictionaryHelper.GetValue(dictionary, "isRequired", false);
            pd.ShowTitle               = DictionaryHelper.GetValue(dictionary, "showTitle", true);

            if (dictionary.ContainsKey("validators") == true)
            {
                PropertyValidatorDescriptorCollection validators = JSONSerializerExecute.Deserialize <PropertyValidatorDescriptorCollection>(dictionary["validators"]);
                pd.Validators.Clear();
                pd.Validators.CopyFrom(validators);
            }

            PropertyValue pv = new PropertyValue(pd);

            pv.StringValue = DictionaryHelper.GetValue(dictionary, "value", (string)null);

            return(pv);
        }
        public string GetLocalizedResource(string textKey, string defaultValue = null, params object[] parameters)
        {
            if (string.IsNullOrEmpty(textKey))
            {
                throw new ArgumentNullException("textKey", "text key cannot be null");
            }
            var langKey    = WorkContext.CurrentCuture;
            var key        = DictionaryHelper.BuildKey(langKey, textKey);
            var dictionary = WorkContext.LocalizedResourceDictionary;

            if (dictionary == null || !dictionary.Any(l => l.Key.Equals(key) && l.Language.Equals(langKey)))
            {
                return(GetDefaultValue(langKey, textKey, defaultValue, parameters));
            }
            var localizeResource = dictionary.FirstOrDefault(d => d.Key.Equals(key));

            if (localizeResource != null)
            {
                if (parameters != null && parameters.Any())
                {
                    return(string.Format(localizeResource.Value, parameters));
                }
                return(localizeResource.Value);
            }

            return(string.Empty);
        }
示例#15
0
        //REMOTE Validation
        public JsonResult CheckEmailIsUsed(string emailAddress)
        {
            //Get Current Member
            var member = Member.GetCurrentMember();

            //Sometimes inconsistent results with GetCurrent Member, unsure why?!
            if (member != null)
            {
                //if the email is the same as the one stored then it's OK
                if (member.Email == emailAddress)
                {
                    //Email is the same as one currently stored on the member - so email ok to use & rule valid (return true, back to validator)
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }

                //Try and get member by email typed in
                var checkEmail = Member.GetMemberFromEmail(emailAddress);

                if (checkEmail != null)
                {
                    return(Json(String.Format(DictionaryHelper.GetDictItem("EmailAddressInUse", "The email address '{0}' is already in use."), emailAddress), JsonRequestBehavior.AllowGet));
                }

                return(Json(true, JsonRequestBehavior.AllowGet));
            }

            //Unable to get current member to check (just an OK for client side validation)
            //and let action in controller validate
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
示例#16
0
        public override bool Equals(object obj)
        {
            var other = obj as SymbolicValueConstraints;

            return(other != null &&
                   DictionaryHelper.DictionaryEquals(constraints, other.constraints));
        }
        public override IDictionary <string, object> Serialize(object obj, System.Web.Script.Serialization.JavaScriptSerializer serializer)
        {
            WfProcessDescriptor processDesp = (WfProcessDescriptor)obj;

            Dictionary <string, object> dictionary = (Dictionary <string, object>)base.Serialize(obj, serializer);

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Version", processDesp.Version);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "ApplicationName", processDesp.ApplicationName);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "ProgramName", processDesp.ProgramName);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Url", processDesp.Url);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "GraphDescription", processDesp.GraphDescription);

            dictionary.Add("Activities", processDesp.Activities);

            SetPropertiesValue(processDesp, "Variables", processDesp.Variables);
            SetPropertiesValue(processDesp, "RelativeLinks", processDesp.RelativeLinks);
            SetPropertiesValue(processDesp, "CancelEventReceivers", processDesp.CancelEventReceivers);
            SetPropertiesValue(processDesp, "CompleteEventReceivers", processDesp.CompleteEventReceivers);
            SetPropertiesValue(processDesp, "InternalRelativeUsers", processDesp.InternalRelativeUsers);
            SetPropertiesValue(processDesp, "ExternalUsers", processDesp.ExternalUsers);
            SetPropertiesValue(processDesp, "ParametersNeedToBeCollected", processDesp.ParametersNeedToBeCollected);
            SetPropertiesValue(processDesp, "CancelBeforeExecuteServices", processDesp.CancelBeforeExecuteServices);
            SetPropertiesValue(processDesp, "CancelAfterExecuteServices", processDesp.CancelAfterExecuteServices);

            ToTransitionsDescriptorCollection transitions = new ToTransitionsDescriptorCollection();

            foreach (WfActivityDescriptor actDesp in processDesp.Activities)
            {
                transitions.CopyFrom(actDesp.ToTransitions);
            }

            dictionary.Add("Transitions", transitions);

            return(dictionary);
        }
示例#18
0
        protected virtual void ExtractOguObject(IDictionary <string, object> dictionary, out SchemaType oguType, out OguBase result)
        {
            string id = (string)dictionary["id"];

            oguType = SchemaType.Users;

            if (dictionary.ContainsKey("objectType"))
            {
                oguType = (SchemaType)dictionary["objectType"];
            }

            result = CreateOguObject(oguType, id);

            result.Description   = DictionaryHelper.GetValue(dictionary, "description", string.Empty);
            result.DisplayName   = DictionaryHelper.GetValue(dictionary, "displayName", string.Empty);
            result.FullPath      = DictionaryHelper.GetValue(dictionary, "fullPath", string.Empty);
            result.GlobalSortID  = DictionaryHelper.GetValue(dictionary, "globalSortID", string.Empty);
            result.Name          = DictionaryHelper.GetValue(dictionary, "name", string.Empty);
            result.SortID        = DictionaryHelper.GetValue(dictionary, "sortID", string.Empty);
            result.Tag           = DictionaryHelper.GetValue(dictionary, "tag", string.Empty);
            result.ClientContext = DictionaryHelper.GetValue(dictionary, "clientContext", (Dictionary <string, object>)null);

            if (dictionary.ContainsKey("status"))
            {
                result.Properties["STATUS"] = DictionaryHelper.GetValue(dictionary, "status", 1);
            }
        }
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            WfActivityDescriptor actDesp = (WfActivityDescriptor)obj;

            IDictionary <string, object> dictionary = base.Serialize(obj, serializer);

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "ActivityType", actDesp.ActivityType);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "CodeName", actDesp.CodeName);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Url", actDesp.Url);

            SetPropertiesValue(actDesp, "Variables", actDesp.Variables);
            SetPropertiesValue(actDesp, "Condition", actDesp.Condition);
            SetPropertiesValue(actDesp, "Resources", actDesp.Resources);
            SetPropertiesValue(actDesp, "RelativeLinks", actDesp.RelativeLinks);
            SetPropertiesValue(actDesp, "BranchProcessTemplates", actDesp.BranchProcessTemplates);
            SetPropertiesValue(actDesp, "EnterEventReceivers", actDesp.EnterEventReceivers);
            SetPropertiesValue(actDesp, "LeaveEventReceivers", actDesp.LeaveEventReceivers);

            SetPropertiesValue(actDesp, "EnterEventExecuteServices", actDesp.EnterEventExecuteServices);
            SetPropertiesValue(actDesp, "LeaveEventExecuteServices", actDesp.LeaveEventExecuteServices);

            SetPropertiesValue(actDesp, "WithdrawExecuteServices", actDesp.WithdrawExecuteServices);
            SetPropertiesValue(actDesp, "BeWithdrawnExecuteServices", actDesp.BeWithdrawnExecuteServices);

            SetPropertiesValue(actDesp, "InternalRelativeUsers", actDesp.InternalRelativeUsers);
            SetPropertiesValue(actDesp, "ExternalUsers", actDesp.ExternalUsers);
            SetPropertiesValue(actDesp, "ParametersNeedToBeCollected", actDesp.ParametersNeedToBeCollected);

            return(dictionary);
        }
示例#20
0
        public IHttpActionResult GetStatus()
        {
            var a          = DictionaryHelper.GetHelper();
            var finished   = _customerLogic.GetFinishedExam(DateTime.Now.AddYears(-1));
            var unfinished = _customerLogic.GetUnfinishedExam(DateTime.Now.AddYears(-1));

            var finishedArray = finished.Select(p => new
            {
                Name  = p.CustomerName,
                Type  = p.ExamTypeName,
                Price = _feeLogic.getExamPrice(p)
            }).ToList();
            var unfinishedArray = unfinished.Select(p => new
            {
                Name  = p.CustomerName,
                Type  = p.ExamTypeName,
                Price = _feeLogic.getExamPrice(p)
            }).ToList();
            var totalCount = finished.Count() + unfinished.Count();
            var totalPrice = finished.Sum(p => _feeLogic.getExamPrice(p)) + unfinished.Sum(p => _feeLogic.getExamPrice(p));

            var result = new
            {
                FinishedList   = finishedArray,
                UnfinishedList = unfinishedArray,
                TotalCount     = totalCount,
                TotalPrice     = totalPrice
            };

            return(Json(result));
        }
示例#21
0
        /// <summary>
        ///反序列化OguObject
        /// </summary>
        /// <param name="dictionary">对象类型</param>
        /// <param name="type">对象类型</param>
        /// <param name="serializer">JS序列化器</param>
        /// <returns>反序列化出的对象</returns>
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            SchemaType oguType;
            OguBase    result;

            ExtractOguObject(dictionary, out oguType, out result);

            switch (oguType)
            {
            case SchemaType.Organizations:
                ((OguOrganization)result).CustomsCode              = DictionaryHelper.GetValue(dictionary, "customsCode", string.Empty);
                ((OguOrganization)result).DepartmentClass          = DictionaryHelper.GetValue(dictionary, "departmentClass", DepartmentClassType.Unspecified);
                ((OguOrganization)result).DepartmentType           = DictionaryHelper.GetValue(dictionary, "departmentType", DepartmentTypeDefine.Unspecified);
                ((OguOrganization)result).Rank                     = DictionaryHelper.GetValue(dictionary, "rank", DepartmentRankType.None);
                ((OguOrganization)result).ExcludeVirtualDepartment = DictionaryHelper.GetValue(dictionary, "excludeVirtualDepartment", false);
                break;

            case SchemaType.Users:
                ((OguUser)result).Email      = DictionaryHelper.GetValue(dictionary, "email", string.Empty);
                ((OguUser)result).IsSideline = DictionaryHelper.GetValue(dictionary, "isSideline", false);
                ((OguUser)result).LogOnName  = DictionaryHelper.GetValue(dictionary, "logOnName", string.Empty);
                ((OguUser)result).Occupation = DictionaryHelper.GetValue(dictionary, "occupation", string.Empty);
                ((OguUser)result).Rank       = DictionaryHelper.GetValue(dictionary, "rank", UserRankType.Unspecified);
                break;

            case SchemaType.Groups:
                break;
            }

            return(result);
        }
示例#22
0
        // GET: /Reference/
        public ActionResult Index()
        {
            Guid guid = Guid.NewGuid();

            ViewBag.DictionaryList = DictionaryHelper.GetOBKList();
            return(PartialView(guid));
        }
示例#23
0
        /// <summary>
        /// (РЕКУРСИЯ!!!)Нахождение всех папок форматов и подсчёт количества фотографий в одинаковых
        /// </summary>
        /// <param name="directoryModel">директория, в которой будет производиться поиск</param>
        /// <returns></returns>
        public Dictionary <string, int> FormatNumSum(DirectoryModel directoryModel)
        {
            Dictionary <string, int> formatesDic = new Dictionary <string, int>();

            if (directoryModel == null)
            {
                return(formatesDic);
            }

            Regex rx = new Regex(@"\d{1,5}[x|х]\d{1,5}[x|х]\d{1,5}",
                                 RegexOptions.Compiled | RegexOptions.IgnoreCase);

            if (rx.IsMatch(directoryModel.ShortName))
            {
                DictionaryHelper.AddToDictionary(formatesDic,
                                                 new KeyValuePair <string, int>(directoryModel.ShortName,
                                                                                directoryModel.AggregateNumOfEachFileType.Values.Sum()), (int a, int b) => a + b);
            }

            foreach (var item in directoryModel.DirectoryModelsList)
            {
                formatesDic = DictionaryМerge <string, int>(formatesDic, FormatNumSum(item), (IEnumerable <KeyValuePair <string, int> > pairs) => pairs.Select(x => x.Value).Sum());
            }

            return(formatesDic);
        }
示例#24
0
        /// <summary>
        /// Generates an expression tree to handle ISerializable deserialization
        /// </summary>
        /// <param name="type">Type to deserialize</param>
        /// <param name="variables">Global variables for expression tree</param>
        /// <param name="inputStream">Stream to read from</param>
        /// <param name="objTracker">Reference tracker</param>
        /// <returns>An expression tree to handle ISerializable deserialization</returns>
        public static Expression GenerateISerializableExpression(Type type,
                                                                 List <ParameterExpression> variables,
                                                                 ParameterExpression inputStream,
                                                                 ParameterExpression objTracker)
        {
            var newInstance = Expression.Parameter(type, "newInstance");
            var trackType   = Expression.Parameter(typeof(byte), "trackType");

            variables.Add(newInstance);
            variables.Add(trackType);

            var dictionaryType        = DictionaryHelper.GetDictionaryType(type, throwIfNotADictionary: false);
            var notTrackedExpressions = new List <Expression>();

            if (dictionaryType == null)
            {
                notTrackedExpressions.Add(PrimitiveHelpers.ReadByte(inputStream, objTracker));
                notTrackedExpressions.Add(DeserializeISerializable(type, variables, inputStream, objTracker, newInstance));
            }
            else
            {
                notTrackedExpressions.Add(Expression.IfThenElse(Expression.Equal(PrimitiveHelpers.ReadByte(inputStream, objTracker), Expression.Constant(1, typeof(int))),
                                                                DeserializeDictionary(type, variables, inputStream, objTracker, newInstance),
                                                                DeserializeISerializable(type, variables, inputStream, objTracker, newInstance)));
            }

            return(Deserializer.GenerateNullTrackedOrUntrackedExpression(type,
                                                                         inputStream,
                                                                         objTracker,
                                                                         newInstance,
                                                                         notTrackedExpressions,
                                                                         trackType,
                                                                         variables));
        }
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            ClientGridColumn column = new ClientGridColumn();

            column.DataField       = DictionaryHelper.GetValue(dictionary, "dataField", string.Empty);
            column.HeaderText      = DictionaryHelper.GetValue(dictionary, "headerText", string.Empty);
            column.HeaderTips      = DictionaryHelper.GetValue(dictionary, "headerTips", string.Empty);
            column.HeaderTipsStyle = DictionaryHelper.GetValue(dictionary, "headerTipsStyle", "{color:Red}");
            column.SortExpression  = DictionaryHelper.GetValue(dictionary, "sortExpression", string.Empty);
            column.SelectColumn    = DictionaryHelper.GetValue(dictionary, "selectColumn", false);
            column.ShowSelectAll   = DictionaryHelper.GetValue(dictionary, "showSelectAll", false);

            column.DataType              = DictionaryHelper.GetValue(dictionary, "dataType", DataType.String);
            column.MaxLength             = DictionaryHelper.GetValue(dictionary, "maxLength", 0);
            column.FormatString          = DictionaryHelper.GetValue(dictionary, "formatString", string.Empty);
            column.EditorStyle           = DictionaryHelper.GetValue(dictionary, "editorStyle", string.Empty);
            column.EditorTooltips        = DictionaryHelper.GetValue(dictionary, "editorTooltips", string.Empty);
            column.EditorReadOnly        = DictionaryHelper.GetValue(dictionary, "editorReadOnly", false);
            column.EditorEnabled         = DictionaryHelper.GetValue(dictionary, "editorEnabled", true);
            column.Visible               = DictionaryHelper.GetValue(dictionary, "visible", true);
            column.IsDynamicColumn       = DictionaryHelper.GetValue(dictionary, "isDynamicColumn", false);
            column.AutoBindingValidation = DictionaryHelper.GetValue(dictionary, "autoBindingValidation", false);
            column.IsFixedLine           = DictionaryHelper.GetValue(dictionary, "isFixedLine", false);
            column.IsStatistic           = DictionaryHelper.GetValue(dictionary, "isStatistic", false);

            if (dictionary.ContainsKey("editTemplate"))
            {
                column.EditTemplate = JSONSerializerExecute.Deserialize <ClientGridColumnEditTemplate>(dictionary["editTemplate"]);
            }

            return(column);
        }
示例#26
0
        /// <summary>
        /// 将所提供的字典转换为<see cref="SchemaDefine"/>类型的对象。
        /// </summary>
        /// <param name="dictionary">作为名称/值对存储的属性数据的 <see cref="T:System.Collections.Generic.IDictionary^2"/>  实例。</param>
        /// <param name="type">所生成对象的类型。</param>
        /// <param name="serializer"><see cref="System.Web.Script.Serialization.JavaScriptSerializer"/>实例。</param>
        /// <returns>反序列化的对象。</returns>
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            SchemaDefine schemaDefine = new SchemaDefine();

            schemaDefine.Name          = DictionaryHelper.GetValue(dictionary, "name", string.Empty);
            schemaDefine.SnapshotTable = DictionaryHelper.GetValue(dictionary, "snapshotTable", string.Empty);
            schemaDefine.Category      = DictionaryHelper.GetValue(dictionary, "category", string.Empty);
            schemaDefine.SortOrder     = DictionaryHelper.GetValue(dictionary, "sortOrder", 0xFFFF);

            if (dictionary.ContainsKey("properties"))
            {
                SchemaPropertyDefineCollection properties = JSONSerializerExecute.Deserialize <SchemaPropertyDefineCollection>(dictionary["properties"]);
                schemaDefine.Properties.Clear();
                schemaDefine.Properties.CopyFrom(properties);
            }

            if (dictionary.ContainsKey("tabs"))
            {
                SchemaTabDefineColleciton tabs = JSONSerializerExecute.Deserialize <SchemaTabDefineColleciton>(dictionary["Tabs"]);
                schemaDefine.Tabs.Clear();
                schemaDefine.Tabs.CopyFrom(tabs);
            }

            return(schemaDefine);
        }
示例#27
0
        public override void ProcessComplited(Guid documentId, EXP_Activities activity)
        {
            var letter         = _context.EXP_DrugCorespondence.FirstOrDefault(e => e.Id == documentId);
            var positiveStatus = DictionaryHelper.GetDicIdByCode(Dictionary.ExpActivityStatus.DicCode,
                                                                 Dictionary.ExpActivityStatus.Executed);

            if (activity.StatusId == positiveStatus)
            {
                //letter.StatusId = DictionaryHelper.GetDicIdByCode(CodeConstManager.STATUS_AGREED, CodeConstManager.STATUS_AGREED);
                var stageRepo       = new ExpertiseStageRepository(_context);
                var stageSupervisor = stageRepo.GetStageSupervisor(letter.StageId, letter.EXP_DrugDeclaration.TypeId);
                var activityManager = new ActivityManager(_context);
                activityManager.SendToExecution(Dictionary.ExpActivityType.ExpertiseLetterSigning, letter.Id,
                                                Dictionary.ExpAgreedDocType.Letter, Dictionary.ExpTaskType.Signing,
                                                letter.NumberLetter, letter.DateCreate, stageSupervisor.Id);
            }
            else
            {
                letter.StatusId =
                    DictionaryHelper.GetDicIdByCode(CodeConstManager.STATUS_REJECTED, CodeConstManager.STATUS_REJECTED);
                if (letter.EXP_DIC_CorespondenceSubject.Code == EXP_DIC_CorespondenceSubject.RefuseByPayment)
                {
                    var declaration =
                        _context.EXP_DrugDeclaration.FirstOrDefault(e => e.Id == letter.DrugDeclarationId);
                    declaration.StatusId = CodeConstManager.STATUS_EXP_SEND_ID;
                }
            }
        }
        public override void TaskRejected(Guid documentId, EXP_Tasks task)
        {
            var directionToPay = _context.EXP_DirectionToPays.FirstOrDefault(e => e.Id == documentId);

            if (directionToPay != null)
            {
                directionToPay.StatusId = DictionaryHelper.GetDicIdByCode(Dictionary.ExpDirectionToPayStatus.DicCode,
                                                                          Dictionary.ExpDirectionToPayStatus.OnСorrection);
                directionToPay.ModifyDate = directionToPay.ModifyDate = DateTime.Now;;

                var  unit1       = UserHelper.GetDepartmentUpper();
                bool isUpperCode = (unit1 != null && unit1.Code == "finance");

                if (UserHelper.GetCurrentEmployee().Id == task.ExecutorId && (UserHelper.GetDepartment().Code == "finance" || isUpperCode))
                {
                    var expDrugDeclaration         = directionToPay.EXP_DrugDeclaration.FirstOrDefault();
                    var expExpertiseStage          = expDrugDeclaration?.EXP_ExpertiseStage.FirstOrDefault(es => es.EXP_DIC_Stage.Code == EXP_DIC_Stage.PrimaryExp);
                    var expExpertiseStageExecutors = expExpertiseStage?.EXP_ExpertiseStageExecutors.FirstOrDefault(ex => ex.IsHead);
                    if (expExpertiseStageExecutors != null)
                    {
                        var headId = expExpertiseStageExecutors.ExecutorId;

                        new NotificationManager().SendNotification(
                            string.Format("Направление на оплату №{0} отклонено", directionToPay.Number),
                            ObjectType.Document, directionToPay.Id, headId);
                    }
                }
            }



            _context.SaveChanges();
        }
示例#29
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            EditorParamsDefine paDefine = new EditorParamsDefine();

            foreach (KeyValuePair <string, object> item in dictionary)
            {
                if (string.Compare(item.Key, "serverControlProperties", true) == 0)
                {
                    string strServerControlProperties = DictionaryHelper.GetValue(dictionary, "serverControlProperties", string.Empty);
                    if (strServerControlProperties.IsNotEmpty())
                    {
                        List <ControlPropertyDefine> desControlProperties = JSONSerializerExecute.Deserialize <List <ControlPropertyDefine> >(strServerControlProperties);
                        desControlProperties.ForEach(pcd =>
                        {
                            paDefine.ServerControlProperties.Add(pcd);
                        });
                    }
                }
                else
                {
                    paDefine.Add(item.Key, item.Value != null ? item.Value.ToString() : string.Empty);
                }
            }

            return(paDefine);
        }
        private static InvoiceProformaBillingRunDTO[] FilterFromParameters(
            InvoiceProformaBillingRunDTO[] serviceModel,
            string soldToParty,
            string dateFrom,
            string dateTo)
        {
            if (string.IsNullOrEmpty(soldToParty) && string.IsNullOrEmpty(dateFrom) && string.IsNullOrEmpty(dateTo))
            {
                return(serviceModel);
            }

            if (!(string.IsNullOrEmpty(soldToParty) || soldToParty == SharedResource.NA))
            {
                serviceModel = serviceModel.Where(e => e.SoldToParty == soldToParty).ToArray();
            }

            if (!string.IsNullOrEmpty(dateFrom))
            {
                var dateFromValue = DictionaryHelper.KendoDatePickerDateStringToDateTime(dateFrom);
                serviceModel = serviceModel.Where(e => e.StartDate >= dateFromValue).ToArray();
            }

            if (!string.IsNullOrEmpty(dateTo))
            {
                var dateToValue = DictionaryHelper.KendoDatePickerDateStringToDateTime(dateTo);
                serviceModel = serviceModel.Where(e => e.EndDate <= dateToValue).ToArray();
            }

            return(serviceModel);
        }
示例#31
0
        public Unit GetUnit(Unit unit)
        {
            unit.Id        = Id;
            unit.Code      = Code;
            unit.Name      = Name;
            unit.NameKz    = NameKz;
            unit.ShortName = ShortName;
            unit.UnitTypeDictionaryValue = UnitTypeDictionaryValue;
            unit.Type                 = Type;
            unit.PositionState        = PositionState;
            unit.Email                = Email;
            unit.Rank                 = Rank;
            unit.Bin                  = Bin;
            unit.ParentId             = ParentId;
            unit.UnitTypeDictionaryId = DictionaryHelper.GetItemsId(UnitTypeDictionaryId);
            unit.BossId               = DictionaryHelper.GetItemsId(BossId);
            unit.ManagerId            = DictionaryHelper.GetItemsId(ManagerId);
            unit.SecretaryId          = DictionaryHelper.GetItemsId(SecretaryId);
            unit.ChancelleryId        = DictionaryHelper.GetItemsId(ChancelleryId);
            unit.CuratorId            = DictionaryHelper.GetItemsId(CuratorId);

            unit.UnitTypeDictionaryValue = DictionaryHelper.GetItemsName(UnitTypeDictionaryId);
            unit.BossValue          = DictionaryHelper.GetItemsName(BossId);
            unit.ManagerValue       = DictionaryHelper.GetItemsName(ManagerId);
            unit.SecretaryValue     = DictionaryHelper.GetItemsName(SecretaryId);
            unit.ChancelleryValue   = DictionaryHelper.GetItemsName(ChancelleryId);
            unit.CuratorValue       = DictionaryHelper.GetItemsName(CuratorId);
            unit.PositionType       = PositionType;
            unit.PositionStaff      = PositionStaff;
            unit.AccreditationData  = AccreditationData;
            unit.AccreditationtTerm = AccreditationTerm;

            return(unit);
        }
        public void DictionaryInterface() {
            // Arrange
            DictionaryHelper<Type, IModelBinder> helper = new DictionaryHelper<Type, IModelBinder>() {
                Creator = () => new ModelBinderDictionary(),
                SampleKeys = new Type[] { typeof(object), typeof(string), typeof(int), typeof(long), typeof(long) },
                SampleValues = new IModelBinder[] { new DefaultModelBinder(), new DefaultModelBinder(), new DefaultModelBinder(), new DefaultModelBinder(), new DefaultModelBinder() },
                ThrowOnKeyNotFound = false
            };

            // Act & assert
            helper.Execute();
        }
        public void DictionaryInterface() {
            // Arrange
            DictionaryHelper<string, object> helper = new DictionaryHelper<string, object>() {
                Creator = () => new ViewDataDictionary(),
                Comparer = StringComparer.OrdinalIgnoreCase,
                SampleKeys = new string[] { "foo", "bar", "baz", "quux", "QUUX" },
                SampleValues = new object[] { 42, "string value", new DateTime(2001, 1, 1), new object(), 32m },
                ThrowOnKeyNotFound = false
            };

            // Act & assert
            helper.Execute();
        }
        public void DictionaryInterface() {
            // Arrange
            DictionaryHelper<string, ValueProviderResult> helper = new DictionaryHelper<string, ValueProviderResult>() {
                Creator = () => new ValueProviderDictionary(null),
                Comparer = StringComparer.OrdinalIgnoreCase,
                SampleKeys = new string[] { "foo", "bar", "baz", "quux", "QUUX" },
                SampleValues = new ValueProviderResult[] {
                    new ValueProviderResult(null, null, null),
                    new ValueProviderResult(null, null, null),
                    new ValueProviderResult(null, null, null),
                    new ValueProviderResult(null, null, null),
                    new ValueProviderResult(null, null, null)
                },
                ThrowOnKeyNotFound = false
            };

            // Act & assert
            helper.Execute();
        }
        public void DictionaryInterface()
        {
            // Arrange
            DictionaryHelper<string, ModelState> helper = new DictionaryHelper<string, ModelState>()
            {
                Creator = () => new ModelStateDictionary(),
                Comparer = StringComparer.OrdinalIgnoreCase,
                SampleKeys = new string[] { "foo", "bar", "baz", "quux", "QUUX" },
                SampleValues = new ModelState[] { new ModelState(), new ModelState(), new ModelState(), new ModelState(), new ModelState() },
                ThrowOnKeyNotFound = false
            };

            // Act & assert
            helper.Execute();
        }