Пример #1
0
        public void TestVariantIdBounds()
        {
            int       count     = 5;
            VariantId variantId = new VariantId(count);

            // Add upto capacity
            for (int i = 0; i < count; ++i)
            {
                variantId.AddIdElement("element" + i);
            }

            Exception exceptionEncountered = null;

            try
            {
                variantId.AddIdElement("outofboundElement");
            }
            catch (Exception exp)
            {
                exceptionEncountered = exp;
            }

            Assert.IsTrue(
                exceptionEncountered != null && exceptionEncountered.GetType() == typeof(InvalidOperationException),
                "An exception is expected when we add elements beyond capacity");
        }
Пример #2
0
        public void TestVariantEquality()
        {
            // Self-Equality
            VariantId first = new VariantId(2);

            first.AddIdElement("one");
            first.AddIdElement("two");
            Assert.IsTrue(first.Equals(first));

            // Equality with a larger capacity variant
            VariantId larger = new VariantId(3);

            larger.AddIdElement("one");
            larger.AddIdElement("two");
            Assert.IsFalse(first.Equals(larger));

            // Equality with a similar size but underfilled
            VariantId third = new VariantId(2);

            third.AddIdElement("one");
            Assert.IsFalse(first.Equals(third));

            // Equality with similar ID
            third.AddIdElement("two");
            Assert.IsTrue(first.Equals(third));

            // Equality with same size and values but different order
            VariantId fourth = new VariantId(2);

            fourth.AddIdElement("two");
            fourth.AddIdElement("one");
            Assert.IsFalse(first.Equals(fourth));
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ChargeIntervalFrequency.GetHashCode();
         hashCode = (hashCode * 397) ^ CutoffDayOfMonth.GetHashCode();
         hashCode = (hashCode * 397) ^ CutoffDayOfWeek.GetHashCode();
         hashCode = (hashCode * 397) ^ ExpireAfterSpecificNumberOfCharges.GetHashCode();
         hashCode = (hashCode * 397) ^ (FulfillmentService != null ? FulfillmentService.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Grams.GetHashCode();
         hashCode = (hashCode * 397) ^ (LinePrice != null ? LinePrice.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ OrderDayOfMonth.GetHashCode();
         hashCode = (hashCode * 397) ^ OrderDayOfWeek.GetHashCode();
         hashCode = (hashCode * 397) ^ OrderIntervalFrequency.GetHashCode();
         hashCode = (hashCode * 397) ^ (OrderIntervalUnit != null ? OrderIntervalUnit.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ProductId.GetHashCode();
         hashCode = (hashCode * 397) ^ Quantity.GetHashCode();
         hashCode = (hashCode * 397) ^ RequiresShipping.GetHashCode();
         hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Taxable.GetHashCode();
         hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ VariantId.GetHashCode();
         hashCode = (hashCode * 397) ^ (VariantTitle != null ? VariantTitle.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Vendor != null ? Vendor.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #4
0
        public Com.DigitalAsset.Ledger.Api.V1.Variant ToProtoVariant()
        {
            var variant = new Com.DigitalAsset.Ledger.Api.V1.Variant {
                Constructor = Constructor, Value = Value.ToProto()
            };

            VariantId.IfPresent(identifier => variant.VariantId = identifier.ToProto());
            return(variant);
        }
Пример #5
0
        public AnnotationResources(string refSequencePath, string inputCachePrefix, List <string> saDirectoryPaths, List <SaUrls> customAnnotations,
                                   string customStrTsvPath, bool disableRecomposition, bool forceMitochondrialAnnotation, bool useLegacyVids, PerformanceMetrics metrics)
        {
            Metrics = metrics;
            PerformanceMetrics.ShowInitializationHeader();

            SequenceProvider = ProviderUtilities.GetSequenceProvider(refSequencePath);

            var annotationFiles = new AnnotationFiles();

            saDirectoryPaths?.ForEach(x => annotationFiles.AddFiles(x));
            customAnnotations?.ForEach(x => annotationFiles.AddFiles(x));

            ProteinConservationProvider = ProviderUtilities.GetProteinConservationProvider(annotationFiles);
            ProteinConservationProvider?.Load();

            metrics.Cache.Start();
            TranscriptAnnotationProvider = ProviderUtilities.GetTranscriptAnnotationProvider(inputCachePrefix, SequenceProvider, ProteinConservationProvider);
            metrics.ShowCacheLoad();

            SaProvider             = ProviderUtilities.GetNsaProvider(annotationFiles);
            ConservationProvider   = ProviderUtilities.GetConservationProvider(annotationFiles);
            LcrProvider            = ProviderUtilities.GetLcrProvider(annotationFiles);
            RefMinorProvider       = ProviderUtilities.GetRefMinorProvider(annotationFiles);
            GeneAnnotationProvider = ProviderUtilities.GetGeneAnnotationProvider(annotationFiles);

            IRepeatExpansionProvider repeatExpansionProvider = GetRepeatExpansionProvider(SequenceProvider.Assembly,
                                                                                          SequenceProvider.RefNameToChromosome, SequenceProvider.RefIndexToChromosome.Count, customStrTsvPath);

            MitoHeteroplasmyProvider = MitoHeteroplasmyReader.GetProvider();

            Annotator = new Annotator(TranscriptAnnotationProvider, SequenceProvider, SaProvider, ConservationProvider, LcrProvider, GeneAnnotationProvider,
                                      repeatExpansionProvider);

            if (useLegacyVids)
            {
                VidCreator = new LegacyVariantId(SequenceProvider.RefNameToChromosome);
            }
            else
            {
                VidCreator = new VariantId();
            }

            Recomposer = disableRecomposition
                ? new NullRecomposer()
                : Phantom.Recomposer.Recomposer.Create(SequenceProvider, TranscriptAnnotationProvider, VidCreator);
            DataSourceVersions = GetDataSourceVersions(TranscriptAnnotationProvider, SaProvider, GeneAnnotationProvider, ConservationProvider, LcrProvider, MitoHeteroplasmyProvider)
                                 .ToList();
            VepDataVersion = TranscriptAnnotationProvider.VepVersion + "." + CacheConstants.DataVersion + "." + SaCommon.DataVersion;

            ForceMitochondrialAnnotation = forceMitochondrialAnnotation;
        }
Пример #6
0
        internal WearableDebugProvider()
        {
            _virtualDevice = new Device
            {
                name      = _name,
                rssi      = _rssi,
                uid       = _uid,
                productId = _productId,
                variantId = _variantId
            };

            _name      = WearableConstants.DebugProviderDefaultDeviceName;
            _rssi      = WearableConstants.DebugProviderDefaultRSSI;
            _uid       = WearableConstants.DebugProviderDefaultUID;
            _productId = WearableConstants.DebugProviderDefaultProductId;
            _variantId = WearableConstants.DebugProviderDefaultVariantId;

            _verbose = true;

            _sensorStatus         = new Dictionary <SensorId, bool>();
            _sensorUpdateInterval = WearableConstants.DefaultUpdateInterval;

            _sensorStatus.Add(SensorId.Accelerometer, false);
            _sensorStatus.Add(SensorId.Gyroscope, false);
            _sensorStatus.Add(SensorId.Rotation, false);
            _sensorStatus.Add(SensorId.GameRotation, false);

            // All gestures start disabled.
            _gestureStatus = new Dictionary <GestureId, bool>();
            GestureId[] gestures = WearableConstants.GestureIds;
            for (int i = 0; i < gestures.Length; ++i)
            {
                if (gestures[i] != GestureId.None)
                {
                    _gestureStatus.Add(gestures[i], false);
                }
            }
        }
Пример #7
0
        private void SaveInventoryRows()
        {
            foreach (GridViewRow row in grdInventory.Rows)
            {
                HiddenField hdnVariantId         = (HiddenField)row.FindControl("VariantId");
                Literal     ltSize               = (Literal)row.FindControl("ltSize");
                Literal     ltColor              = (Literal)row.FindControl("ltColor");
                TextBox     txtInventory         = (TextBox)row.FindControl("txtInventory");
                TextBox     txtGTIN              = (TextBox)row.FindControl("txtGTIN");
                TextBox     txtWarehouseLocation = (TextBox)row.FindControl("txtWarehouseLocation");
                TextBox     txtVendorId          = (TextBox)row.FindControl("txtVendorId");
                TextBox     txtFullVendorSku     = (TextBox)row.FindControl("txtFullVendorSku");
                TextBox     txtWeightDelta       = (TextBox)row.FindControl("txtWeightDelta");

                int inventory = 0;
                int.TryParse(txtInventory.Text, out inventory);

                decimal weightDelta = decimal.Zero;
                decimal.TryParse(txtWeightDelta.Text, out weightDelta);

                string size              = AppLogic.CleanSizeColorOption(ltSize.Text);
                string color             = AppLogic.CleanSizeColorOption(ltColor.Text);
                string gtin              = txtGTIN.Text;
                string warehouseLocation = txtWarehouseLocation.Text;
                string fullSku           = txtFullVendorSku.Text;
                string vendorId          = txtVendorId.Text;

                if (DB.GetSqlN("select count(*) as N from Inventory where VariantID= @VariantId and lower([size]) = @Size and lower(color) = @Color", new SqlParameter[] { new SqlParameter("@VariantId", VariantId), new SqlParameter("@Size", size), new SqlParameter("@Color", color) }) == 0)
                {
                    DB.ExecuteSQL(@"insert into Inventory(InventoryGUID,VariantID,[Size],Color,Quan,WarehouseLocation,VendorFullSKU,VendorID,WeightDelta,GTIN) 
									values(@InventoryGUID,@VariantId,@Size,@Color,@Inventory,@WarehouseLocation,@FullSku,@VendorId,@WeightDelta,@GTIN)"                                    , new SqlParameter[] {
                        new SqlParameter("@InventoryGUID", DB.GetNewGUID()),
                        new SqlParameter("@VariantId", VariantId),
                        new SqlParameter("@Size", size),
                        new SqlParameter("@Color", color),
                        new SqlParameter("@Inventory", inventory),
                        new SqlParameter("@WarehouseLocation", warehouseLocation),
                        new SqlParameter("@FullSku", fullSku),
                        new SqlParameter("@VendorId", vendorId),
                        new SqlParameter("@WeightDelta", weightDelta),
                        new SqlParameter("@GTIN", gtin)
                    });
                }
                else
                {
                    DB.ExecuteSQL(@"update Inventory set 
									Quan = @Inventory,
									WarehouseLocation = @WarehouseLocation,
									VendorFullSKU = @FullSku,
									VendorID = @VendorId,
									WeightDelta = @WeightDelta,
									GTIN=@GTIN
									where VariantID = @VariantId and lower([size]) = @Size and lower(color) = @Color"                                    , new SqlParameter[] {
                        new SqlParameter("@InventoryGUID", DB.GetNewGUID()),
                        new SqlParameter("@VariantId", VariantId),
                        new SqlParameter("@Size", size),
                        new SqlParameter("@Color", color),
                        new SqlParameter("@Inventory", inventory),
                        new SqlParameter("@WarehouseLocation", warehouseLocation),
                        new SqlParameter("@FullSku", fullSku),
                        new SqlParameter("@VendorId", vendorId),
                        new SqlParameter("@WeightDelta", weightDelta),
                        new SqlParameter("@GTIN", gtin)
                    });
                }
                //aqsa arshad code block starts here
                #region Notify customer when Item is back in Stock

                int     c_SkinID = 3;
                int     minimumInventory = 5, InventoryID = 0;
                Decimal price                = 0;
                String  ImageFileNameOvrride = String.Empty;
                String  ImageName            = String.Empty;
                String  Sku = String.Empty;
                if (inventory >= minimumInventory)
                {
                    String ProductName = string.Empty;
                    using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                    {
                        dbconn.Open();
                        using (IDataReader rs = DB.GetRS("select InventoryID from Inventory where Color='" + color + "' and Size='" + size + "' and VariantID=" + VariantId, dbconn))
                        {
                            if (rs.Read())
                            {
                                InventoryID = DB.RSFieldInt(rs, "InventoryID");
                            }
                        }
                    }
                    int pID = CommonLogic.QueryStringNativeInt("ProductID");
                    //get the product name for redirection to that product.
                    using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                    {
                        dbconn.Open();
                        using (IDataReader rs = DB.GetRS("select Name from Product where ProductID=" + pID, dbconn))
                        {
                            if (rs.Read())
                            {
                                ProductName = DB.RSField(rs, "Name");
                            }
                        }
                    }
                    // get the price of product
                    using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                    {
                        dbconn.Open();
                        using (IDataReader rs = DB.GetRS("select price from ProductVariant where VariantID=" + VariantId, dbconn))
                        {
                            if (rs.Read())
                            {
                                price = DB.RSFieldDecimal(rs, "Price");
                            }
                        }
                    }
                    // get the image name
                    using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                    {
                        dbconn.Open();
                        using (IDataReader rs = DB.GetRS("select ImageFilenameOverride,SKU from Product where ProductID=" + pID, dbconn))
                        {
                            if (rs.Read())
                            {
                                ImageFileNameOvrride = DB.RSField(rs, "ImageFilenameOverride");
                                Sku = DB.RSField(rs, "SKU");
                            }
                        }
                    }
                    ImageName = AppLogic.LookupImage("Product", pID, ImageFileNameOvrride, Sku, "icon", c_SkinID, ThisCustomer.LocaleSetting);
                    using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                    {
                        dbconn.Open();
                        using (IDataReader rs = DB.GetRS("select Email from CustomerNotification where ProductID=" + pID + " and VarientID=" + VariantId + " and Issent=0 and InventoryID=" + InventoryID, dbconn))
                        {
                            while (rs.Read())
                            {
                                String EMail         = DB.RSField(rs, "Email");
                                String FromEMail     = AppLogic.AppConfig("OutOfStock.FromEmail");
                                String FromName      = AppLogic.AppConfig("OutOfStock.FromName");
                                String PackageName   = AppLogic.AppConfig("XmlPackage.OutOfStock");
                                var    currentURL    = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "/");
                                String ImageFullPath = String.Format(currentURL.ToString() + ImageName.Substring(1));
                                String pLink         = String.Format(currentURL.ToString() + "p-" + pID + "-" + ProductName.Replace("/", "") + ".aspx");
                                AppLogic.SendOutOfStockMail(AppLogic.AppConfig("StoreName") + " " + AppLogic.GetString("OutOfStock.aspx.6", c_SkinID, ThisCustomer.LocaleSetting), AppLogic.RunXmlPackage(PackageName, null, ThisCustomer, c_SkinID, string.Empty, "productID=" + pID.ToString() + "&VarientID=" + VariantId.ToString() + "&ProductName=" + ProductName.ToString() + "&price=" + String.Format("{0:C}", price) + "&productLink=" + pLink + "&ImagePath=" + ImageFullPath.ToString(), false, false), true, FromEMail, FromName, EMail, EMail, "", AppLogic.MailServer());
                                Boolean SendWasOk = true;
                                if (SendWasOk)
                                {
                                    DB.ExecuteSQL("update CustomerNotification set IsSent=1 where Email='" + EMail + "' and ProductID=" + pID + " and VarientID=" + VariantId + " and InventoryID=" + InventoryID);
                                }
                            }
                        }
                    }
                }
                #endregion
                //aqsa arshad code block ends here
            }
            ProductVariant       variant         = new ProductVariant(VariantId);
            List <InventoryItem> sizeColorCombos = GetSizeColorCombos(variant);
            LoadInventoryGridView(sizeColorCombos);
        }