public static int InsertCaptureEventForTextConversion(AdvancedRecomendation captureEvent, ReplacementEvent replacementEvent)
 {
     int returnCode = -1;
     int RecommendationId = InsertRecommendationForTextConversion(captureEvent);
     int CapturePointId = Rec_CapturePoints_TextConv.InsertCapturePointsForTextConversion(RecommendationId, captureEvent.CaptureEventCapturePointsList);
     replacementEvent.capturePointId = RecommendationId;
     Advanced_Replacements_TextConv.InsertNewReplacementForTextConversion(replacementEvent);
     return returnCode;
 }
 public static void SaveCaptureEventByIdForTextConversion(int captureEventId, AdvancedRecomendation captureEvent, ReplacementEvent replacementEvent)
 {
     SqlCeTransaction transaction;
     SqlCeConnection conn = BackEndUtils.GetSqlConnection();
     try {
         conn.Open();
         transaction = conn.BeginTransaction();
         try {
             UpdateRecommendationByIdForTextConversion(captureEventId, captureEvent, conn, transaction);
             Rec_CapturePoints_TextConv.DeletAllRespectiveCapturePointsForTextConversion(captureEventId, conn, transaction);
             Rec_CapturePoints_TextConv.InsertCapturePointsAsTransactionForTextConversion(captureEventId, captureEvent.CaptureEventCapturePointsList, conn, transaction);
             replacementEvent.capturePointId = captureEventId;
             Advanced_Replacements_TextConv.SaveReplacementEventForTextConversion(replacementEvent, conn, transaction);
             transaction.Commit();
         } catch (Exception ex) {
             CommonUtils.LogError(ex.Message, ex);
             transaction.Rollback();
         }
     } finally {
         conn.Close();
     }
 }
 private static void UpdateRecommendationById(int captureEventId, AdvancedRecomendation advancedRecomendation, SqlCeConnection conn, SqlCeTransaction transaction)
 {
     int value = 0;
     SqlCeCommand command = new SqlCeCommand(Advanced_Recommendations_SQL.commandUpdateRecommendationById, conn);
     command.Transaction = transaction;
     command.Parameters.Add("@name", advancedRecomendation.CaptureEventName);
     command.Parameters.Add("@description", advancedRecomendation.CaptureEventDescription);
     command.Parameters.Add("@event_text", advancedRecomendation.CaptureEventEventText);
     command.Parameters.Add("@id", captureEventId);
     command.Parameters.Add("@categoryId", advancedRecomendation.captureEventCategory);
     command.Parameters.Add("@usageCount", advancedRecomendation.captureEventUsageCount);
     command.Parameters.Add("@userId", FrontendUtils.LoggedInUserId);
     value = Convert.ToInt32(command.ExecuteNonQuery());
 }
 private static AdvancedRecomendation GetAdvancedRecommendationItem(DataRow advancedRecRow, DataTable capturePointsTable, SqlCeConnection conn)
 {
     List<CustomTreeNode> customCapturePointList = BackEndUtils.GetCustomCapturePointListFromTable(capturePointsTable);
     AdvancedRecomendation capture = new AdvancedRecomendation(Convert.ToInt32(advancedRecRow["id"]), advancedRecRow["name"].ToString(), advancedRecRow["description"].ToString(), advancedRecRow["event_text"].ToString(), Convert.ToInt32(advancedRecRow["categoryId"]), Convert.ToInt32(advancedRecRow["usageCount"]), customCapturePointList, FrontendUtils.LoggedInUserId);
     capture.Replacement = Advanced_Replacements.GetReplacementEventByCaptureEventId(capture.CaptureEventId, conn);
     return capture;
 }
 public static int InsertCaptureEvent(AdvancedRecomendation advancedRecomendation)
 {
     int returnCode = -1;
     int RecommendationId = InsertRecommendation(advancedRecomendation);
     int CapturePointId = Rec_CapturePoints.InsertCapturePoints(RecommendationId, advancedRecomendation.CaptureEventCapturePointsList);
     return returnCode;
 }
 private void ParseUsingAdvancedList(AdvancedRecomendation captureEvent, XDocument xdoc)
 {
     var test21 = from c1 in xdoc.Descendants(captureEvent.CaptureEventCapturePointsList[0].Text)
                  where AllAttributesAvailable(c1, captureEvent.CaptureEventCapturePointsList[0].customizedAttributeCollection)
                  select new {
         elements = c1.DescendantNodesAndSelf()
     };
     List<bool> foundlist = new List<bool>();
     for (int i = 0; i < test21.Count(); i++) {
         bool found = true;
         XNode node = test21.ElementAt(i).elements.ElementAt(0);
         XmlReader Xreader = node.CreateReader();
         Xreader.Read();
         while (Xreader.Read() && found) {
             if (Xreader.NodeType == XmlNodeType.Element) {
                 for (int listLength = 1; found && listLength < captureEvent.CaptureEventCapturePointsList.Count; listLength++) {//Xreader.Name;
                     if (!captureEvent.CaptureEventCapturePointsList[listLength].nodeVisited && string.Equals(captureEvent.CaptureEventCapturePointsList[listLength].Text, Xreader.Name)) {
                         captureEvent.CaptureEventCapturePointsList[listLength].nodeVisited = true;
                         #region Loop Thru attributes
                         for (int attrCoun = 0; found && attrCoun < captureEvent.CaptureEventCapturePointsList[listLength].customizedAttributeCollection.Count; attrCoun++) {
                             CustomizedAttribute customizedAttribute = captureEvent.CaptureEventCapturePointsList[listLength].customizedAttributeCollection[attrCoun];
                             string attributeValueFromXml = Xreader.GetAttribute(customizedAttribute.attrName);
                             if (string.IsNullOrEmpty(attributeValueFromXml) && !string.IsNullOrEmpty(customizedAttribute.attrName)) {
                                 found = false;
                             } else if (!string.Equals(attributeValueFromXml, customizedAttribute.attrValue) && !string.IsNullOrEmpty(customizedAttribute.attrName)) {
                                 found = false;
                             }
                         }
                         listLength = captureEvent.CaptureEventCapturePointsList.Count;
                         #endregion
                     }
                 }
             }
         }
         foundlist.Add(found);
     }
     //txtFoundEvents.Text = string.Empty;
     //for (int k = 0; k < foundlist.Count; k++) {
     //    if (foundlist[k]) {
     //        XNode node = test21.ElementAt(k).elements.ElementAt(0);
     //        txtFoundEvents.Text = txtFoundEvents.Text + (string.IsNullOrEmpty(txtFoundEvents.Text) ? "" : "\r\n") + FrontendUtils.FormatXml(node.ToString());
     //    }
     //}
 }
        private void lbAdvancedCE_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            try {
                captureNodesSelectedNames = new List<string>();
                AdvancedRecomendation captureEvent = new AdvancedRecomendation();
                captureEvent = lbAdvancedCE.SelectedItem as AdvancedRecomendation;

                if (captureEvent != null) {
                    btnAddCaptureEvent.Enabled = false;
                    btnSaveCaptureEvent.Enabled = true;
                    txtAOEventIn.ReadOnly = true;
                    tvOutput.Nodes.Clear();
                    dgvAttributes.Rows.Clear();
                    AdvancedRecomendation workingEvent = new AdvancedRecomendation(captureEvent.CaptureEventId,
                            captureEvent.CaptureEventName,
                            captureEvent.CaptureEventDescription,
                            captureEvent.CaptureEventEventText,
                            captureEvent.captureEventCategory,
                            captureEvent.captureEventUsageCount,
                            captureEvent.CaptureEventCapturePointsList,
                            captureEvent.captureEventuserId);
                    CurrentlySelectedCaptureEvent = workingEvent;
                    for (int i = 0; i < captureEvent.CaptureEventCapturePointsList.Count; i++) {
                        captureEvent.CaptureEventCapturePointsList[i].nodeVisited = false;
                    }
                    cboCaptureType.SelectedValue = captureEvent.captureEventCategory;
                    txtAOName.Text = workingEvent.CaptureEventName;
                    txtAODescription.Text = workingEvent.CaptureEventDescription;
                    txtAOEventIn.Text = workingEvent.CaptureEventEventText;
                    InterpretCaptureEvent(workingEvent);

                    RecurResetTag(tvOutput.Nodes);

                    if (captureEvent.captureEventCategory == (int)AdvancedRecomendationCategory.Verbal) {
                        // setup validation and ui for verbal recommendations
                        ConfigureToValidateXml = false;

                    } else {
                        ConfigureToValidateXml = true;
                    }

                }

            } catch (Exception ex) {
                CommonUtils.ShowError(ex.Message, ex);
            }
        }
 private CustomTreeNode GetRespectiveCapturePoint(CustomTreeNode customTreeNode, AdvancedRecomendation captureEvent, XmlNode xNode, int index, int level, int parentIndex, int parentLevel)
 {
     for (int i = 1; i < captureEvent.CaptureEventCapturePointsList.Count; i++) {
         if (captureEvent.CaptureEventCapturePointsList[i].nodeIndex == index &&
                 captureEvent.CaptureEventCapturePointsList[i].nodeLevel == level &&
                 captureEvent.CaptureEventCapturePointsList[i].parentIndex == parentIndex &&
                 captureEvent.CaptureEventCapturePointsList[i].parentLevel == parentLevel) {
             if (string.Equals(captureEvent.CaptureEventCapturePointsList[i].Text, xNode.Name)) {
                 if ((captureNodesSelectedNames.Count < captureEvent.CaptureEventCapturePointsList.Count - 1) || (!captureNodesSelectedNames.Contains(xNode.Name))) {
                     customTreeNode.customizedAttributeCollection = captureEvent.CaptureEventCapturePointsList[i].customizedAttributeCollection;
                     customTreeNode.isNodeUsed = captureEvent.CaptureEventCapturePointsList[i].isNodeUsed;
                     if ((level == 2) && (!string.Equals(captureNodesSelectedNames[captureNodesSelectedNames.Count - 1], xNode.Name))) {
                         captureNodesSelectedNames.Add(xNode.Name);
                     } else if (level < 2) {
                         captureNodesSelectedNames.Add(xNode.Name);
                     }
                 }
             }
         }
     }
     return customTreeNode;
 }
 private void ParseTargetedFile(AdvancedRecomendation captureEvent, string readText, ComplexCaptureMatchObject complexCaptureMatchObject, string fileName)
 {
     captureEvent = GetCapturePointListType(captureEvent);
     XDocument xdoc = XDocument.Parse(readText);
     List<string> foundEvents = new List<string>();
     if (captureEvent.capturePointListType == CapturePointListType.SimpleList) {
         List<XNode> foundNodes = ParseUsingSimpleList(captureEvent, xdoc, foundEvents);
         totalFoundNodes = totalFoundNodes + foundNodes.Count;
         if (foundNodes.Count > 0) {
             FileAndNumberOfMatches fileAndNumberOfMatches = new FileAndNumberOfMatches();
             fileAndNumberOfMatches.fileName = fileName;
             fileAndNumberOfMatches.matchedNodes = foundNodes;
             complexCaptureMatchObject.fileNamesHit.Add(fileAndNumberOfMatches);
         }
     } else {
         List<XNode> foundNodes = ParseUsingAdvancedList(captureEvent, xdoc);
         totalFoundNodes = totalFoundNodes + foundNodes.Count;
         if (foundNodes.Count > 0) {
             FileAndNumberOfMatches fileAndNumberOfMatches = new FileAndNumberOfMatches();
             fileAndNumberOfMatches.fileName = fileName;
             fileAndNumberOfMatches.matchedNodes = foundNodes;
             complexCaptureMatchObject.fileNamesHit.Add(fileAndNumberOfMatches);
         }
     }
 }
 private void lvAdvancedRules_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
 {
     try {
         //tag contains rec id
         if ((sender as ListView).SelectedItems.Count != 0) {
             //currentlySelectedEvent = BackEndUtils.SelectAdvancedRecById((sender as ListView).SelectedItems[0].Tag);
             currentlySelectedEvent = currentlyLoadedEvents[Convert.ToInt32((sender as ListView).SelectedItems[0].Tag)];
             SetupUiFromCapturePoint(currentlySelectedEvent);
         }
     } catch (Exception ex) {
         CommonUtils.ShowError(ex.Message, ex);
     }
 }
 private void LoadAvailableAdvancedRecommendations()
 {
     lvAdvancedRules.Clear();
     DataSet dataSet = Advanced_Recommendation_Categories.GetAllAdvancedRecCategoriesAsDataset();
     foreach (DataRow dataRow in dataSet.Tables[0].Rows) {
         lvAdvancedRules.Groups.Add(dataRow["id"].ToString(), dataRow["enumerationName"].ToString());
     }
     AllCategories = dataSet;
     DataSet newDataSet = Advanced_Recommendations.GetAllAdvancedRecsAsDataSet();
     currentlyLoadedEvents = new Dictionary<int, AdvancedRecomendation>();
     foreach (DataRow dataRow in newDataSet.Tables[0].Rows) {
         System.Windows.Forms.ListViewItem item = lvAdvancedRules.Items.Add(dataRow["id"].ToString(), dataRow["name"].ToString(), 0);
         item.Group = lvAdvancedRules.Groups[dataRow["categoryId"].ToString()];
         item.Tag = dataRow["id"].ToString();//tag holding the id of the rec
         item.ImageIndex = 1;
         AdvancedRecomendation capture = new AdvancedRecomendation();
         capture.CaptureEventId = Convert.ToInt32(item.Tag);
         capture.CaptureEventName = dataRow["name"].ToString();
         capture.CaptureEventDescription = dataRow["description"].ToString();
         capture.captureEventUsageCount = Convert.ToInt32(dataRow["usageCount"]);
         currentlyLoadedEvents.Add(Convert.ToInt32(item.Tag), capture);
     }
     AllAdvancedRecs = newDataSet;
     CAPTURE_TOTAL_USAGE_COUNT = Advanced_Recommendations.GetTotalAdvanceRecUsageCount();
 }
        private void btnResetForm_Click(object sender, EventArgs e)
        {
            try {
                btnStart.Enabled = true;

                currentlySelectedEvent = new AdvancedRecomendation();
                currentlyUsedCaptures = new List<AdvancedRecomendation>();
                backGroundWorkerObject = new BackGroundWorkerObject();
                totalFoundNodes = 0;

                lblFoundNodesCound.Text = 0 + "";

                dgvSearchResult.Rows.Clear();
                dgvSearchResult.Visible = false;

                btnProceedToReplacement.Visible = false;
                btnResetForm.Visible = false;

                pbPercentComplete.Visible = true;
                pbPercentComplete.Value = 0;

                LoadAvailableAdvancedRecommendations();
                pcProgress.Visible = false;
                pcProgress.Clear();
                pcProgress.Rotate = false;

                DataSet AllCategories = new DataSet();
                DataSet AllAdvancedRecs = new DataSet();

                lvAdvancedRules.Focus();

                txtRuleDescription.ResetText();
                txtRuleName.ResetText();

                srcPopularityAdded.m_hoverStar = 0;
                srcPopularityAdded.m_selectedStar = 0;
                srcPopularityAdded.Invalidate();

            } catch (Exception ex) {
                CommonUtils.ShowError(ex.Message, ex);
            }
        }
 private void SetupUiFromCapturePoint(AdvancedRecomendation capture)
 {
     txtRuleName.Text = capture.CaptureEventName;
     txtRuleDescription.Text = capture.CaptureEventDescription;
     SetPopularity(capture);
 }
 private void SetPopularity(AdvancedRecomendation capture)
 {
     srcPopularityAdded.m_hoverStar = 0;
     srcPopularityAdded.m_selectedStar = 0;
     srcPopularityAdded.Invalidate();
     double usagePercent = ((double)capture.captureEventUsageCount / CAPTURE_TOTAL_USAGE_COUNT) * 20;
     srcPopularityAdded.m_hoverStar = (int)usagePercent;
     srcPopularityAdded.m_selectedStar = (int)usagePercent;
     srcPopularityAdded.m_hovering = true;
     srcPopularityAdded.Invalidate();
 }
 private void SelectAllAvailableAdvancedRules()
 {
     //0 => green
     //1 => red
     foreach (System.Windows.Forms.ListViewItem item in lvAdvancedRules.Items) {
         item.ImageIndex = 0;
         //currentlySelectedEvent = BackEndUtils.SelectAdvancedRecById(item.Tag);
         currentlySelectedEvent = currentlyLoadedEvents[Convert.ToInt32(item.Tag)];
         currentlyUsedCaptures = AddCapturePointToList(currentlyUsedCaptures, currentlySelectedEvent);
     }
 }
        private void FillReplacementsListBox(AdvancedRecomendation selectedAdvancedRec)
        {
            int savedIndex = 0;

            if (lbAvailableReplacements.SelectedIndex !=null) {
                savedIndex = lbAvailableReplacements.SelectedIndex;
            }
            lbAvailableReplacements.Items.Clear();

            List<ReplacementEvent> availableReplacements = Advanced_Replacements.GetAvailableReplacementsByCaptureId(selectedAdvancedRec.CaptureEventId, BackEndUtils.GetSqlConnection());
            for (int i = 0; i < availableReplacements.Count; i++) {
                lbAvailableReplacements.Items.Add(availableReplacements[i]);
            }

            lbAvailableReplacements.SelectedIndex = savedIndex;
        }
 private AdvancedRecomendation GetCapturePointListType(AdvancedRecomendation captureEvent)
 {
     List<CustomTreeNode> list = captureEvent.CaptureEventCapturePointsList;
     captureEvent.capturePointListType = CapturePointListType.SimpleList;
     for (int listCount = 1; listCount < list.Count; listCount++) {
         if (list[listCount - 1].nodeLevel > list[listCount].nodeLevel) {
             captureEvent.capturePointListType = CapturePointListType.ListWithMutlipleDesc;
             return captureEvent;
         }
     }
     return captureEvent;
 }
 private List<AdvancedRecomendation> AddCapturePointToList(List<AdvancedRecomendation> currentlyUsedCaptures, AdvancedRecomendation currentlySelectedEvent)
 {
     bool found = false;
     if (currentlyUsedCaptures.Count == 0) {
         currentlyUsedCaptures.Add(currentlySelectedEvent);
     } else {
         for (int i = 0; i < currentlyUsedCaptures.Count && !found; i++) {
             if (currentlyUsedCaptures[i].CaptureEventId == currentlySelectedEvent.CaptureEventId) {
                 found = true;
             }
             if (!found && i == currentlyUsedCaptures.Count - 1) {
                 currentlyUsedCaptures.Add(currentlySelectedEvent);
             }
         }
     }
     return currentlyUsedCaptures;
 }
 private void InterpretCaptureEvent(AdvancedRecomendation captureEvent)
 {
     ParseEventFromDatabase(captureEvent);
     CustomTreeNode[] customArray = new CustomTreeNode[captureEvent.CaptureEventCapturePointsList.Count];
     captureEvent.CaptureEventCapturePointsList.CopyTo(customArray);
     RestoreSelectedCapturePoints(customArray, tvOutput.Nodes);
 }
