.xproj does not throw ItemAdded event - visual-studio-extensions

I want my extension to do something everytime an item gets added to the project. This works fine for normale Projects or, with some magic (see here), for the Project Type "Website". But i cant get it to work with .xproj.
Here my current code to access the ItemAdded event (shortened)
var events = _dte.Events as Events2;
_projectItemEvents = events.ProjectItemsEvents;
_projectItemEvents.ItemAdded += ItemAdded;
_websiteItemEvents = events.GetObject ("WebSiteItemsEvents") as ProjectItemsEvents;
_websiteItemEvents.ItemAdded += ItemAdded;
_csharpItemEvents = events.GetObject ("CSharpProjectItemsEvents") as ProjectItemsEvents;
_csharpItemEvents.ItemAdded += ItemAdded;
Does anyone know how to access the ItemAdded event in case of an .xproj project type?
Edit: Edited code; The variables are all class fields and are not garbage collected, as in case of the other project types, the events are fired properly, just not in case of an .xproj.

Related

Handling browser refresh with query filters from page parameters

I have two data sources
Assets
Locations
Assets has a One to Many relation with Locations
Assets has a query builder data source, AssetLocFiltered, that is set with the following:
ParentLocationKey =:ParentLocationKey
ParentLocationKey is the relation field for the locations table.
On the home page you select a location and then click a button that passes the location ID to a parameter on the ShopPageDemo page. with the following code
app.pages.ShopPageDemo.properties.ParentLocationKey =
widget.datasource.item.Id;
console.log(widget.datasource.item.Id);
app.showPage(app.pages.ShopPageDemo);
One the ShopPageDemo Page there is a table view of the AssetLocFiltered that sets the query parameter in the ondataload event with the following code:
widget.root.datasource.query.parameters.ParentLocationKey =
widget.root.properties.ParentLocationKey;
widget.root.datasource.load();
This works great. The problem is when i hit the browser refresh it seems like it clears the property in ShopPageDemo. How do I handle this browser refresh issue? I am not really sure where to start.
There is more than one way to do this; However, the approach I usually take involves deep linking. In your case, you'll need to do something like this:
1.) On the button that takes you to the next page, add this code:
var params = {
key: widget.datasource.item.Id
};
var page = app.pages.ShopPageDemo;
app.showPage(page);
google.script.history.replace(null, params, page.name);
2.) On the ShopPageDemo onAttach event handler, add the following:
google.script.url.getLocation(function(location) {
widget.root.properties.ParentLocationKey = location.parameter.key;
var ds = widget.datasource;
ds.query.parameters.ParentLocationKey = widget.root.properties.ParentLocationKey;
ds.load();
});
For better performance, I would set the ShopPageDemo datasource to NOT load automatically and also to unload its data on the onDetach event handler like this: widget.datasource.unload().
Reference:
1. https://developers.google.com/apps-script/guides/html/reference/history
2. https://developers.google.com/apps-script/guides/html/reference/url

How to change resource(s) of events

The handling of resource changed in FullCalender 4.0.
In FullCalendar 3.x I changed the resource of an event using:
event.resourceId = newResourceId;
In FullCalendar 4.0 I cannot find the right way...
My current code is:
var calendar_event = calendar.getEventById(data.event.id)
if (calendar_event) {
calendar_event.setProp('title', data.event.title)
calendar_event.setProp('resourceIds', [data.event.resourceId])
}
setProp seems to be not the correct method as afterwards the event does not reflect the change within the grid, only the title has been changed to the new one.
A setter to getResources(), e.g. setResources() does not exist.
The official documentation on https://fullcalendar.io/docs/resource-data only includes resource-fetching, not programmatically set a new one to an existing event.
The migration guide https://fullcalendar.io/docs/upgrading-from-v3 mentions only the methods setProp, setExtendedProp, setStart, setEnd, setDates, setAllDay, moveStart, moveEnd, moveDates to replace updateEvent - resources are missing.
My current workaround is to delete and add the event again:
calendar.getEventById(data.event.id).remove()
calendar.addEvent(data.event)
How to move an event to another resource without loading and initializing the whole event a second time?
Editing resources of an event has been added in version 4.0.2.
The documentation describes the usage as follows:
By ID:
var event = calendar.getEventById('1');
event.setResources([ 'a' ]); // set a single resource
event.setResources([ 'a', 'b' ]); // set multiple
By Resource:
var resourceA = calendar.getResourceById('a');
var resourceB = calendar.getResourceById('b');
var event = calendar.getEventById('1');
event.setResources([ resourceA, resourceB ]);

Flash builder + Zend amf | Insertion function not working when called second time

I'm using standart createOrders function which is autogenerated by Flash Builder 4.6.
It works brilliantly when used once. Here is code:
protected function okButton_clickHandler():void
{
var orders2:Orders = new Orders();
//setting values
createOrdersResult.token = ordersService.createOrders(orders2);
ordersService.commit();
}
When same button is clicked second time and consequently okButton_clickHandler launched, data is not inserted to database.
I added result handler with trace("saved"); and what I saw was that "saved" was written on first click, but not second.
Also I used Charles to see whether request is being sent second time. And no it is not.
EDIT
Just tried to generate auto generate form. Only had to add commit(); because else request is not sent. And here is save problem — request is sent only on first button click.
EDIT 2
So all in all problem is in fact that ordersService.createOrders(orders2); works only once.
Because if i try
createOrdersResult.token = ordersService.createOrders(orders2);
ordersService.commit();
createOrdersResult.token = ordersService.createOrders(orders2);
ordersService.commit();
OR
createOrdersResult.token = ordersService.createOrders(orders2);
createOrdersResult.token = ordersService.createOrders(orders2);
ordersService.commit();
there is only one row added to database.
Any ideas?

