コード例 #1
0
        public ActionResult RefreshYodlee(string displayName = null)
        {
            var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id);
            var yodleeMain    = new YodleeMain();

            var oEsi = new YodleeServiceInfo();

            var yodlees = this.customer.CustomerMarketPlaces
                          .Where(mp => mp.Marketplace.InternalId == oEsi.InternalId)
                          .ToList();

            if (yodlees.Count == 0)
            {
                return(View(new { error = "Error loading bank accounts" }));
            }

            var lu = yodleeMain.LoginUser(yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password));

            if (lu == null)
            {
                return(View(new { error = "Error logging to yodlee account" }));
            }

            MP_CustomerMarketPlace umi = displayName == null ? yodlees[0] : yodlees.FirstOrDefault(y => y.DisplayName == displayName);             //TODO Currently refreshes the first one

            if (umi == null)
            {
                return(View(new { error = "Account not found" }));
            }
            var    callback = Url.Action("RecheckYodleeCallback", "YodleeMarketPlaces", new { Area = "Customer" }, "https") + "/" + umi.Id;
            string finalUrl = yodleeMain.GetEditAccountUrl(Serialized.Deserialize <YodleeSecurityInfo>(umi.SecurityData).ItemId, callback, yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password));

            return(Redirect(finalUrl));
        }
コード例 #2
0
 public void Deserialize2()
 {
     using (var fs = new FileStream(@"d:\attach1.xml", FileMode.Open)) {
         var data = Serialized.Deserialize <FileAttachmentDataInfo>(fs);
         Assert.IsNotNull(data);
     }
 }
コード例 #3
0
        public static IEnumerable <T> Extract <T>(FileAttachment fileAttach)
        {
            var list = new List <T>();

            if (fileAttach == null || fileAttach.Data == null)
            {
                return(list);
            }

            var data = fileAttach.Data;

            using (var mem = new MemoryStream(data))
            {
                var zip = ZipFile.Read(mem);

                using (var rezMem = new MemoryStream())
                {
                    foreach (ZipEntry entry in zip)
                    {
                        entry.Extract(rezMem);
                        rezMem.Flush();
                        rezMem.Seek(0, SeekOrigin.Begin);

                        var item = Serialized.Deserialize <T>(rezMem);

                        list.Add(item);
                    }
                }
            }
            return(list);
        }
コード例 #4
0
ファイル: CGMPUniqChecker.cs プロジェクト: vijayamazon/ezbob
        }         // CheckHmrc

        private bool IsSameMarketPlace(int nMpID, byte[] oSecData, MP_MarketplaceType oMp, string sShopID)
        {
            VendorInfo vi = Integration.ChannelGrabberConfig.Configuration.Instance.GetVendorInfo(oMp.Name);

            if (vi == null)
            {
                return(false);
            }

            try {
                var am = Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(oSecData));
                return(am.Fill().UniqueID() == sShopID);
            } catch (Exception e) {
                string sXml = System.Text.Encoding.Default.GetString(oSecData);

                new SafeILog(this).Warn(
                    e,
                    "Failed to de-serialize security data. Marketplace ID = {0}, Security data: {1}",
                    nMpID,
                    sXml
                    );

                return(false);
            }     // try
        }         // IsSameMarketPlace
