using System.Configuration; using System.Web.Security; using System.ComponentModel; using System.Diagnostics; using System.Configuration.Install; using Microsoft.Win32; namespace Install.NameSpace { [RunInstaller(true)] public class InstallHelper : Installer { #region Public Static Methods public static void SaveLocalRoot(String value) { try { RegistryKey key = Registry .LocalMachine.OpenSubKey(ConfigurationManager .AppSettings["LocalRootRegKey"] .ToString(), true); if (key == null) Registry.LocalMachine.CreateSubKey(ConfigurationManager .AppSettings["LocalRootRegKey"].ToString()); key.SetValue("DefaultLocalRoot", value); } catch (Exception e) { throw e; } } #endregion } }
Thursday, November 29, 2007
Reading and writing to Windows.Registry.
Monday, November 26, 2007
XML Serialization and Deserialization in .NET
/// <summary> /// Serialize /// </summary> /// <param name="clientList">List of objects</param> /// <returns>success/fail (bool)</returns> private static bool SaveClientAttributes(List clientList) { try { XmlSerializer serializer = new XmlSerializer(typeof(List)); StreamWriter writer = new StreamWriter((Server.MapPath(string.Empty)) + "\\ClientData.xml"); List ClientList = new List(); serializer.Serialize(writer, clientList); return true; } catch (Exception ex) { return false; } } /// <summary> /// Deserialize /// </summary> /// <returns>List of objects</returns> private static List LoadClientAttributes() { List clientList = new List(); try { XmlSerializer serializer = new XmlSerializer(typeof(List)); FileStream fileStream = new FileStream((Server.MapPath(string.Empty)) + "\\ClientData.xml", FileAccess.Read); clientList = (List)serializer.Deserialize(fileStream); } catch (Exception ex) { //Do nothing } return clientList; }
Wednesday, November 14, 2007
List.IndexOf(Object o) .NET 3.0
this.ddlCourier.SelectedIndex = affiliatecouriers.IndexOf(affiliatecouriers .Find(delegate(Courier courier) { return courier.ID == int.Parse(iOrder.Supplementary.DeliveryCode); }));
References http://msdn2.microsoft.com/en-us/library/x0b5b5bc.aspx
Tuesday, November 13, 2007
Overriding Index of a Generic List
using System; using System.Collections; using System.Collections.Generic; using System.Text; namespace Application.DomainModel.Collections { public class Couriers<Courier> : List<Courier> { public Courier this[string courierCode] { get { return this.Find(delegate(Courier courier) { return (string.Compare(courier.CourierCode, courierCode) == 0); }); } } } public class Courier { public string CourierCode { get; set; } } }
Friday, November 09, 2007
ORA-24338: statement handle not executed
This happens when you try to read a cursor after fetching data from it. Try to read the cursor before you fetch data from it
PROCEDURE GetAffiliateCouriers(paffiliate_id number, io_cursor IN OUT appCursor)
IS
vcursor appCursor; tcursor appCursor; retCursor appCursor;
affiliate_id INTEGER; t_allow_courier_selection INTEGER;
v_row AFFILIATE%ROWTYPE; t_row AFFILIATE_COURIER%ROWTYPE;
BEGIN
vcursor := NULL;
tcursor := NULL;
affiliate_id := paffiliate_id;
LOOP
OPEN vcursor FOR SELECT * FROM affiliate WHERE id = affiliate_id AND allowcourierselection = 1;
FETCH vcursor INTO v_row;
IF (vcursor%FOUND) THEN
OPEN tcursor FOR SELECT * FROM affiliate_courier WHERE affiliate_courier.fk_affiliate_id = affiliate_id;
FETCH tcursor INTO t_row;
IF (tcursor%FOUND) THEN
OPEN retCursor FOR SELECT * FROM affiliate_courier WHERE affiliate_courier.fk_affiliate_id = affiliate_id;
io_cursor := retCursor;
RETURN;
END IF;
END IF;
SELECT fk_parent_id INTO affiliate_id FROM affiliate WHERE affiliate.id = affiliate_id;
EXIT WHEN affiliate_id IS NULL;
END LOOP;
io_cursor := retCursor;
END GetAffiliateCouriers;
PROCEDURE GetAffiliateCouriers(paffiliate_id number, io_cursor IN OUT appCursor)
IS
vcursor appCursor; tcursor appCursor; retCursor appCursor;
affiliate_id INTEGER; t_allow_courier_selection INTEGER;
v_row AFFILIATE%ROWTYPE; t_row AFFILIATE_COURIER%ROWTYPE;
BEGIN
vcursor := NULL;
tcursor := NULL;
affiliate_id := paffiliate_id;
LOOP
OPEN vcursor FOR SELECT * FROM affiliate WHERE id = affiliate_id AND allowcourierselection = 1;
FETCH vcursor INTO v_row;
IF (vcursor%FOUND) THEN
OPEN tcursor FOR SELECT * FROM affiliate_courier WHERE affiliate_courier.fk_affiliate_id = affiliate_id;
FETCH tcursor INTO t_row;
IF (tcursor%FOUND) THEN
OPEN retCursor FOR SELECT * FROM affiliate_courier WHERE affiliate_courier.fk_affiliate_id = affiliate_id;
io_cursor := retCursor;
RETURN;
END IF;
END IF;
SELECT fk_parent_id INTO affiliate_id FROM affiliate WHERE affiliate.id = affiliate_id;
EXIT WHEN affiliate_id IS NULL;
END LOOP;
io_cursor := retCursor;
END GetAffiliateCouriers;
Subscribe to:
Posts (Atom)
Azure Storage Account Types
Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...
-
Why we need asynchronous tasks? Execute a time consuming operations in parallel to the CLR thread which execute the request If you have ...
-
Demo: I was thinking a way to show images before actually uploading them to server. I would say to preview images using javascript. Obv...