using System; using System.Collections.Generic; using System.Data.Common; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; namespace EGFramework { #region SaveInit public interface IEGSave { void InitSave(string path); } public interface IEGSaveReadOnly { void InitReadOnly(string data); void InitReadOnly(byte[] data); } public interface IEGSaveAsync { Task InitSaveFileAsync(string path); } public interface IEGSaveReadOnlyAsync { Task InitReadOnlyAsync(string data); Task InitReadOnlyAsync(byte[] data); } #endregion #region DBConnection public interface IEGCanGetDBConnection { DbConnection GetConnection(); } public interface IEGDataBase : IEGCanGetDBConnection { void CreateTable(string dataKey); void CreateTable(string dataKey, Dictionary tableParam); void DropTable(string dataKey); } #endregion #region Object public interface IEGSaveObjectReadOnly { TObject GetObject(string objectKey); IEnumerable GetKeys(); bool ContainsKey(string objectKey); } public interface IEGSaveObject : IEGSaveObjectReadOnly{ /// /// SetObject will add a object if it not exisits, replace the object if it already exists. /// /// /// /// void SetObject(string objectKey,TObject obj); void RemoveObject(string objectKey); void AddObject(string objectKey,TObject obj); void UpdateObject(string objectKey,TObject obj); } public interface IEGSaveObjectReadOnlyAsync{ Task GetObjectAsync(string objectKey) where TObject : new(); } public interface IEGSaveObjectAsync : IEGSaveObjectReadOnlyAsync{ Task SetObjectAsync(string objectKey,TObject obj); } #endregion #region Data public interface IEGSaveDataReadOnly{ TData GetData(string dataKey,object id) where TData : new(); IEnumerable GetAll(string dataKey) where TData : new(); IEnumerable GetPage(string dataKey,int pageIndex,int pageSize) where TData : new(); IEnumerable FindData(string dataKey,Expression> expression) where TData : new(); IEnumerable FindData(string dataKey, string columnName, string keyWords) where TData : new(); IEnumerable GetKeys(); bool ContainsKey(string dataKey); bool ContainsData(string dataKey,object id); int GetDataCount(string dataKey); } public interface IEGSaveData : IEGSaveDataReadOnly{ void SetData(string dataKey,TData data,object id); void AddData(string dataKey,TData data); void AddData(string dataKey,IEnumerable data); void AddData(string datakey, Dictionary data); void AddGroup(string datakey, List> dataGroup); int RemoveData(string dataKey,object id); void UpdateData(string dataKey, Dictionary data, object id); void UpdateData(string dataKey,TData data,object id); } public interface IEGSaveDataReadOnlyAsync{ Task GetDataAsync(string dataKey,object id) where TData : new(); Task> GetAllAsync(string dataKey) where TData : new(); Task> FindDataAsync(string dataKey,Expression> expression) where TData : new(); } public interface IEGSaveDataAsync : IEGSaveDataReadOnlyAsync{ Task SetDataAsync(string dataKey,TData data,object id); } #endregion #region File public interface IEGFileMsg{ public string FileName { get; } public bool IsCollection { get; } /// /// unit is kb /// public long? Size { get; } public string Uri { get; } public DateTime? LastModify { get; } public void Init(string fileName,bool isCollection,string uri,long? size,DateTime? lastmodify); } public struct EGFileMsg : IEGFileMsg{ public string FileName { get; set; } public bool IsCollection { get; set; } public long? Size { get; set; } public string Uri { get; set; } public DateTime? LastModify { get; set; } public void Init(string fileName,bool isCollection,string uri,long? size,DateTime? lastmodify){ this.FileName = fileName; this.IsCollection = isCollection; this.Uri = uri; this.Size = size; this.LastModify = lastmodify; } } public interface IEGSaveFileReadOnly{ IEnumerable ListRemoteFilePath(string remotePath); bool IsRemoteFileExist(string remotePath); bool IsRemoteDirectoryExist(string remotePath); void DownloadFile(string remotePath,string localPath); Stream DownloadFile(string remotePath); void SyncFile(string remotePath,string localPath); } public interface IEGSaveFile:IEGSaveFileReadOnly{ void UploadFile(FileStream localFileStream,string remotePath); void UploadFile(string localPath,string remotePath); void CopyFile(string sourcePath,string copyPath); void MoveFile(string sourcePath,string movePath); void RemoveFile(string remotePath); void MakeDirectory(string remotePath); } #endregion }