Commits

Anonymous committed 534673e

new querybuilder serializer
bug fixes

Comments (0)

Files changed (9)

CmsData/CmsData.csproj

     <Compile Include="Classes\QuickBooks\QBDHelper.cs" />
     <Compile Include="Classes\QuickBooks\QBOHelper.cs" />
     <Compile Include="Picture.cs" />
+    <Compile Include="QueryBuilder\Serialize.cs" />
     <Compile Include="Volunteer.cs" />
     <Compile Include="FamilyExtra.cs" />
     <Compile Include="Generated\BackgroundCheck.cs" />

CmsData/QueryBuilder/Serialize.cs

+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+using System.Xml.Linq;
+using UtilityExtensions;
+using System.Linq;
+using CmsData;
+
+namespace CmsData
+{
+    public partial class QueryBuilderClause
+    {
+        public string Serialize()
+        {
+            XmlWriter w;
+            var settings = new XmlWriterSettings();
+            settings.Indent = true;
+            settings.Encoding = new UTF8Encoding(false);
+            var sb = new StringBuilder();
+            using (w = XmlWriter.Create(sb, settings))
+            {
+                w.WriteStartElement("Search");
+                w.WriteComment("{0}/{1}".Fmt(Util.ServerLink("/QueryBuilder/Main"), this.QueryId));
+                WriteClause(w, this);
+                w.WriteEndElement();
+            }
+            return sb.ToString();
+        }
+        public void Serialize(XmlWriter w)
+        { 
+            using (w)
+            {
+                w.WriteStartElement("Search");
+                WriteClause(w, this);
+                w.WriteEndElement();
+            }
+        }
+        private void WriteClause(XmlWriter w, QueryBuilderClause clause)
+        {
+            w.WriteStartElement("Condition");
+            w.WriteAttributeString("ClauseOrder", clause.ClauseOrder.ToString());
+            w.WriteAttributeString("Field", clause.Field);
+            if (clause.Description.HasValue())
+                w.WriteAttributeString("Description", clause.Description);
+            w.WriteAttributeString("Comparison", clause.Comparison);
+            if (clause.TextValue.HasValue())
+                w.WriteAttributeString("TextValue", clause.TextValue);
+            if (clause.DateValue.HasValue)
+                w.WriteAttributeString("DateValue", clause.DateValue.ToString());
+            if (clause.CodeIdValue.HasValue())
+                w.WriteAttributeString("CodeIdValue", clause.CodeIdValue);
+            if (clause.StartDate.HasValue)
+                w.WriteAttributeString("StartDate", clause.StartDate.ToString());
+            if (clause.EndDate.HasValue)
+                w.WriteAttributeString("EndDate", clause.EndDate.ToString());
+            if (clause.Program > 0)
+                w.WriteAttributeString("Program", clause.Program.ToString());
+            if (clause.Division > 0)
+                w.WriteAttributeString("Division", clause.Division.ToString());
+            if (clause.Organization > 0)
+                w.WriteAttributeString("Organization", clause.Organization.ToString());
+            if (clause.Days > 0)
+                w.WriteAttributeString("Days", clause.Days.ToString());
+            if (clause.Quarters.HasValue())
+                w.WriteAttributeString("Quarters", clause.Quarters);
+            if (clause.Tags.HasValue())
+                w.WriteAttributeString("Tags", clause.Tags);
+            if (clause.Schedule > 0)
+                w.WriteAttributeString("Schedule", clause.Schedule.ToString());
+            if (clause.Age.HasValue)
+                w.WriteAttributeString("Age", clause.Age.ToString());
+            foreach (var qc in clause.Clauses)
+                WriteClause(w, qc);
+            w.WriteEndElement();
+        }
+    }
+}

CmsWeb/Areas/Finance/Views/Contributions/Index.cshtml

     Layout = "/Views/Shared/SiteLayout.cshtml";
     CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
-        @<script src="/Scripts/js/Contributions.js"></script>);
+        @<script src="/Scripts/Finance/Contributions.js"></script>);
 }
 @section head
 {

CmsWeb/Areas/Main/Controllers/QueryBuilderController.cs

 using System.Text;
 using System.Threading;
 using System.Web.Mvc;
+using Elmah;
 using UtilityExtensions;
 using CmsWeb.Models;
 using CmsData;
                 return Content("Something went wrong<br><p>" + ex.Message + "</p>");
             }
             m.LoadScratchPad();
-
             var starttime = DateTime.Now;
