Exemplo n.º 1
0
        public Data_AppUserFile RetrieveOne(string email, IMyLog log)
        {
            string folder   = FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_UserAccountFolder_);
            string filePath = folder + Path.DirectorySeparatorChar + Data_AppUserFile.EmailSaveChars(email) + ".txt";

            Data_AppUserFile o      = Data_AppUserFile.CreateBlank();
            Stream           stream = OpenFile.ForRead(filePath, false, false, log);

            if (stream == null)
            {
                return(null);
            }
            using (BinaryReader br = new BinaryReader(stream))
            {
                o.ReadFromStream(br);
            }
            return(o);
        }
Exemplo n.º 2
0
        public void Update_General(string email, d_On_User_Action action, Object args, d_On_User_PostAction postAction, IMyLog log)
        {
            string filePath =
                FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_UserAccountFolder_) +
                Path.DirectorySeparatorChar +
                Data_AppUserFile.EmailSaveChars(email) + ".txt";

            using (Stream stream = OpenFile.ForRead(filePath, true, true, log))
            {
                Data_AppUserFile r = null;

                if (stream != null)
                {
                    r = Data_AppUserFile.CreateBlank();
                    //1) read it in
                    BinaryReader br = new BinaryReader(stream);
                    r.ReadFromStream(br);
                }

                //2) update values
                if (action != null)
                {
                    action(r, args);
                }

                //3) write it back
                if (r != null)
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    BinaryWriter bw = new BinaryWriter(stream);
                    r.WriteToStream(bw);
                    stream.SetLength(stream.Position);
                    stream.Close();
                }
            }
            if (postAction != null)
            {
                postAction(args);
            }
        }