Ejemplo n.º 1
0
 /// <summary>
 /// 保存临时用户
 /// </summary>
 /// <param name="casualUsers"></param>
 public static void SaveCasualUsers(CasualUserDAL casualUsers)
 {
     using (FileStream fs = new FileStream(casualUserDocPath, FileMode.Create, FileAccess.Write))
     {
         BinaryFormatter bf = new BinaryFormatter();
         bf.Serialize(fs, casualUsers);
     }
 }
Ejemplo n.º 2
0
 public static void InitAll()
 {
     if (!Directory.Exists("data"))
     {
         Directory.CreateDirectory("data");
     }
     admins      = DataFileAccess.GetAdmins();
     casualUsers = DataFileAccess.GetCasualUsers();
     formalUsers = DataFileAccess.GetFormalUsers();
     parks       = DataFileAccess.GetParks();
     orders      = DataFileAccess.GetOrders();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 读取临时用户
        /// </summary>
        /// <returns></returns>
        public static CasualUserDAL GetCasualUsers()
        {
            CasualUserDAL casualUsers;

            if (File.Exists(casualUserDocPath))
            {
                using (FileStream fs = new FileStream(casualUserDocPath, FileMode.Open, FileAccess.Read))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    casualUsers = (CasualUserDAL)bf.Deserialize(fs);
                }
            }
            else
            {
                using (FileStream fs = new FileStream(casualUserDocPath, FileMode.CreateNew, FileAccess.Write))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    casualUsers = new CasualUserDAL();
                    bf.Serialize(fs, casualUsers);
                }
            }
            return(casualUsers);
        }