コード例 #5
0
        public JsonResult LandRegistryEnquiry(int customerId, string titleNumber, string buildingNumber, string buildingName, string streetName, string cityName, string postCode)
        {
            if (!string.IsNullOrEmpty(titleNumber))
            {
                this.m_oServiceClient.Instance.LandRegistryRes(this._context.UserId, customerId, titleNumber);
                return(Json(new {
                    isTitle = true
                }));
            }
            else
            {
                var landregistryXml = this.m_oServiceClient
                                      .Instance
                                      .LandRegistryEnquiry(this._context.UserId,
                                                           customerId,
                                                           buildingNumber,
                                                           buildingName,
                                                           streetName,
                                                           cityName,
                                                           postCode);
                var landregistry = Serialized.Deserialize <LandRegistryDataModel>(landregistryXml);

                return(Json(new {
                    titles = landregistry.Enquery.Titles,
                    rejection = landregistry.Enquery.Rejection,
                    ack = landregistry.Enquery.Acknowledgement,
                    isCache = landregistry.DataSource == LandRegistryDataSource.Cache
                }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #6
0
        public void can_deserialize_error_retrying_info()
        {
            var xml  = "<ErrorRetryingInfo UseLastTimeOut=\"false\" MinorTimeoutInSeconds=\"60\" EnableRetrying=\"true\"><IterationSettings Index=\"1\" CountRequestsExpectError=\"10\" TimeOutAfterRetryingExpiredInMinutes=\"30\" /><IterationSettings Index=\"2\" CountRequestsExpectError=\"5\" TimeOutAfterRetryingExpiredInMinutes=\"0\" /></ErrorRetryingInfo>";
            var data = Serialized.Deserialize <ErrorRetryingInfo>(xml);

            Assert.That(data.Info, Is.Not.Null);
        }
コード例 #7
0
 public void Deserialize()
 {
     using (var fs = new FileStream(@"D:\5055375325_report.xml", FileMode.Open)) {
         var data = Serialized.Deserialize <FileAttachmentDataInfo>(fs);
         Assert.IsNotNull(data);
     }
 }
コード例 #8
0
        public ViewResult YodleeCallback()
        {
            Log.InfoFormat("Got to yodlee's callback with params:{0}", HttpContext.Request.Params);
            foreach (string key in HttpContext.Request.Params.Keys)
            {
                if (key == "oauth_error_code")
                {
                    Log.WarnFormat("Yodlee returned an error. oauth_error_code:{0} oauth_error_problem:{1}", HttpContext.Request.Params["oauth_error_code"], HttpContext.Request.Params["oauth_error_problem"]);
                    if (HttpContext.Request.Params["oauth_error_code"] == "407")
                    {
                        return(View(new { error = "Failure linking account" }));
                    }
                }
            }

            var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id);

            string decryptedPassword = Encrypted.Decrypt(yodleeAccount.Password);
            string displayname;
            long   csId;

            var yodleeMain = new YodleeMain();
            var oEsi       = new YodleeServiceInfo();

            var items = this.customer.CustomerMarketPlaces
                        .Where(mp => mp.Marketplace.InternalId == oEsi.InternalId)
                        .Select(mp => Serialized.Deserialize <YodleeSecurityInfo>(mp.SecurityData).ItemId).ToList();

            long itemId = yodleeMain.GetItemId(yodleeAccount.Username, decryptedPassword, items, out displayname, out csId);

            if (itemId == -1)
            {
                return(View(new { error = "Failure linking account" }));
            }

            int marketPlaceId = this.mpTypes
                                .GetAll()
                                .First(a => a.InternalId == oEsi.InternalId)
                                .Id;

            var securityData = new YodleeSecurityInfo
            {
                ItemId        = itemId,
                Name          = yodleeAccount.Username,
                Password      = yodleeAccount.Password,
                MarketplaceId = marketPlaceId,
                CsId          = csId
            };

            var yodleeDatabaseMarketPlace = new YodleeDatabaseMarketPlace();

            var marketPlace = this.dbHelper.SaveOrUpdateCustomerMarketplace(displayname, yodleeDatabaseMarketPlace, securityData, this.customer);

            Log.InfoFormat("Added or updated yodlee marketplace: {0}", marketPlace.Id);

            this.serviceClient.Instance.UpdateMarketplace(this.context.Customer.Id, marketPlace.Id, true, this.context.UserId);

            return(View(YodleeAccountModel.ToModel(marketPlace, this.yodleeBanksRepository)));
        }
コード例 #9
0
        public void can_deserialize_amazon()
        {
            //0x3C3F786D6C2076657273696F6E3D22312E30223F3E0D0A3C416D617A6F6E5365637572697479496E666F20786D6C6E733A7873693D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D612D696E7374616E63652220786D6C6E733A7873643D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D61223E0D0A20203C4D65726368616E7449643E4132573249444D35434A354F314B3C2F4D65726368616E7449643E0D0A20203C4D61726B6574706C61636549643E0D0A202020203C737472696E673E41314638334738433241524F37503C2F737472696E673E0D0A20203C2F4D61726B6574706C61636549643E0D0A3C2F416D617A6F6E5365637572697479496E666F3E
            var data = Convert.FromBase64String("PD94bWwgdmVyc2lvbj0iMS4wIj8+DQo8QW1hem9uU2VjdXJpdHlJbmZvIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiPg0KICA8TWVyY2hhbnRJZD5BMlcySURNNUNKNU8xSzwvTWVyY2hhbnRJZD4NCiAgPE1hcmtldHBsYWNlSWQ+DQogICAgPHN0cmluZz5BMUY4M0c4QzJBUk83UDwvc3RyaW5nPg0KICA8L01hcmtldHBsYWNlSWQ+DQo8L0FtYXpvblNlY3VyaXR5SW5mbz4=");
            var info = Serialized.Deserialize <AmazonSecurityInfo>(data);

            Assert.That(info.MerchantId, Is.EqualTo("A2W2IDM5CJ5O1K"));
        }
コード例 #10
0
        public void can_serialize_amazon_non_generic()
        {
            var data       = new AmazonSecurityInfo("A2W2IDM5CJ5O1K", null /*todo*/);
            var serialized = new Serialized(data);
            var actual     = Serialized.Deserialize <AmazonSecurityInfo>(serialized);

            Assert.That(actual.MerchantId, Is.EqualTo("A2W2IDM5CJ5O1K"));
        }
コード例 #11
0
		public static PayPointAccountModel ToModel(MP_CustomerMarketPlace account) {
			var payPointSecurityInfo = Serialized.Deserialize<PayPointSecurityInfo>(account.SecurityData);

			return new PayPointAccountModel {
				id = payPointSecurityInfo.MarketplaceId,
				mid = payPointSecurityInfo.Mid,
				vpnPassword = payPointSecurityInfo.VpnPassword,
				remotePassword = payPointSecurityInfo.RemotePassword
			};
		} // ToModel
コード例 #12
0
        }         // ToModel

        public static YodleeAccountModel ToModel(MP_CustomerMarketPlace marketplace, YodleeBanksRepository yodleeBanksRepository = null)
        {
            var securityInfo = Serialized.Deserialize <YodleeSecurityInfo>(marketplace.SecurityData);

            var yodleeBank = yodleeBanksRepository != null?yodleeBanksRepository.Search(securityInfo.CsId) : null;

            return(new YodleeAccountModel {
                bankId = yodleeBank != null ? yodleeBank.Id : 0,
                displayName = yodleeBank != null ? yodleeBank.Name : "Uploaded bank"
            });
        } // ToModel
コード例 #13
0
        public static YodleeAccountModel ToModel(IDatabaseCustomerMarketPlace marketplace, YodleeBanksRepository yodleeBanksRepository)
        {
            var securityInfo = Serialized.Deserialize <YodleeSecurityInfo>(marketplace.SecurityData);

            var yodleeBank = yodleeBanksRepository.Search(securityInfo.CsId);

            return(new YodleeAccountModel {
                bankId = yodleeBank.Id,
                displayName = yodleeBank.Name
            });
        }         // ToModel
コード例 #14
0
        }         // constructor

        public override IMarketPlaceSecurityInfo RetrieveCustomerSecurityInfo(
            int customerMarketPlaceId
            )
        {
            var account = GetDatabaseCustomerMarketPlace(customerMarketPlaceId);

            try {
                return(Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(account.SecurityData)));
            } catch (Exception e) {
                throw new ApiException(string.Format("Failed to de-serialise security data for marketplace {0} ({1})",
                                                     account.DisplayName, account.Id), e);
            }     // try
        }         // RetrieveSecurityInfo
