Beispiel #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int columnIndex = e.ColumnIndex;
                int rowIndex    = e.RowIndex;

                if (columnIndex >= 0 && rowIndex >= 0)
                {
                    if (columnIndex == 0) // check box
                    {
                        if (dgvProjects.Rows[rowIndex].Cells["checkBoxesColumn"].Value != null)
                        {
                            dgvProjects.Rows[rowIndex].Cells["checkBoxesColumn"].Value = !(bool)dgvProjects.Rows[rowIndex].Cells["checkBoxesColumn"].Value;
                        }
                        else
                        {
                            dgvProjects.Rows[rowIndex].Cells["checkBoxesColumn"].Value = true;
                        }

                        return;
                    }

                    if (dgvProjects.Columns[columnIndex].HeaderText == Constants.COL_NAME_REMARK)
                    {
                        EditRemark(columnIndex, rowIndex);

                        return;
                    }
                    if (dgvProjects.SelectedRows.Count > 0)
                    {
                        IsActive = true;
                        CxWSSingleResultData reportQueryItemPathResult = dgvProjects.SelectedRows[0].Cells["ResultEntity"].Value as CxWSSingleResultData;
                        int scanId = -1;
                        Int32.TryParse(dgvProjects.SelectedRows[0].Cells["ScanId"].Value.ToString(), out scanId);

                        if (reportQueryItemPathResult == null)
                        {
                            return;
                        }

                        this.SelectedRowChanged(this, new ResultData(reportQueryItemPathResult, scanId, this.SelectedNode));
                        UpdateGridShowPath();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Create().Error(ex.ToString());
            }
        }
Beispiel #2
0
        private void cbAssign_SelectionChangeCommitted(object sender, EventArgs e)
        {
            bool needRefresh = false;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                ComboBox               senderComboBox = (ComboBox)sender;
                ComboBoxItem1          cbItem         = (ComboBoxItem1)senderComboBox.SelectedItem;
                string                 item           = cbItem.Value;
                List <ResultStateData> list           = new List <ResultStateData>();
                foreach (DataGridViewRow row in dgvProjects.Rows)
                {
                    if (row.Cells["checkBoxesColumn"].Value != null && (bool)row.Cells["checkBoxesColumn"].Value)
                    {
                        CxWSSingleResultData reportQueryItemPathResult = row.Cells["ResultEntity"].Value as CxWSSingleResultData;
                        long pathId   = reportQueryItemPathResult.PathId;
                        long resultId = Convert.ToInt64(row.Cells["ScanId"].Value);
                        list.Add(new ResultStateData()
                        {
                            data            = item,
                            PathId          = pathId,
                            Remarks         = string.Empty,
                            ResultLabelType = (int)CxViewerAction.Helpers.ResultLabelTypeEnum.Assign,
                            scanId          = resultId
                        });
                    }
                }

                if (list.Count > 0)
                {
                    needRefresh = PerspectiveHelper.UpdateResultState(list.ToArray());
                }

                if (needRefresh)
                {
                    this.Refresh(this, currentNodedata);
                }
            }
            catch (Exception ex)
            {
                Logger.Create().Error(ex.ToString());
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Beispiel #3
0
        public void SelectRow()
        {
            if (dgvProjects.SelectedRows.Count > 0)
            {
                IsActive = true;
                CxWSSingleResultData reportQueryItemPathResult = dgvProjects.SelectedRows[0].Cells["ResultEntity"].Value as CxWSSingleResultData;
                int scanId = -1;
                Int32.TryParse(dgvProjects.SelectedRows[0].Cells["ScanId"].Value.ToString(), out scanId);

                if (reportQueryItemPathResult == null)
                {
                    return;
                }

                this.SelectedRowChanged(this, new ResultData(reportQueryItemPathResult, scanId, this.SelectedNode));
                UpdateGridShowPath();
            }
        }
Beispiel #4
0
        internal static List <CxWSSingleResultData> ParseQueryItemPathResult(XmlNode xmlNode)
        {
            List <CxWSSingleResultData> outputItems = new List <CxWSSingleResultData>();

            foreach (XmlNode resultNode in xmlNode.ChildNodes)
            {
                int    severity                = 0;
                string assignedUser            = string.Empty;
                string status                  = string.Empty;
                string fullSourceFileName      = resultNode.FirstChild.FirstChild.ChildNodes[0].InnerText;
                string sourceFile              = fullSourceFileName;
                string sourceFolder            = Path.DirectorySeparatorChar.ToString();
                string fullDestinationFileName = resultNode.FirstChild.LastChild.ChildNodes[0].InnerText;
                string destinationFile         = fullDestinationFileName;
                string destinationFolder       = Path.DirectorySeparatorChar.ToString();
                int    state              = 0;
                string lineValue          = resultNode.Attributes["Line"].Value ?? resultNode.Attributes["line"].Value;
                string falsePositiveValue = resultNode.Attributes["FalsePositive"].Value ?? resultNode.Attributes["falsePositive"].Value;
                string pathIdValue        = resultNode.FirstChild.Attributes["PathId"].Value ?? resultNode.FirstChild.Attributes["pathId"].Value;
                try
                {
                    XmlAttribute severityAttribute = xmlNode.Attributes["severity"] ?? xmlNode.Attributes["Severity"];
                    if (severityAttribute.Value != null)
                    {
                        severity = (int)ReportQueryResult.SeverityTypeFromString(severityAttribute.Value);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Create().Error(ex.ToString());
                }
                try
                {
                    sourceFolder = Path.GetDirectoryName(fullSourceFileName);
                    if (string.IsNullOrEmpty(sourceFolder))
                    {
                        sourceFolder = Path.DirectorySeparatorChar.ToString();
                    }
                }
                catch (Exception ex)
                {
                    Logger.Create().Error(ex.ToString());
                }
                try
                {
                    sourceFile = Path.GetFileName(fullSourceFileName);
                }
                catch (Exception ex)
                {
                    Logger.Create().Error(ex.ToString());
                }

                try
                {
                    destinationFolder = Path.GetDirectoryName(fullDestinationFileName);
                    if (string.IsNullOrEmpty(destinationFolder))
                    {
                        destinationFolder = Path.DirectorySeparatorChar.ToString();
                    }
                }
                catch (Exception ex)
                {
                    Logger.Create().Error(ex.ToString());
                }
                try
                {
                    destinationFile = Path.GetFileName(fullDestinationFileName);
                }
                catch (Exception ex)
                {
                    Logger.Create().Error(ex.ToString());
                }

                try
                {
                    assignedUser = resultNode.Attributes["AssignToUser"].Value;
                }
                catch (Exception ex)
                {
                    Logger.Create().Error(ex.ToString());
                }
                try
                {
                    status = resultNode.Attributes["Status"].Value ?? resultNode.Attributes["status"].Value;
                }
                catch (Exception ex)
                {
                    Logger.Create().Error(ex.ToString());
                }

                try
                {
                    state = Convert.ToInt32(resultNode.Attributes["state"].Value);
                }
                catch (Exception ex)
                {
                    Logger.Create().Error(ex.ToString());
                    try
                    {
                        state = falsePositiveValue != null?Convert.ToInt32(Convert.ToBoolean(falsePositiveValue)) : 0;
                    }
                    catch (Exception exc)
                    {
                        Logger.Create().Error(exc.ToString());
                    }
                }


                CxWSSingleResultData reportQueryItemResult = new CxWSSingleResultData
                {
                    SourceFile   = sourceFile,
                    SourceFolder = sourceFolder,
                    SourceLine   = lineValue != null?Convert.ToInt32(lineValue) : 0,
                                       SourceObject                                 = resultNode.FirstChild.FirstChild.ChildNodes[4].InnerText,
                                       Comment                                      = resultNode.Attributes["Remark"].Value ?? resultNode.Attributes["remark"].Value,
                                       PathId                                       = pathIdValue != null?Convert.ToInt32(pathIdValue) : 0,
                                                                       Severity     = severity,
                                                                       AssignedUser = assignedUser,
                                                                       ResultStatus = ConvertResultStatusToEnum(status),
                                                                       State        = state,
                                                                       DestFile     = destinationFile,
                                                                       DestFolder   = destinationFolder,
                                                                       DestLine     = Convert.ToInt64(resultNode.FirstChild.LastChild.ChildNodes[1].InnerText),
                                                                       DestObject   = resultNode.FirstChild.LastChild.ChildNodes[4].InnerText,
                };

                outputItems.Add(reportQueryItemResult);
            }


            return(outputItems);
        }
Beispiel #5
0
 public ResultData(CxWSSingleResultData result, int scanId, TreeNodeData nodeData)
 {
     Result   = result;
     ScanId   = scanId;
     NodeData = nodeData;
 }
Beispiel #6
0
        private void EditRemark(int columnIndex, int rowIndex)
        {
            if (CommonData.IsWorkingOffline)
            {
                MessageBox.Show("You are working offline. \rCannot update data", "Error", MessageBoxButtons.OK);
                return;
            }
            int currentRowIndex    = dgvProjects.CurrentCell.RowIndex;
            int currentColumnIndex = dgvProjects.CurrentCell.ColumnIndex;

            CxWSSingleResultData reportQueryItemPathResult = dgvProjects.Rows[rowIndex].Cells["ResultEntity"].Value as CxWSSingleResultData;

            long pathId   = reportQueryItemPathResult.PathId;
            long resultId = Convert.ToInt64(dgvProjects.Rows[rowIndex].Cells["ScanId"].Value);

            CxViewerAction.CxVSWebService.CxWSResultPath resultPath = PerspectiveHelper.GetPathCommentsHistory(resultId, pathId);
            string commentHistory = string.Empty;

            if (resultPath != null && !string.IsNullOrEmpty(resultPath.Comment))
            {
                commentHistory = resultPath.Comment;
            }

            string[]      commentsArr = commentHistory.Split(Convert.ToChar(255));
            StringBuilder sb          = new StringBuilder();

            for (int i = 0; i < commentsArr.Length; i++)
            {
                if (!string.IsNullOrEmpty(commentsArr[i]))
                {
                    sb.Append(commentsArr[i].ToString());
                    if (i != commentsArr.Length)
                    {
                        sb.Append(Environment.NewLine);
                    }
                }
            }

            EditRemarkPopUp remarkPopUp = new EditRemarkPopUp("", sb.ToString());

            DialogResult result = remarkPopUp.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            string remark = remarkPopUp.Remark;

            if (String.IsNullOrEmpty(remark))
            {
                return;
            }
            if (ChangeResultHelper.EditRemark(resultId, pathId, remark) == Entities.Enum.ProjectScanStatuses.Success)
            {
                reportQueryItemPathResult.Comment = remark;
                dgvProjects.Rows[rowIndex].Cells[columnIndex].Value = remark;
                dgvProjects.Rows[rowIndex].Selected = true;
                dgvProjects.CurrentCell             = dgvProjects.Rows[rowIndex].Cells[columnIndex];
            }
        }