/// <inheritdoc/>
        public override void Deserialize(FRReader reader)
        {
            base.Deserialize(reader);

            // compatibility with old reports: try to use last part of ReferenceName as a value for PropName
            if (!String.IsNullOrEmpty(ReferenceName) && ReferenceName.Contains("."))
            {
                string[] names = ReferenceName.Split(new char[] { '.' });
                PropName      = names[names.Length - 1];
                ReferenceName = "";
            }

            // gather all nested datasource names (PropName properties)
            List <string> dataSourceNames = new List <string>();

            foreach (Column column in Columns)
            {
                if (column is BusinessObjectDataSource)
                {
                    dataSourceNames.Add(column.PropName);
                }
            }

            // delete simple columns that have the same name as a datasource. In old version,
            // there was an invisible column used to support BO infrastructure
            for (int i = 0; i < Columns.Count; i++)
            {
                Column column = Columns[i];
                if (!(column is BusinessObjectDataSource) && dataSourceNames.Contains(column.PropName))
                {
                    column.Dispose();
                    i--;
                }
            }
        }
Пример #2
0
        private static void SetCategory(CbisSupplierManagementClient client, List <string> list)
        {
            if (list.Count != 3)
            {
                Console.WriteLine(
                    string.Format(
                        "Usage: {0} [username] [password] setcat [orgreference] [product reference] [categoryId]",
                        Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location)));
                return;
            }

            ReferenceName orgRef     = new ReferenceName(list[0]);
            ReferenceName prodRef    = new ReferenceName(list[1]);
            int           categoryId = int.Parse(list[2]);

            var product = client.GetProduct(orgRef, prodRef);

            client.SetProduct(
                orgRef,
                ((Client.InformationDataString)product.InformationData.First(x => x.AttributeId == 99)).Value,
                categoryId,
                prodRef,
                product.InformationData,
                product.Images, product.Occasions);
        }
Пример #3
0
        public override int GetHashCode()
        {
            var hashCode = Start.GetHashCode() ^ ReferenceName.GetHashCode();

            hashCode = (hashCode * 397) ^ End.GetHashCode();
            hashCode = (hashCode * 397) ^ Type.GetHashCode();

            return(hashCode);
        }
        private static void EnsureLocalBranchExistsForCurrentBranch(IGitRepository repo, ILog log, IRemote remote, string currentBranch)
        {
            if (log is null)
            {
                throw new ArgumentNullException(nameof(log));
            }

            if (remote is null)
            {
                throw new ArgumentNullException(nameof(remote));
            }

            if (string.IsNullOrEmpty(currentBranch))
            {
                return;
            }

            var isRef              = currentBranch.Contains("refs");
            var isBranch           = currentBranch.Contains("refs/heads");
            var localCanonicalName = !isRef
                ? "refs/heads/" + currentBranch
                : isBranch
                    ? currentBranch
                    : currentBranch.Replace("refs/", "refs/heads/");

            var repoTip = repo.Head.Tip;

            // We currently have the rep.Head of the *default* branch, now we need to look up the right one
            var originCanonicalName = $"{remote.Name}/{currentBranch}";
            var originBranch        = repo.Branches[originCanonicalName];

            if (originBranch != null)
            {
                repoTip = originBranch.Tip;
            }

            var repoTipId = repoTip.Id;

            var referenceName = ReferenceName.Parse(localCanonicalName);

            if (repo.Branches.All(b => !b.Name.Equals(referenceName)))
            {
                log.Info(isBranch ? $"Creating local branch {localCanonicalName}"
                    : $"Creating local branch {localCanonicalName} pointing at {repoTipId}");
                repo.Refs.Add(localCanonicalName, repoTipId.Sha);
            }
            else
            {
                log.Info(isBranch ? $"Updating local branch {localCanonicalName} to point at {repoTip}"
                    : $"Updating local branch {localCanonicalName} to match ref {currentBranch}");
                var localRef = repo.Refs[localCanonicalName];
                repo.Refs.UpdateTarget(localRef, repoTipId);
            }

            repo.Checkout(localCanonicalName);
        }
