/// <summary> /// Handles the OnClick event of the lbAddFile control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void lbAddFile_OnClick(object sender, EventArgs e) { var siteId = CurrentUser.Instance.SiteID; var fsp = new FileSystemProvider(); if (rauFile.UploadedFiles.Count > 0) { string fileName = null; if (rauFile.UploadedFiles.Count > 0) { IFileProvider fileProvider = new FSProvider(); fileName = fileProvider.GetFilename(siteId, rauFile.UploadedFiles[0].FileName); fsp.Upload(siteId, fileName, rauFile.UploadedFiles[0].InputStream); } var link = new tbl_Links(); link.SiteID = siteId; link.Name = fileName; link.RuleTypeID = (int)RuleType.File; link.URL = fileName; link.FileSize = rauFile.UploadedFiles[0].InputStream.Length; string code = String.Format("file_[{0}]_[{1}]", DateTime.Now.ToString("ddMMyyyy"), DateTime.Now.ToString("mmss")); int maxCode = DataManager.Links.SelectByCode(siteId, code); if (maxCode != 0) { maxCode++; } link.Code = code + (maxCode != 0 ? String.Format("[{0}]", maxCode >= 10 ? maxCode.ToString() : "0" + maxCode.ToString()) : ""); DataManager.Links.Add(link); BindFiles(); } }
protected void lbUpdateFile_OnClick(object sender, EventArgs e) { var a = FileId; var fsp = new FileSystemProvider(); if (rauFile.UploadedFiles.Count > 0) { string fileName = null; if (rauFile.UploadedFiles.Count > 0) { //fileName = fsp.Upload(CurrentUser.Instance.SiteID, "SiteActivityRules", // rauFile.UploadedFiles[0].FileName, rauFile.UploadedFiles[0].InputStream, // FileType.Attachment); IFileProvider fileProvider = new FSProvider(); fileName = fileProvider.GetFilename(CurrentUser.Instance.SiteID, rauFile.UploadedFiles[0].FileName); fsp.Upload(CurrentUser.Instance.SiteID, fileName, rauFile.UploadedFiles[0].InputStream); } var file = _dataManager.Links.SelectById(FileId) ?? new tbl_Links(); file.SiteID = ((LeadForceBasePage)Page).SiteId; file.Name = fileName; file.RuleTypeID = (int)RuleType.File; file.URL = fileName; file.FileSize = rauFile.UploadedFiles[0].InputStream.Length; file.Description = txtDescription.Text; string code = String.Format("file_[{0}]_[{1}]", DateTime.Now.ToString("ddMMyyyy"), DateTime.Now.ToString("mmss")); int maxCode = _dataManager.Links.SelectByCode(((LeadForceBasePage)Page).SiteId, code); if (maxCode != 0) { maxCode++; } file.Code = code + (maxCode != 0 ? String.Format("[{0}]", maxCode >= 10 ? maxCode.ToString() : "0" + maxCode.ToString()) : ""); if (file.ID == Guid.Empty) { _dataManager.Links.Add(file); } else { _dataManager.Links.Update(file); } ((Labitec.UI.BaseWorkspace.Grid)FindControl("gridLinks", Page.Controls)).Rebind(); } else { var file = _dataManager.Links.SelectById(FileId); if (file != null) { file.Description = txtDescription.Text; _dataManager.Links.Update(file); ((Labitec.UI.BaseWorkspace.Grid)FindControl("gridLinks", Page.Controls)).Rebind(); } } }
/// <summary> /// Handles the OnClick event of the lbAddFile control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void lbAddFile_OnClick(object sender, EventArgs e) { var btnAddFile = (RadButton)sender; var editFormTableCell = FindControlParent(btnAddFile, typeof(GridEditFormItem.EditFormTableCell)) as GridEditFormItem.EditFormTableCell; var rauFile = (RadAsyncUpload)editFormTableCell.FindControl("rauFile"); var siteId = CurrentUser.Instance.SiteID; var fsp = new FileSystemProvider(); if (rauFile.UploadedFiles.Count > 0) { string fileName = null; if (rauFile.UploadedFiles.Count > 0) { IFileProvider fileProvider = new FSProvider(); fileName = fileProvider.GetFilename(siteId, rauFile.UploadedFiles[0].FileName); fsp.Upload(siteId, fileName, rauFile.UploadedFiles[0].InputStream); } var link = new tbl_Links(); link.SiteID = siteId; link.Name = fileName; link.RuleTypeID = (int)RuleType.File; link.URL = fileName; link.FileSize = rauFile.UploadedFiles[0].InputStream.Length; string code = String.Format("file_[{0}]_[{1}]", DateTime.Now.ToString("ddMMyyyy"), DateTime.Now.ToString("mmss")); int maxCode = _dataManager.Links.SelectByCode(siteId, code); if (maxCode != 0) { maxCode++; } link.Code = code + (maxCode != 0 ? String.Format("[{0}]", maxCode >= 10 ? maxCode.ToString() : "0" + maxCode.ToString()) : ""); _dataManager.Links.Add(link); ((DictionaryOnDemandComboBox)editFormTableCell.FindControl("dcbFile")).BindData(); } }
protected void lbAddFile_OnClick(object sender, EventArgs e) { var fsp = new FileSystemProvider(); if (rauFile.UploadedFiles.Count > 0) { string fileName = null; if (rauFile.UploadedFiles.Count > 0) { //fileName = fsp.Upload(CurrentUser.Instance.SiteID, "Links", // rauFile.UploadedFiles[0].FileName, rauFile.UploadedFiles[0].InputStream, // FileType.Attachment); IFileProvider fileProvider = new FSProvider(); fileName = fileProvider.GetFilename(siteID, rauFile.UploadedFiles[0].FileName); fsp.Upload(siteID, fileName, rauFile.UploadedFiles[0].InputStream); } var file = new tbl_Links(); file.SiteID = siteID; file.Name = fileName; file.RuleTypeID = (int)RuleType.File; file.URL = fileName; file.FileSize = rauFile.UploadedFiles[0].InputStream.Length; file.Description = txtDescription.Text; file.OwnerID = CurrentUser.Instance.ContactID; string code = String.Format("file_[{0}]_[{1}]", DateTime.Now.ToString("ddMMyyyy"), DateTime.Now.ToString("mmss")); int maxCode = _dataManager.Links.SelectByCode(siteID, code); if (maxCode != 0) { maxCode++; } file.Code = code + (maxCode != 0 ? String.Format("[{0}]", maxCode >= 10 ? maxCode.ToString() : "0" + maxCode.ToString()) : ""); _dataManager.Links.Add(file); txtDescription.Text = ""; gridLinks.Rebind(); } }