Exemplo n.º 1
0
 public void StoreProduct(FundamentalProduct product)
 {
     try
     {
         ExecuteNonQuery("[Montel].[Fundamental].[InsertOrUpdateProduct]", CommandType.StoredProcedure, CreateProductParameters(product));
     }
     catch (Exception ex)
     {
         var foo = ex;
         throw;
     }
 }
Exemplo n.º 2
0
        public List <FundamentalValue> GeneraterValueSeries(FundamentalProduct product)
        {
            var random     = new Random();
            var returnList = new List <FundamentalValue>();

            for (int i = 0; i < product.ExpectedElementsPerDay.Value; i++)
            {
                returnList.Add(GenerateValue(product.ProductCode, i, random));
            }

            return(returnList);
        }
Exemplo n.º 3
0
        private SqlParameter[] CreateProductParameters(FundamentalProduct product)
        {
            string sparseXml = "";

            //Creates sparse xml tags for all properties in the DetailSet that are not null.
            foreach (var property in product.DetailSet.GetType().GetProperties())
            {
                //This is a hack, a dirty dirty hack, but it works!
                //To clarify: Gets the value from an F# Option-type if it is passed. Reflection within a reflection, refleception!
                if (property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(FSharpOption <>))
                {
                    object optionObj = (property.GetValue(product.DetailSet));
                    Type   objType   = optionObj.GetType();
                    object value     = objType.GetProperty("Value").GetValue(optionObj);

                    sparseXml += ColConvert.ToSparseXmlTag(value, property.Name);
                }
                else
                {
                    sparseXml += ColConvert.ToSparseXmlTag(property.GetValue(product.DetailSet), property.Name);
                }
            }

            var parameters = new[] {
                new SqlParameter("@DataSource", product.DataSource),
                new SqlParameter("@SourceCode", FSharpOption <string> .get_IsSome(product.SourceCode) ? product.SourceCode.Value : null),
                new SqlParameter("@RequiredServiceID", FSharpOption <int> .get_IsSome(product.RequiredServiceID) ? product.RequiredServiceID.Value : (int?)null),
                new SqlParameter("@ProductCode", product.ProductCode),
                new SqlParameter("@ParentCode", FSharpOption <string> .get_IsSome(product.ParentCode) ? product.ParentCode.Value : null),
                new SqlParameter("@ProductDescription", product.ProductDescription),
                new SqlParameter("@ExpectedElementsPerDay", product.ExpectedElementsPerDay),
                new SqlParameter("@IsPublished", product.IsPublished),
                new SqlParameter("@RecTime", product.RecTime.DateTime),
                new SqlParameter("@MapData", FSharpOption <Geography> .get_IsSome(product.MapData) ? product.MapData.Value : null),
                new SqlParameter("@SQLTimeZoneName", FSharpOption <string> .get_IsSome(product.SQLTimeZoneName) ? product.SQLTimeZoneName.Value : null),

                //The following parameters are sparse.
                //Therefore they are represented as a XML string.
                new SqlParameter("@DetailSet", sparseXml)
            };

            return(parameters);
        }