public void getProductDetails(string email, string productID, string isDuplicate, string clientID) { try { int prod_ID = 0; if (productID != "") prod_ID = Convert.ToInt32(productID); MySQLBusinessLogic bl = new MySQLBusinessLogic(); DataTable dtStore = bl.GetStoreID(email); int storeID = Convert.ToInt32(dtStore.Rows[0].ItemArray[0]); DataTable dt = new DataTable(); dt = bl.GetProductDetails(storeID, prod_ID); DataTable dtImage = new DataTable(); DataTable dtImgPaths = new DataTable(); //if (prod_ID != 0) string json2 = ""; string ImageData = ""; if (isDuplicate == "false") { //dtImage = bl.GetProductImageDetails(storeID, prod_ID); dtImgPaths = bl.GetProductImagePaths(prod_ID,storeID); } string js3 = ""; if (dt.Rows.Count > 0) { string json = ConvertDataTabletoString(dt); // if (prod_ID != 0) { for (int k = 0; k < dtImgPaths.Rows.Count; k++) { js3 += ",\"" + dtImgPaths.Rows[k].ItemArray[1].ToString().Split('\\')[dtImgPaths.Rows[k].ItemArray[1].ToString().Split('\\').Length - 2] + "/" + dtImgPaths.Rows[k].ItemArray[1].ToString().Split('\\').Last() + "\""; //js3 += ",\"" + dtImgPaths.Rows[k].ItemArray[1].ToString().Replace('\\', '/') + "\""; } } else { for (int k = 0; k < dtImgPaths.Rows.Count; k++) { json2 += ",\"" + dtImgPaths.Rows[k].ItemArray[1].ToString().Split('\\')[dtImgPaths.Rows[k].ItemArray[1].ToString().Split('\\').Length - 2] + "/" + dtImgPaths.Rows[k].ItemArray[1].ToString().Split('\\').Last() + "\""; //json2 += ",\"" + dtImgPaths.Rows[k].ItemArray[1].ToString().Replace('\\','/')+ "\""; } } // if (dtImage.Rows.Count > 0) { if (prod_ID != 0) { //for (int i = 0; i < dtImage.Columns.Count; i++) //{ // if (dtImage.Rows[0].ItemArray[i].GetType().Name != "DBNull") // { // byte[] bytes = (Byte[])dtImage.Rows[0].ItemArray[i]; // if (bytes.Length < 16777216) // { // string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); // string ImageUrl = "data:image/png;base64," + base64String; // json2 += ", \"" + ImageUrl + "\""; // } // else // json2 += ",\"NoImage\""; // } // else // { // json2 += ",\"NoImage\""; // } //} } else { //for (int i = 0; i < dtImage.Rows.Count; i++) //{ // if (dtImage.Rows[i].ItemArray[0].GetType().Name != "DBNull") // { // byte[] bytes = (Byte[])dtImage.Rows[i].ItemArray[0]; // if (bytes.Length < 16777216) // { // string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); // string ImageUrl = "data:image/png;base64," + base64String; // json2 += ", \"" + ImageUrl + "\""; // } // else // json2 += ",\"NoImage\""; // } // else // { // json2 += ",\"NoImage\""; // } //} } } if (isDuplicate == "false"&&json2!="") { ImageData = "{\"ImageUrl\":[" + json2.Remove(0, 1) + "]}"; } else { ImageData = ""; } string ImgDataPath = ""; if(js3!=null&&js3!="") ImgDataPath = "{\"ImageUrl\":[" + js3.Remove(0, 1) + "]}"; Clients.Client(clientID).productDetails(json, ImageData, ImgDataPath); } else { Clients.Client(clientID).productDetails(""); } } catch (Exception ex) { Clients.Client(clientID).productDetails(""); } }