Ejemplo n.º 1
0
        private static void NewMethod2()
        {
            List <StatsisLib.UserInfo> infos = new List <StatsisLib.UserInfo>();
            string path = @"E:\Projects\tt\11.txt";
            string t    = File.ReadAllText(path);

            foreach (var item in t.Split('\n'))
            {
                string[] aa = item.Replace("\r", "").Split('|');

                if (aa.Length == 2)
                {
                    string num = aa[1];
                    if (string.IsNullOrWhiteSpace(num))
                    {
                        continue;
                    }
                    infos.Add(new StatsisLib.UserInfo()
                    {
                        Num = num, GroupName = aa[0]
                    });
                }
            }
            DataService.QHXEntities DBContext = new DataService.QHXEntities();
            foreach (var item in infos)
            {
                var s = DBContext.UserInfo.FirstOrDefault(x => x.Id.ToString() == item.Num);
                if (s == null)
                {
                    Console.WriteLine("缺少:{0}", item.Num);
                }
                else if (s.GroupName != item.GroupName)
                {
                    Console.WriteLine("对不上:{0},{1}=>{2}", item.Num, s.GroupName, item.GroupName);
                }
            }


            foreach (var item in DBContext.UserInfo.ToList())
            {
                var s = infos.FirstOrDefault(x => x.Num == item.Id.ToString());
                if (s == null)
                {
                    Console.WriteLine("多余:{0}", item.Id, item.GroupName);
                }
                //else if(s.GroupName!=item.GroupName)
                //{
                //    Console.WriteLine("对不上:{0}", item.Num);
                //}
            }
        }
Ejemplo n.º 2
0
        private static void UpdateUser()
        {
            var dataInfos = StatsisLib.Common.DTToList <DateInfo>(NPOIHelper.ImportExceltoDt(@"E:\Projects\tt\2月\date.xls"));

            DataService.QHXEntities DBContext = new DataService.QHXEntities();
            foreach (var uItem in dataInfos)
            {
                var s = DBContext.UserInfo.FirstOrDefault(x => x.Id.ToString() == uItem.工号);
                if (s != null)
                {
                    Console.WriteLine("{0},{1}=>{2}", uItem.姓名, s.InTime, uItem.岗时间);
                    s.InTime = uItem.岗时间;
                }
                else
                {
                    Console.WriteLine("{0},xx", uItem.姓名);
                }
            }
            DBContext.SaveChanges();
        }
Ejemplo n.º 3
0
        private static void NewMethod1()
        {
            DataService.QHXEntities DBContext = new DataService.QHXEntities();
            var NDirectory = StatsisLib.NestDirectory.Deserialize("C:\\g1.xml");

            foreach (var item in NDirectory.Children)
            {
                DBContext.StatsicInfo.Add(new StatsicInfo()
                {
                    IsDel = 0, StatsicName = item.Name
                });
                foreach (var subItem in item.Children)
                {
                    DBContext.StatsicRelation.Add(new StatsicRelation()
                    {
                        GroupName = subItem.Name, StatsicName = item.Name
                    });
                }
            }
            DBContext.SaveChanges();
        }
Ejemplo n.º 4
0
        private static void NewMethod4()
        {
            string data  = File.ReadAllText(@"E:\Projects\tt\22.txt", Encoding.Default);
            string gName = "";
            List <StatsisLib.UserInfo> infos = new List <StatsisLib.UserInfo>();

            data.Replace("\r", "").Split('\n').ToList().ForEach(x =>
            {
                string[] paramss = x.Split('|');
                if (paramss.Length == 4)
                {
                    if (!string.IsNullOrWhiteSpace(paramss[0]))
                    {
                        gName = paramss[0];
                    }
                    if (!string.IsNullOrWhiteSpace(paramss[1]))
                    {
                        infos.Add(new StatsisLib.UserInfo()
                        {
                            GroupName = gName,
                            InTime    = paramss[3],
                            Name      = paramss[1],
                            Num       = paramss[2],
                            Remark    = "1.4"
                        });
                    }
                }
            });

            int index = 0;

            DataService.QHXEntities DBContext = new DataService.QHXEntities();
            foreach (var item in infos)
            {
                var s = DBContext.UserInfo.FirstOrDefault(x => x.Id.ToString() == item.Num);
                if (s == null)
                {
                    Console.WriteLine("缺少:{0}", item.Num);
                    index = DBContext.UserInfo.Count(y => y.GroupName == item.GroupName) + 1;
                    s     = new DataService.UserInfo()
                    {
                        Id         = int.Parse(item.Num),
                        GroupName  = item.GroupName,
                        Name       = item.Name,
                        OrderIndex = index,
                        InTime     = item.InTime,
                        IsShield   = 0,
                        Remark     = item.Remark,
                        IsDel      = 0
                    };
                    DBContext.UserInfo.Add(s);
                }
                else if (s.GroupName != item.GroupName)
                {
                    Console.WriteLine("对不上:{0},{1}=>{2}", item.Num, s.GroupName, item.GroupName);
                    s.GroupName = item.GroupName;
                }
                s.InTime = item.InTime;
            }
            DBContext.SaveChanges();
        }