Пример #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ReferenceName != null ? ReferenceName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ReferenceProp != null ? ReferenceProp.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ReferenceEntity != null ? ReferenceEntity.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #6
0
    public void EnsureLocalBranchExistsForCurrentBranch(IRemote?remote, string?currentBranch)
    {
        remote.NotNull();

        if (currentBranch.IsNullOrEmpty())
        {
            return;
        }

        var isRef              = currentBranch.Contains("refs");
        var isBranch           = currentBranch.Contains("refs/heads");
        var localCanonicalName = !isRef
            ? "refs/heads/" + currentBranch
            : isBranch
                ? currentBranch
                : currentBranch.Replace("refs/", "refs/heads/");

        var repoTip = this.repository.Head.Tip;

        // We currently have the rep.Head of the *default* branch, now we need to look up the right one
        var originCanonicalName = $"{remote.Name}/{currentBranch}";
        var originBranch        = this.repository.Branches[originCanonicalName];

        if (originBranch != null)
        {
            repoTip = originBranch.Tip;
        }

        var repoTipId = repoTip?.Id;

        if (repoTipId != null)
        {
            var referenceName = ReferenceName.Parse(localCanonicalName);
            if (this.repository.Branches.All(b => !b.Name.Equals(referenceName)))
            {
                this.log.Info(isBranch
                    ? $"Creating local branch {referenceName}"
                    : $"Creating local branch {referenceName} pointing at {repoTipId}");
                this.repository.Refs.Add(localCanonicalName, repoTipId.Sha);
            }
            else
            {
                this.log.Info(isBranch
                    ? $"Updating local branch {referenceName} to point at {repoTipId}"
                    : $"Updating local branch {referenceName} to match ref {currentBranch}");
                var localRef = this.repository.Refs[localCanonicalName];
                if (localRef != null)
                {
                    this.retryAction.Execute(() => this.repository.Refs.UpdateTarget(localRef, repoTipId));
                }
            }
        }
        Checkout(localCanonicalName);
    }
Пример #7
0
        public override int GetHashCode()
        {
            var hashCode = Start.GetHashCode() ^ ReferenceName.GetHashCode();

            hashCode = (hashCode * 397) ^ End.GetHashCode();
            hashCode = (hashCode * 397) ^ VariantType.GetHashCode();
            hashCode = (hashCode * 397) ^ Source.GetHashCode();
            hashCode = (hashCode * 397) ^ AlternateAllele.GetHashCode();

            return(hashCode);
        }
Пример #8
0
        public override bool Equals(object other)
        {
            var otherItem = other as CustomInterval;

            if (otherItem == null)
            {
                return(false);
            }

            return(ReferenceName.Equals(otherItem.ReferenceName) &&
                   Start.Equals(otherItem.Start) &&
                   End.Equals(otherItem.End) &&
                   Type.Equals(otherItem.Type));
        }
Пример #9
0
        public override bool Equals(object other)
        {
            var otherItem = other as SupplementaryInterval;

            if (otherItem == null)
            {
                return(false);
            }

            return(ReferenceName.Equals(otherItem.ReferenceName) &&
                   Start.Equals(otherItem.Start) &&
                   End.Equals(otherItem.End) &&
                   VariantType.Equals(otherItem.VariantType) &&
                   (Source?.Equals(otherItem.Source) ?? otherItem.Source == null));
        }
