Exemplo n.º 1
0
        GetQuery(
            StashClient <KeyDataWithList> stashClient,
            string partitionKey,
            string rowKey)
        {
            if (partitionKey.Is() && RowKey.Is())
            {
                return(stashClient.CreateQuery()
                       .Where(t => t.PartitionKey == partitionKey && t.RowKey == rowKey));
            }

            else if (partitionKey.Is())
            {
                return(stashClient.CreateQuery()
                       .Where(t => t.PartitionKey == partitionKey));
            }

            else if (rowKey.Is())
            {
                return(stashClient.CreateQuery()
                       .Where(t => t.RowKey == rowKey));
            }

            else
            {
                return(stashClient.CreateQuery());
            }
        }
Exemplo n.º 2
0
 public void IsValid()
 {
     if (!RowKey.StartsWith("Result_"))
     {
         throw new InvalidOperationException(String.Format("RowKey {0} doesn't start with 'Result_'", RowKey));
     }
 }
Exemplo n.º 3
0
        public static void PopulateEntity <TEntity>(TEntity entity, RowKey keyMap, byte[] key, ObjectAccessor accessor = null)
        {
            if (accessor == null)
            {
                accessor = ObjectAccessor.Create(entity);
            }

            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (keyMap.RowKeyKind == RowKeyKind.Simple)
            {
                accessor[keyMap.Components.First().Name] = key.GetString();
            }
            else
            {
                var splits = key.GetString().Split(keyMap.Separator.ToCharArray());
                if (keyMap.Components.Count != splits.Length)
                {
                    throw new Exception(
                              $"Inconsistent key, expected {keyMap.Components.Count} parts, got {splits.Length}");
                }

                Parallel.For(0, splits.Length, i =>
                {
                    var map            = keyMap.Components[i];
                    var data           = splits[i];
                    accessor[map.Name] = Convert.ChangeType(data, map.Type);
                });
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Sets the RowKey in the format (REVERSETICKS_AUTHOROID_TITLE).
 /// </summary>
 /// <param name="authorOID">The oid of the author (GUID of the user object), to be saved in RowKey.</param>
 /// <param name="title">The title to be saved in RowKey.</param>
 private void SetRowKey(string authorOID, string title)
 {
     RowKey = string.Format("{0}_{1}_{2}",
                            RowKey?.Substring(0, 19) ?? (DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks).ToString("d19"),
                            RowKey?.Substring(20, 36) ?? authorOID,
                            title);
 }
Exemplo n.º 5
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((RowKey != null ? RowKey.GetHashCode() : 0) * 397) ^ (PartitionKey != null ? PartitionKey.GetHashCode() : 0));
     }
 }
Exemplo n.º 6
0
        protected override int ExecuteCore(IRow row, int tableIndex)
        {
            if (tableIndex > 0)
            {
                return(NoError);
            }

            if (_filter == null)
            {
                InitFilter();
            }

            ISpatialFilter filter = Assert.NotNull(_filter, "_filter");

            var processed0 = new SegmentNeighbors(new SegmentPartComparer());

            IGeometry geom0 = ((IFeature)row).Shape;
            IEnvelope box0  = geom0.Envelope;

            box0.Expand(SearchDistance, SearchDistance, false);

            filter.Geometry = box0;

            var errorCount = 0;

            double    maxNear            = SearchDistance;
            const int neighborTableIndex = 1;

            IFeatureRowsDistance rowsDistance =
                NearDistanceProvider.GetRowsDistance(row, tableIndex);

            foreach (IRow neighborRow in
                     Search((ITable)_reference, filter, _helper, geom0))
            {
                var rowNeighbor = (IFeature)neighborRow;

                if (IgnoreNeighbor(row, neighborRow))
                {
                    continue;
                }

                SegmentNeighbors processed1;
                var neighborKey = new RowKey(rowNeighbor, neighborTableIndex);
                if (!ProcessedList.TryGetValue(neighborKey, out processed1))
                {
                    processed1 = new SegmentNeighbors(new SegmentPartComparer());
                    ProcessedList.Add(neighborKey, processed1);
                }

                NeighborhoodFinder finder =
                    GetNeighborhoodFinder(rowsDistance, (IFeature)row, tableIndex,
                                          rowNeighbor, neighborTableIndex);
                errorCount += FindNeighborhood(finder, tableIndex, processed0,
                                               neighborTableIndex, processed1,
                                               maxNear);
            }

            return(errorCount);
        }
Exemplo n.º 7
0
 private void ConfigureKeys()
 {
     if (string.IsNullOrWhiteSpace(RowKey))
     {
         throw new System.Exception($"User requires a name.");
     }
     PartitionKey = RowKey.Substring(0, 1).ToUpperInvariant();
 }
Exemplo n.º 8
0
 public override bool Equals(object?obj)
 {
     if (obj is WriteObject wo)
     {
         return(RowKey.SequenceEqual(wo.RowKey));
     }
     return(false);
 }
Exemplo n.º 9
0
 public string GetConversationId()
 {
     if (RowKey.Length < ConversationIdPrefix.Length)
     {
         throw new ArgumentException($"Invalid row key for conversation Id {RowKey}");
     }
     return(RowKey.Substring(ConversationIdPrefix.Length));
 }
Exemplo n.º 10
0
        public override void ReadEntity(IDictionary <string, EntityProperty> properties, OperationContext operationContext)
        {
            base.ReadEntity(properties, operationContext);
            var split = RowKey.Split(':');

            CategoryId = split[0];
            Locale     = split[1];
        }
Exemplo n.º 11
0
 public Model.Site.MonthIndex GetSiteEntity()
 {
     return(new Model.Site.MonthIndex
     {
         FirstPostId = this.FirstPostId,
         MonthsPosts = this.MonthsPosts,
         YearMonth = this.RowKey.Substring(0, 4) + "-" + RowKey.Substring(4, 2)
     });
 }
Exemplo n.º 12
0
            /// <summary>
            /// Qualifies a ColumnInfo with the crosstab name.  Ensures that the Identifier
            /// in the ColumnInfo will be unique in the new ResultSet, and prepends the
            /// crosstab name to the ColumnInfo caption.
            /// </summary>
            private static ColumnInfo QualifyColumnInfo(ColumnInfo columnInfo, RowKey rowKey)
            {
                List <String> parts   = new List <string>();
                String        caption = string.Empty;

                parts.Add("pivot"); // Not L10N

                foreach (var part in rowKey)
                {
                    String str = part == null ? "null" : part.ToString(); // Not L10N
                    parts.Add(str);
                    caption += str + " ";                                 // Not L10N
                }
                parts.AddRange(columnInfo.ReportColumn.Column.Parts);
                Identifier identifier = new Identifier(parts);

                // HACK: This is a hack to hide certain pivot columns which will never contain
                //       values in the case of label types and ratios.
                // TODO(nicksh): Something more general
                bool hidden = false;
                //const string nameTotalRatioTo = "TotalAreaRatioTo";
                //const string nameRatioTo = "AreaRatioTo";
                string colCap = columnInfo.Caption;

                // L10N: Caption is set to HeaderText in PreviewReportDlg
                if (Equals(colCap, Resources.Pivoter_QualifyColumnInfo_TotalAreaRatio) || Equals(colCap, Resources.Pivoter_QualifyColumnInfo_AreaRatio))
                {
                    // HACK: Unfortunately, the default internal standard label type
                    //       is needed in order to do this correctly.  The string "heavy"
                    //       should be the default 99% of the time, and if someone used
                    //       the string "heavy" for something else, and complained about
                    //       losing this column in this case, we could always tell them
                    //       change the name of the label type to something else.
                    hidden = RowKeyContains(rowKey, IsotopeLabelType.heavy.ToString());
                }
                // Hide RatioTo columns for the label type for which they are a ratio
                else if (colCap.StartsWith(Resources.Pivoter_QualifyColumnInfo_TotalAreaRatioTo)) // L10N: Caption is set to HeaderText in PreviewReportDlg
                {
                    hidden = RowKeyContains(rowKey, colCap.Substring(Resources.Pivoter_QualifyColumnInfo_TotalAreaRatioTo.Length));
                }
                else if (colCap.StartsWith(Resources.Pivoter_QualifyColumnInfo_AreaRatioTo))
                {
                    hidden = RowKeyContains(rowKey, colCap.Substring(Resources.Pivoter_QualifyColumnInfo_AreaRatioTo.Length));
                }

                return(new ColumnInfo
                {
                    Format = columnInfo.Format,
                    ReportColumn = new ReportColumn(columnInfo.ReportColumn.Table, identifier),
                    Caption = caption + columnInfo.Caption,
                    ColumnType = columnInfo.ColumnType,
                    IsHidden = hidden
                });
            }
    public override bool Equals(object obj)
    {
        if (!(obj is RowKey))
        {
            return(false);
        }

        RowKey other = obj as RowKey;

        return(Title.Equals(other.Title) && Id.Equals(other.Id));
    }
        public CloudEventLogPosition GetEnd()
        {
            // l-00000000-000000000000
            // 01234567890123456789012
            //           1111111112222

            var log            = RowKey.FromFixed(2, 8);
            var sequenceNumber = RowKey.FromFixed(11, 12);

            return(new CloudEventLogPosition(log, sequenceNumber + 1));
        }
