コード例 #1
0
ファイル: DaYanService.cs プロジェクト: Echo-Ji/Yanxing
 public void update_inform(Person person, DaYan dayan)
 {
     _persondal.Update(person);
     _dayandal.Update(dayan);
 }
コード例 #2
0
ファイル: ECleaderService.cs プロジェクト: Echo-Ji/Yanxing
        //update member grade
        public bool updateMemGrade(Person person, string toGrade)
        {
            bool   res       = true;
            Person tPerson   = null;
            var    persondal = new PersonDal();
            //get the person's old profile
            var pres = persondal.GetEntities(m => m.PID == person.PID);

            try
            {
                foreach (var p in pres)
                {
                    tPerson = p;
                }
                if (person.Pgrade != toGrade)  //若前后grade不一致
                //update person first
                {
                    updatePersonGrade(person, toGrade);
                    //update Member later
                    switch (person.Pgrade)
                    {
                    case "XiaoYan":
                    case "EC": {
                        //get the old profile of the member
                        var oldmem   = new XiaoYan();
                        var xymemdal = new XiaoYanDal();
                        var mems     = xymemdal.GetEntities(m => m.PID == person.PID);
                        foreach (var p in mems)
                        {
                            oldmem = p;
                        }
                        //update the member profile
                        if (toGrade == "EC")
                        {
                            //XiaoYan=>EC,set EC flag
                            xymemdal.Update(new XiaoYan {
                                    XYID = oldmem.XYID,
                                    PID  = oldmem.PID, Sid = oldmem.Sid,
                                    isEC = true, isActive = oldmem.isActive
                                });
                        }
                        else if (toGrade == "XiaoYan")
                        {
                            //EC=>XiaoYan,unset EC flag
                            xymemdal.Update(new XiaoYan
                                {
                                    XYID     = oldmem.XYID,
                                    PID      = oldmem.PID,
                                    Sid      = oldmem.Sid,
                                    isEC     = false,
                                    isActive = oldmem.isActive
                                });
                        }
                        else if (toGrade == "DaYan")
                        {
                            var dymemdal = new DaYanDal();
                            //inactivate the xiaoyan
                            xymemdal.Update(new XiaoYan
                                {
                                    XYID     = oldmem.XYID,
                                    PID      = oldmem.PID,
                                    Sid      = oldmem.Sid,
                                    isEC     = oldmem.isEC,
                                    isActive = false
                                });
                            //insert a dayan
                            dymemdal.Insert(new DaYan
                                {
                                    DYID       = Guid.NewGuid(),
                                    PID        = oldmem.PID,
                                    Sid        = oldmem.Sid,
                                    isECleader = false,
                                    isActive   = true
                                });
                        }
                        break;
                    }

                    case "DaYan":
                    case "ECleader": {
                        var oldmem   = new DaYan();
                        var dymemdal = new DaYanDal();
                        var mems     = dymemdal.GetEntities(m => m.PID == person.PID);
                        foreach (var p in mems)
                        {
                            oldmem = p;
                        }

                        if (toGrade == "ECleader")
                        {        //DaYan=>ECleader,set ECleader flag
                            dymemdal.Update(new DaYan
                                {
                                    DYID       = oldmem.DYID,
                                    PID        = oldmem.PID,
                                    Sid        = oldmem.Sid,
                                    isECleader = true,
                                    isActive   = oldmem.isActive
                                });
                        }
                        else if (toGrade == "DaYan")
                        {        //ECleader=>DaYan,unset ECleader flag
                            dymemdal.Update(new DaYan
                                {
                                    DYID       = oldmem.DYID,
                                    PID        = oldmem.PID,
                                    Sid        = oldmem.Sid,
                                    isECleader = false,
                                    isActive   = oldmem.isActive
                                });
                        }
                        break;
                    }
                    }
                }
            }
            catch (Exception e)
            {
                res = false;
                using (StreamWriter writer =
                           new StreamWriter(@"C:\Users\JJH\Desktop\log.txt", true))
                {
                    writer.WriteLine(DateTime.Now.ToString());
                    writer.WriteLine(e.Message);
                    writer.WriteLine(e.StackTrace);
                }
            }
            return(res);
        }