Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

MrEyes

@MrEyes
About
Posts
351
Topics
166
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • SOAP Messages - Intercepting and redirecting the HTTP call to a remoting server
    M MrEyes

    Hello all, As most of you will already know, when one imports a WSDL into a project the resulting web reference allows the developer to call the WSDL methods, for example:

    int resultCode = DoSomething(valueA, valueB, ref valueC, out valueD);

    However, this import wraps the entire message creation / send / result parsing into code that is embedded with .NET libraries. I need to "intercept" the raw outgoing SOAP message and send it somewhere else via remoting. The server at the end of the remoting call will then perform the HTTP send and synchronously return the raw SOAP response. I then need to parse the SOAP response so that it can be parsed into the return/ref/out objects the method (as above) returns. Does anybody know of a way to do this? My original stab was to create a code generator app (as an alternative to adding a web reference) that would read the WSDL and generate a callable stub. However I am having trouble generating the SOAP messages and parsing the incoming sync response. So another question would be: Does anybody know of a way to create/deconstruct SOAP messages?

    C# wcf question csharp sysadmin hardware

  • Silly Duncan
    M MrEyes

    Not entirely fair Some men would have a more streamlined "keel" than others ;)

    The Lounge help announcement

  • A thief
    M MrEyes

    I prefer this one myself: select top 42 * from tablename where('the meaning of life' != 'answered');

    The Lounge database

  • Heres a simple mathematical/statistical question
    M MrEyes

    The thing is people might not visit everyday so could easily have their vote excluded from the calculations. Here is another of my alternative solutions, which I think might work: Assuming the following: 5 - Excellent, 4 - Good, 3 - Average, 2 - Bad, 1 - Terrible Deduct 3 from each score: 2 - Excellent, 1 - Good, 0 - Average, -1 - Bad, -2 - Terrible (Total adjusted scores) / (Total of days the message was publicly available).

    The Lounge question css functional help

  • Heres a simple mathematical/statistical question
    M MrEyes

    Possibly suck a thumb :), that was one of my possible solutions but it doesn't work: Message 1 (10 Days) 4, 2, 1, 1, 1 = (9 / 5) / 10 = 0.18 Message 2 (40 days) 1, 1, 1, 1, 3, 1, 1 = (9 / 7) / 40 = 0.03 Message 3 (40 days) 5, 5, 5, 4, 5, 4, 3 = (31 / 7) / 40 = 0.11 Message 3 is obviously the better message, but message 1 wins here as it has a higher "total"

    The Lounge question css functional help

  • Heres a simple mathematical/statistical question
    M MrEyes

    Lets say that Codeproject is running a competition for the best message, entries to this competition can be made from the 1st to the 31st of January. The winner of the competition is decided, by Codeproject members, via the existing and immutable message rating system. Rating is open from the 1st January to the 7th February (i.e. competition entry time plus one week). Now here's the problem, how do you decide who the winner is? Obviously summing the points (1 to 5) is the simplest answer, however this has a few critical flaws:

    Lets say a message is posted on the 2nd January - this will
    be available for public ratings for almost 5 weeks. However
    if a message is posted on the 30th of January, it is only
    available for rating for around a week. So it will most
    likely have less votes and therefore a lower score.

    Lets say a message is rated 1 a total of 15 times, this will
    score 15 points - another entry may have been rated 5 twice
    and therefore score 10 points. However the second entry is
    obviously better than the first as it has more 5 ratings.

    The rating system and assigned points cannot be changed, so the question is: Considering the flaws - how do you decide which entry is the winner on the morning of the 8th February? My current solution sums all the votes and divides by the total days the message was publicly available, this effectively gives an average daily vote total, the highest total wins. However this does not really take into consideration the second flaw.

    The Lounge question css functional help

  • General UI Question - Anybody can have a go at this one
    M MrEyes

    Cursed with fat fingers and the lack of a typing wand :doh:

    C# design help tutorial question lounge

  • General UI Question - Anybody can have a go at this one
    M MrEyes

    Not a technical question, rather a fairly nebulous question about a UI design. In summary, I have an application that may or may not perform a task every minute. I need to create a visual representation of when this task will be performed over a day/week. Something like a time line where a user can view a single day/week that displays when the task will execute. As an example, the task is configured to execute at 12,34,45,50,56 past the hour in the hours 1,4,8,15,18,20,21,22 The problem is that there are 2440 minutes in a day, so creating a visual UI is somewhat complicated. Unless of course the user has a 500 inch wide screen monitor :omg: Just incase anybody has heard of it, I am trying to create this for Crontab jobs.

    C# design help tutorial question lounge

  • Yet another LHC joke
    M MrEyes

    There is more to this than you think: http://img71.imageshack.us/img71/6058/376a30b9c823c84df0fb425vd1.jpg[^]

    The Lounge question

  • Call a .NET 2.0 library from a .NET 1.1 Library [modified]
    M MrEyes

    I like the cut of your jib, however.... When I find a hack frig solution this will be deployed out to over 10 thousand servers and unfortunately the current build of these does not have MSMQ installed. Installing this as part of the deployment process is not feasible.

    C# csharp sysadmin question

  • Call a .NET 2.0 library from a .NET 1.1 Library [modified]
    M MrEyes

    Title says it all really, is it possible to call a .NET 2 library from a .NET 1.1 library? The obvious and immediate answer is no, as the 1.1 library will be running in a 1.1 AppDomain that does not include the 2.0 framework. However is there anyway to "bridge" across, maybe remoting/custom socket server?

    modified on Thursday, September 25, 2008 8:47 AM

    C# csharp sysadmin question

  • Remoting : Server calling another [modified]
    M MrEyes

    After much hair pulling I have found a solution to this problem, I am not particularly happy with it but it is a solution none the less. After doing some further debugging it seems that when the A to B request is made the .NET Framework pushes this into the incorrect channel (i.e. the Client to A) as this channel has different sinks, when B receives the data it is unable to process it. Interestingly if I unregistered the Client to A channel the A to B call would work, obviously this isn't a solution as this then breaks all Client to A comms. At first it seemed that the solution was obvious, make sure that the correct channel is used. After much googling I have been unable to find a method of doing this. I did however find alot of people with the same problem ;) So the solution... The server B remoting framework has a client library which is installed on A. This library contains all the methods that B exposes across remoting. The solution was to create a wrapper around this client library, on instantiation the wrapper creates a new AppDomain and loads the client library into it. I then use a marhsalled transparent proxy object across to call the client library. Doing this means that the new AppDomain on has a single TcpChannel registered and therefore the selection issue doesn't exist. As always with these things there was a gotcha, which is if you leave the AppDomain unused for more than 5 minutes (default) the lease expires and the proxy fails. This can be fixed by, in the client library, overriding "InitializeLifetimeService" and returning null. So, wrapper code:

    public sealed class ClientLibraryWrapper
    {
    AppDomain clientDomain;
    ServerB.Client.EntryPoint client;

    public ClientLibraryWrapper
    {
    	this.clientDomain = AppDomain.CreateDomain("ServerBClientDomain");
    	Assembly clientAssembly = Assembly.LoadFile(Environment.CurrentDirectory + @"\\ServerB.Client.dll");
        this.clientDomain.Load(clientAssembly.FullName);
        
        Object obj = mhsClientDomain.CreateInstanceAndUnwrap(clientAssembly.FullName, "ServerB.Client.EntryPoint");
        this.client = (ServerB.Client.EntryPoint)obj;
    }
    
    public int ServerBMethod()
    {
    	this.client.ServerBMethod();
    }
    

    }

    Client library code:

    public sealed class EntryPoint : MarshalByRefObject
    {
    public override object InitializeLifetimeService()
    {
    return null;
    }

    public int ServerBMethod()
    {
    	return 1;
    }
    

    }

    C# sysadmin security help question workspace

  • Remoting : Server calling another [modified]
    M MrEyes

    Apologies for the vague thread title, the following is a tad complicated to summarise well. Anyway, enough excuses... Lets say I have a multi tier application that consists of 1 client and 2 server applications (A & B). Both servers have remoting listener services each of which are entirely self contained and do not share any common sinks, both remoting frameworks contain a custom encryption sink (each of which are entirely independent implementations) In my current setup, the client pushes all its requests to server A. Some of these are handled within A others require a server A to server B remoting call. Now here's the problem: When server A is invoked by the client and this requires a remoting call to server B the call from A to B fails with a CryptographicException. It seems that for some reason the A to B encryption sink is not being called, so when B receives the data it cannot decrypt as the format is invalid. Does anybody have any ideas of what could be happening here? p.s. Interesting if I code the client to remote directly to A or B then these calls work without any issues.

    modified on Wednesday, September 10, 2008 1:05 PM

    C# sysadmin security help question workspace

  • Recruiter fees
    M MrEyes

    In a previous life I worked as a slave trader recruitment consultant in the UK, so.... Typically when a candidate is placed in a company the recruitment company receives a single one off fee which in my experience the company always pays. This fee depends on any agreements between the company and the recruitment agency and can be anything from 5% to 40% of the starting salary. When I was doing the job the average fee was 17% and we would drop to 10% for companies that regularly used our services. I have to admit I have never come across any recruitment agency that requires the placed candidate to pay a fee, however as this is Japan and I have no experience of this I do not want to stick my neck out and say that your friend has misinterpreted. I would suggest that your friend contacts the recruiter and clarifies the fee structure/responsibilities. If he is required to pay I would also ask if this fee can be paid over an agreed period of time (i.e. via instalments), 10% of your salary is a large amount of money to pay out in one lump some.

    The Lounge question career help

  • Accessing index arrays via string keys [modified]
    M MrEyes

    Yes they do, however what I don't know how to do is encapsulate the XSD tool generate simple array with a StringDictionary while keeping everything in sync and not breaking the (de)serialiser, and therefore allow the following:

    string val1 = widget[0]
    string val2 = widget["mykey"]

    Console.Writeline(val1 == val2)

    Which would output true

    C# question database data-structures xml help

  • Accessing index arrays via string keys [modified]
    M MrEyes

    Well thats the idea, wrap the base array with a StringDictionary. However I need to keep the StringDictionary and base array in sync as code adds/edits/removes items regardless of whether this is done by string key on integer index. So the question is how to do it?

    C# question database data-structures xml help

  • Accessing index arrays via string keys [modified]
    M MrEyes

    Christian Graus wrote:

    Quick ? What sort of subject line is that ?

    An extremely poor one, my error - we all make them from time to time :doh:

    Christian Graus wrote:

    The obvious solution is a Dictionary, that's what they are for.

    Yes, however as mentioned in the original post, I am working with classes generated by the XSD tool. As such I need underpin the stringdictionary with the simple arrays this tool creates and keep the array and the dictionary in synchronisation as code adds, removes, edits values. Unfortunately this is where I am not sure where to go or what to do.

    C# question database data-structures xml help

  • Accessing index arrays via string keys [modified]
    M MrEyes

    Hello all, I have an array of a simple object type:

    class EntryPoint
    {
    private widgets[];

    public EntryPoint()
    {
    this.widgets = new widgets[1000]

    ...code here to populate 1000 widgets...
    }

    public Widgets[]
    {
    get { return this.widgets; }
    }
    }

    class widgets
    {
    public string key;
    public string value;
    }

    Now, elsewhere in the the application, I need to be able to extract values from the widgets[] from instances of EntryPoint. However I need to be able to do this using the string key, not the index number. So the question is how can I do this? A hacking but slow way is something like this:

    public string GetWidgetValue(string key)
    {
    string returnValue = null;

    foreach(widget w in this.widgets)
    {
    if (w.Key == key)
    {
    returnValue = w.value;
    break;
    }
    }

    return returnValue;
    }

    This would work, however as mentioned enumerating through the array for every value request could prove to be slow. So can anybody give me an idea of what to do? A perfect solution would be to encapsulate the base array with something like a StringDictionary and therefore do something like this:

    EntryPoint ep = new EntryPoint();
    string value = ep.Widgets["widgetkey"];

    So the question is, how to do this? Obviously the sample above is a simplified version of the question, in reality I am working with an array that is generated by deserialising an XML file into a class generated by the XSD tool. This means that unless I ditch XSD for something else (any suggestions?) I am stuck with integer indexed arrays.

    modified on Friday, May 9, 2008 7:23 AM

    C# question database data-structures xml help

  • Enums and text descriptions
    M MrEyes

    Initially I did consider XSLT, however the input XML is a rather interesting example of XML usage, so creating the XSL transform would have been extremely convoluted. As an example the input XML is entirely attribute based and attribute values and presence depend on the value and presence of other attributes. So for example these two samples represent two different people (customer, staff)

    C# tutorial

  • Enums and text descriptions
    M MrEyes

    Well to cut a very long story short I am currently in the throws of creating an XML data transformation library. Unfortunately for me neither XML structure can be schema'd and these are also out of my control and cannot be change. To get around this I have created a series of enums for the 100's of different keys these items contain, so now I am trying to create mapping data from one to the other. It could be done with switch/case statements, however this is messy and will be complicated to maintain. So I am attempting to use attributes on the input enums to easily convert these to the output format. So for example each data structure contains the concept of Address Type, e.g.

    public enum OutputAddressType
    {
    [Description("ResidentialAddress")]
    Residential,
    [Description("CommercialAddress")]
    Commericial,
    [Description("UnknownAddress")]
    Unknown,

    }

    public enum InputAddressType
    {
    [Description("ADR001")]
    Home,
    [Description("ADR002")]
    HomeSecondary,
    [Description("ADR003")]
    Business
    }

    Now as I iterate through the input data object address values, I currently have a switch case that looks something like this:

    switch(input.AddressType)
    {
    case InputAddressType.Home:
    this.output.AddressType = OutputAddressType.ResidentialAddress;
    break;
    case InputAddressType.HomeSecondary:
    this.output.AddressType = OutputAddressType.Unknown;
    break;
    case InputAddressType.Business:
    this.output.AddressType = OutputAddressType.CommercialAddress;
    break;
    }

    It would be great if I could do something like this to the input enum:

    public enum InputAddressType
    {
    [ObjectDescription(InputAddressType.ResidentialAddress)]
    [Description("ADR001")]
    Home,
    [ObjectDescription(InputAddressType.Unknown)]
    [Description("ADR002")]
    HomeSecondary,
    [ObjectDescription(InputAddressType.CommercialAddress)]
    [Description("ADR003")]
    Business
    }

    The example above is a simple example, however if you imagine that there are over 200 of these enums, each having anywhere from 2 to 200 values you can see why having loads of switch/cases is unmaintainable. Also in the example there is a direct 1 to 1 map from input to output, however in the real world this is a rarity.

    C# tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups