Exemple #1
0
        public static void UpdateCompanyInfo(Company ci)
        {
            if(!string.IsNullOrEmpty(ci.AddressLine1))
                ci.AddressLine1.Replace('\n', ' ');

            if (!string.IsNullOrEmpty(ci.CareOf))
                ci.CareOf.Replace('\n', ' ');
            if (!string.IsNullOrEmpty(ci.Town))
                ci.Town.Replace('\n', ' ');
            if (!string.IsNullOrEmpty(ci.State))
                ci.State.Replace('\n', ' ');
            if (!string.IsNullOrEmpty(ci.Zip))
                ci.Zip.Replace('\n', ' ');

            using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                conn.Open();
                try
                {
                    IEnumerable<Company> resultList = conn.Query<Company>(@"
                        UPDATE [Phenix].[dbo].[RegisteredCompanies]
                                    SET CareOf = @CareOf
                                        ,AddressLine1 = @AddressLine1
                                        ,Town = @Town
                                        ,State = @State
                                        ,Zip = @Zip
                        WHERE RegisteredCompanyId = @RegisteredCompanyId
                    ", ci);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    //Console.ReadLine();
                }

            }

        }
Exemple #2
0
        static void EnrichCompanyAddress(string inputLine, ref Company updateCompany)
        {
            string[] lines = inputLine.Split('\n');
            int i = 0;
            string corpType = string.Empty;
            List<string> addressFragmentList = new List<string>();
            foreach (var l in lines)
            {
                
                if (string.IsNullOrEmpty(l))
                    continue;

                if(l.Trim().ToUpper().Equals("LLC") || l.Trim().ToUpper().Equals("INC"))
                {
                    corpType = l;
                }

                addressFragmentList.Add(l);
            }

            if(string.IsNullOrEmpty(updateCompany.CareOf))
                updateCompany.CareOf = addressFragmentList.ElementAtOrDefault(0);

            updateCompany.AddressLine1 = addressFragmentList.ElementAtOrDefault(1);
            updateCompany.Town = addressFragmentList.ElementAtOrDefault(2);
            if (!string.IsNullOrEmpty(corpType))
            {
                updateCompany.CareOf = string.Format("{0} {1}", updateCompany.CareOf, corpType);
            }

        }
Exemple #3
0
        public static void EnrichCompany(string innterText, ref Company c)
        {
            try
            {
                string[] temp = innterText.Split('\n');
                if (innterText.Contains("Current Entity Name"))
                {
                    foreach (var w in temp)
                    {
                        w.Trim();

                        if (string.IsNullOrEmpty(w))
                            continue;
                        if (w.Contains("Current Entity Name"))
                            continue;

                        c.CompanyName = w.Replace("amp;", "");
                        break;
                    }

                }

                if (innterText.Contains("Initial DOS Filing Date"))
                {
                    DateTime t = new DateTime();
                    foreach (var w in temp)
                    {
                        w.Trim();
                        if (string.IsNullOrEmpty(w))
                            continue;
                        if (w.Contains("Initial DOS Filing Date"))
                            continue;

                        if (DateTime.TryParse(w, out t))
                            c.FilingDate = t;
                        break;
                    }

                }


                if (innterText.Contains("DOS Process"))
                {
                    innterText.Replace("DOS Process", "");
                    innterText.Replace("(Address to which DOS will mail process if accepted on behalf of the entity)", "");
                    c.CompanyName = innterText;
                }

                if (innterText.Contains("DOS ID"))
                {
                    foreach (var w in temp)
                    {
                        w.Trim();

                        if (string.IsNullOrEmpty(w))
                            continue;
                        if (w.Contains("DOS ID"))
                            continue;

                        c.DOSID = w.Replace("amp;", "");
                        break;
                    }
                }

            }
            catch (Exception ex)
            {

            }
        }
Exemple #4
0
        static void ReadCompanyInfo(string href)
        {

            string url = "https://appext20.dos.ny.gov/corp_public/" + href.Replace("amp;", "");
            try
            {
                using (var client = new WebClient())
                {
                    string result = client.DownloadString(url);
                    HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

                    // There are various options, set as needed
                    htmlDoc.OptionFixNestedTags = true;

                    // filePath is a path to a file containing the html
                    htmlDoc.LoadHtml(result);

                    // Use:  htmlDoc.LoadHtml(xmlString);  to load from a string (was htmlDoc.LoadXML(xmlString)



                    // ParseErrors is an ArrayList containing any errors from the Load statement
                    if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
                    {
                        // Handle any parse errors as required

                    }
                    else
                    {

                        if (htmlDoc.DocumentNode != null)
                        {
                            HtmlAgilityPack.HtmlNodeCollection tableNodes = htmlDoc.DocumentNode.SelectNodes("//table");
                            Company c = new Company();

                            foreach (var node in tableNodes)
                            {
                                // Do something with bodyNode
                                if (node != null)
                                {
                                    if (node.InnerText.Contains("Selected Entity Status Information"))
                                    {

                                        foreach (HtmlNode row in node.SelectNodes("tr"))
                                        {
                                            EnrichCompany(row.InnerText, ref c);
                                            //Console.WriteLine("row");
                                            //foreach (HtmlNode cell in row.SelectNodes("th|td"))
                                            //{
                                            //    Console.WriteLine("cell: " + cell.InnerText);
                                            //}
                                        }
                                    }

                                    if (node.InnerText.Contains("Selected Entity Address Information"))
                                    {
                                        foreach (HtmlNode row in node.SelectNodes("tr"))
                                        {
                                            if (row.InnerText.Contains("DOS Process"))
                                                continue;

                                            if (row.InnerText.Contains("Address to which DOS will "))
                                                continue;

                                            if (row.InnerText.Contains("Chief Executive Officer"))
                                                break;

                                            

                                            if(string.IsNullOrEmpty(c.CompanyAddress))
                                            {
                                                c.CompanyAddress = row.InnerText.Replace("amp;", "");
                                            }
                                            if(c.CompanyAddress.Contains("NONE"))
                                            {

                                            }
                                        }
                                    }

                                }
                            }
                            if (!string.IsNullOrEmpty(c.CompanyName))
                            {
                                companyList.Add(c);
                                AddCompanyInfo(c);
                            }

                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }


        }
Exemple #5
0
        public static void AddCompanyInfo(Company ci)
        {

            ci.AddedBy = Environment.UserName;
            ci.AddDate = DateTime.UtcNow;
            ci.MailSent = false;
            ci.CompanyAddress.Trim();
            ci.CompanyName.Trim();
            ci.DOSID.Trim();

            if (dictDOSID.ContainsKey(ci.DOSID))
                return;

            using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                conn.Open();
                try
                {
                    IEnumerable<Company> resultList = conn.Query<Company>(@"
                        INSERT INTO [Phenix].[dbo].[RegisteredCompanies]
                                    ([CompanyName]
                                    ,[CompanyAddress]
                                    ,[FilingDate]
                                    ,[DOSID]
                                    ,[MailSent]
                                    ,[AddDate]
                                    ,[AddedBy]
                                    )
                                VALUES
                                    (@CompanyName
                                    ,@CompanyAddress
                                    ,@FilingDate
                                    ,@DOSID
                                    ,@MailSent
                                    ,@AddDate
                                    ,@AddedBy)
                    ", new
                    {
                        ci.CompanyName
                            ,
                        ci.CompanyAddress
                            ,
                        ci.FilingDate
                            ,
                        ci.DOSID
                            ,
                        ci.MailSent
                            ,
                        ci.AddDate
                            ,
                        ci.AddedBy
                    }
                     );
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    //Console.ReadLine();
                }

            }



        }