private static int? CreateDealContact(CookieCollection cookies, C6_15tblAmberbrookDealInfo blueDeal, DealDetailModel deepBlueDealDetail, out string resp) { int? contactId = null; resp = string.Empty; DeepBlue.Models.Admin.EditDealContactModel model = new Models.Admin.EditDealContactModel(); model.ContactName = blueDeal.AmberContactName; NameValueCollection formValues = HttpWebRequestUtil.SetUpForm(model, string.Empty, string.Empty); // Send the request string url = HttpWebRequestUtil.GetUrl("/Admin/UpdateDealContact"); byte[] postData = System.Text.Encoding.ASCII.GetBytes(HttpWebRequestUtil.ToFormValue(formValues)); HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, postData, true, cookies); if (response.StatusCode == System.Net.HttpStatusCode.OK) { using (Stream receiveStream = response.GetResponseStream()) { // Pipes the stream to a higher level stream reader with the required encoding format. using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) { resp = readStream.ReadToEnd(); contactId = HttpWebRequestUtil.GetNewKeyFromResponse(resp); response.Close(); readStream.Close(); } } } return contactId; }
private static string ImportDealExpenses(CookieCollection cookies, BlueEntities context, C6_15tblAmberbrookDealInfo blueDeal, DealDetailModel deepBlueDealDetail) { int dealId = deepBlueDealDetail.DealId; StringBuilder sb = new StringBuilder(); string message = string.Empty; if (deepBlueDealDetail.DealExpenses == null || deepBlueDealDetail.DealExpenses.Count == 0) { List<C6_40tblDealExpenses> blueDealExpenses = context.C6_40tblDealExpenses.Where(x => x.AmberbrookFundNo == blueDeal.AmberbrookFundNo).Where(x => x.AmberbrookDealNo == blueDeal.DealNo).ToList(); if (blueDealExpenses.Count > 0) { foreach (C6_40tblDealExpenses blueDealExpense in blueDealExpenses) { string resp = string.Empty; int? dealExpenseId = ImportDealExpense(cookies, blueDealExpense, dealId, out resp); if (!dealExpenseId.HasValue) { string error = "Failed to import deal expense for amb fund#:" + blueDealExpense.AmberbrookFundNo + " ,deal#:" + blueDealExpense.AmberbrookDealNo + ", error:" + resp; // Util.WriteError(error); sb.Append(error); } else { message = "New DealExpenseID:" + dealExpenseId; Util.WriteNewEntry(message); messageLog.AppendLine(message); } } } else { Util.Log("No deal expenses found to import.."); } } else { message = "Deal:" + dealId + " already has deal expenses. Skipping Importing Deal Expenses"; Util.WriteWarning(message); messageLog.AppendLine(message); } return sb.ToString(); }
private static int? ImportDealSellerInfo(CookieCollection cookies, C6_15tblAmberbrookDealInfo blueDeal, DealDetailModel deepBlueDealDetail, out string resp) { int dealId = deepBlueDealDetail.DealId; int? sellerId = null; resp = string.Empty; string message = string.Empty; if (!deepBlueDealDetail.SellerContactId.HasValue) { if (!string.IsNullOrEmpty(blueDeal.SellerName)) { DealSellerDetailModel model = new DealSellerDetailModel(); model.DealId = deepBlueDealDetail.DealId; model.SellerName = blueDeal.SellerName; model.ContactName = blueDeal.SellerCompany; model.Phone = blueDeal.SellerPhone; model.Email = blueDeal.SellerEmail; model.Fax = blueDeal.SellerFax; model.CompanyName = blueDeal.SellerCompany; model.SellerTypeId = Globals.SellerTypes.Where(x => x.SellerType1.Equals(blueDeal.SellerType)).FirstOrDefault().SellerTypeID; NameValueCollection formValues = HttpWebRequestUtil.SetUpForm(model, string.Empty, string.Empty); // Send the request string url = HttpWebRequestUtil.GetUrl("/Deal/CreateSellerInfo"); string data = HttpWebRequestUtil.ToFormValue(formValues); messageLog.AppendLine("Form data:" + data); byte[] postData = System.Text.Encoding.ASCII.GetBytes(data); HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, postData, true, cookies); if (response.StatusCode == System.Net.HttpStatusCode.OK) { using (Stream receiveStream = response.GetResponseStream()) { // Pipes the stream to a higher level stream reader with the required encoding format. using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) { resp = readStream.ReadToEnd(); messageLog.AppendLine("Response: " + resp); sellerId = HttpWebRequestUtil.GetNewKeyFromResponse(resp); response.Close(); readStream.Close(); } } } } else { message = "Blue Deal: " + blueDeal.DealName + " doesnt have a seller"; Util.Log(message); return 0; } } else { sellerId = deepBlueDealDetail.SellerContactId; message = "Seller Contact already exists:" + sellerId; Util.WriteWarning(message); messageLog.AppendLine(message); } return sellerId; }
private static int? ImportDealContact(CookieCollection cookies, C6_15tblAmberbrookDealInfo blueDeal, DealDetailModel deepBlueDealDetail, out string resp) { int? contactId = null; resp = string.Empty; string message = string.Empty; if (!deepBlueDealDetail.ContactId.HasValue) { DealContactList dealContact = ContactsList.Where(c => c.ContactName == blueDeal.AmberContactName).FirstOrDefault(); if (dealContact != null) { contactId = dealContact.ContactId; Util.Log("Found contact.."); } else { contactId = CreateDealContact(cookies, blueDeal, deepBlueDealDetail, out resp); if (contactId.HasValue) { message = "New Contact created:" + contactId + " for deal:" + deepBlueDealDetail.DealId; Util.WriteNewEntry(message); messageLog.AppendLine(message); ContactsList.Add(new DealContactList { ContactName = blueDeal.AmberContactName, ContactId = contactId.Value }); } } if (contactId.HasValue) { int? dealId = UpdateDealWithContact(cookies, contactId.Value, deepBlueDealDetail, out resp); if (!dealId.HasValue) { resp = string.Format("Unable to update deal: {0} with contactId: {1}, Reason: {2}", dealId, contactId, resp); } else { string success = string.Format("deal: {0} updated with contactId: {1}, DealContactID: {2}", deepBlueDealDetail.DealId, contactId, dealId); Util.WriteNewEntry(success); messageLog.AppendLine(success); } } // } else { contactId = deepBlueDealDetail.ContactId; message = "Contact already exists. ContactID:" + contactId; Console.Write(message); } return contactId; }
private static string ImportAssetInDeal(CookieCollection cookies, BlueEntities context, C6_15tblAmberbrookDealInfo blueDeal, C6_10AmberbrookFundInfo blueDealAmbFund, DeepBlue.Models.Deal.DealListModel deepBlueDeal, int fundID) { StringBuilder sb = new StringBuilder(); List<C5_10tblDealOrigination> blueAssetsInDeal = context.C5_10tblDealOrigination.Where(x => x.AmberbrookFundNo == blueDeal.AmberbrookFundNo).Where(x => x.DealNo == blueDeal.DealNo).ToList(); DealDetailModel deepBlueDealDetail = GetDeal(cookies, deepBlueDeal.DealId); foreach (C5_10tblDealOrigination blueAssetInDeal in blueAssetsInDeal) { // This can either be a direct or a UF C7_10tblGPPaymentInstructions blueAsset = context.C7_10tblGPPaymentInstructions.Where(x => x.Fund.Equals(blueAssetInDeal.Fund, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (blueAsset != null) { // Find the deal with the same DealNumber and DealName, and that belongs to the same Amberbrook fund if (blueAsset.FundType.Equals("Direct", StringComparison.OrdinalIgnoreCase)) { List<KeyValuePair<C5_11tblDealOriginationDirects, string>> failedDirects = ImportUnderlyingDirect(cookies, context, blueAssetInDeal, deepBlueDeal.DealId, deepBlueDealDetail, fundID); if (failedDirects.Count > 0) { Util.WriteError("The following " + failedDirects.Count + " securities could not be imported:"); } foreach (KeyValuePair<C5_11tblDealOriginationDirects, string> failedDirect in failedDirects) { string errorMsg = "Cannot import direct:" + failedDirect.Key.Direct + " into the deal:" + deepBlueDeal.DealId + ", reason:" + failedDirect.Value; Util.WriteError(errorMsg); sb.Append(" " + errorMsg + " "); } } else { string resp = string.Empty; int? underlyingFundId = ImportUnderlyingFund(cookies, blueAssetInDeal, deepBlueDeal.DealId, fundID, deepBlueDealDetail, out resp); if (!underlyingFundId.HasValue) { string error = "Failed to import underlying fund:" + blueAssetInDeal.Fund + " into deal:" + deepBlueDeal.DealId + ", error:" + resp; Util.WriteError(error); sb.Append(error); } else { Util.Log("New DealUnderlyingFundID:" + underlyingFundId); } } } else { string msg = "Unable to find record in C7_10tblGPPaymentInstructions with Fund:" + blueAssetInDeal.Fund; Util.WriteError(msg); sb.Append(msg); } } return sb.ToString(); }
private static int? CreateNewDeal(CookieCollection cookies, C6_15tblAmberbrookDealInfo blueDeal, int fundID, int? purchaseTypeId, out string resp) { int? dealID = null; resp = string.Empty; // Deal/Create DealDetailModel model = new DealDetailModel(); model.FundId = fundID; model.DealName = blueDeal.DealName; model.DealNumber = blueDeal.DealNo; if (purchaseTypeId.HasValue) { model.PurchaseTypeId = purchaseTypeId.Value; } model.IsPartnered = false; // GPP // NPP/ // Total Costs // Syn // Syndicate // AmberBrook Contact Name // Seller Type DeepBlue has InvestorEntityType which has same values as SellerType. However, InvestorEntityType is on the Investor level // => Contact // Seller Name // Seller Company // Seller Phone // Seller Fax // Seller Email // Seller Comments // Comments // blueDeal.NAVAllocation // model.ContactId; // model.IsPartnered; // model.PartnerName; NameValueCollection formValues = HttpWebRequestUtil.SetUpForm(model, string.Empty, string.Empty); formValues.Remove("SellerInfo"); formValues.Remove("DealExpenses"); formValues.Remove("DealUnderlyingFunds"); formValues.Remove("DealUnderlyingDirects"); // Send the request string url = HttpWebRequestUtil.GetUrl("Deal/Create"); byte[] postData = System.Text.Encoding.ASCII.GetBytes(HttpWebRequestUtil.ToFormValue(formValues)); HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, postData, true, cookies); if (response.StatusCode == System.Net.HttpStatusCode.OK) { using (Stream receiveStream = response.GetResponseStream()) { // Pipes the stream to a higher level stream reader with the required encoding format. using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) { resp = readStream.ReadToEnd(); dealID = HttpWebRequestUtil.GetNewKeyFromResponse(resp); response.Close(); readStream.Close(); } } } return dealID; }
/// <summary> /// Deprecated Method for adding a new object to the C6_15tblAmberbrookDealInfo EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToC6_15tblAmberbrookDealInfo(C6_15tblAmberbrookDealInfo c6_15tblAmberbrookDealInfo) { base.AddObject("C6_15tblAmberbrookDealInfo", c6_15tblAmberbrookDealInfo); }
/// <summary> /// Create a new C6_15tblAmberbrookDealInfo object. /// </summary> /// <param name="amberbrookFundNo">Initial value of the AmberbrookFundNo property.</param> /// <param name="dealNo">Initial value of the DealNo property.</param> /// <param name="dealName">Initial value of the DealName property.</param> /// <param name="grossPurchasePrice">Initial value of the GrossPurchasePrice property.</param> /// <param name="netPurchasePrice">Initial value of the NetPurchasePrice property.</param> /// <param name="totalCosts">Initial value of the TotalCosts property.</param> /// <param name="amberContactName">Initial value of the AmberContactName property.</param> /// <param name="sSMA_TimeStamp">Initial value of the SSMA_TimeStamp property.</param> public static C6_15tblAmberbrookDealInfo CreateC6_15tblAmberbrookDealInfo(global::System.String amberbrookFundNo, global::System.Int32 dealNo, global::System.String dealName, global::System.Decimal grossPurchasePrice, global::System.Decimal netPurchasePrice, global::System.Decimal totalCosts, global::System.String amberContactName, global::System.Byte[] sSMA_TimeStamp) { C6_15tblAmberbrookDealInfo c6_15tblAmberbrookDealInfo = new C6_15tblAmberbrookDealInfo(); c6_15tblAmberbrookDealInfo.AmberbrookFundNo = amberbrookFundNo; c6_15tblAmberbrookDealInfo.DealNo = dealNo; c6_15tblAmberbrookDealInfo.DealName = dealName; c6_15tblAmberbrookDealInfo.GrossPurchasePrice = grossPurchasePrice; c6_15tblAmberbrookDealInfo.NetPurchasePrice = netPurchasePrice; c6_15tblAmberbrookDealInfo.TotalCosts = totalCosts; c6_15tblAmberbrookDealInfo.AmberContactName = amberContactName; c6_15tblAmberbrookDealInfo.SSMA_TimeStamp = sSMA_TimeStamp; return c6_15tblAmberbrookDealInfo; }