Ejemplo n.º 1
0
 public void GoToAddNewProductPage()
 {
     CatalogElement.Click();
     wait.Until(ExpectedConditions.ElementToBeClickable(this.AddNewProductButtonElement));
     this.AddNewProductButtonElement.Click();
     WaitTheTabToBeActive("General");
 }
Ejemplo n.º 2
0
        public ActionResult Catalog(String Filter)
        {
            var OutputConteiner = new CatalogConteiner();

            if (String.IsNullOrEmpty(Filter))
            {
                var i           = 0;
                var Rand        = new Random();
                var AllTypes    = _DBdata.ProdType.ToList();
                var AllProducts = _DBdata.Product.Where(p => p.Avail == true).ToList();
                foreach (var MainType in AllTypes)
                {
                    var Element       = new CatalogElement();
                    var ProductByType = AllProducts.Where(p => p.ProdTypeId == MainType.Id).ToList();
                    Element.ProductTypeId   = MainType.Id;
                    Element.ProductTypeName = MainType.RusName;
                    for (var j = 0; j < 10; j++)
                    {
                        if (ProductByType.Count() > 0)
                        {
                            Element.Products.Add(ProductByType[Rand.Next(0, ProductByType.Count())]);
                        }
                    }
                    if (Element.Products.Count() > 0)
                    {
                        OutputConteiner.Content.Add(Element);
                    }
                    i++;
                }
            }
            return(View(OutputConteiner));
        }
Ejemplo n.º 3
0
 private static void AddUIDToEntities(Course1C course, int acc_id, CatalogElement ce)
 {
     ce.custom_fields.Add(new CatalogElement.Custom_fields()
     {
         id     = FieldLists.Courses[acc_id]["product_id_1C"],
         values = new CatalogElement.Custom_fields.Values[] { new CatalogElement.Custom_fields.Values()
                                                              {
                                                                  value = course.product_id_1C.Value.ToString("D")
                                                              } }
     });
 }
Ejemplo n.º 4
0
        private static void PopulateCFs(Course1C course, int acc_id, CatalogElement ce)
        {
            foreach (var p in course.GetType().GetProperties())
            {
                if (FieldLists.Courses[acc_id].ContainsKey(p.Name) &&
                    p.GetValue(course) is not null)
                {
                    if (p.Name == "price")
                    {
                        continue;
                    }

                    try { if ((string)p.GetValue(course) == "")
                          {
                              continue;
                          }
                    }
                    catch { }

                    ce.custom_fields.Add(new CatalogElement.Custom_fields()
                    {
                        id     = FieldLists.Courses[acc_id][p.Name],
                        values = new CatalogElement.Custom_fields.Values[] { new CatalogElement.Custom_fields.Values()
                                                                             {
                                                                                 value = p.GetValue(course).ToString()
                                                                             } }
                    });
                }
            }

            if (course.ItemPrices is not null &&
                course.ItemPrices.Any())
            {
                ce.custom_fields.Add(new CatalogElement.Custom_fields()
                {
                    id     = FieldLists.Courses[acc_id]["price"],
                    values = new CatalogElement.Custom_fields.Values[] { new CatalogElement.Custom_fields.Values()
                                                                         {
                                                                             value = course.ItemPrices.First().Price.ToString()
                                                                         } }
                });
            }
        }
Ejemplo n.º 5
0
        public Task Run()
        {
            if (_token.IsCancellationRequested)
            {
                _processQueue.Remove($"setCourse-{_leadNumber}");
                return(Task.FromCanceled(_token));
            }

            try
            {
                Lead lead = _repo.GetById(_leadNumber);

                if (lead._embedded is not null &&
                    lead._embedded.catalog_elements is not null &&
                    lead._embedded.catalog_elements.Any())
                {
                    CatalogElement catalogElement = _repo.GetCEById(lead._embedded.catalog_elements.First().id);

                    if (catalogElement is null ||
                        catalogElement.custom_fields is null ||
                        !catalogElement.custom_fields.Any(x => x.id == 647993))
                    {
                        throw new Exception("Incorrect catalog element, no article field.");
                    }

                    Lead result = new(){ id = _leadNumber };
                    result.AddNewCF(357005, catalogElement.custom_fields.First(x => x.id == 647993).values[0].value);

                    _repo.Save(result);

                    _processQueue.Remove($"setCourse-{_leadNumber}");
                    return(Task.CompletedTask);
                }

                _repo.AddNotes(new Note()
                {
                    entity_id = _leadNumber, note_type = "common", parameters = new Note.Params()
                    {
                        text = "Укажите, пожалуйста, товар в сделке."
                    }
                });

                var events = _repo.GetEntityEvents(_leadNumber)
                             .Where(x => x.type == "lead_status_changed")
                             .OrderByDescending(x => x.created_at)
                             .ToList();

                if (!events.Any())
                {
                    _repo.Save(new Lead()
                    {
                        id          = _leadNumber,
                        pipeline_id = 3198184,
                        status_id   = 32532880
                    });

                    _processQueue.Remove($"setCourse-{_leadNumber}");
                    return(Task.CompletedTask);
                }

                int recentPipelineId = events.First().value_before.First().lead_status.pipeline_id;
                int recentStatusId   = events.First().value_before.First().lead_status.id;

                int[] forbiddenStatuses = new int[] {
                    142,
                    143,
                    32532886,
                    32533195,
                    32533198,
                    32533201,
                    32533204,
                    33625285,
                    33817816
                };

                if (!forbiddenStatuses.Contains(recentStatusId))
                {
                    _repo.Save(new Lead()
                    {
                        id          = _leadNumber,
                        pipeline_id = recentPipelineId,
                        status_id   = recentStatusId
                    });
                }

                _processQueue.Remove($"setCourse-{_leadNumber}");
                return(Task.CompletedTask);
            }
            catch (Exception e)
            {
                _processQueue.Remove($"setCourse-{_leadNumber}");
                _log.Add($"Не получилось установить курс в сделке {_leadNumber}: {e.Message}.");
                return(Task.FromException(e));
            }
        }