コード例 #15
0
ファイル: Program.cs プロジェクト: vijayamazon/ezbob
        private static List <OrderItemTwo> GetOrders(int umi, ElapsedTimeInfo elapsedTimeInfo, AmazonServiceConnectionInfo _ConnectionInfo, int days, bool useReporting)
        {
            var session = ObjectFactory.GetInstance <ISession>();

            var marketplace = session.Get <MP_CustomerMarketPlace>(umi);

            var securityInfo = Serialized.Deserialize <AmazonSecurityInfo>(marketplace.SecurityData);

            var endDate   = DateTime.UtcNow;
            var startDate = endDate.AddDays(-days);

            var errorRetryingInfo = new ErrorRetryingInfo((bool)CurrentValues.Instance.AmazonEnableRetrying, CurrentValues.Instance.AmazonMinorTimeoutInSeconds, CurrentValues.Instance.AmazonUseLastTimeOut);

            errorRetryingInfo.Info    = new ErrorRetryingItemInfo[2];
            errorRetryingInfo.Info[0] = new ErrorRetryingItemInfo(CurrentValues.Instance.AmazonIterationSettings1Index, CurrentValues.Instance.AmazonIterationSettings1CountRequestsExpectError, CurrentValues.Instance.AmazonIterationSettings1TimeOutAfterRetryingExpiredInMinutes);
            errorRetryingInfo.Info[1] = new ErrorRetryingItemInfo(CurrentValues.Instance.AmazonIterationSettings2Index, CurrentValues.Instance.AmazonIterationSettings2CountRequestsExpectError, CurrentValues.Instance.AmazonIterationSettings2TimeOutAfterRetryingExpiredInMinutes);

            var amazonOrdersRequestInfo = new AmazonOrdersRequestInfo
            {
                StartDate         = startDate,
                EndDate           = endDate,
                MarketplaceId     = securityInfo.MarketplaceId,
                MerchantId        = securityInfo.MerchantId,
                ErrorRetryingInfo = errorRetryingInfo,
            };

            List <OrderItemTwo> orders;

            if (useReporting)
            {
                var configurator = AmazonServiceConfigurationFactory.CreateServiceReportsConfigurator(_ConnectionInfo);

                orders = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                    elapsedTimeInfo, umi,
                    ElapsedDataMemberType.RetrieveDataFromExternalService,
                    () => AmazonServiceReports.GetUserOrders(configurator, amazonOrdersRequestInfo, ActionAccessType.Full))
                         .Select(OrderItemTwo.FromOrderItem)
                         .ToList();
            }
            else
            {
                var ordersList = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(elapsedTimeInfo, umi,
                                                                                                ElapsedDataMemberType.RetrieveDataFromExternalService,
                                                                                                () => AmazonServiceHelper.GetListOrders(_ConnectionInfo, amazonOrdersRequestInfo, ActionAccessType.Full, null));

                //todo make it work again
                orders = new List <OrderItemTwo>();
            }

            return(orders);
        }
コード例 #16
0
        public JsonResult ParseYodlee(int customerId, int fileId)
        {
            var file         = m_oServiceClient.Instance.GetCompanyFile(_context.UserId, fileId);
            var fileMetaData = _companyFiles.Get(fileId);
            var parser       = new TransactionsParser();
            var parsed       = parser.ParseFile(fileMetaData.FileName, file);

            if (!string.IsNullOrEmpty(parsed.Error))
            {
                return(Json(new { error = parsed.Error }));
            }

            if (parsed.NumOfTransactions == 0)
            {
                return(Json(new { error = "File contains 0 transactions" }));
            }

            var customer = _customers.Get(customerId);
            var yodlee   = new YodleeServiceInfo();
            var yodleeMp = customer.CustomerMarketPlaces.FirstOrDefault(mp => mp.Marketplace.InternalId == yodlee.InternalId && mp.DisplayName == "ParsedBank");

            if (yodleeMp != null)
            {
                var data = Serialized.Deserialize <YodleeSecurityInfo>(yodleeMp.SecurityData);
                data.ItemId           = fileId;
                yodleeMp.SecurityData = new Serialized(data);
                _session.Flush();
                m_oServiceClient.Instance.UpdateMarketplace(customer.Id, yodleeMp.Id, false, _context.UserId);
            }
            else
            {
                int marketPlaceId = _mpTypes.GetAll().First(a => a.InternalId == yodlee.InternalId).Id;

                var securityData = new YodleeSecurityInfo {
                    ItemId        = fileId,
                    Name          = "",
                    Password      = "",
                    MarketplaceId = marketPlaceId,
                    CsId          = 0
                };

                var yodleeDatabaseMarketPlace = new YodleeDatabaseMarketPlace();
                var mp = _helper.SaveOrUpdateCustomerMarketplace("ParsedBank", yodleeDatabaseMarketPlace, securityData, customer);

                m_oServiceClient.Instance.UpdateMarketplace(customer.Id, mp.Id, false, _context.UserId);
            }     // if
            return(Json(new { }));
        }         // ParseYodlee
コード例 #17
0
        }         // ToModel

        public static AccountModel ToModel(IDatabaseCustomerMarketPlace account)
        {
            try {
                var m = Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(account.SecurityData));
                m.id = account.Id;
                return(m);
            } catch (Exception e) {
                throw new ApiException(
                          string.Format(
                              "Failed to de-serialize security data for marketplace {0} ({1})",
                              account.DisplayName,
                              account.Id
                              ),
                          e
                          );
            }     // try
        }         // ToModel
コード例 #18
0
        public ActionResult TryRecheckYodlee(int umi)
        {
            var mp            = _customerMarketplaces.Get(umi);
            var yodleeMain    = new YodleeMain();
            var yodleeAccount = _yodleeAccountsRepository.Search(mp.Customer.Id);

            if (yodleeAccount == null)
            {
                return(View(new { error = "Yodlee Account was not found" }));
            }

            var  securityInfo = Serialized.Deserialize <YodleeSecurityInfo>(mp.SecurityData);
            long itemId       = securityInfo.ItemId;
            var  lu           = yodleeMain.LoginUser(yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password));

            if (lu == null)
            {
                return(View(new { error = "Error Loging to Yodlee Account" }));
            }

            if (!yodleeMain.IsMFA(itemId))
            {
                bool isRefreshed;
                try {
                    isRefreshed = yodleeMain.RefreshNotMFAItem(itemId);
                } catch (RefreshYodleeException ex) {
                    Log.Warn(ex, "TryRecheckYodlee exception");
                    return(View(new { error = ex.ToString() }));
                }
                if (isRefreshed)
                {
                    var customer = mp.Customer;
                    m_oServiceClient.Instance.UpdateMarketplace(customer.Id, umi, true, _context.UserId);
                    return(View(new { success = true }));
                }

                return(View(new { error = "Account wasn't refreshed successfully" }));
            }

            //MFA Account for testing redirecting to Yodlee LAW
            var    callback = Url.Action("YodleeCallback", "YodleeRecheck", new { Area = "Underwriter" }, "https") + "/" + umi;
            string finalUrl = yodleeMain.GetEditAccountUrl(securityInfo.ItemId, callback, yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password));

            return(Redirect(finalUrl));
        }         // TryRecheckYodlee
