//添加元属性页面
        public IActionResult add_ysx()
        {
            var p = new YSX_Model("1");

            ViewData["YSX_Model"] = p;
            //维度信息查询
            M_Db_Operate m_Db_Operate = new M_Db_Operate();
            var          collection   = m_Db_Operate.database.GetCollection <Dimension_Information_Model>("Dimension_Information");

            //查询维度
            List <string> key = new List <string>();

            key.Add("TYPE");
            List <string> value = new List <string>();

            value.Add("资产类别维度");
            var type0 = m_Db_Operate.Inquire_Data(collection, key, value);

            value[0] = "应用特性维度";
            var type1 = m_Db_Operate.Inquire_Data(collection, key, value);

            value[0] = "管理者维度";
            var type2 = m_Db_Operate.Inquire_Data(collection, key, value);

            value[0] = "自定义维度";
            var type3 = m_Db_Operate.Inquire_Data(collection, key, value);

            ViewData["type0"] = type0;
            ViewData["type1"] = type1;
            ViewData["type2"] = type2;
            ViewData["type3"] = type3;

            return(View());
        }
 //元属性删除完成动作
 public IActionResult Del_ysx_OK(IFormCollection f)
 {
     try
     {
         var name = f["One_Class"];
         if (name == "")
         {
             return(View("../Home/add_ERROR"));
         }
         var          type         = f["Kindda"];
         M_Db_Operate m_Db_Operate = new M_Db_Operate();
         var          coll         = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");
         //List<string> KEY = new List<string>();
         //List<string> Value = new List<string>();
         //KEY.Add("Dimension_dic.资产类别维度");
         //KEY.Add("Name");
         //Value.Add(type);
         //Value.Add(name);
         //var res = m_Db_Operate.Inquire_Data(coll, KEY, Value);
         m_Db_Operate.Del_Data(coll, "ID", name);
     }
     catch
     {
         return(View("../Home/add_ERROR"));
     }
     return(View("../Home/add_OK"));
 }
Example #3
0
        [HttpGet]//查询资产类别的信息
        public List <List <string> > Get_Type(string type)
        {
            //从数据库获取类别信息并返回 获取到的元属性名称
            List <string> zy_name = new List <string>();
            List <string> kz_name = new List <string>();

            List <string> key = new List <string>();

            key.Add("ID");
            Class_template old = new Class_template(type);

            for (int i = 0; i < old.ZC_SX.Count; i++)
            {
                M_Db_Operate  m_Db_Operate = new M_Db_Operate();
                var           collection   = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");
                List <string> value        = new List <string>();
                value.Add(old.ZC_SX[i]);
                var resu = m_Db_Operate.Inquire_Data(collection, key, value);
                if (resu[0].Dimension_dic["资产类别维度"].Contains("专用集"))
                {
                    zy_name.Add(resu[0].Name);
                }
                else if (resu[0].Dimension_dic["资产类别维度"].Contains("扩展集"))
                {
                    kz_name.Add(resu[0].Name);
                }
            }
            List <List <string> > data = new List <List <string> >();

            data.Add(zy_name);
            data.Add(kz_name);
            return(data);
        }
 //资产删除完成动作
 public IActionResult Del_zc_OK(IFormCollection f)
 {
     try
     {
         string id;
         if (f["zc_id"] == "-- 资产编码 --")
         {
             id = f["int_zc_"];
         }
         else
         {
             id = f["zc_id"];
         }
         M_Db_Operate m_Db_Operate = new M_Db_Operate();
         var          coll         = m_Db_Operate.database.GetCollection <SJ_ZC_Model>("ZC_data");
         if (!m_Db_Operate.Del_Data(coll, "ZCBM", id))
         {
             return(View("../Home/add_ERROR"));
         }
         return(View("../Home/add_OK"));
     }
     catch (InvalidCastException e)
     {
         ViewData["e"] = e.ToString();
         return(View("../Home/add_ERROR"));
     };
 }
        //元属性修改完成动作
        public IActionResult Up_Ysx_OK(IFormCollection f)
        {
            try
            {
                var p = new YSX_Model();
                p.ID        = f["ID"];
                p.Name      = f["One_Class"];
                p.Length    = f["Length"];
                p.Unit      = f["Unit"];
                p.Remarks   = f["Remarks"];
                p.Edition   = f["Edition"];
                p.Data_Type = f["Data_Type"];

                M_Db_Operate m_Db_Operate = new M_Db_Operate();
                var          coll         = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");
                //m_Db_Operate.Up_Data(coll, "ID", p.ID, "ID", p.ID);
                m_Db_Operate.Up_Data(coll, "ID", p.ID, "Length", p.Length);
                m_Db_Operate.Up_Data(coll, "ID", p.ID, "Remarks", p.Remarks);
                m_Db_Operate.Up_Data(coll, "ID", p.ID, "Unit", p.Unit);
                m_Db_Operate.Up_Data(coll, "ID", p.ID, "Data_Type", p.Data_Type);
                m_Db_Operate.Up_Data(coll, "ID", p.ID, "Edition", p.Edition);
                //m_Db_Operate.Up_Data(coll, "ID", p.ID, "Dimension_dic", p.Dimension_dic);
            }
            catch
            {
                return(View("../Home/add_ERROR"));
            }
            return(View("../Home/add_OK"));
        }
Example #6
0
        //资产类别修改界面
        public IActionResult manage_zc_type()
        {
            ViewData["ty_names"] = ty_names;
            //从数据库中读取数据
            M_Db_Operate m_Db_Operate = new M_Db_Operate();
            var          collection   = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");
            var          result       = m_Db_Operate.Inquire_Data(collection, type: 2).ToList();

            return(View());
        }
        //元属性查询方式2:元属性名称查询
        public IActionResult query_ysx_2(IFormCollection f)
        {
            string ysx_2 = f["ysx_name"];
            var    p     = new YSX_Model();

            try
            {
                //这里用来查询数据库,整合数据
                M_Db_Operate m_Db_Operate = new M_Db_Operate();
                var          collection   = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");

                List <string> key = new List <string>();
                key.Add("Name");
                List <string> value = new List <string>();
                value.Add(ysx_2);
                var Result = m_Db_Operate.Inquire_Data(collection, key, value);

                string[] wd_name = new string[4];
                wd_name[0] = "应用特性维度";
                wd_name[1] = "管理者维度";
                wd_name[2] = "扩展资产类别维度";
                wd_name[3] = "自定义维度";
                for (var i = 0; i < Result.Count; i++)
                {
                    for (var j = 0; j < wd_name.Length; j++)
                    {
                        try
                        {
                            var a = Result[i].Dimension_dic[wd_name[j]];
                        }
                        catch
                        {
                            Result[i].Dimension_dic.Add(wd_name[j], "null");
                        };
                    }
                }

                ViewData["ysx_name"] = ysx_2;
                ViewData["wd_name"]  = null;
                ViewData["f_l"]      = null;
                ViewData["wd_list"]  = wd_name.ToList <string>();
                ViewData["YSX_DATA"] = Result;
            }
            catch (InvalidCastException e)
            {
                ViewData["e"] = e.ToString();
                return(View("query_ERROR"));
            }
            ViewData["YSX_Model"] = p;
            return(View("query_ysx"));
        }
 //删除维度完成
 public IActionResult Del_wd_OK(IFormCollection f)
 {
     try
     {
         var          name         = f["One_Class"];
         M_Db_Operate m_Db_Operate = new M_Db_Operate();
         var          coll         = m_Db_Operate.database.GetCollection <Dimension_Information_Model>("Dimension_Information");
         m_Db_Operate.Del_Data(coll, "NAME", name);
     }
     catch
     {
         return(View("../Home/add_ERROR"));
     }
     return(View("../Home/add_OK"));
 }
        //TODO:添加一些资产
        public IActionResult add_zc_ten()
        {
            M_Db_Operate m_Db_Ct = new M_Db_Operate();
            var          coll    = m_Db_Ct.database.GetCollection <Class_template>("Class_templates");
            M_Db_Operate zc_db   = new M_Db_Operate();
            var          zc_coll = zc_db.database.GetCollection <SJ_ZC_Model>("ZC_data");
            int          number  = zc_db.Inquire_Data(zc_coll, type: 2).Count;
            var          types   = m_Db_Ct.Inquire_Data(coll, type: 2);

            foreach (var type in types)
            {
                List <SJ_ZC_Model> sj_zc_s = new List <SJ_ZC_Model>();
                var res = m_Db_Ct.Get_Aggregate("Class_templates",
                                                new List <string>()
                {
                    "TPYE"
                },
                                                new List <string>()
                {
                    type.TPYE
                },
                                                new List <string>()
                {
                    "Meta_attribute"
                },
                                                new List <string>()
                {
                    "ZC_SX"
                },
                                                new List <string>()
                {
                    "ID"
                },
                                                new List <string>()
                {
                    "ZC_SX"
                })[0];
                for (int i = 0; i < 27273; i++)
                {
                    number++;
                    SJ_ZC_Model sJ_ZC = new SJ_ZC_Model(res, type.TPYE, number);
                    sj_zc_s.Add(sJ_ZC);
                }
                zc_coll.InsertMany(sj_zc_s);
            }
            //总条目数
            return(query_zc());
        }
        public Class_template(String type)
        {
            ZC_SX = new List <string>();
            TPYE  = type;
            M_Db_Operate m_Db_Operate = new M_Db_Operate();
            var          client       = new MongoClient("mongodb://127.0.0.1:27017");
            var          database     = client.GetDatabase("test");
            var          collection   = database.GetCollection <Class_template>("Class_templates");

            List <string> key   = new List <string>();
            List <string> value = new List <string>();

            key.Add("TPYE");
            value.Add(type);
            ZC_SX = m_Db_Operate.Inquire_Data(collection, key, value)[0].ZC_SX;
        }