-            m.PopulateResults();
+            try
+            {
+                m.PopulateResults();
+            }
+            catch (Exception ex)
+            {
+				var ex2 = new Exception("SearchBuilder error:\n" + m.Qb.Serialize(), ex);
+				ErrorLog errorLog = ErrorLog.GetDefault(null);
+				errorLog.Log(new Error(ex2));
+                return Content("Something went wrong<br><p>" + ex.Message + "</p>");
+            }
             DbUtil.LogActivity("QB Results ({0:N1}, {1})".Fmt(DateTime.Now.Subtract(starttime).TotalSeconds, m.QueryId));
             return View(m);
         }

CmsWeb/Areas/Main/Models/Other/QBExportResult.cs

             var settings = new XmlWriterSettings();
             settings.Encoding = new System.Text.UTF8Encoding(false);
             using (w = XmlWriter.Create(context.HttpContext.Response.OutputStream, settings))
-            {
-                w.WriteStartElement("Search");
-                WriteClause(clause);
-                w.WriteEndElement();
-            }
-        }
-        private void WriteClause(QueryBuilderClause clause)
-        {
-            w.WriteStartElement("Condition");
-            w.WriteAttributeString("ClauseOrder", clause.ClauseOrder.ToString());
-            w.WriteAttributeString("Field", clause.Field);
-            if (clause.Description.HasValue())
-                w.WriteAttributeString("Description", clause.Description);
-            w.WriteAttributeString("Comparison", clause.Comparison);
-            if (clause.TextValue.HasValue())
-                w.WriteAttributeString("TextValue", clause.TextValue);
-            if (clause.DateValue.HasValue)
-                w.WriteAttributeString("DateValue", clause.DateValue.ToString());
-            if (clause.CodeIdValue.HasValue())
-                w.WriteAttributeString("CodeIdValue", clause.CodeIdValue);
-            if (clause.StartDate.HasValue)
-                w.WriteAttributeString("StartDate", clause.StartDate.ToString());
-            if (clause.EndDate.HasValue)
-                w.WriteAttributeString("EndDate", clause.EndDate.ToString());
-            if (clause.Program > 0)
-                w.WriteAttributeString("Program", clause.Program.ToString());
-            if (clause.Division > 0)
-                w.WriteAttributeString("Division", clause.Division.ToString());
-            if (clause.Organization > 0)
-                w.WriteAttributeString("Organization", clause.Organization.ToString());
-            if (clause.Days > 0)
-                w.WriteAttributeString("Days", clause.Days.ToString());
-            if (clause.Quarters.HasValue())
-                w.WriteAttributeString("Quarters", clause.Quarters);
-            if (clause.Tags.HasValue())
-                w.WriteAttributeString("Tags", clause.Tags);
-            if (clause.Schedule > 0)
-                w.WriteAttributeString("Schedule", clause.Schedule.ToString());
-            if (clause.Age.HasValue)
-                w.WriteAttributeString("Age", clause.Age.ToString());
-            foreach (var qc in clause.Clauses)
-                WriteClause(qc);
-            w.WriteEndElement();
+                clause.Serialize(w);
         }
     }
 }

CmsWeb/Areas/Main/Models/Other/QueryModel.cs

     public class QueryModel : IQBUpdateable
     {
         private CMSDataContext Db;
-        private QueryBuilderClause Qb;
+        public QueryBuilderClause Qb;
         private int TagTypeId { get; set; }
         private string TagName { get; set; }
         private int? TagOwner { get; set; }

CmsWeb/Content/bvcms.css

  * Designed and built with all the love in the world @twitter by @mdo and @fat.
  */
 .clearfix {
-  *zoom: 1;
+  *zoom: 1; 
 }
 .clearfix:before,
 .clearfix:after {

CmsWeb/Controllers/HomeController.cs

             var q = HomeModel.Names(term).ToList();
             return Json(q, JsonRequestBehavior.AllowGet);
         }
+        public ActionResult TestRegs()
+        {
+            foreach (var o in DbUtil.Db.Organizations)
+            {
+                try
+                {
+                    var rs = new Settings(o.RegSetting, DbUtil.Db, o.OrganizationId);
+                }
+                catch (Exception ex)
+                {
+                    return Content("bad org <a href=\"{0}{1}\">{2}</a>\n{3}".Fmt(Util.ServerLink("/RegSetting/Index/"), o.OrganizationId, o.OrganizationName, ex.Message));
+                }
+            }
+            return Content("ok");
+        }
+
     }
 }
 

CmsWeb/Web.config

     </sectionGroup>
     <section name="cassette" type="Cassette.CassetteConfigurationSection, Cassette" />
   </configSections>
-  <cassette debug="true" cacheDirectory="cassette-cache" />
+  <cassette debug="false" cacheDirectory="cassette-cache" />
   <appSettings file="secrets.config">
     <add key="cmshost" value="http://localhost:888/" />
     <add key="sysfromemail" value="mailer@bvcms.com" />