/// <summary
        /// GetData , then encrypt , then Compress file and copy to file system
        /// </summary>
        /// <param name="datasetIds"></param>
        /// <param name="filePath"></param>
        /// <param name="folderPath"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public DataResponseModel generateJSON(List<int> datasetIds , string filePath , string folderPath , string fileName)
        {
            DataResponseModel dataResponseModel = new DataResponseModel();

            DataSetRepo dataSetRepo = new DataSetRepo();
            JsonDatasetModel Jdsm = dataSetRepo.GetData(datasetIds, filePath);

            if (Jdsm == null)
            {
                dataResponseModel.IsValid = true;
                dataResponseModel.Error = "Dataset Not Exist";
                return dataResponseModel;
            }

            #region Encrypt
            Encryption ec = new Encryption();
            JsonDatasetModel encryptedData = ec.Secure(Jdsm);
            #endregion

            #region CompressFileAndCopyToFileSystem
            CompressFile cf = new CompressFile();
            cf.GetCompressed(Jdsm, filePath, folderPath, fileName);
            #endregion

            return dataResponseModel;
        }
        public DataResponseModel UpdateFromServer()
        {
            var BackUpSourceDir = System.Web.Hosting.HostingEnvironment.MapPath(System.Configuration.ConfigurationManager.AppSettings["DataBackupSourcePath"]);
            var BackUpTargetDir = System.Web.Hosting.HostingEnvironment.MapPath(System.Configuration.ConfigurationManager.AppSettings["DataBackupTargetPath"]);
            BackUpTargetDir = string.Format("{0}{1}_{2}_{3}_{4}_{5}_{6}",BackUpTargetDir, DateTime.Now.Day , DateTime.Now.Month, DateTime.Now.Year ,DateTime.Now.Hour,DateTime.Now.Minute,DateTime.Now.Second);

            Backup createBackup = new Backup();
            createBackup.CreateBackupOfFiles(BackUpSourceDir ,BackUpTargetDir);

            bool IsDataSetPublished = true;
            DataResponseModel responseModel = new DataResponseModel();
            int[] datasetId = new int[5];
            datasetId[0] = 4;
            datasetId[1] = 7;
            datasetId[2] = 10004;
            datasetId[3] = 10007;

            List<int> datasetIds;
            for (int i = 0; i < 5; i++)
            {
                if (i == 4)
                {
                    datasetIds = new List<int>();
                    datasetIds.Add(datasetId[0]);
                    datasetIds.Add(datasetId[1]);
                    IsDataSetPublished = false;
                }

                else
                {
                    datasetIds = new List<int>();
                    datasetIds.Add(datasetId[i]);
                    IsDataSetPublished = true;

                }

                string fileName = "";
                var folderPath = "";
                var filePath = "";

                GenerateJSON createFile = new GenerateJSON();
                createFile.createFileName(datasetIds, ref filePath, ref folderPath, ref fileName);

                createFile.generateJSON(datasetIds, filePath, folderPath, fileName);


                if (IsDataSetPublished)   //Update Date Last Published On Data Set Table
                {
                    DataSetRepo repo = new DataSetRepo();
                    repo.DateLastPublished(datasetId[i]);
                }
            }

            responseModel.IsValid = true;
            responseModel.Error = null;
            return responseModel;
        }
示例#3
0
        /// <summary>
        /// Returns LIst of All Dataset with datasubset
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        #region GetAllDataSet
        public GetAllDataSetResponseModel GetAllDataSet(GetAllDataSetRequestModel requestModel)
        {
            GetAllDataSetResponseModel responseModel = new GetAllDataSetResponseModel();

            DataSetRepo dataSetRepo = new DataSetRepo();
            List<PharmaGuide.Repository.Repo.DataSetIdName> dataSet = dataSetRepo.GetAllDataSet(requestModel.AppId);

            if (dataSet == null)
            {
                responseModel.IsValid = false;
                return responseModel;
            }
            responseModel.CollectionOfDataSet = dataSet;


            responseModel.IsValid = true;
            return responseModel;
        }