Not able to read file from server - on-premise CRM - plugins

Trying to read file from server where CRM is installed. When I am reading the file from the server, plugin throws an error "Directory not found".
Entity attachment = new Entity("activitymimeattachment");
FileStream stream = File.OpenRead(fileName);
byte[] byteData = new byte[stream.Length];
stream.Read(byteData, 0, byteData.Length);
stream.Close();
// Encode the data using base64.
string encodedData = System.Convert.ToBase64String(byteData);
attachment["subject"] = "Attachment";
attachment["filename"] = "emailstatement.pdf";
//byte[] fileStream = Encoding.ASCII.GetBytes(fileName);
attachment["body"] = encodedData;
attachment["mimetype"] = #"application\pdf";
attachment["attachmentnumber"] = 1;
attachment["objectid"] = new EntityReference("email", emailguid);
attachment["objecttypecode"] = "email";
service.Create(attachment);
Can anyone help me to read file from server using plugin?
Thank you.

Makes sure your plugin is registered outside of the sandbox (in partial trust). Its an option in the plugin registration tool.
Plug-in isolation, trusts, and statistics
Microsoft Dynamics 365 (online & on-premises) support the execution of
plug-ins and custom workflow activities in an isolated environment. In
this isolated environment, also known as a sandbox, a plug-in or
custom activity can make use of the full power of the Microsoft
Dynamics 365 SDK to access the organization web service. Access to the
file system, system event log, certain network protocols, registry,
and more is prevented in the sandbox.

Related

Error opening MDB file on network location with EntityFrameworkCore.jet.oledb 3.1

I have a project opening up MS Access DBs on a network folder. The project is a .net core 3.1 webapi.
EDIT: I'm using EntityFrameworkCore.Jet.OleDb v3.1 with provider in connection string Provider=Microsoft.ACE.OLEDB.12.0.
It very simply updates a list of boards based on new ones
public void SyncBoards(List<Board> boards)
{
_cutriteDbContext.RemoveRange(boards);
_cutriteDbContext.SaveChanges();
_cutriteDbContext.AddRange(boards);
_cutriteDbContext.SaveChanges();
}
I'm getting the error (sanitized)
System.Data.OleDb.OleDbException (0x80004005): The Microsoft Access
database engine cannot open or write to the file
'\{SHAREDFOLDER}{PATH_TO_FILE}\imatv11.mdb'. It is already opened
exclusively by another user, or you need permission to view and write
its data.
This works fine in IIS Express when debugging from VS 2019. I believe this is because the API doesn't have the credentials to access the file. The DBs do not have password protection. Is there a way to provide credentials to the file?
I had to set the identity in the IIS application pool in advanced settings.

AWS MobileAnalyticsManager access to folder 'AWS Mobile Services\M4SP' is denied

I am trying to add the AWSSDK DLL into my C# code to collect my event data and pass the data to the AWS bucket. My C# code is created with VS Share point template. The project contains WSP files. The following code indicates how I use the AWSSDK :
using Amazon;
using Amazon.CognitoIdentity;
using Amazon.MobileAnalytics.MobileAnalyticsManager;
CognitoAWSCredentials credentials = new CognitoAWSCredentials(
"us-east-1:xxxxxx",//PoolID
RegionEndpoint.USEast1
);
Amazon.AWSConfigs.ApplicationName = "M4SP";
AWSConfigs.LoggingConfig.LogMetrics = true;
AWSConfigs.LoggingConfig.LogResponses = ResponseLoggingOption.Always;
AWSConfigs.LoggingConfig.LogMetricsFormat = LogMetricsFormatOption.JSON;
MobileAnalyticsManager manager = MobileAnalyticsManager.GetOrCreateInstance(
"xxxxxxxxxxxxxxxxxxx",//AppID
credentials,
RegionEndpoint.USEast1 // Region
);
CustomEvent customEvent = new CustomEvent("TestRecordEvent");
customEvent.AddAttribute("label", "M4SP");
customEvent.AddAttribute("action", "invoke");
customEvent.AddAttribute("details", "run the workflow test");
manager.RecordEvent(customEvent);
I found the code inside AWSSDK DLL was trying to log the data to local folder before passing it to AWS database. The location of the folder is C:\Users\[userid]\AppData\Roaming\AWS Mobile Services.
There is no problem in a standalone project since it always uses current user’s identity to run the application so it has access to the folder. But, because of the authentication mechanism of SharePoint solutions, it uses Application Pool Identity to access the folder and it gets access denied issue and the whole process fails.
Here is the error:
"Access to the path 'AWS Mobile Services\M4SP' is denied."
I modified the access right of Share point Application Pool Identity (in my case, it is “network service” account) but it still can’t access the folder .
Does anyone have a solution for this issue? Thanks very much for the help!!

Agile Classes.jar file

I am using Agile PLM Version: 9.3.0.2 (Build 20). I am on the client side. I'm trying to use Eclipse to interact with Agile's API features. According to the Agile SDK Developer Guide I need both:
AgileAPI.jar
agileclasses.jar
I have the AgileAPI.jar file, but I don't have the agileclasses.jar file.
Any suggestions/links/ methods in which I can obtain this file!
AgileAPI.jar, contains the factories and interfaces used by the Agile EJB on server side.
If you have an Agile instance on a server, you don't need to have agileclasses.jar (unofficial API) but creating an IAgileSession using AgileSessionFactory, all the implementation of interfaces (IChange, IPrograms, IItem. etc) are retrieved using it.
session.getObject(IChange.OBJECT_TYPE, "ChangeNumber123");
where did you find that agileclasses.jar is required?
However, you can find them in the Weblogic Server shared lib folder.
EDIT
Eclipse interacts with an Agile Server using AgileAPI.jar.
String server = "http://myServer:7001/Agile";
HashMap<Integer,String> params = new HashMap<Integer, String>();
AgileSessionFactory instance = AgileSessionFactory.getInstance(server);
params.put(AgileSessionFactory.USERNAME, "myUsername");
params.put(AgileSessionFactory.PASSWORD, "myPassword");
IAgileSession session=instance.createSession(params);
IItem item = (IItem) session.getObject(IItem.OBJECT_TYPE, "ITEMID1234");
item.setValue("Page Two.MYFIELD", "Value");
The example above, connect to an instance of Agile (server) already started up and get the item with number ITEMID1234. Then it sets the value of a field (MYFIELD) with "Value"

