Example #1
0
        public static void UploadReports()
        {
            try
            {
                string workspaceCollection = ConfigurationManager.AppSettings["powerbiWorkspaceCollection"];
                string accessKey           = ConfigurationManager.AppSettings["powerbiAccessKey"];
                string apiUrl = ConfigurationManager.AppSettings["powerbiApiUrl"];

                var    workspace   = PowerBIHelper.CreateWorkspace(workspaceCollection, accessKey, apiUrl);
                string workspaceId = workspace.WorkspaceId;
                System.Web.HttpContext.Current.Application["WorkspaceID"] = workspace.WorkspaceId;

                string reportsPath = HttpContext.Current.Server.MapPath("~/ReportFiles");

                var files = Directory.GetFiles(reportsPath);
                foreach (string file in files)
                {
                    var temp        = file.Substring(file.LastIndexOf('\\') + 1);
                    var datasetName = temp.Substring(0, temp.Length - 5);
                    var filePath    = file;
                    var import      = ImportPbix(workspaceCollection, workspaceId, datasetName, filePath, accessKey, apiUrl);
                }
            }
            catch (Exception ex)
            {
                StorageClient.LogError(ex);
            }
        }
Example #2
0
        public DataSet FilterData(ArsonFilterModel filterData)
        {
            var     connectionString = ConfigurationManager.ConnectionStrings["UCR_DataEntities"];
            DataSet dsResult         = new DataSet();

            using (SqlConnection conn = new SqlConnection(connectionString.ConnectionString))
            {
                try
                {
                    SqlCommand command = new SqlCommand();
                    command.Connection  = conn;
                    command.CommandText = GenerateArsonORQuery(filterData);
                    command.CommandType = System.Data.CommandType.Text;
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    adapter.SelectCommand = command;

                    conn.Open();
                    adapter.Fill(dsResult);
                    conn.Close();
                    adapter.Dispose();
                    command.Dispose();
                }
                catch (Exception ex)
                {
                    StorageClient.LogError(ex);
                }
            }
            return(dsResult);
        }