我有使用sqlite的邮件服务器来存储用户帐户信息 我还创建了一个应用程序(在另一台计算机上)来直接编辑/插入用户数据库,而无需打开邮件服务器GUI来执行此操作。 在邮件服务器升级到新版本并以wal模式连接到sqlite db之前,它运行良好。 然后,每当我通过devart dot连接sqlite连接sqlite并编辑用户数据库时,db崩溃并丢失了所有用户信息,db文件似乎已损坏。 我还发现沃尔玛模式可能不适用于网络文件夹。 https://www.sqlite.org/wal.html 但是这里的任何人都可以帮助我解决这一问题的最佳方法 在这种情况下,我真的需要编辑sqlite数据库 非常感谢
受保护的无效btnSave_Click(对象发送者,EventArgs e) {
try
{
MailAddress Usermail = new MailAddress(txtAccEmail.SelectedItem.Text);
string user = Usermail.User;
string Domain = Usermail.Host;
using (var Db = new MailContext.MailDataContext())
{
var X = Db.Mailusers.Where(n => n.Name == user && n.Domain == "" && Domain.ToUpper() == "MYDOMAIN.NET"
|| string.Concat(n.Name, "@", n.Domain) == Usermail.Address).FirstOrDefault();
if (X != null)
{
if (cmbEmailManager.SelectedItem != null)
{
X.EmailManagers = cmbEmailManager.SelectedItem.Text;
}
if (btnAllowDownload.Checked)
{
X.AllowDownloadAttachment = 1;
}
else
{
X.AllowDownloadAttachment = 0;
}
if (chkWebApp.Checked)
{
X.WebAppPermission = 1;
}
else
{
X.WebAppPermission = 0;
}
string NewIds = string.Join(",", lstDeviceIds.Items.Select(o => o.Text).ToArray());
if (NewIds.Trim() == "")// ko co deviceids
{
X.DeviceIDs = string.Empty;
}
else// co deviceids
{
X.DeviceIDs = NewIds;
}
// if ((DateTime)extWebmailPicker.SelectedDate > DateTime.Now)
{
X.ExtWebmail = Tools.ConvertToUnixTime((DateTime)extWebmailPicker.SelectedDate);
}
}
X.Office = txtMailOffice.Text;
X.Authtype = byte.Parse(ddlAuthen.SelectedValue);
if (ddlAuthen.SelectedValue == "0" && txtMailPassword.Text != "")
{
X.Authtype = 0;
X.Password = "{md5}" + Tools.Md5Hash(txtMailPassword.Text);
}
X.Status = byte.Parse(ddlMailAccountStatus.SelectedValue);
X.Mailquota = long.Parse(txtMailQuota.Text.Trim()) * long.Parse(ddlQuotaUnit.SelectedValue);
X.Maxrcpt = int.Parse(txtMailMaxRecipients.Text.Trim());
X.Maxmsgsize = int.Parse(txtMailMaxBytes.Text.Trim()) * int.Parse(ddlUnit.SelectedValue);
byte Recvcontrol = 0;
if (chkDenyReceive2.Checked)
Recvcontrol += 2;
if (chkDenyReceive4.Checked)
Recvcontrol += 4;
if (chkDenyReceive8.Checked)
Recvcontrol += 8;
byte Sendcontrol = 0;
if (chkDenySend2.Checked)
Sendcontrol += 2;
if (chkDenySend4.Checked)
Sendcontrol += 4;
if (chkDenySend8.Checked)
Sendcontrol += 8;
X.Sendcontrol = Sendcontrol;
X.Recvcontrol = Recvcontrol;
X.Senddomainlist = FinalString(lstSendDomainList);
X.Recvdomainlist = FinalString(lstReceiveDomainList);
if (chkEmailForward.Checked)
X.Fwdsavecopy = 1;
else
X.Fwdsavecopy = 1;
X.Forwardaddr = FinalString(lstMailForward);
string Smtpright = "";
string Imapright = "";
if (smtpNone.Checked)
{
Smtpright = "0";
Imapright = "0";
}
if (smtpAllow.Checked)
{
Smtpright = "1";
Imapright = "1";
}
if (smtpDeny.Checked)
{
Smtpright = "2";
Imapright = "2";
}
Smtpright += ":" + FinalString(lstSmtp);
Imapright += ":" + FinalString(lstSmtp);
X.Smtpacl = Smtpright;
X.Imapacl = Imapright;
string Webmailright = "";
if (webmailNone.Checked)
{
Webmailright = "0";
}
if (webmailAllow.Checked)
{
Webmailright = "1";
}
if (webmailDeny.Checked)
{
Webmailright = "2";
}
Webmailright += ":" + FinalString(lstWebmail);
X.Webmailacl = Webmailright;
Db.SubmitChanges();
lblMessageAll.Text = "Object was successfully changed";
ClearTextBox();
}
}
catch (Exception Ex)
{
lblMessageAll.Text = Ex.Message;
}
}