コード例 #19
0
        }         // CheckEkm

        private void CheckHmrc(LoadCustomerMarketplaceSecurityData.ResultRow hmrc)
        {
            AccountModel oSecInfo;

            try {
                oSecInfo = Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(hmrc.SecurityData));
            }
            catch (Exception e) {
                Log.Alert(
                    e,
                    "Failed to de-serialise security data for HMRC marketplace {0} ({1}).",
                    hmrc.DisplayName,
                    hmrc.CustomerMarketplaceID
                    );

                return;
            }             // try

            if ((oSecInfo.login == m_oCustomerData.Mail) && (oSecInfo.password == VendorInfo.TopSecret))
            {
                if (hmrc.UpdatingStart.HasValue && hmrc.UpdatingStart.Value.AddDays(1) < DateTime.UtcNow)
                {
                    Result.HasUploadedHmrc = true;
                }
                return;
            }

            try {
                var ctr = new Connector(oSecInfo.Fill(), Log, m_oCustomerData.Id, m_oCustomerData.Mail);

                if (ctr.Init())
                {
                    ctr.Run(true);
                    ctr.Done();
                }                 // if
            }
            catch (InvalidCredentialsException) {
                Log.Debug("Invalid credentials detected for linked HMRC account {0} ({1}).", hmrc.CustomerMarketplaceID, oSecInfo.login);
                Result.LinkedHmrc.Add(oSecInfo.login);
            }
            catch (Exception e) {
                Log.Warn(e, "Failed to validate credentials for linked HMRC account {0} ({1}).", hmrc.CustomerMarketplaceID, oSecInfo.login);
            }     // try
        }         // CheckHmrc
コード例 #20
0
        }         // AccountData

        protected AccountData ValidateInput()
        {
            GetCustomerID();
            GetDisplayName();
            GetPassword();

            var oReader = new LoadCustomerMarketplaceSecurityData(
                CustomerID,
                m_sDisplayName,
                global::Integration.ChannelGrabberConfig.Configuration.GetInstance(Log).Hmrc.Guid()
                );

            oReader.Execute();

            if (oReader.Result.Count != 1)
            {
                Log.Warn("Too many/few HMRC accounts with display name of '{0}' for customer {1}.", m_sDisplayName, CustomerID);
                return(null);
            }             // if

            LoadCustomerMarketplaceSecurityData.ResultRow hmrc = oReader.Result[0];

            AccountModel oSecInfo;

            try {
                oSecInfo = Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(hmrc.SecurityData));
            }
            catch (Exception e) {
                Log.Alert(
                    e,
                    "Failed to de-serialise security data for HMRC marketplace {0} ({1}).",
                    hmrc.DisplayName,
                    hmrc.CustomerMarketplaceID
                    );

                return(null);
            }             // try

            return(new AccountData {
                CustomerMarketplaceID = hmrc.CustomerMarketplaceID,
                SecInfo = oSecInfo,
            });
        }         // ValidateInput
コード例 #21
0
        }         // Name

        public override void Execute()
        {
            ChaGraConfig oCgCfg = ChaGraConfig.GetInstance(Log);

            m_oStra.Execute();

            foreach (var oRes in m_oStra.Result)
            {
                string sSecData;

                VendorInfo vi = oCgCfg.GetVendorInfo(oRes.MarketplaceType);

                if (vi == null)
                {
                    switch (oRes.MarketplaceType.Trim().ToLower())
                    {
                    case "ekm":
                        sSecData = TryDecrypt(oRes.SecurityData);
                        break;

                    case "yodlee":
                        sSecData = Serialized.Deserialize <YodleeSecurityInfo>(oRes.SecurityData).Stringify();
                        break;

                    default:
                        sSecData = oRes.SecurityData.ToString();
                        break;
                    }                     // switch
                }
                else
                {
                    sSecData = TryDecrypt(oRes.SecurityData);
                }

                Log.Info(
                    "Customer market place {0} - ({1}) {2}:\n{3}\n\n",
                    oRes.MarketplaceType,
                    oRes.CustomerMarketplaceID,
                    oRes.DisplayName,
                    sSecData
                    );
            }     // for each result
        }         // Execute
コード例 #22
0
        public static bool TryExtractErrorMessage(SoapException ex, out ServiceFaultDetail fault)
        {
            fault = null;
            if (ex == null)
            {
                return(false);
            }

            try
            {
                fault = Serialized.Deserialize <ServiceFaultDetail>(ex.Detail.InnerXml);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
コード例 #23
0
        }         // Check

        public void Check(Guid marketplaceType, Customer customer, long csId)
        {
            if (this.WhiteList.IsMarketPlaceInWhiteList(marketplaceType, string.Format("{0}", csId)))
            {
                return;
            }

            var alreadyAdded = customer.CustomerMarketPlaces
                               .Where(m =>
                                      m.Marketplace.InternalId == marketplaceType &&
                                      m.Customer.CustomerOrigin.CustomerOriginID == customer.CustomerOrigin.CustomerOriginID
                                      )
                               .Select(m => Serialized.Deserialize <YodleeSecurityInfo>(m.SecurityData))
                               .Any(s => s.CsId == csId);

            if (alreadyAdded)
            {
                throw new MarketPlaceAddedByThisCustomerException();
            }
        } // Check
コード例 #24
0
        }         // Name

        public override void Execute()
        {
            Log.Debug("Loading uploaded HMRC data for customer {0}...", this.customerID);

            List <MpData> lst = DB.Fill <MpData>(
                "LoadCustomerUploadedHmrcAccountData",
                CommandSpecies.StoredProcedure,
                new QueryParameter("CustomerID", this.customerID)
                );

            if (lst.Count < 1)
            {
                Log.Debug("Customer {0} has no uploaded HMRC marketplace.", this.customerID);
                return;
            }             // if

            Log.Say(
                lst.Count > 1 ? Severity.Alert : Severity.Debug,
                "Customer {0} has {1}.",
                this.customerID,
                Grammar.Number(lst.Count, "uploaded HMRC marketplace")
                );

            var vendorInfo = global::Integration.ChannelGrabberConfig.Configuration.Instance.Hmrc;

            int counter = 1;

            foreach (MpData mpData in lst)
            {
                try {
                    AccountModel x = Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(mpData.SecurityData));

                    if (x.password != VendorInfo.TopSecret)
                    {
                        Log.Warn(
                            "Password is not '{1}' for marketplace {0}, skipping it.",
                            mpData.MpID,
                            VendorInfo.TopSecret
                            );

                        continue;
                    }                     // if
                } catch {
                    Log.Warn("Failed to deserialise security data for marketplace {0}, skipping it.", mpData.MpID);
                    continue;
                }                 // try

                var model = new AccountModel {
                    accountTypeName = vendorInfo.Name,
                    displayName     = mpData.NewEmail,
                    name            = mpData.NewEmail,
                    login           = mpData.NewEmail,
                    password        = VendorInfo.TopSecret,
                };

                string displayName = string.Format("{0}{1}", mpData.NewEmail, lst.Count > 1 ? "-" + counter : string.Empty);

                Log.Debug("Updating security data and display name for marketplace id {0}...", mpData.MpID);

                DB.ExecuteNonQuery(
                    "UpdateCustomerUploadedHmrcAccountData",
                    CommandSpecies.StoredProcedure,
                    new QueryParameter("@MpID", mpData.MpID),
                    new QueryParameter("@DisplayName", displayName),
                    new QueryParameter("@SecurityData", new Encrypted(new Serialized(model)))
                    );

                Log.Debug("Updated security data and display name for marketplace id {0}.", mpData.MpID);

                counter++;
            }     // for each
        }         // Execute
コード例 #25
0
        protected override ElapsedTimeInfo RetrieveAndAggregate(
            IDatabaseCustomerMarketPlace databaseCustomerMarketPlace,
            MP_CustomerMarketplaceUpdatingHistory historyRecord
            )
        {
            log.Info("Starting to update Sage marketplace. Id:{0} Name:{1}", databaseCustomerMarketPlace.Id, databaseCustomerMarketPlace.DisplayName);

            SageSecurityInfo sageSecurityInfo = (Serialized.Deserialize <SageSecurityInfo>(databaseCustomerMarketPlace.SecurityData));

            string accessToken = sageSecurityInfo.AccessToken;

            log.Info("Getting sales invoices...");

            SageSalesInvoicesList salesInvoices = SageConnector.GetSalesInvoices(
                accessToken,
                Helper.GetSageDeltaPeriod(databaseCustomerMarketPlace)
                );

            log.Info("Getting incomes...");

            SageIncomesList incomes = SageConnector.GetIncomes(
                accessToken,
                Helper.GetSageDeltaPeriod(databaseCustomerMarketPlace)
                );

            log.Info("Getting purchase invoices...");

            SagePurchaseInvoicesList purchaseInvoices = SageConnector.GetPurchaseInvoices(
                accessToken,
                Helper.GetSageDeltaPeriod(databaseCustomerMarketPlace)
                );

            log.Info("Getting expenditures...");

            SageExpendituresList expenditures = SageConnector.GetExpenditures(
                accessToken,
                Helper.GetSageDeltaPeriod(databaseCustomerMarketPlace)
                );

            var elapsedTimeInfo = new ElapsedTimeInfo();

            log.Info("Saving request, {0} sales invoices, {1} purchase invoices, {2} incomes, {3} expenditures in DB...", salesInvoices.Count, purchaseInvoices.Count, incomes.Count, expenditures.Count);

            ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                elapsedTimeInfo,
                databaseCustomerMarketPlace.Id,
                ElapsedDataMemberType.StoreDataToDatabase,
                () => Helper.StoreSageData(
                    databaseCustomerMarketPlace,
                    salesInvoices,
                    purchaseInvoices,
                    incomes,
                    expenditures,
                    historyRecord
                    )
                );

            log.Info("Getting payment statuses...");
            var paymentStatuses = SageConnector.GetPaymentStatuses(accessToken);

            ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                elapsedTimeInfo,
                databaseCustomerMarketPlace.Id,
                ElapsedDataMemberType.StoreDataToDatabase,
                () => Helper.StoreSagePaymentStatuses(paymentStatuses)
                );

            return(elapsedTimeInfo);
        }
コード例 #26
0
        }         // RetrieveSecurityInfo

        protected override ElapsedTimeInfo RetrieveAndAggregate(
            IDatabaseCustomerMarketPlace databaseCustomerMarketPlace,
            MP_CustomerMarketplaceUpdatingHistory historyRecord
            )
        {
            if (historyRecord == null)               // should never happen
            {
                var os = new StringBuilder();
                var st = new StackTrace(true);

                os.Append("historyRecord is NULL when creating/updating a Channel Grabber account!");

                for (var i = 0; i < st.FrameCount; i++)
                {
                    StackFrame oFrame = st.GetFrame(i);
                    os.AppendFormat("\n\t{0}: {1} at {2}:{3}:{4}",
                                    i,
                                    oFrame.GetMethod().Name,
                                    oFrame.GetFileName(),
                                    oFrame.GetFileLineNumber(),
                                    oFrame.GetFileColumnNumber()
                                    );
                }                 // for

                ms_oLog.Error("{0}", os.ToString());

                throw new ApiException("History record is not specified.");
            }             // if

            AccountModel oSecInfo;

            try {
                oSecInfo = Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(databaseCustomerMarketPlace.SecurityData));
            } catch (Exception e) {
                throw new ApiException(string.Format("Failed to de-serialise security data for marketplace {0} ({1})",
                                                     databaseCustomerMarketPlace.DisplayName, databaseCustomerMarketPlace.Id), e);
            }             // try

            AccountData ad = oSecInfo.Fill();

            var ctr = new Connector(
                ad,
                ms_oLog,
                databaseCustomerMarketPlace.Customer.Id,
                databaseCustomerMarketPlace.Customer.Name
                );

            if (ctr.Init())
            {
                try {
                    ctr.Run(false, databaseCustomerMarketPlace.Id);

                    switch (ad.VendorInfo.Behaviour)
                    {
                    case Behaviour.Default:
                        return(ProcessRetrieved(
                                   ctr.DataHarvester,
                                   databaseCustomerMarketPlace,
                                   historyRecord
                                   ));

                    case Behaviour.HMRC:
                        if (ctr.DataHarvester.ErrorsToEmail.Count > 0)
                        {
                            ObjectFactory.GetInstance <IEzServiceAccessor>().EmailHmrcParsingErrors(
                                databaseCustomerMarketPlace.Customer.Id,
                                databaseCustomerMarketPlace.Id,
                                ctr.DataHarvester.ErrorsToEmail
                                );
                        }                         // if

                        return(ObjectFactory.GetInstance <IEzServiceAccessor>().SaveVatReturnData(
                                   databaseCustomerMarketPlace.Id,
                                   historyRecord.Id,
                                   ctr.SourceID,
                                   HmrcVatReturnConversion(ctr.DataHarvester),
                                   HmrcRtiTaxMonthConversion(ctr.DataHarvester)
                                   ));

                    default:
                        throw new ApiException("Unsupported behaviour for CG flavour: " + ad.VendorInfo.Behaviour.ToString());
                    }                     // switch
                } catch (ApiException) {
                    ctr.Done();
                    throw;
                }         // try
            }             // if Init succeeded

            throw new ApiException("Failed to initialise CG connector.");
        }         // RetrieveAndAggregate
