public void AddWorkflowItem(string documentWorkflowItemID, string CertificateID, string companyName, string companyID, string clientID, bool?active, bool?compliant, DateTime?issueDate, DateTime?nextExpirationDate, string workflowAnalyst, string workflowAnalystID, string companyAnalyst, string companyAnalystID, DateTime?emailDate, string emailFromAddress, string subjectLine, string emailBody, string status, string certusFileID, string fileName, string fileURL, string fileSize, string fileMime, bool?fileExtracted)
        {
            WorkflowItem wi = new WorkflowItem
                              (
                documentWorkflowItemID,
                CertificateID,
                companyName,
                companyID,
                clientID,
                active,
                compliant,
                issueDate,
                nextExpirationDate,
                workflowAnalyst,
                workflowAnalystID,
                companyAnalyst,
                companyAnalystID,
                emailDate,
                emailFromAddress,
                subjectLine,
                emailBody,
                status,
                certusFileID,
                fileName,
                fileURL,
                fileSize,
                fileMime,
                fileExtracted
                              );

            workflowItemDatabase.Add(wi);
        }
        //
        // methods
        public void AddWorkflowItem(WorkflowItem itemToAdd, bool updateDuplicates)
        {
            this.itemBeingAdded       = itemToAdd;
            this.updateDuplicateItems = updateDuplicates;

            // if the item exists in the database
            if (this.workflowItemDatabase.Exists(i => i.DocumentWorkflowItemID == itemBeingAdded.DocumentWorkflowItemID))
            {
                WorkflowItem existingItem = new WorkflowItem();
                var          item         = (this.workflowItemDatabase.First(i => i.DocumentWorkflowItemID == itemBeingAdded.DocumentWorkflowItemID));
                existingItem = item as WorkflowItem;

                // if user wants to add and update (if check box is not checked, item will not be added if there is one existing with the same id)
                if (updateDuplicateItems)
                {
                    // if the new item was updated
                    if (CheckIfItemWasUpdated(existingItem, itemBeingAdded))
                    {
                        // replace new with old
                        this.workflowItemDatabase[this.workflowItemDatabase.IndexOf(existingItem)] = itemBeingAdded;
                        return;
                    }
                }
            }
            else // item doesn't exist in the list so add it
            {
                workflowItemDatabase.Add(itemBeingAdded);
            }
        }
Exemple #3
0
        private WorkflowItem GetWorkflowItemFromCurrentViewByID(string id)
        {
            // query the list for id
            WorkflowItem result = this.workflowItemsLoaded.Find(o => o.DocumentWorkflowItemID == id);

            return(result);
        }
Exemple #4
0
        private void itemsView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            string idBeingDrawn = e.Item.SubItems[1].Text;

            if (showColors)
            {
                WorkflowItem itemBeingDrawn = GetWorkflowItemFromCurrentViewByID(idBeingDrawn);
                ListViewItem lvItem         = itemsListView.Items[e.ItemIndex] as ListViewItem;

                // draw respective color
                try
                {
                    e.Item.ForeColor = Color.FromName(itemBeingDrawn.DisplayColor);
                    e.Item.UseItemStyleForSubItems = true;
                    if (e.Item.Focused == true || e.Item.Checked == true)
                    {
                        e.Item.BackColor = Color.FromName("ActiveCaption");
                    }
                    else
                    {
                        e.Item.BackColor = Color.FromArgb(15, 15, 15);
                    }
                }
                catch (Exception)
                {
                    // just so the program doesn't crash if there's any issues drawing an item (when items get removed from the view)
                }

                // draw every other item default
                e.DrawDefault = true;
            }
            else
            {
                try
                {
                    e.Item.ForeColor = Color.FromName("ControlLight");
                    e.Item.UseItemStyleForSubItems = true;
                    if (e.Item.Focused == true || e.Item.Checked == true)
                    {
                        e.Item.BackColor = Color.FromName("ActiveCaption");
                    }
                    else
                    {
                        e.Item.BackColor = Color.FromArgb(15, 15, 15);
                    }
                }
                catch (Exception)
                {
                    // just so the program doesn't crash if there's any issues drawing an item (when items get removed from the view)
                }

                // draw every other item default
                e.DrawDefault = true;
            }
        }
        public WorkflowItem GetItemFromDatabase(string id)
        {
            WorkflowItem itemToReturn = new WorkflowItem();

            var query = from item in workflowItemDatabase
                        where item.DocumentWorkflowItemID == id
                        select item as WorkflowItem;

            foreach (var item in query)
            {
                itemToReturn = item;
            }

            return(itemToReturn);
        }
Exemple #6
0
        private List <WorkflowItem> GetWorkflowItemsFromItemsView()
        {
            List <WorkflowItem> items = new List <WorkflowItem>();

            for (int i = 0; i < this.itemsListView.Items.Count; i++)
            {
                WorkflowItem item = new WorkflowItem();

                item = GetWorkflowItemByID(itemsListView.Items[i].SubItems[1].Text);

                items.Add(item);
            }

            return(items);
        }
 private bool CheckIfItemWasUpdated(WorkflowItem currentItemInDB, WorkflowItem importItem)
 {
     // if any data is not the same, item was changed. return true for check if item was updated
     if (currentItemInDB.CertificateName != importItem.CertificateName || currentItemInDB.Active != importItem.Active ||
         currentItemInDB.Compliant != importItem.Compliant || currentItemInDB.NextExpirationDate != importItem.NextExpirationDate ||
         currentItemInDB.WorkflowAnalyst != importItem.WorkflowAnalyst || currentItemInDB.CompanyAnalyst != importItem.CompanyAnalyst ||
         currentItemInDB.Status != importItem.Status || currentItemInDB.FileSize != importItem.FileSize ||
         currentItemInDB.FileMIME != importItem.FileMIME || currentItemInDB.AssignedToName != importItem.AssignedToName)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #8
0
        private List <string> GenerateValues(WorkflowItem wi)
        {
            List <string> ls = new List <string>();

            if (this.DocumentWorkflowItemIDCheckChoice)
            {
                ls.Add(wi.DocumentWorkflowItemID);
            }
            if (this.CertificateIDCheckChoice)
            {
                if (wi.CertificateName != null)
                {
                    ls.Add(wi.CertificateName);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.CompanyNameCheckChoice)
            {
                if (wi.VendorName != null)
                {
                    ls.Add(wi.VendorName);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.ActiveCheckChoice)
            {
                if (wi.Active != null)
                {
                    ls.Add(wi.Active.ToString());
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.CompliantCheckChoice)
            {
                if (wi.Compliant != null)
                {
                    ls.Add(wi.Compliant.ToString());
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.IssueDateCheckChoice)
            {
                if (wi.IssueDate != null)
                {
                    ls.Add(wi.IssueDate.Value.ToString());
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.WorkflowAnalystCheckChoice)
            {
                if (wi.WorkflowAnalyst != null)
                {
                    ls.Add(wi.WorkflowAnalyst);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.ComplianceAnalystCheckChoice)
            {
                if (wi.CompanyAnalyst != null)
                {
                    ls.Add(wi.CompanyAnalyst);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.EmailDateCheckChoice)
            {
                if (wi.EmailDate != null)
                {
                    ls.Add(wi.EmailDate.Value.ToString());
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.EmailFromAddressCheckChoice)
            {
                if (wi.EmailFromAddress != null)
                {
                    ls.Add(wi.EmailFromAddress);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.SubjectLineCheckChoice)
            {
                if (wi.SubjectLine != null)
                {
                    ls.Add(wi.SubjectLine);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.StatusCheckChoice)
            {
                if (wi.Status != null)
                {
                    ls.Add(wi.Status);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.CertusFileIDCheckChoice)
            {
                if (wi.CertusFileID != null)
                {
                    ls.Add(wi.CertusFileID);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.FileNameCheckChoice)
            {
                if (wi.FileName != null)
                {
                    ls.Add(wi.FileName);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.FileURLCheckChoice)
            {
                if (wi.FileURL != null)
                {
                    ls.Add(wi.FileURL);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.FileSizeCheckChoice)
            {
                if (wi.FileSize != null)
                {
                    ls.Add(wi.FileSize);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.FileMIMECheckChoice)
            {
                if (wi.FileMIME != null)
                {
                    ls.Add(wi.FileMIME);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.AssignedToCheckChoice)
            {
                if (this.AssignedToComboBoxSelectedIndex == 0)
                {
                    if (wi.AssignedToName != null)
                    {
                        ls.Add(wi.AssignedToName);
                    }
                    else
                    {
                        ls.Add("");
                    }
                }
                else if (this.AssignedToComboBoxSelectedIndex == 1)
                {
                    if (wi.AssignedToID != null)
                    {
                        ls.Add(wi.AssignedToID);
                    }
                    else
                    {
                        ls.Add("");
                    }
                }
            }
            if (this.DisplayColorCheckChoice)
            {
                if (wi.DisplayColor != null)
                {
                    ls.Add(wi.DisplayColor);
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.ItemsAttachedCheckChoice)
            {
                if (wi.ItemsAttached != null)
                {
                    ls.Add(wi.ItemsAttached.Count.ToString());
                }
                else
                {
                    ls.Add("");
                }
            }
            if (this.NoteCheckChoice)
            {
                if (wi.Note != null)
                {
                    ls.Add(wi.Note);
                }
                else
                {
                    ls.Add("");
                }
            }

            return(ls);
        }
Exemple #9
0
        private void GenerateWorkflowItemList()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["CertusDB"].ToString();
            string query;

            SqlConnection conn    = new SqlConnection(connectionString);
            SqlCommand    command = conn.CreateCommand();

            // get query
            using (Stream strm = Assembly.GetExecutingAssembly().GetManifestResourceStream("CertusCompanion.ImportQueries.WIR4.0_DS.sql"))
            {
                using (StreamReader sr = new StreamReader(strm))
                {
                    query = sr.ReadToEnd();
                }
            }

            // manipulate query
            if (workflowItemSelection == "Non-completed")
            {
                query = query.Replace("TOP", "--TOP");
                query = query.Replace("0--<cl>", $"{clientID}--<cl>");
                query = query.Replace("AND DocumentWorkflowStatus.DocumentWorkflowStatusID > 3--<c2>", "--AND DocumentWorkflowStatus.DocumentWorkflowStatusID > 3--<c2>");
            }
            else if (workflowItemSelection == "Most Recent...")
            {
                query = query.Replace("TOP 0", $"TOP {itemCount}");
                query = query.Replace("0--<cl>", $"{clientID}--<cl>");
                query = query.Replace("AND DocumentWorkflowStatus.DocumentWorkflowStatusID <= 3--<c1>", "--AND DocumentWorkflowStatus.DocumentWorkflowStatusID <= 3--<c1>");
                query = query.Replace("AND DocumentWorkflowStatus.DocumentWorkflowStatusID > 3--<c2>", "--AND DocumentWorkflowStatus.DocumentWorkflowStatusID > 3--<c2>");
            }
            else if (workflowItemSelection == "Most Recent (Non-completed)...")
            {
                query = query.Replace("TOP 0", $"TOP {itemCount}");
                query = query.Replace("0--<cl>", $"{clientID}--<cl>");
                query = query.Replace("AND DocumentWorkflowStatus.DocumentWorkflowStatusID > 3--<c2>", "--AND DocumentWorkflowStatus.DocumentWorkflowStatusID > 3--<c2>");
            }
            else if (workflowItemSelection == "Most Recent (Completed)...")
            {
                query = query.Replace("TOP 0", $"TOP {itemCount}");
                query = query.Replace("0--<cl>", $"{clientID}--<cl>");
                query = query.Replace("AND DocumentWorkflowStatus.DocumentWorkflowStatusID <= 3--<c1>", "--AND DocumentWorkflowStatus.DocumentWorkflowStatusID <= 3--<c1>");
            }

            // execute query
            command.CommandText    = query;
            command.CommandType    = CommandType.Text;
            command.CommandTimeout = 450;

            SqlDataAdapter wiAdapter = new SqlDataAdapter(command);
            DataTable      wiTable   = new DataTable();

            wiAdapter.Fill(wiTable);

            // if there is a LoadingForm, report progress
            if (WorkflowManager.CheckIfFormIsOpened("LoadingForm"))
            {
                if (Application.OpenForms[0].InvokeRequired)
                {
                    Application.OpenForms[0].Invoke(new Action(() =>
                    {
                        (Application.OpenForms["LoadingForm"] as LoadingForm).ChangeLabel($"Generating items...");
                        (Application.OpenForms["LoadingForm"] as LoadingForm).MoveBar(25);
                        (Application.OpenForms["LoadingForm"] as LoadingForm).Refresh();
                    }));
                }
                else
                {
                    (Application.OpenForms["LoadingForm"] as LoadingForm).ChangeLabel($"Generating items...");
                    (Application.OpenForms["LoadingForm"] as LoadingForm).MoveBar(25);
                    (Application.OpenForms["LoadingForm"] as LoadingForm).Refresh();
                }
            }

            // add to WI
            foreach (DataRow row in wiTable.Rows)
            {
                string   documentWorkflowItemID = row[0].ToString();
                string   CertificateID          = row[1].ToString();
                string   vendorName             = row[2].ToString();
                string   vendorID          = row[3].ToString();
                string   clID              = row[4].ToString();
                string   workflowAnalyst   = row[5].ToString();
                string   workflowAnalystID = row[6].ToString();
                string   companyAnalyst    = row[7].ToString();
                string   companyAnalystID  = row[8].ToString();
                DateTime parsedDateTimeValue;
                DateTime?emailDate = null;
                DateTime.TryParse(row[9].ToString(), out parsedDateTimeValue);
                emailDate = parsedDateTimeValue;
                string emailFromAddress = row[10].ToString();
                string subjectLine      = row[11].ToString();
                string status           = row[12].ToString();
                string certusFileID     = row[13].ToString();
                string fileName         = row[14].ToString();
                string fileSize         = row[15].ToString();
                string fileMIME         = row[16].ToString();
                string fileURL          = row[17].ToString();

                WorkflowItem wi = new WorkflowItem
                                  (
                    documentWorkflowItemID,
                    CertificateID,
                    vendorName,
                    vendorID,
                    clID,
                    null,
                    null,
                    null,
                    null,
                    workflowAnalyst,
                    workflowAnalystID,
                    companyAnalyst,
                    companyAnalystID,
                    emailDate,
                    emailFromAddress,
                    subjectLine,
                    null,
                    status,
                    certusFileID,
                    fileName,
                    fileURL,
                    fileSize,
                    fileMIME,
                    null
                                  );

                this.currentImportItems.Add(wi);
            }

            // if there is a LoadingForm, report progress
            if (WorkflowManager.CheckIfFormIsOpened("LoadingForm"))
            {
                if (Application.OpenForms[0].InvokeRequired)
                {
                    Application.OpenForms[0].Invoke(new Action(() =>
                    {
                        (Application.OpenForms["LoadingForm"] as LoadingForm).ChangeLabel($"Saving item data...");
                        (Application.OpenForms["LoadingForm"] as LoadingForm).MoveBar(25);
                        (Application.OpenForms["LoadingForm"] as LoadingForm).Refresh();
                    }));
                }
                else
                {
                    (Application.OpenForms["LoadingForm"] as LoadingForm).ChangeLabel($"Saving item data...");
                    (Application.OpenForms["LoadingForm"] as LoadingForm).MoveBar(25);
                    (Application.OpenForms["LoadingForm"] as LoadingForm).Refresh();
                }
            }

            WorkflowImportRouter(3);
        }
        public void UpdateItem(string id, WorkflowItem updateItem)
        {
            int index = workflowItemDatabase.FindIndex(i => i.DocumentWorkflowItemID == id);

            workflowItemDatabase[index] = updateItem;
        }
 //
 // constructors
 public WorkflowItemDatabase()
 {
     this.workflowItemDatabase = new List <WorkflowItem>();
     this.itemBeingAdded       = new WorkflowItem();
     this.itemListBeingAdded   = new List <WorkflowItem>();
 }
 public void RemoveWorkflowItem(WorkflowItem item)
 {
     workflowItemDatabase.Remove(item);
 }
Exemple #13
0
        // ----- ITEM POPULATION ----- //
        #region Item Population
        public void PopulateItems(List <WorkflowItem> workflowItems, List <string> excludedIDs)
        {
            idsAddedToLv        = new List <string>();
            excludedWfItems     = new List <WorkflowItem>();
            workflowItemsLoaded = new List <WorkflowItem>();
            int itemsNotShowing = 0;

            // save lists to this instance
            this.workflowItems = workflowItems;
            this.excludedIDs   = excludedIDs;

            // set excluded items as wf items or notify user they cannot be set
            try
            {
                excludedWfItems     = GetItemsToDisplayFromIDs();
                workflowItemsLoaded = excludedWfItems;
            }
            catch (Exception)
            {
                MessageBox.Show("Could not load items. Ensure ID list is in the correct format");
            }

            // reset lv
            this.itemsListView.BeginUpdate();
            this.itemsListView.ListViewItemSorter = null;
            this.itemsListView.Items.Clear();

            // column headers
            this.viewColumnHeader1.Text = "";
            this.viewColumnHeader2.Text = "Item ID";
            this.viewColumnHeader3.Text = "Company Name";
            this.viewColumnHeader4.Text = "Sent Date";
            this.viewColumnHeader5.Text = "From Address";
            this.viewColumnHeader6.Text = "Subject";
            this.viewColumnHeader7.Text = "Status";

            SetInitialColumnHeaderSizes();

            // for each id in the list
            foreach (string excludedID in excludedIDs)
            {
                // if list does not already contain item
                if (!idsAddedToLv.Contains(excludedID))
                {
                    // if workflow items are available, show entire items in LV
                    if (workflowItems != null && workflowItems.Count > 0)
                    {
                        // if item is available
                        if (this.GetWorkflowItemByID(excludedID) != null)
                        {
                            // get the item from the id string
                            WorkflowItem wfItem = this.GetWorkflowItemByID(excludedID);

                            // make tmp lvItem
                            ListViewItem lvItem = new ListViewItem(itemNum.ToString());

                            // add to tmp lvItem
                            lvItem.SubItems.Add(wfItem.DocumentWorkflowItemID.ToString());
                            lvItem.SubItems.Add(wfItem.VendorName);
                            lvItem.SubItems.Add(wfItem.EmailDate.ToString());
                            lvItem.SubItems.Add(wfItem.EmailFromAddress);
                            lvItem.SubItems.Add(wfItem.SubjectLine);
                            lvItem.SubItems.Add(wfItem.Status);

                            // add lvItem to lv
                            itemsListView.Items.Add(lvItem);

                            // add string to added lv ids
                            idsAddedToLv.Add(excludedID);
                        }
                        else
                        {
                            ++itemsNotShowing;
                        }
                    }
                    // if workflow items aren't available, just show IDs instead
                    else
                    {
                        // make tmp lvItem
                        ListViewItem lvItem = new ListViewItem(itemNum.ToString());

                        // add ID to tmp lvItem
                        lvItem.SubItems.Add(excludedID);

                        // add lvItem to lv
                        itemsListView.Items.Add(lvItem);
                    }

                    altMain.CountListViewItems(itemsListView);
                    this.itemsListView.ListViewItemSorter = lvwColumnSorter;
                    this.itemsListView.EndUpdate();
                    CorrectColumnHeaderSize(viewColumnHeader6);
                }
            }

            // display items not showing count if > 0
            if (itemsNotShowing > 0)
            {
                if (itemsNotShowing == 1)
                {
                    SetStatusLabelAndTimer($"{itemsNotShowing} item on the file cannot displayed. Item ID doesn't correlate with any item in the current view.");
                }
                else
                {
                    SetStatusLabelAndTimer($"{itemsNotShowing} items on the file cannot displayed. Item ID's don't correlate with any items in the current view.");
                }
            }
        }
Exemple #14
0
        public void Populate(WorkflowItem item)
        {
            this.Note = item.Note;

            this.noteTbx.Text = item.Note;
        }