Exemplo n.º 1
0
        public void getAllStoreDetails(string clientID, string categoryIDs,string storeType)
        {
            try
            {
                MySQLBusinessLogic bl = new MySQLBusinessLogic();
                DataTable dt = new DataTable();
                if (categoryIDs == "" && storeType=="")
                    dt = bl.GetAllStores();
                else
                {
                    //get list of Store ID's from category id
                    List<string> lst = new List<string>();
                    string storeIDS = "";
                    if (categoryIDs != "")
                    {
                        lst = bl.GetStoresbyCategoryID(categoryIDs);
                        storeIDS = String.Join(",", lst);
                    }
                    //return all stores
                    //if (lst.Count > 0)
                        dt = bl.GetStoresByStoreID(storeIDS, storeType);
                    //else
                    //    Clients.Client(clientID).gotStores("0");

                }
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DataTable temp = new DataTable();
                        for (int c = 0; c < dt.Columns.Count; c++)
                        {
                            DataColumn dc = new DataColumn();
                            dc.ColumnName = dt.Columns[c].ToString();
                            if (dc.ColumnName == "StoreImage")
                            {
                                dc.DataType = typeof(string);
                            }
                            else
                                dc.DataType = dt.Columns[c].DataType;
                            temp.Columns.Add(dc);
                        }
                        //temp.Rows[i].ItemArray = dt.Rows[i].ItemArray;
                        temp.ImportRow(dt.Rows[i]);
                        string ImageUrl = "NoImage";
                        if (dt.Rows[i]["StoreImage"].GetType().Name != "DBNull")
                        {
                            byte[] bytes = (Byte[])dt.Rows[i]["StoreImage"];
                            string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
                            ImageUrl = "data:image/png;base64," + base64String;
                        }
                        temp.Rows[0]["StoreImage"] = ImageUrl;
                        string json = ConvertDataTabletoString(temp);
                        Clients.Client(clientID).gotStores("1", json);
                    }
                }
                else
                {
                    Clients.Client(clientID).gotStores("0");
                }

            }
            catch (Exception ex)
            {
            }
        }