Beispiel #1
0
 internal void Save(string baseDir)
 {
     if (PostProcessOutputsFile == null)
     {
         PostProcessOutputsFile = IncrementalUtility.CreateRandomFileName(baseDir);
     }
     if (MessageInfoFile == null)
     {
         MessageInfoFile = IncrementalUtility.CreateRandomFileName(baseDir);
     }
     IncrementalUtility.SaveIntermediateFile(Path.Combine(baseDir, PostProcessOutputsFile), PostProcessOutputs);
     using var sw = new StreamWriter(Path.Combine(baseDir, MessageInfoFile), false, UTF8);
     MessageInfo.Save(sw);
 }
Beispiel #2
0
        protected void btnSendFile_Click(object sender, EventArgs e)
        {
            if (IsPageValid())
            {
                try
                {
                    int          emid = Convert.ToInt32(Session["EmployeeId"]);
                    EmployeeInfo em   = (EmployeeInfo)Session["Employee"];
                    //获取文件名
                    string   name     = this.UpFile.FileName;
                    DateTime sendtime = DateTime.Now;
                    if (!CanYou.OA.BLL.FileInfo.IsFileSame(name))
                    {
                        string[] strto = new String[lbxRecv.Items.Count];
                        for (int i = 0; i < lbxRecv.Items.Count; i++)
                        {
                            CanYou.OA.BLL.FileInfo file = new CanYou.OA.BLL.FileInfo();
                            file.RecvEmployeeId = Convert.ToInt32(lbxRecv.Items[i].Value);
                            file.FileName       = name;
                            file.FileTypeId     = Convert.ToInt32(ddlFileType.SelectedValue.ToString());
                            file.SendEmployeeId = emid;
                            file.Memo           = txtMemo.Text.ToString();
                            file.SendTime       = sendtime;
                            file.IsCommon       = 0;
                            file.IsDelete       = 0;
                            file.IsMsg          = 0;
                            file.Save();

                            MessageInfo Msg = new MessageInfo();
                            Msg.Msg            = "您收到新文件:" + name;
                            Msg.Url            = "~/ShareManage/RecvFile.aspx";
                            Msg.RecvEmployeeId = Convert.ToInt32(lbxRecv.Items[i].Value);
                            Msg.Memo           = file.FileId.ToString();
                            Msg.EmployeeName   = em.EmployeeName;
                            Msg.MsgType        = "daiyue";
                            Msg.MsgTime        = DateTime.Now.ToString("yyyy-MM-dd");
                            Msg.MsgTitle       = name;
                            Msg.Save();

                            EmployeeInfo ems = new EmployeeInfo(Convert.ToInt32(lbxRecv.Items[0].Value));
                            strto[i] = ems.Qq.ToString();
                        }


                        //文件上传地址根目录,这里通过IIS架设本地主机为FTP服务器
                        //string FileSaveUri = @"ftp://192.168.11.70/www/Files/File/";
                        ////FTP用户名密码,就是本机的用户名密码
                        //string ftpUser = "******";
                        //string ftpPassWord = "******";
                        //SendFiles(FileSaveUri, ftpUser, ftpPassWord);
                        this.UpFile.PostedFile.SaveAs(Server.MapPath("~/Files/File/" + UpFile.FileName));
                        MessageInfo.SendMailS(strto, "OA新消息", "您收到新文件");

                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('发送成功!');</script>");
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('该文件名已存在,请重命名!');</script>");
                    }
                }
                catch (Exception ex)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('发送失败:" + ex.Message + "');", true);
                }
            }
        }