Beispiel #1
0
        /// <summary>
        /// Encapsula a chamada ao gerador de relatórios, decide qual classe de relatório utilizar
        /// </summary>
        private void BuildReport(String reportFilename, ReportTypeEnum reportType, ReportFrequencyEnum reportFrequency)
        {
            FileInfo  reportFile = new FileInfo(reportFilename);
            DateRange dateRange  = ReportContext.GetDateRange(reportFrequency);

            // Usa a classe base dos relatórios para obter o nome completo da classe incluindo dll/assembly
            String qualifiedName = typeof(AbstractReport).AssemblyQualifiedName;

            qualifiedName = qualifiedName.Replace("AbstractReport", reportType.ToString());
            Type reportClass = Type.GetType(qualifiedName);

            // Monta os parâmetros do relatório e cria uma instância da classe de relatório
            ArgumentBuilder argumentBuilder = new ArgumentBuilder();

            argumentBuilder.Add("tenantId", currentTenant.ToString());
            argumentBuilder.Add("startDate", dateRange.GetFirstDay().ToString());
            argumentBuilder.Add("endDate", dateRange.GetLastDay().ToString());
            AbstractReport report = (AbstractReport)Activator.CreateInstance(reportClass, argumentBuilder.GetArguments(reportClass));

            // Caso não seja nenhum dos relatórios implementados aborta
            if ((reportClass == null) || (report == null))
            {
                return;
            }

            // Gera o relatório
            report.InitializeComponents(reportFile, currentReportBuilder, dataAccess.GetConnection());
            report.BuildReport();
        }
