Example #1
0
 public static object[,] GetResults([ExcelArgument(Description = "The name of the results object as returned by a call to another QuantSA function")] string objectName,
                                    [ExcelArgument(Description = "The name of the result required.  Use QSA.GetAvailableResults to get a list of all availabale results in this object.")] string resultName)
 {
     try
     {
         IProvidesResultStore resultStore = ObjectMap.Instance.GetObjectFromID <IProvidesResultStore>(objectName);
         if (resultStore == null)
         {
             throw new ArgumentException("The provided object is not a results object.");
         }
         if (resultStore.GetResultStore().IsDate(resultName))
         {
             Date[,] dates = resultStore.GetResultStore().GetDates(resultName);
             return(ExcelUtilities.ConvertToObjects(dates));
         }
         else if (resultStore.GetResultStore().IsString(resultName))
         {
             return(ExcelUtilities.ConvertToObjects(resultStore.GetResultStore().GetStrings(resultName)));
         }
         else
         {
             return(ExcelUtilities.ConvertToObjects(resultStore.GetResultStore().Get(resultName)));
         }
     }
     catch (Exception e)
     {
         return(ExcelUtilities.Error2D(e));
     }
 }
 /// <summary>
 /// Convert an erorr message to a 2d object array for return to Excel.
 /// </summary>
 /// <param name="e">The exception that has been thrown and needs to be displaced in the cell.</param>
 /// <returns></returns>
 public static object[,] Error2D(Exception e)
 {
     ExcelUtilities.SetLatestException(e);
     return(new object[, ] {
         { "ERROR: " + e.Message }
     });
 }
Example #3
0
 public static object LatestError()
 {
     try {
         if (ExcelUtilities.latestException == null)
         {
             ExcelMessage latestError = new ExcelMessage("No errors have occured.");
             latestError.ShowDialog();
         }
         else
         {
             ExcelMessage latestError = new ExcelMessage(ExcelUtilities.latestException);
             latestError.ShowDialog();
         }
         return("");
     }
     catch (Exception e)
     {
         return(ExcelUtilities.Error0D(e));
     }
 }
 /// <summary>
 /// Convert an erorr message to an object for return to Excel.
 /// </summary>
 /// <param name="e">The exception that has been thrown and needs to be displaced in the cell.</param>
 /// <returns></returns>
 public static object Error0D(Exception e)
 {
     ExcelUtilities.SetLatestException(e);
     return("ERROR: " + e.Message);
 }