Exemple #1
0
 private static System.Data.DataTable SetupTable()
 {
     System.Data.DataTable table = new System.Data.DataTable();
     foreach (string headerName in HomeEquityApplication.rowHeaderArray())
     {
         table.Columns.Add(headerName, typeof(string));
     }
     return(table);
 }
Exemple #2
0
        private static System.Data.DataTable QueryOnBase()
        {
            var extractCustomQueryName = System.Configuration.ConfigurationManager.AppSettings["extractCustomQueryName"];

            if (!Int32.TryParse(System.Configuration.ConfigurationManager.AppSettings["numberOfDaysExtracted"], out Int32 numberOfDaysExtracted))
            {
                Log.Logger.Warning("numberOfDaysExtracted in Config is invalid! Defaulting to 30 days!");
                numberOfDaysExtracted = 30;
            }

            if (!Int32.TryParse(System.Configuration.ConfigurationManager.AppSettings["maxQueryDocuments"], out Int32 maxQueryDocuments))
            {
                Log.Logger.Warning("maxQueryDocuments in Config is invalid! Defaulting to 10,000 documents!");
                maxQueryDocuments = 10000;
            }

            System.Data.DataTable table = SetupTable();

            using (Application obApp = OnBaseConnect())
            {
                DocumentQuery docQuery = obApp.Core.CreateDocumentQuery();

                CustomQuery extractCQ = obApp.Core.CustomQueries.Find(extractCustomQueryName);

                if (extractCQ != null)
                {
                    Log.Logger.Debug(String.Format("Custom Query Found: {0}", extractCustomQueryName));

                    docQuery.AddCustomQuery(extractCQ);
                    DateTime endTime   = DateTime.Now;
                    DateTime startTime = endTime.AddDays(-1 * numberOfDaysExtracted);
                    docQuery.AddDateRange(startTime, endTime);

                    DocumentList docList = docQuery.Execute(maxQueryDocuments);

                    foreach (Document doc in docList)
                    {
                        Log.Logger.Debug("Doc: {docId} - {docName}", doc.ID, doc.Name);

                        Form form = obApp.Core.GetDocumentByID(doc.ID).UnityForm;

                        if (form != null)
                        {
                            HomeEquityApplication heApplication = new HomeEquityApplication(doc, form);
                            table.Rows.Add(heApplication.RowDataArray());
                        }
                    }
                }
                else
                {
                    Log.Logger.Error("Custom Query NOT Found: {extractCustomQueryName}", extractCustomQueryName);
                }
            }

            return(table);
        }