Beispiel #2
0
        private void Revert_Click(object sender, EventArgs e)
        {
            var args       = new ArgumentBuilder();
            var canExecute = true;

            if (_isMerge)
            {
                if (ParentsList.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, _noneParentSelectedTextCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    canExecute = false;
                }
                else
                {
                    args.Add("-m " + (ParentsList.SelectedItems[0].Index + 1));
                }
            }

            if (checkAddReference.Checked)
            {
                args.Add("-x");
            }

            if (canExecute)
            {
                FormProcess.ShowDialog(this, GitCommandHelpers.CherryPickCmd(Revision.ObjectId, AutoCommit.Checked, args.ToString()));
                MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
        public ArgumentString GetRevisionFilter()
        {
            // If the value is not user defined, update it to the new default value.
            if (_maxRevisionGraphCommitsDefaultValue == (int)_NO_TRANSLATE_Limit.Value)
            {
                _maxRevisionGraphCommitsDefaultValue = AppSettings.MaxRevisionGraphCommits;
                _NO_TRANSLATE_Limit.Value            = AppSettings.MaxRevisionGraphCommits;
            }

            var filter = new ArgumentBuilder();

            if (AuthorCheck.Checked && GitVersion.Current.IsRegExStringCmdPassable(Author.Text))
            {
                filter.Add($"--author=\"{Author.Text}\"");
            }

            if (CommitterCheck.Checked && GitVersion.Current.IsRegExStringCmdPassable(Committer.Text))
            {
                filter.Add($"--committer=\"{Committer.Text}\"");
            }

            if (MessageCheck.Checked && GitVersion.Current.IsRegExStringCmdPassable(Message.Text))
            {
                filter.Add($"--grep=\"{Message.Text}\"");
            }

            if (!filter.IsEmpty && IgnoreCase.Checked)
            {
                filter.Add("--regexp-ignore-case");
            }

            if (SinceCheck.Checked)
            {
                filter.Add($"--since=\"{Since.Value:yyyy-MM-dd hh:mm:ss}\"");
            }

            if (CheckUntil.Checked)
            {
                filter.Add($"--until=\"{Until.Value:yyyy-MM-dd hh:mm:ss}\"");
            }

            if (LimitCheck.Checked && _NO_TRANSLATE_Limit.Value > 0)
            {
                filter.Add($"--max-count={(int)_NO_TRANSLATE_Limit.Value}");
            }

            return(filter);
        }
Beispiel #4
0
        /// <summary>
        /// Adds a directory to the archive, compressing it in the process.
        /// </summary>
        /// <param name="dir">The directory to compress.</param>
        /// <param name="workingdir">The working directory to set.</param>
        /// <param name="level">The amount of compression to use.</param>

        public void CompressDirectory(string[] folders, string workingdir, CompressionLevel level = CompressionLevel.Normal)
        {
            ArgumentBuilder argumentBuilder = GetCompressionArguments(level);

            // Adding password switch only if password has been given in constructor
            if (!string.IsNullOrEmpty(password))
            {
                argumentBuilder.AddSwitch(new SwitchPassword(password));

                if (encryptHeaders)
                {
                    argumentBuilder.Add(new SwitchEncryptHeaders());
                }
            }

            argumentBuilder.AddTargets(folders);

            WProcess p = new WProcess(argumentBuilder);

            if (workingdir != null)
            {
                p.BaseProcess.StartInfo.WorkingDirectory = workingdir;
            }

            p.ProgressUpdated += ProgressUpdated;

            p.Execute();
        }
Beispiel #5
0
        public void IsEmpty()
        {
            var builder = new ArgumentBuilder();

            builder.IsEmpty.Should().BeTrue();

            builder.Add("test");
            builder.IsEmpty.Should().BeFalse();
        }
        public ArgumentString GetRevisionFilter()
        {
            var filter = new ArgumentBuilder();

            if (AuthorCheck.Checked && GitVersion.Current.IsRegExStringCmdPassable(Author.Text))
            {
                filter.Add($"--author=\"{Author.Text}\"");
            }

            if (CommitterCheck.Checked && GitVersion.Current.IsRegExStringCmdPassable(Committer.Text))
            {
                filter.Add($"--committer=\"{Committer.Text}\"");
            }

            if (MessageCheck.Checked && GitVersion.Current.IsRegExStringCmdPassable(Message.Text))
            {
                filter.Add($"--grep=\"{Message.Text}\"");
            }

            if (!filter.IsEmpty && IgnoreCase.Checked)
            {
                filter.Add("--regexp-ignore-case");
            }

            if (SinceCheck.Checked)
            {
                filter.Add($"--since=\"{Since.Value:yyyy-MM-dd hh:mm:ss}\"");
            }

            if (CheckUntil.Checked)
            {
                filter.Add($"--until=\"{Until.Value:yyyy-MM-dd hh:mm:ss}\"");
            }

            if (LimitCheck.Checked && _NO_TRANSLATE_Limit.Value > 0)
            {
                filter.Add($"--max-count=\"{(int)_NO_TRANSLATE_Limit.Value}\"");
            }

            return(filter);
        }
Beispiel #7
0
        public void Add(string[] args, int expectedLength, string expected)
        {
            var builder = new ArgumentBuilder();

            foreach (string arg in args)
            {
                builder.Add(arg);
            }

            builder.Length.Should().Be(expectedLength);
            builder.ToString().Should().Be(expected);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Organiza os argumentos recebidos na querystring
            ArgumentBuilder argumentBuilder = new ArgumentBuilder();

            foreach (String argumentName in Request.QueryString)
            {
                argumentBuilder.Add(argumentName, Request.QueryString[argumentName]);
            }

            // Cria uma instância da classe de relatório ( através de Reflection )
            Type           reportClass = null;
            AbstractReport report      = null;

            if (!String.IsNullOrEmpty(Request["report"]))
            {
                // Usa a classe base dos relatórios para obter o nome completo da classe incluindo dll/assembly
                String qualifiedName = typeof(AbstractReport).AssemblyQualifiedName;
                qualifiedName = qualifiedName.Replace("AbstractReport", Request["report"]);

                reportClass = Type.GetType(qualifiedName);
                report      = (AbstractReport)Activator.CreateInstance(reportClass, argumentBuilder.GetArguments(reportClass));
            }

            // Aborta a operação caso o relatório solicitado não exista
            if ((reportClass == null) || (report == null))
            {
                return;
            }

            Dictionary <String, Object> exportOptions = ExportFormatContext.GetExportOptions(Session);

            this.Response.Clear();
            this.Response.ContentType = (String)exportOptions["ContentType"];
            this.Response.AddHeader("content-disposition", (String)exportOptions["Disposition"]);

            // Abre a conexão com o banco
            DataAccess dataAccess = DataAccess.Instance;

            dataAccess.MountConnection(FileResource.MapWebResource(this.Page.Server, "DataAccess.xml"), DatabaseEnum.PrintAccounting);
            dataAccess.OpenConnection();

            // Executa inicializações e chama o método "BuildReport" na instância da classe de relatório
            report.InitializeComponents(this.Page, (IReportBuilder)exportOptions["ReportBuilder"], dataAccess.GetConnection());
            report.BuildReport();

            // Fecha a conexão com o banco
            dataAccess.CloseConnection();
            dataAccess = null;

            this.Response.End();
        }
Beispiel #9
0
        private void Revert_Click(object sender, EventArgs e)
        {
            var args       = new ArgumentBuilder();
            var canExecute = true;

            if (_isMerge)
            {
                if (ParentsList.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    canExecute = false;
                }
                else
                {
                    args.Add("-m " + (ParentsList.SelectedItems[0].Index + 1));
                }
            }

            if (checkAddReference.Checked)
            {
                args.Add("-x");
            }

            if (canExecute)
            {
                var  command = GitCommandHelpers.CherryPickCmd(Revision.ObjectId, AutoCommit.Checked, args.ToString());
                bool success = FormProcess.ShowDialog(this, process: null, arguments: command, Module.WorkingDir, input: null, useDialogSettings: true);
                if (!success)
                {
                    return;
                }

                MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Beispiel #10
0
        public void Length()
        {
            var builder = new ArgumentBuilder();

            builder.Length.Should().Be(0);

            builder.Add("test");
            builder.Length.Should().Be(4);

            var args           = "Lorem ipsum dolor sit amet, solet soleat option mel no.";
            var expectedLength = args.Length;

            builder.AddRange(args.Split(' '));
            builder.Length.Should().Be(expectedLength + /* 'test ' */ 5);
        }
Beispiel #11
0
        private void Revert_Click(object sender, EventArgs e)
        {
            var args       = new ArgumentBuilder();
            var canExecute = true;

            if (_isMerge)
            {
                if (ParentsList.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, TranslatedStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    canExecute = false;
                }
                else
                {
                    args.Add("-m " + (ParentsList.SelectedItems[0].Index + 1));
                }
            }

            if (checkAddReference.Checked)
            {
                args.Add("-x");
            }

            if (canExecute && Revision is not null)
            {
                var command = GitCommandHelpers.CherryPickCmd(Revision.ObjectId, AutoCommit.Checked, args.ToString());

                // Don't verify whether the command is successful.
                // If it fails, likely there is a conflict that needs to be resolved.
                FormProcess.ShowDialog(this, process: null, arguments: command, Module.WorkingDir, input: null, useDialogSettings: true);

                MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Beispiel #12
0
        private ArgumentString GetInternal([CanBeNull] string firstRevision, [CanBeNull] string secondRevision, string fileName = null, string oldFileName = null, bool isTracked = true)
        {
            // Combined Diff artificial commit should not be included in diffs
            if (firstRevision == GitRevision.CombinedDiffGuid || secondRevision == GitRevision.CombinedDiffGuid)
            {
                throw new ArgumentOutOfRangeException(nameof(firstRevision), firstRevision,
                                                      "CombinedDiff artificial commit cannot be explicitly compared: " +
                                                      firstRevision + ", " + secondRevision);
            }

            var extra = new ArgumentBuilder();

            firstRevision  = ArtificialToDiffOptions(firstRevision);
            secondRevision = ArtificialToDiffOptions(secondRevision);

            // Note: As artificial are options, diff unstage..unstage and
            // stage..stage will show output, different from e.g. HEAD..HEAD
            // Diff-to-itself is not always disabled or is transient why this is not handled as error in release builds
            Debug.Assert(!(firstRevision == secondRevision && (string.IsNullOrEmpty(firstRevision) || firstRevision == StagedOpt)),
                         "Unexpectedly two identical artificial revisions to diff: " + firstRevision +
                         ". This will be displayed as diff to HEAD, not an identical diff.");

            // As empty (unstaged) and --cached (staged) are options (not revisions),
            // order must be preserved with -R
            if (firstRevision != secondRevision && (string.IsNullOrEmpty(firstRevision) ||
                                                    (firstRevision == StagedOpt && !string.IsNullOrEmpty(secondRevision))))
            {
                extra.Add("-R");
            }

            // Special case: Remove options comparing worktree-index
            if ((string.IsNullOrEmpty(firstRevision) && secondRevision == StagedOpt) ||
                (firstRevision == StagedOpt && string.IsNullOrEmpty(secondRevision)))
            {
                firstRevision = secondRevision = "";
            }

            // Reorder options - not strictly required
            if (secondRevision == StagedOpt)
            {
                extra.Add(StagedOpt);
                secondRevision = "";
            }

            if (string.IsNullOrWhiteSpace(fileName))
            {
                extra.Add(firstRevision);
                extra.Add(secondRevision);
            }
            else
            {
                // Untracked files can only be compared to /dev/null
                // The UI should normally only allow this for worktree to index, but it can be included in multi selections
                if (!isTracked)
                {
                    extra.Add("--no-index");
                    oldFileName = fileName;
                    fileName    = "/dev/null";
                }
                else
                {
                    extra.Add(firstRevision);
                    extra.Add(secondRevision);
                }

                extra.Add("--");
                extra.Add(fileName.QuoteNE());
                extra.Add(oldFileName.QuoteNE());
            }

            return(extra);
        }
Beispiel #13
0
        private void BuildCommandLineArguments(BuildEnvironment environment, Csc csc, ArgumentBuilder arguments)
        {
            if (AllowUnsafeBlocks(environment, csc))
            {
                arguments.Flag("unsafe");
            }

            arguments.Add("debug", GetDebugType(environment, csc));
            if (EmitDebugInformation(environment, csc))
            {
                arguments.Flag("debug+");
            }

            if (!Optimize(environment, csc))
            {
                arguments.Flag("optimize-");
            }

            var baseAddress = GetBaseAddress(environment, csc);

            if (!string.IsNullOrEmpty(baseAddress))
            {
                arguments.Add("baseaddress", baseAddress);
            }

            arguments.Add("define", GetDefines(environment, csc));
            arguments.Add("nowarn", GetDisabledWarnings(environment, csc));

            if (GetNoLogo(environment, csc))
            {
                arguments.Flag("nologo");
            }

            arguments.Add("target", GetTarget(environment, csc));
            arguments.Add("errorreport", GetErrorReport(environment, csc));
            arguments.Add("platform", GetPlatform(environment, csc));

            if (ErrorEndLocation(environment, csc))
            {
                arguments.Flag("errorendlocation");
            }

            arguments.Add("filealign", GetFileAlignment(environment, csc));

            if (HighEntropyVA(environment, csc))
            {
                arguments.Flag("highentropyva+");
            }

            arguments.Add("out", GetOutputAssembly(environment, csc));

            arguments.Flag("nostdlib+");

            var rootPath   = environment.Properties[Properties.MSBuildProjectDirectory];
            var references = _expressionEngine.EvaluateItemList(csc.References, environment);

            foreach (var reference in references)
            {
                AddReference(arguments, reference, rootPath);
            }

            var resources = _expressionEngine.EvaluateItemList(csc.Resources, environment);

            foreach (var resource in resources)
            {
                var include      = resource.Include;
                var resourceName = string.Format("EmbeddedResource.{0}", include.Replace('\\', '.'));
                arguments.Add("resource", resource.Include, resourceName);
            }

            var sources = _expressionEngine.EvaluateItemList(csc.Sources, environment);

            foreach (var source in sources)
            {
                arguments.Add(source.Include);
            }

            string outputPath = environment.Properties[Properties.OutputPath];

            _fileSystem.CreateDirectory(outputPath);

            // http://stackoverflow.com/questions/19306194/process-launch-exception-filename-or-extension-is-too-long-can-it-be-caused-b
            int commandLineLength = arguments.Length + CompilerPath.Length + 1;

            if (commandLineLength > 32000)             //< The maximum length seems to be 32768, but this one's close enough
            {
                // In order to not exceed the limit we'll have to write the arguments
                // to a file that is then passes as an argument to csc (so that's why that option exists).
                var filename = Path.Combine(outputPath, "csc_arguments.txt");
                File.WriteAllText(filename, arguments.ToString());
                arguments.Clear();

                arguments.Add(string.Format("\"@{0}\"", filename));
            }

            // without this, csc automatically references a bunch of assemblies and then gives us shit
            // that we've included a double reference...
            arguments.Flag("noconfig");
        }
Beispiel #14
0
        private void AddReference(ArgumentBuilder arguments, ProjectItem reference, string rootPath)
        {
            string referencePath = reference.Include;

            arguments.Add("reference", referencePath);
        }