|
So here is my dilemma, rather then describe it I will show you it.
Let say we take back a certain amount of records records from the DB Called Inventory Count and they have a corresponding number attached to them indicating if they are an opening Count (1) or a closing count (2)
Date-Product-Quantity-Opening/Closing
1. 1/1/2010, Ice Cream Cones, 10, 1
2. 1/1/2010, Bananas, 8, 1
3. 1/1/2010, Chocolate Bars, 9, 1
4. 2/1/2010, Ice Cream Cones, 5, 2
5. 2/1/2010, Bananas, 4, 2
6. 2/1/2010, Chocolate Bars, 3, 2
7. 4/1/2010, Ice Cream Cones, 12, 1
8. 4/1/2010, Bananas, 8, 1
9. 4/1/2010, Chocolate Bars, 9, 1
10. 5/1/2010, Ice Cream Cones, 1, 2
11. 5/1/2010, Bananas, 2, 2
12. 5/1/2010, Chocolate Bars, 3, 2
I need to build a dictionary that will take the first group (Openings = 1) and do the subtraction of quantity for closing(Closing 2), This will make up Session 1, Session 2 will be the next corresponding groups of Opening = 1 - Closing = 2
Thanks for the help in advance, hopefully this is understandable
|
|
|
|
|
Ive used sorteddictionary to now group the different dates.. <datetime, object="">
|
|
|
|
|
You say that you want to build a dictionary. Are you under instruction to use a Dictionary? It seems, from what you have posted that this should all be done in the database.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
This is for generic usb devices (3 of same usb devices)
I'm not sure if it is possible to do this scenario...
With all 3 usb devices are on and loaded in the application...
When device B is disconnected, the device B handle/instance is disposed.
When device B comes back on (reconnected), the system detects device B (using the wndproc messaging), the handle/instance) is being established, without changing the intptr handle of the device A & C.
Is this possible?
Right now, when the application detects Device B is reconnected and powered up, the application re-scan all of usb devices (and filters out specific Product ID & Vendor ID), all of 3 devices gets new handle/instance.
|
|
|
|
|
I'd guess (a wild guess) that the handle for A and C wouldn't change if it's being used when B is disconnected/reconnected.
(maybe google how multiple USB TV-tuners keep using the ones that arent dis-/re-connected)
|
|
|
|
|
|
I'm using Compact Framework 3.5 on a phone to contact a WCF-service, but I think my question is more related to this message board.
When the code below is called a second time, from a class that is implemented as a singleton, it ends in som really unexpected errors.
It works fine the first time it's run.
MaintenanceService svc = new MaintenanceService();
List<Assignment> assignments = svc.GetAssignments().ToList<Assignment>;
The second time, it randomly throws 2 different exceptions (only one each time):
- Sometimes it's a TimeOutException
(System.Net.HttpWebRequest... - in VS-generated code).
- And Other times it's a ObjectDisposedException
(system.threading.timer for the WCF-TimeOut - in VS-generated code).
If I use the same code from a Button_Click in a Form, it works every time, so I know it's not the service that are causing the error.
I really need som help on this one?
|
|
|
|
|
Michael9000 wrote: from a class that is implemented as a singleton, Is it your intent to reuse an existing client proxy?
/ravi
|
|
|
|
|
Not necessarily.
I'm using a static Maintenance-class (where the previously posted code is called from a static method), because it has to make the same list of objects available throughout the entire app (Gui+Backend).
Edit: svc.dispose don't make any difference after the code in opening-post.
(Performance doesn't really matter - time does (my deadline is in approximately 48 hours).)
Any ideas are welcome. I'm stuck (I'm probably thinking about this i a wrong way) ?
|
|
|
|
|
OK, I was just concerned you were reusing a cached client proxy. I tried the same thing a while ago (in the interests of not having to recreate the proxy) and ended up getting burned by (a) disposed objects and (b) the channel being in a faulted state if an uncaught exception occured on the server.
Can you confirm that your static class is in fact using (or serving up) a new instance of the proxy every time it's used?
/ravi
|
|
|
|
|
What you described is exactly whay I'm getting (a and b).
Not entirely sure what you mean, but I create a new for each call
public static class
{
public static List<Assignment> Test()
{
MaintenanceService svc = new MaintenanceService();
List<Assignment> assignments = svc.GetAssignments().ToList<Assignment>;
svc.Dispose();
return assignments;
}
}
|
|
|
|
|
Does this help?
public static List<Assignment> Test()
{
MaintenanceService svc = new MaintenanceService();
svc.InnerChannel.OperationTimeout = new TimeSpan (1, 0, 0);
List<Assignment> ret = svc.GetAssignments().ToList<Assignment>();
Debug.Assert (ret != null);
List<Assignment> assignments = new List<Assignment>();
foreach (Assignment a in ret) {
assignments.Add (a);
}
return assignments;
}
/ravi
|
|
|
|
|
Did you just read my offline code or my mind!? That's 99,9% the original code except 'svc.innerC...' and my out-commented 'Debug.' Now that's thougths that I like
It's getting a little late in the evening here, so I'll have to try it tomorrow morning.
But it seems you like you know the "little thing" I need to change
|
|
|
|
|
Thanks. I couldn't find InnerChanel on the svc, so I'll see if I can find another way around it.
|
|
|
|
|
Crap - I forgot you're using the CF. The property may be missing for that version of .NET.
/ravi
|
|
|
|
|
Some more thoughts:
- Have you tried setting the timeout of the client proxy (at run-time) to a comfortably high value?
- Is there an uncaught exception occuring on the service end?
- Is the returned list guaranteed to be not-
null ?
/ravi
|
|
|
|
|
You think like me , that was som of the first things I tried - without success.
Ravi Bhavnani wrote: Have you tried setting the timeout of the client proxy (at run-time) to a comfortably high value?
Yes, tried that as the first thing. Changed timeout to 180 seconds (server responds in less than 4 seconds).
Ravi Bhavnani wrote: Is there an uncaught exception occuring on the service end?
Not likely. The server always responds with, at least, a empty List within 4 seconds.
(same for another test-method that simply takes a string and returns the same string).
Ravi Bhavnani wrote: Is the returned list guaranteed to be not-null?
Yes. (at minimum it's a empty List of objects).
modified on Monday, January 17, 2011 6:54 PM
|
|
|
|
|
I am researching a job position and was curious if anyone deals with Dynamics GP on the regular? I am basically wondering if this is a new language that I will have to learn or can I utilize C# and/or vb.net to work with it? I viewed a project that was created in this a few months ago and looked like really ugly code.
I am weighing the pro's and con's of this and deciding if it would be worth leaving a job using c#/vb.net to go exclusively to developing GP. Is it a great pain or nice to work with? Can you use c# or vb to code or do I have to use the ugly code I viewed sometime ago?
Thanks,
|
|
|
|
|
Thanks, but I finally figured it out.
I am fairly new to VB.net but I am getting by. I am almost clueless about C# though. I have managed to find a C# function that does what I need
and have converted it with the online code converter. It runs in VB and works but two of the four calculations are not working. (I had hoped to get it
working in C# to test the formulas.) It takes a string (a mapping Tile Quadkey, 02311102221333130 for example) and calculates the bounding box for that
map tile(Lat/Lon) corner positions coordinates of the four corners). The calculated values W (West Longitude) N (North Latitude) E (East Longitude) and
S (South Latitude). I have set up a new C# project, a console app. I have used the code at bottom and created a new class in that program. On the form Program.cs
I don't have a clue about how to make use of that class. The test value would be Quadkey = "02311102221333130"
It appears that it returns a string of the array bounds, values separated by commas.
If someone wanted to convert this to working VB.net that would really great, but I hardly expect that.
The corrected, working calling procedure. I guess that I knew even less than I thought.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
WMSHandler outCl = new WMSHandler();
double N = 0;
string MyString = outCl.QuadKeyToBBox("02311102221333130");
Console.WriteLine(MyString);
Console.ReadLine();
}
}
}
But that is not working. Any help would be appreciated.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
using System;
using System.Math;
using System.IO;
public class WMSHandler
{
public const int TILE_HEIGHT = 256, TILE_WIDTH = 256;
public string QuadKeyToBBox(string quadKey)
{
int zoom = quadKey.Length;
int x = 0, y = 0;
for (int i = zoom; i > 0; i--)
{
int mask = 1 << (i - 1);
switch (quadKey[zoom - i])
{
case '0':
break;
case '1':
x |= mask;
break;
case '2':
y |= mask;
break;
case '3':
x |= mask;
y |= mask;
break;
default:
throw new ArgumentException("Invalid QuadKey digit sequence.");
}
}
double W = (float)(x * TILE_WIDTH) * 360 / (float)(TILE_WIDTH * Math.Pow(2, zoom)) - 180;
double N = (float)Math.Asin((Math.Exp((0.5 - (y * TILE_HEIGHT) / (TILE_HEIGHT) / Math.Pow(2, zoom)) * 4 * Math.PI) - 1) / (Math.Exp((0.5 - (y * TILE_HEIGHT) / 256 / Math.Pow(2, zoom)) * 4 * Math.PI) + 1)) * 180 / (float)Math.PI;
double E = (float)((x + 1) * TILE_WIDTH) * 360 / (float)(TILE_WIDTH * Math.Pow(2, zoom)) - 180;
double S = (float)Math.Asin((Math.Exp((0.5 - ((y + 1) * TILE_HEIGHT) / (TILE_HEIGHT) / Math.Pow(2, zoom)) * 4 * Math.PI) - 1) / (Math.Exp((0.5 - ((y + 1) * TILE_HEIGHT) / 256 / Math.Pow(2, zoom)) * 4 * Math.PI) + 1)) * 180 / (float)Math.PI;
double[] bounds = new double[] { W, S, E, N };
return string.Join(",", Array.ConvertAll(bounds, s => s.ToString()));
}
}
}
modified on Monday, January 17, 2011 11:18 AM
|
|
|
|
|
Don't bother converting it. Leave it in VB.NET as a class library, and add that as a reference to any application that needs it. The whole point of .NET is supposed to be language neutrality.
|
|
|
|
|
I Agree, but if you want to see how it can be done in c#, create a new WinfowdFormsApplication and take a look at it's Program.cs
|
|
|
|
|
Why would I want to do this? The OP doesn't get replies to posts sent to me, so you might want to address it to him instead.
|
|
|
|
|
Pete O'Hanlon wrote: The OP doesn't get replies to posts sent to me, so you might want to address it to him instead.
Ooops, didn't know that, 'cause That's the most common way in other forums
|
|
|
|
|
When I ran it through the converter found here:
http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
I got this:
Public Function QuadKeyToBBox(quadKey As String) As String
Dim TILE_HEIGHT As Integer = 256
Dim TILE_WIDTH As Integer = 256
Dim zoom As Integer = quadKey.Length
Dim x As Integer = 0
Dim y As Integer = 0
For i As Integer = zoom To 1 Step -1
Dim mask As Integer = 1 << (i - 1)
Select Case quadKey(zoom - i)
Case "0"C
Exit Select
Case "1"C
x = x Or mask
Exit Select
Case "2"C
y = y Or mask
Exit Select
Case "3"C
x = x Or mask
y = y Or mask
Exit Select
Case Else
Throw New ArgumentException("Invalid QuadKey digit sequence.")
End Select
Next
Dim W As Double = CSng(x * TILE_WIDTH) * 360 / CSng(TILE_WIDTH * Math.Pow(2, zoom)) - 180
Dim N As Double = CSng(Math.Asin((Math.Exp((0.5 - ((y * TILE_HEIGHT) / (TILE_HEIGHT)) / Math.Pow(2, zoom)) * 4 * Math.PI) - 1) / (Math.Exp((0.5 - ((y * TILE_HEIGHT) / 256) / Math.Pow(2, zoom)) * 4 * Math.PI) + 1))) * 180 / CSng(Math.PI)
Dim E As Double = CSng((x + 1) * TILE_WIDTH) * 360 / CSng(TILE_WIDTH * Math.Pow(2, zoom)) - 180
Dim S__1 As Double = CSng(Math.Asin((Math.Exp((0.5 - (((y + 1) * TILE_HEIGHT) / (TILE_HEIGHT)) / Math.Pow(2, zoom)) * 4 * Math.PI) - 1) / (Math.Exp((0.5 - (((y + 1) * TILE_HEIGHT) / 256) / Math.Pow(2, zoom)) * 4 * Math.PI) + 1))) * 180 / CSng(Math.PI)
Dim bounds As Double() = New Double() {W, S__1, E, N}
Return String.Join(",", Array.ConvertAll(bounds, Function(s__2) s__2.ToString()))
End Function
I have no idea how this is going to work because I just converted it and pasted it here (with some corrections where the converter incorrectly inserted backslashes in the converted code).
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Thanks, I just tried it again myself and got another error message"-- line 3 col 8: invalid TypeDecl"
That is the converter that I was using yesterday.
Anyway the conversion that you posted is something that I can work with. Thanks again.
|
|
|
|
|