[STAThread] // Required to support the interactive login experience
        static void Main(string[] args)
        {
            CrmServiceClient service = null;

            try
            {
                service = SampleHelpers.Connect("Connect");
                if (service.IsReady)
                {
                    // Create any entity records that the demonstration code requires
                    SetUpSample(service);

                    #region Demonstrate
                    // Create the target for the request.
                    var target = new EntityReference();

                    // Id is the GUID of the account that is being merged into.
                    // LogicalName is the type of the entity being merged to, as a string
                    target.Id          = _account1Id;
                    target.LogicalName = Account.EntityLogicalName;

                    // Create the request.
                    var merge = new MergeRequest();
                    // SubordinateId is the GUID of the account merging.
                    merge.SubordinateId          = _account2Id;
                    merge.Target                 = target;
                    merge.PerformParentingChecks = false;

                    Console.WriteLine("\nMerging account2 into account1 and adding " +
                                      "\"test\" as Address 1 Line 1");

                    // Create another account to hold new data to merge into the entity.
                    // If you use the subordinate account object, its data will be merged.
                    var updateContent = new Account();
                    updateContent.Address1_Line1 = "test";

                    // Set the content you want updated on the merged account
                    merge.UpdateContent = updateContent;

                    // Execute the request.
                    var merged = (MergeResponse)service.Execute(merge);

                    var mergeeAccount =
                        (Account)service.Retrieve(Account.EntityLogicalName,
                                                  _account2Id, new ColumnSet(allColumns: true));

                    if (mergeeAccount.Merged == true)
                    {
                        var mergedAccount =
                            (Account)service.Retrieve(Account.EntityLogicalName,
                                                      _account1Id, new ColumnSet(allColumns: true));

                        Console.WriteLine("\nAccounts merged successfully into account1");
                        Console.WriteLine("  Name: {0}", mergedAccount.Name);
                        Console.WriteLine("  Description: {0}", mergedAccount.Description);
                        Console.WriteLine("  Number of Employees: {0}",
                                          mergedAccount.NumberOfEmployees);
                        Console.WriteLine("  Address 1 Line 1: {0}",
                                          mergedAccount.Address1_Line1);
                    }
                    #endregion Demonstrate

                    #region Clean up
                    CleanUpSample(service);
                    #endregion Clean up
                }
                else
                {
                    const string UNABLE_TO_LOGIN_ERROR = "Unable to Login to Microsoft Dataverse";
                    if (service.LastCrmError.Equals(UNABLE_TO_LOGIN_ERROR))
                    {
                        Console.WriteLine("Check the connection string values in cds/App.config.");
                        throw new Exception(service.LastCrmError);
                    }
                    else
                    {
                        throw service.LastCrmException;
                    }
                }
            }
            catch (Exception ex)
            {
                SampleHelpers.HandleException(ex);
            }

            finally
            {
                if (service != null)
                {
                    service.Dispose();
                }

                Console.WriteLine("Press <Enter> to exit.");
                Console.ReadLine();
            }
        }
