private FileReaderWriter GetReaderWriter(FileSourceType type) { FileReaderWriter readerWriter; switch (type) { case FileSourceType.TextFile: readerWriter = TextFileReader; break; case FileSourceType.BinaryFile: readerWriter = BinaryFileReaderWriter; break; case FileSourceType.XMLFile: readerWriter = XmlFileReader; break; case FileSourceType.JSONFile: readerWriter = JsonFileReader; break; default: throw new InvalidOperationException("Invalid type of file source"); } return(readerWriter); }
protected string GetHtml(object type, object text, object id) { FileSourceType sourceType = (FileSourceType)type; switch (sourceType) { case FileSourceType.Project: if (UserInfo.Role == RolesEnum.CLIENT) { return(text.ToString()); } if (!CheckRoleCanAccessPage("/Sunnet/Projects/ViewProject.aspx")) { return(text.ToString()); } return(string.Format(" <a href='###' onclick='OpenEditObject({0})' >{1}</a>", id.ToString(), text.ToString())); case FileSourceType.Ticket: return(string.Format(" <a href='###' onclick='OpenTicketDetail({0})' >{1}</a>", id.ToString(), text.ToString())); case FileSourceType.FeedBack: return(string.Format(" <a href='###' onclick='OpenTicketDetailFeedBack({0})' >{1}</a>", id.ToString(), text.ToString())); default: break; } return(string.Empty); }
public MsiOperation(string packageName, string srcMsiFilePath, InstallOptions.InstallOptionsValues installOptions = null) { _packageName = packageName; _srcMsiFilePath = srcMsiFilePath; _installOptions = installOptions; _srcType = FileSourceType.File; }
public MsiOperation(string packageName, Uri srcMsiUri, InstallOptions.InstallOptionsValues installOptions = null) { _packageName = packageName; _srcMsiUri = srcMsiUri; _installOptions = installOptions; _srcType = FileSourceType.Url; }
public bool DeleteFile(int Sid, FileSourceType type) { this.ClearBrokenRuleMessages(); bool result = mgr.Delete(Sid, type); this.AddBrokenRuleMessages(mgr.BrokenRuleMessages); return(result); }
public InstallExecutableOperation(string packageName, string srcExecutableFilePath, string exeParams, InstallOptions.InstallOptionsValues values) { _packageName = packageName; _srcExecutableFilePath = srcExecutableFilePath; _exeParams = exeParams; _values = values; _sourceType = FileSourceType.File; }
public InstallExecutableOperation(string packageName, Uri srcExecutableUri, string exeParams, InstallOptions.InstallOptionsValues values) { _packageName = packageName; _srcExecutableUri = srcExecutableUri; _exeParams = exeParams; _values = values; _sourceType = FileSourceType.Url; }
public string GetFileString(string name, FileSourceType type) { //I don't actually know if this is right, it will probably be wrong though, iOS does like, catalogs and stuff and I don't understand how it works if (type == FileSourceType.Image) { return(Path.GetFileNameWithoutExtension(name)); } return(name.ToLower()); }
public string GetFileString(string name, FileSourceType type) { var value = Path.Combine("Assets", name); if (type == FileSourceType.PackageImage) { value = Path.Combine(@"ms-appx:///", value); } return(value); }
public List <FilesEntity> GetFileListBySourceId(int Sid, FileSourceType SourceType) { this.ClearBrokenRuleMessages(); if (Sid <= 0) { return(null); } return(repository.GetFileListBySourceId(Sid, SourceType)); }
public bool Delete(int Sid, FileSourceType type) { this.ClearBrokenRuleMessages(); bool result = fileRepo.Delete(Sid, type); if (!result) { this.AddBrokenRuleMessage(); } return(result); }
public static string GetApplicationPathToFile(FileSourceType fileSourceType, string pathToFile) { switch (fileSourceType) { case FileSourceType.Resources: return(Application.dataPath + "/Resources/" + pathToFile); case FileSourceType.ApplicationPersistentData: return(Application.persistentDataPath + "/" + pathToFile); } throw new NotImplementedException(); }
public List <FilesEntity> GetFileListBySourceId(int Sid, FileSourceType type) { List <FilesEntity> list = new List <FilesEntity>(); StringBuilder strSql = new StringBuilder(); strSql.Append("select * from Files "); switch (type) { case FileSourceType.Ticket: strSql.Append(" where TicketId=@Sid "); break; case FileSourceType.Project: strSql.Append(" where ProjectId=@Sid "); break; case FileSourceType.FeedBack: strSql.Append(" where FeedbackId=@Sid "); break; case FileSourceType.WorkRequest: strSql.Append(" where WorkRequestId=@Sid "); break; case FileSourceType.KnowledgeShare: strSql.Append(" where SourceID=@Sid "); break; default: break; } strSql.Append(" and SourceType=@SourceType and Isdelete =0"); strSql.Append(" order by CreatedOn desc"); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "Sid", DbType.Int32, Sid); db.AddInParameter(dbCommand, "SourceType", DbType.Int32, (int)type); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { list.Add(FilesEntity.ReaderBind(dataReader)); } } } return(list); }
/// <summary> /// Create an IStreamer instance /// </summary> /// <param name="fileSourceType">The file source type of streamer</param> /// <returns>IStreamer instance</returns> public static IStreamer CreateInstance(FileSourceType fileSourceType) { IStreamer result = null; switch (fileSourceType) { case FileSourceType.Local: result = new LocalFileStreamer(); break; //case FileSourceType.Ftp: // break; default: throw new NotImplementedException(); } return(result); }
public static byte[] LoadBytesFromFile(FileSourceType fileSourceType, string pathToFile) { try { var applicationPathToFile = GetApplicationPathToFile(fileSourceType, pathToFile); using (var reader = new BinaryReader(File.Open(applicationPathToFile, FileMode.Open))) { return(reader.ReadAllBytes()); } } catch (Exception) { var errorMessage = $"Failed to load byte data from source {fileSourceType}, path {pathToFile}"; UnityLogger.Error(errorMessage); throw; } return(null); }
public bool Delete(int Sid, FileSourceType type) { List <FilesEntity> list = new List <FilesEntity>(); StringBuilder strSql = new StringBuilder(); strSql.Append("update Files set "); strSql.Append("IsDelete=1"); switch (type) { case FileSourceType.Ticket: strSql.Append(" where TicketId=@Sid "); break; case FileSourceType.Project: strSql.Append(" where ProjectId=@Sid "); break; case FileSourceType.FeedBack: strSql.Append(" where FeedbackId=@Sid "); break; } strSql.Append(" and SourceType=@SourceType "); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "Sid", DbType.Int32, Sid); db.AddInParameter(dbCommand, "SourceType", DbType.Int32, (int)type); int rows = db.ExecuteNonQuery(dbCommand); if (rows > 0) { return(true); } else { return(false); } } }
public static void SaveBytesToFile(FileSourceType fileSourceType, string pathToFile, byte[] bytes) { var applicationPathToFile = GetApplicationPathToFile(fileSourceType, pathToFile); CreateDirectoryIfNotExistsWithActualPath(Path.GetDirectoryName(applicationPathToFile)); try { File.Delete(applicationPathToFile); using (var writer = new BinaryWriter(File.OpenWrite(applicationPathToFile))) { writer.Write(bytes); writer.Flush(); } } catch (Exception) { var errorMessage = "Failed to save bytes data to file " + applicationPathToFile; UnityLogger.Error(errorMessage); throw; } }
public string GetFileString(string name, FileSourceType type) { //TODO: Implement type return(name.ToLower()); }
public string Write(string filePath, List <Flower> flowers, FileSourceType type) { return(GetReaderWriter(type).Write(flowers, filePath)); }
public List <Flower> Read(string filePath, FileSourceType type) { return(GetReaderWriter(type).Read(filePath)); }
public FileSource(FileSourceType fileSourceType) { FileSourceType = fileSourceType; }