Exemple #1
0
        /*
         * Собственно, запуск процессора.
         */
        public void Process()
        {
            if (fileSource != null)
            {
                fileSource.Open();

                IDataRecord dataRecord;

                while ((dataRecord = fileSource.GetNextRecord()) != null)
                {
                    try
                    {
                        ToffLead lead = DataTransformer.MakeToffLead(dataRecord);

                        if (lead != null)
                        {
                            logLines.Add(string.Format(PATTERN_MESSAGE, lead.innOrOgrn, ToffAPI.createApplication(lead)));
                        }
                    }
                    catch (Exception e)
                    {
                        logLines.Add(e.ToString());
                    }
                }

                fileSource.Close();
            }
        }
Exemple #2
0
        /*
         * Создание заявки на обслуживание.
         */
        public static string createApplication(ToffLead lead)
        {
            string result = "";

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(pApiUrl);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(DEFAULT_MEDIA_TYPE));
                makeHttpHeaders(client, pAgentId, pApiKey, pApiSecret);

                var response    = client.PostAsJsonAsync(CREATE_APP_FUNC, lead).Result;
                var reponseMess = response.Content.ReadAsStringAsync();

                result = reponseMess.Result.ToString();
            }

            return(result);
        }
Exemple #3
0
        private static ToffLead GetLead(string inn, string lastName, string firstName, string patronymic, string phone, string companyName)
        {
            ToffLead lead = new ToffLead();

            lead.product     = Settings.Default.LeadProduct;
            lead.source      = Settings.Default.LeadSource;
            lead.subsource   = Settings.Default.LeadSubsource;
            lead.firstName   = firstName;
            lead.middleName  = patronymic;
            lead.lastName    = lastName;
            lead.phoneNumber = phone;
            lead.email       = null;
            lead.isHot       = Settings.Default.LeadIsHot;
            lead.companyName = companyName;
            lead.innOrOgrn   = inn;
            lead.comment     = null;
            lead.temperature = Settings.Default.LeadTemperature;

            return(lead);
        }