Example #11
0
        [HttpGet]//获取元属性信息
        public YSX_Model Get_YSX_XX(string Name, string Type)
        {
            M_Db_Operate m_Db_Operate = new M_Db_Operate();
            var          collection   = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");

            List <string> key   = new List <string>();
            List <string> value = new List <string>();

            key.Add("Dimension_dic." + "资产类别维度");
            value.Add(Type);
            key.Add("Name");
            value.Add(Name);
            var Result = m_Db_Operate.Inquire_Data(collection, key, value);

            return(Result[0]);
        }
Example #12
0
 [HttpGet] //获取维度信息
 public Dimension_Information_Model Get_WD_XX(string Name)
 {
     try
     {
         List <string> key   = new List <string>();
         List <string> value = new List <string>();
         key.Add("NAME");
         value.Add(Name);
         M_Db_Operate m_Db_Operate = new M_Db_Operate();
         var          collection   = m_Db_Operate.database.GetCollection <Dimension_Information_Model>("Dimension_Information");
         var          resule       = m_Db_Operate.Inquire_Data(collection, key, value);
         return(resule[0]);
     }
     catch
     {
         return(null);
     }
 }
        public Class_templates(string TYPE)
        {
            TPYE  = TYPE;
            KZ_SX = new List <string>();
            //从数据库中读取资产类别的元属性名称
            M_Db_Operate  m_Db_Operate = new M_Db_Operate();
            var           client       = new MongoClient("mongodb://127.0.0.1:27017");
            var           database     = client.GetDatabase("test");
            var           collection   = database.GetCollection <Class_templates>("Class_templates");
            List <string> key          = new List <string>();

            key.Add("TPYE");
            List <string> value = new List <string>();

            value.Add(TPYE);
            //读取
            KZ_SX = m_Db_Operate.Inquire_Data(collection, key, value)[0].KZ_SX;
        }
Example #14
0
        [HttpGet]//获取已有类别下的类别名称
        public List <string> Get_Two_Type(string type)
        {
            //从数据库获取类别信息并返回 获取到的元属性名称
            List <string> data  = new List <string>();
            List <string> key   = new List <string>();
            List <string> value = new List <string>();

            key.Add("F_id");
            value.Add(type);
            M_Db_Operate m_Db_Operate = new M_Db_Operate();
            var          collection   = m_Db_Operate.database.GetCollection <Class_template>("Class_templates");
            var          resule       = m_Db_Operate.Inquire_Data(collection, key, value);

            for (int i = 0; i < resule.Count; i++)
            {
                data.Add(resule[i].TPYE);
            }
            return(data);
        }
Example #15
0
        [HttpGet]//获取维度下全部元属性名称
        public Dictionary <string, string> Get_YSXS_Name(string WD, string Name)
        {
            M_Db_Operate m_Db_Operate = new M_Db_Operate();
            var          collection   = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");

            List <string> key   = new List <string>();
            List <string> value = new List <string>();

            key.Add("Dimension_dic." + WD);
            value.Add(Name);
            var Result = m_Db_Operate.Inquire_Data(collection, key, value);
            Dictionary <string, string> names = new Dictionary <string, string>();

            foreach (var i in Result)
            {
                names.Add(i.ID, i.Name);
            }
            return(names);
        }
        //添加元属性完成动作
        public IActionResult addYSX_OK(IFormCollection f)
        {
            var p = new YSX_Model();

            p.ID        = f["ID"];
            p.Length    = f["Length"];
            p.Name      = f["Name"];
            p.Unit      = f["Unit"];
            p.Remarks   = f["Remarks"];
            p.Edition   = f["Edition"];
            p.Data_Type = f["Data_Type"];
            List <string> keys  = new List <string>();
            List <string> value = new List <string>();
            List <Dictionary <string, string> > WDs = new List <Dictionary <string, string> >();
            int j = 0;

            for (int i = 0; i < f.Count; i++)
            {
                if (f.Keys.ToArray()[i].Contains("ysx_wd_key_"))
                {
                    keys.Add(f["ysx_wd_key_" + (j + 1).ToString()]);
                    value.Add(f["ysx_wd_value_" + (j + 1).ToString()]);
                    p.Dimension_dic[keys[j]] = value[j];
                    j++;
                }
            }
            ;
            //在这里将数据插入数据库
            try
            {
                M_Db_Operate m_Db_Operate = new M_Db_Operate();
                var          collection   = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");

                m_Db_Operate.Insert_Data(collection, p);
                return(View("../Home/add_OK"));
            }
            catch (InvalidCastException e)
            {
                ViewData["e"] = e.ToString();
                return(View("../Home/add_ERROR"));
            }
        }