Exemplo n.º 15
0
 public T Read <T>(PartitionKey partitionKey, RowKey rowKey) where T : TableEntity
 {
     try {
         Debug.WriteLine("Storage read start.");
         TableOperation readOperation = TableOperation.Retrieve <T>(partitionKey.Value, rowKey.Value);
         TableResult    tableResult   = table.Execute(readOperation);
         object         result        = tableResult.Result;
         Debug.WriteLine("Storage read complete.");
         return((T)result);
     } catch (StorageException sex) { Debug.WriteLine(sex.RequestInformation.ExtendedErrorInformation.ErrorMessage); }
     return(null);
 }
Exemplo n.º 16
0
 public override int GetHashCode()
 {
     unchecked
     {
         var res = (Id * 397) ^ (PropertyAsEncrypted != null ? PropertyAsEncrypted.GetHashCode() : 0);
         res = (res * 397) ^ (PlainProperty != null ? PlainProperty.GetHashCode() : 0);
         res = (res * 397) ^ (SecondPropertyAsEncrypted != null ? SecondPropertyAsEncrypted.GetHashCode() : 0);
         res = (res * 397) ^ (PartitionKey != null ? PartitionKey.GetHashCode() : 0);
         res = (res * 397) ^ (RowKey != null ? RowKey.GetHashCode() : 0);
         return(res);
     }
 }
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = PartitionKey?.GetHashCode() ?? 0;
                hashCode = (hashCode * 397) ^ (RowKey?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (Created?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ Modified.GetHashCode();
                hashCode = (hashCode * 397) ^ (Deleted?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (Data?.GetHashCode() ?? 0);

                return(hashCode);
            }
        }
Exemplo n.º 18
0
        public static string ExtractFromEntity <TEntity>(TEntity entity, RowKey key, ObjectAccessor accessor = null)
        {
            if (accessor == null)
            {
                accessor = ObjectAccessor.Create(entity);
            }

            var components = key.Components.Select(rowkeyComponent => key.IncludePropertyNameInSerialization
                    ? $"{rowkeyComponent.Name}-{accessor[rowkeyComponent.Name].ToString()}"
                    : accessor[rowkeyComponent.Name].ToString())
                             .ToList();

            return(string.Join(key.Separator, components));
        }
Exemplo n.º 19
0
        public ProductModel(string name, string description, string photourl, string companyid)
        {
            RowKey = Guid.NewGuid().ToString();

            ProductName = name;
            Description = description;
            PhotoUrl    = photourl;
            IsApproved  = false;
            CompanyID   = companyid;

            BrandName = string.Empty;

            PartitionKey = RowKey.Substring(0, 1);

            FeaturedProductWeight = 0;
        }
Exemplo n.º 20
0
 /// <summary>
 /// Compare to another RowKey.  Used for determining the order that crosstab columns
 /// are displayed in.
 /// </summary>
 public int CompareTo(RowKey that)
 {
     if (that.Count != Count)
     {
         return(0);
     }
     for (int i = 0; i < Count; i++)
     {
         int value = Compare(this[i], that[i]);
         if (value != 0)
         {
             return(value);
         }
     }
     return(0);
 }
Exemplo n.º 21
0
        public BuyerRequestModel(string companyID, string title, string category, string description, int quantity, DateTime dateExpire, string photoUrl)
        {
            DatePosted = DateTime.UtcNow;

            RowKey = Guid.NewGuid().ToString();

            CompanyID          = companyID;
            RequestTitle       = title;
            Category           = category;
            RequestDescription = description;
            Quantity           = quantity;
            DateExpire         = dateExpire;
            PhotoUrl           = photoUrl;

            PartitionKey = RowKey.Substring(0, 1);
        }
Exemplo n.º 22
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = PartitionKey?.GetHashCode() ?? 0;
                hashCode = (hashCode * 397) ^ (RowKey?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ Created.GetHashCode();
                hashCode = (hashCode * 397) ^ (EventType?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (OperationName?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (OrganizationId?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (SubscriptionId?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (Data?.GetHashCode() ?? 0);

                return(hashCode);
            }
        }
Exemplo n.º 23
0
        public Item ToItem()
        {
            var item = new Item
            {
                Payload = Payload
            };

            var ids = PartitionKey.Split('$');
            var productionTimeTicks = long.Parse(RowKey.Split('$')[0]);

            item.PrimaryId      = ids[0];
            item.SecondaryId    = ids[1];
            item.ProductionTime = new DateTimeOffset(productionTimeTicks, TimeSpan.Zero);

            return(item);
        }
Exemplo n.º 24
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (PartitionKey != null ? PartitionKey.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RowKey != null ? RowKey.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Timestamp.GetHashCode();
         hashCode = (hashCode * 397) ^ Cost.GetHashCode();
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Purchased.GetHashCode();
         hashCode = (hashCode * 397) ^ Count;
         hashCode = (hashCode * 397) ^ GlobalGuid.GetHashCode();
         hashCode = (hashCode * 397) ^ Awesomeness.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 25
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            if (RowKey.Equals(TABLE_VERSION_ROW))
            {
                sb.Append("VersionRow [").Append(DeploymentId);
                sb.Append(" Deployment=").Append(DeploymentId);
                sb.Append(" MembershipVersion=").Append(MembershipVersion);
                sb.Append("]");
            }
            else
            {
                sb.Append("OrleansSilo [");
                sb.Append(" Deployment=").Append(DeploymentId);
                sb.Append(" LocalEndpoint=").Append(Address);
                sb.Append(" LocalPort=").Append(Port);
                sb.Append(" Generation=").Append(Generation);

                sb.Append(" Host=").Append(HostName);
                sb.Append(" Status=").Append(Status);
                sb.Append(" ProxyPort=").Append(ProxyPort);
                sb.Append(" Primary=").Append(Primary);

                if (!string.IsNullOrEmpty(RoleName))
                {
                    sb.Append(" RoleName=").Append(RoleName);
                }
                sb.Append(" Instance=").Append(InstanceName);
                sb.Append(" UpgradeZone=").Append(UpdateZone);
                sb.Append(" FaultZone=").Append(FaultZone);

                if (!string.IsNullOrEmpty(SuspectingSilos))
                {
                    sb.Append(" SuspectingSilos=").Append(SuspectingSilos);
                }
                if (!string.IsNullOrEmpty(SuspectingTimes))
                {
                    sb.Append(" SuspectingTimes=").Append(SuspectingTimes);
                }
                sb.Append(" StartTime=").Append(StartTime);
                sb.Append(" IAmAliveTime=").Append(IAmAliveTime);
                sb.Append("]");
            }
            return(sb.ToString());
        }
Exemplo n.º 26
0
        private string GetKey(TItem item)
        {
            if (RowKey != null && RowKey.Equals(""))
            {
                throw new ArgumentException($"An empty {nameof(RowKey)} is not supported.");
            }

            if (RowKeyFunction != null)
            {
                return(RowKeyFunction(item));
            }
            if (!string.IsNullOrEmpty(RowKey))
            {
                return(item.GetType().GetProperty(RowKey)?.GetValue(item).ToString());
            }

            return(null);
        }
Exemplo n.º 27
0
        public void SaveRows()
        {
            if (Rows.Count > 0)
            {
                IniFile f = IniFile.FromFile(FileName);

                IOrderedEnumerable <Int32> r = Rows.Keys.OrderByDescending(x => x);
                string sRowIndex             = "";
                foreach (Int32 RowKey in r)
                {
                    sRowIndex = sRowIndex + RowKey.toString() + ";";
                    Rows.Save(f, RowKey);
                }
                sRowIndex          = sRowIndex.toBase64EncryptStr();
                f["A"]["RowIndex"] = sRowIndex;

                f.Save(FileName);
            }
        }
Exemplo n.º 28
0
        internal void ParseSiloAddressFromRowKey()
        {
            const string debugInfo = "ParseSiloAddressFromRowKey";

            try
            {
                var segments = RowKey.Split(SeparatorChars, 4);

                ClusterId  = segments[0];
                Address    = IPAddress.Parse(segments[1]);
                Port       = Int32.Parse(segments[2]);
                Generation = Int32.Parse(segments[3]);

                this.SiloAddress = SiloAddress.New(new IPEndPoint(Address, Port), Generation);
            }
            catch (Exception exc)
            {
                throw new FormatException("Error from " + debugInfo, exc);
            }
        }
Exemplo n.º 29
0
// ReSharper disable ParameterTypeCanBeEnumerable.Local
            private static bool RowKeyContains(RowKey rowKey, string keyPart)
// ReSharper restore ParameterTypeCanBeEnumerable.Local
            {
                string keyPartLower  = keyPart.ToLower();
                string keyPartSpaces = keyPartLower.Replace('_', ' ');  // Ugh. // Not L10N

                foreach (var part in rowKey)
                {
                    if (part == null)
                    {
                        continue;
                    }
                    string partLower = part.ToString().ToLower();
                    if (Equals(partLower, keyPartLower) || Equals(partLower, keyPartSpaces))
                    {
                        return(true);
                    }
                }
                return(false);
            }
Exemplo n.º 30
0
        public void SaveTable()
        {
            IniFile f = IniFile.FromFile(FileName);

            // Column Index, list of keys by delimited by semicolon
            IOrderedEnumerable <short> k = Columns.Keys.OrderByDescending(x => x);
            string sColIndex             = "";

            foreach (short key in k)
            {
                sColIndex = sColIndex + key.toString() + ";";
            }
            sColIndex             = sColIndex.toBase64EncryptStr();
            f["A"]["ColumnIndex"] = sColIndex;

            CColumn c;

            foreach (short key in k)
            {
                c = (CColumn)Columns[key];
                string sI = c.Key.toString();
                f["C" + sI]["Ca"] = c.Caption;
                f["C" + sI]["Na"] = c.Name;;
                f["C" + sI]["Ty"] = c.ColType.ToString();
            }

            if (Rows.Count > 0)
            {
                IOrderedEnumerable <Int32> r = Rows.Keys.OrderByDescending(x => x);
                string sRowIndex             = "";
                foreach (Int32 RowKey in r)
                {
                    sRowIndex = sRowIndex + RowKey.toString() + ";";
                    Rows.Save(f, RowKey);
                }
                sRowIndex          = sRowIndex.toBase64EncryptStr();
                f["A"]["RowIndex"] = sRowIndex;
            }

            f.Save(FileName);
        }