Exemplo n.º 20
0
 private void showDetailsFormToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try {
         AdvancedRecomendation obj = new AdvancedRecomendation();
         ShowSearchDetailsForm form = new ShowSearchDetailsForm(obj);
         form.MdiParent = this;
         form.Show();
     } catch (Exception ex) {
         FrontendUtils.ShowError(ex.Message, ex);
     }
 }
 private void ParseEventFromDatabase(AdvancedRecomendation captureEvent)
 {
     xmlDocument = XDocument.Parse(captureEvent.CaptureEventEventText);
     populateTreeviewSingleEventFromDatabase(xmlDocument.ToString(), captureEvent);
     //IEnumerable<XElement> childred =
     //       object patterns = xmlDocument.XPathEvaluate(@"MXClientScript\Events");
     IEnumerable<XElement> children = xmlDocument.Elements();
 }
Exemplo n.º 22
0
        private string ParseTargetedFile(AdvancedRecomendation captureEvent, string readText)
        {
            captureEvent = GetCapturePointListType(captureEvent);
            XDocument xdoc = XDocument.Parse(readText);
            List<string> foundEvents = new List<string>();
            List<XNode> foundNodes = new List<XNode>();
            if (captureEvent.capturePointListType == CapturePointListType.SimpleList) {
                foundNodes = ParseUsingSimpleList(captureEvent, xdoc, foundEvents);
                if (foundNodes.Count > 0) {
                    FileAndNumberOfMatches fileAndNumberOfMatches = new FileAndNumberOfMatches();
                    fileAndNumberOfMatches.matchedNodes = foundNodes;

                }
            } else {
                foundNodes = ParseUsingAdvancedList(captureEvent, xdoc);
                if (foundNodes.Count > 0) {
                    FileAndNumberOfMatches fileAndNumberOfMatches = new FileAndNumberOfMatches();
                    fileAndNumberOfMatches.matchedNodes = foundNodes;
                }
            }
            ReplaceFoundNodes(captureEvent.Replacement, foundNodes);
            return xdoc.ToString();
        }
 private void ParseUsingSimpleList(AdvancedRecomendation captureEvent, XDocument xdoc, List<string> foundEvents)
 {
     switch (captureEvent.CaptureEventCapturePointsList.Count) {
     case 1:
         var q1 = from c1 in xdoc.Descendants(captureEvent.CaptureEventCapturePointsList[0].Text)
                  where AllAttributesAvailable(c1, captureEvent.CaptureEventCapturePointsList[0].customizedAttributeCollection)
                  select new {
             elements = c1.DescendantNodesAndSelf()
         };
         for (int i = 0; i < q1.Count(); i++) {
             foundEvents.Add(q1.ElementAt(i).elements.ElementAt(0).ToString());
         }
         break;
     case 2:
         var q2 = from c1 in xdoc.Descendants(captureEvent.CaptureEventCapturePointsList[0].Text)
                  where AllAttributesAvailable(c1, captureEvent.CaptureEventCapturePointsList[0].customizedAttributeCollection)
                  from c2 in c1.Elements(captureEvent.CaptureEventCapturePointsList[1].Text)
                  where AllAttributesAvailable(c2, captureEvent.CaptureEventCapturePointsList[1].customizedAttributeCollection)
                  select new {
             elements = c1.DescendantNodesAndSelf()
         };
         for (int i = 0; i < q2.Count(); i++) {
             foundEvents.Add(q2.ElementAt(i).elements.ElementAt(0).ToString());
         }
         break;
     case 3:
         var q3 = from c1 in xdoc.Descendants(captureEvent.CaptureEventCapturePointsList[0].Text)
                  where AllAttributesAvailable(c1, captureEvent.CaptureEventCapturePointsList[0].customizedAttributeCollection)
                  from c2 in c1.Elements(captureEvent.CaptureEventCapturePointsList[1].Text)
                  where AllAttributesAvailable(c2, captureEvent.CaptureEventCapturePointsList[1].customizedAttributeCollection)
                  from c3 in c2.Elements(captureEvent.CaptureEventCapturePointsList[2].Text)
                  where AllAttributesAvailable(c3, captureEvent.CaptureEventCapturePointsList[2].customizedAttributeCollection)
                  select new {
             elements = c1.DescendantNodesAndSelf()
         };
         for (int i = 0; i < q3.Count(); i++) {
             foundEvents.Add(q3.ElementAt(i).elements.ElementAt(0).ToString());
         }
         break;
     case 4:
         var q4 = from c1 in xdoc.Descendants(captureEvent.CaptureEventCapturePointsList[0].Text)
                  where AllAttributesAvailable(c1, captureEvent.CaptureEventCapturePointsList[0].customizedAttributeCollection)
                  from c2 in c1.Elements(captureEvent.CaptureEventCapturePointsList[1].Text)
                  where AllAttributesAvailable(c2, captureEvent.CaptureEventCapturePointsList[1].customizedAttributeCollection)
                  from c3 in c2.Elements(captureEvent.CaptureEventCapturePointsList[2].Text)
                  where AllAttributesAvailable(c3, captureEvent.CaptureEventCapturePointsList[2].customizedAttributeCollection)
                  from c4 in c3.Elements(captureEvent.CaptureEventCapturePointsList[3].Text)
                  where AllAttributesAvailable(c4, captureEvent.CaptureEventCapturePointsList[3].customizedAttributeCollection)
                  select new {
             elements = c1.DescendantNodesAndSelf()
         };
         for (int i = 0; i < q4.Count(); i++) {
             foundEvents.Add(q4.ElementAt(i).elements.ElementAt(0).ToString());
         }
         break;
     }
 }
        private void populateTreeviewSingleEventFromDatabase(string document, AdvancedRecomendation captureEvent)
        {
            try {
                //Just a good practice -- change the cursor to a
                //wait cursor while the nodes populate
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(document);
                this.Cursor = Cursors.WaitCursor;
                //First, we'll load the Xml document
                //Now, clear out the treeview,
                //and add the first (root) node
                tvOutput.Nodes.Clear();//captureEvent.CaptureEventCapturePointsList[i]
                CustomTreeNode customRootNode = new CustomTreeNode(xDoc.DocumentElement.Name, xDoc.DocumentElement.Attributes);
                customRootNode.isNodeUsed = true;
                customRootNode.customizedAttributeCollection = captureEvent.CaptureEventCapturePointsList[0].customizedAttributeCollection;
                tvOutput.Nodes.Add(customRootNode);
                TreeNode tNode = new TreeNode();
                tNode = (TreeNode)tvOutput.Nodes[0];
                //We make a call to addTreeNode,
                //where we'll add all of our nodes
                addTreeNodeForSingleEventFromDatabase(xDoc.DocumentElement, tNode, captureEvent, 1, 0, 0, 0);
                //Expand the treeview to show all nodes
                tvOutput.ExpandAll();
            } catch (XmlException xExc)
                //Exception is thrown is there is an error in the Xml
            {
                CommonUtils.ShowError(xExc.Message, xExc);
            } catch (Exception ex) { //General exception

                CommonUtils.ShowError(ex.Message, ex);
            } finally {
                this.Cursor = Cursors.Default; //Change the cursor back
            }
        }