Example #17
0
        //资产类类别添加完成
        public IActionResult addTYPE_OK(IFormCollection f)
        {
            var type_name = f["type_name"].ToString();
            var F_name    = f["F_name"].ToString();

            try
            {
                Class_template old = new Class_template(F_name);
                old.TPYE = type_name;
                old.F_id = F_name;
                M_Db_Operate m_Db_Operate = new M_Db_Operate();
                var          collection   = m_Db_Operate.database.GetCollection <Class_template>("Class_templates");
                m_Db_Operate.Insert_Data(collection, old);
                return(View("../Home/add_OK"));
            }
            catch (InvalidCastException e)
            {
                ViewData["e"] = e.ToString();
                return(View("../Home/add_ERROR"));
            }
        }
        //添加维度完成 -- 没有用到
        public IActionResult addWD_OK(IFormCollection f)
        {
            Dimension_Information_Model D_M = new Dimension_Information_Model();

            D_M.NAME    = f["wd_name"];
            D_M.ID      = f["wd_id"];
            D_M.Remarks = f["bg"];

            //在这里将数据插入数据库
            try
            {
                M_Db_Operate m_Db_Operate = new M_Db_Operate();
                var          collection   = m_Db_Operate.database.GetCollection <Dimension_Information_Model>("Dimension_Information");
                m_Db_Operate.Insert_Data(collection, D_M);
                return(View("../Home/add_OK"));
            }
            catch (InvalidCastException e)
            {
                ViewData["e"] = e.ToString();
                return(View("../Home/add_ERROR"));
            }
        }
 //修改维度信息完成
 public IActionResult Up_wd_OK(IFormCollection f)
 {
     try
     {
         Dimension_Information_Model now = new Dimension_Information_Model();
         now.ID      = f["wd_id"];
         now.TYPE    = f["wd_type"];
         now.F_ID    = f["wd_F_id"];
         now.Remarks = f["bg"];
         now.NAME    = f["One_Class"];
         M_Db_Operate m_Db_Operate = new M_Db_Operate();
         var          coll         = m_Db_Operate.database.GetCollection <Dimension_Information_Model>("Dimension_Information");
         m_Db_Operate.Up_Data(coll, "NAME", now.NAME, "ID", now.ID);
         m_Db_Operate.Up_Data(coll, "NAME", now.NAME, "TYPE", now.TYPE);
         m_Db_Operate.Up_Data(coll, "NAME", now.NAME, "F_ID", now.F_ID);
         m_Db_Operate.Up_Data(coll, "NAME", now.NAME, "Remarks", now.Remarks);
     }
     catch
     {
         return(View("../Home/add_ERROR"));
     }
     return(View("../Home/add_OK"));
 }
Example #20
0
        //资产类别删除完成
        public IActionResult del_type(IFormCollection f)
        {
            var    Kindda    = f["Kindda"];
            var    One_Class = f["One_Class"];
            string type;

            try
            {
                if (Kindda == "-- 门类 -- ")
                {
                    return(View("../Home/add_ERROR"));
                }
                if (One_Class == "不选择--")
                {
                    type = Kindda;
                }
                else if (One_Class == "-- 大类 --")
                {
                    return(View("../Home/add_ERROR"));
                }
                else
                {
                    type = One_Class;
                }
                M_Db_Operate m_Db_Operate = new M_Db_Operate();
                var          collection   = m_Db_Operate.database.GetCollection <Class_template>("Class_templates");
                if (m_Db_Operate.Del_Data(collection, "TPYE", type) == false)
                {
                    return(View("../Home/add_ERROR"));
                }
            }
            catch
            {
                return(View("../Home/add_ERROR"));
            }
            return(View("../Home/add_OK"));
        }
Example #21
0
        public SX_Model(string Names)
        {
            M_Db_Operate m_Db_Operate = new M_Db_Operate();
            var          client       = new MongoClient("mongodb://127.0.0.1:27017");
            var          database     = client.GetDatabase("test");
            var          collection   = database.GetCollection <YSX_Model>("Meta_attribute");

            List <string> key0 = new List <string>();

            key0.Add("Name");
            List <string> value0 = new List <string>();

            value0.Add(Names);
            var ysx0 = m_Db_Operate.Inquire_Data(collection, key0, value0);  //查询数据

            ID            = ysx0[0].ID;
            Name          = ysx0[0].Name;
            Length        = ysx0[0].Length;
            Remarks       = ysx0[0].Remarks;
            Unit          = ysx0[0].Unit;
            Dimension_dic = ysx0[0].Dimension_dic;
            Edition       = ysx0[0].Edition;
            // _id = ysx0[0]._id;
        }
Example #22
0
        [HttpGet]//根据资产类别获取该类别下全部维度名称
        public List <string> Get_WD_name(string Type)
        {
            List <string> name = new List <string>();

            try
            {
                List <string> key   = new List <string>();
                List <string> value = new List <string>();
                key.Add("TYPE");
                value.Add(Type);
                M_Db_Operate m_Db_Operate = new M_Db_Operate();
                var          collection   = m_Db_Operate.database.GetCollection <Dimension_Information_Model>("Dimension_Information");
                var          resule       = m_Db_Operate.Inquire_Data(collection, key, value);
                for (int i = 0; i < resule.Count; i++)
                {
                    name.Add(resule[i].NAME);
                }
            }
            catch
            {
                return(null);
            }
            return(name);
        }
Example #23
0
        [HttpGet]//获取一个类别下所有的资产名称和资产编码
        public List <List <string> > Get_ZC_NI(string Type, string Name = null, int n = 0)
        {
            try
            {
                List <string> key   = new List <string>();
                List <string> value = new List <string>();
                if (Name != null)
                {
                    M_Db_Operate m_Db_Operate = new M_Db_Operate();
                    var          collection   = m_Db_Operate.database.GetCollection <SJ_ZC_Model>("ZC_data");
                    FilterDefinitionBuilder <SJ_ZC_Model> builderFilters = Builders <SJ_ZC_Model> .Filter;
                    FilterDefinitionBuilder <SJ_SX_Model> builderFilter  = Builders <SJ_SX_Model> .Filter;
                    var filter = builderFilters.ElemMatch("ZC_SX", builderFilter.And(builderFilter.Eq("V", Name), builderFilter.Eq("mp", "0004")));
                    var result = collection.Find(filter).ToList();
                    var s      = from one in result
                                 from sx in one.ZC_SX
                                 where sx.mp == "0004"
                                 select sx.V;
                    List <string> sn = s.GroupBy(p => p).Select(g => g.First()).ToList();
                    s = from one in result
                        from sx in one.ZC_SX
                        where sx.mp == "0003"
                        select sx.V;
                    List <string> si = new List <string>();
                    if (Name != null)
                    {
                        si = s.Distinct().ToList();
                    }
                    List <List <string> > resu = new List <List <string> >()
                    {
                        sn, si
                    };
                    return(resu);
                }
                else
                {
                    M_Db_Operate m_Db_Operate = new M_Db_Operate();
                    var          collection   = m_Db_Operate.database.GetCollection <SJ_ZC_Model>("ZC_data");
                    FilterDefinitionBuilder <SJ_ZC_Model> builderFilters = Builders <SJ_ZC_Model> .Filter;
                    FilterDefinitionBuilder <SJ_SX_Model> builderFilter  = Builders <SJ_SX_Model> .Filter;
                    FilterDefinition <SJ_ZC_Model>        filter         = builderFilters.ElemMatch("ZC_SX", builderFilter.And(builderFilter.Eq("V", Type), builderFilter.Eq("mp", "0002")));
                    var result = collection.Find(filter).ToList();
                    var s      = from one in result
                                 from sx in one.ZC_SX
                                 where sx.mp == "0004"
                                 select sx.V;
                    List <string> sn = s.GroupBy(p => p).Select(g => g.First()).ToList();
                    s = from one in result
                        from sx in one.ZC_SX
                        where sx.mp == "0003"
                        select sx.V;
                    List <string> si = new List <string>();
                    if (Name != null)
                    {
                        si = s.Distinct().ToList();
                    }
                    List <List <string> > resu = new List <List <string> >()
                    {
                        sn, si
                    };
                    return(resu);
                }
                //M_Db_Operate m_Db_Operate = new M_Db_Operate();
                //var collection = m_Db_Operate.database.GetCollection<SJ_ZC_Model>("ZC_data");
                //FilterDefinitionBuilder<SJ_ZC_Model> builderFilter = Builders<SJ_ZC_Model>.Filter;
                ////约束条件
                //List<FilterDefinition<SJ_ZC_Model>> builderFilterss = new List<FilterDefinition<SJ_ZC_Model>>();
                //for (int i = 0; i < key.Count; i++)
                //    builderFilterss.Add(builderFilter.Eq(key[i], value[i]));
                //FilterDefinition<SJ_ZC_Model> filter = builderFilter.And(builderFilterss.ToArray());
                ////获取数据
                //var res = collection.Find(filter).Skip(n * 100).ToList();
                //var s = from one in res
                //         from sx in one.ZC_SX
                //         where sx.mp == "0004"
                //         select sx.V;
                //List<string> sn = s.GroupBy(p => p).Select(g => g.First()).ToList();
                //s = from one in res
                //    from sx in one.ZC_SX
                //    where sx.mp == "0003"
                //    select sx.V;
                //List<string> si = new List<string>();
                //if (Name != null)
                //    si = s.Distinct().ToList();
                //var res = m_Db_Operate.Inquire_Data(collection, key, value).Skip(1).Take(100).ToList();

                /*List<string> name = new List<string>();
                 * List<string> ID = new List<string>();
                 * for (int i = 0; i < res.Count; i++)
                 * {
                 *  for (int j = 0; j < res[i].ZC_SX.Count; j++)
                 *  {
                 *      if (res[i].ZC_SX[j].mp == "0004")
                 *          if (!name.Contains(res[i].ZC_SX[j].V))
                 *              name.Add(res[i].ZC_SX[j].V);
                 *      if(res[i].ZC_SX[j].mp == "0003")
                 *          ID.Add(res[i].ZC_SX[j].V);
                 *  }
                 * }*/
            }
            catch (Exception e)
            {
                return(null);
            }
        }
        //按照管理者维度查找
        //public IActionResult query_zc_3(IFormCollection f)
        //{
        //    string guanlizhe = f["glz"];
        //    try
        //    {
        //        M_Db_Operate m_Db_Operate = new M_Db_Operate();
        //        var collection1 = m_Db_Operate.database.GetCollection<Dimension_Information_Model>("Dimension_Information");

        //        List<string> key1 = new List<string>();
        //        key1.Add("TYPE");
        //        List<string> value1 = new List<string>();
        //        value1.Add("管理者维度");
        //        var Result1 = m_Db_Operate.Inquire_Data(collection1, key1, value1);
        //        List<string> name = new List<string>();
        //        for (var i = 0; i < Result1.Count; i++)
        //        {
        //            name.Add(Result1[i].NAME);
        //        }
        //        ViewData["glz_list"] = name;
        //        //在这里查询数据库并整合数据
        //        var collection = m_Db_Operate.database.GetCollection<YSX_Model>("Meta_attribute");

        //        List<string> key = new List<string>();
        //        key.Add("Dimension_dic.管理者维度");
        //        List<string> value = new List<string>();
        //        value.Add(guanlizhe);
        //        var Result = m_Db_Operate.Inquire_Data(collection, key, value);

        //        List<string> results = new List<string>();
        //        for (var i = 0; i < Result.Count; i++)
        //        {
        //            results.Add(Result[i].Name);
        //        }
        //        List<string> value2 = new List<string>();
        //        value2.Add("默认管理者");
        //        Result = m_Db_Operate.Inquire_Data(collection, key, value2);
        //        for (var i = 0; i < Result.Count; i++)
        //        {
        //            results.Add(Result[i].Name);
        //        }
        //        var collection2 = m_Db_Operate.database.GetCollection<SJ_ZC_Model>("ZC_data");
        //        FilterDefinitionBuilder<SJ_ZC_Model> builderFilter = Builders<SJ_ZC_Model>.Filter;
        //        var result = collection2.FindSync<SJ_ZC_Model>(builderFilter.Empty).ToList();

        //        List<List<string>> ZC_datas = new List<List<string>>();
        //        for (var i = 0; i < result.Count; i++)
        //        {
        //            List<string> ZC_data = new List<string>();
        //            ZC_data.Add(sx_name[0] + ":" +result[i].SJZCFLBM.V.ToString());
        //            ZC_data.Add(sx_name[1] + ":" +result[i].SJZCFLMC.V.ToString());
        //            ZC_data.Add(sx_name[2] + ":" +result[i].ZCBM.V.ToString());
        //            ZC_data.Add(sx_name[3] + ":" +result[i].ZCMC.V.ToString());
        //            ZC_data.Add(sx_name[4] + ":" +result[i].YWMC.V.ToString());
        //            ZC_data.Add(sx_name[5] + ":" +result[i].SL.V.ToString());
        //            ZC_data.Add(sx_name[6] + ":" +result[i].JLDW.V.ToString());
        //            ZC_data.Add(sx_name[7] + ":" +result[i].ZMJZ.V.ToString());
        //            ZC_data.Add(sx_name[8] + ":" +result[i].JZLX.V.ToString());
        //            ZC_data.Add(sx_name[9] + ":" +result[i].BiZ.V.ToString());
        //            ZC_data.Add(sx_name[10] + ":" +result[i].GB.V.ToString());
        //            ZC_data.Add(sx_name[11] + ":" +result[i].QDRQ.V.ToString());
        //            ZC_data.Add(sx_name[12] + ":" +result[i].KSKYRQ.V.ToString());
        //            ZC_data.Add(sx_name[13] + ":" +result[i].YT.V.ToString());
        //            ZC_data.Add(sx_name[14] + ":" +result[i].SYZK.V.ToString());
        //            ZC_data.Add(sx_name[15] + ":" +result[i].SYFX.V.ToString());
        //            ZC_data.Add(sx_name[16] + ":" +result[i].QDFS.V.ToString());
        //            ZC_data.Add(sx_name[17] + ":" +result[i].KJPZH.V.ToString());
        //            ZC_data.Add(sx_name[18] + ":" +result[i].SYBM.V.ToString());
        //            ZC_data.Add(sx_name[19] + ":" +result[i].SYR.V.ToString());
        //            ZC_data.Add(sx_name[20] + ":" +result[i].BZ.V.ToString());
        //            string kz_sx = "";
        //            M_Db_Operate m_Db_ = new M_Db_Operate();
        //            var coll = m_Db_.database.GetCollection<YSX_Model>("Meta_attribute");
        //            List<string> key2 = new List<string>();
        //            key2.Add("ID");
        //            for (var j = 0; j < result[i].ZY_SX.Count; j++)
        //            {
        //                List<string> value3 = new List<string>();
        //                value3.Add(result[i].ZY_SX[j].mp.ToString());
        //                var su = m_Db_.Inquire_Data(coll, key2, value3);
        //                kz_sx += su[0].Name.ToString() + " : " + result[i].ZY_SX[j].V.ToString() + "     ";
        //            }
        //            for (var j = 0; j < result[i].KJ_SX.Count; j++)
        //            {
        //                List<string> value3 = new List<string>();
        //                value3.Add(result[i].KJ_SX[j].mp.ToString());
        //                var su = m_Db_.Inquire_Data(coll, key2, value3);
        //                kz_sx += su[0].Name.ToString() + " : " + result[i].KJ_SX[j].V.ToString() + "     ";
        //            }
        //            ZC_data.Add(kz_sx);
        //            ZC_datas.Add(ZC_data);
        //        }
        //        ViewData["ZC_datas"] = ZC_datas;
        //        ViewData["sx_name"] = sx_name;
        //    }
        //    catch (InvalidCastException e)
        //    {
        //        ViewData["e"] = e.ToString();
        //        return View("query_ERROR");
        //    }
        //    ViewData["glz"] = guanlizhe;
        //    ViewData["zc_name"] = null;
        //    ViewData["ysx_name"] = null;
        //    ViewData["ysx_value"] = null;
        //    return View("query_zc");
        //}

        //添加资产完成动作
        public IActionResult addZC_OK(IFormCollection f)
        {
            string Kindda, One_Class;

            Kindda    = f["Kindda"];
            One_Class = f["One_Class"];
            //Two_Class = f["Two_Class"];
            SJ_ZC_Model SJ_ZC = new SJ_ZC_Model();

            for (int i = 1; i < ty_names.Count; i++)
            {
                SJ_SX_Model sJ_SX_ = new SJ_SX_Model();
                sJ_SX_.V = f[ty_names[i - 1]];
                if (i > 9)
                {
                    sJ_SX_.mp = "00" + i.ToString();
                }
                else
                {
                    sJ_SX_.mp = "000" + i.ToString();
                }
                SJ_ZC.ZC_SX.Add(sJ_SX_);
            }
            SJ_ZC.ZCBM = f["资产编码"];
            Class_template old = new Class_template();

            if (One_Class == "不选择--")
            {
                old = new Class_template(Kindda);
            }
            else
            {
                old = new Class_template(One_Class);
            }
            List <string> key = new List <string>();

            key.Add("ID");
            M_Db_Operate m_Db_Operate = new M_Db_Operate();
            var          collection   = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");

            for (var i = 1; i < old.ZC_SX.Count; i++)
            {
                SJ_SX_Model   sj_sx = new SJ_SX_Model();
                List <string> value = new List <string>();
                value.Add(old.ZC_SX[i].ToString());
                var resu = m_Db_Operate.Inquire_Data(collection, key, value);
                sj_sx.V  = f[resu[0].Name];
                sj_sx.mp = resu[0].ID.ToString();
                SJ_ZC.ZC_SX.Add(sj_sx);
                if (resu[0].Name == "文物标识")
                {
                    var re_ww = m_Db_Operate.Inquire_Data(collection, new List <string> {
                        "Dimension_dic.应用特性维度"
                    }, new List <string> {
                        "文物信息"
                    });
                    for (int j = 0; j < re_ww.Count; j++)
                    {
                        sj_sx    = new SJ_SX_Model();
                        sj_sx.V  = f[re_ww[j].Name];
                        sj_sx.mp = re_ww[j].ID.ToString();
                        SJ_ZC.ZC_SX.Add(sj_sx);
                    }
                }
                else if (resu[0].Name == "是否包含物联网传感")
                {
                    var re_ww = m_Db_Operate.Inquire_Data(collection, new List <string> {
                        "Dimension_dic.应用特性维度"
                    }, new List <string> {
                        "物联网信息"
                    });
                    for (int j = 0; j < re_ww.Count; j++)
                    {
                        sj_sx    = new SJ_SX_Model();
                        sj_sx.V  = f[re_ww[j].Name];
                        sj_sx.mp = re_ww[j].ID.ToString();
                        SJ_ZC.ZC_SX.Add(sj_sx);
                    }
                }
                else if (resu[0].Name == "陈列品标识")
                {
                    var re_ww = m_Db_Operate.Inquire_Data(collection, new List <string> {
                        "Dimension_dic.应用特性维度"
                    }, new List <string> {
                        "标本信息"
                    });
                    for (int j = 0; j < re_ww.Count; j++)
                    {
                        sj_sx    = new SJ_SX_Model();
                        sj_sx.V  = f[re_ww[j].Name];
                        sj_sx.mp = re_ww[j].ID.ToString();
                        SJ_ZC.ZC_SX.Add(sj_sx);
                    }
                }
            }
            try
            {
                M_Db_Operate m_Db = new M_Db_Operate();
                var          coll = m_Db.database.GetCollection <SJ_ZC_Model>("ZC_data");
                coll.InsertOne(SJ_ZC);
                return(View("../Home/add_OK"));
            }
            catch (InvalidCastException e)
            {
                ViewData["e"] = e.ToString();
                return(View("../Home/add_ERROR"));
            };
        }