示例#2
0
 public void AbortBuild(MergeRequest mergeRequest, Build build = null)
 {
     gitLabWrapper.AbortBuild(mergeRequest, build);
 }
        /// <inheritdoc />
        public override async Task <IReadOnlyCollection <RevInfoTestMerge> > RemoveMergedTestMerges(
            IRepository repository,
            RepositorySettings repositorySettings,
            RevisionInformation revisionInformation,
            CancellationToken cancellationToken)
        {
            if (repository == null)
            {
                throw new ArgumentNullException(nameof(repository));
            }
            if (repositorySettings == null)
            {
                throw new ArgumentNullException(nameof(repositorySettings));
            }
            if (revisionInformation == null)
            {
                throw new ArgumentNullException(nameof(revisionInformation));
            }

            if (revisionInformation.ActiveTestMerges?.Any() != true)
            {
                Logger.LogTrace("No test merges to remove.");
                return(Array.Empty <RevInfoTestMerge>());
            }

            var client = repositorySettings.AccessToken != null
                                ? new GitLabClient(GitLabRemoteFeatures.GitLabUrl, repositorySettings.AccessToken)
                                : new GitLabClient(GitLabRemoteFeatures.GitLabUrl);

            var tasks = revisionInformation
                        .ActiveTestMerges
                        .Select(x => client
                                .MergeRequests
                                .GetAsync(
                                    $"{repository.RemoteRepositoryOwner}/{repository.RemoteRepositoryName}",
                                    x.TestMerge.Number)
                                .WithToken(cancellationToken));

            try
            {
                await Task.WhenAll(tasks).ConfigureAwait(false);
            }
            catch (Exception ex) when(!(ex is OperationCanceledException))
            {
                Logger.LogWarning(ex, "Merge requests update check failed!");
            }

            var newList = revisionInformation.ActiveTestMerges.ToList();

            MergeRequest lastMerged = null;

            async Task CheckRemoveMR(Task <MergeRequest> task)
            {
                var mergeRequest = await task.ConfigureAwait(false);

                if (mergeRequest.State != MergeRequestState.Merged)
                {
                    return;
                }

                // We don't just assume, actually check the repo contains the merge commit.
                if (await repository.ShaIsParent(mergeRequest.MergeCommitSha, cancellationToken).ConfigureAwait(false))
                {
                    if (lastMerged == null || lastMerged.ClosedAt < mergeRequest.ClosedAt)
                    {
                        lastMerged = mergeRequest;
                    }
                    newList.Remove(
                        newList.First(
                            potential => potential.TestMerge.Number == mergeRequest.Id));
                }
            }

            foreach (var prTask in tasks)
            {
                await CheckRemoveMR(prTask).ConfigureAwait(false);
            }

            return(newList);
        }
示例#4
0
 public async Task MergePullRequest(string repositoryName, string ownerName, MergeRequest mergeRequest)
 {
     var url     = EnterpriseApiUrls.PullRequestMerge(ownerName, repositoryName, mergeRequest.Id, mergeRequest.Version);
     var request = new BitbucketRestRequest(url, Method.POST);
     await RestClient.ExecuteTaskAsync(request);
 }
