예제 #1
0
        public override void GenerateCode(IFunctionBuilder functionBuilder)
        {
            bool closeFileHandle = FunctionData.Properties.ContainsKey(FileShared.OwnsFileHandlePropertyName) ? FunctionData.Properties[FileShared.OwnsFileHandlePropertyName].GetValue <bool>() : true;

            functionBuilder.AddCode(String.Format(
                                        @"var fileHandle = (Twenty57.Linx.Components.File.Common.BinaryFileHandle){0};{1}
				return Twenty57.Linx.Components.File.BinaryFileWriteX.WriteFile(
					fileHandle, 
					{2},
					{3}, 
					{4}, 
					{5},
					message => {6}.Log(message)
					);"                    ,
                                        functionBuilder.GetParamName(FileShared.FilePathPropertyName),
                                        closeFileHandle ? string.Format("{0}fileHandle.LogEvent += message => {1}.Log(message);", Environment.NewLine, functionBuilder.ContextParamName) : string.Empty,
                                        CSharpUtilities.BoolAsString(closeFileHandle),
                                        functionBuilder.GetParamName(BinaryFileWriteShared.ContentsPropertyName),
                                        CSharpUtilities.EnumAsString(FunctionData.Properties[BinaryFileWriteShared.FileDoesNotExistPropertyName].Value),
                                        CSharpUtilities.EnumAsString(FunctionData.Properties[BinaryFileWriteShared.FileExistsPropertyName].Value),
                                        functionBuilder.ContextParamName
                                        ));

            functionBuilder.AddAssemblyReference(typeof(BinaryFileWriteX));
        }
예제 #2
0
        public override void GenerateCode(IFunctionBuilder functionBuilder)
        {
            this.functionBuilder = functionBuilder;

            FileListX_Gen generator = new FileListX_Gen();

            generator.Session = new Dictionary <string, object>();
            generator.Session.Add("FunctionContextPropertyName", functionBuilder.ContextParamName);

            generator.Session.Add("IncludeSubfolders", CSharpUtilities.BoolAsString(FunctionData.Properties[FileListShared.IncludeSubfoldersPropertyName].GetValue <bool>()));
            generator.Session.Add("FolderPath", functionBuilder.GetParamName(FileListShared.FolderPathPropertyName));
            generator.Session.Add("SearchPattern", functionBuilder.GetParamName(FileListShared.SearchPatternPropertyName));
            generator.Session.Add("LoopResults", LoopResults);
            generator.Session.Add("ReturnFullPath", FunctionData.Properties[FileListShared.ReturnFullPathPropertyName].GetValue <bool>());

            generator.Session.Add("FileInfoTypeName", GetFileInfoTypeName());
            generator.Session.Add("OutputTypeName", functionBuilder.GetTypeName(FunctionData.Output));
            generator.Session.Add("ExecutionPathName", FileListShared.OutputFileProperty);
            generator.Session.Add("ExecutionPathOutputName", functionBuilder.ExecutionPathOutParamName);

            generator.Initialize();
            functionBuilder.AddCode(generator.TransformText());

            functionBuilder.AddAssemblyReference(typeof(FileListX));
        }
예제 #3
0
        public override void GenerateCode(IFunctionBuilder functionBuilder)
        {
            RobocopyShared.ModeOption modeOption = FunctionData.Properties[RobocopyShared.ModePropertyName].GetValue <RobocopyShared.ModeOption>();

            functionBuilder.AddCode(string.Format("Twenty57.Linx.Components.File.RobocopyX.Execute({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26},{27},{28},{29},{30},{31},{32},{33},{34},{35},{36},{37},{38},message => {39}.Log(message));",
                                                  functionBuilder.GetParamName(RobocopyShared.SourceDirectoryPropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.TargetDirectoryPropertyName)
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.CopySubdirectoriesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.IncludeEmptySubdirectoriesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.RestartModePropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.BackupModePropertyName].GetValue <bool>())
                                                  , functionBuilder.GetParamName(RobocopyShared.NumberOfRetriesPropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.TimeBetweenRetriesPropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.FilePatternPropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.ExcludeFilesPropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.ExcludeDirectoriesPropertyName)
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludesChangedFilesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludesNewerFilesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludesOlderFilesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludesExtraFilesAndDirectoriesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludesLonelyFilesAndDirectoriesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.IncludesSameFilesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.IncludesTweakedFilesPropertyName].GetValue <bool>())
                                                  , functionBuilder.GetParamName(RobocopyShared.MaxFileSizePropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.MinFileSizePropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.MaxAgePropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.MinAgePropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.MaxLastAccessDatePropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.MinLastAccessDatePropertyName)
                                                  , functionBuilder.GetParamName(RobocopyShared.LogFilePropertyName)
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.OverwriteFilePropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ListFilesOnlyPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.LogAllExtraFilesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.VerbosePropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.IncludeSourceFileTimestampsPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.IncludeFullPathPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.LogSizeAsBytesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludeFileSizePropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludeFileClassPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludeFileNamesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludeDirectoryNamesPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.ExcludeProgressPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.BoolAsString(FunctionData.Properties[RobocopyShared.IncludeETAPropertyName].GetValue <bool>())
                                                  , CSharpUtilities.EnumAsString(modeOption)
                                                  , functionBuilder.ContextParamName));

            functionBuilder.AddAssemblyReference(typeof(Robocopy));
        }