Пример #10
0
    private void CreateOrUpdateLocalBranchesFromRemoteTrackingOnes(string remoteName)
    {
        var prefix = $"refs/remotes/{remoteName}/";
        var remoteHeadCanonicalName  = $"{prefix}HEAD";
        var headReferenceName        = ReferenceName.Parse(remoteHeadCanonicalName);
        var remoteTrackingReferences = this.repository.Refs
                                       .FromGlob(prefix + "*")
                                       .Where(r => !r.Name.Equals(headReferenceName));

        foreach (var remoteTrackingReference in remoteTrackingReferences)
        {
            var remoteTrackingReferenceName = remoteTrackingReference.Name.Canonical;
            var branchName         = remoteTrackingReferenceName.Substring(prefix.Length);
            var localReferenceName = ReferenceName.FromBranchName(branchName);

            // We do not want to touch our current branch
            if (this.repository.Head.Name.EquivalentTo(branchName))
            {
                continue;
            }

            var localRef = this.repository.Refs[localReferenceName];
            if (localRef != null)
            {
                if (localRef.TargetIdentifier == remoteTrackingReference.TargetIdentifier)
                {
                    this.log.Info($"Skipping update of '{remoteTrackingReference.Name.Canonical}' as it already matches the remote ref.");
                    continue;
                }
                var remoteRefTipId = remoteTrackingReference.ReferenceTargetId;
                if (remoteRefTipId != null)
                {
                    this.log.Info($"Updating local ref '{localRef.Name.Canonical}' to point at {remoteRefTipId}.");
                    this.retryAction.Execute(() => this.repository.Refs.UpdateTarget(localRef, remoteRefTipId));
                }
                continue;
            }

            this.log.Info($"Creating local branch from remote tracking '{remoteTrackingReference.Name.Canonical}'.");
            this.repository.Refs.Add(localReferenceName.Canonical, remoteTrackingReference.TargetIdentifier, true);

            var branch = this.repository.Branches[branchName];
            if (branch != null)
            {
                this.repository.Branches.UpdateTrackedBranch(branch, remoteTrackingReferenceName);
            }
        }
    }
        public void RemoveLastEntry()
        {
            Count--;
            ReferenceName.RemoveAt(Count);
            ReferencePosition.RemoveAt(Count);
            ChrIndexer.Remove(NumIndexer[Count]);
            NumIndexer.Remove(Count);
            Ad.RemoveAt(Count);
            Dp.RemoveAt(Count);

            if (Categories != null)
            {
                Categories.RemoveAt(Count);
                QScores.RemoveAt(Count);
                Gp.RemoveAt(Count);
            }
        }
Пример #12
0
        /// <summary>
        /// Creates a default <see cref="ConflictResolutionRule"/>.
        /// </summary>
        /// <param name="applicableScope">The scope as it applies to the <see cref="ConflictResolutionRule"/> being
        /// created.</param>
        /// <param name="description">The description of the <see cref="ConflictResolutionRule"/>.</param>
        /// <param name="actionData">The action data to be associated with the <see cref="ConflictResolutionRule"/>
        /// defined as a collection of key/value pairs.</param>
        /// <returns>
        /// A new, default <see cref="ConflictResolutionRule"/>.
        /// </returns>
        /// <remarks>Override this method in a derived class to provide a more specific conflict resolution rule
        /// implementation.</remarks>
        public virtual ConflictResolutionRule NewRule(string applicableScope, string description, Dictionary <string, string> actionData)
        {
            ConflictResolutionRule newRule = new ConflictResolutionRule();

            newRule.ActionReferenceName = ReferenceName.ToString();
            newRule.ApplicabilityScope  = applicableScope;
            newRule.RuleDescription     = description;
            newRule.RuleReferenceName   = Guid.NewGuid().ToString();
            newRule.DataField           = new DataField[actionData.Count];
            for (int i = 0; i < actionData.Count; ++i)
            {
                newRule.DataField[i]            = new DataField();
                newRule.DataField[i].FieldName  = actionData.ElementAt(i).Key;
                newRule.DataField[i].FieldValue = actionData.ElementAt(i).Value;
            }

            return(newRule);
        }
Пример #13
0
        private static void AddReference(CbisSupplierManagementClient client, List <string> list)
        {
            if (list.Count != 2)
            {
                Console.WriteLine(string.Format("Usage: {0} [username] [password] addref [subsystem:id (existing ref)] [subsystem:id (ref to add)]",
                                                Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location)));
                return;
            }

            ReferenceName target  = new ReferenceName(list[0]);
            ReferenceName newName = new ReferenceName(list[1]);

            client.ModifyProductReferences(
                null,
                target,
                new List <ReferenceName>()
            {
                newName
            },
                new List <ReferenceName>());
        }
        public void AddLocus(CalledAllele variant)
        {
            ReferenceName.Add(variant.Chromosome);
            ReferencePosition.Add(variant.ReferencePosition);
            ChrIndexer.Add(variant.Chromosome + ":" + variant.ReferencePosition.ToString(), Count);
            NumIndexer.Add(Count, variant.Chromosome + ":" + variant.ReferencePosition.ToString());
            int dp = variant.TotalCoverage;

            if (dp < AdaptiveGenotyperCalculator.MaxEffectiveDepth)
            {
                Dp.Add(dp);
                Ad.Add(VariantReader.GetAlternateAlleleSupport(variant));
            }
            else
            {
                var(ad, depth) = AdaptiveGenotyperCalculator.DownsampleVariant(
                    VariantReader.GetAlternateAlleleSupport(variant), dp);
                Dp.Add(depth);
                Ad.Add(ad);
            }
            Count++;
        }
