210411PX Fixed AuthCode not working, Worked on Attachments (for MV and other entities)
This commit is contained in:
parent
3dcb107aae
commit
f2cf3b07c7
104
model/Blob.cs
104
model/Blob.cs
|
@ -1,20 +1,108 @@
|
|||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
|
||||
namespace dezentrale.model
|
||||
{
|
||||
public class Blob
|
||||
{
|
||||
[XmlIgnore] public string Guid { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public DateTime Added { get; set; } = DateTime.Now;
|
||||
public DateTime LastChanged { get; set; }
|
||||
[XmlAttribute] public DateTime Added { get; set; } = DateTime.Now;
|
||||
[XmlAttribute] public DateTime Modified { get; set; }
|
||||
[XmlElement] public string FileName { get; set; } = "";
|
||||
[XmlIgnore] public string DataFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"{FileName}.xml";
|
||||
}
|
||||
}
|
||||
private BlobData data = null;
|
||||
[XmlIgnore] public BlobData Data
|
||||
{
|
||||
get
|
||||
{
|
||||
if(data == null)
|
||||
{
|
||||
data = new BlobData();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
set
|
||||
{
|
||||
data = value;
|
||||
}
|
||||
}
|
||||
public Blob() : base() { }
|
||||
public Blob(string fileName) : base()
|
||||
{
|
||||
FileName = fileName;
|
||||
Added = Modified = DateTime.Now;
|
||||
}
|
||||
|
||||
public bool SaveData()
|
||||
{
|
||||
string completePath = System.IO.Path.Combine(Program.config.DbDirectory, DataFileName);
|
||||
Program.config.DbChangedSinceExport = true;
|
||||
Program.config.LastDbLocalChange = DateTime.Now;
|
||||
XmlData.SaveToFile(Program.ConfigFile, Program.config);
|
||||
return XmlData.SaveToFile(completePath, Data);
|
||||
}
|
||||
}
|
||||
|
||||
//This is for storage into a separate file
|
||||
public class BlobData
|
||||
public class BlobData : XmlData
|
||||
{
|
||||
[XmlIgnore] public string Guid { get; set; }
|
||||
public byte[] Data { get; set; } = null;
|
||||
[XmlAttribute] public bool Compressed { get; set; } = false;
|
||||
[XmlAttribute] public int DecompressedLength { get; set; } = 0;
|
||||
public byte[] DataInternal { get; set; }
|
||||
[XmlIgnore] public byte[] Bytes
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!Compressed)
|
||||
{
|
||||
return DataInternal;
|
||||
} else
|
||||
{
|
||||
//\todo This doesn't work right yet
|
||||
Inflater i = new Inflater(false);
|
||||
i.SetInput(DataInternal);
|
||||
byte[] ret = new byte[DecompressedLength];
|
||||
|
||||
int len = i.Inflate(ret);
|
||||
if (len != DecompressedLength) throw new Exception("Decompression of {DecompressedLength} Bytes using Inflater failed");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
DecompressedLength = value.Length;
|
||||
if(true) //if (DecompressedLength == 0)
|
||||
{
|
||||
Compressed = false;
|
||||
DataInternal = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
//\todo This doesn't work right yet
|
||||
Deflater d = new Deflater(Deflater.BEST_COMPRESSION, false);
|
||||
d.SetInput(value);
|
||||
byte[] output = new byte[DecompressedLength];
|
||||
int len = d.Deflate(output, 0, DecompressedLength);
|
||||
if (len < 0)
|
||||
{
|
||||
Console.WriteLine($"Deflate compression of {DecompressedLength} Bytes returned {len}, storing uncompressed");
|
||||
Compressed = false;
|
||||
DataInternal = value;
|
||||
} else
|
||||
{
|
||||
Compressed = true;
|
||||
byte[] di = new byte[len];
|
||||
Buffer.BlockCopy(output, 0, di, 0, len);
|
||||
DataInternal = di;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,8 +121,6 @@ namespace dezentrale.model
|
|||
[XmlElement] public DateTime LastCronjobReducedFeeMail { get; set; } = DateTime.Now;
|
||||
[XmlElement] public DateTime MvEventDate { get; set; }
|
||||
[XmlElement] public DateTime MvDateInvited { get; set; }
|
||||
[XmlElement] public string MvAuthenticationCode { get; set; }
|
||||
|
||||
|
||||
[XmlElement("MoneyTransferId")] public List<string> MoneyTransfersIds { get; set; } = new List<string>();
|
||||
|
||||
|
|
11
model/Mv.cs
11
model/Mv.cs
|
@ -124,7 +124,7 @@ namespace dezentrale.model
|
|||
+ "des dezentrale e.V. zur Mitgliederversammlung einladen.\n\n"
|
||||
+ "Ort: {Place}\n"
|
||||
+ "Datum und Uhrzeit: {EventDate}\n"
|
||||
+ "Dein Authentifizierungscode: {MvAuthenticationCode}\n\n"
|
||||
+ "Dein Authentifizierungscode: {AuthCode}\n\n"
|
||||
+ "Agenda:\n-------\n"
|
||||
+ "{AgendaNumberedString}\n\n"
|
||||
+ "Bitte denkt daran, dass für die Beschlussfähigkeit 51% der regulären Mitglieder vonnöten sind [1].\n"
|
||||
|
@ -165,9 +165,16 @@ namespace dezentrale.model
|
|||
(FormMail f, MvInvitedMember m, IProcessController LogTarget) =>
|
||||
{
|
||||
m.Member.StartLogEvent("MV invitation mail", LogEvent.eEventType.EMail, Program.config.LocalUser);
|
||||
m.AuthCode = RandomString(10);
|
||||
m.Member.CurrentLog.SubEvents.Add(new LogSubEvent()
|
||||
{
|
||||
Type = LogEvent.eEventType.DataChange,
|
||||
Topic = "New AuthCode for MV",
|
||||
Details = m.AuthCode,
|
||||
});
|
||||
try
|
||||
{
|
||||
m.Member.CurrentLog.SubEvents.Add(f.Send(m.Member));
|
||||
m.Member.CurrentLog.SubEvents.Add(f.ReplaceReflect(m).Send(m.Member));
|
||||
m.Member.SaveToFile();
|
||||
} catch(Exception ex)
|
||||
{
|
||||
|
|
|
@ -324,10 +324,12 @@ namespace dezentrale.view
|
|||
if (mv == null)
|
||||
{
|
||||
MessageBox.Show("No MV entry selected");
|
||||
}
|
||||
else if(mv.Status == Mv.MvStatus.Cancelled)
|
||||
} else if(mv.Status == Mv.MvStatus.Cancelled)
|
||||
{
|
||||
MessageBox.Show("MV is already cancelled");
|
||||
} else if(mv.Status == Mv.MvStatus.Ended)
|
||||
{
|
||||
MessageBox.Show("MV is finished and cannot be cancelled.");
|
||||
} else
|
||||
{
|
||||
DialogResult res;
|
||||
|
|
|
@ -175,7 +175,7 @@ namespace dezentrale.view
|
|||
DialogResult res = MessageBox.Show($"There are {subList.Count} already-invited members:\r\n{subListString}\r\n\r\nInvite them again?", "Invite members again?", MessageBoxButtons.YesNoCancel);
|
||||
if (res == DialogResult.Cancel) return;
|
||||
//I know this iteration is inefficient, but should do the trick for normal eV business.
|
||||
if (res == DialogResult.Yes)
|
||||
if (res == DialogResult.No)
|
||||
foreach (MvInvitedMember mvi in subList) inv.Remove(mvi);
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ namespace dezentrale.view
|
|||
SerialMailProcess<MvInvitedMember> invProcess = mv.GetInvitationMailProcess(inv);
|
||||
frmProcessWithLog frmInvProcess = new frmProcessWithLog(invProcess, true);
|
||||
frmInvProcess.ShowDialog();
|
||||
if (mv.Status == Mv.MvStatus.InPreparation)
|
||||
if (invProcess.EntitiesSuccessful.Count > 0)
|
||||
mv.Status = Mv.MvStatus.InvitationSent;
|
||||
foreach (MvInvitedMember mvi in inv) lvMvInvitations.UpdateEntry(mvi);
|
||||
UpdateGui();
|
||||
|
@ -486,15 +486,20 @@ namespace dezentrale.view
|
|||
{
|
||||
if (mv.Status != Mv.MvStatus.Started) return;
|
||||
if (e.KeyChar != 13) return;
|
||||
e.KeyChar = (char)0;
|
||||
bool foundAuthCode = false;
|
||||
foreach(MvInvitedMember mvi in mv.Members)
|
||||
{
|
||||
if (string.IsNullOrEmpty(mvi.AuthCode))
|
||||
continue;
|
||||
|
||||
if (tbAuthCodePaste.Text.Contains(mvi.AuthCode))
|
||||
{
|
||||
foundAuthCode = true;
|
||||
mvi.AttendedMv = true;
|
||||
//Add mvi to selection in list
|
||||
//lvMvInvitations.SelectedItems
|
||||
lvMvInvitations.UpdateEntry(mvi);
|
||||
lvMvInvitations.DeSelectEntry(mvi, true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue