Example #1
0
        private void Search_Click(object sender, EventArgs e)
        {
            Task task;

            DisableMatterSearchInput();
            DisableForms();
            DisableMatterSearchInput();

            MatterResults.Enabled = false;

            ProgressBarMatter.Show();

            task = new Task(() =>
            {
                Common.Net.Response <List <OpenLawOffice.Common.Models.Matters.Matter> > resp;

                resp = CommManager.ListMatters(Contact.Text.Trim(), Title.Text.Trim(),
                                               CaseNumber.Text.Trim(), Jurisdiction.Text.Trim(), true);

                if (Extensions.DynamicPropertyExists(resp.Package, "Error"))
                {
                    if (Globals.ThisAddIn.CanLog)
                    {
                        LogManager.GetCurrentClassLogger().Error("Error: " + resp.Error);
                    }
                    MessageBox.Show("Error: " + resp.Error, "Error");
                }
                else
                {
                    MatterResults.Invoke(new MethodInvoker(delegate
                    {
                        MatterResults.SelectedIndexChanged -= MatterResults_SelectedIndexChanged;
                        MatterResults.DataSource            = resp.Package;
                        MatterResults.DisplayMember         = "Title";
                        MatterResults.ValueMember           = "Id";
                        MatterResults.SelectedIndex         = -1;
                        MatterResults.SelectedIndexChanged += MatterResults_SelectedIndexChanged;

                        ProgressBarMatter.Hide();
                        MatterResults.Enabled = true;

                        EnableMatterSearchInput();
                        DisableForms();
                    }));
                }
            });

            task.Start();
        }
        void ThisAddIn_ActiveMatterChanged(object oldValue, object newValue)
        {
            if (newValue == null)
            {
                group1.Visible          = false;
                ActiveMatterTitle.Label = "";
                FormSelector.Items.Clear();
            }
            else
            {
                Common.Models.Matters.Matter matter = (Common.Models.Matters.Matter)newValue;
                Task task;

                group1.Visible          = true;
                ActiveMatterTitle.Label = matter.Title;

                task = new Task(() =>
                {
                    Common.Net.Response <List <Common.Models.Forms.Form> > resp;

                    resp = CommManager.ListFormsForMatter(matter.Id.Value);

                    if (Extensions.DynamicPropertyExists(resp.Package, "Error"))
                    {
                        if (Globals.ThisAddIn.CanLog)
                        {
                            LogManager.GetCurrentClassLogger().Error("Error: " + resp.Error);
                        }
                    }
                    else
                    {
                        resp.Package.ForEach(x =>
                        {
                            RibbonDropDownItem item = Factory.CreateRibbonDropDownItem();
                            item.Label = x.Title;
                            item.Tag   = x;
                            FormSelector.Items.Add(item);
                        });
                    }
                });

                task.Start();
            }
        }
Example #3
0
        public void DownloadFormDataForMatter(Guid id)
        {
            Task task;

            task = new Task(() =>
            {
                Common.Net.Response <List <Common.Models.Forms.FormFieldMatter> > resp;

                resp = CommManager.GetFormDataForMatter(id);

                if (Extensions.DynamicPropertyExists(resp.Package, "Error"))
                {
                    if (Globals.ThisAddIn.CanLog)
                    {
                        LogManager.GetCurrentClassLogger().Error("Error: " + resp.Error);
                    }
                    MessageBox.Show("Error: " + resp.Error, "Error");
                }
                else
                {
                    Microsoft.Office.Interop.Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;

                    resp.Package.ForEach(formFieldMatter =>
                    {
                        Microsoft.Office.Interop.Word.ContentControls contentControls;

                        contentControls = doc.SelectContentControlsByTitle(formFieldMatter.FormField.Title);

                        foreach (Microsoft.Office.Interop.Word.ContentControl cc in contentControls)
                        {
                            cc.Range.Text = formFieldMatter.Value;
                        }
                    });

                    //doc.SelectContentControlsByTitle("Case Number")[1].Range.Text = resp.Package.Single(x => x.FormField.Title == "Case Number").Value;
                }
            });

            task.Start();
        }
Example #4
0
        private void MatterResults_SelectedIndexChanged(object sender, EventArgs e)
        {
            Common.Models.Matters.Matter matter = (Common.Models.Matters.Matter)MatterResults.SelectedItem;
            Task task;

            ProgressBarForm.Show();

            Globals.ThisAddIn.ActiveMatter = matter;

            task = new Task(() =>
            {
                Common.Net.Response <List <Common.Models.Forms.Form> > resp;

                resp = CommManager.ListFormsForMatter(matter.Id.Value);

                if (Extensions.DynamicPropertyExists(resp.Package, "Error"))
                {
                    if (Globals.ThisAddIn.CanLog)
                    {
                        LogManager.GetCurrentClassLogger().Error("Error: " + resp.Error);
                    }
                    MessageBox.Show("Error: " + resp.Error, "Error");
                }
                else
                {
                    FormResults.Invoke(new MethodInvoker(delegate
                    {
                        FormResults.DataSource    = resp.Package;
                        FormResults.DisplayMember = "Title";
                        FormResults.ValueMember   = "Id";

                        ProgressBarForm.Hide();
                        FormResults.Enabled = true;
                        Select.Enabled      = true;
                    }));
                }
            });

            task.Start();
        }