示例#5
0
 private static bool isServiceEvent(MergeRequest m)
 {
     return(m.Author.Username == Program.ServiceManager.GetServiceMessageUsername());
 }
        public void ShouldUpdateOnlyAndDeleteWhenFlaggedInRequest()
        {
            var helper = new MergeQueryObjectTestHelper();

            helper.DataService.DropTable();
            helper.DataService.CreateCompositeKeyTable();

            helper.DataService.Insert(new SampleCompositeKeyDto
            {
                Pk1          = 1,
                Pk2          = "A",
                TextValue    = "JJ",
                IntValue     = 100,
                DecimalValue = 100.99m
            });

            helper.DataService.Insert(new SampleCompositeKeyDto
            {
                Pk1          = 2,
                Pk2          = "B",
                TextValue    = "ZZ",
                IntValue     = 999,
                DecimalValue = 123.45m
            });

            helper.DataService.Insert(new SampleCompositeKeyDto
            {
                Pk1          = 3,
                Pk2          = "B",
                TextValue    = "AA",
                IntValue     = 1,
                DecimalValue = 1
            });


            var dtos = new[]
            {
                new SampleCompositeKeyDto
                {
                    Pk1          = 1,
                    Pk2          = "A",
                    TextValue    = "zz",
                    IntValue     = 999,
                    DecimalValue = 999m
                },
                new SampleCompositeKeyDto
                {
                    Pk1          = 4,
                    Pk2          = "C",
                    TextValue    = "CC",
                    IntValue     = 666,
                    DecimalValue = 666.66m
                }
            };

            var request = new MergeRequest <SampleCompositeKeyDto>
            {
                DataToMerge                     = dtos,
                TargetTableName                 = "dbo.Sample",
                UseRealTempTable                = false,
                PrimaryKeyExpression            = t => new object[] { t.Pk1, t.Pk2 },
                KeepPrimaryKeyInInsertStatement = true,
                WhenNotMatchedDeleteBehavior    = DeleteBehavior.Delete,
                OnMergeInsertActive             = false
            };

            helper.DataService.Merge(request);

            var sampleDtos = helper.DataService.GetAllSampleDtos <SampleCompositeKeyDto>().ToArray();

            sampleDtos.Length.Should().Be(1);

            var firstDto = sampleDtos.First(x => x.Pk1 == 1);

            firstDto.Pk2.Should().Be("A");
            firstDto.TextValue.Should().Be("zz");
            firstDto.IntValue.Should().Be(999);
            firstDto.DecimalValue.Should().Be(999);
        }
 public GitLabMergeRequest(MergeRequest mergeRequest)
 {
     this.mergeRequest = mergeRequest;
 }
        async internal static Task <bool> ApplyChangesToMergeRequest(GitLabInstance gitLabInstance,
                                                                     IModificationListener modificationListener,
                                                                     ProjectKey projectKey, MergeRequest originalMergeRequest, ApplyMergeRequestChangesParameters parameters,
                                                                     string oldSpecialNote, string newSpecialNote, User currentUser)
        {
            if (String.IsNullOrEmpty(parameters.Title) ||
                String.IsNullOrEmpty(parameters.TargetBranch) ||
                parameters.AssigneeUserName == null ||
                newSpecialNote == null ||
                currentUser == null)
            {
                // this is unexpected due to UI restrictions, so don't implement detailed logging here
                MessageBox.Show("Invalid parameters for a merge request", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Trace.TraceError("[MergeRequestEditHelper] Invalid parameters for a merge request");
                return(false);
            }

            string oldAssigneeUsername = originalMergeRequest.Assignee?.Username ?? String.Empty;
            User   assignee            = oldAssigneeUsername == parameters.AssigneeUserName
            ? originalMergeRequest.Assignee
            : await getUserAsync(gitLabInstance, parameters.AssigneeUserName);

            checkFoundAssignee(projectKey.HostName, parameters.AssigneeUserName, assignee);

            bool            result = false;
            MergeRequestKey mrk    = new MergeRequestKey(projectKey, originalMergeRequest.IId);

            if (oldSpecialNote != newSpecialNote)
            {
                result = await addComment(gitLabInstance, modificationListener, mrk, currentUser, newSpecialNote);
            }

            bool changed =
                oldAssigneeUsername != parameters.AssigneeUserName ||
                originalMergeRequest.Force_Remove_Source_Branch != parameters.DeleteSourceBranch ||
                originalMergeRequest.Squash != parameters.Squash ||
                originalMergeRequest.Target_Branch != parameters.TargetBranch ||
                originalMergeRequest.Title != parameters.Title ||
                originalMergeRequest.Description != parameters.Description;

            if (!changed)
            {
                return(result);
            }

            int assigneeId = assignee?.Id ?? 0; // 0 means to unassign
            UpdateMergeRequestParameters updateMergeRequestParameters = new UpdateMergeRequestParameters(
                parameters.TargetBranch, parameters.Title, assigneeId, parameters.Description,
                null, parameters.DeleteSourceBranch, parameters.Squash);

            try
            {
                MergeRequest mergeRequest = await Shortcuts
                                            .GetMergeRequestEditor(gitLabInstance, modificationListener, mrk)
                                            .ModifyMergeRequest(updateMergeRequestParameters);
            }
            catch (MergeRequestEditorException ex)
            {
                reportErrorToUser(ex);
                return(result);
            }
            return(true);
        }
示例#9
0
 public FullMergeRequestKey(ProjectKey projectKey, MergeRequest mergeRequest)
 {
     ProjectKey   = projectKey;
     MergeRequest = mergeRequest;
 }
示例#10
0
 public void Dispose()
 {
     this.gitHubService = null;
     this.expectedMergeRequestResponse = null;
 }
 public MergeRequestWithProject(MergeRequest mergeRequest, ProjectKey project)
 {
     MergeRequest = mergeRequest;
     Project      = project;
 }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connection"></param>
        /// <param name="entities"></param>
        /// <param name="dbFields"></param>
        /// <param name="tableName"></param>
        /// <param name="qualifiers"></param>
        /// <param name="batchSize"></param>
        /// <param name="fields"></param>
        /// <param name="hints"></param>
        /// <param name="transaction"></param>
        /// <param name="statementBuilder"></param>
        /// <param name="skipIdentityCheck"></param>
        /// <returns></returns>
        private static MergeAllExecutionContext <TEntity> CreateInternal <TEntity>(IDbConnection connection,
                                                                                   IEnumerable <TEntity> entities,
                                                                                   IEnumerable <DbField> dbFields,
                                                                                   string tableName,
                                                                                   IEnumerable <Field> qualifiers,
                                                                                   int batchSize,
                                                                                   IEnumerable <Field> fields,
                                                                                   string hints = null,
                                                                                   IDbTransaction transaction         = null,
                                                                                   IStatementBuilder statementBuilder = null,
                                                                                   bool skipIdentityCheck             = false)
            where TEntity : class
        {
            var dbSetting       = connection.GetDbSetting();
            var identity        = (Field)null;
            var inputFields     = (IEnumerable <DbField>)null;
            var identityDbField = dbFields?.FirstOrDefault(f => f.IsIdentity);

            // Check the fields
            if (fields?.Any() != true)
            {
                fields = dbFields?.AsFields();
            }

            // Check the qualifiers
            if (qualifiers?.Any() != true)
            {
                var primary = dbFields?.FirstOrDefault(dbField => dbField.IsPrimary == true);
                qualifiers = primary?.AsField().AsEnumerable();
            }

            // Set the identity value
            if (skipIdentityCheck == false)
            {
                identity = IdentityCache.Get <TEntity>()?.AsField();
                if (identity == null && identityDbField != null)
                {
                    identity = FieldCache.Get <TEntity>()?.FirstOrDefault(field =>
                                                                          string.Equals(field.Name.AsUnquoted(true, dbSetting), identityDbField.Name.AsUnquoted(true, dbSetting), StringComparison.OrdinalIgnoreCase));
                }
            }

            // Filter the actual properties for input fields
            inputFields = dbFields?
                          .Where(dbField =>
                                 fields.FirstOrDefault(field => string.Equals(field.Name.AsUnquoted(true, dbSetting), dbField.Name.AsUnquoted(true, dbSetting), StringComparison.OrdinalIgnoreCase)) != null)
                          .AsList();

            // Exclude the fields not on the actual entity
            if (typeof(TEntity).IsClassType() == false)
            {
                var entityFields = Field.Parse(entities?.FirstOrDefault());
                inputFields = inputFields?
                              .Where(field =>
                                     entityFields.FirstOrDefault(f => string.Equals(f.Name.AsUnquoted(true, dbSetting), field.Name.AsUnquoted(true, dbSetting), StringComparison.OrdinalIgnoreCase)) != null)
                              .AsList();
            }

            // Variables for the context
            var multipleEntitiesFunc = (Action <DbCommand, IList <TEntity> >)null;
            var singleEntityFunc     = (Action <DbCommand, TEntity>)null;
            var identitySetterFunc   = (Action <TEntity, object>)null;

            // Get if we have not skipped it
            if (skipIdentityCheck == false && identity != null && typeof(TEntity).IsClassType())
            {
                identitySetterFunc = FunctionCache.GetDataEntityPropertySetterCompiledFunction <TEntity>(identity);
            }

            // Identity which objects to set
            if (batchSize <= 1)
            {
                singleEntityFunc = FunctionCache.GetDataEntityDbParameterSetterCompiledFunction <TEntity>(
                    string.Concat(typeof(TEntity).FullName, StringConstant.Period, tableName, ".MergeAll"),
                    inputFields?.AsList(),
                    null,
                    dbSetting);
            }
            else
            {
                multipleEntitiesFunc = FunctionCache.GetDataEntityListDbParameterSetterCompiledFunction <TEntity>(
                    string.Concat(typeof(TEntity).FullName, StringConstant.Period, tableName, ".MergeAll"),
                    inputFields?.AsList(),
                    null,
                    batchSize,
                    dbSetting);
            }

            // Identify the requests
            var mergeAllRequest = (MergeAllRequest)null;
            var mergeRequest    = (MergeRequest)null;

            // Create a different kind of requests
            if (batchSize > 1)
            {
                mergeAllRequest = new MergeAllRequest(tableName,
                                                      connection,
                                                      transaction,
                                                      fields,
                                                      qualifiers,
                                                      batchSize,
                                                      hints,
                                                      statementBuilder);
            }
            else
            {
                mergeRequest = new MergeRequest(tableName,
                                                connection,
                                                transaction,
                                                fields,
                                                qualifiers,
                                                hints,
                                                statementBuilder);
            }

            // Return the value
            return(new MergeAllExecutionContext <TEntity>
            {
                CommandText = batchSize > 1 ? CommandTextCache.GetMergeAllText(mergeAllRequest) : CommandTextCache.GetMergeText(mergeRequest),
                InputFields = inputFields,
                BatchSize = batchSize,
                SingleDataEntityParametersSetterFunc = singleEntityFunc,
                MultipleDataEntitiesParametersSetterFunc = multipleEntitiesFunc,
                IdentityPropertySetterFunc = identitySetterFunc
            });
        }
        private void TestSplitAndMerge(string reservationOrderId)
        {
            HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                var reservationsClient = ReservationsTestUtilities.GetAzureReservationAPIClient(context, new RecordedDelegatingHandler {
                    StatusCodeToReturn = HttpStatusCode.OK
                });
                var reservations = reservationsClient.Reservation.List(reservationOrderId);
                var enumerator1  = reservations.GetEnumerator();
                ReservationResponse validReservation = null;
                while (enumerator1.MoveNext())
                {
                    var currentReservation = enumerator1.Current;
                    if (String.Equals(currentReservation.Properties.ProvisioningState, "Succeeded"))
                    {
                        validReservation = currentReservation;
                        break;
                    }
                }
                Assert.NotNull(validReservation);

                var reservationId = validReservation.Id.Split('/')[6];

                // Begin split test
                SplitRequest Split = new SplitRequest(
                    new List <int?>()
                {
                    1, 2
                },
                    CreateResourceId(reservationOrderId, reservationId)
                    );
                var splitResponse = reservationsClient.Reservation.Split(reservationOrderId, Split);
                Assert.NotNull(splitResponse);
                Assert.True(splitResponse.Any());

                var enumerator2 = splitResponse.GetEnumerator();
                ReservationResponse splitReservation1 = null;
                ReservationResponse splitReservation2 = null;
                while (enumerator2.MoveNext())
                {
                    var currentReservation = enumerator2.Current;
                    if (String.Equals(currentReservation.Properties.ProvisioningState, "Succeeded"))
                    {
                        if (splitReservation1 == null)
                        {
                            splitReservation1 = currentReservation;
                        }

                        else
                        {
                            splitReservation2 = currentReservation;
                        }
                    }
                }

                var splitReservationId1 = splitReservation1.Id.Split('/')[6];
                var splitReservationId2 = splitReservation2.Id.Split('/')[6];

                // Begin merge test
                MergeRequest Merge = new MergeRequest(
                    new List <string>()
                {
                    CreateResourceId(reservationOrderId, splitReservationId1),
                    CreateResourceId(reservationOrderId, splitReservationId2)
                }
                    );
                var mergeResponse = reservationsClient.Reservation.Merge(reservationOrderId, Merge);
                var enumerator3   = splitResponse.GetEnumerator();

                ReservationResponse mergedReservation = null;
                while (enumerator3.MoveNext())
                {
                    var currentReservation = enumerator3.Current;
                    if (String.Equals(currentReservation.Properties.ProvisioningState, "Succeeded"))
                    {
                        mergedReservation = currentReservation;
                    }
                }

                Assert.NotNull(mergedReservation);
                ValidateReservation(mergedReservation);
            }
        }
