Archive for Settembre, 2007

create user

Settembre 30th, 2007

Description: create a user using nbear

Link: http://www.codekeep.net/snippets/567f1f61-6453-4879-a6e6-77ec350a2345.aspx

 User[] aUsers = Gateways.SdaiBuy.From<Entities.User>().Where(Entities.User._.UserName == tbName.Text.Trim()).ToArray<Entities.User>();
        if (aUsers.Length > 0)
        {
            lblError.Text = "??????";
        }
        else
        {
            Entities.User aUser = new Entities.User();
            aUser.UserName = tbName.Text.Trim();
            aUser.Password = tbPassword.Text;
            aUser.College = ddlCollege.SelectedValue;
            aUser.dorm = ddlDorm.SelectedValue;
            aUser.HeadPic = "UpFile/UserFace/noname.jpg";
            int UserID = Gateways.SdaiBuy.Save<User>(aUser);

            Response.Redirect("Registerok.aspx?UserID=" + UserID);
        }

New website for FOREX signal service!!

maurodx Settembre 27th, 2007

www.happylifewithforex.com

This is the new website where you can register for a FOREX signal service with a desktop popup that tells you when to buy or sell a pair.

Come and register, service will start on October,1st

Crear un WSDL

Settembre 26th, 2007

Description: Explicación de como obtener un WDSL de un servicio web desplegado.

Link: http://www.codekeep.net/snippets/7eaea489-dea1-4be7-aa6b-0dadb08f1814.aspx

http://localhost:2802/Service1.asmx?wsdl

Para obtener el wsdl de un servicio basta con lanzarlo
y añadir a la url de invocacion "?wsdl" al final.

El Visual Studio cuando añade una referencia Web,
en realidad lo que hace es añadir este sufijo para
obtener el wdsl, y ejecutar internamente el wdsl.exe
que creará la clase proxy cliente para invocar al
servicio.

TestSnippet

Book Review: The Designer's Apprentice

Settembre 26th, 2007

One of the challenges facing computer artists is productivity, especially with repetitive tasks. Fortunately, this book shows you how to automate your workflow by using several types of scripting, including: AppleScript, JavaScript, VBScript, data-driven publishing and more. By Nathan Segal. 0926

Create image’s thumbnail

Settembre 26th, 2007

Description: Create a thumbnail from an image and save the thumbnail into it’s original image file format

Link: http://www.codekeep.net/snippets/52492b12-d17b-4dcd-acdf-c2c9fcb09f68.aspx

public bool MakeThumbnail(string thumb, string img, int width, int height, bool keepOriginalRatio)
    {
        System.Drawing.Image fullSizeImg;
        try
        {
            fullSizeImg = new System.Drawing.Bitmap(img);
        }
        catch (Exception ex)
        {
            return false;
        }

        if ((fullSizeImg.Width <= width) && (fullSizeImg.Height <= height))
        {
            //Smaller or same size as thumbnail so no need to do anything special
            try
            {
                fullSizeImg.Save(thumb);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        else
        {
            if (keepOriginalRatio)
            {
                if (width <= 0)
                {
                    width = height * fullSizeImg.Width / fullSizeImg.Height;
                }
                else if (height <= 0)
                {
                    height = width * fullSizeImg.Height / fullSizeImg.Width;
                }
                else
                {
                    float TargetRatio = width / height;
                    float CurrentRatio = fullSizeImg.Width / fullSizeImg.Height;

                    if (CurrentRatio > TargetRatio) //We'll scale height
                    { height = width / Convert.ToInt16(CurrentRatio); }
                    else // We'll scale width
                    { width = height * Convert.ToInt16(CurrentRatio); }
                }
            }

            System.Drawing.Image thumbNailImg = new System.Drawing.Bitmap(fullSizeImg, width, height);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumbNailImg);

            g.FillRectangle(System.Drawing.Brushes.White, 0, 0, width, height);
            g.DrawImage(fullSizeImg, 0, 0, width, height);

            try
            {
                thumbNailImg.Save(thumb, fullSizeImg.RawFormat);
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        return false;
    }

Create a comma delimited list

Settembre 25th, 2007

Description: This converts rows returned from a reader into a comma-delimited string.

Link: http://www.codekeep.net/snippets/07df10fa-37c2-4a2e-8bb1-b26c55cecc05.aspx

        private string GetCommaDelimitedList(IDataReader reader)
        {
            string list = string.Empty;
            StringBuilder sb = new StringBuilder();

            while (reader.Read())
                sb.AppendFormat(",{0}", reader[0]);

            if (sb.Length > 0)
                list = sb.ToString(1, sb.Length - 1);

            return list;
        }

Executing File Directory (The Correct Way)

Settembre 25th, 2007

Description: Often people will use Environment.CurrentDirectory to get what they think is the executing files directory. In reality, it is only sometimes the executing files directory. This shows the correct way to always get the executing files directory.

Link: http://www.codekeep.net/snippets/91510bc7-f9a9-41fd-9c9e-aa7c56dfa231.aspx

string correctPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

XML-Enabled Applications - Part 2

Settembre 24th, 2007

Oracle XML DB allows you to perform SQL operations on XML data as well as XML operations on relational data, thus bridging the gap between the SQL and XML worlds. You can choose between several storage options and achieve required levels of performance and scalability. By Yuli Vasiliev. 0924

Get Calling Method

Settembre 21st, 2007

Description: Retrieves the fully qualified name of the calling method.

Link: http://www.codekeep.net/snippets/3f718583-7ff8-49c1-bfcf-2ff271119436.aspx

System.Reflection.MethodBase methodBase =
	(new System.Diagnostics.StackFrame(2, false)).GetMethod();
Console.WriteLine(methodBase.ReflectedType.FullName + "." + methodBase.Name);

Next »