Exemplo n.º 25
0
 public static void SaveAdvancedRecomendationById(int captureEventId, AdvancedRecomendation advancedRecomendation)
 {
     SqlCeTransaction transaction;
     SqlCeConnection conn = BackEndUtils.GetSqlConnection();
     try {
         conn.Open();
         transaction = conn.BeginTransaction();
         try {
             UpdateRecommendationById(captureEventId, advancedRecomendation, conn, transaction);
             Rec_CapturePoints.DeletAllRespectiveCapturePoints(captureEventId, conn, transaction);
             Rec_CapturePoints.InsertCapturePointsAsTransaction(captureEventId, advancedRecomendation.CaptureEventCapturePointsList, conn, transaction);
             transaction.Commit();
         } catch (Exception ex) {
             FrontendUtils.LogError(ex.Message, ex);
             transaction.Rollback();
         }
     } finally {
         conn.Close();
     }
 }
        private void addTreeNodeForSingleEventFromDatabase(XmlNode xmlNode, TreeNode treeNode, AdvancedRecomendation captureEvent, int level, int index, int parentLevel, int parentIndex)
        {
            int newParentLevel = 0;
            XmlNode xNode;
            TreeNode tNode;
            XmlNodeList xNodeList;
            if (xmlNode.HasChildNodes) { //The current node has children
                xNodeList = xmlNode.ChildNodes;
                for (int x = 0, j = 0; x <= xNodeList.Count - 1; x++, j++)
                    //Loop through the child nodes
                {
                    xNode = xmlNode.ChildNodes[x];
                    if (xNode.NodeType != XmlNodeType.Text) {
                        CustomTreeNode customTreeNode = new CustomTreeNode(xNode.Name, xNode.Attributes);
                        int currentIndex = j;
                        customTreeNode = GetRespectiveCapturePoint(customTreeNode, captureEvent, xNode, currentIndex, level, parentIndex, parentLevel);
                        treeNode.Nodes.Add(customTreeNode);
                        //nodeIncludedText
                        tNode = treeNode.Nodes[j];
                        newParentLevel = level;
                        int newParentIndex = currentIndex;
                        if (xNode.HasChildNodes) {
                            //addTreeNodeForSingleEventFromDatabase(xNode, tNode, captureEvent, level + 1, 0, newParentIndex, newParentLevel);
                            int indextElementTypeOnly = 0;
                            for (int i = 0; i < xNode.ChildNodes.Count; i++) {
                                XmlNode childNode = xNode.ChildNodes[i];
                                if (childNode.NodeType != XmlNodeType.Text) {

                                    customTreeNode = new CustomTreeNode(childNode.Name, childNode.Attributes);
                                    currentIndex = i;
                                    customTreeNode = GetRespectiveCapturePoint(customTreeNode, captureEvent, childNode, indextElementTypeOnly, level + 1, j, level);
                                    tNode.Nodes.Add(customTreeNode);
                                    indextElementTypeOnly++;
                                }
                            }
                        }
                    } else {
                        j = x - 1;
                    }
                }

            } else { //No children, so add the outer xml (trimming off whitespace)
                // treeNode.Text = xmlNode.Name;
                // treeNode.Text = xmlNode.Attributes["name"].Value;
                treeNode.Text = xmlNode.Attributes["name"] == null ? xmlNode.Name : xmlNode.Attributes["name"].Value;
            }
        }
