public void FileMover(int itemID, string imgRootPath, string sourceFileCol, string pathCollection, string isActive, string imageType, string description, string displayOrder, string imgPreFix, int itemLargeThumbNailSize, int itemMediumThumbNailSize, int itemSmallThumbNailSize)
        {
            string pathList = string.Empty;

            string[] sourceFileList = sourceFileCol.Split('%');
            string   destpath       = HostingEnvironment.MapPath("~/" + imgRootPath);

            if (!Directory.Exists(destpath))
            {
                Directory.CreateDirectory(destpath);
            }

            Random randVar = new Random();

            try
            {
                string[] sourceList = pathCollection.Split('%');
                //  DirectoryInfo destDir = new DirectoryInfo(destpath);

                #region FileDelete
                // Delete images from dstination folder of same itemID

                /*
                 *                 if (destDir.Exists)
                 *                 {
                 *                     FileInfo[] files = GetFilesList(int.Parse(itemID), destDir);
                 *
                 *                     string listFiles = string.Empty;
                 *                     int j = 0;
                 *                     if (files.Length != 0)
                 *                     {
                 *                         while (j < files.Length)
                 *                         {
                 *
                 *                             if (files[j].FullName.Contains(".db") || files[j].FullName.Contains(".DB"))
                 *                             {
                 *                                 System.IO.File.Delete(files[j].FullName);
                 *                             }
                 *                             j++;
                 *                         }
                 *                         foreach (FileInfo file in files)
                 *                         {
                 *                             foreach (string fileStr in sourceList)
                 *                             {
                 *                                 string sourceCol = HostingEnvironment.MapPath("~/" + fileStr);
                 *                                 string destCol = file.DirectoryName + "\\" + file;
                 *                                 if (destCol == sourceCol)
                 *                                 {
                 *                                     break;
                 *                                 }
                 *                                 else
                 *                                 {
                 *                                     listFiles += sourceCol + ",";
                 *                                 }
                 *
                 *                             }
                 *                         }
                 *                     }
                 *
                 *
                 *
                 *
                 *
                 *                     if (listFiles.Contains(","))
                 *                     {
                 *                         listFiles = listFiles.Remove(listFiles.LastIndexOf(","));
                 *
                 *
                 *                         string[] delFileCol = listFiles.Split(',');
                 *
                 *                         int count = delFileCol.Length;
                 *                         int i = 0;
                 *                         while (i < count)
                 *                         {
                 *                             if (File.Exists(delFileCol[i]))
                 *                             {
                 *                                 if (delFileCol[i].Contains(".db") || delFileCol[i].Contains(".DB"))
                 *                                 {
                 *                                     System.IO.File.Delete(delFileCol[i]);
                 *                                 }
                 *
                 *                                 else
                 *                                 {
                 *                                     string[] path_Splitter = delFileCol[i].ToString().Split('\\');
                 *                                     int words_length = path_Splitter.Length;
                 *                                     string[] words_Splitter = path_Splitter[words_length - 1].Split('_');
                 *                                     int length = words_Splitter.Length;
                 *                                     if (words_Splitter[length - 2].ToString() == itemID)
                 *                                     {
                 *                                         System.IO.File.Delete(delFileCol[i]);
                 *                                     }
                 *                                 }
                 *                             }
                 *                             i++;
                 *                         }
                 *                     }
                 *                 }*/
                #endregion

                //Move files from source to destination folder
                for (int i = 0; i < sourceFileList.Length; i++)
                {
                    string sourceCol = HostingEnvironment.MapPath("~/" + sourceList[i]);
                    string fileExt   = sourceFileList[i].Substring(sourceFileList[i].LastIndexOf("."));
                    string fileName  = imgPreFix + itemID + '_' + randVar.Next(111111, 999999).ToString() + fileExt;
                    pathList += imgRootPath + fileName + "%";
                    //TODO:: make only image Name instead Path
                    sourceFileList[i] = fileName;
                    if (destpath != null)
                    {
                        string destination = Path.Combine(destpath, sourceFileList[i]);
                        if (sourceCol != destination)
                        {
                            if (File.Exists(sourceCol) && !File.Exists(destination))
                            {
                                if (sourceCol != null)
                                {
                                    File.Copy(sourceCol, destination);
                                }
                                //image Thumbnails generates here
                                string vertualUrl0 = destpath + "Large\\";
                                string vertualUrl1 = destpath + "Medium\\";
                                string vertualUrl2 = destpath + "Small\\";

                                if (!Directory.Exists(vertualUrl0))
                                {
                                    Directory.CreateDirectory(vertualUrl0);
                                }
                                if (!Directory.Exists(vertualUrl1))
                                {
                                    Directory.CreateDirectory(vertualUrl1);
                                }
                                if (!Directory.Exists(vertualUrl2))
                                {
                                    Directory.CreateDirectory(vertualUrl2);
                                }

                                vertualUrl0 = vertualUrl0 + fileName;
                                vertualUrl1 = vertualUrl1 + fileName;
                                vertualUrl2 = vertualUrl2 + fileName;

                                string[] imageTypeFiles = new string[] { "jpg", "jpeg", "jpe", "gif", "bmp", "png", "ico" };
                                bool     isValidImage   = false;
                                foreach (string x in imageTypeFiles)
                                {
                                    if (fileExt.Contains(x))
                                    {
                                        isValidImage = true;
                                        break;
                                    }
                                }

                                if (isValidImage)
                                {
                                    PictureManager.CreateThmnail(destination, itemLargeThumbNailSize, vertualUrl0);
                                    PictureManager.CreateThmnail(destination, itemMediumThumbNailSize, vertualUrl1);
                                    PictureManager.CreateThmnail(destination, itemSmallThumbNailSize, vertualUrl2);
                                }
                                else
                                {
                                    System.IO.File.Copy(destination, vertualUrl0);
                                    System.IO.File.Copy(destination, vertualUrl1);
                                    System.IO.File.Copy(destination, vertualUrl2);
                                }
                            }
                        }
                    }
                }
                if (pathList.Contains("%"))
                {
                    pathList = pathList.Remove(pathList.LastIndexOf("%"));
                }

                //Save to database
                ImageUploaderSqlhandler imageSql = new ImageUploaderSqlhandler();
                imageSql.SaveImageSettings(itemID, pathList, isActive, imageType, description, displayOrder);

                //// delete files created earlier
                //DirectoryInfo temDir = new DirectoryInfo(sourcepath);
                //if (temDir.Exists)
                //{
                //    FileInfo[] files = temDir.GetFiles();
                //    foreach (FileInfo file in files)
                //    {
                //        if (file.CreationTime.ToShortDateString() != DateTime.Now.ToShortDateString())
                //        {
                //            System.IO.File.Delete(file.FullName);
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void FileMoverOld(int itemID, string imgRootPath, string sourceFileCol, string pathCollection, string isActive, string imageType, string itemImageIds, string description, string displayOrder, string imgPreFix,int  itemLargeThumbNailHeight,int itemLargeThumbNailWidth,int itemMediumThumbNailHeight,int itemMediumThumbNailWidth,
                                 int itemSmallThumbNailHeight,int itemSmallThumbNailWidth, string cultureName, int portalID)
        {
            string pathList = string.Empty;
            string[] sourceFileList = sourceFileCol.Split('%');
            string destpath = HostingEnvironment.MapPath("~/" + imgRootPath);
            if (!Directory.Exists(destpath))
            {
                Directory.CreateDirectory(destpath);
            }

            Random randVar = new Random();

            try
            {
                string[] sourceList = pathCollection.Split('%');
                //  DirectoryInfo destDir = new DirectoryInfo(destpath);

                #region FileDelete

                // Delete images from dstination folder of same itemID
                /*  
                                   if (destDir.Exists)
                                   {
                                       FileInfo[] files = GetFilesList(int.Parse(itemID), destDir);

                                       string listFiles = string.Empty;
                                       int j = 0;
                                       if (files.Length != 0)
                                       {
                                           while (j < files.Length)
                                           {

                                               if (files[j].FullName.Contains(".db") || files[j].FullName.Contains(".DB"))
                                               {
                                                   System.IO.File.Delete(files[j].FullName);
                                               }
                                               j++;
                                           }
                                           foreach (FileInfo file in files)
                                           {
                                               foreach (string fileStr in sourceList)
                                               {
                                                   string sourceCol = HostingEnvironment.MapPath("~/" + fileStr);
                                                   string destCol = file.DirectoryName + "\\" + file;
                                                   if (destCol == sourceCol)
                                                   {
                                                       break;
                                                   }
                                                   else
                                                   {
                                                       listFiles += sourceCol + ",";
                                                   }

                                               }
                                           }
                                       }





                                       if (listFiles.Contains(","))
                                       {
                                           listFiles = listFiles.Remove(listFiles.LastIndexOf(","));


                                           string[] delFileCol = listFiles.Split(',');

                                           int count = delFileCol.Length;
                                           int i = 0;
                                           while (i < count)
                                           {
                                               if (File.Exists(delFileCol[i]))
                                               {
                                                   if (delFileCol[i].Contains(".db") || delFileCol[i].Contains(".DB"))
                                                   {
                                                       System.IO.File.Delete(delFileCol[i]);
                                                   }

                                                   else
                                                   {
                                                       string[] path_Splitter = delFileCol[i].ToString().Split('\\');
                                                       int words_length = path_Splitter.Length;
                                                       string[] words_Splitter = path_Splitter[words_length - 1].Split('_');
                                                       int length = words_Splitter.Length;
                                                       if (words_Splitter[length - 2].ToString() == itemID)
                                                       {
                                                           System.IO.File.Delete(delFileCol[i]);
                                                       }
                                                   }
                                               }
                                               i++;
                                           }
                                       }
                                   }*/
                #endregion

                //Move files from source to destination folder
                for (int i = 0; i < sourceFileList.Length; i++)
                {
                    string sourceCol = "";
                    string fileExt = "";
                    string fileName = "";
                    if (!sourceFileList[i].StartsWith("item_") &&
                    File.Exists(HostingEnvironment.MapPath("~/" + sourceList[i])))
                    {
                        sourceCol = HostingEnvironment.MapPath("~/" + sourceList[i]);
                        fileExt = sourceFileList[i].Substring(sourceFileList[i].LastIndexOf("."));
                        fileName = imgPreFix + itemID + '_' + randVar.Next(111111, 999999).ToString() + fileExt;
                        pathList += fileName + "%";
                        //TODO:: make only image Name instead Path 
                        sourceFileList[i] = fileName;
                        if (destpath != null)
                        {
                            string destination = Path.Combine(destpath, sourceFileList[i]);
                            if (sourceCol != destination)
                            {
                                if (File.Exists(sourceCol) && !File.Exists(destination))
                                {
                                    if (sourceCol != null) File.Copy(sourceCol, destination);
                                    //image Thumbnails generates here
                                    string vertualUrl0 = destpath + "Large\\";
                                    string vertualUrl1 = destpath + "Medium\\";
                                    string vertualUrl2 = destpath + "Small\\";

                                    if (!Directory.Exists(vertualUrl0))
                                        Directory.CreateDirectory(vertualUrl0);
                                    if (!Directory.Exists(vertualUrl1))
                                        Directory.CreateDirectory(vertualUrl1);
                                    if (!Directory.Exists(vertualUrl2))
                                        Directory.CreateDirectory(vertualUrl2);

                                    vertualUrl0 = vertualUrl0 + fileName;
                                    vertualUrl1 = vertualUrl1 + fileName;
                                    vertualUrl2 = vertualUrl2 + fileName;

                                    string[] imageTypeFiles = new string[] { "jpg", "jpeg", "jpe", "gif", "bmp", "png", "ico" };
                                    bool isValidImage = false;
                                    foreach (string x in imageTypeFiles)
                                    {
                                        if (fileExt.Contains(x))
                                        {
                                            isValidImage = true;
                                            break;
                                        }
                                    }

                                    if (isValidImage)
                                    {
                                        //PictureManager.CreateThmnail(destination, itemLargeThumbNailHeight,itemLargeThumbNailWidth, vertualUrl0);
                                        //PictureManager.CreateThmnail(destination, itemMediumThumbNailHeight,itemMediumThumbNailWidth, vertualUrl1);
                                        //PictureManager.CreateThmnail(destination, itemSmallThumbNailHeight,itemSmallThumbNailWidth, vertualUrl2);
                                    }
                                    else
                                    {
                                        System.IO.File.Copy(destination, vertualUrl0);
                                        System.IO.File.Copy(destination, vertualUrl1);
                                        System.IO.File.Copy(destination, vertualUrl2);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        pathList += sourceFileList[i] + "%";
                    }
                }
                if (pathList.Contains("%"))
                {
                    pathList = pathList.Remove(pathList.LastIndexOf("%"));
                }

                //Save to database
                ImageUploaderSqlhandler imageSql = new ImageUploaderSqlhandler();
                imageSql.SaveImageSettings(itemID, pathList, isActive, imageType, itemImageIds, description, displayOrder, cultureName, portalID);

                //// delete files created earlier
                //DirectoryInfo temDir = new DirectoryInfo(sourcepath);
                //if (temDir.Exists)
                //{
                //    FileInfo[] files = temDir.GetFiles();
                //    foreach (FileInfo file in files)
                //    {
                //        if (file.CreationTime.ToShortDateString() != DateTime.Now.ToShortDateString())
                //        {
                //            System.IO.File.Delete(file.FullName);
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string SaveImageContents(Int32 itemID, string imageRootPath, string sourceFileCol, string dataCollection, int itemLargeThumbNailSize, int itemMediumThumbNailSize, int itemSmallThumbNailSize, string imgPreFix)
        {

            if (dataCollection.Contains("#"))
            {
                dataCollection = dataCollection.Remove(dataCollection.LastIndexOf("#"));
            }
            SQLHandler sageSql = new SQLHandler();
            string[] individualRow = dataCollection.Split('#');
            string[] words;

            StringBuilder sbPathList = new StringBuilder();
            StringBuilder sbIsActiveList = new StringBuilder();
            StringBuilder sbImageType = new StringBuilder();
            StringBuilder sbDescription = new StringBuilder();
            StringBuilder sbDisplayOrder = new StringBuilder();
            StringBuilder sbSourcePathList = new StringBuilder();

            foreach (string str in individualRow)
            {
                words = str.Split('%');
                sbPathList.Append(words[0] + "%");
                sbIsActiveList.Append(words[1] + "%");
                sbImageType.Append(words[2] + "%");
                sbDescription.Append(words[3] + "%");
                sbDisplayOrder.Append(words[4] + "%");
            }
            string pathList = string.Empty;
            string isActive = string.Empty;
            string imageType = string.Empty;
            string description = string.Empty;
            string displayOrder = string.Empty;

            pathList = sbPathList.ToString();
            isActive = sbIsActiveList.ToString();
            imageType = sbImageType.ToString();
            description = sbDescription.ToString();
            displayOrder = sbDisplayOrder.ToString();

            if (pathList.Contains("%"))
            {
                pathList = pathList.Remove(pathList.LastIndexOf("%"));
            }
            if (isActive.Contains("%"))
            {
                isActive = isActive.Remove(isActive.LastIndexOf("%"));
            }
            if (imageType.Contains("%"))
            {
                imageType = imageType.Remove(imageType.LastIndexOf("%"));
            }

            if (sourceFileCol.Contains("%"))
            {
                sourceFileCol = sourceFileCol.Remove(sourceFileCol.LastIndexOf("%"));
            }

            ImageUploaderSqlhandler imageManager = new ImageUploaderSqlhandler();

            try
            {
                FileHelperController fhc = new FileHelperController();
                //TODO:: delete all previous files infos lists
                fhc.FileMover(itemID, imageRootPath, sourceFileCol, pathList, isActive, imageType, description, displayOrder, imgPreFix, itemLargeThumbNailSize, itemMediumThumbNailSize, itemSmallThumbNailSize);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return "Success";

        }
        public void FileMover(int itemID, string imgRootPath, string sourceFileCol, string pathCollection, string isActive, string imageType, string itemImageIds, string description, string displayOrder, string imgPreFix, int itemLargeThumbNailHeight, int itemLargeThumbNailWidth, int itemMediumThumbNailHeight, int itemMediumThumbNailWidth,
                                int itemSmallThumbNailHeight, int itemSmallThumbNailWidth, string cultureName, int portalID)
        {
            string pathList = string.Empty;
            string[] sourceFileList = sourceFileCol.Split('%');
            string destpath = HostingEnvironment.MapPath("~/" + imgRootPath);
            if (!Directory.Exists(destpath))
            {
                Directory.CreateDirectory(destpath);
            }

            Random randVar = new Random();

            try
            {
                string[] sourceList = pathCollection.Split('%');
                //Move files from source to destination folder
                for (int i = 0; i < sourceFileList.Length; i++)
                {
                    string sourceCol = "";
                    string fileExt = "";
                    string fileName = "";
                    if (!sourceFileList[i].StartsWith("item_") &&
                    File.Exists(HostingEnvironment.MapPath("~/" + sourceList[i])))
                    {
                        sourceCol = HostingEnvironment.MapPath("~/" + sourceList[i]);
                        fileExt = sourceFileList[i].Substring(sourceFileList[i].LastIndexOf("."));
                        fileName = imgPreFix + itemID + '_' + randVar.Next(111111, 999999).ToString() + fileExt;
                        pathList += fileName + "%";
                        //TODO:: make only image Name instead Path 
                        sourceFileList[i] = fileName;
                        if (destpath != null)
                        {
                            string destination = Path.Combine(destpath, sourceFileList[i]);
                            if (sourceCol != destination)
                            {
                                if (File.Exists(sourceCol) && !File.Exists(destination))
                                {
                                    if (sourceCol != null) File.Copy(sourceCol, destination);
                                    //image Thumbnails generates here
                                    string vertualUrl0 = destpath + "Large\\";
                                    string vertualUrl1 = destpath + "Medium\\";
                                    string vertualUrl2 = destpath + "Small\\";

                                    if (!Directory.Exists(vertualUrl0))
                                        Directory.CreateDirectory(vertualUrl0);
                                    if (!Directory.Exists(vertualUrl1))
                                        Directory.CreateDirectory(vertualUrl1);
                                    if (!Directory.Exists(vertualUrl2))
                                        Directory.CreateDirectory(vertualUrl2);

                                    vertualUrl0 = vertualUrl0 + fileName;
                                    vertualUrl1 = vertualUrl1 + fileName;
                                    vertualUrl2 = vertualUrl2 + fileName;

                                    string[] imageTypeFiles = new string[] { "jpg", "jpeg", "jpe", "gif", "bmp", "png", "ico" };
                                    bool isValidImage = false;
                                    foreach (string x in imageTypeFiles)
                                    {
                                        if (fileExt.Contains(x))
                                        {
                                            isValidImage = true;
                                            break;
                                        }
                                    }

                                    if (!(isValidImage))
                                    {
                                        System.IO.File.Copy(destination, vertualUrl0);
                                        System.IO.File.Copy(destination, vertualUrl1);
                                        System.IO.File.Copy(destination, vertualUrl2);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        pathList += sourceFileList[i] + "%";
                    }
                }
                if (pathList.Contains("%"))
                {
                    pathList = pathList.Remove(pathList.LastIndexOf("%"));
                }

                //Save to database
                ImageUploaderSqlhandler imageSql = new ImageUploaderSqlhandler();
                imageSql.SaveImageSettings(itemID, pathList, isActive, imageType, itemImageIds, description, displayOrder, cultureName, portalID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }