A system that intergates with Tibco spotfire - c#

I want to develop a system that integrates with Tibco Spotfire and is able to Retrieve Visualizations rendered by Spotfire and expose them for WYSIWYG manipulation. Is this possible?
If so someone please offer guidance. I want to use C# and ASP.NET

first load the javascriptapi for handling client interactions
<script type="text/javascript" src="http://domainname/SpotfireWeb/GetJavaScriptApi.ashx?Version=3.1" > </script>
add the code for adding the spotfire template to web page
create a javascript file in your project with the code below:
function addPlayer()
{
var fileInfo = new FileInformation(SpotfireVisualizationPath,SpotfireVisualizationName,SpotfireParameter, '');
var customization = new spotfire.webPlayer.Customization();
customization.showCustomizableHeader = false;
customization.showToolBar = false;
customization.showClose = false;
customization.showTopHeader = false;
if (app != null)
{
app.close();
}
app = new spotfire.webPlayer.Application(SpotfireWebPlayerURL, customization);
app.open(fileInfo.path, 'SpotfireContainer', fileInfo.parameters);
}

The Spotfire Web Player (which I assume you refer to) is not built in this way - in its current implementation it is more like a remote desktop session to the desktop Spotfire application (if you replace the remote desktop technology with html and javascript).
It simply is not built to be able to grab pieces of the UI for reuse in other contexts. The closest you can do is host the entire web player UI in an iframe and use the javascript API for client-side interactions. By creating single-visualization pages and removing all chrome (toolbars etc) you can get to something that appears to be a single visualization on a page, but it's really just a hack.

Related

How to make a complex file download functionality with Blazor server?

I have a Blazor server application. I want to allow the user to download files but the content of the files needs to be built dynamically.
Basically the application shows reports to the user based on filters and etc. and I want the user to have the option to download whatever he is currently seeing.
I know I can make a "link button" that points to a Razor page that returns some sort of FileContentResult in its OnGet method but I have no idea how to pass any data to that so that the correct report file can be built.
I know there is an alternative that uses JavaScript but, as far as I know, it's more cumbersome and I'm not sure if it is any better.
I thought about doing a request to some sort of REST/WebAPI (which would allow me to pass arguments and stuff) but I cannot seem to get a WebAPI and Blazor Server projects run at the same time. The only partial success I've had is adding a WebAPI project to my Blazor Server solution and starting both. But then, while debugging, for some reason, both processes stop when I download the file.
Also the application must be hosted on Azure Web app and am not sure how feasible it would be to run both projects at the same time.
So, how can I make my Blazor Server allow the user to download a file but generate the file dynamically based on what the user is seeing on his browser?
The JavaScript alternative is very straightforward.
export function saveAsFile(filename, bytesBase64) {
if (navigator.msSaveBlob) {
//Download document in Edge browser
var data = window.atob(bytesBase64);
var bytes = new Uint8Array(data.length);
for (var i = 0; i < data.length; i++) {
bytes[i] = data.charCodeAt(i);
}
var blob = new Blob([bytes.buffer], { type: "application/octet-stream" });
navigator.msSaveBlob(blob, filename);
}
else {
var link = document.createElement('a');
link.download = filename;
link.href = "data:application/octet-stream;base64," + bytesBase64;
document.body.appendChild(link); // Needed for Firefox
link.click();
document.body.removeChild(link);
}
}
create a bytestream of whatever content you want to create and call this function through IJSInterop. I have used it in blazor server and it works well.
Please note : I found this piece of code online but I don't remember from where. I will be happy to give credit to the original author if someone knows the source.

PhantomJs save webpage containing dynamic data as webpage

I have used jQuery plugin to generate charts on screen along with dynamic data and notes.
I need to generate PDF of this webpage on button click.
I have tried to search good option but not able to find any proper one.
Right now I am trying to use phantomjs for this. It works for internet sites but not working for intranet sites.
I am continuously getting Unable to load address.
Can anyone suggest me the way to achieve this? Or any alternative way to generate PDF from html content (My html contains SVG, Javascript generated dynamic data too).
Code:
string serverPath = "C:\\Phantomjs\\bin\\phantomjs";
var phantomJS = new PhantomJS();
var outFile = Path.Combine(serverPath, "google2.pdf");
if (File.Exists(outFile))
File.Delete(outFile);
try {
phantomJS.Run(Path.Combine(serverPath, "rasterize.js"),
new[] { "http://localhost:61362/HT.aspx?FNo=D1&PrNo=Dummy1&HtId=1033", outFile });
} finally {
phantomJS.Abort();
}
The url is not working in this case. But if I take any internet hosted site, it works.

SharePoint 2007 - Update all site home pages

I am wondering if there is a way to update all site home pages to display a new custom web part.
I have a site collection with 100+ sub sites and I have created a custom web part which i want to display in all site home pages.. what would you suggest as the best way to do this, as as doing this manually will take considerable time?!
First write the code to programmatically add a webpart to a single homepage. The specifics of how to do this will vary based on how your homepage is structured, whether it's a publishing page, etc. It's most likely possible, but implementations could differ. You'll possibly be using something similar to this:
using(SPSite site = new SPSite("http://localhost"))
using(SPWeb web = site.RootWeb)
{
web.AllowUnsafeUpdates = true;
SPLimitedWebPartManager webParts = web.GetLimitedWebPartManager("Pagees/Home.aspx"
, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
MyWebPart wp = new MyWebPart(); // your custom webpart
wp.Title = "My WebPart";
webParts.AddWebPart(wp, "Left", 0);
webParts.SaveChanges(wp);
}
There are lots of variations when searching the subject online.
Once you have that you can create either a console application or a feature to be executed on the top level site, open up each subsite, and then execute the above code.

What would be considered the best way to architect sending email from a C# web application?

I am working on a web application that will be going live soon, and I am now trying to figure out the best way for handling sending email from the application. I understand completely HOW to send email from the application using the MailMessage and SmtpClient classes, however my question is from a different angle. My main purpose at my job before this project was support of old applications that had been developed before my time. In these applications, when they needed to send email, they hard coded any of the messages into the actual message with all of the HTML tags embeded directly into the C# code.
The application that I am working on will have a template for the emails to be sent in, as a sort of styling container, and the different messages will be embeded into the main content div's of the template. I would like to avoid hardcoding these templates in this application, so I have been trying to figure out the best way to layout my project. I have thought of using a t4 template, and reading the different t4's into the application and applying a String.Format with the specified parameters to add names/emails to the messages to be sent. However, I am not sure this is the best way to do it.
My other idea was to define a class for each type of message, however this would end up hardcoding messages again, which as I said I don't want to do.
My question is, how have you approached this in the past? What worked, and what didn't and for what reasons? I have looked all over online, but either the only content out there is on HOW to send the message, or I have not used the right Google power words.
I do it this way:
Code it the usual way with ViewModel and Razor Template
By creating the e-mail, use http://razorengine.codeplex.com/ to load and parse the template
Be aware to not use Html and Url helper if you want to send e-mails in a thread, because they rely on HttpContext which you don't have in that case. Build your own helpers if needed.
For example, if you have a ViewModel Car in your application which is displayed somewhere, you could also use this ViewModel as #model in a Razor Template for e-mail.
I've had to do this on a couple of occasions. I originally used the ASP.Net template engine based on I think a Rick Strahl blog post. It worked but there was always some issue I was banging my head against.
I switched to using the NVelocity template engine and found it a really simple way to create and maintain email templates. There are a number of other template engines and I suspect next time I might have a serious look at the Razor engine.
The code for merging values into the template:
private string Merge(ManualTypeEnum manualType, Object mergeValues)
{
var body = "";
var templateFile = string.Format("{0}MailTemplate.vm", manualType);
var velocity = new VelocityEngine();
var props = new ExtendedProperties();
props.AddProperty("file.resource.loader.path", Config.EmailTemplatePath);
velocity.Init(props);
var template = velocity.GetTemplate(templateFile);
var context = new VelocityContext();
context.Put("Change", mergeValues);
using (var writer = new StringWriter())
{
template.Merge(context, writer);
body = writer.ToString();
}
return body;
}
The values to merge are passed as an anonymous object, and can include various types including lists etc e.g.
var emailBody = Merge(newDocument.ManualType, new
{
ManualType = newDocument.ManualType.ToString(),
Message = change.Message,
NewTitle = newDocument.Title ?? "",
NewVersion = newDocument.Version ?? "",
Contact = From,
Changes = change.ToList(),
});

Integrate Microsoft Office Communicator 2007 in ASP.NET Page

I am working on a website build using ASP.NET and C# for my company's intranet.So is it possible to integrate the Microsoft Office Communicator 2007 in ASP.NET Page. i.e. the site should be able to provide the current status(avalible, busy , offline) of all contacts and when a user clicks on the username, the chat window should open.
Assuming the client machine is running Communicator, Office and IE, by far the simplest way is to use the NameCtrl in client-side script - the example below should gives the basic concepts. This will also give you the most bang-for-buck in terms of functionality. Hover over the "Your Contact" text to see the persona menu pop up.
For a real world solution, you'd just need to implement an image that changes depending on the presence state that gets returned (i.e. a presence bubble to display alongside each users name), and a collection of sip uris to images, to ensure you can map an incoming status change to the relevant image.
It's worth bearing in mind that the Ajax/CWA solution mentioned in the other answer will most likely not work with Lync Server (I believe Communicator Web Access is no more) so you'd need to change the solution if your company upgrades to Lync. I've tested the solution below, and it works with the Lync Server RC.
<script>
var sipUri = "your.contact#your.domain.com";
var nameCtrl = new ActiveXObject('Name.NameCtrl.1');
if (nameCtrl.PresenceEnabled)
{
nameCtrl.OnStatusChange = onStatusChange;
nameCtrl.GetStatus(sipUri, "1");
}
function onStatusChange(name, status, id)
{
// This function is fired when the contacts presence status changes.
// In a real world solution, you would want to update an image to reflect the users presence
alert(name + ", " + status + ", " + id);
}
function ShowOOUI()
{
nameCtrl.ShowOOUI(sipUri, 0, 15, 15);
}
function HideOOUI()
{
nameCtrl.HideOOUI();
}
</script>
<span onmouseover="ShowOOUI()" onmouseout="HideOOUI()" style="border-style:solid">Your Contact</span>

Categories