Web Application Architecture (ASP.NET 3.5,JavaScript)

hey all ,
background -
I'm using an activx that allow me to access some information on the client side,
By using the activex events and callback i'm updating server side from client.
i wrote a user control that register all activex's events so when one of the events occuer there is a callback to the server that handle this event.
I need to write some other user controls based on this control so on every callback this user controls will be render on the client side.
My question is -
what is the best way to make a shared infrastructure that handle this events and render the right content base on user controls?
is there any other ways i can use ?
thanks!
hey! thanks for your fast reply,
first of all , i'm calling the activex using object tags,
HtmlGenericControl SkypeObject = new HtmlGenericControl("object");
SkypeObject.Attributes.Add("id", "Skype");
SkypeObject.Attributes.Add("codeBase", "http://ip/Skype4COM.dll");
SkypeObject.Attributes.Add("classid", "clsid:830690FC-BF2F-47A6-AC2D-330BCB402664");
SkypeObject.Attributes.Add("name", "Skype");
write callback :
string SkypeAsyncCallbackOnEvent = ClientScript.GetCallbackEventReference(this, "values", ClientScriptName, "context", true);
string SkypeCallbackFunction = "\n<script>\n";
SkypeCallbackFunction += "function SkypeCallback(values,context) {\n";
SkypeCallbackFunction += SkypeAsyncCallbackOnEvent + "\n}\n";
SkypeCallbackFunction += "</script>";
then i register the active'x events :
string SkypeOnUserStatusChange = "\n<script for=\"Skype\" event=\"UserStatus(Status)\">\n";
SkypeOnUserStatusChange += "var values = {\"StatusInfo\" : Status};\n";
SkypeOnUserStatusChange += "var myArray = {\"key\" : \"Status\", \"values\" : values};\n";
SkypeOnUserStatusChange += "var s=JSON.stringify(myArray);";
SkypeOnUserStatusChange += "SkypeCallback(s,null);\n";
SkypeOnUserStatusChange += "</script>";
this is my base user control (in short) so on each events callback is occur.
(this can be change to any class it doesnt metter right now)
now i want to create custom controls that will show the data back from the client.
in my opinion, i can change the call back reference client script to the one that exist in the Child Control and register the child control to the events of the base control.
what do you think ?
thanks :)
A little more info on your project would be helpful, but I think you would be well served using two approaches, one to handle the logic/events... and one to actually handle the visual updates - with some glue in the middle to make it all work like a charm.
First, the events. I could envision some sort of javascript class that registers with your activex control and binds methods to the various event handlers. This class would also expose methods you could bind functions to that would provide callbacks to your display logic.
Second, I would recommend using a library like jQuery to help with the heavy lifting of modifying the user page.
function eventTrap() {}
eventTrap.prototype.hookActiveX() { // your code to attach to your activex object }
eventTrap.prototype.register(event, callback) { // code to register for an event and callback }
// actually use it...
var trapObj = new eventTrap();
trapObj.hookActiveX();
trapObj.register("click", function(){alert('click');});

Passing flash variables to asp.net

I don't know much about Flash but we are working on a site that has a flash form and when the users pick an option, like selecting a value from a drop down list, we need the value to be passed to asp.net server-side code. What's the easiest way to do this?
Flash can invoke server side service. So use GET or POST to pass data
You could explore these options:
1) Communicate between the SWF and the containing page through JavaScript
2) Communicate via asp.net webservices from the SWF directly to the webservice.
3) Not sure but could probably do a POST to a processing aspx page?
HTH
I think a good option is to use the XML class so consider this:
var xmlRequest = new XML();
xmlRequest.onLoad = parseXMLResponse;
xmlRequest.load("http://yourpathtoyourserver/file.aspx?listselectedvalue=something");
function parseXMLRequest(loaded)
{
trace("hi");
}
You can also have the page give you data back this way so it's not just one way communication.
Assuming you are using Action Script 2.
Read the important notes at the bottom of each codes pertain to sending and retrieving data from flash to .net page. Explanation of the code is in the comment inside the code.
Flash Part (Action Script 2)
//function to send collected form data to asp.net page
//use other control/button to call this function
//important: in order for the 'onLoad' event to work correctly, this function has to be 'Void'
function sendForm():Void
{
//create LoadVars object
var lv_in:LoadVars = new LoadVars();
var lv_out:LoadVars = new LoadVars();
//set onLoad event
lv_in.onLoad = function(success:Boolean)
{
//if success, meaning data has received from .net page, run this code
if (success)
{
//lv_in.status is use to get the posted data from .Net page
statusMsg.text = "Thank you for filling up the form!" + lv_in.status;
}
//if fail, run this code
else
{
statusMsg.text = "The form you are trying to fill up has an error!";
}
}
//this is the collected data from the form
lv_out.userName = txtUserName.text;
lv_out.userAddress = txtUserAddress.text;
lv_out.userBirthday = txtUserBirthday.text;
//begin invoke .net page
lv_out.sendAndLoad("ProcessDataForm.aspx", lv_in, "POST");
}
Important note:
The function that contain onLoad event, in this case sendForm function, has to be Void function, meaning it's not returning value. If this function return value, what happen is the function will be executed all the way without waiting for the returned data from .net page, thus the onLoad event will not be set properly.
.Net Part
public void ProcessData
{
//process the data here
Response.Write("status=processed&");
}
Important note:
To send data/message back to flash, you can use Response.Write. However, if you want Action Script to parse the posted message/data from .Net page keep in mind you have to include & symbol at the end of the message. When parsing data/message, Action Script will stop at & symbol, thus leave the rest of the message alone and only get the message under sent variable.

Resources