|
Hello Guys,
i would like to ask about how to view the office files (.docx, .xlsx, .pptx) in windows 8.1 app.
modified 2-Mar-16 10:26am.
|
|
|
|
|
You want to preview it within the app itself or just load the doc ?
<tag>I have no tag
|
|
|
|
|
just load it and preview in my app
|
|
|
|
|
When an object A needs to know that something "interesting" happened in object B, object B has an event for that, and A can subscribe to that event. Works well if A and B reside in the same program.
Now imagine A on one computer, and B on a different computer, connected with a not so stable wireless network. Of course, events can be sent via .Net Remoting or WCF. But things become naughty when the connection breaks. .Net Remoting may automatically re-establish the connection, WCF is more of a WTF here.
But anyway, we want B to make sure that the event was sent to all subscribers, and try to send it until it eventually succeeds.
Are there any components available which wrap those extra concerns or do we need to write our own "events" (including the subscription/unsubscription process, sending with a list of pending subscribers, connection fault handling) here? Or would you prefer a different architecture (e.g. A polls the state of B)?
Edit:
Let me create an example for that scenario. We have to take care of a flock of sheep. A shepherding drone is hovering over the area and searching for wolves. After detection of a wolf, it will notify the dogs and tell them where the wolves are etc. In most case there is one drone and one dog, but sometimes there may be many. With some trees around, the connection between the drone and the network may get disrupted.
An alternative solution is the dogs querying the drone's LastWolfDetected property in short intervals. Or the drones sending the LastWolfDetected message to a server, and the dogs query the server.
Anyway, the dogs must be informed reliably.
modified 3-Mar-16 3:18am.
|
|
|
|
|
Would WCF with reliable messaging help you? I kind of think that is what you are looking for.
"You'd have to be a floating database guru clad in a white toga and ghandi level of sereneness to fix this goddamn clusterfuck.", BruceN[ ^]
|
|
|
|
|
|
Bernhard Hiller wrote: But does it really reconnect automatically? No, it doesn't. Reliable Messaging basically just ensures that the sender knows whether a message has been received or not, no more, no less. For automatic reconnection you'll have to implement your own solution.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
|
OK, so we have something similar (I guess) here that uses SignalR. We keep track of connected clients on the server side. Now, if any client is disconnected, server marks it. The client will then try and reconnect. When that happens, it is unmarked. During this time, if any message was sent, we know how many clients have not received it. So we send it across. Here are the steps we used:
- When the client first connects, it sends a unique value that helps identification (since SignalR connectionIds are not persistent).
- This is saved in dictionary with value as true (for connected).
- When the client is disconnected, the value is set to false.
- When the notification is sent from server to client, we check if there is any client with value as false in the dictionary. If yes, we save the client identifiers.
- Next time they connect, the notification is sent again.
So, in drone-sheep-wolf-dog scene,
- Drone notes all the dogs available.
- If any dogs runs away to eat grass or whatever, it makes note of that too.
- If a wolf is noticed, all dogs are notified. Drone also knows one dog is not there and will need to notify this dog later.
- As soon as dog is back, it is send message.
- If any new dog joins in, that too gets the message.
Now, this assumes that drone is always functional. If drone can fail to retain this information, it can be saved to database. In that case, on any new connection, check drone cache and also database for any pending messages.
"You'd have to be a floating database guru clad in a white toga and ghandi level of sereneness to fix this goddamn clusterfuck.", BruceN[ ^]
|
|
|
|
|
Sounds like you're after a MessageQueue here.
This space for rent
|
|
|
|
|
"WCF with reliable messaging" uses some kind of a message queue internally. The problem remaining with WCF is its lack of automatic reconnect.
|
|
|
|
|
I'm talking about a fully fledged message queue, not some baked into a framework one. A full Message Queue should guarantee delivery when it is possible to do so. You might want to have a read of this article[^] on MSMQ for an interesting take on things.
This space for rent
|
|
|
|
|
That's a very interesting question ... got my vote.
Let me ask a question that, in this context, may be/seem naive. Isn't the kind of mutually-assured-notification you describe only possible with some "outside entity" like a server, to maintain the message queue ?
My object B, located wherever, sends a message to its "address" for your object A: absent response from A, what else can B know other than A has not responded. Is it an error in my App that I believe the message was sent, but it was not sent ? Did the facility I sent the message to fail ? Did the sender get the message, but never sent it ? Was the message sent, but not received because A's reception facility failed ? Did A get the message, but has not responded ? Did A send a response, but A's sender failed ? Did B's receiver fail ?
"Who's on First"
Okay, my App closes down, the message to A, and the fact it is not responded, to is saved; now, I re-open my App, B is instantiated, and B sees that it has a message sent to A in its un-responded-to queue ... and ?
Now, throw in the issue of the reliability of the third-party entity ... and your headed into quis custodiet custodes territy.
«In art as in science there is no delight without the detail ... Let me repeat that unless these are thoroughly understood and remembered, all “general ideas” (so easily acquired, so profitably resold) must necessarily remain but worn passports allowing their bearers short cuts from one area of ignorance to another.» Vladimir Nabokov, commentary on translation of “Eugene Onegin.”
|
|
|
|
|
The scenario can be seen from many points of view. I added a small example to show the problem. It is a design question where to implement the responsibility for the information getting to its addressee.
|
|
|
|
|
Bernhard Hiller wrote: We have to take care of a flock of sheep. A shepherding drone is hovering over the area and searching for wolves. After detection of a wolf, it will notify the dogs and tell them where the wolves are etc. In most case there is one drone and one dog, but sometimes there may be many. With some trees around, the connection between the drone and the network may get disrupted.
An alternative solution is the dogs querying the drone's LastWolfDetected property in short intervals. Or the drones sending the LastWolfDetected message to a server, and the dogs query the server.
Anyway, the dogs must be informed reliably. If (may the sheep be so unlucky, and the wolves so lucky, and the dogs confused) I were the shepherd here, and had the resources, and the means, I would like:
1. the server: keeps a time-stamped log of all contacts with every drone, every dog; a integral part of these logs is a list of all periods of time when a connection check (perhaps every #n minutes) fails. Hopefully this check could be some kind of lightweight "ping."
when the drone signals the server that a wolf is spotted, the message goes into an "alert queue" ... if the server fails to respond immediately to acknowledge the alert message, the drone repeats sending the message frequently which is also packaged with a log of previous tries, or time-stamped with when the first message was sent.
so, the server, receiving the alert can know from the message if it had been sent previously, when it was sent, etc.
the server maintains a parallel logging facility for the active dogs.
2. the drones: if it is possible for them to contact the dogs directly, and the dogs can signal the server that they received an alert message from a drone, then, the dogs ... assuming they can respond to gps co-ordinates ... can go immediately to the area where the alert was raised, as well as signalling the server they are in action.
The idea here being redundancy, and if the server is down, the dogs can still be called into action by the drones. If the drones are down, perhaps the server could direct the dogs to enter "reconnoiter mode" ? Could the dogs also raise an alert ... consider the dogs could smell a wolf ?
Of course, this is all wool-gathering.
«In art as in science there is no delight without the detail ... Let me repeat that unless these are thoroughly understood and remembered, all “general ideas” (so easily acquired, so profitably resold) must necessarily remain but worn passports allowing their bearers short cuts from one area of ignorance to another.» Vladimir Nabokov, commentary on translation of “Eugene Onegin.”
modified 3-Mar-16 8:11am.
|
|
|
|
|
|
That's what Pete suggested above.
|
|
|
|
|
Great minds think alike!
|
|
|
|
|
Hi All,
I am new to Unit Testing. Need your help in understanding how to use reflection in unit test case.i am using N-Unit Framework for writing unit test.
How to write unit test case for function "GetStudentinfo" in which private field "Studentresult" is updating. How to check this list value in unit test in order to compare expected and actual value using Assertions.
class Updatestdinfo
{
private enum Result
{
Firstclass,
secondclass
}
private List<int, Result > Studentresult = new List<int, Result >();
public void GetStudentinfo()
{
Studentresult[0] = Result.secondclass;
}
}
I tried to use reflection [gettype, getmethod] inorder to get the ENum type so that i can define list to initialize the expected value which can be used in Assert method. But its not returning the type of object. How can i resolve this?
modified 2-Mar-16 0:31am.
|
|
|
|
|
In the .Net world, a test class can inherit from the class under test.
[TestFixture]
public class UpdatestdinfoTests : Updatestdinfo
Change the access modifiers from private to protected , and voila, it works. No reflection required.
|
|
|
|
|
Thanks for your fast reply.
You are suggesting me to change the access modifier from private to protected.But i don't want to change the design of code for unit testing purpose.So how can i proceed?
Regards,
Mala
modified 3-Mar-16 1:33am.
|
|
|
|
|
Take a look at
Michael C. Feathers: Working Effectively with Legacy Code
|
|
|
|
|
May I suggest you read the discussion here: [^], and think about whether unti-testing of the private "details" of your objects is really a requirement.
But, if you have to do it, note that Microsoft's testing facility hands you tools like 'PrivateObject and 'PrivateType.
Without seeing your code where you try and test an 'Enum, I don't think much can be said except that, yes, it can be done.
«In art as in science there is no delight without the detail ... Let me repeat that unless these are thoroughly understood and remembered, all “general ideas” (so easily acquired, so profitably resold) must necessarily remain but worn passports allowing their bearers short cuts from one area of ignorance to another.» Vladimir Nabokov, commentary on translation of “Eugene Onegin.”
|
|
|
|
|
Thanks for the info.
Yes i wanted to check the private variable in unit testing as the method is having void as return type. So decided to check the variable values in order to do assertions.
I am able to get the private primitive data type [int, string] variables. but facing issue in accessing private custom data type i.e., user defined data types.
So please help me out.
|
|
|
|
|
/*I retrieve key value pairs for each of the conditions. The error is in the bolded. First condition returns longitude & latitude pairs. The third condition returns "State" and "WY" or "County"and "Buffalo", so that works fine. If it contains an "ID", it errors when the kvp consist of "value" = LocationID (corresponds to column name) that has empty string in uppercase "Value", because some are empty in the database */
public static tbl_Location ParseLocation(IOrderedDictionary values)
{
tbl_Location locFromValues = new tbl_Location();
foreach (DictionaryEntry value in values)
{
if (value.Key.Equals("Latitude") ||
value.Key.Equals("Longitude"))
{
double? valueAsNumber = null;
try { valueAsNumber = double.Parse(value.Value.ToString()); }
catch { }
locFromValues.GetType().GetProperty(value.Key.ToString()).SetValue(locFromValues, valueAsNumber);
}
else if (value.Key.ToString().Contains("ID"))
{
int? valueAsNumber = null;
try { valueAsNumber = int.Parse(value.Value.ToString()); }
catch { }
locFromValues.GetType().GetProperty(value.Key.ToString()).SetValue(locFromValues, valueAsNumber);
}
else
{
locFromValues.GetType().GetProperty(value.Key.ToString()).SetValue(locFromValues, value.Value);
}
}
return locFromValues;<pre lang="c#">
//I tried several ways for nullable int to take empty strings but it doesn't work, without adding another return in the catch. I have a return at the end of code block. Thank you.
|
|
|
|
|