/// <summary>
 /// Метод выполняющий запросы в CRM, по маппингу полученного ключа с файлом SettingsIntegration
 /// Параметр для маппинга ключей в конфигурационном файле: CollectionService
 /// </summary>
 internal void ExecuteCrmThread()
 {
     if (!string.IsNullOrEmpty(BasicDeliverEvent))
     {
         if (_exchange == "exchange1c")
         {
             DataIntegration1C <object> executeData1C           = JsonConvert.DeserializeObject <DataIntegration1C <object> >(BasicDeliverEvent);
             RequestApplicationClass    requestApplicationClass = new RequestApplicationClass(executeData1C);
             StartIntegrationCrm(requestApplicationClass);
         }
         if (_exchange == "exchangebilling")
         {
             ExecuteDataBilling      executeDataBilling      = JsonConvert.DeserializeObject <ExecuteDataBilling>(BasicDeliverEvent);
             RequestApplicationClass requestApplicationClass = new RequestApplicationClass(executeDataBilling);
             StartIntegrationCrm(requestApplicationClass);
         }
     }
 }
 private void StartIntegrationCrm(RequestApplicationClass requestApplicationClass)
 {
     requestApplicationClass.Request(GeneralSettingRequest.POST);
     //_channel.BasicAck(deliveryTag, false);
 }
        /// <summary>
        /// Маппинг коллекции методов для корректного составления json
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="applicationClassRequest"></param>
        /// <returns></returns>
        private static object MappingCollectionMethod1C <T>(HttpWebRequest httpWebRequest, T applicationClassRequest)
        {
            DataIntegration1C <object> data1C       = applicationClassRequest as DataIntegration1C <object>;
            string stringJsonObject                 = JsonConvert.SerializeObject(data1C.Data);
            Dictionary <string, object> requestData = new Dictionary <string, object>();

            switch (data1C.EntityName)
            {
            case EntityConsts.Employee:
                httpWebRequest = new GeneralSettingRequest().SettingMethodRequest(GeneralSettingRequest.POST, RequestApplicationClass.ReturnCurrentUrlApi(new ImplementationRequestBilling().MappingCollectionMethods(), EntityConsts.Employee));

                requestData = new Dictionary <string, object>()
                {
                    { "employeeData", JsonConvert.DeserializeObject <RequestData1C <object> >(stringJsonObject) }
                };
                break;

            case EntityConsts.JobPosition:
                httpWebRequest = new GeneralSettingRequest().SettingMethodRequest(GeneralSettingRequest.POST, RequestApplicationClass.ReturnCurrentUrlApi(new ImplementationRequestBilling().MappingCollectionMethods(), EntityConsts.JobPosition));

                requestData = new Dictionary <string, object>()
                {
                    { "jobPositionData", JsonConvert.DeserializeObject <RequestData1C <object> >(stringJsonObject) }
                };
                break;

            case EntityConsts.Department:
                httpWebRequest = new GeneralSettingRequest().SettingMethodRequest(GeneralSettingRequest.POST, RequestApplicationClass.ReturnCurrentUrlApi(new ImplementationRequestBilling().MappingCollectionMethods(), EntityConsts.Department));

                requestData = new Dictionary <string, object>()
                {
                    { "departmentData", JsonConvert.DeserializeObject <RequestData1C <object> >(stringJsonObject) }
                };
                break;

            case EntityConsts.StaffTable:
                httpWebRequest = new GeneralSettingRequest().SettingMethodRequest(GeneralSettingRequest.POST, RequestApplicationClass.ReturnCurrentUrlApi(new ImplementationRequestBilling().MappingCollectionMethods(), EntityConsts.StaffTable));

                requestData = new Dictionary <string, object>()
                {
                    { "staffTableData", JsonConvert.DeserializeObject <RequestData1C <object> >(stringJsonObject) }
                };
                break;

            case EntityConsts.SendEmployeeHistory:
                httpWebRequest = new GeneralSettingRequest().SettingMethodRequest(GeneralSettingRequest.POST, RequestApplicationClass.ReturnCurrentUrlApi(new ImplementationRequestBilling().MappingCollectionMethods(), EntityConsts.SendEmployeeHistory));

                RequestData1C <SendEmployeeHistory> requestDataEmployeeHistory = JsonConvert.DeserializeObject <RequestData1C <SendEmployeeHistory> >(stringJsonObject);

                if (requestDataEmployeeHistory?.Records.Count > 0)
                {
                    requestDataEmployeeHistory?.Records.ForEach(item => item.EmploymentId = requestDataEmployeeHistory.EmploymentId);
                    requestDataEmployeeHistory?.Records.ForEach(item => RequestCollectionData(httpWebRequest,
                                                                                              new Dictionary <string, SendEmployeeHistory>()
                    {
                        { "sendEmployeeHistoryData", item }
                    }));
                    return(null);
                }
                break;

            case EntityConsts.SendCalendar:
                httpWebRequest = new GeneralSettingRequest().SettingMethodRequest(GeneralSettingRequest.POST, RequestApplicationClass.ReturnCurrentUrlApi(new ImplementationRequestBilling().MappingCollectionMethods(), EntityConsts.SendCalendar));

                requestData = new Dictionary <string, object>()
                {
                    { "sendCalendarData", JsonConvert.DeserializeObject <RequestData1C <object> >(stringJsonObject) }
                };
                break;

            case EntityConsts.SendVacation:
                httpWebRequest = new GeneralSettingRequest().SettingMethodRequest(GeneralSettingRequest.POST, RequestApplicationClass.ReturnCurrentUrlApi(new ImplementationRequestBilling().MappingCollectionMethods(), EntityConsts.SendVacation));

                RequestData1C <SendVacation> requestDataVacation = JsonConvert.DeserializeObject <RequestData1C <SendVacation> >(stringJsonObject);

                if (requestDataVacation?.Records.Count > 0)
                {
                    requestDataVacation?.Records.ForEach(item => item.EmploymentId = requestDataVacation.EmploymentId);
                    requestDataVacation?.Records.ForEach(item => RequestCollectionData(httpWebRequest,
                                                                                       new Dictionary <string, SendVacation>()
                    {
                        { "sendVacationData", item }
                    }));
                    return(null);
                }
                break;

            default:
                throw new Exception("Not supported request method");
            }

            return(requestData);
        }