Example #25
0
        public SJ_ZC_Model(BsonDocument res, string type, int number)
        {
            Random ra = new Random();

            ZC_SX = new List <SJ_SX_Model>();
            M_Db_Operate YSX_db   = new M_Db_Operate();
            var          ysx_coll = YSX_db.database.GetCollection <YSX_Model>("Meta_attribute");
            int          j        = 0;

            ZCBM = number.ToString();
            while (true)
            {
                try
                {
                    SJ_SX_Model sx = new SJ_SX_Model();
                    sx.mp = res["ZC_SX"][j]["ID"].ToString();
                    if (sx.mp == "0002")
                    {
                        sx.V = type;
                        ZC_SX.Add(sx);
                        j++;
                        continue;
                    }
                    if (sx.mp == "0003")
                    {
                        sx.V = number.ToString();
                        ZC_SX.Add(sx);
                        j++;
                        continue;
                    }
                    if (sx.mp == "0004")
                    {
                        sx.V = type + ra.Next(15).ToString();
                        ZC_SX.Add(sx);
                        j++;
                        continue;
                    }
                    if (res["ZC_SX"][j]["Name"].ToString() == "文物标识")
                    {
                        sx.V = ra.Next(2).ToString();
                        if (sx.V == "1")
                        {
                            var ww_ysx = YSX_db.Inquire_Data(ysx_coll, new List <string>()
                            {
                                "Dimension_dic.应用特性维度"
                            }, new List <string> {
                                "文物信息"
                            });
                            foreach (var ww in ww_ysx)
                            {
                                SJ_SX_Model ww_s = new SJ_SX_Model();
                                if (ww.Data_Type == "整型")
                                {
                                    ww_s.V = ra.Next(1, 100).ToString();
                                }
                                else if (ww.Data_Type == "时间型")
                                {
                                    ww_s.V = Convert.ToDateTime("2007-1-1").AddDays(ra.Next(1000)).ToString();
                                }
                                else
                                {
                                    ww_s.V = ww.Name + ra.Next(1, 100).ToString();
                                }
                                ww_s.mp = ww.ID;
                                ZC_SX.Add(ww_s);
                            }
                        }
                    }
                    else if (res["ZC_SX"][j]["Name"].ToString() == "是否包含物联网传感")
                    {
                        sx.V = ra.Next(2).ToString();
                        if (sx.V == "1")
                        {
                            var wlw_ysx = YSX_db.Inquire_Data(ysx_coll, new List <string>()
                            {
                                "Dimension_dic.应用特性维度"
                            }, new List <string> {
                                "物联网信息"
                            });
                            foreach (var wlw in wlw_ysx)
                            {
                                SJ_SX_Model wlw_s = new SJ_SX_Model();
                                if (wlw.Data_Type == "整型")
                                {
                                    wlw_s.V = ra.Next(1, 100).ToString();
                                }
                                else if (wlw.Data_Type == "时间型")
                                {
                                    wlw_s.V = Convert.ToDateTime("2007-1-1").AddDays(ra.Next(1000)).ToString();
                                }
                                else
                                {
                                    wlw_s.V = wlw.Name + ra.Next(1, 100).ToString();
                                }
                                wlw_s.mp = wlw.ID;
                                ZC_SX.Add(wlw_s);
                            }
                        }
                    }
                    else if (res["ZC_SX"][j]["Name"].ToString() == "陈列品标识")
                    {
                        sx.V = ra.Next(2).ToString();
                        if (sx.V == "1")
                        {
                            var bb_ysx = YSX_db.Inquire_Data(ysx_coll, new List <string>()
                            {
                                "Dimension_dic.应用特性维度"
                            }, new List <string> {
                                "标本信息"
                            });
                            foreach (var bb in bb_ysx)
                            {
                                SJ_SX_Model bb_s = new SJ_SX_Model();
                                if (bb.Data_Type == "整型")
                                {
                                    bb_s.V = ra.Next(1, 100).ToString();
                                }
                                else if (bb.Data_Type == "时间型")
                                {
                                    bb_s.V = Convert.ToDateTime("2007-1-1").AddDays(ra.Next(1000)).ToString();
                                }
                                else
                                {
                                    bb_s.V = bb.Name + ra.Next(1, 100).ToString();
                                }
                                bb_s.mp = bb.ID;
                                ZC_SX.Add(bb_s);
                            }
                        }
                    }
                    else
                    {
                        if (res["ZC_SX"][j]["Data_Type"].ToString() == "整型")
                        {
                            sx.V = ra.Next(1, 100).ToString();
                        }
                        else if (res["ZC_SX"][j]["Data_Type"].ToString() == "时间型")
                        {
                            sx.V = Convert.ToDateTime("2007-1-1").AddDays(ra.Next(1000)).ToString();
                        }
                        else
                        {
                            sx.V = res["ZC_SX"][j]["Name"].ToString() + ra.Next(1, 100).ToString();
                        }
                    }
                    ZC_SX.Add(sx);
                    j++;
                }
                catch
                {
                    break;
                }
            }
        }
 //资产修改完成动作result[0].SJZCFLBM
 public IActionResult Updata_zc_OK(IFormCollection f)
 {
     try
     {
         string id;
         if (f["zc_id"] == "-- 资产编码 --")
         {
             id = f["int_zc_"];
         }
         else
         {
             id = f["zc_id"];
         }
         List <SJ_SX_Model> new_ZC_SX    = new List <SJ_SX_Model>();
         M_Db_Operate       m_Db_Operate = new M_Db_Operate();
         var coll   = m_Db_Operate.database.GetCollection <SJ_ZC_Model>("ZC_data");
         var result = m_Db_Operate.Get_Aggregate(
             "ZC_data",
             new List <string>()
         {
             "ZCBM"
         },
             new List <string>()
         {
             id
         },
             new List <string>()
         {
             "Meta_attribute"
         },
             new List <string>()
         {
             "ZC_SX.mp"
         },
             new List <string>()
         {
             "ID"
         },
             new List <string>()
         {
             "ZC_SXN"
         }
             )[0];
         M_Db_Operate       m_Db       = new M_Db_Operate();
         var                collection = m_Db.database.GetCollection <YSX_Model>("Meta_attribute");
         int                j          = 0;
         int[]              flag       = { 1, 1, 1 };
         List <SJ_SX_Model> del_sx     = new List <SJ_SX_Model>();
         while (true)
         {
             try
             {
                 SJ_SX_Model sx = new SJ_SX_Model();
                 sx.V = f[result["ZC_SXN"][j]["ID"].ToString()];
                 int u = 0;
                 while (true)
                 {
                     try
                     {
                         if (result["ZC_SX"][u]["mp"].ToString() == result["ZC_SXN"][j]["ID"].ToString())
                         {
                             sx.mp = result["ZC_SX"][u]["mp"].ToString();
                             break;
                         }
                         u++;
                     }
                     catch
                     {
                         break;
                     }
                 }
                 //sx.mp = result["ZC_SX"][j]["mp"].ToString();
                 new_ZC_SX.Add(sx);
                 if (result["ZC_SXN"][j]["Name"].ToString() == "文物标识")
                 {
                     if (sx.V == "1")
                     {
                         var ww_resu = m_Db.Inquire_Data(collection, new List <string>()
                         {
                             "Dimension_dic.应用特性维度"
                         }, new List <string>()
                         {
                             "文物信息"
                         });
                         foreach (var ysx in ww_resu)
                         {
                             SJ_SX_Model ww_sx = new SJ_SX_Model();
                             ww_sx.V  = f[ysx.ID];
                             ww_sx.mp = ysx.ID;
                             new_ZC_SX.Add(ww_sx);
                         }
                     }
                     if (sx.V == "0")
                     {
                         var ww_resu = m_Db.Inquire_Data(collection, new List <string>()
                         {
                             "Dimension_dic.应用特性维度"
                         }, new List <string>()
                         {
                             "文物信息"
                         });
                         foreach (var ysx in ww_resu)
                         {
                             SJ_SX_Model ww_sx = new SJ_SX_Model();
                             ww_sx.V  = f[ysx.ID];
                             ww_sx.mp = ysx.ID;
                             del_sx.Add(ww_sx);
                         }
                     }
                 }
                 else if (result["ZC_SXN"][j]["Name"].ToString() == "是否包含物联网传感")
                 {
                     if (sx.V == "1")
                     {
                         var wlw_resu = m_Db.Inquire_Data(collection, new List <string>()
                         {
                             "Dimension_dic.应用特性维度"
                         }, new List <string>()
                         {
                             "物联网信息"
                         });
                         foreach (var ysx in wlw_resu)
                         {
                             SJ_SX_Model wlw_sx = new SJ_SX_Model();
                             wlw_sx.V  = f[ysx.ID];
                             wlw_sx.mp = ysx.ID;
                             new_ZC_SX.Add(wlw_sx);
                         }
                     }
                     if (sx.V == "0")
                     {
                         var wlw_resu = m_Db.Inquire_Data(collection, new List <string>()
                         {
                             "Dimension_dic.应用特性维度"
                         }, new List <string>()
                         {
                             "物联网信息"
                         });
                         foreach (var ysx in wlw_resu)
                         {
                             SJ_SX_Model wlw_sx = new SJ_SX_Model();
                             wlw_sx.V  = f[ysx.ID];
                             wlw_sx.mp = ysx.ID;
                             del_sx.Add(wlw_sx);
                         }
                     }
                 }
                 else if (result["ZC_SXN"][j]["Name"].ToString() == "陈列品标识")
                 {
                     if (sx.V == "1")
                     {
                         var bb_resu = m_Db.Inquire_Data(collection, new List <string>()
                         {
                             "Dimension_dic.应用特性维度"
                         }, new List <string>()
                         {
                             "标本信息"
                         });
                         foreach (var ysx in bb_resu)
                         {
                             SJ_SX_Model bb_sx = new SJ_SX_Model();
                             bb_sx.V  = f[ysx.ID];
                             bb_sx.mp = ysx.ID;
                             new_ZC_SX.Add(bb_sx);
                         }
                     }
                     if (sx.V == "0")
                     {
                         var bb_resu = m_Db.Inquire_Data(collection, new List <string>()
                         {
                             "Dimension_dic.应用特性维度"
                         }, new List <string>()
                         {
                             "标本信息"
                         });
                         foreach (var ysx in bb_resu)
                         {
                             SJ_SX_Model bb_sx = new SJ_SX_Model();
                             bb_sx.V  = f[ysx.ID];
                             bb_sx.mp = ysx.ID;
                             del_sx.Add(bb_sx);
                         }
                     }
                 }
                 j++;
             }
             catch
             {
                 foreach (var del in del_sx)
                 {
                     new_ZC_SX.Remove(del);
                     for (int i = 0; i < new_ZC_SX.Count; i++)
                     {
                         if (new_ZC_SX[i].mp == del.mp)
                         {
                             new_ZC_SX.RemoveAt(i);
                             break;
                         }
                     }
                 }
                 break;
             }
         }
         m_Db_Operate.Up_Data(coll, "ZCBM", f["0003"], "ZC_SX", new_ZC_SX);
         return(View("../Home/add_OK"));
     }
     catch (InvalidCastException e)
     {
         ViewData["e"] = e.ToString();
         return(View("../Home/add_ERROR"));
     };
 }
        //TODO:资产查询界面
        public IActionResult query_zc()
        {
            M_Db_Operate m_Db_Operate = new M_Db_Operate();

            //var zc_coll = m_Db_Operate.database.GetCollection<BsonDocument>("ZC_data");
            //string pipelineJson1 = "{$match:{'ZCBM.V':'1',}}";
            //string pipelineJson2 = "{$lookup:{from: 'Meta_attribute',localField: 'ZY_SX.mp',foreignField: 'ID',as: 'ZY_SX_N'}}";
            //string pipelineJson3 = "{$lookup:{from: 'Meta_attribute',localField: 'KJ_SX.mp',foreignField: 'ID',as: 'KJ_SX_N'}}";
            //IList<IPipelineStageDefinition> stages = new List<IPipelineStageDefinition>();
            //PipelineStageDefinition<BsonDocument, BsonDocument> stage1 =
            //    new JsonPipelineStageDefinition<BsonDocument, BsonDocument>(pipelineJson1);
            //PipelineStageDefinition<BsonDocument, BsonDocument> stage2 =
            //    new JsonPipelineStageDefinition<BsonDocument, BsonDocument>(pipelineJson2);
            //PipelineStageDefinition<BsonDocument, BsonDocument> stage3 =
            //    new JsonPipelineStageDefinition<BsonDocument, BsonDocument>(pipelineJson3);
            ////stages.Add(stage1);
            //stages.Add(stage2);
            //stages.Add(stage3);
            //PipelineDefinition<BsonDocument, BsonDocument> pipeline = new PipelineStagePipelineDefinition<BsonDocument, BsonDocument>(stages);
            //var result = zc_coll.Aggregate(pipeline).ToList();

            List <List <string> > ZC_datas = new List <List <string> >();
            //for (int i = 0; i < result.Count; i++)
            //{
            //    List<string> ZC_data = new List<string>();
            //    ZC_data.Add(sx_name[0] + ":" + result[i]["SJZCFLBM"]["V"].ToString());
            //    ZC_data.Add(sx_name[1] + ":" + result[i]["SJZCFLMC"]["V"].ToString());
            //    ZC_data.Add(sx_name[2] + ":" + result[i]["ZCBM"]["V"].ToString());
            //    ZC_data.Add(sx_name[3] + ":" + result[i]["ZCMC"]["V"].ToString());
            //    ZC_data.Add(sx_name[4] + ":" + result[i]["YWMC"]["V"].ToString());
            //    ZC_data.Add(sx_name[5] + ":" + result[i]["SL"]["V"].ToString());
            //    ZC_data.Add(sx_name[6] + ":" + result[i]["JLDW"]["V"].ToString());
            //    ZC_data.Add(sx_name[7] + ":" + result[i]["ZMJZ"]["V"].ToString());
            //    ZC_data.Add(sx_name[8] + ":" + result[i]["JZLX"]["V"].ToString());
            //    ZC_data.Add(sx_name[9] + ":" + result[i]["BiZ"]["V"].ToString());
            //    ZC_data.Add(sx_name[10] + ":" + result[i]["GB"]["V"].ToString());
            //    ZC_data.Add(sx_name[11] + ":" + result[i]["QDRQ"]["V"].ToString());
            //    ZC_data.Add(sx_name[12] + ":" + result[i]["KSKYRQ"]["V"].ToString());
            //    ZC_data.Add(sx_name[13] + ":" + result[i]["YT"]["V"].ToString());
            //    ZC_data.Add(sx_name[14] + ":" + result[i]["SYZK"]["V"].ToString());
            //    ZC_data.Add(sx_name[15] + ":" + result[i]["SYFX"]["V"].ToString());
            //    ZC_data.Add(sx_name[16] + ":" + result[i]["QDFS"]["V"].ToString());
            //    ZC_data.Add(sx_name[17] + ":" + result[i]["KJPZH"]["V"].ToString());
            //    ZC_data.Add(sx_name[18] + ":" + result[i]["SYBM"]["V"].ToString());
            //    ZC_data.Add(sx_name[19] + ":" + result[i]["SYR"]["V"].ToString());
            //    ZC_data.Add(sx_name[20] + ":" + result[i]["BZ"]["V"].ToString());
            //    string kz_sx = "";
            //    var j = 0;
            //    while (true)
            //    {
            //        try
            //        {
            //            var name1 = result[i]["ZY_SX_N"][j]["Name"].ToString();
            //            var Value = result[0]["ZY_SX"][j]["V"].ToString();
            //            kz_sx += name1 + " : " + Value + "     ";
            //            j++;
            //        }
            //        catch
            //        {
            //            break;
            //        }
            //    }
            //    j = 0;
            //    while (true)
            //    {
            //        try
            //        {
            //            var name1 = result[i]["KJ_SX_N"][j]["Name"].ToString();
            //            var Value = result[0]["KJ_SX"][j]["V"].ToString();
            //            kz_sx += name1 + " : " + Value + "     ";
            //            j++;
            //        }
            //        catch
            //        {
            //            break;
            //        }
            //    }
            //    ZC_data.Add(kz_sx);
            //    ZC_datas.Add(ZC_data);
            //}
            //查询管理者维度
            var collection1 = m_Db_Operate.database.GetCollection <Dimension_Information_Model>("Dimension_Information");

            List <string> key = new List <string>();

            key.Add("TYPE");
            List <string> value = new List <string>();

            value.Add("管理者维度");
            var           Result = m_Db_Operate.Inquire_Data(collection1, key, value);
            List <string> name   = new List <string>();

            for (var i = 0; i < Result.Count; i++)
            {
                name.Add(Result[i].NAME);
            }
            ViewData["glz_list"] = name;
            ViewData["ZC_datas"] = ZC_datas;
            ViewData["sx_name"]  = sx_name;
            return(View("query_zc"));
        }