示例#14
0
 public IEnumerable <MergeRequestFileData> GetMergeRequestChanges(MergeRequest mergeRequest)
 {
     return(gitLabWrapper.GetMergeRequestChanges(mergeRequest));
 }
示例#15
0
        public void ShouldNotDeleteIfNotInTargetFilter()
        {
            var helper = new MergeQueryObjectTestHelper();

            helper.DataService.DropTable();
            helper.DataService.CreateCompositeKeyTable();

            helper.DataService.Insert(new SampleCompositeKeyDto
            {
                Pk1          = 3,
                Pk2          = "B",
                TextValue    = "AA",
                IntValue     = 1,
                DecimalValue = 1
            });

            var dtos = new[]
            {
                new SampleCompositeKeyDto
                {
                    Pk1          = 1,
                    Pk2          = "A",
                    TextValue    = "JJ",
                    IntValue     = 100,
                    DecimalValue = 100.99m
                },
                new SampleCompositeKeyDto
                {
                    Pk1          = 2,
                    Pk2          = "B",
                    TextValue    = "ZZ",
                    IntValue     = 999,
                    DecimalValue = 123.45m
                }
            };

            var request = new MergeRequest <SampleCompositeKeyDto>
            {
                DataToMerge                     = dtos,
                TargetTableName                 = "dbo.Sample",
                UseRealTempTable                = false,
                PrimaryKeyExpression            = t => new object[] { t.Pk1, t.Pk2 },
                KeepPrimaryKeyInInsertStatement = true,
                TargetDataSetFilter             = t => t.Pk1 >= 1 && t.Pk1 <= 2,
                WhenNotMatchedDeleteBehavior    = DeleteBehavior.Delete
            };

            helper.DataService.Merge(request);

            var sourceDtos = helper.DataService.GetAllSampleDtos <SampleCompositeKeyDto>().ToArray();

            sourceDtos.Length.Should().Be(3);

            var firstDto = sourceDtos.First(x => x.Pk1 == 1);

            firstDto.Pk2.Should().Be("A");
            firstDto.TextValue.Should().Be("JJ");
            firstDto.IntValue.Should().Be(100);
            firstDto.DecimalValue.Should().Be(100.99m);

            var secondDto = sourceDtos.First(x => x.Pk1 == 2);

            secondDto.Pk2.Should().Be("B");
            secondDto.TextValue.Should().Be("ZZ");
            secondDto.IntValue.Should().Be(999);
            secondDto.DecimalValue.Should().Be(123.45m);
        }
