Beispiel #1
0
        public Data_Net__02ScreenshotRequest ReadOne(NiceSystemInfo niceSystem, string fileName, IMyLog log)
        {
            try
            {
                WithAndWithoutUnderline ww = new WithAndWithoutUnderline(
                    FolderNames.GetFolder(niceSystem, MyFolders.ASP_QueuedMessages_),
                    fileName);
                Data_Net__02ScreenshotRequest o = null;

                Stream stream = OpenFile.ForRead(ww.Existing, false, false, log);
                if (stream == null)
                {
                    return(null);
                }
                using (BinaryReader br = new BinaryReader(stream))
                {
                    ASPTrayBase ox = ASPTrayBase.ReadOne(br);
                    if (ox.GetEnumType() == ASPTrayBase.eASPtrayType.ScreenShotRequest)
                    {
                        o = (Data_Net__02ScreenshotRequest)ox;
                    }
                }
                return(o);
            }
            catch (SystemException se)
            {
                log.Error("*** SystemException ***");
                log.Error(se.Message);
            }
            return(null);
        }
Beispiel #2
0
        public Data_Net__00NormalMessage ReadOne(NiceSystemInfo niceSystem, string fileName, Data_Net__00NormalMessage.eLocation location, IMyLog log)
        {
            try
            {
                WithAndWithoutUnderline ww = new WithAndWithoutUnderline(
                    FolderNames.GetFolder(niceSystem, eLocationToMyFolder(location)),
                    fileName);

                Data_Net__00NormalMessage o = null;

                Stream stream = OpenFile.ForRead(ww.Existing, false, false, log);
                if (stream == null)
                {
                    return(null);
                }
                using (BinaryReader br = new BinaryReader(stream))
                {
                    ASPTrayBase ox = ASPTrayBase.ReadOne(br);
                    if (ox.GetEnumType() == ASPTrayBase.eASPtrayType.NormalMessage)
                    {
                        o = (Data_Net__00NormalMessage)ox;
                    }
                }
                return(o);
            }
            catch (SystemException se)
            {
                log.Error("*** SystemException ***");
                log.Error(se.Message);
            }
            return(null);
        }
Beispiel #3
0
 public static Stream GetForReadOnly(string fullPath)
 {
     if (File.Exists(fullPath))
     {
         return(OpenFile.ForRead(fullPath, true, false, s_log));
     }
     return(null);
 }
Beispiel #4
0
        public Data_AppUserWallet RetrieveOne(string email, IMyLog log)
        {
            string filePath = getWalletFullPath(email);

            Data_AppUserWallet o      = Data_AppUserWallet.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);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public static Stream GetForUpdate_CreateIfNeeded(string fullPath, IData_Base oOut)
        {
            Stream r = null;

            if (!File.Exists(fullPath))
            {
                // not there yet
                oOut.NetIniMembers();
                r = OpenFile.ForWrite(fullPath, s_log);
                using (BinaryWriter bw = new BinaryWriter(r))
                {
                    oOut.NetTo(bw);
                }
            }

            r = OpenFile.ForRead(fullPath, true, true, s_log);
            oOut.NetFrom(new BinaryReader(r));
            return(r);
        }
Beispiel #7
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);
            }
        }
Beispiel #8
0
        public void UpdateAll(
            string Email,
            string Title,
            string[] DisplayLines,
            Data_AppUserFile.eUserStatus RequestedType,
            AmountAndPrice Numbers,
            AmountAndPrice Messages,
            AmountAndPrice Month,
            AmountAndPrice Setup,
            AmountAndPrice FullPayment,
            IMyLog log)
        {
            string filePath = getWalletFullPath(Email);

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

                //1) read it in
                BinaryReader br = new BinaryReader(stream);
                r.ReadFromStream(br);

                //2) update values
                r.Email         = Email;
                r.Title         = Title;
                r.DisplayLines  = DisplayLines.MyClone();
                r.RequestedType = RequestedType;
                r.Numbers       = Numbers.Clone();
                r.Messages      = Messages.Clone();
                r.Month         = Month.Clone();
                r.Setup         = Setup.Clone();
                r.FullPayment   = FullPayment.Clone();

                //3) write it back
                stream.Seek(0, SeekOrigin.Begin);
                BinaryWriter bw = new BinaryWriter(stream);
                r.WriteToStream(bw);
            }
        }