Beispiel #1
0
        private void InitializeFormEdit()
        {
            lvSelectedItems.Items.Clear();
            _displayResultsAsAssetRegister = "";

            DataTable reportsDataTable = new ReportsDAO().GetReportById(_customReportId);

            tbCustomReportName.Text = reportsDataTable.Rows[0][1].ToString();;
            string lReportData = reportsDataTable.Rows[0][2].ToString();

            BinaryFormatter bf  = new BinaryFormatter();
            MemoryStream    mem = new MemoryStream(Convert.FromBase64String(lReportData));

            List <string> lReportDataList = (List <string>)bf.Deserialize(mem);

            // remove the locations item, just need the asset list
            foreach (string reportItem in lReportDataList)
            {
                if (reportItem.StartsWith("ASSET_REGISTER:"))
                {
                    _displayResultsAsAssetRegister = reportItem;
                }
            }

            lReportDataList.Remove(_displayResultsAsAssetRegister);

            if (_displayResultsAsAssetRegister != "")
            {
                cbAssetRegister.Checked = Convert.ToBoolean(_displayResultsAsAssetRegister.Substring(15));
            }

            selectAuditedDataFieldsControl.SelectedItems = lReportDataList;
            selectAuditedDataFieldsControl.RestoreSelections();
        }
        private void RunCustomReport_Click(object sender, EventArgs e)
        {
            if (cmbCustomReports.SelectedValue == null)
            {
                return;
            }

            DataTable reportsDataTable = new ReportsDAO().GetReportById(Convert.ToInt32(cmbCustomReports.SelectedValue));
            string    lReportData      = reportsDataTable.Rows[0][2].ToString();
            string    reportName       = ((DataRowView)(cmbCustomReports.SelectedItem)).Row.ItemArray[1].ToString();

            BinaryFormatter bf  = new BinaryFormatter();
            MemoryStream    mem = new MemoryStream(Convert.FromBase64String(lReportData));

            List <string> lReportDataList = (List <string>)bf.Deserialize(mem);

            // is this a 'group results by asset' report
            bool lDisplayAsAssetRegister = false;

            foreach (string lReportCondition in lReportDataList)
            {
                if (lReportCondition.StartsWith("ASSET_REGISTER:"))
                {
                    lDisplayAsAssetRegister = Convert.ToBoolean(lReportCondition.Substring(15));
                    break;
                }
            }

            ReportsWorkItemController wiController = (ReportsWorkItemController)workItem.Controller;

            wiController.RunCustomReport(reportName, lReportDataList);

            cbAssetRegister1.Checked = lDisplayAsAssetRegister;
        }