示例#16
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connection"></param>
        /// <param name="dbFields"></param>
        /// <param name="tableName"></param>
        /// <param name="qualifiers"></param>
        /// <param name="fields"></param>
        /// <param name="hints"></param>
        /// <param name="transaction"></param>
        /// <param name="statementBuilder"></param>
        /// <param name="skipIdentityCheck"></param>
        /// <returns></returns>
        private static MergeExecutionContext <TEntity> CreateInternal <TEntity>(IDbConnection connection,
                                                                                IEnumerable <DbField> dbFields,
                                                                                string tableName,
                                                                                IEnumerable <Field> qualifiers,
                                                                                IEnumerable <Field> fields,
                                                                                string hints = null,
                                                                                IDbTransaction transaction         = null,
                                                                                IStatementBuilder statementBuilder = null,
                                                                                bool skipIdentityCheck             = false)
            where TEntity : class
        {
            var dbSetting       = connection.GetDbSetting();
            var identity        = (Field)null;
            var inputFields     = new List <DbField>();
            var identityDbField = dbFields?.FirstOrDefault(f => f.IsIdentity);

            // Set the identity field
            if (skipIdentityCheck == false)
            {
                identity = IdentityCache.Get <TEntity>()?.AsField();
                if (identity == null && identityDbField != null)
                {
                    identity = FieldCache.Get <TEntity>().FirstOrDefault(field =>
                                                                         string.Equals(field.Name.AsUnquoted(true, dbSetting), identityDbField.Name.AsUnquoted(true, dbSetting), StringComparison.OrdinalIgnoreCase));
                }
            }

            // Filter the actual properties for input fields
            inputFields = dbFields?
                          .Where(dbField =>
                                 fields.FirstOrDefault(field => string.Equals(field.Name.AsUnquoted(true, dbSetting), dbField.Name.AsUnquoted(true, dbSetting), StringComparison.OrdinalIgnoreCase)) != null)
                          .AsList();

            // Variables for the entity action
            var identityPropertySetter = (Action <TEntity, object>)null;

            // Get the identity setter
            if (skipIdentityCheck == false && identity != null)
            {
                identityPropertySetter = FunctionCache.GetDataEntityPropertySetterCompiledFunction <TEntity>(identity);
            }

            // Identify the requests
            var mergeRequest = new MergeRequest(tableName,
                                                connection,
                                                transaction,
                                                fields,
                                                qualifiers,
                                                hints,
                                                statementBuilder);

            // Return the value
            return(new MergeExecutionContext <TEntity>
            {
                CommandText = CommandTextCache.GetMergeText(mergeRequest),
                InputFields = inputFields,
                ParametersSetterFunc = FunctionCache.GetDataEntityDbParameterSetterCompiledFunction <TEntity>(
                    string.Concat(typeof(TEntity).FullName, StringConstant.Period, tableName, ".Merge"),
                    inputFields?.AsList(),
                    null,
                    dbSetting),
                IdentityPropertySetterFunc = identityPropertySetter
            });
        }
示例#17
0
 public IEnumerable <Commit> GetCommits(MergeRequest mergeRequest)
 {
     return(gitLabWrapper.GetMergeRequestCommits(mergeRequest));
 }
示例#18
0
        private void ComboBoxFilteredMergeRequests_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }

            ComboBox     comboBox     = sender as ComboBox;
            MergeRequest mergeRequest = (MergeRequest)(comboBox.Items[e.Index]);

            e.DrawBackground();

            if ((e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit)
            {
                Color comboBoxEditBackColor = Color.FromArgb(225, 225, 225); // Gray shade similar to original one
                using (Brush brush = new SolidBrush(comboBoxEditBackColor))
                {
                    e.Graphics.FillRectangle(brush, e.Bounds);
                }

                e.Graphics.DrawString(mergeRequest.Title, comboBox.Font, SystemBrushes.ControlText, e.Bounds);
            }
            else
            {
                bool isSelected = (e.State & DrawItemState.Selected) == DrawItemState.Selected;
                if (isSelected)
                {
                    e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                }
                else
                {
                    System.Drawing.Color backColor = getMergeRequestColor(mergeRequest);
                    using (Brush brush = new SolidBrush(backColor))
                    {
                        e.Graphics.FillRectangle(brush, e.Bounds);
                    }
                }

                string labels     = String.Join(", ", mergeRequest.Labels.ToArray());
                string authorText = "Author: " + mergeRequest.Author.Name;
                Brush  textBrush  = isSelected ? SystemBrushes.HighlightText : SystemBrushes.ControlText;

                using (Font boldFont = new Font(comboBox.Font, FontStyle.Bold))
                {
                    // first row
                    e.Graphics.DrawString(mergeRequest.Title, boldFont, textBrush,
                                          new PointF(e.Bounds.X, e.Bounds.Y));

                    // second row
                    SizeF authorTextSize = e.Graphics.MeasureString(authorText, comboBox.Font);

                    e.Graphics.DrawString(authorText, comboBox.Font, textBrush,
                                          new PointF(e.Bounds.X, e.Bounds.Y + e.Bounds.Height / 2));

                    e.Graphics.DrawString(" [" + labels + "]", comboBox.Font, textBrush,
                                          new PointF(e.Bounds.X + authorTextSize.Width, e.Bounds.Y + e.Bounds.Height / 2));
                }
            }

            e.DrawFocusRectangle();
        }
