Пример #1
0
        public List <SelectListItem> SyncRegistration()
        {
            List <SelectListItem>          lstMonitoringRegistrations = new List <SelectListItem>();
            ThirdPartyAPICredentialsFacade thirdAPIFac = new ThirdPartyAPICredentialsFacade(this.CurrentClient.ApplicationDBConnectionString);

            //Get DirectPlus Credentials
            List <ThirdPartyAPICredentialsEntity> lstAuth = thirdAPIFac.GetThirdPartyAPICredentials(ThirdPartyProvider.DNB.ToString());

            if (lstAuth != null && lstAuth.Any())
            {
                List <ThirdPartyAPICredentialsEntity> lstDirectPlusAuth = lstAuth.Where(x => x.APIType.ToLower() == ApiLayerType.Directplus.ToString().ToLower()).ToList();
                if (lstDirectPlusAuth != null && lstDirectPlusAuth.Any())
                {
                    foreach (var authItem in lstDirectPlusAuth)
                    {
                        ListMonitoringRegistrationResponse objtMonitoringRegistrationResponse = GetListMonitoringRegistrationResponse(authItem.AuthToken);
                        if (objtMonitoringRegistrationResponse != null && objtMonitoringRegistrationResponse.messages != null && objtMonitoringRegistrationResponse.messages.references != null)
                        {
                            SettingFacade fac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString);
                            string        NotDeleteRegistration = string.Join(",", objtMonitoringRegistrationResponse.messages.references.ToArray());
                            //sync DPMRegistration Name
                            fac.DeleteAllDPMRegistration(NotDeleteRegistration, authItem.CredentialId);
                            foreach (var item in objtMonitoringRegistrationResponse.messages.references)
                            {
                                MonitoringRegistrationDetailResponse monitoringRegistrationDetailResponse = new MonitoringRegistrationDetailResponse();
                                monitoringRegistrationDetailResponse = GetMonitoringRegistrationDetailResponse(item.ToString(), authItem.AuthToken);
                                //insert Registration name in database
                                fac.DPMInsertRegistration(monitoringRegistrationDetailResponse.messages.registration.reference, monitoringRegistrationDetailResponse.messages.registration.Tags, monitoringRegistrationDetailResponse.messages.notificationsSuppressed, monitoringRegistrationDetailResponse.messages.registration.productId, monitoringRegistrationDetailResponse.messages.registration.versionId, monitoringRegistrationDetailResponse.messages.registration.email, monitoringRegistrationDetailResponse.messages.registration.fileTransferProfile, monitoringRegistrationDetailResponse.messages.registration.description, monitoringRegistrationDetailResponse.messages.registration.deliveryTrigger, monitoringRegistrationDetailResponse.messages.registration.deliveryFrequency, monitoringRegistrationDetailResponse.messages.dunsCount, monitoringRegistrationDetailResponse.messages.registration.seedData, authItem.CredentialId, monitoringRegistrationDetailResponse.messages.registration.blockIds);
                                //insert Registration name in List
                                lstMonitoringRegistrations.Add(new SelectListItem {
                                    Value = item.ToString(), Text = item.ToString()
                                });
                            }
                        }
                    }
                }
            }
            return(lstMonitoringRegistrations);
        }