Exemple #1
0
        private List <T> selectExVertical <T>(int index, int pageSize) where T : class, new()
        {
            List <t1_code> fileds = new t1_code().Select <t1_code>().ToList();
            //Guid tableid = fileds.First().table_id;
            List <t1_house>   infos = new t1_house().Select <t1_house>(index, pageSize, "createtime desc");
            ConcurrentBag <T> res   = new ConcurrentBag <T>();
            Type typeInfo           = typeof(T);
            var  properties         = typeInfo.GetProperties().ToList();
            //计算机 内核数量 最大并发数
            ParallelOptions opt = new ParallelOptions
            {
                MaxDegreeOfParallelism = 2
            };

            //List<FiledAuth> filedAuths = GetFiledAuth(tableName, "0c945d67-c95d-4ecc-8e7a-3e63e040ec7a");
            Parallel.ForEach(infos, opt, info =>
            {
                T model = new T();
                //List<new_filed_modify_log> filedValues = total.Where(o => o.resource_id == info.id).ToList();
                List <t1_history> filedValues = new t1_history(true).Select <t1_history>(o => o.houseid == info.id).ToList();
                Parallel.ForEach(properties, opt, p =>
                {
                    t1_code filed = fileds.Where(o => o.name == p.Name).FirstOrDefault();

                    //if (filedAuths.Where(o => o.id == filed.id).FirstOrDefault().auth)
                    //{
                    var value = filedValues.Where(o => o.codeid == filed.id).FirstOrDefault().value;
                    Task.Run(() => { p.SetValue(model, value); }).ConfigureAwait(false);
                    //}
                });
                res.Add(model);
            });

            return(res.ToList());
        }
Exemple #2
0
        public void AddTest()
        {
            int id = 0;

            for (int i = 1; i <= 40000; i++)
            {
                t1_code        code       = new t1_code();
                PropertyInfo[] properties = code.GetType().GetProperties();
                int            z          = 1;
                foreach (var p in properties)
                {
                    t1_history model = new t1_history();
                    if (p.Name == "column2" ||
                        p.Name == "column3" ||
                        p.Name == "column4" ||
                        p.Name == "column5" ||
                        p.Name == "column6" ||
                        p.Name == "column7" ||
                        p.Name == "column8" ||
                        p.Name == "column9" ||
                        p.Name == "column10" ||
                        p.Name == "column11" ||
                        p.Name == "column12" ||
                        p.Name == "column13" ||
                        p.Name == "column14")
                    {
                        for (int j = 1; j <= 14; j++)
                        {
                            id               = id + 1;
                            model.id         = id;
                            model.codeid     = z;
                            model.houseid    = i;
                            model.value      = $"{i}-{p.Name}{z}-{j}";
                            model.createtime = DateTime.Now;
                            model.opreatorid = Guid.NewGuid();
                        }
                    }
                    else
                    {
                        id               = id + 1;
                        model.id         = id;
                        model.codeid     = z;
                        model.houseid    = i;
                        model.value      = $"{i}-column{z}";
                        model.createtime = DateTime.Now;
                        model.opreatorid = Guid.NewGuid();
                    }
                    model.Insert();
                    z = z + 1;
                }
            }
        }
        private void AddModel(int i, int j)
        {
            id++;
            t1_history history = new t1_history()
            {
                id         = id,
                codeid     = j,
                houseid    = i,
                createtime = DateTime.Now,
                opreatorid = Guid.NewGuid(),
                value      = i.ToString() + "-" + "column" + j.ToString()
            };

            history.Insert();
        }