Audit.net with azure table storage - asp.net-mvc

How can i store audit data in azure table storage,audit.net provides (https://github.com/thepirat000/Audit.NET#data-providers-included)
sqldataprovider only can you please help me.
Thanks

Now you can use the Azure Table data provider to store your audit events on azure tables. It is included from version 12.1.9 on the Audit.NET.AzureStorage package.
You can configure the columns dynamically via an anonymous object or dictionary, or implementing your own TableEntity class.
For example:
Audit.Core.Configuration.Setup()
.UseAzureTableStorage(_ => _
.ConnectionString("your cnn string")
.TableName("Events")
.EntityBuilder(e => e
.PartitionKey($"Events{ev.StartDate:yyyyMM}")
.Columns(c => c.FromObject(ev => new
{
Date = ev.StartDate,
User = ev.Environment.UserName,
...
}))));
Take a look at the README file here.
For further problems, note you can also open an issue instead of asking on SO. or ask on the Audit.NET Gitter chat

Audit.Core.Configuration.DataProvider = new AzureTableDataprovider()
{
ConnectionString = ConfigurationManager.ConnectionStrings["AuditDbConnection"].ToString(),
Schema = "dbo",
TableName = "tblbateventsauditing",
IdColumnName = "EventId",
JsonColumnName = "Data"
};

Related

Autodesk Simple Viewer - "Could not list models. "

I'm trying to implement the code example in this repo:
https://github.com/autodesk-platform-services/aps-simple-viewer-dotnet
While launching in debugging mode, I get an error in the AuthController.cs says:
Could not list models. See the console for more details
I didn't make any significant changes to the original code, I only changed the env vars (client id, secret etc..)
The error is on the below function:
async function setupModelSelection(viewer, selectedUrn) {
const dropdown = document.getElementById('models');
dropdown.innerHTML = '';
try {
const resp = await fetch('/api/models');
if (!resp.ok) {
throw new Error(await resp.text());
}
const models = await resp.json();
dropdown.innerHTML = models.map(model => `<option value=${model.urn} ${model.urn === selectedUrn ? 'selected' : ''}>${model.name}</option>`).join('\n');
dropdown.onchange = () => onModelSelected(viewer, dropdown.value);
if (dropdown.value) {
onModelSelected(viewer, dropdown.value);
}
} catch (err) {
alert('Could not list models. See the console for more details.');
console.error(err);
}
}
I get an access token so my client id and secret are probably correct, I also added the app to the cloud hub, what could be the problem, why the app can't find the projects in the hub?
I can only repeat what AlexAR said - the given sample is not for accessing files from user hubs like ACC/BIM 360 Docs - for that follow this: https://tutorials.autodesk.io/tutorials/hubs-browser/
To address the specific error. One way I can reproduce that is if I set the APS_BUCKET variable to something simple that has likely been used by someone else already, e.g. "mybucket", and so I'll get an error when trying to access the files in it, since it's not my bucket. Bucket names need to be globally unique. If you don't want to come up with a unique name yourself, then just do not declare the APS_BUCKET environment variable and the sample will generate a bucket name for you based on the client id of your app.

Odata Query Batch Request - Filter not working

We are using SAP SDK 3.25.0 and calling a batch request Read query passing some filters. I am getting the response of all the records and it can be seen that the filter is not working properly.
I have referred this blog here but I am getting the same issue of decode URL issue YY1_QuantityContractTracki?$filter=((CustomerName eq %27Ford%27) and (SalesSchedulingAgreement eq %270030000141%27)) and (PurchaseOrderByCustomer eq %27TEST%27)&$select=SalesSchedulingAgreement,PurchaseOrderByCustomer,Customer,CustomerName,SalesSchedulingAgreementItem,Material,MaterialByCustomer&$format=json
Below is the query program which I am using.
Am I missing something here. Please let us know
Thanks,
Arun Pai
final BatchRequestBuilder builder = BatchRequestBuilder.withService("/sap/opu/odata/sap/YY1_QUANTITYCONTRACTTRACKI_CDS");
for (Contract contract : contracts) {
FilterExpression mainFilter = new FilterExpression("CustomerName", "eq", ODataType.of(contract.getCustomerName()))
.and(new FilterExpression("SalesSchedulingAgreement", "eq", ODataType.of(contract.getSchAgrmntNo())))
.and(new FilterExpression("PurchaseOrderByCustomer", "eq", ODataType.of(contract.getCustRefNo())));
final ODataQuery oDataQuery = ODataQueryBuilder
.withEntity(sapConfig.getEssentialsContractServiceUrl(),
sapConfig.getEssentialsContractListEntity())
.select("SalesSchedulingAgreement", "PurchaseOrderByCustomer", "Customer", "CustomerName",
"SalesSchedulingAgreementItem", "Material", "MaterialByCustomer")
.filter(mainFilter)
.build();
builder.addQueryRequest(oDataQuery);
}
final BatchRequest batchRequest = builder.build();
final BatchResult batchResult = batchRequest.execute(httpClient);
Update
I have changed the version to 3.35.0 today with connectivity version 1.40.11 but it did'nt work either.
Below is the log request which gets printed in the console
2021-01-15 19:15:03.831 INFO 42640 --- [io-8084-exec-10] c.s.c.s.o.c.impl.BatchRequestImpl : --batch_123
Content-Type: application/http
Content-Transfer-Encoding: binary
GET YY1_QuantityContractTracki?%24filter%3D%28%28CustomerName+eq+%2527Ford27%29+and+%28SalesSchedulingAgreement+eq+%25270030000141%2527%29%29+and+%28PurchaseOrderByCustomer+eq+%2527TEST%2527%29%26%24select%3DSalesSchedulingAgreement%2CPurchaseOrderByCustomer%2CCustomer%2CCustomerName%2CSalesSchedulingAgreementItem%2CMaterial%2CMaterialByCustomer%26%24format%3Djson HTTP/1.1
Accept: application/json;odata=verbose
--batch_123--
For your information: with the release of SAP Cloud SDK 3.41.0 we enabled support for read operations in OData batch requests on the type-safe API. Please find the chapter in the respective documentation. You would no longer need to use the Generic OData Client of SAP Cloud SDK as suggested in the other response. Example:
BusinessPartnerService service;
BusinessPartnerAddress addressToCreate1;
BusinessPartnerAddress addressToCreate2;
BusinessPartnerFluentHelper requestTenEntities = service.getAllBusinessPartner().top(10);
BusinessPartnerByKeyFluentHelper requestSingleEntity = service.getBusinessPartnerByKey("bupa9000");
BatchResponse result =
service
.batch()
.addReadOperations(requestTenEntities)
.addReadOperations(requestSingleEntity)
.executeRequest(destination);
List<BusinessPartner> entities = result.getReadResult(requestTenEntities);
BusinessPartner entity = result.getReadResult(requestSingleEntity);
Update (22.03.2021)
With the release of SAP Cloud SDK 3.41.0 this week we'll enable support for read operations in OData batch requests on the type-safe API. Please find the chapter in the respective documentation.
Example:
BusinessPartnerService service;
BusinessPartnerAddress addressToCreate1;
BusinessPartnerAddress addressToCreate2;
BusinessPartnerFluentHelper requestTenEntities = service.getAllBusinessPartner().top(10);
BusinessPartnerByKeyFluentHelper requestSingleEntity = service.getBusinessPartnerByKey("bupa9000");
BatchResponse result =
service
.batch()
.addReadOperations(requestTenEntities)
.addReadOperations(requestSingleEntity)
.executeRequest(destination);
List<BusinessPartner> entities = result.getReadResult(requestTenEntities);
BusinessPartner entity = result.getReadResult(requestSingleEntity);
Original response:
I'm from the SAP Cloud SDK team. Generally we recommend our users to generate classes for their OData service interactions. This way you can easily make sure that requests are according to specification, while type safety is taken care of.
Unfortunately I cannot help you with the API of BatchRequestBuilder, BatchRequest or BatchResult because they are not directly a part of SAP Cloud SDK and not maintained by us. Instead we suggest our own request builders.
If the generation of classes, as linked above, is not an option for you, then I would suggest to try our expert API featuring the Generic OData Client of SAP Cloud SDK. This is the code that we would also use internally for our generated request builders:
String servicePath = "/sap/opu/odata/sap/YY1_QUANTITYCONTRACTTRACKI_CDS";
ODataRequestBatch requestBatch = new ODataRequestBatch(servicePath, ODataProtocol.V2);
Map<Contract, ODataRequestRead> batchedRequests = new HashMap<>();
// iterate over contracts, construct OData query objects and add them to the OData batch request builder
for (Contract contract : contracts) {
String entityName = sapConfig.getEssentialsContractListEntity();
String serviceUrl = sapConfig.getEssentialsContractServiceUrl();
StructuredQuery structuredQuery = StructuredQuery.onEntity(entityName, ODataProtocol.V2);
structuredQuery.select("SalesSchedulingAgreement", "PurchaseOrderByCustomer", "Customer", "CustomerName", "SalesSchedulingAgreementItem", "Material", "MaterialByCustomer");
structuredQuery.filter(FieldReference.of("SalesSchedulingAgreement").equalTo(contract.getSchAgrmntNo()));
structuredQuery.filter(FieldReference.of("PurchaseOrderByCustomer").equalTo(contract.getCustRefNo()));
String encodedQuery = structuredQuery.getEncodedQueryString();
ODataRequestRead requestRead = new ODataRequestRead(serviceUrl, entityName, encodedQuery, ODataProtocol.V2);
batchedRequests.put(contract, requestRead);
requestBatch.addRead(requestRead);
}
// execute the OData batch request
ODataRequestResultMultipartGeneric batchResult = requestBatch.execute(httpClient);
// extract information from batch response, by referring to the individual OData request references
for( Map.Entry<Contract, ODataRequestRead> requestMapping : batchedRequests.entrySet() ) {
ODataRequestResultGeneric queryResult = batchResult.getResult(requestMapping.getValue());
List<Map<String, Object>> itemsForQuery = queryResult.asListOfMaps();
}
Kind regards
Alexander

Tfs WIQL to object converter

this is my first question :)
I was wondering, if there is something like a WIQL (TFS Work Item Query Language) parser.
I'm dealing with TFS Queries and i have to programatically change some fields of them. Searching for a parses or something had no results to me. Can you help me?
NOTE: I have to change the queries themselves. Not any workitems.
Thank you Guys.
You can use REST api or the .net api:
REST API:
POST https://{instance}/defaultcollection/[{project}/]_apis/wit/wiql?api-version={version}
Content-type: Application/json
{
"query": string
}
.net API:
// credentials if required
System.Net.ICredentials credentials = new System.Net.NetworkCredential("User", "Password", "Domain");
// create the collection
Microsoft.TeamFoundation.Client.TfsTeamProjectCollection teamProjectCollection =
new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(new Uri(#"http://tfsServer:8080/tfs/collection"), credentials);
// check we are authenticated
teamProjectCollection.EnsureAuthenticated();
// create the work item store
Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore Store =
(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore)
teamProjectCollection.GetService(typeof(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore));
// create a query to select tasks
string query = "SELECT * FROM WorkItems WHERE [System.WorkItemType] = 'Task' AND [System.IterationPath] = '#IterationPath' ORDER BY [System.WorkItemType], [System.Id]";
// replace the iteration
query = query.Replace("#IterationPath", "IterationPath");
// query the store!
Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemCollection WIC = Store.Query(query);

Querying Fusion-Table from PHP

My case is as follows:
I have a MySQL database which I exported and inserted in Fusion Table. Now I need to modify the php page in querying the data from the Fusion Table instead of the localhost db.
I've read about querying Fusion-Tables from the Developers guide, but it refers to a GData Java Library and the SQL API. On another site I saw there were other libraries that can be used for querying, including Zend framework where PHP relies on, which is relevant in my case. However, I haven't stumbled upon any sample or tutorial which simply shows a php page on how you can query a simple cell, row or column from where I can just modify and improve the coding to apply it on the design.
My questions are:
Do I need to install/upload on the hosting space some library?
Is there a php sample & tutorial on querying Fusion Table data, I might have missed?
Can anyone provide me with a clue how you would query for example the Latitude info of the row with ID 5? (pages are retrieved using the path: articles.php?lang=en&pg=comm_en&m=view&commID=88
Below is the coding I have in comm_en.php page, which queries from PHP to SQL the data.
Thank you in advance!
Drini
<?php
session_start();
foreach ($_REQUEST as $key => $value){
$$key=addslashes(htmlspecialchars(strip_tags($value)));
}
if(isset($_GET["m"])) {$m=$_GET["m"];} else {$m="";}
if(isset($_GET["commID"])) {$commID=$_GET["commID"];} else {$commID=1;}
if(isset($_GET["lang"])) {$lang=$_GET["lang"];}
else {$lang="en";}
Shfaq($m,$commID);
function Shfaq($metod,$commID)
{
switch($metod)
{
case "view":
{View($commID);}
break;
case "default":
{View($artID);}
break;
}
} // end of Shfaq();
function View($commID)
{
$link =mysql_connect("localhost", "db-user", "db-pass") or die ("E pamundur lidhja!");
mysql_select_db("DataBase-name") or die (mysql_error());
$queryComm = "SELECT * FROM communities WHERE id ='$commID' LIMIT 0,1";
$commRes=mysql_query($queryComm) or die(mysql_error());
$comm=mysql_fetch_array($commRes);
$healthPerc = round(($comm["healthBooklet"]/$comm["totalChildNo"]), 3)*100 ;
echo ' <table class="gpsbox" align="right">
<caption>GPS Location</caption>
<tr><td>Latitude </td><td>'.$comm["latitude"].'</td></tr>
<tr><td>Longitude</td><td>'.$comm["longitude"].'</td></tr>
</table>....<html coding continues>
Here is how to use the newest PHP API client library with Fusion Tables:
use Google_Service_Fusiontables;
$client_email = '<id>#developer.gserviceaccount.com';
$private_key = file_get_contents('<private key>.p12');
$scopes= array(
'https://www.googleapis.com/auth/fusiontables',
'https://www.googleapis.com/auth/fusiontables.readonly',
);
$credentials = new Google_Auth_AssertionCredentials(
$client_email,
$scopes,
$private_key
);
$client = new Google_Client();
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion();
}
$service = new Google_Service_Fusiontables($client);
$result = $service->query->sql('SELECT <column> FROM <table id>');
var_dump($result);
There is a PHP client library, you can use it if you want (it's probably the easiest way to access Fusion Tables from PHP)
Next to the client library there is also PHP sample code, just take a look, it probably helps you to understand the concept.
When you use the library, you can simply write sql statements, i.e. something like
select latitude from 123456 where id = 5;
123456 refers to the table id of your fusion table. If your table is public, you don't even have to care about authentication, but if you want to access private tables or update/insert data, I'd recommend to use OAuth for authentication.
Sample code in general can be found on the Google Fusion Tables API Sample Code

find signature is required or not using shipment API (USPS, UPS, DHL, FeDex)

I am integrating the Carrier (USPS, UPS, DHL, FeDex) API with my application.
For that i need to find different statuses for that shipment like is it delivered or not, which is getting me properly.
Similarly, i need to check whether the shipment required the signature or not?
How do i came to know this using the different API?
Regards,
Salil Gaikwad
Not all APIs support the same functionality. All will tell you the current status and some will provide the shipper/recipient information but I don't believe any will tell you if it was sent signature required.
E.g. for FedEx if you want to know about parcel's tracking events (delivered or not, any problems, delivery time and many other info) use this service endpoint - https://ws.fedex.com:443/web-services/track. The request to FedEx will be look like this (C# sample):
TrackRequest request = new TrackRequest();
request.WebAuthenticationDetail = new WebAuthenticationDetail();
request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential()
{
Key = "ApiKey",
Password = "PasswordKey"
};
request.ClientDetail = new ClientDetail
{
AccountNumber = "...",
MeterNumber = "..."
};
request.TransactionDetail = new TransactionDetail();
request.PackageIdentifier = new TrackPackageIdentifier();
request.PackageIdentifier.Value = "parcel tracking number";
request.PackageIdentifier.Type = TrackIdentifierType.TRACKING_NUMBER_OR_DOORTAG;
request.IncludeDetailedScans = true;
request.IncludeDetailedScansSpecified = true;
request.Version = new VersionId();
When you receive from FedEx - TrackReply, you should check TrackDetails array. There will be tracking info. As for other carriers, the common idea is the same. Almost every carrier use tracking number.

Resources