Beispiel #1
0
        public void UpdateWeight(int arid, string CMIDWeight)
        {
            try
            {
                var cws = new List <AMIDWeightDTO>();
                //amid|weight
                if (CMIDWeight.Length > 0)
                {
                    CMIDWeight = CMIDWeight.Substring(0, CMIDWeight.Length - 1);
                    //amid|weight数据
                    var cmwg = CMIDWeight.Split(',');
                    foreach (var s in cmwg)
                    {
                        //s amid|weight 拆分成数组
                        var cw     = s.Split('|');
                        var tcmid  = int.Parse(cw[0]);
                        var tweght = int.Parse(cw[1]);
                        if (cws.Any(x => x.AMID == tcmid))
                        {
                            var tcw = cws.First(x => x.AMID == tcmid);
                            var ncw = new AMIDWeightDTO {
                                AMID = tcmid, Weight = tcw.Weight |= tweght
                            };
                            cws.Remove(tcw);
                            cws.Add(ncw);
                        }
                        else
                        {
                            cws.Add(new AMIDWeightDTO()
                            {
                                AMID = tcmid, Weight = tweght
                            });
                        }
                    }
                }

                var ocws =
                    _adminR_MRepository.GetMany(
                        new DirectSpecification <AdminRole_Module>(x => x.ARID == arid), false);
                foreach (var corpUserRoleModule in ocws)
                {
                    if (cws.Any(x => x.AMID == corpUserRoleModule.AMID))
                    {
                        corpUserRoleModule.Weights = cws.FirstOrDefault(x => x.AMID == corpUserRoleModule.AMID).Weight;
                        _adminR_MRepository.Update(corpUserRoleModule, x => x.Weights);
                    }
                }
            }
            catch
            {
                throw new InvalidOperationException("修改权值时出错!");
            }
        }
Beispiel #2
0
        public void UpdateWeight(int arid, string CMIDWeight)
        {
            try
            {
                var cws = new List<AMIDWeightDTO>();
                //amid|weight
                if (CMIDWeight.Length > 0)
                {
                    CMIDWeight = CMIDWeight.Substring(0, CMIDWeight.Length - 1);
                    //amid|weight数据
                    var cmwg = CMIDWeight.Split(',');
                    foreach (var s in cmwg)
                    {
                        //s amid|weight 拆分成数组
                        var cw = s.Split('|');
                        var tcmid = int.Parse(cw[0]);
                        var tweght = int.Parse(cw[1]);
                        if (cws.Any(x => x.AMID == tcmid))
                        {
                            var tcw = cws.First(x => x.AMID == tcmid);
                            var ncw = new AMIDWeightDTO { AMID = tcmid, Weight = tcw.Weight |= tweght };
                            cws.Remove(tcw);
                            cws.Add(ncw);
                        }
                        else
                        {
                            cws.Add(new AMIDWeightDTO() { AMID = tcmid, Weight = tweght });
                        }
                    }
                }

                var ocws =
                    _adminR_MRepository.GetMany(
                        new DirectSpecification<AdminRole_Module>(x => x.ARID == arid), false);
                foreach (var corpUserRoleModule in ocws)
                {
                    if (cws.Any(x => x.AMID == corpUserRoleModule.AMID))
                    {
                        corpUserRoleModule.Weights = cws.FirstOrDefault(x => x.AMID == corpUserRoleModule.AMID).Weight;
                        _adminR_MRepository.Update(corpUserRoleModule, x => x.Weights);
                    }
                }
            }
            catch
            {
                throw new InvalidOperationException("修改权值时出错!");
            }
        }