How to create SOAPAdater using IBM worklight 6.2?

I am trying to create Soap Adapter using IBM Work light but I am not able to get web services methods to work light projects Services folder. When I am running my project after deployment of adapter it will not showing proper output. Let me know if anyone had made demo or some good Links related to it.
Your explanation does not provide the steps you have actually taken nor the expected output, the service you are using, the error you're getting, etc... so it is somewhat difficult to understand/recreate the issue... Also, please do mention the build number of the Worklight Studio 6.2 installation you're using.
There is no such thing as a "SOAP adapter" per-se. What you are referring to is "HTTP adapter" that is generated by providing a WSDL scheme location.
For example, WebServiceX.net provides a global weather service.
In order to generate an adapter from the above:
Create a new project
In the project structure, right-click on the Services folder and select "Discover back-end services"
From the "Service type" dropdown, select "Web Service Definition Language (WSDL)"
In the "URL" field paste "http://www.webservicex.net/globalweather.asmx?WSDL" and click on "Go"
From the "Select Service" table, select a service and click on "Finish"
The end result is a new HTTP adapter in the adapters folder called "SoapAdapter1", containing an auto-generated XML and -impl.js file ready to use.
You can read more about it, here:
HTTP adapters training module, slide #16
Generating adapters with the services discovery wizard user documentation topic
I also suggest using the very latest iFix available for the 6.2.0.1 release, as it contains some WSDL-related fixes, so best to be up-to-date.
It can be downloaded from either IBM Fix Central or from the Eclipse Marketplace (Eclipse > Help > Marketplace).
Finally I have successfully consume weather Soap service.
Below given is main function which should call after successful connection.
function loadContactSuccess(result){
WL.Logger.debug("Device is connected to WL server");
WL.Logger.info("Inside loadContactSuccess" );
var list = result.invocationResult.Envelope.Body.GetWeatherInformationResponse.GetWeatherInformationResult.WeatherDescription;
console.log("list detail ..." + list);
sessionStorage.setItem("WeatherDescription", JSON.stringify(result.invocationResult.Envelope.Body.GetWeatherInformationResponse.GetWeatherInformationResult.WeatherDescription));
WL.Logger.debug("WeatherDescription list :: ", JSON.parse(sessionStorage.getItem("WeatherDescription")));
var tempValue = JSON.parse(sessionStorage.getItem("WeatherDescription"));
console.log("Inside loadContactSuccess ..." + tempValue.length);
text = "";
var i;
for (i = 0; i < tempValue.length; i++) {
text += tempValue[i].WeatherID +" "+"<img src="+ tempValue[i].PictureURL +">" + "<br>";
}
document.getElementById("demo").innerHTML = text ;
}
You can also download demo example create by me from URL.Click Here

COM+ application deployment using command-line

I need to deploy my COM dll as a COM+ application. I used to do that from Component Services manager (dcomcnfg.exe). But my requirement is to deploy it from command-line. Is there a command to do that?
Update: And how to uninstall the same?
Thanks.
Here are a couple of scripts that dump a COM+ application's settings to an XML file, as well as installs applications from and XML file. It provided me a good framework for doing something similar a while back. It contains example code of how to create and remove COM+ applications using the COM+ administration API.
This vbscript snippet creates an application and installs a component:
Dim catalog
Dim applications
Dim application
Set catalog = CreateObject("COMAdmin.COMAdminCatalog")
Set applications = catalog.GetCollection("Applications")
Call applications.Populate
Set application = applications.Add()
' ID is an arbitrary GUID, that you can create using uuidgen
application.Value("ID") = "{da2d72e3-f402-4f98-a415-66d21dafc0a9}"
application.Value("Name") = "SampleApp"
application.Value("Activation") = 0' COMAdmin.COMAdminActivationOptions.COMAdminActivationLocal
application.Value("ApplicationAccessChecksEnabled") = 0 'COMAdmin.COMAdminAccessChecksLevelOptions.COMAdminAccessChecksApplicationComponentLevel
application.Value("Description") = "Sample Application"
'application.Value("Identity") = "machine\administrator"
'application.Value("Password") = "YourPassword"
application.Value("RunForever") = True
Call applications.SaveChanges
catalog.InstallComponent "SampleApp", "C:\Documents and Settings\me\My Documents\Test\MyTestProj.dll", "", ""
Set application = Nothing
Set applications = Nothing
Set catalog = Nothing
This is running on Windows XP -- other OS's may have different behavior. And it does seem to be pretty temperamental. If it doesn't work the errors are really vague and unhelpful.
To delete I think you will have to iterate over the the components in the application and remove from the list as per this example. I think a similar approach would be required to remove the entire application.
References
See Configurating COM+ for a good easy to understand article (but is not in script). MSDN has a good reference on Automating COM+ Administration and also the complete COM+ Administration Reference.