Beispiel #1
0
        private static IEnumerable <SsqExcelFunction> LoadFunctions(SsqJson ssqJson)
        {
            IEnumerable <SsqExcelFunction> ssqExcelFunctions = SsqDelegate.GetSsqExcelFunctions(ssqJson);

            log.Debug("Loaded SSQ Excel functions.");

            return(ssqExcelFunctions);
        }
Beispiel #2
0
        private static SsqJson LoadSsqJson(string json)
        {
            SsqJson ssqJson = SsqJson.FromJson(json);

            log.Debug("Loaded SSQ JSON object.");

            return(ssqJson);
        }
Beispiel #3
0
 public static IEnumerable <KeyValuePair <string, UserDefinedFunction> > GetUserDefinedFunctions(SsqJson ssqJson)
 {
     return(ssqJson.UDF.Where(x => x.Value.QueryInformation.Enabled));
 }
Beispiel #4
0
        public static IEnumerable <SsqExcelFunction> GetSsqExcelFunctions(SsqJson ssqJson)
        {
            List <SsqExcelFunction> ssqExcelFunctions = null;

            try
            {
                ssqExcelFunctions = new List <SsqExcelFunction>();

                foreach (KeyValuePair <string, UserDefinedFunction> udf in GetUserDefinedFunctions(ssqJson))
                {
                    UserDefinedFunction userDefinedFunction = udf.Value;
                    QueryInformation    queryInformation    = userDefinedFunction.QueryInformation;
                    QueryParameter      queryParameter      = userDefinedFunction.QueryParameter;

                    Delegate excelFunction = new Func <string, object>(wkn_isin_ticker =>
                    {
                        object value;

                        try
                        {
                            Ssq ssq = new Ssq(queryParameter,
                                              udf.Key);

                            value = ssq.TryQ(wkn_isin_ticker);
                        }
                        catch (Exception ex)
                        {
                            log.Error(ex.Message);
                            return(ExcelError.ExcelErrorGettingData);
                        }

                        return(value);
                    });

                    ExcelFunctionAttribute excelFunctionAttribute = new ExcelFunctionAttribute
                    {
                        Name        = queryInformation.Name,
                        Description = queryInformation.Description + "\n" +
                                      "Author: " + queryInformation.Author + " (" + queryInformation.AuthorEmail + ")\n" +
                                      "Version " + queryInformation.Version + " of " + queryInformation.VersionDate + ", Provider: " + queryInformation.Provider,
                        Category     = "FFE",
                        IsThreadSafe = true,
                        HelpTopic    = !String.IsNullOrEmpty(queryInformation.HelpTopic) ? queryInformation.HelpTopic : null
                    };

                    ExcelArgumentAttribute excelArgumentAttribute = new ExcelArgumentAttribute {
                        Name = queryInformation.ExcelArgNameStockIdentifier, Description = queryInformation.ExcelArgDescStockIdentifier
                    };

                    ssqExcelFunctions.Add(new SsqExcelFunction(queryInformation.Name, excelFunction, excelFunctionAttribute, excelArgumentAttribute));

                    log.Debug("Created SSQ Excel function: {@SsqExcelFunction}", queryInformation.Name);
                }
            }
            catch (Exception ex)
            {
                log.Error("Exception while creating SSQ Excel functions. {@ExceptionMessage}", ex.Message);

                throw;
            }

            return(ssqExcelFunctions);
        }