Esempio n. 1
0
        public List <string> GetNextUserDepartmentLeadDisQualifield()
        {
            List <string>            result                   = new List <string>();
            DepartmentServices       departmentServices       = new DepartmentServices();
            DisQualifiedLeadServices disQualifiedLeadServices = new DisQualifiedLeadServices();
            AttendantServices        attendantServices        = new AttendantServices();

            List <Department> lstDepartments             = departmentServices.GetDepartments();
            DisqualifiedLead  lastDisQualifiedLeadInsert = disQualifiedLeadServices.GetLastDisQualifiedLeadInserted();

            Department nextDepartment = null;

            if (lastDisQualifiedLeadInsert != null)
            {
                nextDepartment = lstDepartments.SkipWhile(x => x.DepartmentId != lastDisQualifiedLeadInsert.DepartmentID).Skip(1).FirstOrDefault();
            }

            if (nextDepartment == null)
            {
                nextDepartment = lstDepartments[0];
            }

            List <Attendant> lstAttendants = attendantServices.GetAttendantsByCompanyId(nextDepartment.DepartmentId);

            DisqualifiedLead lastDisQualifiedLeadInsertAttendant = disQualifiedLeadServices.GetLastDisQualifiedLeadInsertedAttendant(nextDepartment.DepartmentId);

            if (lastDisQualifiedLeadInsertAttendant == null)
            {
                result.Add(nextDepartment.DepartmentId.ToString());
                result.Add(lstAttendants[0].AttendantId.ToString());
                if (nextDepartment.WebHook != null)
                {
                    result.Add(nextDepartment.WebHook.WebhookPath);
                }
            }
            else
            {
                var nextAttendant = lstAttendants.SkipWhile(x => x.AttendantId != lastDisQualifiedLeadInsertAttendant.AttendantID).Skip(1).FirstOrDefault();

                if (nextAttendant == null)
                {
                    nextAttendant = lstAttendants[0];
                }

                result.Add(nextDepartment.DepartmentId.ToString());
                result.Add(nextAttendant.AttendantId.ToString());
                if (nextDepartment.WebHook != null)
                {
                    result.Add(nextDepartment.WebHook.WebhookPath);
                }
            }

            return(result);
        }
        public int ReprocessQualifiedLeadsContingency()
        {
            DepartmentServices _serviceDepartment = new DepartmentServices();
            Bitrix24Services   objService         = new Bitrix24Services();

            try
            {
                foreach (QualifiedLead lead in GetAll())
                {
                    Department itemDepartment = _serviceDepartment.GetDepartmentsById(lead.DepartmentID);
                    string     webHookPath    = itemDepartment.WebHook.WebhookPath;

                    objService.CreateQualifiedLead(lead, webHookPath, "*****@*****.**", "", true);
                }
                return(1);
            }
            catch
            {
                return(0);
            }
        }
Esempio n. 3
0
        public int SincronizeAttendantWithBitrix()
        {
            Bitrix24Services   _serviceBitrix     = new Bitrix24Services();
            WebhookServices    _serviceWebhook    = new WebhookServices();
            DepartmentServices _serviceDepartment = new DepartmentServices();

            try
            {
                IList <Webhook> lstWebhook = _serviceWebhook.GetWebhooks();
                DeleteAllAttendants();

                foreach (Webhook webhook in lstWebhook)
                {
                    IList <Department> lstDepartment = _serviceBitrix.GetDepartments(webhook.WebhookPath);

                    foreach (Department departItem in lstDepartment)
                    {
                        IList <Attendant> lstAttendant = _serviceBitrix.GetEmployeeDepartments(webhook.WebhookPath,
                                                                                               departItem.DepartmentId);

                        foreach (Attendant attendants in lstAttendant)
                        {
                            if (GetAttendantsByID(attendants.AttendantId).Count == 0)
                            {
                                _attendantRepository.Add(attendants);
                            }
                        }
                    }
                }
                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }