Пример #1
0
 public Team(Team team)
 {
     Clone(team);
 }
Пример #2
0
 public static Team Parse(String s)
 {
     Team team = new Team();
     String[] ss = s.Split(Constant.SPLIT2);
     try
     {
         team.TeamID = Int32.Parse(ss[0]);
         team.password = ss[1];
         team.TeamName = ss[2];
         team.TeamLinkman = ss[3];
         team.TeamTel = ss[4];
         team.TeamAddress = ss[5];
         team.JoinTime = ss[6];
         team.PolicyModCar = Int32.Parse(ss[7]);
         team.PolicyOrder = Int32.Parse(ss[8]);
         team.policyRegion = Int32.Parse(ss[9]);
         team.PolicyRegionAlarm = Int32.Parse(ss[10]);
     }
     catch { return null; }
     return team;
 }
Пример #3
0
 public void Clone(Team team)
 {
     this.TeamID = team.TeamID;
     this.password = team.password;
     this.TeamName = team.TeamName;
     this.TeamLinkman = team.TeamLinkman;
     this.TeamTel = team.TeamTel;
     this.teamAddress = team.teamAddress;
     this.PolicyModCar = team.PolicyModCar;
     this.PolicyOrder = team.PolicyOrder;
     this.policyRegion = team.policyRegion;
     this.PolicyRegionAlarm = team.PolicyRegionAlarm;
 }
Пример #4
0
 //��ʼ��ϵͳ����
 private bool LoadInfoFromDB()
 {
     bool ret = false;
     dbm = DBManager.GetInstance(Config.DbHost, Config.DbName, Config.DbUser, Config.DbPw);
     if(dbm != null)
     {
         try
         {
             //regionList.Clear();
             teamList.Clear();
             userList.Clear();
             DataTable dt = null;
             /*dbm.ExecuteQuery("select_region");
             foreach(DataRow dr in dt.Rows)
             {
                 int id = Int32.Parse(dr[0].ToString());
                 String s = dr[1].ToString();
                 Region region = new Region(dr[2].ToString());
                 region.RegionID = id;
                 region.RegionName = s;
                 regionList.Add(region);
             }*/
             dt = dbm.ExecuteQuery("select_team");
             foreach(DataRow dr in dt.Rows)
             {
                 Team team = new Team();
                 team.TeamID = Int32.Parse(dr[0].ToString());
                 team.Password = dr[1].ToString();
                 team.TeamName = dr[2].ToString();
                 team.TeamLinkman = dr[3].ToString();
                 team.TeamTel = dr[4].ToString();
                 team.TeamAddress = dr[5].ToString();
                 team.JoinTime = dr[6].ToString();
                 team.PolicyModCar = Int32.Parse(dr[7].ToString());
                 team.PolicyOrder = Int32.Parse(dr[8].ToString());
                 team.PolicyRegion = Int32.Parse(dr[9].ToString());
                 team.PolicyRegionAlarm = Int32.Parse(dr[10].ToString());
                 teamList.Add(team);
             }
             dt = dbm.ExecuteQuery("select_car");
             foreach(DataRow dr in dt.Rows)
             {
                 Car car = Car.ParseWithPosition(dr);
                 if(car != null)
                 {
                     //if(car.RegionID != 0)
                         //car.Region = GetRegionByID(car.RegionID);
                     car.Team = GetTeamByID(car.TeamID);
                     car.Team.Cars.Add(car);
                 }
             }
             dt = dbm.ExecuteQuery("select_user");
             foreach(DataRow dr in dt.Rows)
             {
                 User user = new User();
                 user.UserID = Int32.Parse(dr[0].ToString());
                 user.UserName = dr[1].ToString();
                 user.Password = dr[2].ToString();
                 user.UserType = Int32.Parse(dr[3].ToString());
                 user.Tel = dr[4].ToString();
                 user.Email = dr[5].ToString();
                 user.JoinTime = dr[6].ToString();
                 if(user.UserType != User.USER_ADMIN)
                 {
                     user.Teams = new List<Team>();
                     String ts = dr[7].ToString();
                     if(ts.Length > 0)
                     {
                         if(ts[0] == Constant.SPLIT_EX_1)
                             ts = ts.Substring(1);
                         if(ts[ts.Length - 1] == Constant.SPLIT_EX_1)
                             ts = ts.Substring(0, ts.Length - 1);
                     }
                     if(ts != null && ts != "")
                     {
                         user.TeamStr = ts;
                         String[] temp = ts.Split(Constant.SPLIT_EX_1);
                         foreach(String s in temp)
                         {
                             if(s == null || s == "")
                                 continue;
                             try
                             {
                                 Team team = GetTeamByID(Int32.Parse(s));
                                 if(team != null)
                                     user.Teams.Add(team);
                             }
                             catch { }
                         }
                     }
                     else user.TeamStr = "";
                     user.PolicyModTeam = Int32.Parse(dr[8].ToString());
                     user.PolicyModCar = Int32.Parse(dr[9].ToString());
                     user.PolicyOrder = Int32.Parse(dr[10].ToString());
                     user.PolicyExportCars = Int32.Parse(dr[11].ToString());
                     user.PolicyDeclare = Int32.Parse(dr[12].ToString());
                     user.PolicyAlarmList = Int32.Parse(dr[13].ToString());
                     user.PolicyOverTime = Int32.Parse(dr[14].ToString());
                     user.PolicyNotify = Int32.Parse(dr[15].ToString());
                 }
                 else
                 {
                     user.Teams = teamList;
                 }
                 userList.Add(user);
             }
             dt = dbm.ExecuteQuery("select_alarm");
             foreach(DataRow dr in dt.Rows)
             {
                 AlarmPosition apos = new AlarmPosition();
                 apos.Id = Int32.Parse(dr[0].ToString());
                 apos.CarID = Int32.Parse(dr[1].ToString());
                 apos.GpsTime = dr[2].ToString();
                 apos.Pointed = Int32.Parse(dr[3].ToString());
                 apos.Lo = Double.Parse(dr[4].ToString());
                 apos.La = Double.Parse(dr[5].ToString());
                 apos.Speed = Int32.Parse(dr[6].ToString());
                 apos.Direction = Int32.Parse(dr[7].ToString());
                 apos.Status = dr[8].ToString();
                 apos.Alarm = dr[9].ToString();
                 //GetCarByID(apos.CarID).AlarmPos.Add(apos); ��������Ի���
             }
             dt = dbm.ExecuteQuery("select carID from tDeclare where opUser=''");
             foreach(DataRow dr in dt.Rows)
             {
                 try
                 {
                     GetCarByID(Int32.Parse(dr[0].ToString())).DeclareCount++;
                 }
                 catch{}
             }
             ret = true;
         }
         catch(Exception e)
         {
             if(FormMain.LOG_ERR)
                 logger.AddErr(e, "");
         }
     }
     inited = ret;
     return ret;
 }