Example #1
0
 private Name CheckInsertPO(JustWareApiClient apiClient, XElement caseXml)
 {
     XElement poXml = caseXml.Descendants("PoliceOfficer").First();
     if (poXml != null)
     {
         Name poName = new Name();
         XElement poNameXml = poXml.Descendants("Name").First();
         var nameValues = GetChildValues(poNameXml);
         string query = String.Format("Last = \"{0}\" AND First = \"{1}\"", nameValues["Last"], nameValues["First"]);
         List<Name> poNames = apiClient.FindNames(query, null);
         if (poNames.Count > 0)
         {
             poName = poNames.First();
         }
         else
         {
             poName = CreateName(nameValues);
             List<Key> returnedKeys = apiClient.Submit(poName);
             poName.ID = returnedKeys.First(k => k.TypeName == "Name").NewID;
         }
         return poName;
     }
     return null;
 }
Example #2
0
        private Name InsertDefendent(JustWareApiClient apiClient, XElement defXml)
        {
            XElement defNameXml = defXml.Descendants("Name").First();
            var nameValues = GetChildValues(defNameXml);
            Name defendant = CreateName(nameValues);
            defendant = AddAddressIfExists(defXml, defendant);
            defendant = AddPhoneIfExists(defXml, defendant);

            List<Key> returnedKeys = apiClient.Submit(defendant);
            defendant.ID = returnedKeys.First(k => k.TypeName == "Name").NewID;

            return defendant;
        }
Example #3
0
        private void InsertDataFromXml()
        {
            JustWareApiClient apiClient = new JustWareApiClient();
            apiClient.ClientCredentials.UserName.UserName = "USERNAME";
            apiClient.ClientCredentials.UserName.Password = "PASSWORD";

            XDocument doc = XDocument.Load("CaseImport.xml");
            List<XElement> cases = doc.Descendants("Case").ToList();
            foreach (var singleCase in cases)
            {
                XElement defXml = cases.Descendants("Defendant").First();
                Name defendant = InsertDefendent(apiClient, defXml);
                Name policeOfficer = CheckInsertPO(apiClient, singleCase);

                Case c = InsertCase(apiClient, singleCase, defendant, policeOfficer);

            }
        }
Example #4
0
        private Case InsertCase(JustWareApiClient apiClient, XElement caseXml, Name defendant, Name policeOfficer)
        {
            Case c = new Case();
            c.Operation = OperationType.Insert;
            c.TypeCode = "F";
            c.StatusCode = "ACTIV";
            c.AgencyAddedByCode = "NDT";
            c.StatusDate = DateTime.Now;
            c.ReceivedDate = DateTime.Now;

            CaseInvolvedName def = CreateInvolvedName("DEF", defendant.ID);
            CaseInvolvedName po = CreateInvolvedName("PO", policeOfficer.ID);
            c.CaseInvolvedNames = new List<CaseInvolvedName>() {def, po};

            var chargeElements = caseXml.Descendants("Charge");
            foreach (var chargeElement in chargeElements)
            {
                Charge charge = CreateNewCharge(apiClient, chargeElement);
                if (charge == null) continue;
                if (c.Charges == null)
                {
                    c.Charges = new List<Charge>();
                }
                c.Charges.Add(charge);
            }

            List<Key> returnedKeys = apiClient.Submit(c);
            string newCaseID = returnedKeys.First(k => k.TypeName == "Case").NewCaseID;

            Case finishedCase = apiClient.GetCase(newCaseID, null);
            return finishedCase;
        }
Example #5
0
        private Charge CreateNewCharge(JustWareApiClient api, XElement chargeXml)
        {
            var chargeValues = GetChildValues(chargeXml);
            Charge charge = new Charge();
            charge.Operation = OperationType.Insert;
            string query = String.Format("Code = \"{0}\"", chargeValues["Code"]);
            Statute statute = api.FindStatutes(query, null).FirstOrDefault();
            if (statute != null)
            {
                charge.StatuteID = statute.ID;
            }
            else
            {
                MessageBox.Show("Statue with code " + chargeValues["Code"] + " not found");
                return null;
            }
            charge.ChargeNumber = short.Parse(chargeValues["ChargeNumber"]);
            charge.Date = DateTime.Parse(chargeValues["Occurred"]);
            charge.Notes = chargeValues["OfficerNotes"];

            return charge;
        }
 public APICommunicator()
 {
     _apiClient = new JustWareApiClient();
     _apiClient.ClientCredentials.UserName.UserName = "NDT\\apiuser";
     _apiClient.ClientCredentials.UserName.Password = "NewDawn2012";
 }