private void IdentifyFileType(string testPath, FileTypeEnum expectedType) { testPath = GetPath(testPath); var reader = new ExifReader(); var file = reader.Open(testPath); Assert.True(file.FileType == expectedType); }
public FileMetaData( string localFileName, string remoteFileName, string stationID) { LocalFileName = localFileName; RemoteFileName = remoteFileName; FileType = FileTypeEnum.Generic; StationID = stationID; }
public FileMetaData( string localFileName, string remoteFileName, FileTypeEnum fileType, string stationID) { LocalFileName = localFileName; RemoteFileName = remoteFileName; FileType = fileType; StationID = stationID; }
// this function as side effect of lack of Glob.h in windows // be cuz of this lack, we can not grab non-sequence images -_- private string GenerateFileName(FileTypeEnum type, string extension, string folderName) { if (type == FileTypeEnum.audio) { return($"{Guid.NewGuid()}{extension}"); } var fileCount = (from file in Directory.EnumerateFiles(folderName, $"*{extension}", SearchOption.TopDirectoryOnly) select file).Count() + 1; return(fileCount.ToString() + extension); }
public static UploadLocation Get(FileTypeEnum fileType) { switch (fileType) { case FileTypeEnum.FlashcardImage: return(FlashcardImageFolder); case FileTypeEnum.Temp: return(TempFolder); } throw new NotImplementedException(); }
public VideoMetadata(string contentId, string contentTitle, MediaQualityEnum quality, string downloadUrl) { ContentId = contentId; ContentTitle = contentTitle; Quality = quality; Itag = (int)Quality; MimeType = Quality.GetMimeType(); FileType = Quality.GetFileType(); FileExt = Quality.GetShortName(); DownloadUrl = downloadUrl; }
private static string TypeToLithuanian(HolidayType typeToTranslate, FileTypeEnum holidayDocumentType) { return(typeToTranslate switch { HolidayType.Annual => (holidayDocumentType == FileTypeEnum.Order ? "kasmetines atostogas" : "išleisti mane kasmetinių atostogų"), HolidayType.DayForChildren => (holidayDocumentType == FileTypeEnum.Order ? "papildomą poilsio dieną" : "suteikti man papildomą poilsio dieną vaikų priežiūrai"), HolidayType.Science => (holidayDocumentType == FileTypeEnum.Order ? "mokslo atostogas" : "išleisti mane mokslo atostogų"), HolidayType.Unpaid => (holidayDocumentType == FileTypeEnum.Order ? "neapmokamas atostogas" : "išleisti mane neapmokamų atostogų"), _ => "", });
/// <summary> /// 向节点添加图片 /// </summary> /// <param name="fileType"></param> /// <param name="item"></param> private static void AddImage(FileTypeEnum fileType, TreeViewImgItem item) { if (fileType == FileTypeEnum.Directory) { item.DefaultImageSource = new BitmapImage(new Uri("pack://application:,,,/Frame.SysWindows;component/Resources/Open_16x16.png")); item.ExpandedImageSource = new BitmapImage(new Uri("pack://application:,,,/Frame.SysWindows;component/Resources/Article_16x16.png")); } else { item.DefaultImageSource = new BitmapImage(new Uri("pack://application:,,,/Frame.SysWindows;component/Resources/New_16x16.png")); item.ExpandedImageSource = item.DefaultImageSource; } }
public void ExportToFile(string name, FileTypeEnum type) { switch (type) { case FileTypeEnum.Bmp: FileHelper.ExportToBmp(GetBitmap(), name); break; case FileTypeEnum.Text: FileHelper.ExportToTxt(_previousMap, name); break; } }
public async Task <string> SaveFile(MemoryStream ms, string fileName, FileTypeEnum fileType) { GridFSUploadOptions options = new GridFSUploadOptions { Metadata = new BsonDocument() { { "type", fileType } } }; ObjectId imageId = await _gridFS.UploadFromStreamAsync(fileName, ms, options); return(imageId.ToString()); }
public async Task <IActionResult> UploadFile(IFormFile file, FileTypeEnum fileTypeFid, string domainId, string folderId) { try { var result = await _fileService.UploadFile(file, fileTypeFid, domainId, folderId); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex)); } }
public virtual MethodResult CanUpload(HttpPostedFileBase file, FileTypeEnum fileType) { if (file == null || file.ContentLength == 0) { return(new MethodResult("File is empty or does not exist")); } if (file.ContentLength >= 5_000_000) { return(new MethodResult("File is too big! Upload something smaller than 5MB")); } return(MethodResult.Success); }
private void mInitTestingModeFile() { _size = FileName.Length; _exists = true; _fileType = FileTypeEnum.Undefined; System.IO.Stream lFileStream; OpenReadTestingModeFile(out lFileStream); using (lFileStream) { Utility.Crc32 lCrcCalculator = new PIS.Ground.Core.Utility.Crc32(); _crc = lCrcCalculator.CalculateChecksum(lFileStream); } }
/// <summary> /// 加载Credit数据 /// CMS: .csv /// WFS: .csv /// </summary> /// <param name="filePaths"></param> protected string[] GetCreditFiles(FileTypeEnum type, string directoryPath) { string[] result = null; switch (type) { case FileTypeEnum.CMS: result = LoadDirectory(directoryPath, "CMS*", true).Where(c => c.ToLower().EndsWith(".csv", StringComparison.OrdinalIgnoreCase)).ToArray(); break; case FileTypeEnum.WFS: result = LoadDirectory(directoryPath, "WFS*", true).Where(c => c.ToLower().EndsWith(".csv", StringComparison.OrdinalIgnoreCase)).ToArray(); break; } return(result); }
public async Task Upload(IFormFile formFile, FileTypeEnum fileType) { if (formFile.Length > 0) { await CreateFileRecord(formFile.FileName, fileType); var containerName = GetBlobContainerName(fileType); var fileStream = formFile.OpenReadStream(); await _azureStorageService.UploadBlob(containerName, fileType == FileTypeEnum.HolidayPolicy ?_configuration["FileConfig:HolidayPolicyFileName"] : formFile.FileName, formFile.ContentType, fileStream); fileStream.Close(); } }
public async Task <int> CreateFileRecord(string fileName, FileTypeEnum fileType) { var guid = Guid.NewGuid().ToString(); var fileRecordToCreate = new FileRecord { Guid = guid, Name = fileName, Type = fileType, CreatedAt = _timeService.GetCurrentTime() }; var fileId = await _fileRepository.Create(fileRecordToCreate); return(fileId); }
public IFileHandler CreateFileHandler(FileTypeEnum fileType) { IFileHandler fileHandler = null; if (fileType == FileTypeEnum.JSON) { fileHandler = new JsonFileHandler(); } if (fileType == FileTypeEnum.CSV || fileType == FileTypeEnum.TXT) { fileHandler = new CsvFileHandler(); } return(fileHandler); }
public static IFile Generate(FileTypeEnum fileType) { switch (fileType) { case FileTypeEnum.TXT: return(new TXTFile()); case FileTypeEnum.JSON: return(new JSONFile()); case FileTypeEnum.XML: return(new XMLFile()); default: return(null); } }
public bool Start(FileTypeEnum type, FileFormatEnum srcFormat, string[] inputPaths) { Wrapper.SetButtonState(this._userControl.startButton, false); Wrapper.SetProgressBar(this._userControl.progressBar, 0, false); string message = string.Empty; List <int> newMalwareHistoryIds; bool result = Wrapper.ScanFiles(type, srcFormat, inputPaths, out newMalwareHistoryIds, out message); MessageBox.Show(message); // Active form Wrapper.SetButtonState(this._userControl.startButton, true); Wrapper.SetProgressBar(this._userControl.progressBar, 100, !result); return(result); }
public override ExportEmployees GetExportFile(FileTypeEnum fileType) { switch (fileType) { case FileTypeEnum.CSV: return(new ExportCSVEmployees()); case FileTypeEnum.JSON: return(new ExportJsonEmployees()); case FileTypeEnum.DELIMITED: return(new ExportPipeDelimetedEmployees()); default: throw new ApplicationException(string.Format("File type '{0}' cannot be created", fileType)); } }
public void ReportTypeExtraB_Every_Property_Has_Get_Set_Test() { string val1 = "Some text"; reportTypeExtraB.ReportTypeReportTest = val1; Assert.AreEqual(val1, reportTypeExtraB.ReportTypeReportTest); string val2 = "Some text"; reportTypeExtraB.LastUpdateContactText = val2; Assert.AreEqual(val2, reportTypeExtraB.LastUpdateContactText); int val3 = 45; reportTypeExtraB.ReportTypeID = val3; Assert.AreEqual(val3, reportTypeExtraB.ReportTypeID); TVTypeEnum val4 = (TVTypeEnum)3; reportTypeExtraB.TVType = val4; Assert.AreEqual(val4, reportTypeExtraB.TVType); FileTypeEnum val5 = (FileTypeEnum)3; reportTypeExtraB.FileType = val5; Assert.AreEqual(val5, reportTypeExtraB.FileType); string val6 = "Some text"; reportTypeExtraB.UniqueCode = val6; Assert.AreEqual(val6, reportTypeExtraB.UniqueCode); DateTime val7 = new DateTime(2010, 3, 4); reportTypeExtraB.LastUpdateDate_UTC = val7; Assert.AreEqual(val7, reportTypeExtraB.LastUpdateDate_UTC); int val8 = 45; reportTypeExtraB.LastUpdateContactTVItemID = val8; Assert.AreEqual(val8, reportTypeExtraB.LastUpdateContactTVItemID); bool val9 = true; reportTypeExtraB.HasErrors = val9; Assert.AreEqual(val9, reportTypeExtraB.HasErrors); IEnumerable <ValidationResult> val30 = new List <ValidationResult>() { new ValidationResult("First CSSPError Message") }.AsEnumerable(); reportTypeExtraB.ValidationResults = val30; Assert.AreEqual(val30, reportTypeExtraB.ValidationResults); }
/// <summary> /// 根据文件类型获取文件图标 /// </summary> /// <param name="type"></param> /// <returns></returns> private static ImageSource GetIcon(FileTypeEnum type) { string iconPath = string.Empty; switch (type) { case FileTypeEnum.JPG: iconPath = "pack://application:,,,/LWIR.NET.Common;component/Images/fileIcon_jpg.png"; break; case FileTypeEnum.TIF: iconPath = "pack://application:,,,/LWIR.NET.Common;component/Images/fileIcon_tiff.png"; break; case FileTypeEnum.MP4: iconPath = "pack://application:,,,/LWIR.NET.Common;component/Images/fileIcon_mp4.png"; break; case FileTypeEnum.PDF: iconPath = "pack://application:,,,/LWIR.NET.Common;component/Images/fileIcon_pdf.png"; break; case FileTypeEnum.CSV: iconPath = "pack://application:,,,/LWIR.NET.Common;component/Images/fileIcon_csv.png"; break; case FileTypeEnum.BMP: iconPath = "pack://application:,,,/LWIR.NET.Common;component/Images/fileIcon_bmp.png"; break; case FileTypeEnum.PNG: iconPath = "pack://application:,,,/LWIR.NET.Common;component/Images/fileIcon_png.png"; break; case FileTypeEnum.FOLDER: iconPath = "pack://application:,,,/LWIR.NET.Common;component/Images/folder.png"; break; default: iconPath = "pack://application:,,,/LWIR.NET.Common;component/Images/fileIcon_general.png"; break; } return(CreateIcon(iconPath)); }
public File[] Filter(Folder root, FileTypeEnum type) { foreach (File file in root.Files) { if (file.Type == type) { output.Add(file); } } foreach (Folder folder in root.Folders) { if (!folder.IsEmpty) { Filter(folder, type); } } return(output.ToArray()); }
private void ExportData(FileTypeEnum storageEnum, bool selected = false, bool all = false) { var players = FilePath.GetBasketballPlayers(); var teams = FilePath.GetTeams(); var selectedTeam = lvTeamsOutput.SelectedItem as Teams; var refer = new ImpExpDB(); string path; refer.DataStorage = storageEnum; if (players.Count > 0 && storageEnum.ToString().Contains("player", StringComparison.OrdinalIgnoreCase)) { if (all) { refer.ExportPlayerDataFromDB(players.ToArray()); } if (selected) { refer.ExportPlayerDataFromDB(selectedTeam.BasketballPlayers.ToArray()); } ToLog("Basketball players data was inserted from database", MessageBoxImage.Information); path = refer.GetFilePath(); ShowFileDialog(path); return; } if (teams.Count > 0 && storageEnum.ToString().Contains("team", StringComparison.OrdinalIgnoreCase)) { if (all) { refer.ExportTeamDataFromDB(teams.ToArray()); } if (selected) { refer.ExportTeamDataFromDB(selectedTeam); } ToLog("Team data was inserted from database", MessageBoxImage.Information); path = refer.GetFilePath(); ShowFileDialog(path); return; } else { ToLog("Database is empty", MessageBoxImage.Error); } }
/// <summary> /// Returns the extension for the specified file type, including the period. /// Example: .wmod /// </summary> /// <param name="fileType">The type of file to retrieve an extension for.</param> /// <returns></returns> public string GetFileExtension(FileTypeEnum fileType) { switch (fileType) { // Contains end-user's custom graphics, sounds, etc case FileTypeEnum.ContentPackage: return ".cpak"; // Contains database information specific to an end-user's module case FileTypeEnum.Module: return ".wmod"; // Contains transportable database information case FileTypeEnum.Erf: return ".werf"; // Contains the engine's built-in models, textures, etc case FileTypeEnum.WinterResource: return ".wrsc"; // Sprite Sheet graphics case FileTypeEnum.SpriteSheet: return ".png"; // XNA compiled files case FileTypeEnum.XNACompiledFile: return ".xnb"; // Uncompiled hakpak files case FileTypeEnum.UncompiledHakpak: return ".wuch"; // Music files case FileTypeEnum.Music: return ".mp3"; // Sound files case FileTypeEnum.Sound: return ".wav"; // Database files case FileTypeEnum.Database: return ".sdf"; // Player character files case FileTypeEnum.PlayerCharacter: return ".wpc"; // "Deleted" player character files case FileTypeEnum.DeletedPlayerCharacter: return ".dwpc"; default: return ""; } }
public static FileTypeEnum CheckFile(HttpPostedFileBase file) { FileTypeEnum result = FileTypeEnum.UnKnow; foreach (var rule in DefaultRules.Values) { var tmp = rule; if (CustomRules.ContainsKey(rule.Type)) { tmp = CustomRules[rule.Type]; } if (CheckFile(file, tmp) != FileTypeEnum.UnKnow) { result = rule.Type; break; } } return(result); }
public static FileTypeEnum CheckFile(HttpPostedFileBase file, FileRule rule) { var extension = Path.GetExtension(file.FileName).ToLower(); var size = file.ContentLength; FileTypeEnum result = FileTypeEnum.UnKnow; if (Regex.IsMatch(extension, rule.FileExtensions)) { if (rule.Size > 0) { if (rule.Size < size) { throw new AbhsException(ErrorCodeEnum.FileSizeOverFlow, AbhsErrorMsg.ConstFileSizeError); } } result = rule.Type; } return(result); }
public void Write(string content, bool hasTimeStamp, FileTypeEnum fileType) { try { IFileNameGenerator generator = FileNameGeneratorFactory.Create(fileType); string fullfilename = generator.GetFileName(_fileNameFormat, fileSize); FileInfo file = new FileInfo(fullfilename); StringBuilder log = new StringBuilder(); if (hasTimeStamp) { log.AppendFormat("{0} -- {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), content); } else { log.Append(content); } //lock (locker) //{ if (!writeLock.IsWriteLockHeld) { writeLock.EnterWriteLock(); } try { if (!file.Exists) { file.Create().Close(); } File.AppendAllLines(file.FullName, new string[] { log.ToString() }); } finally { if (writeLock.IsWriteLockHeld) { writeLock.ExitWriteLock(); } } //} } catch { } }
/// <summary> /// Initialization for a local file (i.e UNC or local path). Use FileInfo for checking path and /// getting file size. Use Utility.Crc32 to calculate the CRC. All errors are catch and write in /// log manager. /// </summary> private void mInitLocalFile() { try { System.IO.FileInfo lFileInfo = new System.IO.FileInfo(_filePath); _exists = lFileInfo.Exists; _size = lFileInfo.Length; _fileType = FileTypeEnum.LocalFile; using (System.IO.Stream lFileStream = lFileInfo.OpenRead()) { //Calcul CRC Utility.Crc32 lCrcCalculator = new PIS.Ground.Core.Utility.Crc32(); _crc = lCrcCalculator.CalculateChecksum(lFileStream); } } catch (System.Security.SecurityException lEx) { PIS.Ground.Core.LogMgmt.LogManager.WriteLog(TraceType.ERROR, "mInitLocalFile() SecurityException with FilePath : " + _filePath, "PIS.Ground.Core.Data.RemoteFileClass", lEx, EventIdEnum.GroundCore); } catch (ArgumentException lEx) { PIS.Ground.Core.LogMgmt.LogManager.WriteLog(TraceType.ERROR, "mInitLocalFile() ArgumentException with FilePath : " + _filePath, "PIS.Ground.Core.Data.RemoteFileClass", lEx, EventIdEnum.GroundCore); } catch (UnauthorizedAccessException lEx) { PIS.Ground.Core.LogMgmt.LogManager.WriteLog(TraceType.ERROR, "mInitLocalFile() UnauthorizedAccessException with FilePath : " + _filePath, "PIS.Ground.Core.Data.RemoteFileClass", lEx, EventIdEnum.GroundCore); } catch (System.IO.PathTooLongException lEx) { PIS.Ground.Core.LogMgmt.LogManager.WriteLog(TraceType.ERROR, "mInitLocalFile() PathTooLongException with FilePath : " + _filePath, "PIS.Ground.Core.Data.RemoteFileClass", lEx, EventIdEnum.GroundCore); } catch (NotSupportedException lEx) { PIS.Ground.Core.LogMgmt.LogManager.WriteLog(TraceType.ERROR, "mInitLocalFile() NotSupportedException with FilePath : " + _filePath, "PIS.Ground.Core.Data.RemoteFileClass", lEx, EventIdEnum.GroundCore); } catch (Exception lEx) { PIS.Ground.Core.LogMgmt.LogManager.WriteLog(TraceType.ERROR, "mInitLocalFile() UnsupportedException with FilePath : " + _filePath, "PIS.Ground.Core.Data.RemoteFileClass", lEx, EventIdEnum.GroundCore); } }
public ErrorNotification(FileShell failedImg, FileTypeEnum fileType, bool allowReUpload, string uploader, string errorMessage) { InitializeComponent(); StartPosition = FormStartPosition.Manual; Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - Width, Screen.PrimaryScreen.WorkingArea.Height - Height); Closing += ErrorNotification_Closing; _animator = new FormAnimator(this); _animator.Direction = FormAnimator.AnimationDirection.Up; _animator.Method = FormAnimator.AnimationMethod.Slide; _animator.Duration = 500; if (!allowReUpload) { retryButton.Visible = false; } metroLabel2.Text = (fileType == FileTypeEnum.Video ? "There was an error while uploading your recording." : "There was an error while uploading your screenshot."); }
public void ImportFromFile(string name, FileTypeEnum type) { var mapper = GetColorMapper(); switch (type) { case FileTypeEnum.Bmp: _currentMap = FileHelper.ImportFromBmp(name, mapper); break; case FileTypeEnum.Text: _currentMap = FileHelper.ImportFromTxt(name, mapper); break; } _width = _currentMap.Width; _height = _currentMap.Height; Commit(); }
public static IFileNameGenerator Create(FileTypeEnum type) { IFileNameGenerator generator = null; switch (type) { case FileTypeEnum.Log: generator = new LogFileNameGenerator(); break; case FileTypeEnum.Debug: generator = new DebugFileNameGanerator(); break; case FileTypeEnum.Error: generator = new ErrorFileNameGenerator(); break; } return(generator); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="sourceFileType"></param> /// <param name="destinationFileType"></param> /// <param name="inputPath"></param> /// <param name="outputPath"></param> public FileConverter(FileTypeEnum sourceFileType, FileTypeEnum destinationFileType, string inputPath, string outputPath = null) { // 引数チェック if (sourceFileType.Equals(destinationFileType)) { throw new ArgumentException($"{ nameof( sourceFileType ) }と{ nameof( destinationFileType ) }が同じです。"); } if (inputPath.IndexOfAny(Path.GetInvalidPathChars()) > 0) { throw new ArgumentException("存在しないファイルパスです。", $"{ nameof( inputPath ) } = { inputPath }"); } if ((outputPath != null) && (outputPath.IndexOfAny(Path.GetInvalidPathChars()) > 0)) { throw new ArgumentException("存在しないファイルパスです。", $"{ nameof( outputPath ) } = { outputPath }"); } // プロパティの設定 SourceFileType = sourceFileType; DestinationFileType = destinationFileType; InputPath = inputPath; OutputPath = outputPath ?? inputPath.GetDirectoryName(); if (Directory.Exists(inputPath)) { var files = Directory.GetFiles(InputPath); if (sourceFileType.Equals(FileTypeEnum.All)) { TotalCount = files.Count(); } else { TotalCount = files.Where(x => x.FileTypeEquals(sourceFileType)).Count(); } } else { TotalCount = inputPath.FileTypeEquals(sourceFileType) ? 1 : 0; } }
private string GeneratePathByFileType(FileTypeEnum type) { string fileFolderPerType = null; switch (type) { case FileTypeEnum.BookFile: fileFolderPerType = $"{BasePath}/book/files"; break; case FileTypeEnum.BookPhoto: fileFolderPerType = $"{BasePath}/book/Imgs"; break; case FileTypeEnum.UserPhoto: fileFolderPerType = $"{BasePath}/user/Imgs"; break; } CreateDirectoryIfDoesNotExist(fileFolderPerType); return(fileFolderPerType); }
public IList<FileModel> GetAllFiles(FileTypeEnum enumValue) { IList<FileModel> fileModels = new List<FileModel>(); using (var unitOfWork = _unitOfWorkFactory.Create()) { try { var entities = unitOfWork.FileRepository.Get(x => x.FileType == (int)enumValue); foreach (var entity in entities) { fileModels.Add(new FileModel(entity)); } unitOfWork.Save(); } catch (Exception e) { _logger.LogToFile(_logger.CreateErrorMessage(e)); } } return fileModels; }
public static void UploadFile(string localFileName,FileTypeEnum fileType) { eAdDataAccess.ServiceClient service = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress); try { using (Stream fileStream = new FileStream(localFileName, FileMode.Open, FileAccess.Read)) { // var request = new FileUploadMessage(); string remoteFileName = null; if (fileType == FileTypeEnum.Generic) { // WE ARE USING THE SERVICE AS A "FTP ON WCF" // GIVE THE REMOTE FILE THE SAME NAME AS THE LOCAL ONE remoteFileName = Path.GetFileName(localFileName); } var fileMetadata = new FileMetaData { LocalFilename = localFileName, RemoteFilename = remoteFileName,FileType = fileType}; // request.MetaData = fileMetadata; // request.FileByteStream = fileStream; //service.UploadFile(fileMetadata,fileStream); service.Close(); } } catch (TimeoutException exception) { Console.WriteLine("Got {0}", exception.GetType()); service.Abort(); } catch (CommunicationException exception) { Console.WriteLine("Got {0}", exception.GetType()); service.Abort(); } }
protected ExifFile(FileTypeEnum fileType) { FileType = fileType; }
public FileMetaData(string fileName, string remoteFilePath, FileTypeEnum? fileType) { FileName = fileName; RemoteServerFilePath = remoteFilePath; FileType = fileType; }
private bool FindFile(FileTypeEnum fte) { bool exists = false; bool ret = false; string searchFile = ""; string errMsg = ""; if (fte == FileTypeEnum.Sql) { errMsg = sqlFile; if (dpType == DeployTypeEnum.Assembly && sqlProjFile == "") { if (firstFind) sqlProjFile = ""; else sqlProjFile = Path.Combine(vsProjPath, "sql.proj"); } searchFile =sqlProjFile; } else if (fte == FileTypeEnum.Project) { errMsg = projFile; if (vsProjectFile != "" && !vsProjectFile.Contains("$safeprojectname$")) searchFile = Path.Combine(vsProjPath, vsProjectFile); else if (vsProjectFile.Contains("$safeprojectname$")) searchFile = ""; else searchFile = vsProjectFile; } else if (fte == FileTypeEnum.Xml) { errMsg = typeErrFile; if (vsProjectFile != "") searchFile = Path.Combine(vsProjPath, "typeconversion.xml"); else searchFile = ""; } //check for the file and if not there browse for it if (searchFile == "" || !File.Exists(searchFile)) { MessageBox.Show(errMsg, "File Not Found"); searchFile = ""; exists = SelectFile(fte, out searchFile); } else exists = true; //if the file is there, set the properties if (exists) { if (fte == FileTypeEnum.Sql) { sqlProjFile = searchFile; txtSqlProjFile.Text = sqlProjFile; if (vsProjPath == "") vsProjPath = Path.GetDirectoryName(sqlProjFile); } else if (fte == FileTypeEnum.Project) { vsProjectFile = searchFile; txtProjFile.Text = vsProjectFile; } else if (fte == FileTypeEnum.Xml) { dsSqlProj.Tables["PropertyGroup"].Rows[0]["TypeConversionFilePath"] = searchFile; txtTypeFile.Text = searchFile; } ret = true; } return ret; }
/// <summary> /// Loads the external edit control and sets visibility of other controls /// </summary> /// <param name="repeaterItem">Repeater item</param> /// <param name="type">Source type</param> private void LoadExternalEditControl(RepeaterItem repeaterItem, FileTypeEnum type) { var plcAttachmentActions = repeaterItem.FindControl("plcAttachmentActions") as PlaceHolder; var plcAttachmentUpdtAction = repeaterItem.FindControl("plcAttachmentUpdtAction") as PlaceHolder; var plcLibraryUpdtAction = repeaterItem.FindControl("plcLibraryUpdtAction") as PlaceHolder; var plcExt = repeaterItem.FindControl("plcExtEdit") as PlaceHolder; var plcExtMfi = repeaterItem.FindControl("plcExtEditMfi") as PlaceHolder; var pnlDisabledUpdate = (repeaterItem.FindControl("pnlDisabledUpdate") as Panel); var dfuLib = repeaterItem.FindControl("dfuElemLib") as DirectFileUploader; var dfu = repeaterItem.FindControl("dfuElem") as DirectFileUploader; var btnEdit = repeaterItem.FindControl("btnEdit") as WebControl; var btnDelete = repeaterItem.FindControl("btnDelete") as WebControl; if ((plcAttachmentActions != null) && (plcLibraryUpdtAction != null) && (plcAttachmentUpdtAction != null) && (plcExt != null) && (plcExtMfi != null) && (pnlDisabledUpdate != null) && (dfuLib != null) && (dfu != null) && (btnEdit != null) && (btnDelete != null)) { var data = new DataRowContainer((DataRowView)repeaterItem.DataItem); plcAttachmentActions.Visible = true; plcAttachmentUpdtAction.Visible = false; pnlDisabledUpdate.Visible = false; dfuLib.Visible = false; dfu.Visible = false; btnEdit.Visible = false; btnDelete.Visible = false; plcExt.Visible = false; plcExtMfi.Visible = false; plcLibraryUpdtAction.Visible = (type == FileTypeEnum.MediaFile); ExternalEditHelper.LoadExternalEditControl(plcExt, type, null, data, IsLiveSite, TreeNodeObj, true); } }
private void LoadDocsForAsm(FileTypeEnum fte) { bool success = false; isDirty = false; try { // so we are checking for assembly first if (dpType == DeployTypeEnum.Assembly) { //we have started with an assembly or project file if (fte == FileTypeEnum.Project) { firstFind = false; pnlSql.Enabled = true; if (LoadSql()) { success = true; //if we're pointing to a dll (instead of a project file) if (Path.GetExtension(vsProjectFile) == ".dll") { if (dsSqlProj.Tables.Contains("Import")) dsSqlProj.Tables.Remove(dsSqlProj.Tables["Import"]); dsSqlProj.Tables["PropertyGroup"].Rows[0]["Assemblypath"] = vsProjectFile; dsSqlProj.Tables["PropertyGroup"].Rows[0]["Debugpath"] = Path.ChangeExtension(vsProjectFile, ".pdb"); } else {//we're pointing to a project file if (dsSqlProj.Tables["Import"].Rows[0]["Project"].ToString().Contains("$safeprojectname$")) { dsSqlProj.Tables["Import"].Rows[0]["Project"] = vsProjectFile; } } } } //we have loaded an already existing sql.proj file else if (fte == FileTypeEnum.Sql) { ReadIntoDatasetSqlFile(); if (dsSqlProj.Tables.Contains("Import")) { vsProjectFile = dsSqlProj.Tables["Import"].Rows[0]["Project"].ToString(); } else vsProjectFile = dsSqlProj.Tables["PropertyGroup"].Rows[0]["Assemblypath"].ToString(); if (LoadProj()) { success = true; } } } if (success) { SetProjectNameAndAsm(); LoadTypeFile(); pnlType.Enabled = true; //hook up the data SetUpDataBinding(); ////finally set control state grpAsmSettings.Enabled = true; grpDb.Enabled = true; grpMisc.Enabled = true; pnlSrcPath.Enabled = chkSource.Checked; pnlDbg.Enabled = chkDbgSymbols.Checked; } } catch(Exception e) { MessageBox.Show("An unexpected error happened. The error is: " + e.Message + ".", "Unexpected Error"); grpProjFiles.Enabled = true; isDirty = false; } }
/// <summary> /// Allows the user to select the various project files /// </summary> /// <param name="fte">FileTypeEnum defining whether we're looking for the *.proj file (0), the VS project file, the Xml type conversion file or the compiled assembly.</param> /// <param name="projFile">The path to the file</param> /// <returns>boolean</returns> private bool SelectFile(FileTypeEnum fte, out string projFile) { projFile = ""; string combineFile = "sql.proj"; string filePath = appPath; string fileFilter = "sql deployment proj files (*.proj)|*.proj|All files (*.*)|*.*"; if (fte == FileTypeEnum.Sql) { if (dpType == DeployTypeEnum.Assembly && vsProjPath != "") filePath = vsProjPath; } else if (fte == FileTypeEnum.Project) { fileFilter = "C# Project files (*.csproj)|*.csproj|VB Project files (*.vbproj)|*.vbproj |All files (*.*)|*.*"; if (dpType == DeployTypeEnum.Assembly) fileFilter = "Dll file (*.dll)|*.dll|C# Project files (*.csproj)|*.csproj|VB Project files (*.vbproj)|*.vbproj |All files (*.*)|*.*"; filePath = vsProjPath; } else if (fte == FileTypeEnum.Assembly) { fileFilter = "Dll file (*.dll)|*.dll|All files (*.*)|*.*"; filePath = vsProjPath; } else if (fte == FileTypeEnum.Xml) { fileFilter = "Type conversion file (*.xml)|*.xml|All files (*.*)|*.*"; filePath = appPath; } else if (fte == FileTypeEnum.Debug) { fileFilter = "Debug symbols file (*.pdb)|*.pdb|All files (*.*)|*.*"; filePath = vsProjPath; } fd = new OpenFileDialog(); fd.InitialDirectory = filePath; fd.Filter = fileFilter; fd.FilterIndex = 1; fd.RestoreDirectory = false; if (fd.ShowDialog() == DialogResult.OK) { projFile = fd.FileName; if (Path.GetDirectoryName(projFile) != vsProjPath) { if (fte == FileTypeEnum.Xml) combineFile = "typeconversion.xml"; if(fte == FileTypeEnum.Sql || fte == FileTypeEnum.Xml) { File.Copy(projFile, Path.Combine(vsProjPath, combineFile)); projFile = Path.Combine(vsProjPath, combineFile); } } return true; } else return false; }