コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: FilesList.aspx.cs プロジェクト: KhaledSMQ/SunNet.PM
        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);
        }
コード例 #3
0
 public MsiOperation(string packageName, string srcMsiFilePath, InstallOptions.InstallOptionsValues installOptions = null)
 {
     _packageName    = packageName;
     _srcMsiFilePath = srcMsiFilePath;
     _installOptions = installOptions;
     _srcType        = FileSourceType.File;
 }
コード例 #4
0
 public MsiOperation(string packageName, string srcMsiFilePath, InstallOptions.InstallOptionsValues installOptions = null)
 {
     _packageName = packageName;
     _srcMsiFilePath = srcMsiFilePath;
     _installOptions = installOptions;
     _srcType = FileSourceType.File;
 }
コード例 #5
0
 public MsiOperation(string packageName, Uri srcMsiUri, InstallOptions.InstallOptionsValues installOptions = null)
 {
     _packageName    = packageName;
     _srcMsiUri      = srcMsiUri;
     _installOptions = installOptions;
     _srcType        = FileSourceType.Url;
 }
コード例 #6
0
 public MsiOperation(string packageName, Uri srcMsiUri, InstallOptions.InstallOptionsValues installOptions = null)
 {
     _packageName = packageName;
     _srcMsiUri = srcMsiUri;
     _installOptions = installOptions;
     _srcType = FileSourceType.Url;
 }
コード例 #7
0
        public bool DeleteFile(int Sid, FileSourceType type)
        {
            this.ClearBrokenRuleMessages();
            bool result = mgr.Delete(Sid, type);

            this.AddBrokenRuleMessages(mgr.BrokenRuleMessages);
            return(result);
        }
コード例 #8
0
 public InstallExecutableOperation(string packageName, string srcExecutableFilePath, string exeParams, InstallOptions.InstallOptionsValues values)
 {
     _packageName           = packageName;
     _srcExecutableFilePath = srcExecutableFilePath;
     _exeParams             = exeParams;
     _values     = values;
     _sourceType = FileSourceType.File;
 }
コード例 #9
0
 public InstallExecutableOperation(string packageName, Uri srcExecutableUri, string exeParams, InstallOptions.InstallOptionsValues values)
 {
     _packageName      = packageName;
     _srcExecutableUri = srcExecutableUri;
     _exeParams        = exeParams;
     _values           = values;
     _sourceType       = FileSourceType.Url;
 }
コード例 #10
0
 public InstallExecutableOperation(string packageName, Uri srcExecutableUri, string exeParams, InstallOptions.InstallOptionsValues values)
 {
     _packageName = packageName;
     _srcExecutableUri = srcExecutableUri;
     _exeParams = exeParams;
     _values = values;
     _sourceType = FileSourceType.Url;
 }
コード例 #11
0
 public InstallExecutableOperation(string packageName, string srcExecutableFilePath, string exeParams, InstallOptions.InstallOptionsValues values)
 {
     _packageName = packageName;
     _srcExecutableFilePath = srcExecutableFilePath;
     _exeParams = exeParams;
     _values = values;
     _sourceType = FileSourceType.File;
 }
コード例 #12
0
 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());
 }
コード例 #13
0
        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);
        }
コード例 #14
0
        public List <FilesEntity> GetFileListBySourceId(int Sid, FileSourceType SourceType)
        {
            this.ClearBrokenRuleMessages();

            if (Sid <= 0)
            {
                return(null);
            }

            return(repository.GetFileListBySourceId(Sid, SourceType));
        }
コード例 #15
0
        public bool Delete(int Sid, FileSourceType type)
        {
            this.ClearBrokenRuleMessages();
            bool result = fileRepo.Delete(Sid, type);

            if (!result)
            {
                this.AddBrokenRuleMessage();
            }
            return(result);
        }
コード例 #16
0
        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();
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        /// <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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        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);
                }
            }
        }
コード例 #21
0
        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;
            }
        }
コード例 #22
0
 public string GetFileString(string name, FileSourceType type)
 {
     //TODO: Implement type
     return(name.ToLower());
 }
コード例 #23
0
 public string Write(string filePath, List <Flower> flowers, FileSourceType type)
 {
     return(GetReaderWriter(type).Write(flowers, filePath));
 }
コード例 #24
0
 public List <Flower> Read(string filePath, FileSourceType type)
 {
     return(GetReaderWriter(type).Read(filePath));
 }
コード例 #25
0
 public FileSource(FileSourceType fileSourceType)
 {
     FileSourceType = fileSourceType;
 }