示例#19
0
 public IEnumerable <Build> GetBuilds(MergeRequest mergeRequest, Sha1 sha)
 {
     return(gitLabWrapper.GetBuilds(mergeRequest, sha));
 }
示例#20
0
 private static bool isCurrentUserActivity(User currentUser, MergeRequest m)
 {
     return(m.Author.Id == currentUser.Id);
 }
示例#21
0
 public byte[] DownloadArtifacts(MergeRequest mergeRequest, Build build)
 {
     return(gitLabWrapper.DownloadArtifacts(mergeRequest, build));
 }
示例#22
0
 private bool AuthorizeAccess(MergeRequest mergeRequest)
 {
     return(mergeRequest.SubmitBy == LoginUser);
 }
示例#23
0
 public byte[] DownloadTrace(MergeRequest mergeRequest, Build build)
 {
     return(gitLabWrapper.DownloadTrace(mergeRequest, build));
 }
示例#24
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connection"></param>
        /// <param name="entities"></param>
        /// <param name="tableName"></param>
        /// <param name="qualifiers"></param>
        /// <param name="batchSize"></param>
        /// <param name="fields"></param>
        /// <param name="hints"></param>
        /// <param name="transaction"></param>
        /// <param name="statementBuilder"></param>
        /// <returns></returns>
        public static MergeAllExecutionContext <TEntity> Create <TEntity>(IDbConnection connection,
                                                                          IEnumerable <TEntity> entities,
                                                                          string tableName,
                                                                          IEnumerable <Field> qualifiers,
                                                                          int batchSize,
                                                                          IEnumerable <Field> fields,
                                                                          string hints = null,
                                                                          IDbTransaction transaction         = null,
                                                                          IStatementBuilder statementBuilder = null)
            where TEntity : class
        {
            var key = GetKey <TEntity>(tableName, qualifiers, fields, batchSize, hints);

            // Get from cache
            var context = MergeAllExecutionContextCache.Get <TEntity>(key);

            if (context != null)
            {
                return(context);
            }

            // Create
            var dbFields    = DbFieldCache.Get(connection, tableName, transaction);
            var commandText = (string)null;

            // Create a different kind of requests
            if (batchSize > 1)
            {
                var request = new MergeAllRequest(tableName,
                                                  connection,
                                                  transaction,
                                                  fields,
                                                  qualifiers,
                                                  batchSize,
                                                  hints,
                                                  statementBuilder);
                commandText = CommandTextCache.GetMergeAllText(request);
            }
            else
            {
                var request = new MergeRequest(tableName,
                                               connection,
                                               transaction,
                                               fields,
                                               qualifiers,
                                               hints,
                                               statementBuilder);
                commandText = CommandTextCache.GetMergeText(request);
            }

            // Call
            context = CreateInternal <TEntity>(connection,
                                               entities,
                                               dbFields,
                                               tableName,
                                               qualifiers,
                                               batchSize,
                                               fields,
                                               commandText);

            // Add to cache
            MergeAllExecutionContextCache.Add <TEntity>(key, context);

            // Return
            return(context);
        }
