Пример #1
0
        public static CompanyResult GetStock(string input)
        {
            string urlMarkit = "http://dev.markitondemand.com/Api/v2/Quote/json?symbol=" + input;

            try
            {
                using (WebClient webClient = new WebClient())
                {
                    string json = webClient.DownloadString(urlMarkit);

                    var o = JObject.Parse(json);

                    CompanyResult cr = new CompanyResult();

                    cr.status = o["Status"].ToString();

                    if (cr.status == null)
                    {
                        Console.WriteLine("There is no data for " + input + ". Please make sure you have written the correct symbol for the company you are looking for.");
                        return null;
                    }

                    else
                    {
                        cr.name = o["Name"].ToString();

                        cr.symbol = o["Symbol"].ToString();

                        cr.lastPrice = o["LastPrice"].ToString();

                        cr.low = o["Low"].ToString();

                        cr.high = o["High"].ToString();

                        string lastPrice = cr.lastPrice;

                        decimal priceParse = Convert.ToDecimal(lastPrice);

                        return cr;
                    }
                }
            }
            catch (Exception e)
            {

                Console.WriteLine("There was an error, please try again.");
                return null;
            }
        }
Пример #2
0
        // converts the received person/company object into a string
        public String convertObjectToString(Result obj, String separator)
        {
            String result = "";

            switch (obj is PersonResult)
            {
            case true:
                PersonResult person = obj as PersonResult;
                result += "person" + separator +    // result type
                          person.firstName + separator +
                          person.lastName + separator +
                          "" + separator +     // company name
                          person.phone1 + separator +
                          person.phone2 + separator +
                          person.phone3 + separator +
                          person.streetAddressName + separator +
                          person.streetAddressNumber + separator +
                          person.streetAddressZipcode + separator +
                          person.streetAddressCity + separator +
                          person.boxAddress + separator +
                          person.postAddress + separator +
                          person.coordinateEast + separator +
                          person.coordinateNorth + separator +
                          person.birthday;
                break;

            case false:
                CompanyResult company = obj as CompanyResult;
                result += "company" + separator + // result type
                          "" + separator +        // first name
                          "" + separator +        // last name
                          company.companyName + separator +
                          company.phone1 + separator +
                          company.phone2 + separator +
                          company.phone3 + separator +
                          company.streetAddressName + separator +
                          company.streetAddressNumber + separator +
                          company.streetAddressZipcode + separator +
                          company.streetAddressCity + separator +
                          company.boxAddress + separator +
                          company.postAddress + separator +
                          company.coordinateEast + separator +
                          company.coordinateNorth + separator +
                          "";     // birthday
                break;
            }
            return(ISO8859_1_Filter(extraSpaceRemover(result)));
        }
Пример #3
0
 private void CountResults(CompanyResult result)
 {
     if (result != null)
     {
         if (result.Company != null)
         {
             _loadCount.AddLoaded(EntityType.Company);
             _loadCount.AddLoaded(EntityType.Contact, (uint)result.Company.Contacts.Count);
         }
         if (result.Customer != null)
         {
             _loadCount.AddLoaded(EntityType.Customer);
             _loadCount.AddLoaded(EntityType.CustomerNote, (uint)result.Customer.Notes.Count);
         }
     }
 }
    public static CompanyResult GetCompanies(string email)
    {
        Organizations organizations = new Organizations(LoginUser.Anonymous);

        organizations.LoadByEmail(email);
        List <ComboBoxItem> items = new List <ComboBoxItem>();

        foreach (Organization organization in organizations)
        {
            items.Add(new ComboBoxItem(organization.Name, organization.OrganizationID));
        }


        CompanyResult result = new CompanyResult();

        result.Items = items.ToArray();

        result.SelectedID = int.Parse(SystemSettings.ReadString(LoginUser.Anonymous, "LastCompany-" + email, "-1"));

        return(result);
    }
Пример #5
0
        protected override IEnumerable <CompanyResult> BirthRecords()
        {
            _loadCount.Reset();

            _brokersByName          = new Dictionary <string, Models.Company>();
            _customersPendingBroker = new Dictionary <string, List <Customer> >();
            _notebookFactory        = NotebookFactory.Create(_newContext);

            var companies     = SelectCompaniesToLoad(OldContext);
            var nextCompanyId = 1;

            foreach (var company in companies)
            {
                _loadCount.AddRead(EntityType.Company);

                SerializableCompany serialized;
                var newCompany = CreateNewCompany(company, nextCompanyId, out serialized);
                if (newCompany == null)
                {
                    continue;
                }

                if (!newCompany.CompanyTypes.Any())
                {
                    Log(new CallbackParameters(CallbackReason.CompanyTypeUndetermined)
                    {
                        Company = company
                    });
                }

                Customer newCustomer = null;
                if (newCompany.CompanyTypes.Any(t => t.CompanyTypeEnum == CompanyType.Customer))
                {
                    var broker = serialized != null && serialized.Customer != null && !string.IsNullOrWhiteSpace(serialized.Customer.Broker) ? serialized.Customer.Broker : company.CustomerBroker;
                    if (string.IsNullOrWhiteSpace(broker))
                    {
                        Log(new CallbackParameters(CallbackReason.CustomerDefaultBrokerAssigned)
                        {
                            Company = company
                        });
                        broker = Models.StaticRecords.StaticCompanies.RVCBroker.Name;
                    }

                    newCustomer = CreateCustomer(newCompany, broker, company);
                }
                newCompany.Contacts = GetContacts(company.Contacts, newCompany).ToList();

                if (newCompany.CompanyTypes.Any(t => t.CompanyTypeEnum == CompanyType.Broker))
                {
                    RegisterBroker(newCompany.Name, newCompany);
                }

                var companyResult = new CompanyResult(newCompany, newCustomer);
                CountResults(companyResult);
                nextCompanyId += 1;
                yield return(companyResult);
            }

            _customersPendingBroker.ForEach(c => c.Value.ForEach(u => Log(new CallbackParameters(CallbackReason.CustomerUnresolvedBroker)
            {
                Customer = u
            })));

            _loadCount.LogResults(l => Log(new CallbackParameters(l)));
        }