protected void DoUpload() { try { HttpPostedFile file = file1.PostedFile; DateTime dateTime = DateTime.Now; string fileName = dateTime.ToString("yyyyMMddhhmmssffff"); if (!Directory.Exists(WebHelper.GetAttachmentTempPath())) { Directory.CreateDirectory(WebHelper.GetAttachmentTempPath()); } string fullName = WebHelper.GetAttachmentTempPath() + "/" + fileName; string strNewPath = fullName + WebHelper.GetExtension(file.FileName); string savepath = fileName + WebHelper.GetExtension(file.FileName); file.SaveAs(strNewPath); BasAttachmentInfo att = new BasAttachmentInfo(); att.PhysicalPath = strNewPath; att.FileNo = fileName; att.OriginalName = Path.GetFileName(file.FileName); att.FriendlyKey = "N/A"; att.ExtensionName = WebHelper.GetExtension(file.FileName); att.FileName = fileName + att.ExtensionName; att.FullPath = "../../Uploads" + "/" + fileName + WebHelper.GetExtension(file.FileName); att.FileType = 0; att.UpdatedDate = DateTime.Now; att.UpdatedBy = WebHelper.GetUserInfo().UserCode; PubHelper.GetHelper(WebHelper.GetDB(WebHelper.GetUserInfo())).SaveAttachment(att); if (SaveToDB(strNewPath, savepath)) { Label1.Text = "上传完毕"; } WriteJs("uploadsuccess('" + att.FileNo + "','" + att.OriginalName + "','" + att.FullPath + "'); "); } catch { WriteJs("uploaderror();"); } }
//public IList<BasBuInfo> GetBUList() //{ // return DBContext.FindArray<BasBuInfo>(ConditionExpress.EMPTY, BasBuInfo.Meta.CODE.ASC); //} //public string GetBUName(string code) //{ // return DBContext.Load<BasBuInfo>(code).BuName; //} //public SysErrorLog GetErrorLog(string id) //{ // return DBContext.Find<SysErrorLog>(SysErrorLog.Meta.ID == id); //} //public string GetSiteName(string code) //{ // return DBContext.Load<BasSiteInfo>(code).SiteName; //} //public IList<BasSiteInfo> GetSiteList() //{ // return DBContext.FindArray<BasSiteInfo>(ConditionExpress.EMPTY, BasSiteInfo.Meta.CODE.ASC); //} //public IList<BasBuInfo> GetValidBUList() //{ // return DBContext.FindArray<BasBuInfo>(BasBuInfo.Meta.STATUS == BLLConstants.COM_STATUS_ACTIVED, BasBuInfo.Meta.CODE.ASC); //} //public IList<BasSiteInfo> GetValidSiteList() //{ // return DBContext.FindArray<BasSiteInfo>(BasSiteInfo.Meta.STATUS == BLLConstants.COM_STATUS_ACTIVED, BasSiteInfo.Meta.CODE.ASC); //} //public IList<BasAttachmentInfo> LoadFiles(string key) //{ // return DBContext.FindArray<BasAttachmentInfo>(BasAttachmentInfo.Meta.FriendlyKey == key); //} //public BasLabelTemplate GetLabelTemplate(string labelType, string stationId, string site, string bu) //{ // BasLabelTemplate lbl = DBContext.Find<BasLabelTemplate>(BasLabelTemplate.Meta.LabelType == labelType // & BasLabelTemplate.Meta.BU == bu // & BasLabelTemplate.Meta.SITE == site // & BasLabelTemplate.Meta.StationId == stationId); // if (lbl == null) // { // lbl = DBContext.Find<BasLabelTemplate>(BasLabelTemplate.Meta.LabelType == labelType // & BasLabelTemplate.Meta.BU == bu // & BasLabelTemplate.Meta.SITE == site // & BasLabelTemplate.Meta.StationId == "ALL"); // } // return lbl; //} public void SaveAttachment(BasAttachmentInfo f) { DBContext.SaveAndUpdate <BasAttachmentInfo>(f); }