/// <summary>
        /// Create Hidden Seed in Interqaction Master Table in Seed
        /// </summary>
        /// <param name="Jdsm"></param>
        /// <param name="seed"></param>
        /// <returns></returns>
        public Repository.Database.ViewsModel.InteractionMasterSet CreateHiddenSeed(JsonDatasetModel Jdsm ,string seed)
        {
            try
            {
                //string sixteenDigit = "";


                Random randomNumber = new Random();
                int[] randomXndex = new int[4];
                for (int i = 0; i < randomXndex.Length; i++)
                {
                    randomXndex[i] = randomNumber.Next(0, Jdsm.InteractionMasters.Count - 2);
                }

                string reverse = "";
                for (int i = seed.Length - 1; i >= 0; i--)
                {
                    reverse += seed[i];
                }
                //sixteenDigit = seed;
                var a = Encoding.UTF8.GetBytes(seed);
                seed = Convert.ToBase64String(a);
                a = Encoding.UTF8.GetBytes(reverse);
                seed += Convert.ToBase64String(a);

                Repository.Database.ViewsModel.InteractionMasterSet cryptoseed = new Repository.Database.ViewsModel.InteractionMasterSet
                {
                    a = 100000,
                    b = seed,
                    c = Jdsm.InteractionMasters[randomXndex[0]].c,
                    d = Jdsm.InteractionMasters[randomXndex[1]].d,
                    e = Jdsm.InteractionMasters[randomXndex[2]].e,
                    f = Jdsm.InteractionMasters[randomXndex[3]].f
                };
                return cryptoseed;

            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Encrypt secret data and create hidden seed
        /// </summary>
        /// <param name="Jdsm"></param>
        /// <returns></returns>
        public JsonDatasetModel Secure(JsonDatasetModel Jdsm)
        {
            //string seed = "1qwsdefcfvffgffg";
            string seed = Guid.NewGuid().ToString();

            string sixteenDigit = seed.Replace("-", "");

            seed = "";
            for (int i = 0; i < sixteenDigit.Length; i = i + 2)
            {
                seed += sixteenDigit[i];
            }


            Repository.Database.ViewsModel.InteractionMasterSet convertedSeed = CreateHiddenSeed(Jdsm, seed);

            CryptographyManager crypto = new CryptographyManager(seed);

            foreach (var categoryList in Jdsm.Categories)
            {
                categoryList.b =  crypto.Encrypt(categoryList.b);
            }

            foreach (var interactionMaster in Jdsm.InteractionMasters)
            {
                interactionMaster.b = crypto.Encrypt(interactionMaster.b);
                interactionMaster.d = crypto.Encrypt(interactionMaster.d);
                interactionMaster.e = crypto.Encrypt(interactionMaster.e);
                interactionMaster.c = crypto.Encrypt(interactionMaster.c);
                interactionMaster.f = crypto.Encrypt(interactionMaster.f);
            }

            foreach (var prescription in Jdsm.Prescriptions)
            {
                prescription.d = crypto.Encrypt(prescription.d);
            }

            Jdsm.InteractionMasters.Add(convertedSeed);

            return Jdsm;
        }
        /// <summary>
        /// Serialize JSOn and Create JSOn file Compressed data in GZ form
        /// </summary>
        /// <param name="jdsm"></param>
        /// <param name="filePath"></param>
        /// <param name="folderPath"></param>
        /// <param name="fileName"></param>
        public void GetCompressed(JsonDatasetModel jdsm , string filePath , string folderPath , string fileName)
        {
            //foreach (var item in jdsm.Items)
            //{
            //    if (item.a == 44611)
            //    {
            //        string strength = item.h;
            //    }
            //}


            string jsonToSave = JsonConvert.SerializeObject(jdsm);
     


            File.Create(filePath).Close();
            using (StreamWriter jsonFileWriter = new StreamWriter(filePath))
            {
                jsonFileWriter.Write(jsonToSave);
            }

            byte[] jsonBytes = Encoding.Unicode.GetBytes(jsonToSave);

            using (MemoryStream ms = new MemoryStream())
            {
                using (GZipStream gZipStream = new GZipStream(ms, CompressionMode.Compress))
                {
                    
                    gZipStream.Write(jsonBytes, 0, jsonBytes.Length);
                }

                string compressedFileName = string.Format("{0}.gz", fileName);
                string compressedFilePath = System.Web.Hosting.HostingEnvironment.MapPath(string.Format("{0}{1}", folderPath, compressedFileName));
                File.WriteAllBytes(compressedFilePath, ms.ToArray());
            }
            return;
        }