Exemple #1
0
        void dansearch_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            //有错误
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
            }
            else
            {
                //把数据转换成JSON
                JsonArray items = JsonValue.Parse(e.Result) as JsonArray;
                daninfos.ItemsSource = list;
                if (list.Size != 0)
                {
                    list.Clear();
                }
                foreach (JsonObject json in items)
                {
                    GeneralObject go = new GeneralObject();
                    try
                    {
                        go.EntityType = "t_handplan";



                        string f_userid = (string)json["f_userid"];                   //表具编号
                        go.SetPropertyValue("f_userid", f_userid, false);
                        string f_userinfoid = (string)json["f_userinfoid"];           //用户编号
                        go.SetPropertyValue("f_userinfoid", f_userinfoid, false);
                        string f_handid = (string)json["f_handid"];                   //抄表编号
                        go.SetPropertyValue("f_handid", f_handid, false);
                        string f_meternumber = (string)json["f_meternumber"];         //表钢印号
                        go.SetPropertyValue("f_meternumber", f_meternumber, false);
                        int id = (int)json["id"];                                     //抄表记录id
                        go.SetPropertyValue("id", id, false);
                        string f_stairtype = (string)json["f_stairtype"];             //阶梯类型
                        go.SetPropertyValue("f_stairtype", f_stairtype, false);
                        string f_extrawaterprice = (string)json["f_extrawaterprice"]; //混合用水差价
                        go.SetPropertyValue("f_extrawaterprice", f_extrawaterprice, false);
                        string f_username = (string)json["f_username"];               //用户名
                        go.SetPropertyValue("f_username", f_username, false);
                        string f_address = (string)json["f_address"];                 //地址
                        go.SetPropertyValue("f_address", f_address, false);
                        decimal lastinputgasnum = (decimal)json["lastinputgasnum"];   //上期指数
                        go.SetPropertyValue("lastinputgasnum", lastinputgasnum, false);
                        list.Add(go);
                    }
                    catch (Exception ex)
                    {
                        ui_handBusy.IsBusy = false;
                        MessageBox.Show("用户:" + go.GetPropertyValue("f_userid") + "抄表数据有问题,请核查!");
                        MessageBox.Show(ex.ToString() + "" + go.GetPropertyValue("f_userid"));
                        return;
                    }
                }
            }
            ui_handBusy.IsBusy = false;
        }
Exemple #2
0
        protected virtual IDictionary <string, int> GetAttributeIdByAliasMappings()
        {
            return(_cacheManager.Get(ALL_ATTRIBUTE_ID_BY_ALIAS_KEY, () =>
            {
                var result = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase);
                var optionIdMappings = new Dictionary <int, int>();
                IPagedList <SpecificationAttribute> attributes = null;
                var attributeId = 0;
                var pageIndex = 0;

                var query = _specificationAttributeService.GetSpecificationAttributes()
                            .Expand(x => x.SpecificationAttributeOptions)
                            .OrderBy(x => x.Id);

                do
                {
                    attributes = new PagedList <SpecificationAttribute>(query, pageIndex++, 500);

                    foreach (var attribute in attributes)
                    {
                        if (attribute.Alias.HasValue())
                        {
                            result[CreateKey("attr", 0, attribute.Alias)] = attribute.Id;
                        }

                        foreach (var option in attribute.SpecificationAttributeOptions)
                        {
                            optionIdMappings[option.Id] = option.SpecificationAttributeId;

                            if (option.Alias.HasValue())
                            {
                                result[CreateOptionKey("attr.option", 0, attribute.Id, option.Alias)] = option.Id;
                            }
                        }
                    }
                }while (attributes.HasNextPage);

                attributes.Clear();

                CachedLocalizedAlias("SpecificationAttribute", x => result[CreateKey("attr", x.LanguageId, x.LocaleValue)] = x.EntityId);
                CachedLocalizedAlias("SpecificationAttributeOption", x =>
                {
                    if (optionIdMappings.TryGetValue(x.EntityId, out attributeId))
                    {
                        result[CreateOptionKey("attr.option", x.LanguageId, attributeId, x.LocaleValue)] = x.EntityId;
                    }
                });

                return result;
            }));
        }
