im trying to create the object NotesUIWorkspace to open the Maildialog from an Lotus Note Client V9 (add attachmen, text, recipents, ec) but it doesn't work
I'm searching for the reference for NotesUIWorkspace, (i don't find it)
dim obj as Object
obj = CreateObject("Notes.NotesUIWorkspace")
The Class i'm Trying to use https://notes.helsinki.fi/help/help8_designer.nsf/2e73cbb2141acefa85256b8700688cea/027a2bc771e3cb6e8525731b004a77f6?OpenDocument#183993280029220079
from the Documentation
https://notes.helsinki.fi/help/help8_designer.nsf/Main?OpenFrameSet
I have searched for some examples but i didn't find any usefull for my expirience level.
Does anybody have some usefull tipps or examples?
Best Regards
Florian
Here is an example using C# that will compose a memo in the UI:
public void ComposeMemo(String sendto, String subject, String body)
{
// instantiate a Notes session and workspace
Type NotesSession = Type.GetTypeFromProgID("Notes.NotesSession");
Type NotesUIWorkspace = Type.GetTypeFromProgID("Notes.NotesUIWorkspace");
Object sess = Activator.CreateInstance(NotesSession);
Object ws = Activator.CreateInstance(NotesUIWorkspace);
// open current user's mail file
String mailServer = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailServer", true });
String mailFile = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailFile", true });
NotesUIWorkspace.InvokeMember("OpenDatabase", BindingFlags.InvokeMethod, null, ws, new Object[] { mailServer, mailFile });
Object uidb = NotesUIWorkspace.InvokeMember("GetCurrentDatabase", BindingFlags.InvokeMethod, null, ws, null);
Object db = NotesUIWorkspace.InvokeMember("Database", BindingFlags.GetProperty, null, uidb, null);
Type NotesDatabase = db.GetType();
// compose a new memo
Object uidoc = NotesUIWorkspace.InvokeMember("ComposeDocument", BindingFlags.InvokeMethod, null, ws, new Object[] { mailServer, mailFile, "Memo", 0, 0, true });
Type NotesUIDocument = uidoc.GetType();
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "EnterSendTo", sendto });
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Subject", subject });
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Body", body });
// bring the Notes window to the front
String windowTitle = (String)NotesUIDocument.InvokeMember("WindowTitle", BindingFlags.GetProperty, null, uidoc, null);
Interaction.AppActivate(windowTitle);
}
Are you running on a 64 bit OS? If so, you can expect to have some problems with the Domino classes. They are not supported for 64 bits though they can be made to work, mostly.
See my answer to this question for some links to additional information.
Related
how can I set up a proxy that has username and password in CefSharp browser in visual basic?
I tried with this code but doesn't work:
Dim proxy = "IP:PORT#USERNAME:PASSWORD"
Dim settings As New CefSettings()
settings.CefCommandLineArgs.Add("proxy-server", proxy)
Thanks
Your browser implement a IBrowser interface with GetHost method that allow you get RequestContext. You can set the proxy:
var requestContext = browser.GetHost().RequestContext;
var values = new Dictionary<string, object>
{
["mode"] = "fixed_servers",
["server"] = $"{proxyScheme}://{proxyHost}:{proxyPort}"
};
string error;
bool success = requestContext.SetPreference("proxy", values, out error);
To set user/password, you need to implement an IRequestHandler interface and implement this method:
public bool GetAuthCredentials(
IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
{
if (isProxy)
{
var browser2 = browserControl as IChromeRequestHandler;
var proxyOptions = browser2?.ProxySettings;
if (proxyOptions != null)
{
callback.Continue(proxyOptions.UserName, proxyOptions.Password);
return true;
}
}
callback.Dispose();
return false;
}
Then, you must set the RequestHandler property of your browser:
browser.RequestHandler = new YourIRequestHandlerImplementation();
Sorry for the C# implementation, but I think may be useful to you.
I have tried many solutions for this simple error but I couldn't find bug what actually cause it.
Here is some code for reference.
GPController
[HttpPost("testConnection")]
public bool TestConnection()
{
try
{
var data = eConn.GetEntity();
if (data)
{
return true;
}
return false;
}
catch(Exception ex)
{
throw ex;
}
}
eConn.cs
public static bool GetEntity()
{
try
{
string connString = DataAccess.ConnectionString;
eConnectOut myRequest = new eConnectOut();
myRequest.DOCTYPE = "Customer";
myRequest.OUTPUTTYPE = 1;
myRequest.INDEX1FROM = "Customer001";
myRequest.INDEX1TO = "Customer001";
myRequest.FORLIST = 1;
// Create the eConnect requester XML document object
RQeConnectOutType[] eConnectOutType =
new RQeConnectOutType[1] { new RQeConnectOutType()};
eConnectOutType[0].eConnectOut = myRequest;
eConnectType eConnectDoc = new eConnectType();
eConnectDoc.RQeConnectOutType = eConnectOutType;
// Serialize the object to produce an XML document
MemoryStream memStream = new MemoryStream();
XmlSerializer serializer = new XmlSerializer(typeof(eConnectType));
serializer.Serialize(memStream, eConnectDoc);
memStream.Position = 0;
XmlDocument myDoc = new XmlDocument();
myDoc.Load(memStream);
eConnectMethods eConnCall = new eConnectMethods();
eConnCall.RequireProxyService = false;
// Retrieve the specified customer document
string myCustomer = eConnCall.GetEntity(connString, myDoc.OuterXml);
return true;
}
catch(Exception ex)
{
throw ex;
}
}
In eConn.cs calling GetEntity method I am getting this error.
{System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Dynamics.GP.eConnect.EventLogHelper.AddExceptionHeader(String action, Object[] inputParameters, StringBuilder errorString)
at Microsoft.Dynamics.GP.eConnect.EventLogHelper.CreateEventLogEntry(Exception exception, String action, Object[] inputParameters)
at Microsoft.Dynamics.GP.eConnect.eConnectMethods.GetEntity(String connectionString, String sXML)
at AP.GPServices.Helper.eConn.GetEntity() in D:\projects\APSystem SM\Source Code\AP.GPServices\Helper\eConn.cs:line 46}
I am referring this Programmer guide.
http://www.mypurelogic.com/files/purelogic/files/manuals/econnectprogrammersguide.pdf
In my API application, I field values coming from registration view which I want to store into the database. On AccountController.cs, I have collected these values using the following code.
[Route("Register")]
public async Task<object> Register(UserDetails data)
{
var userRegister = new IdentityUser
{
FirstName = data.FirstName,
LastName = data.LastName,
UserName = data.Email,
Email = data.Email,
PhoneNumber = data.PhoneNumber,
PasswordHash = data.Password
};
UserManager<IdentityUser> _manager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(new TachusApi.DBContext.AuthDbContext()));
string pHash = _manager.PasswordHasher.HashPassword(data.Password);
DBAccess dbaccess = new DBAccess();
dbaccess.SaveAdmin(userRegister, pHash);
return data;
}
What I want to do is to pass these values to the SaveAdmin method in DBAccess.cs for storing into the database. Here is my SaveAdmin method:
#region Save Admin User
public void SaveAdmin(string userRegister, string hash)
{
SqlConnection conn = null;
SqlCommand command = null;
int retValue;
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
command = conn.CreateCommand();
command.CommandText = "RequestedServiceUserDataInsert";
command.CommandType = CommandType.StoredProcedure;
...
}
#endregion
I can't pass a valid format of the values to my SaveAdmin method where I can save them into the database. Is there anyone who may advise an effective way that can help me pass these values as an object for using them in my save method? Please advice
Since you define the userRegister object as an IdentityUser object
var userRegister = new IdentityUser
{
FirstName = data.FirstName,
LastName = data.LastName,
UserName = data.Email,
Email = data.Email,
PhoneNumber = data.PhoneNumber,
PasswordHash = data.Password
};
And then pass it to the SaveAdmin function of your dbaccess class
dbaccess.SaveAdmin(userRegister, pHash);
The SaveAdmin method needs to be set up to accept the userRegister of type IdentityUser. Right now it expects a plain string.
So, instead of having your SaveAdmin function declared as this:
public void SaveAdmin(string userRegister, string hash)
You need to have it declared like this:
public void SaveAdmin(IdentityUser userRegister, string hash)
That way the method gets the data it expects and you can access all properties of that object and insert them into SQL server.
I am using the .Net Core 1.2 with Amazon SES(SimpleEmail) to send the Emails(Raw Emails).
Below is the working code version we have used in .net framework 4.5:
public MemoryStream ConvertMailMessageToMemoryStream(MailMessage message)
{
Assembly assembly = typeof(SmtpClient).Assembly;
Type mailWriterType = assembly.GetType("System.Net.Mail.MailWriter");
MemoryStream fileStream = new MemoryStream();
ConstructorInfo mailWriterContructor = mailWriterType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Stream) }, null);
object mailWriter = mailWriterContructor.Invoke(new object[] { fileStream });
MethodInfo sendMethod = typeof(MailMessage).GetMethod("Send", BindingFlags.Instance | BindingFlags.NonPublic);
sendMethod.Invoke(message, BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { mailWriter, true, true }, null);
MethodInfo closeMethod = mailWriter.GetType().GetMethod("Close", BindingFlags.Instance | BindingFlags.NonPublic);
closeMethod.Invoke(mailWriter, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { }, null);
return fileStream;
}
But in .Net Core 1.2 we are unable to get reference for class Assembly of SmtpClient and System.Net.Mail.MailWriter. Below is working in regular .net framework:
Assembly assembly = typeof(SmtpClient).Assembly;
In .Net Core, since SmtpClient is available in MailKit, we have referenced it and gives the following error:
'Type' does not contain a definition for 'Assembly' and no extension method 'Assembly' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?)
Is there any way in .Net Core to convert the MailMessage to MemoryStream?
Looks like there is no constructor accepting only one argument in dotnet core 5.0, try this.
ConstructorInfo mailWriterContructor = mailWriterType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Stream), typeof(bool) }, null);
object mailWriter = mailWriterContructor.Invoke(new object[] { fileStream,true });
** try this**
private static string ConvertMailMessageToMemoryStream(MailMessage message)
{
BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
Assembly assembly = typeof(SmtpClient).Assembly;
Type mailWriterType = assembly.GetType("System.Net.Mail.MailWriter");
MemoryStream stream = new MemoryStream();
ConstructorInfo mailWriterConstructor = mailWriterType.GetConstructor(flags, null, new[] { typeof(Stream) }, null);
object mailWriter = mailWriterConstructor.Invoke(new object[] { stream });
MethodInfo sendMethod = typeof(MailMessage).GetMethod("Send", flags);
sendMethod.Invoke(message, flags, null, new[] { mailWriter, true, true }, null);
var sr = new StreamReader(stream);
var str = sr.ReadToEnd();
MethodInfo closeMethod = mailWriter.GetType().GetMethod("Close", flags);
closeMethod.Invoke(mailWriter, flags, null, new object[] { }, null);
return str;
}
I've been trying to convert a SSRS Report to PDF and save to my local drive using the Reporting Web Services. Though I'm able to generate the corresponding pdf file but the contents of the file are missing. I've checked that the report I'm trying to convert is not an empty one. Only the header section is present there within the generated pdf files. Below is the code I'm using:
protected void GeneratePDFFromReport(object sender, EventArgs e)
{
RS2005.ReportingService2005 rs;
RE2005.ReportExecutionService rsExec;
// Create a new proxy to the web service
rs = new RS2005.ReportingService2005();
rsExec = new RE2005.ReportExecutionService();
// Authenticate to the Web service using Windows credentials
rs.Credentials = new System.Net.NetworkCredential("username", "password", "domain");
rsExec.Credentials = new System.Net.NetworkCredential("username", "password", "domain");
//rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url = "http://servername/reportserver/reportservice2005.asmx";
rsExec.Url = "http://servername/reportserver/reportexecution2005.asmx";
string historyID = null;
string deviceInfo = null;
string format = "PDF";
Byte[] results;
string encoding = String.Empty;
string mimeType = "application/pdf";
string extension = String.Empty;
RE2005.Warning[] warnings = null;
string[] streamIDs = null;
// Path of the Report - XLS, PDF etc.
string fileName = #"C:\Report\MemberReport.pdf";
// Name of the report - Please note this is not the RDL file.
string _reportName = #"/ReportFolder/ReportName";
string _historyID = null;
bool _forRendering = false;
RS2005.ParameterValue[] _values = null;
RS2005.DataSourceCredentials[] _credentials = null;
RS2005.ReportParameter[] _parameters = null;
try
{
_parameters = rs.GetReportParameters(_reportName, _historyID, _forRendering, _values, _credentials);
RE2005.ExecutionInfo ei = rsExec.LoadReport(_reportName, historyID);
results = rsExec.Render(format, deviceInfo,
out extension, out encoding,
out mimeType, out warnings, out streamIDs);
try
{
FileStream stream = File.Create(fileName, results.Length);
stream.Write(results, 0, results.Length);
stream.Close();
}
catch { }
results = null;
}
catch (Exception ex)
{
throw ex;
}
}
Any help would highly be appreciated. Thanks.
Assuming that SSRS is working OK using browser, please modify your posted code as shown below:
1) Device info string, please set it as follows:
string deviceInfo = #"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"; //Initial value was null
2) Create Header instance before using web call LoadReport:
ExecutionHeader execHeader = new ExecutionHeader();
RE2005.ExecutionHeaderValue = execHeader;