Пример #1
0
        /// <summary>
        /// Returns all active issuers.
        /// </summary>
        /// <returns></returns>
        internal List <issuer> GetIssuerConfiguration()
        {
            var rtnList = new List <issuer>();

            try
            {
                using (var context = new indigo_databaseEntities(dbObject.EFSQLConnectionString))
                {
                    ObjectResult <issuer> results = context.usp_find_issuer_by_status((int)IssuerStatus.ACTIVE);

                    foreach (issuer result in results)
                    {
                        rtnList.Add(result);
                    }
                }
            }
            catch (Exception ex)
            {
                LogFileWriter.WriteFileLoaderComment("Unable to access the database, cannot run the file loader");
                LogFileWriter.WriteFileLoaderError(ToString(), ex);
            }
            return(rtnList);
        }
Пример #2
0
        /// <summary>
        /// THIS IS NOW REDUNDENT CODE - DONT USE
        /// </summary>
        /// <param name="config"></param>
        private void LoadCardFile(issuer config)
        {
            //build app log comment
            applogcomment = DateTime.Now.ToLongTimeString() + " " + config.issuer_code + " CARD FILES: ";

            var dirInfo = new DirectoryInfo("" /*config.cards_file_location*/);

            //check there are files to load
            FileInfo[] filesToLoad = GetFilesToLoad(config, dirInfo);

            if (filesToLoad != null)
            {
                //process each file in array
                foreach (FileInfo fileInfo in filesToLoad)
                {
                    file_history fileHistory = new file_history();
                    fileHistory.file_types              = new file_types();
                    fileHistory.file_statuses           = new file_statuses();
                    fileHistory.name_of_file            = fileInfo.Name;
                    fileHistory.file_directory          = fileInfo.Directory.ToString();
                    fileHistory.file_size               = (int)fileInfo.Length;
                    fileHistory.file_types.file_type_id = (int)FileType.CARD_IMPORT;
                    fileHistory.file_created_date       = fileInfo.CreationTime;

                    //setup variables
                    SetupVariables(fileInfo);

                    //check if the file has already been loaded
                    if (!CheckIfDuplicateFile(config, fileInfo.Name))
                    {
                        //TO DO: get this value from the database (hard coded for Ecobank)
                        var    cmsType            = CMS.TIETO;
                        string loadBatchReference = "";
                        //<PAN, ValidCard>
                        Dictionary <string, ValidCard> validCards = new Dictionary <string, ValidCard>();

                        //card issuing
                        switch (cmsType)
                        {
                        case CMS.TIETO:
                            //Ecobank
                            loadBatchReference = CreateCardBatchReference_Tieto(fileInfo.Name);
                            if (fileStatus.Equals(FileStatus.READ))
                            {
                                validCards = ProcessCardFile_Tieto(fullFileName, config, fileHistory);
                            }
                            break;
                        }

                        //write batch and cards to DB
                        if (fileStatus.Equals(FileStatus.PROCESSED) || fileStatus.Equals(FileStatus.PARTIAL_LOAD))
                        {
                            if (validCards.Count > 0)
                            {
                                if (true /*fileLoaderDAL.CreateLoadBatch(validCards, loadBatchReference, config.issuer_id, fileHistory)*/)
                                {
                                    Veneka.Indigo.CardManagement.LoadBatchMangementService loadBatchMgm = new Veneka.Indigo.CardManagement.LoadBatchMangementService();

                                    //SELF APPROVES LOAD BATCH
                                    Veneka.Indigo.CardManagement.objects.DatabaseResponse response = null;//loadBatchMgm.UpdateLoadBatchStatus(loadBatchReference, "SYSTEM",
                                    //     indigoCardManagement.LoadBatchStatus.APPROVED.ToString());


                                    if (response.responseSuccess)
                                    {
                                        //CREATES A DISTRIBUTION BATCH
                                        List <string> cardsList  = new List <string>();
                                        string        branchCode = String.Empty;
                                        foreach (var item in this.CardRecords)
                                        {
                                            cardsList.Add(item[0]);
                                            branchCode = item[1];
                                        }

                                        var batch = new Veneka.Indigo.CardManagement.objects.DistributionBatch
                                                    (
                                            0, String.Empty, string.Empty, config.issuer_id, null,
                                            DateTime.Now, Veneka.Indigo.CardManagement.DistributionBatchStatus.CREATED,
                                            cardsList, branchCode, string.Empty,
                                            new List <string>());

                                        Veneka.Indigo.CardManagement.DistBatchManagementService distBatchMgm = new Veneka.Indigo.CardManagement.DistBatchManagementService();


                                        if (cardsList.Count > 0)
                                        {
                                            response = null;//distBatchMgm.CreateDistributionBatch(batch, "SYSTEM", cardsList);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //write history
                    CreateFileHistory(fileInfo.Name, fileInfo.Directory.ToString(), fileInfo.Length,
                                      FileType.CARD_IMPORT,
                                      fileInfo.CreationTime.ToString(), fileStatus, strDateTime, config.issuer_id,
                                      processedrecords,
                                      duplicaterecords, fileLoadComments);
                    //archive

                    ArchiveFiles(fileStatus, config, fileInfo, strDateTime);
                }

                //build app log comment
                applogcomment += " Success=" + successfileload + ", Partial=" + partialfileload + " Failed=" +
                                 failedfileload +
                                 ", Duplicate=" + duplicatefile + ", Invalid format=" + invalidformatfile;
            }

            //write to application log
            LogFileWriter.WriteFileLoaderComment(applogcomment);
        }