private void ImportFundCompanyLinkData(DataRow row, DataContext dataContext) { string fundId = row["FundID"].ToString(); string deletedCompanyId = row["deletedCompany"].ToString(); string addedCompanyId = row["addedCompany"].ToString(); if (!String.IsNullOrEmpty(fundId) && !String.IsNullOrEmpty(deletedCompanyId) && !String.IsNullOrEmpty(addedCompanyId)) { FundCompanyLinkGroup fundCompanyLinkGroup = new FundCompanyLinkGroup(dataContext,fundId); ArrayList fundCompanyLinks = fundCompanyLinkGroup.GetCompanyLinksByFundId(fundId); if(fundCompanyLinks != null && fundCompanyLinks.Count > 0) { for(int i = 0; i < fundCompanyLinks.Count; i++) { FundCompanyLinkGroup.FundCompanyLink fundCompanyLink = (FundCompanyLinkGroup.FundCompanyLink) fundCompanyLinks[i]; if (fundCompanyLink.CompanyId == deletedCompanyId) { fundCompanyLinkGroup.Records.Remove(fundCompanyLink); FundCompanyLinkGroup.FundCompanyLink link = fundCompanyLinkGroup.CreateOrGetCompanyLinkObject(fundId, fundCompanyLink.EffectiveDate, addedCompanyId, fundCompanyLink.CompanyType); new OperationDataGroupContainer(fundCompanyLinkGroup).Save(); break; } } } } }
private void DeleteFundCompanyLinkData(DataRow row, DataContext dataContext) { try { string fundId = row["FundId"].ToString().Trim(); string companyId = row["CompanyID"].ToString().Trim(); int companyTypeId = 0; int.TryParse(row["CompanyTypeId"].ToString().Trim(), out companyTypeId); if(companyTypeId != 0 && !String.IsNullOrEmpty(fundId) && !String.IsNullOrEmpty(companyId)) { _log.Info(String.Format("handle FundCompanyLink:{0},{1},{2} begin", fundId, companyId, companyTypeId.ToString())); FundCompanyLinkGroup fundCompanyLinkGroup = new FundCompanyLinkGroup(dataContext, fundId); ArrayList fundCompanyLinks = fundCompanyLinkGroup.GetCompanyLinksByFundIdCompanyType(fundId, companyTypeId); if(fundCompanyLinks != null && fundCompanyLinks.Count > 0) { foreach (FundCompanyLinkGroup.FundCompanyLink fundCompanyLink in fundCompanyLinks) { if(fundCompanyLink.CompanyId == companyId) { fundCompanyLinkGroup.Records.Remove(fundCompanyLink); new OperationDataGroupContainer(fundCompanyLinkGroup).Save(); _log.Info(String.Format("delete FundCompanyLink:{0},{1},{2} successfully.", fundId, companyId, companyTypeId.ToString())); } } } else { _log.Info("Not exist this fund company link data"); } _log.Info(String.Format("handle FundCompanyLink:{0},{1},{2} end", fundId, companyId, companyTypeId.ToString())); } else { _log.Warn("Data Error, can't handle the next step."); } } catch (Exception ex) { _log.Warn(ex.Message); } }