Пример #15
0
        /// <summary>
        /// Resolve a list of references to a set of nodes
        /// </summary>
        /// <param name="Element">Element used to locate any errors</param>
        /// <param name="ReferenceNames">Sequence of names to look up</param>
        /// <returns>Set of all the nodes included by the given names</returns>
        HashSet <NodeOutput> ResolveInputReferences(ScriptElement Element, IEnumerable <string> ReferenceNames)
        {
            HashSet <NodeOutput> Inputs = new HashSet <NodeOutput>();

            foreach (string ReferenceName in ReferenceNames)
            {
                NodeOutput[] ReferenceInputs;
                if (Graph.TryResolveInputReference(ReferenceName, out ReferenceInputs))
                {
                    Inputs.UnionWith(ReferenceInputs);
                }
                else if (!ReferenceName.StartsWith("#") && Graph.NameToNodeOutput.ContainsKey(ReferenceName))
                {
                    LogError(Element, "Reference to '{0}' cannot be resolved; did you mean '#{0}'?", ReferenceName);
                }
                else
                {
                    LogError(Element, "Reference to '{0}' cannot be resolved; check it has been defined.", ReferenceName);
                }
            }
            return(Inputs);
        }
Пример #16
0
    public void CreateBranchForPullRequestBranch(AuthenticationInfo auth) => RepositoryExtensions.RunSafe(() =>
    {
        this.log.Info("Fetching remote refs to see if there is a pull request ref");

        // FIX ME: What to do when Tip is null?
        if (Head.Tip == null)
        {
            return;
        }

        var headTipSha    = Head.Tip.Sha;
        var remote        = RepositoryInstance.Network.Remotes.Single();
        var reference     = GetPullRequestReference(auth, remote, headTipSha);
        var canonicalName = reference.CanonicalName;
        var referenceName = ReferenceName.Parse(reference.CanonicalName);
        this.log.Info($"Found remote tip '{canonicalName}' pointing at the commit '{headTipSha}'.");

        if (referenceName.IsTag)
        {
            this.log.Info($"Checking out tag '{canonicalName}'");
            Checkout(reference.Target.Sha);
        }
        else if (referenceName.IsPullRequest)
        {
            var fakeBranchName = canonicalName.Replace("refs/pull/", "refs/heads/pull/").Replace("refs/pull-requests/", "refs/heads/pull-requests/");

            this.log.Info($"Creating fake local branch '{fakeBranchName}'.");
            Refs.Add(fakeBranchName, headTipSha);

            this.log.Info($"Checking local branch '{fakeBranchName}' out.");
            Checkout(fakeBranchName);
        }
        else
        {
            var message = $"Remote tip '{canonicalName}' from remote '{remote.Url}' doesn't look like a valid pull request.";
            throw new WarningException(message);
        }
    });
Пример #17
0
        Uri CreateRequestUri()
        {
            var sb = new StringBuilder();

            //language
            sb.Append("/");
            sb.Append(LanguageCode);

            //request type
            sb.Append("/list");

            //reference type
            sb.Append("/");
            sb.Append(ReferenceName.ToLowerInvariant());

            //skip
            sb.Append("?skip=");
            sb.Append(string.Format("{0}", Skip));

            //take
            sb.Append("&take=");
            sb.Append(string.Format("{0}", Take));

            //content link depth
            sb.Append("&contentLinkDepth=");
            sb.Append(string.Format("{0}", ContentLinkDepth));

            //filter
            if (!string.IsNullOrWhiteSpace(EncodedFilter))
            {
                sb.Append("&filter=");
                sb.Append(EncodedFilter);
            }

            return(new Uri(CreateRequestBaseUri(), sb.ToString()));;
        }
Пример #18
0
        public int CompareTo(object obj)
        {
            var otherField = obj as TfsField;

            return(ReferenceName.CompareTo(otherField.ReferenceName));
        }
Пример #19
0
 internal override void AppendTo(SqlStringBuilder builder)
 {
     ReferenceName.AppendTo(builder);
 }
Пример #20
0
        /// <summary>
        /// Set value for this field.
        /// </summary>
        private void SetValue(string value, FieldValueType fieldValueType)
        {
            if (_range == null)
            {
                return;
            }

            switch (fieldValueType)
            {
            // Set converted value, add hyperlink to range
            case FieldValueType.PlainText:
            {
                _range.Text = (_converter == null) ? value : _converter.Convert(value, Direction.TfsToOther);
                if (!string.IsNullOrEmpty(Hyperlink))
                {
                    _range.Hyperlinks.Add(_range, Hyperlink);
                }

                break;
            }

            case FieldValueType.BasedOnFieldType:
            {
                if (ReferenceName.Equals(FieldReferenceNames.TestSteps))
                {
                    if (string.IsNullOrEmpty(value) == false)
                    {
                        var template =
                            _range.Application.ListGalleries[WdListGalleryType.wdNumberGallery].ListTemplates[1];
                        if (template != null)
                        {
                            _range.ListFormat.ApplyListTemplate(template, false);
                        }
                    }

                    _range.Text = value;
                }
                break;
            }

            case FieldValueType.DropDownList:
            {
                var contentControlsCache = _range.ContentControls;

                if (contentControlsCache.Count != 1)
                {
                    SyncServiceTrace.E("DropDownList value should be set but the field contains not exactly one FormField.");
                    return;
                }

                var dropDown        = contentControlsCache[1];
                var dropDownEntries = dropDown.DropdownListEntries.Cast <ContentControlListEntry>();

                // if we previously assigned allowed values, check the cache. If not read existing values from dropdown list
                var matchingEntry = dropDownEntries.FirstOrDefault(x => x.Value == value);
                if (matchingEntry == null)
                {
                    SyncServiceTrace.E("DropDownList value should be set but the value is not in the lists of possible values.");
                    return;
                }

                matchingEntry.Select();
                break;
            }

            case FieldValueType.HTML:
            {
                if (string.IsNullOrEmpty(value))
                {
                    // if the value is empty then do not use clipboard
                    _range.Text = value;
                }
                else
                {
                    // Fix for 15925. Editing html fields using vs or browser will not always surround text in tags.
                    // Word appears to only parse strings like "A&amp;B" correctly when they are surrounded with tags.
                    if (!(value.StartsWith("<", StringComparison.Ordinal) && value.EndsWith(">", StringComparison.Ordinal)))
                    {
                        value = $"<span>{value}</span>";
                        SyncServiceTrace.W("Automatically surrounded text with span tags");
                    }

                    value = HtmlHelper.AddMissingImageSizeAttributes(value);
                    // value = HtmlHelper.ShrinkImagesAllSamePercentage(value, 0.8f);

                    // Get the range to work with
                    Range range;
                    if (!string.IsNullOrEmpty(Configuration.WordBookmark))
                    {
                        // Set the Bookmarks
                        // If the Text of the range is empty, add some non blank space to help word with its Bookmarks
                        if (string.IsNullOrWhiteSpace(_range.Text))
                        {
                            _range.Text = "&nbsp;";
                        }

                        _range.Bookmarks.Add(Configuration.WordBookmark);
                        range = _range.Bookmarks[Configuration.WordBookmark].Range;
                    }
                    else
                    {
                        range = _range;
                    }

                    // Get the start of actual range to select whole pasted 'thing'
                    var startRange = range.Start;

                    try
                    {
                        WordHelper.PasteSpecial(range, value);
                    }
                    catch (COMException ce)
                    {
                        if (ce.ErrorCode == WordHelper.CommandFailedCode)
                        {
                            _range.Text = string.Empty;
                            SyncServiceTrace.I("HTML-content \"{0}\" was effectively empty and therefore it has been replaced by an empty string.", value);
                        }
                        else
                        {
                            throw;
                        }
                    }

                    // Set the start back to the previous position to set the pasted 'thing' into this range
                    range.Start = startRange;
                    var parser = new PasteStreamParser();
                    parser.ParseAndRepairAfterPaste(value, range);
                }
                break;
            }
            }

            RefreshBookmarks();
        }
 protected override void AppendTo(SqlStringBuilder builder)
 {
     ReferenceName.AppendTo(builder);
     builder.Append(" = ");
     Value.AppendTo(builder);
 }