Beispiel #3
0
        private void buttonSaveAs_Click(object sender, EventArgs e)
        {
            if (tbCustomReportName.Text.Length == 0)
            {
                MessageBox.Show(
                    "Please enter a name for the custom report.",
                    "Save Custom Report",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);

                return;
            }

            SaveFields();

            BinaryFormatter bf  = new BinaryFormatter();
            MemoryStream    mem = new MemoryStream();

            bf.Serialize(mem, _selectedFields);

            string lReportData = Convert.ToBase64String(mem.ToArray());

            if (_editingReport)
            {
                new ReportsDAO().Update(_customReportId, tbCustomReportName.Text, lReportData);
            }
            else
            {
                DataTable lExistingReports = new ReportsDAO().GetReportsByTypeAndName(ReportsDAO.ReportType.CustomReport, tbCustomReportName.Text);

                if (lExistingReports.Rows.Count > 0)
                {
                    if (MessageBox.Show(
                            "A custom report already exists with this name." + Environment.NewLine + Environment.NewLine +
                            "Do you wish to overwrite?",
                            "Save Custom Report",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        new ReportsDAO().Update(Convert.ToInt32(lExistingReports.Rows[0][0]), tbCustomReportName.Text, lReportData);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    new ReportsDAO().Insert(tbCustomReportName.Text, ReportsDAO.ReportType.CustomReport, lReportData);
                }
            }

            bnSaveComplianceReport.Enabled = false;
            _reportSaved = true;
            DesktopAlert.ShowDesktopAlert(String.Format("The custom report '{0}' has been saved.", tbCustomReportName.Text));
        }
 /// <summary>
 /// Deletes a report from the database.
 /// </summary>
 /// <returns>true if the deletion is successful.</returns>
 public bool DeleteReport()
 {
     try
     {
         ReportsDAO.DeleteReport(this.ReportId);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #5
0
        public bool SendReportsViaEmail()
        {
            List <ReportSubscription> subscriptions = new List <ReportSubscription>();

            using (IDataReader dr = new ReportsDAO().GetSubscriptions())
            {
                //napchac do subscriptions
                while (dr.Read())
                {
                    ReportSubscription s = new ReportSubscription();
                    s.ReportName   = dr["ReportName"].ToString();
                    s.ReportTitle  = "Raport z systemu eSoda";
                    s.Format       = dr["Format"].ToString();
                    s.Filename     = "Raport";
                    s.EmailAddress = dr["emailAddress"].ToString();
                    XElement p = XElement.Parse(dr["xmlParams"].ToString());
                    s.ParamOUID = p.Descendants("ouID").First().Value;
                    s.ParamYear = p.Descendants("year").FirstOrDefault() != null?p.Descendants("year").FirstOrDefault().Value : null;

                    s.ParamJRWA = p.Descendants("jrwa").FirstOrDefault() != null?p.Descendants("jrwa").FirstOrDefault().Value : null;

                    s.ParamDaysFrom = p.Descendants("daysFrom").FirstOrDefault() != null?p.Descendants("daysFrom").FirstOrDefault().Value : null;

                    s.ParamDaysTo = p.Descendants("daysTo").FirstOrDefault() != null?p.Descendants("daysTo").FirstOrDefault().Value : null;

                    if (s.ParamJRWA == "")
                    {
                        s.ParamJRWA = null;
                    }
                    if (s.ParamDaysFrom == "")
                    {
                        s.ParamDaysFrom = null;
                    }
                    if (s.ParamDaysTo == "")
                    {
                        s.ParamDaysTo = null;
                    }
                    subscriptions.Add(s);
                }
            }


            foreach (ReportSubscription subsc in subscriptions)
            {
                SendReport(subsc);
            }



            return(true);
        }
Beispiel #6
0
        public FormSQLReport(int aReportId)
        {
            InitializeComponent();

            DataTable reportsDataTable = new ReportsDAO().GetReportById(aReportId);

            tbReportName.Text = reportsDataTable.Rows[0][1].ToString();

            BinaryFormatter bf  = new BinaryFormatter();
            MemoryStream    mem = new MemoryStream(Convert.FromBase64String(reportsDataTable.Rows[0][2].ToString()));

            List <string> lSqlStringList = (List <string>)bf.Deserialize(mem);

            textBoxSQLString.Text = lSqlStringList[0];

            _reportSaved = true;
        }
        private void bnRunSQLReport_Click(object sender, EventArgs e)
        {
            if (cmbSQLReports.SelectedValue == null)
            {
                return;
            }

            DataTable reportsDataTable = new ReportsDAO().GetReportById(Convert.ToInt32(cmbSQLReports.SelectedValue));
            string    lReportData      = reportsDataTable.Rows[0][2].ToString();
            string    reportName       = ((DataRowView)(cmbSQLReports.SelectedItem)).Row.ItemArray[1].ToString();

            BinaryFormatter bf              = new BinaryFormatter();
            MemoryStream    mem             = new MemoryStream(Convert.FromBase64String(lReportData));
            List <string>   lReportDataList = (List <string>)bf.Deserialize(mem);

            ReportsWorkItemController wiController = (ReportsWorkItemController)workItem.Controller;

            wiController.RunSQLReport(reportName, lReportDataList[0]);
        }
        /// <summary>
        /// Creates a report that will be saved to the database.
        /// </summary>
        /// <returns>success for successful insert, else will return the error message.</returns>
        public string CreateReport(IContentLocator contentLocator)
        {
            foreach (var document in Media.Where(document => document != null))
            {
                AddUrlList(document.Url);
                document.Save(contentLocator);
            }

            try
            {
                ReportsDAO.CreateReport(ReportTypeId, Message,
                                        Latitude, Longitude, Location, DateReported,
                                        User.UserName, UrlList);
                return("success");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Beispiel #9
0
        public FormComplianceReport(ReportsWorkItemController wiController, int aReportId)
        {
            InitializeComponent();
            lblUnits.Text = "";
            _wiController = wiController;
            _reportSaved  = false;
            cbBooleanValue.SelectedIndex = 0;

            DataTable reportsDataTable = new ReportsDAO().GetReportById(aReportId);

            _originalFileName = reportsDataTable.Rows[0][1].ToString();
            tbReportName.Text = _originalFileName;
            string lReportData = reportsDataTable.Rows[0][2].ToString();

            BinaryFormatter bf  = new BinaryFormatter();
            MemoryStream    mem = new MemoryStream(Convert.FromBase64String(lReportData));

            _filterConditions = (List <string>)bf.Deserialize(mem);

            selectedFields.Focus();
        }
        private void SaveForm()
        {
            DataTable lExistingReports = new ReportsDAO().GetReportsByTypeAndName(ReportsDAO.ReportType.CustomReport, textBox1.Text);

            if (lExistingReports.Rows.Count > 0)
            {
                MessageBox.Show(
                    "A custom report already exists with the name '" + textBox1.Text + "'.",
                    "Save Custom Report",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);

                return;
            }
            else
            {
                _reportName = textBox1.Text;
            }

            Close();
        }
        /// <summary>
        /// Gets a list of reports from the database.
        /// </summary>
        /// <returns>The list of Report object.</returns>
        public static List <Report> GetReports()
        {
            SqlDataReader reader  = ReportsDAO.GetReports();
            List <Report> reports = new List <Report>();

            try
            {
                int oReportId    = reader.GetOrdinal("ReportId");
                int oReportType  = reader.GetOrdinal("ReportType");
                int oMarkerImage = reader.GetOrdinal("MarkerImage");
                int oMessage     = reader.GetOrdinal("Message");
                int oLatitude    = reader.GetOrdinal("Latitude");
                int oLongitude   = reader.GetOrdinal("Longitude");
                int oLocation    = reader.GetOrdinal("Location");
                int oTimeStamp   = reader.GetOrdinal("TimeStamp");
                int oUserName    = reader.GetOrdinal("UserName");
                int oFirstName   = reader.GetOrdinal("FirstName");
                int oLastName    = reader.GetOrdinal("LastName");
                int oGender      = reader.GetOrdinal("Gender");
                int oEmail       = reader.GetOrdinal("Email");
                int oPhoneNumber = reader.GetOrdinal("PhoneNumber");
                int oAddress     = reader.GetOrdinal("Address");
                int oZipCode     = reader.GetOrdinal("ZipCode");

                while (reader.Read())
                {
                    Report report = new Report
                    {
                        ReportId     = Convert.ToInt32(reader[oReportId]),
                        ReportType   = reader[oReportType].ToString(),
                        MarkerImage  = reader[oMarkerImage].ToString(),
                        Message      = reader[oMessage].ToString(),
                        Latitude     = reader[oLatitude].ToString(),
                        Longitude    = reader[oLongitude].ToString(),
                        Location     = reader[oLocation].ToString(),
                        DateReported = Convert.ToDateTime(reader[oTimeStamp]),
                        User         = new User
                        {
                            UserName    = reader[oUserName].ToString(),
                            FirstName   = reader[oFirstName].ToString(),
                            LastName    = reader[oLastName].ToString(),
                            Gender      = reader[oGender].ToString(),
                            Email       = reader[oEmail].ToString(),
                            PhoneNumber = reader[oPhoneNumber].ToString(),
                            Address     = reader[oAddress].ToString(),
                            ZipCode     = reader[oZipCode].ToString()
                        }
                    };

                    for (int i = 1; i <= 5; i++)
                    {
                        String mediaUrl = reader["Media" + i].ToString();
                        if (!String.IsNullOrEmpty(mediaUrl))
                        {
                            report.AddUrlList(mediaUrl);
                        }
                    }
                    reports.Add(report);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                reader.Close();
            }
            return(reports);
        }
Beispiel #12
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (checkBoxSave.Checked == true)
            {
                if (textBoxUserDefinedReportName.Text == "")
                {
                    MessageBox.Show("Please Enter the Report Name..");
                    textBoxUserDefinedReportName.Focus();
                    return;
                }
                DataTable lExistingReports = new ReportsDAO().GetReportsByTypeAndName(ReportsDAO.ReportType.SqlReport, textBoxUserDefinedReportName.Text);

                if (lExistingReports.Rows.Count > 0)
                {
                    MessageBox.Show("A SQL report already exists with this name. Please change the Report Name.");
                    textBoxUserDefinedReportName.Focus();
                    return;
                }
                SaveAsUserDefinedReport = true;
                UserDefinedReportName   = textBoxUserDefinedReportName.Text;
            }
            this.Cursor = Cursors.WaitCursor;

            LastSavedSelectionItem.ApplicationItemList.Clear();
            LastSavedSelectionItem.LocationNames.Clear();
            LastSavedSelectionItem.AllApplications = false;
            LastSavedSelectionItem.AllLocations    = false;

            // Check for all applications being selected and if so set the relevent flag, otherwise add the selected applications				// 8.3.4 - CMD
            if (treeViewApplications.Nodes[0].Checked)
            {
                LastSavedSelectionItem.AllApplications = true;
            }
            else
            {
                for (int i = 0; i < treeViewApplications.Nodes.Count; i++)
                {
                    AddAllCheckedChildNodes(treeViewApplications.Nodes[i], true);
                }
            }

            // Same for Locations - ensure we capture the Select All situation																	// 8.3.4 - CMD
            if (treeViewLocations.Nodes[0].Checked)
            {
                LastSavedSelectionItem.AllLocations = true;
            }
            else
            {
                for (int i = 0; i < treeViewLocations.Nodes.Count; i++)
                {
                    AddAllCheckedChildNodes(treeViewLocations.Nodes[i], false);
                }
            }

            if ((!LastSavedSelectionItem.AllApplications) && (LastSavedSelectionItem.ApplicationItemList.Count == 0))
            {
                MessageBox.Show("Please check at least one Application..");
                this.Cursor = Cursors.Default;
                return;
            }

            if ((!LastSavedSelectionItem.AllLocations) && (LastSavedSelectionItem.LocationNames.Count == 0))
            {
                MessageBox.Show("Please check at least one Location...");
                this.Cursor = Cursors.Default;
                return;
            }

            if (checkBoxSave.Checked == true)
            {
                LoadAllSavedSQLProfiles();

                SelectionItem NewItem = new SelectionItem();

                NewItem.ItemName            = UserDefinedReportName;
                NewItem.AllApplications     = LastSavedSelectionItem.AllApplications;
                NewItem.AllLocations        = LastSavedSelectionItem.AllLocations;
                NewItem.ApplicationItemList = LastSavedSelectionItem.ApplicationItemList;
                NewItem.LocationNames       = LastSavedSelectionItem.LocationNames;

                SQLProfileListManager.SQLProfileItemList.Add(NewItem);
            }

            DialogResult = DialogResult.OK;

            this.Close();
        }
 public void Cleanup()
 {
     _testReport = null;
     ReportsDAO.DeleteReportTest();
 }
Beispiel #14
0
        private void bnSave_Click(object sender, EventArgs e)
        {
            if (!textBoxSQLString.Text.ToUpper().StartsWith("SELECT"))
            {
                MessageBox.Show(
                    "Only SELECT statements can be executed from this dialog.",
                    "SQL Query",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                return;
            }

            if (tbReportName.Text == "")
            {
                MessageBox.Show(
                    "Please enter a name for the SQL report.",
                    "Save SQL Report",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                return;
            }

            if (textBoxSQLString.Text.Length == 0)
            {
                MessageBox.Show(
                    "Please enter a SQL string to run against the database.",
                    "Save SQL Report",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                return;
            }

            List <string> _filterConditions = new List <string>();

            _filterConditions.Add(textBoxSQLString.Text);

            BinaryFormatter bf  = new BinaryFormatter();
            MemoryStream    mem = new MemoryStream();

            bf.Serialize(mem, _filterConditions);
            string lReportData = Convert.ToBase64String(mem.ToArray());

            DataTable lExistingReports = new ReportsDAO().GetReportsByTypeAndName(ReportsDAO.ReportType.SqlReport, tbReportName.Text);

            if (lExistingReports.Rows.Count > 0)
            {
                if (MessageBox.Show(
                        "A SQL report already exists with this name." + Environment.NewLine + Environment.NewLine +
                        "Do you wish to overwrite?",
                        "Save SQL Report",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    new ReportsDAO().Update(Convert.ToInt32(lExistingReports.Rows[0][0]), tbReportName.Text, lReportData);
                }
                else
                {
                    return;
                }
            }
            else
            {
                new ReportsDAO().Insert(tbReportName.Text, ReportsDAO.ReportType.SqlReport, lReportData);
            }

            DesktopAlert.ShowDesktopAlert(String.Format("The SQL report '{0}' has been saved.", tbReportName.Text));
            bnSave.Enabled = false;
            _reportSaved   = true;
        }