在登录处进行初始化:
1.读取配置
GModel.ServerSetin = JsonToIni.GetClass<ServerSet>(ConfigFiles.ConfigFile);
if (!string.IsNullOrWhiteSpace(GModel.ServerSetin.FTPUser))
{
OPCommon.NetControls.NetworkShareConnect.connectToShare(GModel.ServerSetin.FTPUrl, GModel.ServerSetin.FTPUser, GModel.ServerSetin.FTPPW);
}
2.配置到封装类
ServerSet ServerModel = new ServerSet();
ServerModel =OPCommon.JsonToIni.GetClass<ServerSet>(OPCommon.ConfigFiles.ConfigFile);
if (ServerModel != null && ServerModel.FTPUrl != null)
{
UpAndDown.CommParameter.DirName = ServerModel.WebDir;
CommParameter.Pwd = ServerModel.FTPPW;
CommParameter.Url = ServerModel.FTPUrl;
CommParameter.UserName = ServerModel.FTPUser;
CommParameter.SetType = FileType.文档;
}
3.实操–上传文件
OpenFileDialog Openfile = new OpenFileDialog();
Openfile.Filter = "图片文件(*.jpg,*.bmp,*.png)|*.jpg;*.bmp;*.png";
if (Openfile.ShowDialog() == DialogResult.OK)
{
ImageFujian1 = new FileInfo(Openfile.FileName);
CommMsg ThisMsg = new WebDavUpDown().UploadByweb(Openfile.FileName);
if (ThisMsg.Success)
{
string FilePathSave = GModel.FilePathSet + "\\" + ThisMsg.ReturnStr.Replace("/", "\\");
FujianInfo FujianModel = new FujianInfo();
FujianModel.FileName = ImageFujian1.Name;
FujianModel.YangbenId = YangbenModel.Id;
FujianModel.FujianAdd = ThisMsg.ReturnStr;
FujianModel.FujianType = 1;
ResultMsg msg = new DAL.DALFujianInfo().Insert(FujianModel);
if (msg.Success)
{
PBImageFuijan1.Tag = msg.ReturnInt;
}
if (File.Exists(FilePathSave))
{
Image ThisImage = ImageHelper.FileToImage(FilePathSave);
PBImageFuijan1.Image = ThisImage;
}
}
else
{
MessageBox.Show("文件服务器连接失败,请检查连接。", "系统提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
4.实操–下载展示
if (BaogaoModel.FujianQita > 0) //审核印章
{
FujianInfo ThisFujian = new DAL.DALFujianInfo().GetModel(BaogaoModel.FujianQita);
if (ThisFujian != null)
{
string DownStr = GModel.FilePathSet + ThisFujian.FujianAdd.Replace("/", "\\");
if (!File.Exists(DownStr))
{
CommMsg MsgCom = new WebDavUpDown().DownloadFile(ThisFujian.FujianAdd);
if (MsgCom.Success)
{
PBQitaFujian.Image = Resources.文件类型其他类型;
PBQitaFujian.Tag = ThisFujian.Id;
}
}
}
else
{
PBQitaFujian.Image = Resources.文件类型其他类型;
PBQitaFujian.Tag = ThisFujian.Id;
}
}