Example #28
0
        [HttpGet]//根据资产ID获取一个资产的全部信息
        public List <Dictionary <string, SJ_SX_Model> > Get_ZC_XX(string ID)
        {
            try
            {
                List <Dictionary <string, SJ_SX_Model> > resu   = new List <Dictionary <string, SJ_SX_Model> >();
                Dictionary <string, SJ_SX_Model>         TY_SX  = new Dictionary <string, SJ_SX_Model>();
                Dictionary <string, SJ_SX_Model>         ZY_SX  = new Dictionary <string, SJ_SX_Model>();
                Dictionary <string, SJ_SX_Model>         KZ_SX  = new Dictionary <string, SJ_SX_Model>();
                Dictionary <string, SJ_SX_Model>         GZ_WW  = new Dictionary <string, SJ_SX_Model>();
                Dictionary <string, SJ_SX_Model>         GZ_WLW = new Dictionary <string, SJ_SX_Model>();
                Dictionary <string, SJ_SX_Model>         GZ_BB  = new Dictionary <string, SJ_SX_Model>();
                M_Db_Operate m_Db_Operate = new M_Db_Operate();
                var          collection   = m_Db_Operate.database.GetCollection <SJ_ZC_Model>("ZC_data");

                var result = m_Db_Operate.Get_Aggregate(
                    "ZC_data",
                    new List <string>()
                {
                    "ZCBM"
                },
                    new List <string>()
                {
                    ID
                },
                    new List <string>()
                {
                    "Meta_attribute"
                },
                    new List <string>()
                {
                    "ZC_SX.mp"
                },
                    new List <string>()
                {
                    "ID"
                },
                    new List <string>()
                {
                    "ZC_SXN"
                }
                    )[0];
                int j = 0;
                while (true)
                {
                    try
                    {
                        SJ_SX_Model sJ_SX_ = new SJ_SX_Model();
                        sJ_SX_.mp = result["ZC_SXN"][j]["ID"].ToString();
                        int u = 0;
                        while (true)
                        {
                            try
                            {
                                if (result["ZC_SX"][u]["mp"].ToString() == result["ZC_SXN"][j]["ID"].ToString())
                                {
                                    sJ_SX_.V = result["ZC_SX"][u]["V"].ToString();
                                    break;
                                }
                                u++;
                            }
                            catch
                            {
                                break;
                            }
                        }
                        if (result["ZC_SXN"][j]["Dimension_dic"]["资产类别维度"].ToString().Contains("通用集"))
                        {
                            TY_SX.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_);
                        }
                        else if (result["ZC_SXN"][j]["Dimension_dic"]["资产类别维度"].ToString().Contains("专用集"))
                        {
                            ZY_SX.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_);
                        }
                        else if (result["ZC_SXN"][j]["Dimension_dic"]["资产类别维度"].ToString().Contains("扩展集"))
                        {
                            if (result["ZC_SXN"][j]["Dimension_dic"]["应用特性维度"] == "文物信息")
                            {
                                GZ_WW.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_);
                            }
                            else if (result["ZC_SXN"][j]["Dimension_dic"]["应用特性维度"] == "物联网信息")
                            {
                                GZ_WLW.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_);
                            }
                            else if (result["ZC_SXN"][j]["Dimension_dic"]["应用特性维度"] == "标本信息")
                            {
                                GZ_BB.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_);
                            }
                            else
                            {
                                KZ_SX.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_);
                            }
                        }
                        j++;
                    }
                    catch
                    {
                        break;
                    }
                }
                resu.Add(ZY_SX);
                resu.Add(KZ_SX);
                resu.Add(TY_SX);
                resu.Add(GZ_WW);
                resu.Add(GZ_WLW);
                resu.Add(GZ_BB);
                return(resu);
            }
            catch
            {
                return(null);
            }
        }
Example #29
0
 //资产类别修改完成
 public IActionResult addZCTYPE_OK(IFormCollection f)
 {
     try
     {
         string Kindda, One_Class, type;
         Kindda    = f["Kindda"];
         One_Class = f["One_Class"];
         if (One_Class == "不选择--")
         {
             type = Kindda;
         }
         else if (One_Class == "-- 大类 -- ")
         {
             type = null;
         }
         else if (Kindda == "-- 门类 -- ")
         {
             type = null;
         }
         else
         {
             type = One_Class;
         }
         if (type == null)
         {
             ViewData["e"] = "类别错误";
             return(View("../Home/add_ERROR"));
         }
         Class_template zc_type      = new Class_template();
         M_Db_Operate   m_Db_Operate = new M_Db_Operate();
         var            collection   = m_Db_Operate.database.GetCollection <YSX_Model>("Meta_attribute");
         List <string>  key          = new List <string>();
         key.Add("Name");
         int i = 1;
         while (true)
         {
             var name = f["kz_key_" + i.ToString()];
             if (name.ToString() == "")
             {
                 break;
             }
             else
             {
                 List <string> value = new List <string>();
                 value.Add(name);
                 var Result = m_Db_Operate.Inquire_Data(collection, key, value);
                 zc_type.ZC_SX.Add(Result[0].ID.ToString());
                 i++;
             }
         }
         Class_template old = new Class_template();
         old = new Class_template(type);
         for (var j = 0; j < old.ZC_SX.Count; j++)
         {
             zc_type.ZC_SX.Add(old.ZC_SX[j]);
         }
         i = 1;
         while (true)
         {
             var name = f["sc_key_" + i.ToString()];
             if (name.ToString() == "")
             {
                 break;
             }
             else
             {
                 List <string> value = new List <string>();
                 value.Add(name);
                 var Result = m_Db_Operate.Inquire_Data(collection, key, value);
                 zc_type.ZC_SX.Remove(Result[0].ID.ToString());
                 while (zc_type.ZC_SX.Equals(Result[0].ID.ToString()))
                 {
                     zc_type.ZC_SX.Remove(Result[0].ID.ToString());
                 }
             }
             i++;
         }
         M_Db_Operate m_Db_Ct = new M_Db_Operate();
         var          coll    = m_Db_Ct.database.GetCollection <Class_template>("Class_templates");
         m_Db_Ct.Up_Data(coll, "TPYE", type, "ZC_SX", zc_type.ZC_SX);
         return(View("../Home/add_OK"));
     }
     catch (InvalidCastException e)
     {
         ViewData["e"] = e.ToString();
         return(View("../Home/add_ERROR"));
     }
 }
        //按照资产编码查找
        public IActionResult query_zc_2(IFormCollection f)
        {
            string zc_name = f["zc_name"];

            try
            {
                M_Db_Operate m_Db_Operate = new M_Db_Operate();
                var          collection1  = m_Db_Operate.database.GetCollection <Dimension_Information_Model>("Dimension_Information");

                List <string> key1 = new List <string>();
                key1.Add("TYPE");
                List <string> value1 = new List <string>();
                value1.Add("管理者维度");
                var           Result = m_Db_Operate.Inquire_Data(collection1, key1, value1);
                List <string> name   = new List <string>();
                for (var i = 0; i < Result.Count; i++)
                {
                    name.Add(Result[i].NAME);
                }
                ViewData["glz_list"] = name;
                //在这里查询数据库并整合数据

                var           collection = m_Db_Operate.database.GetCollection <SJ_ZC_Model>("ZC_data");
                List <string> key        = new List <string>();
                List <string> value      = new List <string>();
                key.Add("ZCBM");
                value.Add(zc_name.ToString());

                var result = m_Db_Operate.Get_Aggregate(
                    "ZC_data",
                    key,
                    value,
                    new List <string>()
                {
                    "Meta_attribute"
                },
                    new List <string>()
                {
                    "ZC_SX.mp"
                },
                    new List <string>()
                {
                    "ID"
                },
                    new List <string>()
                {
                    "ZC_SXN"
                }
                    );
                List <List <string> > ZC_datas = new List <List <string> >();
                for (var i = 0; i < result.Count; i++)
                {
                    List <string> ZC_data = new List <string>();
                    string        kz_sx   = "";
                    int           j       = 0;
                    while (true)
                    {
                        try
                        {
                            if (result[i]["ZC_SXN"][j]["Dimension_dic"]["资产类别维度"].ToString().Contains("通用集"))
                            {
                                string uu = result[i]["ZC_SXN"][j]["Name"].ToString() + ":";
                                int    k  = 0;
                                while (true)
                                {
                                    try
                                    {
                                        if (result[i]["ZC_SXN"][j]["ID"].ToString() == result[i]["ZC_SX"][k]["mp"].ToString())
                                        {
                                            uu += result[i]["ZC_SX"][k]["V"].ToString();
                                            break;
                                        }
                                        k++;
                                    }
                                    catch
                                    {
                                        ;
                                    }
                                }
                                ZC_data.Add(uu);
                            }
                            else
                            {
                                string uu = result[i]["ZC_SXN"][j]["Name"].ToString() + ":";
                                int    k  = 0;
                                while (true)
                                {
                                    try
                                    {
                                        if (result[i]["ZC_SXN"][j]["ID"].ToString() == result[i]["ZC_SX"][k]["mp"].ToString())
                                        {
                                            uu += result[i]["ZC_SX"][k]["V"].ToString();
                                            break;
                                        }
                                        k++;
                                    }
                                    catch
                                    {
                                        ;
                                    }
                                }
                                ZC_data.Add(uu);
                            }
                        }
                        catch
                        {
                            break;
                        }
                        j++;
                    }
                    ZC_data.Add(kz_sx);
                    ZC_datas.Add(ZC_data);
                }
                ViewData["ZC_datas"] = ZC_datas;
                ViewData["sx_name"]  = sx_name;
            }
            catch (InvalidCastException e)
            {
                ViewData["e"] = e.ToString();
                return(View("query_ERROR"));
            }

            ViewData["wd_type"]   = null;
            ViewData["wd_xx"]     = null;
            ViewData["zc_name"]   = null;
            ViewData["ysx_name"]  = null;
            ViewData["ysx_value"] = null;

            return(View("query_zc"));
        }