示例#25
0
 public void ForceBuild(MergeRequest mergeRequest, Build build = null)
 {
     gitLabWrapper.ForceBuild(mergeRequest, build);
 }
示例#26
0
文件: Merge.cs 项目: cesugden/Scripts
        /// <summary>
        /// This method shows how to merge two entity records with the Merge message.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptForDelete">When True, the user will be prompted to delete
        /// all created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig,bool promptForDelete)
        {
            using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
            {
                // This statement is required to enable early-bound type support.
                _serviceProxy.EnableProxyTypes();

                //Create the Contact and Incident required for this sample.
                CreateRequiredRecords();
 
                //<snippetMerge1>
                // Create the target for the request.
			    EntityReference target = new EntityReference();

			    // Id is the GUID of the account that is being merged into.
                // LogicalName is the type of the entity being merged to, as a string
			    target.Id = _account1Id;
                target.LogicalName = Account.EntityLogicalName;

                // Create the request.
                MergeRequest merge = new MergeRequest();
                // SubordinateId is the GUID of the account merging.
                merge.SubordinateId = _account2Id;
                merge.Target = target;
                merge.PerformParentingChecks = false;

                Console.WriteLine("\nMerging account2 into account1 and adding " +
                    "\"test\" as Address 1 Line 1");

                // Create another account to hold new data to merge into the entity.
                // If you use the subordinate account object, its data will be merged.
                Account updateContent = new Account();
                updateContent.Address1_Line1 = "test";

                // Set the content you want updated on the merged account
                merge.UpdateContent = updateContent;

                // Execute the request.
                MergeResponse merged = (MergeResponse)_serviceProxy.Execute(merge);
                //</snippetMerge1>

                Account mergeeAccount = 
                    (Account)_serviceProxy.Retrieve(Account.EntityLogicalName, 
                    _account2Id, new ColumnSet(allColumns:true));

                if(mergeeAccount.Merged == true)
                {
                    Account mergedAccount =
                        (Account)_serviceProxy.Retrieve(Account.EntityLogicalName,
                        _account1Id, new ColumnSet(allColumns: true));

                    Console.WriteLine("\nAccounts merged successfully into account1");
                    Console.WriteLine("  Name: {0}", mergedAccount.Name);
                    Console.WriteLine("  Description: {0}", mergedAccount.Description);
                    Console.WriteLine("  Number of Employees: {0}", 
                        mergedAccount.NumberOfEmployees);
                    Console.WriteLine("  Address 1 Line 1: {0}", 
                        mergedAccount.Address1_Line1);
                }

                DeleteRequiredRecords(promptForDelete);
            }
        }
示例#27
0
 private void updateStaticMergeRequestProperties(MergeRequest mergeRequest)
 {
     _author = mergeRequest.Author;
     _webUrl = mergeRequest.Web_Url;
 }