Exemple #3
0
        protected virtual IDictionary <string, int> GetVariantIdByAliasMappings()
        {
            return(_cacheManager.Get(ALL_VARIANT_ID_BY_ALIAS_KEY, () =>
            {
                var result = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase);
                var optionIdMappings = new Dictionary <int, int>();
                IPagedList <ProductVariantAttributeValue> options = null;
                var variantId = 0;
                var pageIndex = 0;

                var query = _productVariantAttributeValueRepository.TableUntracked
                            .Expand(x => x.ProductVariantAttribute)
                            .Expand("ProductVariantAttribute.ProductAttribute")
                            .OrderBy(x => x.Id);

                do
                {
                    options = new PagedList <ProductVariantAttributeValue>(query, pageIndex++, 500);

                    foreach (var option in options)
                    {
                        var variant = option.ProductVariantAttribute.ProductAttribute;

                        optionIdMappings[option.Id] = variant.Id;

                        if (variant.Alias.HasValue())
                        {
                            result[CreateKey("vari", 0, variant.Alias)] = variant.Id;
                        }

                        if (option.Alias.HasValue())
                        {
                            result[CreateOptionKey("vari.option", 0, variant.Id, option.Alias)] = option.Id;
                        }
                    }
                }while (options.HasNextPage);

                options.Clear();

                CachedLocalizedAlias("ProductAttribute", x => result[CreateKey("vari", x.LanguageId, x.LocaleValue)] = x.EntityId);
                CachedLocalizedAlias("ProductVariantAttributeValue", x =>
                {
                    if (optionIdMappings.TryGetValue(x.EntityId, out variantId))
                    {
                        result[CreateOptionKey("vari.option", x.LanguageId, variantId, x.LocaleValue)] = x.EntityId;
                    }
                });

                return result;
            }));
        }
 void dansearch_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
 {
     //有错误
     if (e.Error != null)
     {
         MessageBox.Show(e.Error.Message);
     }
     else
     {
         //把数据转换成JSON
         JsonObject obj   = JsonValue.Parse(e.Result) as JsonObject;
         JsonArray  items = obj["rows"] as JsonArray;
         daninfos.ItemsSource = list;
         if (list.Size != 0)
         {
             list.Clear();
         }
         foreach (JsonObject json in items)
         {
             GeneralObject go = new GeneralObject();
             try
             {
                 go.EntityType = "t_";
                 go.SetPropertyValue("id", json["id"], false);                             //用户编号
                 go.SetPropertyValue("remote_key", json["remote_key"], false);             //用户编号
                 go.SetPropertyValue("terminal_code", json["terminal_code"], false);       //用户编号
                 go.SetPropertyValue("meter_code", json["meter_code"], false);             //用户编号
                 go.SetPropertyValue("operate_type", json["operate_type"], false);         //用户编号
                 go.SetPropertyValue("send_data", json["send_data"], false);               //用户编号
                 go.SetPropertyValue("receive_data", json["receive_data"], false);         //用户编号
                 go.SetPropertyValue("state", json["state"], false);                       //用户编号
                 go.SetPropertyValue("result", json["result"], false);                     //用户编号
                 go.SetPropertyValue("operator1", json["operator"], false);                //用户编号
                 go.SetPropertyValue("des", json["des"], false);                           //用户编号
                 go.SetPropertyValue("create_date", json["create_date"], false);           //用户编号
                 go.SetPropertyValue("company_code", json["company_code"], false);         //用户编号
                 go.SetPropertyValue("telecomm_address", json["telecomm_address"], false); //用户编号
                 go.SetPropertyValue("customer_code", json["customer_code"], false);       //用户编号
                 list.Add(go);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
                 return;
             }
         }
     }
 }
Exemple #5
0
        protected virtual IDictionary <string, string> GetVariantAliasByIdMappings()
        {
            return(_cacheManager.Get(ALL_VARIANT_ALIAS_BY_ID_KEY, () =>
            {
                var result = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                IPagedList <ProductAttribute> variants = null;
                IPagedList <ProductVariantAttributeValue> options = null;
                var pageIndex = 0;

                var variantQuery = _productAttributeRepository.TableUntracked
                                   .Where(x => !string.IsNullOrEmpty(x.Alias))
                                   .OrderBy(x => x.Id);

                var optionQuery = _productVariantAttributeValueRepository.TableUntracked
                                  .Where(x => !string.IsNullOrEmpty(x.Alias))
                                  .OrderBy(x => x.Id);

                do
                {
                    variants = new PagedList <ProductAttribute>(variantQuery, pageIndex++, 500);

                    foreach (var variant in variants)
                    {
                        result[CreateKey("vari", 0, variant.Id)] = variant.Alias;
                    }
                }while (variants.HasNextPage);
                pageIndex = 0;
                variants.Clear();

                do
                {
                    options = new PagedList <ProductVariantAttributeValue>(optionQuery, pageIndex++, 500);

                    foreach (var option in options)
                    {
                        result[CreateOptionKey("attr.option", 0, option.Id)] = option.Alias;
                    }
                }while (options.HasNextPage);
                options.Clear();

                CachedLocalizedAlias("ProductAttribute", x => result[CreateKey("vari", x.LanguageId, x.EntityId)] = x.LocaleValue);
                CachedLocalizedAlias("ProductVariantAttributeValue", x => result[CreateOptionKey("vari.option", x.LanguageId, x.EntityId)] = x.LocaleValue);

                return result;
            }));
        }
        public void AddItemsAndClear()
        {
            const int length = 4 * 1024;

            var list = new PagedList <int>();

            for (int i = 0; i < length; i++)
            {
                list.Add(i);
            }

            Assert.Equal(length, list.Count);

            for (int i = 0; i < length; i++)
            {
                Assert.Equal(i, list[i]);
            }

            list.Clear();

            Assert.Equal(0, list.Count);
        }
        public void InsertItemsAndClear()
        {
            const int length = 4 * 1024;

            var list = new PagedList <int>();

            for (int i = 0; i < length; i++)
            {
                list.Insert(0, i);
            }

            Assert.Equal(length, list.Count);

            for (int i = 0, j = length - 1; i < length; i++, j--)
            {
                Assert.Equal(j, list[i]);
            }

            list.Clear();

            Assert.Equal(0, list.Count);
        }