/// <summary> /// Uploads files to the Oyster System. /// /// </summary> /// <param name="sourcefiles"></param> /// <param name="ShowProgress"></param> /// <param name="EncryptFileNames"></param> /// <returns> /// If EncryptFileNames is true then all files will be given GUID Names on the /// Oyster Server and the GUID Names will be returned /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Otherwise the original file names will be stored on the /// Oyster Server and the original file names will be returned. /// </returns> internal string[] UploadFiles(string[] sourcefiles,bool ShowProgress,bool EncryptFileNames) { FTPTransfer FT = new FTPTransfer(); OCL.Attachments AS = new Attachments(); try { FT.ConnectToOysterServer(ServerAddress); //FT.ConnectToOysterServer("ome-prototype"); } catch(Exception Err) { throw new Exception(Err.Message); } System.IO.FileInfo[] FI = new System.IO.FileInfo[sourcefiles.Length]; int i = 0; foreach(string CFile in sourcefiles) { FI[i] = new System.IO.FileInfo(CFile); i++; } string[] EncodedFileNames = new string[1]; try { EncodedFileNames = FT.UploadFile(FI,ShowProgress,EncryptFileNames); } catch(Exception Err) { throw new Exception(Err.Message); } return EncodedFileNames; }
internal bool UploadFile(string sfile, out string EncryptedFileName) { FTPTransfer FT = new FTPTransfer(); OCL.Attachments AS = new Attachments(); try { FT.ConnectToOysterServer(ServerAddress); //FT.ConnectToOysterServer("ome-prototype"); } catch(Exception Err) { throw new Exception(Err.Message); } try { bool bResult = FT.UploadFile(sfile, out EncryptedFileName); FT.DisconnectFromOysterServer(); return bResult; } catch(Exception Err) { throw new Exception(Err.Message); } }
internal Attachments GetAttachments(int NoteId) { string sSQL = "SELECT * FROM tblAttachments WHERE NoteId = " + NoteId + " And IsDefault = 0"; DataSet DS = RF.GetDataSet(sSQL); DataTable DT = DS.Tables[0]; Attachments AS = new Attachments(); if(DT.Rows.Count == 0) return AS; foreach(DataRow r in DT.Rows) { Attachment X = new Attachment(); X.mvarID = Convert.ToInt32(r[0]); X.mvarOriginalName = Convert.ToString(r[1]); X.mvarStoredName = Convert.ToString(r[2]); X.mvarNoteId = Convert.ToInt32(r[3]); X.mvarCreated = Convert.ToDateTime(r[4]); X.mvarFileSize = Convert.ToInt32(r[6]); AS.Add(X); } return AS; }
internal OCL.Attachments SetNoteAttachments(int NotedId, string[] sfile,ref OCL.FTPTransfer FTP) { OCL.Attachments AS = new Attachments(); try { FTP.ConnectToOysterServer(ServerAddress); //FT.ConnectToOysterServer("ome-prototype"); } catch(Exception Err) { throw new Exception(Err.Message); } System.IO.FileInfo[] FI = new System.IO.FileInfo[sfile.Length]; int i = 0; foreach(string CFile in sfile) { FI[i] = new System.IO.FileInfo(CFile); i++; } string[] EncodedFileNames = FTP.UploadFile(FI,false,true); i = 0; foreach(string EFN in EncodedFileNames) { string sSQL = "INSERT INTO tblAttachments(OriginalName,StoredName,NoteId, FileSize) VALUES(" + " '" + FI[i].Name + "','" + EFN + "'," + NotedId.ToString() + "," + FI[i].Length + "); SELECT IDENT_CURRENT('tblAttachments')"; int AttachmentID = Convert.ToInt32(RF.ExecuteCommandWithQuery(sSQL)); OCL.Attachment A = this.GetAttachment(AttachmentID); AS.Add(A); i++; } return AS; }
internal OCL.Attachments AllVisibleAttachments(OCL.User AccessingUser,OCL.Group TargetGroup, OCL.Note TargetNote) { string sSQL = "SELECT DISTINCT tblGroupTokens.ObjectId, tblAttachments.OriginalName FROM tblGroupTokens LEFT OUTER JOIN tblAttachments ON tblGroupTokens.ObjectId = tblAttachments.Id" + " AND tblGroupTokens.ObjectTypeId = " + Convert.ToInt32(OCL.OysterObjectType.Attachment) + " AND tblGroupTokens.GroupId = " + TargetGroup.mvarID + " AND tblAttachments.IsDefault = 0" + " AND tblAttachments.NoteId = " + TargetNote.mvarID + " ORDER BY tblAttachments.OriginalName"; if(!AccessingUser.mvarIsSuperUser) { sSQL = "SELECT DISTINCT tblGroupTokens.ObjectId, tblAttachments.OriginalName FROM tblGroupTokens LEFT OUTER JOIN tblAttachments ON tblGroupTokens.ObjectId = tblAttachments.Id WHERE UserId = " + AccessingUser.ID + " AND tblGroupTokens.ObjectTypeId = " + Convert.ToInt32(OCL.OysterObjectType.Attachment) + " AND tblGroupTokens.GroupId = " + TargetGroup.mvarID + " AND tblGroupTokens.IsVisible <> 0" + " AND tblAttachments.IsDefault = 0" + " AND tblAttachments.NoteId = " + TargetNote.mvarID + " ORDER BY tblAttachments.OriginalName"; } DataSet DS = RF.GetDataSet(sSQL); DataTable DT = DS.Tables[0]; Attachments AS = new Attachments(); if(DT.Rows.Count == 0) return AS; foreach(DataRow r in DT.Rows) { Attachment X = GetAttachment(Convert.ToInt32(r[0])); AS.Add(X); } return AS; }