Exemplo n.º 27
0
 private static int InsertRecommendation(AdvancedRecomendation advancedRecomendation)
 {
     SqlCeConnection conn = BackEndUtils.GetSqlConnection();
     int value = 0;
     try {
         conn.Open();
         SqlCeCommand command = new SqlCeCommand(Advanced_Recommendations_SQL.commandInsertRecommendation, conn);
         command.Parameters.Add("@name", advancedRecomendation.CaptureEventName);
         command.Parameters.Add("@description", advancedRecomendation.CaptureEventDescription);
         command.Parameters.Add("@eventText", advancedRecomendation.CaptureEventEventText);
         // @categoryId, @usageCount
         command.Parameters.Add("@categoryId", advancedRecomendation.captureEventCategory);
         command.Parameters.Add("@usageCount", advancedRecomendation.captureEventUsageCount);
         command.Parameters.Add("@userId", FrontendUtils.LoggedInUserId);
         value = Convert.ToInt32(command.ExecuteNonQuery());
         SqlCeCommand commandMaxId = new SqlCeCommand(Advanced_Recommendations_SQL.commandMaxRecommendationId, conn);
         value = Convert.ToInt32(commandMaxId.ExecuteScalar());
     }catch (Exception ex){
         FrontendUtils.LogError(ex.Message,ex);
     }
     finally {
         conn.Close();
     }
     return value;
 }
 private void btnAddCaptureEvent_Click(object sender, EventArgs e)
 {
     try {
         if (eventParsed) {
             tvOutput.Select();
             string ruleName = txtAOName.Text;
             string ruleDescription = txtAODescription.Text;
             string ruleEventIn = txtAOEventIn.Text;
             if (IsValidToAddRule(ruleName, ruleDescription, ruleEventIn)) {
                 Recur(tvOutput.Nodes);
                 SaveUpdatedAttributes();
                 AdvancedRecomendation captureEvent = new AdvancedRecomendation(ruleName, ruleDescription, ruleEventIn, captureEventNodes);
                 captureEvent.captureEventCategory = Convert.ToInt32(cboCaptureType.SelectedValue);
                 captureEvent.captureEventUsageCount = 0;
                 Advanced_Recommendations.InsertCaptureEvent(captureEvent);
                 CommonUtils.ShowInformation("Capture event inserted successfully!",false);
             }
         }
         LoadAvailableARtoList();
         SetAllCombos();
         BindCombos();
         lbAdvancedCE.Select();
     } catch (Exception ex) {
         CommonUtils.ShowError(ex.Message, ex);
     }
 }
 public ShowSearchDetailsForm(AdvancedRecomendation passedCaptureEvent)
 {
     InitializeComponent();
     captureEvent = passedCaptureEvent;
 }
 private void btnSaveCaptureEvent_Click(object sender, EventArgs e)
 {
     try {
         tvOutput.Select();
         Recur(tvOutput.Nodes);
         SaveUpdatedAttributes();
         AdvancedRecomendation captureEvent = new AdvancedRecomendation(txtAOName.Text, txtAODescription.Text, txtAOEventIn.Text, captureEventNodes);
         captureEvent.captureEventCategory = Convert.ToInt32(cboCaptureType.SelectedValue);
         captureEvent.captureEventUsageCount = CurrentlySelectedCaptureEvent.captureEventUsageCount;
         Advanced_Recommendations.SaveAdvancedRecomendationById(CurrentlySelectedCaptureEvent.CaptureEventId, captureEvent);
         LoadAvailableARtoList();
         SetAllCombos();
         BindCombos();
         ResetForm();
         CommonUtils.ShowInformation("Recommendation ["+captureEvent.CaptureEventName+"] saved.",false);
     } catch (Exception ex) {
         CommonUtils.ShowError(ex.Message, ex);
     }
 }