Saturday 31 May 2014

Dragdrop link in jqurey

http://jqueryui.com/sortable/#display-grid

Read Excel file and convert into Dataset

   OleDbConnection connection = new OleDbConnection();
        string path = string.Concat(Server.MapPath("../Uploaded Folder/chart.xls"));

      // Excle Read Connection String for open office
        string excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + "; Extended Properties=Excel 8.0;";
     
        connection.ConnectionString = excelConnectionString;
        OleDbCommand command = new OleDbCommand("select * from [Sheet1$]", connection);
        OleDbCommand command2 = new OleDbCommand("select * from [Sheet2$]", connection);
        connection.Open();
        // Create DbDataReader to Data Worksheet
        DbDataReader dr = command.ExecuteReader();
        DbDataReader dr2 = command2.ExecuteReader();
     

        dt.Load(dr);
        dt1.Load(dr2);
        ds = new DataSet();
        ds.Tables.Add(dt);
        ds.Tables.Add(dt1);

convert object in to dataset


        DataSet ds_obj = (DataSet)obj_ds;

Covert array in to xml


        int[] values = { 1, 2, 17, 8 };
        XDocument doc = new XDocument();
        doc.Add(new XElement("root", values.Select(x => new XElement("item", x))));

convert dataset into JSON

public static class myclassGeneral
{
    static object RowsToDictionary(this DataTable table)
    {

        var columns = table.Columns.Cast<DataColumn>().ToArray();

        return table.Rows.Cast<DataRow>().Select(r => columns.ToDictionary(c => c.ColumnName, c => r[c]));

    }

    static Dictionary<string, object> ToDictionary(this DataTable table)
    {

        return new Dictionary<string, object>

   {

       { table.TableName, table.RowsToDictionary() }

   };

    }

    static Dictionary<string, object> ToDictionary(this DataSet data)
    {

        return data.Tables.Cast<DataTable>().ToDictionary(t => t.TableName, t => t.RowsToDictionary());

    }

    public static string GetJSONString(DataTable table)
    {

        JavaScriptSerializer serializer = new JavaScriptSerializer();

        return serializer.Serialize(table.ToDictionary());

    }

    public static string GetJSONString(DataSet data)
    {

        JavaScriptSerializer serializer = new JavaScriptSerializer();

        return serializer.Serialize(data.ToDictionary());

    }
}

Convert JSON data into Dataset

 public DataSet DerializeDataTable(string a)
    {
        DataTable datatable = new DataTable();
        string json = a;
        DataSet myDataSet = JsonConvert.DeserializeObject<DataSet>(json);
        return myDataSet;
    }

Convert Object into Xml Format

 public XmlNode CreateXML(Object YourClassObject)
    {
        XmlDocument xmlDoc = new XmlDocument();   //Represents an XML document,
        // Initializes a new instance of the XmlDocument class.         
        XmlSerializer xmlSerializer = new XmlSerializer(YourClassObject.GetType());
        // Creates a stream whose backing store is memory.
        using (MemoryStream xmlStream = new MemoryStream())
        {
            xmlSerializer.Serialize(xmlStream, YourClassObject);
            xmlStream.Position = 0;
            //Loads the XML document from the specified string.
            xmlDoc.Load(xmlStream);
            return xmlDoc;
        }
    }

Friday 23 May 2014


photo shop tutorial/course

https://www.udemy.com/photoshoptraining

रूस-यूक्रेन संकट लाइव: भारतीयों को 'उपलब्ध किसी भी साधन' के माध्यम से कीव को तत्काल छोड़ने के लिए कहा

  रूस यूक्रेन संकट लाइव: कीव में भारतीय दूतावास ने मंगलवार को जारी एक एडवाइजरी में भारतीयों को  'किसी भी उपलब्ध साधन' के माध्यम से क...