コード例 #1
0
 private void DeleteReportsFromLocalProfile(string strSQLProfileName)
 {
     try
     {
         FormAppByLocation AppByLocation = new FormAppByLocation();
         AppByLocation.LoadAllSavedSQLProfiles();
         if (AppByLocation.DeleteFromProfileList(strSQLProfileName))
         {
             AppByLocation.SaveAllSQLProfilesFromTheList();
         }
     }
     catch (Exception)
     {
     }
 }
コード例 #2
0
        private void RunApplicationByLocationOption(string reportName)
        {
            //MessageBox.Show("Assets By Location Selected");
            //Hide the tab first
            //Display the asset selection dialog..
            FormAppByLocation AppByLocation = new FormAppByLocation();

            if (AppByLocation.ShowDialog() == DialogResult.OK)
            {
                //run the query based on for the recordset..

                string strQuery = "SELECT APP._PUBLISHER, APP._NAME + ' (' + APP._VERSION + ')' AS [Application & Version], A._NAME AS Asset, L._NAME AS Location " +
                                  "FROM APPLICATIONS APP " +
                                  "INNER JOIN APPLICATION_INSTANCES APPI ON (APP._APPLICATIONID = APPI._APPLICATIONID) " +
                                  "INNER JOIN ASSETS A ON (A._ASSETID = APPI._ASSETID) " +
                                  "INNER JOIN LOCATIONS L ON (A._LOCATIONID = L._LOCATIONID) " +
                                  "WHERE APP._IGNORED = 0 ";

                string strSelectedApplicationSQL = "";
                string strSelectedLocationSQL    = "";

                if (AppByLocation.LastSavedSelectionItem.ApplicationItemList.Count > 0)
                {
                    strSelectedApplicationSQL = "AND (";

                    for (int i = 0; i < AppByLocation.LastSavedSelectionItem.ApplicationItemList.Count - 1; i++)
                    {
                        strSelectedApplicationSQL += "APP._NAME ='";
                        strSelectedApplicationSQL += AppByLocation.LastSavedSelectionItem.ApplicationItemList[i].ApplicationName;
                        strSelectedApplicationSQL += "' OR ";
                    }
                    strSelectedApplicationSQL += "APP._NAME =";
                    strSelectedApplicationSQL += AuditWizardDataAccess.PrepareSqlString(AppByLocation.LastSavedSelectionItem.ApplicationItemList[AppByLocation.LastSavedSelectionItem.ApplicationItemList.Count - 1].ApplicationName);
                    //strSelectedApplicationSQL += "";
                    strSelectedApplicationSQL += " )";

                    strQuery += strSelectedApplicationSQL;
                }
                if (AppByLocation.LastSavedSelectionItem.LocationNames.Count > 0)
                {
                    strSelectedLocationSQL = "AND (";

                    for (int i = 0; i < AppByLocation.LastSavedSelectionItem.LocationNames.Count - 1; i++)
                    {
                        strSelectedLocationSQL += "L._NAME ='";
                        strSelectedLocationSQL += AppByLocation.LastSavedSelectionItem.LocationNames[i];
                        strSelectedLocationSQL += "' OR ";
                    }
                    strSelectedLocationSQL += "L._NAME ='";
                    strSelectedLocationSQL += AppByLocation.LastSavedSelectionItem.LocationNames[AppByLocation.LastSavedSelectionItem.LocationNames.Count - 1];
                    strSelectedLocationSQL += "'";
                    strSelectedLocationSQL += " )";

                    strQuery += strSelectedLocationSQL;
                }
                strQuery += "ORDER BY L._NAME";

                ReportsWorkItemController wiController = (ReportsWorkItemController)workItem.Controller;
                wiController.RunSQLReport(reportName, strQuery);

                //Filter the recodset based on the dialog settings
                if (AppByLocation.SaveAsUserDefinedReport)
                {
                    List <string> _filterConditions = new List <string>();
                    _filterConditions.Add(strQuery);

                    BinaryFormatter bf  = new BinaryFormatter();
                    MemoryStream    mem = new MemoryStream();
                    bf.Serialize(mem, _filterConditions);
                    string lReportData = Convert.ToBase64String(mem.ToArray());
                    new ReportsDAO().Insert(AppByLocation.UserDefinedReportName, ReportsDAO.ReportType.SqlReport, lReportData);

                    RefreshView();
                    AppByLocation.SaveAllSQLProfilesFromTheList();
                }
                AppByLocation.SaveItemSelection();

                //Fill the Report grid
                //Show the grid to the user
            }
            else
            {
            }
        }