예제 #4
0
        public override void GenerateCode(Plugin.Common.CodeGeneration.IFunctionBuilder functionBuilder)
        {
            functionBuilder.AddCode(
                string.Format(@"var executor = new Twenty57.Linx.Components.File.V1.DirectoryOperationsX();
				executor.LogEvent += message => {0}.Log(message);"                , functionBuilder.ContextParamName));

            DirectoryOperationsShared.ActionType actionType = FunctionData.Properties[DirectoryOperationsShared.ActionPropertyName].GetValue <DirectoryOperationsShared.ActionType>();
            switch (actionType)
            {
            case DirectoryOperationsShared.ActionType.DirectoryExists:
                functionBuilder.AddCode(string.Format("return executor.DirectoryExists({0});",
                                                      functionBuilder.GetParamName(DirectoryOperationsShared.DirectoryPropertyName)));
                break;

            case DirectoryOperationsShared.ActionType.Create:
                functionBuilder.AddCode(string.Format("return executor.CreateDirectory({0}, {1});",
                                                      functionBuilder.GetParamName(DirectoryOperationsShared.DirectoryPropertyName),
                                                      CSharpUtilities.EnumAsString(FunctionData.Properties[DirectoryOperationsShared.CreateDirectoryExistsPropertyName].GetValue <DirectoryOperationsShared.CreateExistsOption>())));
                break;

            case DirectoryOperationsShared.ActionType.Delete:
                functionBuilder.AddCode(string.Format("executor.DeleteDirectory({0});",
                                                      functionBuilder.GetParamName(DirectoryOperationsShared.DirectoryPropertyName)));
                break;

            case DirectoryOperationsShared.ActionType.Copy:
            case DirectoryOperationsShared.ActionType.Move:
                functionBuilder.AddCode(string.Format(@"executor.CopyOrMove({0}, {1}, {2}, {3}, {4});",
                                                      CSharpUtilities.EnumAsString(actionType),
                                                      functionBuilder.GetParamName(DirectoryOperationsShared.SourceDirectoryPropertyName),
                                                      functionBuilder.GetParamName(DirectoryOperationsShared.TargetDirectoryPropertyName),
                                                      CSharpUtilities.EnumAsString(FunctionData.Properties[DirectoryOperationsShared.DirectoryExistsPropertyName].GetValue <DirectoryOperationsShared.ExistsOption>()),
                                                      CSharpUtilities.BoolAsString(FunctionData.Properties[DirectoryOperationsShared.ReplaceExistingFilePropertyName].GetValue <bool>())));
                break;

            default:
                throw new Exception(string.Format("Invalid action type [{0}] specified.", actionType));
            }

            functionBuilder.AddAssemblyReference(typeof(DirectoryOperations));
        }
예제 #5
0
        public override void GenerateCode(IServiceBuilder serviceBuilder)
        {
            var data = ServiceUpdater.Instance.Update(serviceBuilder.Data);

            var notifyFilterValue = data.Properties[DirectoryWatchShared.NotifyFilterPropertyName].Value as NotifyFilter;

            var code = String.Format(
                @"return new Twenty57.Linx.Components.File.DirectoryWatchX({0}, {1}, {2}, {3}, Twenty57.Linx.Components.File.NotifyFilter.ConvertFromString(""{4}""), {5}, {6}, {7}, {8});",
                serviceBuilder.GetParamName(DirectoryWatchShared.PathPropertyName),
                serviceBuilder.GetParamName(DirectoryWatchShared.FilterPropertyName),
                serviceBuilder.GetParamName(DirectoryWatchShared.IncludeSubdirectoriesPropertyName),
                serviceBuilder.GetParamName(DirectoryWatchShared.BufferSizePropertyName),
                notifyFilterValue.ConvertToString(),
                CSharpUtilities.BoolAsString(data.Properties[DirectoryWatchShared.WatchForChangesPropertyName].GetValue <bool>()),
                CSharpUtilities.BoolAsString(data.Properties[DirectoryWatchShared.WatchForCreationPropertyName].GetValue <bool>()),
                CSharpUtilities.BoolAsString(data.Properties[DirectoryWatchShared.WatchForDeletionsPropertyName].GetValue <bool>()),
                CSharpUtilities.BoolAsString(data.Properties[DirectoryWatchShared.WatchForRenamingPropertyName].GetValue <bool>()));

            serviceBuilder.AddCode(code);

            serviceBuilder.AddAssemblyReference(typeof(DirectoryWatchX));
        }
예제 #6
0
        public override void GenerateCode(IFunctionBuilder functionBuilder)
        {
            FileOperationsShared.ActionType   actionType   = FunctionData.Properties[FileOperationsShared.ActionPropertyName].GetValue <FileOperationsShared.ActionType>();
            FileOperationsShared.ExistsOption existsOption = FunctionData.Properties[FileOperationsShared.FileExistsPropertyName].GetValue <FileOperationsShared.ExistsOption>();

            if (actionType == FileOperationsShared.ActionType.FileExists)
            {
                functionBuilder.AddCode(string.Format(
                                            @"bool exists = Twenty57.Linx.Components.File.FileOperationsX.FileExists({0});
					{1}.Log(System.String.Format(""File {{0}} {{1}}"", {0}, exists ? ""exists."" : ""does not exist.""));
					return exists;"                    ,
                                            functionBuilder.GetParamName(FileOperationsShared.SourceFilePathPropertyName),
                                            functionBuilder.ContextParamName));
            }
            else if (actionType == FileOperationsShared.ActionType.CreateTempFile)
            {
                functionBuilder.AddCode(string.Format(
                                            @"string tempFilePath = Twenty57.Linx.Components.File.FileOperationsX.CreateTempFile();
					{0}.Log(System.String.Format(""Temp file created at {{0}}."", tempFilePath));
					return tempFilePath;"                    ,
                                            functionBuilder.ContextParamName));
            }
            else
            {
                bool keepFileName = FunctionData.Properties.ContainsKey(FileOperationsShared.KeepFileNamePropertyName) ? FunctionData.Properties[FileOperationsShared.KeepFileNamePropertyName].GetValue <bool>() : true;
                functionBuilder.AddCode(string.Format(@"string destinationFilePath = 
					Twenty57.Linx.Components.File.FileOperationsX.Execute({0}, {1}, {2}, {3}, {4}, message => {5}.Log(message));"
                                                      , functionBuilder.GetParamName(FileOperationsShared.SourceFilePathPropertyName)
                                                      , CSharpUtilities.BoolAsString(keepFileName)
                                                      , functionBuilder.GetParamName(keepFileName ? FileOperationsShared.DestinationFolderPathPropertyName : FileOperationsShared.DestinationFilePathPropertyName)
                                                      , CSharpUtilities.EnumAsString(actionType), CSharpUtilities.EnumAsString(existsOption)
                                                      , functionBuilder.ContextParamName));
                if (actionType != FileOperationsShared.ActionType.Delete)
                {
                    functionBuilder.AddCode("return destinationFilePath;");
                }
            }
            functionBuilder.AddAssemblyReference(typeof(FileOperations));
        }
예제 #7
0
        public override void GenerateCode(IFunctionBuilder functionBuilder)
        {
            bool isText = FunctionData.Properties[FileOpenShared.IsTextPropertyName].GetValue <bool>();

            functionBuilder.AddCode(string.Format(
                                        @"var fileOpenX = new Twenty57.Linx.Components.File.FileOpen.FileOpenX({0}, {1}, {2}, {3}, {4}, message => {5}.Log(message));
			{6} = fileOpenX.Select(fileHandle => new Twenty57.Linx.Plugin.Common.CodeGeneration.NextResult({7}, new {8} {{ {9} = fileOpenX.FilePath, {10} = ({11})fileHandle }}));
			return fileOpenX.FilePath;"            ,
                                        functionBuilder.GetParamName(FileOpenShared.FilePathPropertyName),
                                        CSharpUtilities.BoolAsString(isText),
                                        CSharpUtilities.EnumAsString(FunctionData.Properties[FileOpenShared.CodepagePropertyName].Value),
                                        CSharpUtilities.EnumAsString(FunctionData.Properties[FileOpenShared.FileDoesNotExistPropertyName].Value),
                                        CSharpUtilities.EnumAsString(FunctionData.Properties[FileOpenShared.FileExistsPropertyName].Value),
                                        functionBuilder.ContextParamName,
                                        functionBuilder.ExecutionPathOutParamName,
                                        CSharpUtilities.ToVerbatimString(FileOpenShared.ExecutionPathName),
                                        functionBuilder.GetTypeName(FunctionData.ExecutionPaths[FileOpenShared.ExecutionPathName].Output),
                                        FileOpenShared.OutputFilePathPropertyName,
                                        FileOpenShared.OutputFileHandlePropertyName,
                                        (isText ? typeof(TextFileHandle) : typeof(BinaryFileHandle)).FullName));

            functionBuilder.AddAssemblyReference(typeof(FileOpenX));
        }