コード例 #27
0
 protected TSecurityData RetrieveCustomerSecurityInfo <TSecurityData>(IDatabaseCustomerMarketPlace databaseCustomerMarketPlace)
     where TSecurityData : IMarketPlaceSecurityInfo
 {
     return(Serialized.Deserialize <TSecurityData>(databaseCustomerMarketPlace.SecurityData));
 }
コード例 #28
0
 public override IMarketPlaceSecurityInfo RetrieveCustomerSecurityInfo(int customerMarketPlaceId)
 {
     return(Serialized.Deserialize <YodleeSecurityInfo>(GetDatabaseCustomerMarketPlace(customerMarketPlaceId)
                                                        .SecurityData));
 }         // RetrieveCustomerSecurityInfo
コード例 #29
0
        public override IMarketPlaceSecurityInfo RetrieveCustomerSecurityInfo(int customerMarketPlaceId)
        {
            IDatabaseCustomerMarketPlace customerMarketPlace = GetDatabaseCustomerMarketPlace(customerMarketPlaceId);

            return(Serialized.Deserialize <PayPointSecurityInfo>(customerMarketPlace.SecurityData));
        }
コード例 #30
0
        }         // Execute

        private LandRegistryDataModel GetLandRegistryEnquiryData()
        {
            try {
                //check cache
                var landRegistryLoad = new LandRegistryLoad(this.customerID);
                landRegistryLoad.Execute();
                var customersLrs = landRegistryLoad.Result;
                var cache        = customersLrs.Where(x => x.RequestTypeEnum == LandRegistryRequestType.Enquiry).ToList();

                if (cache.Any())
                {
                    foreach (var landRegistry in cache)
                    {
                        var           lrReq     = Serialized.Deserialize <LandRegistryLib.LREnquiryServiceNS.RequestSearchByPropertyDescriptionV2_0Type>(landRegistry.Request);
                        Q1AddressType lrAddress = lrReq.Product.SubjectProperty.Address;

                        if (lrAddress.IsA(this.buildingNumber, this.buildingName, this.streetName, this.cityName, this.postCode))
                        {
                            var b          = new LandRegistryModelBuilder();
                            var cacheModel = new LandRegistryDataModel {
                                Request      = landRegistry.Request,
                                Response     = landRegistry.Response,
                                Enquery      = b.BuildEnquiryModel(landRegistry.Response),
                                RequestType  = landRegistry.RequestTypeEnum,
                                ResponseType = landRegistry.ResponseTypeEnum,
                                DataSource   = LandRegistryDataSource.Cache,
                            };
                            return(cacheModel);
                        }         // if
                    }             // for each
                }                 // if
            } catch (Exception ex) {
                Log.Warn(ex, "Failed to retrieve land registry enquiry from cache.");
            }             // try

            bool isProd = CurrentValues.Instance.LandRegistryProd;

            ILandRegistryApi lr;

            if (isProd)
            {
                lr = new LandRegistryApi(
                    CurrentValues.Instance.LandRegistryUserName,
                    Encrypted.Decrypt(CurrentValues.Instance.LandRegistryPassword),
                    CurrentValues.Instance.LandRegistryFilePath);
            }
            else
            {
                lr = new LandRegistryTestApi();
            }

            var model = lr.EnquiryByPropertyDescription(this.buildingNumber, this.buildingName, this.streetName, this.cityName, this.postCode, this.customerID);


            var lrDB = new LandRegistryDB {
                CustomerId   = this.customerID,
                InsertDate   = DateTime.UtcNow,
                Postcode     = string.IsNullOrEmpty(this.postCode) ? string.Format("{3}{0},{1},{2}", this.buildingNumber, this.streetName, this.cityName, this.buildingName) : this.postCode,
                Request      = model.Request,
                Response     = model.Response,
                RequestType  = model.RequestType.ToString(),
                ResponseType = model.ResponseType.ToString()
            };
            int lrID = DB.ExecuteScalar <int>("LandRegistryDBSave", CommandSpecies.StoredProcedure, DB.CreateTableParameter("Tbl", lrDB));

            Log.Info("LandRegistryDBSave {0}", lrID);
            model.DataSource = LandRegistryDataSource.Api;

            return(model);
        }         // GetLandRegistryEnquiryData