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
G

grmihel2

@grmihel2
About
Posts
36
Topics
13
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Combobox displayMembers with .dbml objects
    G grmihel2

    Just realized that I've never used the partial function before, so I'm not sure how to attack it. Could you gief an example plz? I have a CRUD (Create, Read, Update, Delete) class for handeling all the email specific methods like: public Email GetAllEmails(){} The Email class is within the DataClass Datacontext, and thats the one who is getting regenerated each time I have a db scheme change. Could you give an example of how to make this partial class for a ToString() for the Email class? Here is a short outtake of the CD (Class Diagram): http://imageshack.us/photo/my-images/36/classdiagram.jpg/

    C# csharp database linq question

  • Combobox displayMembers with .dbml objects
    G grmihel2

    Thanks, that will work for sure. But it still feels like some kind of 'hack' in the structure. Ain't there any official way to do it, like 'click here and choose which data field to be shown as display member', for non-DataSources (like generic lists)??

    C# csharp database linq question

  • Combobox displayMembers with .dbml objects
    G grmihel2

    Are there any genius way to make Display and value member object related to the object in the combobox? As you can see in the following code, I'm using IEnumrable of Email objects to add into the combobox, and the Email are an entity object related to the LinQ (.dbml) object mapped from the database (which means each object itself contains value fields from the database). comboBox_n1.Items.Clear(); comboBox_n1.Items.AddRange(_controller.getEmailList().ToArray<Email>()); comboBox_n1.Sorted = true; comboBox_n1.SelectedIndex = -1; Right now it shows an object string like: 'MyApp.Email' for each object in the list. Before now, I have made a ToString() in the .dbml code, for each object which ofcause works, but it ain't a sustainable solution since it will dissapear each time I made a change to the datamapper. So are there any way to auto generate these display members??

    C# csharp database linq question

  • Data Mapping in PHP
    G grmihel2

    Cheers, will look at the possibilities. So, when you have to program a PHP web app by your own, do you hand code all patterns needed to control objects between each others? Like controlling FKs between relations.

    Linux, Apache, MySQL, PHP csharp database php html visual-studio

  • Data Mapping in PHP
    G grmihel2

    Hi there, I'm quiet new to the PHP language, tho I have mostly programmed in C# in .NET platforms. Now I want to get some experience with the opensource part of the web development. I know the basic coding for PHP (the syntax), but I'm not sure about which app is the best to make dynamic PHP programming in (like MS Visual Studio for C#), which patterns is a most, which do I have to code by hand, and which can be autogenerated by the developer app? I'm especially curious about the possibilities of doing DataMapping, like DataBase Markup Language/LinQ to SQL in Visual Studio for C#, where Database tables are being related to code objects like: UML diagram: http://yuml.me/diagram/scruffy/class/[Phones]1->*[Category] Code with ORM to the DB table: Phone p = new Phone(); Or how do you guys handle objects in PHP, where Foreinger keys between tables can happen, in a easy way?

    Linux, Apache, MySQL, PHP csharp database php html visual-studio

  • Application directories for Form App?
    G grmihel2

    IoC? I havn't practically used that pattern yet, but ain't that some kind of Facade/Controller pattern? But after what I see in replys, I guess that making folder in the solutions for keeping subsystems controlled, is a good idea, and may be the correct use depending on size of application? And add the using .Marketing or .Management in the classes, sounds like a nice trick instead of editing 10000 lines of code.

    C# sales question

  • Estimate the cost of a Software application
    G grmihel2

    I agree that it ain't directly connecting to the computer science approach, and sounds more likely to be a marketing approach. But I guess he ask on a development forum in the fact that he doesn't know the software price estimate variables... But as Eddy say's, its a combination of many variables related to a giving project.

    Design and Architecture sales help

  • Chat Feature
    G grmihel2

    Your question ain't really related to 'Desgin and Architecture'. I think you will be better of, asking this question in one of the forums related to the technology you are using, eg. asp.net.

    Design and Architecture lounge

  • GRASP: Controller architecture, correct and wrong.
    G grmihel2

    But won't it just be another class class with duplicated code, containing all the method's from sub-controllers? Or are there any smart way to do it?

    Design and Architecture question database graphics design business

  • Application directories for Form App?
    G grmihel2

    I have a kinda hugh client Form Application running and maintaining. It consist of two sub-systems, 1 for marketing and 1 for management. It started as a Management applicaiton, created in VS08, so all classes etc. thats created for the Management sub-system (that was the first), was inside the Project root.... Later when I added Marketing Subsystem, I created a directory in the Project root, named 'Marketing' and afterwards I created every single Class and stuff related to Marketing in that folder. But making folder for sub-systems also means that I have to call Class' and objects from each folder, with the foldername in front. Eg.: Marketing.Customer newCustomer = new Marketing.Customer(); instead of: Customer newCustomer = new Customer(); But is it right or wrong to make those folders for each subsystem, to keep an easy overview of your application? Or should I forget everything about folders in the solution?

    C# sales question

  • GRASP: Controller architecture, correct and wrong.
    G grmihel2

    I've developed on an application for quiet long now, and it consist of 2 sub systems, 1 for Marketing and 1 for Management. They have an seperated DB each. Now I have an UI that have to pick information in both databases, and I wondered if my controller pattern was correct, since I somehow got the idea that a UI that have connection to both Controller Facades, must be somehow incorrect? My original setup was like this:

          \[UI\]
    

    ------Controllers------

     \[Business Logic\]
    

    ------Datacontext------

    MarketingDB | ManagementDB

    I don't know if it give you any sense? The controller on the drawing consist of the 2 controllers described above. Would it be right to make an on-top controller and call that one FrontController, so ALL UI's are connection to the FrontController no matter if they are Marketing UIs or Management UIs? Imo that gives you the ultimate of low coupling between UI and business layer, and lowest coupling between the Controllers and the UI layer, but I don't know if this is 'correct' or wrong? What is your oppinion??? I have two drawings to show the concept I wanted to do: http://img192.imageshack.us/i/controllerdomaincontrol.jpg/[^] ONLY FrontController: http://img62.imageshack.us/i/controllerfrontcontroll.jpg/[^] Which one would you prefer as correct architecture? And why?

    Design and Architecture question database graphics design business

  • text file > Binary and Binary > Text file
    G grmihel2

    Thanks a lot! That worked like a charm... I certainly need to study some more of the FileStreamers posibilities, thats a whole new world opening, but ain't that the beauty of coding, to explorer new posibilities? :) Yet again, thnx for your expertise, it works brilliant now.

    C# database question help tutorial

  • text file > Binary and Binary > Text file
    G grmihel2

    True, I can see that the Write method didn't make sense :) I'm not really used to do these RW files programming, so I'm sorry for newbieness, but you have to learn it some how :) Anyways, I have attempted to rewrite another write method like this:

        public void WriteFile(string filePath, StoredFile file)
        {
            byte\[\] data = file.FilContent.ToArray();
            FileStream fileStream = new FileStream(@"d:\\temp\\doctest.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            try
            {
                int length = (int)data.Length;
                int buffer = 1000;
    
                fileStream.SetLength(length);
                fileStream.Seek(length - buffer, SeekOrigin.Begin);
                fileStream.Write(data, 0, buffer);
                fileStream.Flush();
            }
            finally
            {
                fileStream.Close();
            }
        }
    

    The doctest.docx file is now 14KB as the original, so something seems right. But the file is still somehow corrupted, cuz I can't open the docx without an error message telling me the data in the Word document is wrong... Notice that the file.Filcontent is the varbinary value from the Database. By the way, is it really so simple, that when I'm sure that its a .docx file I store in my DB as varbinary, I can just store it on local machine as a file with the same extension? No need of creating a Word application object and write it through that?

    C# database question help tutorial

  • text file > Binary and Binary > Text file
    G grmihel2

    Oh yes, sorry, the WriteFile function is following:

    public byte[] WriteFile(string filePath, StoredFile file)
    {
    byte[] buffer = file.FilContent.ToArray();
    FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
    try
    {
    int length = (int)fileStream.Length; // get file length
    buffer = new byte[length]; // create buffer
    int count; // actual number of bytes read
    int sum = 0; // total number of bytes read

                // read until Read method returns 0 (end of the stream has been reached)
                while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)
                    sum += count;  // sum is a buffer offset for next reading
        }
        finally
        {
            fileStream.Close();
        }
    
        return buffer;
    

    }

    C# database question help tutorial

  • text file > Binary and Binary > Text file
    G grmihel2

    I try'd the following (had no clue where to start, so just gave it a try with BinaryWriter):

    public void DownloadFile(string filSti, StoredFile fil)
    {
    byte[] file = WriteFile(filSti, fil);
    BinaryWriter bw = new BinaryWriter(File.Open(@"d:\temp\doctest.docx", FileMode.OpenOrCreate));
    bw.Write(file);
    bw.Close();
    }

    Didn't worked that well... It created a .docx file of 32KB (the original was 14KB), and when I try to open it, Word says it cannot be open be cause it may be broken.. Any hint what to do? I have an idea then when I see the light of the end, it would be 'easy' to do the same operation for the PDF documents :)

    C# database question help tutorial

  • text file > Binary and Binary > Text file
    G grmihel2

    The view function is kinda cool, but my problem is, the code ain't ASP, but plain old winforms, and can't find a link between the asp view function and similar function for winforms?

    C# database question help tutorial

  • text file > Binary and Binary > Text file
    G grmihel2

    I used FileStream like this:

    public byte[] ReadFile(string filePath)
    {
    byte[] buffer;
    FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
    try
    {
    int length = (int)fileStream.Length; // get file length
    buffer = new byte[length]; // create buffer
    int count; // actual number of bytes read
    int sum = 0; // total number of bytes read

                // read until Read method returns 0 (end of the stream has been reached)
                while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)
                    sum += count;  // sum is a buffer offset for next reading
            }
            finally
            {
                fileStream.Close();
            }
            return buffer;
        }
    

    and stored the returned value byte[] as the varbinary into the Database... Try'd to figure the reverse way back, but didn't worked that well tbh, maybe because I didn't do it the write way, but when I stored it as .docx the file was 'damage' and when I store it as .txt there is just binary numbers.

    C# database question help tutorial

  • text file > Binary and Binary > Text file
    G grmihel2

    Hi guys... I have need some help cuz I'm totally lost of how I should figure this out... My case is: - Make a storage function, so text documents like PDF, docx, doc, can be stored in the Database (MSSQL08 express). Functions: - Show files in a ListView (check) - Upload files selected from the client, and store them as varbinary(max) in the Database (check) - Download the selected file on the ListView to the correct documenttype on the clients PC (uncheck) My database table is quiet simple and look something like: ID - int (Primary key)NOT NULL (is identity) FileName - varchar(50)NOT NULL FileContent - varbinary(MAX)NOT NULL FileExt - varchar(8) NOT NULL FileComment - varchar(MAX) NULL So as you can see, I can with ease locate if the selected file got .doc og .pdf extension. The storage of a file into the varbinary of byte[] works brilliant! But I'm stucked at how do I download those selected files back to the client, so they look excatly the same as when the document got uploaded to the db? I mainly have two types of documents stored: - WORD files - PDF files Can anyone provide at codesnippet or anything, that shows how to make a varbinary file (with bytes) into a appropreated document on the client computer readable as WORD document and/or PDF?

    C# database question help tutorial

  • UTF-8 format with mail()
    G grmihel2

    Hi php folks... I decided to try to make an PHP script that a webform could call, to send an email, so I doesn't need the ugly mailto:xxx@yyy.domain in the form action. So I have 2 pages. 1 frontend (html) and 1 backend (php). The frontend contain an webform that on submit using the backend php as action, so its like: index.html sendemail.php action="sendemail.php" (in the index.html form). Everything works fine, and I recieving the emails as supposed... I have configured the php.ini to use my own smtp server (which I use at work too, so I know the SMTP server works). the issue now is, that I want to send my emails as utf-8 format, cuz the need of some special characters inside the email?!? I'm using the mail($to, $subject, $body, $header); as function right now... And when I type in some utf-8 formatted characters like ø, its viewed as ?? in the recieved email :( How can I send my email()'s as utf-8? I have try following: - Set header of the email to utf-8:

    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-Type: text/plain; charset=utf-8' . "\r\n";
    $headers .= 'From: ' . $_POST['email'] . "\r\n";

    I'm using Eclipse PHP as php editor for development.

        $dato = date("d-m-y");
    $to = "your@domain.dk";
    $subject = "Web $dato";
    $headers = 'MIME-Version: 1.0' . "\\r\\n";
    $headers .= 'Content-Type: text/plain; charset=utf-8' . "\\r\\n";
    $headers .= 'From: ' . $\_POST\['email'\] . "\\r\\n";
    
    if($\_POST\['street'\] != "")
    	$street = $\_POST\['street'\];
    if($\_POST\['no'\] != "")
    	$no = $\_POST\['no'\];
    if($\_POST\['floor'\] != "")
    	$floor = $\_POST\['floor'\];   	
    if($\_POST\['name'\] != "")
    	$name = $\_POST\['name'\];
    
    //Set email body
    $newline = "\\r\\n";
    $body = "Date: $dato" . $newline .
    $street . " " . $no . ", " . $floor . "." . $nnewline .
    $navn;
    			
    //Send email
    mail($to, $subject, $body, $headers);
    

    Whitebox test: Input: $street = "ø"; $no = "53st"; $floor = "2nd"; $name = "æøå"; $dato = "20-09-2010"; Output SHOULD be:

    Date: 20-09-2010
    ø 53st, 2nd.
    æøå

    Actual output:

    Date: 20-09-2010
    ?? 53st, 2nd.
    ??????

    Linux, Apache, MySQL, PHP question php html database sysadmin

  • How to get the mac address on a specific switch port?
    G grmihel2

    Thanks for your suggestions, but it didn't quiet make my solution. I'm looking for an API with a DLL I can use for this purpose, I want to use the existing SNMP protocol with correct MIBs and OIDs to collect and find the mac address on a switch port which is already known. I have almost figured out at this time, how I locate a switch port based on a known mac address, but I want the opposite options if even possible? My last thoughs was read the FDB table mib request (which should return all mac address' and portnumber for each?), and sort them after the port number? But I stumbled on it, cuz it seems that it returns some wrong bits (which ain't representing the MAC address in HEX string). Any other suggestions, that could help me using the SNMP and mibs, collecting a mac address, on a KNOWN switch port?

    C# tutorial sysadmin help question
  • Login

  • Don't have an account? Register

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