long CreateGroupIfNotExists() { long id = Last_Selected_GroupId; string grupName = "General"; if (Request["group"] != null && Request["group"].Trim() != "") { grupName = Request["group"]; } AWAPI_Data.Data.awFileGroup group = _fileLib.GetFileGroup(App_Code.SessionInfo.CurrentSite.siteId, grupName.ToLower()); if (group == null) { group = new AWAPI_Data.Data.awFileGroup(); group.title = grupName; group.description = "Automatically created."; group.siteId = App_Code.SessionInfo.CurrentSite.siteId; group.userId = App_Code.SessionInfo.CurrentUser.userId; id = _fileLib.AddFileGroup(group.siteId.Value, group.userId.Value, group.title, group.description, null); } return(group.fileGroupId); }
protected void btnSaveFile__Click(object sender, EventArgs e) { long groupId = 0; try { if (ddlGroupList.SelectedIndex > 0) { groupId = Convert.ToInt64(ddlGroupList.SelectedValue); } //if group isn't selected, create a new group if (groupId == 0) { //check if 'General' uploads exists get it else create new AWAPI_Data.Data.awFileGroup group = _fileLib.GetFileGroup(App_Code.SessionInfo.CurrentSite.siteId, "general"); if (group != null) { groupId = group.fileGroupId; } else { groupId = _fileLib.AddFileGroup(App_Code.SessionInfo.CurrentSite.siteId, App_Code.SessionInfo.CurrentUser.userId, "General", "General file uploads", null); PopulateFileGroups(groupId); } } if (_fileUpload == null || !_fileUpload.HasFile) { lblMessage.Text = "Select a file to upload."; } else { //byte[] bytes = new byte[_fileUpload.PostedFile.InputStream.Length]; //_fileUpload.PostedFile.InputStream.Read(bytes, 0, (int)_fileUpload.PostedFile.InputStream.Length); //string content = Convert.ToBase64String(bytes); ArrayList groupIds = new ArrayList(); groupIds.Add(groupId); long id = _fileLib.Upload(App_Code.SessionInfo.CurrentSite.siteId, (long[])groupIds.ToArray(typeof(long)), App_Code.SessionInfo.CurrentUser.userId, _fileTitle.Text, _fileDescription.Text, _fileUpload.PostedFile.FileName, _fileUpload.PostedFile.InputStream, true, _fileSize.SelectedValue); _fileId.Text = id.ToString(); _fileUrl.Text = AWAPI_BusinessLibrary.library.ConfigurationLibrary.Config.fileServiceUrl + "?id=" + id.ToString(); _fileImg.ImageUrl = _fileUrl.Text + "&size=150x150"; _selectedFileTitle.Text = _fileTitle.Text; PopulateFiles(); ShowHidePanels(pnlExisting); } } catch (Exception ex) { lblMessage.Text = "ERROR: " + ex.Message; } }