Exemple #1
0
        public static int StepsToOrigin(this Parameter parameter, ProductBlock block)
        {
            if (parameter.IsOrigin)
            {
                return(0);
            }

            var relations = parameter.ParameterRelations.Where(x => x.RequiredParameters.AllContainsIn(block.Parameters)).ToList();

            if (!relations.Any())
            {
                throw new ArgumentException("Передан параметр, который не должен быть в блоке.");
            }

            var relation = relations.OrderBy(x => x.RequiredParameters.Count).Last();

            int result = 1;

            foreach (var requiredParameter in relation.RequiredParameters)
            {
                result += requiredParameter.StepsToOrigin(block);
            }

            return(result);
        }
Exemple #2
0
        public void PrintProducts(IEnumerable <Product> products, ProductBlock block = null)
        {
            try
            {
                var pathDocx = AppDomain.CurrentDomain.BaseDirectory + $"\\{Guid.NewGuid()}.docx";
                WordDocumentWriter docWriter = WordDocumentWriter.Create(pathDocx);
                docWriter.StartDocument();

                foreach (var product in products)
                {
                    docWriter.PrintParagraph($"{product}");
                    Print(docWriter, product, null, block);

                    var paragraphProperties = docWriter.CreateParagraphProperties();
                    paragraphProperties.PageBreakBefore = true;
                    docWriter.PrintParagraph(string.Empty, paragraphProperties);
                }


                docWriter.EndDocument();
                docWriter.Close();

                //var pathPdf = AppDomain.CurrentDomain.BaseDirectory + @"\ProductsDocument.pdf";
                //var documentCore = DocumentCore.Load(pathDocx);
                //documentCore.Save(pathPdf, SaveOptions.PdfDefault);

                System.Diagnostics.Process.Start(pathDocx);
                //System.Diagnostics.Process.Start(pathPdf);
            }
            catch (IOException ioException)
            {
                _container.Resolve <IMessageService>().ShowOkMessageDialog("Ошибка", ioException.PrintAllExceptions());
            }
        }
        public string GetDesignation(ProductBlock block)
        {
            if (block == null)
            {
                return("block is null!");
            }

            //если обозначение уже содержится в словаре
            if (_dictionaryBlockDesignations.ContainsKey(block.Id))
            {
                return(_dictionaryBlockDesignations[block.Id]);
            }

            if (!string.IsNullOrEmpty(block.DesignationSpecial))
            {
                _dictionaryBlockDesignations.Add(block.Id, block.DesignationSpecial);
                return(_dictionaryBlockDesignations[block.Id]);
            }

            if (!block.Parameters.Any())
            {
                _dictionaryBlockDesignations.Add(block.Id, "block has no parameters!");
                return(_dictionaryBlockDesignations[block.Id]);
            }

            var designation = _designationsOfBlocks.FirstOrDefault(desOfBlock => desOfBlock.Parameters.AllContainsIn(block.Parameters, new ParameterComparer()));

            var result = !Equals(designation, default(DesignationOfBlock))
                ? designation.Designation
                : block.ParametersToString();

            _dictionaryBlockDesignations.Add(block.Id, result);

            return(result);
        }
Exemple #4
0
 public static double GetWeight(this Parameter parameter, ProductBlock block)
 {
     if (parameter.IsOrigin)
     {
         return(2);
     }
     return(1.0 / parameter.StepsToOrigin(block));
 }
Exemple #5
0
        /// <summary>
        ///     Collection information about available products on worksheet
        /// </summary>
        /// <param name="worksheet">
        ///     Worksheet for analyze
        /// </param>
        public static List <ProductBlock> AnalyzeWorksheet(ExcelObject.Worksheet worksheet)
        {
            List <ProductBlock> result = new List <ProductBlock>();

            int row = 0;

            int maxRow = worksheet.Cells[worksheet.Rows.Count, 1].End(ExcelObject.XlDirection.xlUp).Row + 10;

            ProductBlock product = null;

            do
            {
                row++;

                // First match
                ProductType isMatch = IsNameInThisRow(worksheet, row);
                if (isMatch != ProductType.ptUnknown)
                {
                    // Second match
                    if (IsHeaderInThisRow(worksheet, row + 1))
                    {
                        // Set end if needed
                        if (product != null)
                        {
                            product.end = row - 1;

                            result.Add(product);

                            product = null;
                        }

                        // MaxRow пока не знаю иначе
                        product = new ProductBlock
                        {
                            productType   = isMatch,
                            worksheet     = worksheet.Index,
                            worksheetName = worksheet.Name,
                            name          = ExcelFunctions.GetString(worksheet, row, isMatch == ProductType.ptRegular ? 6 : 5),
                            start         = row,
                            end           = maxRow
                        };
                    }

                    row += 2;
                }
            }while (row < maxRow);

            // Last one. Could be Null if no product on worksheet. Shouldn't be 0 product on worksheet, but who knows
            if (product != null)
            {
                result.Add(product);
            }

            return(result);
        }
Exemple #6
0
        public double GetPrice(DateTime?date = null)
        {
            var    targetDate = date ?? DateTime.Today;
            double sum        = ProductBlock.GetPrice(targetDate);

            foreach (var dependentProduct in DependentProducts)
            {
                sum += dependentProduct.Product.GetPrice(targetDate) * dependentProduct.Amount;
            }
            return(sum);
        }
        /// <summary>
        /// Поиск аналога для блока.
        /// </summary>
        /// <param name="blockTarget">Целевой блок.</param>
        /// <returns></returns>
        public ProductBlock GetAnalogWithPrice(ProductBlock blockTarget)
        {
            if (AnalogsWithPrice.ContainsKey(blockTarget.Id))
            {
                return(AnalogsWithPrice[blockTarget.Id]);
            }

            var targetBlock      = Blocks.SingleOrDefault(block => block.Id == blockTarget.Id) ?? blockTarget;
            var blocksWithPrices = Blocks
                                   .Where(productBlock => productBlock.Id != targetBlock.Id)
                                   .Where(productBlock => productBlock.HasPrice).ToList();

            var dic = new Dictionary <ProductBlock, double>();

            foreach (var blockWithPrice in blocksWithPrices)
            {
                double dif = 0;

                //общие параметры
                var intParams = blockWithPrice.Parameters.Intersect(targetBlock.Parameters, new ParameterComparer()).ToList();
                foreach (var parameter in intParams)
                {
                    //Single было бы правильнее, но надо искать ошибку в формировании путей
                    var path = parameter.Paths().First(pathToOrigin => pathToOrigin.Parameters.AllContainsIn(blockWithPrice.Parameters, new ParameterComparer()));
                    dif += 1.0 / path.Parameters.Count;
                }

                //различающиеся параметры
                var difParams1 = blockWithPrice.Parameters.Except(targetBlock.Parameters, new ParameterComparer()).ToList();
                foreach (var parameter in difParams1)
                {
                    //Single было бы правильнее, но надо искать ошибку в формировании путей
                    var path = parameter.Paths().First(pathToOrigin => pathToOrigin.Parameters.AllContainsIn(blockWithPrice.Parameters, new ParameterComparer()));
                    dif -= 1.0 / path.Parameters.Count;
                }

                var difParams2 = targetBlock.Parameters.Except(blockWithPrice.Parameters, new ParameterComparer()).ToList();
                foreach (var parameter in difParams2)
                {
                    //Single было бы правильнее, но надо искать ошибку в формировании путей
                    var path = parameter.Paths().First(pathToOrigin => pathToOrigin.Parameters.AllContainsIn(targetBlock.Parameters, new ParameterComparer()));
                    dif -= 1.0 / path.Parameters.Count;
                }

                dic.Add(blockWithPrice, dif);
            }

            var blockAnalog = dic.OrderByDescending(x => x.Value).First().Key;

            AnalogsWithPrice.Add(blockTarget.Id, blockAnalog);
            return(blockAnalog);
        }
        /// <summary>
        /// Получение нормо-часов на изготовление блока оборудования
        /// </summary>
        /// <param name="block"></param>
        /// <returns></returns>
        public double?GetLaborHoursAmount(ProductBlock block)
        {
            var laborHours = LaborHoursList
                             .Where(hours => hours.Parameters.AllContainsIn(block.Parameters))
                             .ToList();

            if (laborHours.Any())
            {
                return(laborHours.OrderBy(hours => hours.Parameters.Count).Last().Amount);
            }

            return(null);
        }
Exemple #9
0
        public void AddError(ProductBlock block, PriceErrorType errorType, ProductBlock analog = null)
        {
            if (_errors.Select(x => x.Key.Id).Contains(block.Id))
            {
                return;
            }
            _errors.Add(block, errorType);

            if (_analogs.Select(x => x.Key.Id).Contains(block.Id))
            {
                return;
            }
            _analogs.Add(block, analog);
        }
Exemple #10
0
        public IEnumerable <ProductBlockWrapper> GetBlocksWithoutActualPriceOnDate(DateTime date)
        {
            if (!ProductBlock.HasActualPriceOnDate(date))
            {
                yield return(ProductBlock);
            }

            foreach (var dependentProduct in DepPrpds)
            {
                foreach (var productBlockWrapper in dependentProduct.GetBlocksWithoutActualPriceOnDate(date))
                {
                    yield return(productBlockWrapper);
                }
            }
        }
        public ProductType GetProductType(ProductBlock block)
        {
            if (_dictionaryBlockTypes.ContainsKey(block.Id))
            {
                return(_dictionaryBlockTypes[block.Id]);
            }

            var designations = _designationsOfProductTypes.Where(pd => pd.Parameters.AllContainsIn(block.Parameters, new ParameterComparer())).ToList();

            var result = designations.Any()
                ? designations.OrderBy(x => x.Parameters.Count).Last().ProductType
                : _emptyProductType;

            _dictionaryBlockTypes.Add(block.Id, result);

            return(result);
        }
Exemple #12
0
        /// <summary>
        /// инициализаци¤ по прайсу/фиксированной цене
        /// </summary>
        /// <param name="productBlock"></param>
        /// <param name="targetDate"></param>
        private void Init(ProductBlock productBlock, DateTime targetDate)
        {
            Name = productBlock.ToString();

            //по фиксированной цене
            if (productBlock.HasFixedPrice)
            {
                SumFixed = productBlock.FixedCosts.GetClosedSumOnDate(targetDate).Sum;
                return;
            }

            //по прайсу
            if (productBlock.HasPrice)
            {
                UnitPrice = productBlock.Prices.GetClosedSumOnDate(targetDate).Sum;
            }
        }
Exemple #13
0
        /// <summary>
        /// ¬озвращает продукт, либо создает новый.
        /// </summary>
        /// <param name="block"></param>
        /// <param name="productsDependent"></param>
        /// <returns></returns>
        public Product GetProduct(ProductBlock block, IEnumerable <ProductDependent> productsDependent)
        {
            var product = new Product
            {
                ProductBlock      = block,
                DependentProducts = productsDependent.ToList()
            };
            //если такой продукт существует - возвращаем его
            var existsProduct = Products.SingleOrDefault(x => x.Equals(product));

            if (existsProduct != null)
            {
                return(existsProduct);
            }

            Products.Add(product);
            return(product);
        }
        public double?GetWageFund(ProductBlock productBlock, DateTime targetDate)
        {
            //получение количества нормо-часов на блок
            double?laborHoursAmount = GetLaborHoursAmount(productBlock);

            if (laborHoursAmount == null)
            {
                return(null);
            }

            //стоимость нормо-часа
            double laborHoursCost = LaborHourCosts.GetClosedSumOnDate(targetDate).Sum;

            //фонд оплаты труда
            double wageFund = laborHoursAmount.Value * laborHoursCost;

            return(wageFund);
        }
Exemple #15
0
        public PriceOfProductBlock(ProductBlock productBlock, DateTime targetDate, IPriceService priceService, double amount)
        {
            _productBlock = productBlock;
            _targetDate   = targetDate;
            _priceService = priceService;

            Amount = amount;

            if (productBlock.HasPrice || productBlock.HasFixedPrice)
            {
                //инициализаци¤ по прайсу/фиксированной цене
                Init(productBlock, targetDate);
            }
            else
            {
                //инициализаци¤ по аналогу
                Init(priceService.GetAnalogWithPrice(productBlock), targetDate, productBlock);
            }
        }
Exemple #16
0
        public ProductBlock GetBlock(IEnumerable <Parameter> parameters)
        {
            //создание нового блока
            var block = new ProductBlock {
                Parameters = parameters.ToList()
            };

            //поиск в существующих блоках
            var exist = Blocks.SingleOrDefault(x => x.Equals(block));

            if (exist != null)
            {
                return(exist);
            }

            //добавление блока в банк
            Blocks.Add(block);
            return(block);
        }
        public ProductBlockSelector(IEnumerable <Parameter> parameters, Bank bank, ProductBlock selectedProductBlock = null)
        {
            _bank = bank;

            //создаем селекторы параметров
            var groupedParameters = GetGroupingParameters(parameters).Select(x => new ParameterSelector(x));

            ParameterSelectors = new ObservableCollection <ParameterSelector>(groupedParameters);

            //подписка на смену параметра в селекторе
            ParameterSelectors.ToList().ForEach(ps => ps.SelectedParameterFlagedChanged += OnSelectedParameterChanged);

            //если есть выбранный блок
            if (selectedProductBlock != null)
            {
                if (!selectedProductBlock.Parameters.AllContainsIn(parameters))
                {
                    throw new ArgumentException("Параметры блока не соответствуют возможным параметрам.");
                }
                SelectedBlock = selectedProductBlock;
            }
        }
        private IEnumerable<ProductsItem> GetProductsBlocks(IReadOnlyList<Product> products)
        {
            var productsBlocks = new List<ProductsItem>();

            for (var i = 0; i <= (products.Count() - 1) / DisplayCount; i++)
            {
                var productBlocks = new List<ProductBlock>();
                for (var j = i*DisplayCount; j < (i + 1)*DisplayCount; j++)
                {
                    if (j < products.Count)
                    {
                        var productBlock = new ProductBlock
                        {
                            Id = products[j].Id.ToString(),
                            Name = products[j].Name,
                            Image240x192Path = products[j].Image240x192Path,
                            Image800x640Path = products[j].Image800x640Paths.First(im => im.IsActive).Path,
                            RatingImagePath = products[j].RatingImagePath,
                            OldPrice = products[j].OldPrice.HasValue?products[j].OldPrice.Value.ToString("C"):string.Empty,
                            NewPrice = products[j].NewPrice.ToString("C"),
                            ExTax = (products[j].NewPrice - products[j].NewPrice*.15m).ToString("C"),
                            Description =
                                products[j].Description.Length > 140
                                    ? string.Format("{0}...", products[j].Description.Substring(0, 140))
                                    : products[j].Description
                        };
                        productBlocks.Add(productBlock);
                    }
                }
                var productsItem = new ProductsItem
                {
                    ProductBlocks = productBlocks
                };
                productsBlocks.Add(productsItem);
            }
            return productsBlocks;
        }
Exemple #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int    startIndex, count;
            string selectedValue = "-1";

            lnkPrevious.Visible    = false;
            lnkNext.Visible        = false;
            lblNoProducts.Visible  = false;
            lblAmountError.Visible = false;

            /* Get the Service */
            IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IProductService productService = iocManager.Resolve <IProductService>();

            /* Get Start Index */
            try
            {
                startIndex = int.Parse(Request.Params.Get("startIndex"));
            }
            catch (ArgumentNullException)
            {
                startIndex = 0;
            }

            /* Get Count */
            try
            {
                count = int.Parse(Request.Params.Get("count"));
            }
            catch (ArgumentNullException)
            {
                count = Settings.Default.PracticaMaD_defaultCount;
            }

            /* Get keyword */
            string keyword = Request.Params.Get("keyword");

            if (keyword != null)
            {
                txtSearch.Text = keyword;

                /* Get category id */
                try
                {
                    long catId = long.Parse(Request.Params.Get("category"));

                    selectedValue = Request.Params.Get("category");

                    /* Get Products Info */
                    ProductBlock productBlock = productService.FindAllProductsByKeyword(keyword, catId, startIndex, count);

                    if (productBlock.Products.Count == 0)
                    {
                        lblNoProducts.Visible = true;
                    }
                    else
                    {
                        gvProducts.DataSource = productBlock.Products;
                        gvProducts.DataBind();

                        /* "Previous" link */
                        if ((startIndex - count) >= 0)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?keyword=" + keyword + "&category=" + catId +
                                "&startIndex=" + (startIndex - count) + "&count=" + count;

                            lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkPrevious.Visible     = true;
                        }

                        /* "Next" link */
                        if (productBlock.ExistMoreProducts)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?keyword=" + keyword + "&category=" + catId +
                                "&startIndex=" + (startIndex + count) + "&count=" + count;

                            lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkNext.Visible     = true;
                        }
                    }
                }
                catch (ArgumentNullException)
                {
                    /* Get Products Info */
                    ProductBlock productBlock = productService.FindAllProductsByKeyword(keyword, startIndex, count);

                    if (productBlock.Products.Count == 0)
                    {
                        lblNoProducts.Visible = true;
                    }
                    else
                    {
                        gvProducts.DataSource = productBlock.Products;
                        gvProducts.DataBind();

                        /* "Previous" link */
                        if ((startIndex - count) >= 0)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?keyword=" + keyword +
                                "&startIndex=" + (startIndex - count) + "&count=" + count;

                            lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkPrevious.Visible     = true;
                        }

                        /* "Next" link */
                        if (productBlock.ExistMoreProducts)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?keyword=" + keyword +
                                "&startIndex=" + (startIndex + count) + "&count=" + count;

                            lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkNext.Visible     = true;
                        }
                    }
                }
            }
            /* If there is no keyword, search all products */
            else
            {
                try
                {
                    long tagId = long.Parse(Request.Params.Get("tagId"));

                    /* Get Products Info */
                    ProductBlock productBlock = productService.FindAllProductsByTag(tagId, startIndex, count);

                    if (productBlock.Products.Count == 0)
                    {
                        lblNoProducts.Visible = true;
                    }
                    else
                    {
                        gvProducts.DataSource = productBlock.Products;
                        gvProducts.DataBind();

                        /* "Previous" link */
                        if ((startIndex - count) >= 0)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?tagId=" + tagId + "startIndex=" + (startIndex - count) +
                                "&count=" + count;

                            lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkPrevious.Visible     = true;
                        }

                        /* "Next" link */
                        if (productBlock.ExistMoreProducts)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?tagId=" + tagId + "startIndex=" + (startIndex + count) +
                                "&count=" + count;

                            lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkNext.Visible     = true;
                        }
                    }
                }
                catch (ArgumentNullException)
                {
                    /* Get Products Info */
                    ProductBlock productBlock = productService.FindAllProducts(startIndex, count);

                    if (productBlock.Products.Count == 0)
                    {
                        lblNoProducts.Visible = true;
                    }
                    else
                    {
                        gvProducts.DataSource = productBlock.Products;
                        gvProducts.DataBind();

                        /* "Previous" link */
                        if ((startIndex - count) >= 0)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?startIndex=" + (startIndex - count) +
                                "&count=" + count;

                            lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkPrevious.Visible     = true;
                        }

                        /* "Next" link */
                        if (productBlock.ExistMoreProducts)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?startIndex=" + (startIndex + count) +
                                "&count=" + count;

                            lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkNext.Visible     = true;
                        }
                    }
                }
            }

            if (!IsPostBack)
            {
                List <Category> categories = productService.FindAllCategories();

                // Create a table to store data for the DropDownList control.
                DataTable dt = new DataTable();

                // Define the columns of the table.
                dt.Columns.Add(new DataColumn("CategoryNameField", typeof(string)));
                dt.Columns.Add(new DataColumn("CategoryIdField", typeof(long)));

                // Populate the table.
                dt.Rows.Add(CreateRow("-", -1, dt));

                foreach (Category category in categories)
                {
                    dt.Rows.Add(CreateRow(category.categoryName, category.categoryId, dt));
                }

                // Create a DataView from the DataTable to act as the data source
                // for the DropDownList control.
                DataView dv = new DataView(dt);

                CategoryDropDownList.DataSource     = dv;
                CategoryDropDownList.DataTextField  = "CategoryNameField";
                CategoryDropDownList.DataValueField = "CategoryIdField";

                // Bind the data to the control.
                CategoryDropDownList.DataBind();

                // Set the default selected item.
                CategoryDropDownList.SelectedValue = selectedValue;
            }
        }
Exemple #20
0
        public static string GatherProductInformation(ProductBlock product, ExcelFile excelFile)
        {
            string result = "";

            // now cycle. find all and include all one by one
            int row = product.start;

            ExcelObject.Worksheet worksheet = excelFile.sheet.Worksheets[product.worksheet];
            do
            {
                if (IsHeaderInThisRow(worksheet, row))
                {
                    // Start!
                    do
                    {
                        row++;

                        string id = ExcelFunctions.GetString(worksheet, row, 1);

                        // Is number in first col? Yes, mean new option
                        if (!String.IsNullOrEmpty(id))
                        {
                            int counter = 0;

                            result += "\n\t<product>";

                            result += "\n\t\t<category>" + product.worksheetName + "</category>";
                            result += "\n\t\t<subcategory>" + product.name + "</subcategory>";
                            result += "\n\t\t<name>" + ExcelFunctions.GetString(worksheet, row, 2) + "</name>";
                            string description = ExcelFunctions.GetString(worksheet, row + 1, 2);
                            if (!String.IsNullOrEmpty(description))
                            {
                                result += "\n\t\t<description>" + description.Trim() + "</description>";
                            }

                            // now while match pattern collect data
                            result += "\n\t\t<suboptions>";

                            do
                            {
                                counter++;

                                string o1 = ExcelFunctions.GetString(worksheet, row, 1);
                                string o2 = ExcelFunctions.GetString(worksheet, row, 3);
                                string o3 = ExcelFunctions.GetString(worksheet, row, 4);
                                // price for ptBed. weight for ptRegular
                                string o4 = ExcelFunctions.GetString(worksheet, row, 5);
                                // price for ptRegular
                                string o5 = ExcelFunctions.GetString(worksheet, row, 6);

                                if ((!String.IsNullOrEmpty(o1) && counter > 1) || String.IsNullOrEmpty(o2) || String.IsNullOrEmpty(o3) || String.IsNullOrEmpty(o4) || (String.IsNullOrEmpty(o5) && product.productType == ProductType.ptRegular))
                                {
                                    break;
                                }

                                result += String.Format(
                                    "\n\t\t\t<suboption id=\"{0}\">" +
                                    "\n\t\t\t\t<garums_mm>{1}</garums_mm>" +
                                    "\n\t\t\t\t<platums_mm>{2}</platums_mm>",
                                    counter, o2, o3
                                    );

                                if (product.productType == ProductType.ptRegular)
                                {
                                    // add data
                                    result += String.Format(
                                        "\n\t\t\t\t<augstums_mm>{0}</augstums_mm>" +
                                        "\n\t\t\t\t<price_eur_no_vat>{1}</price_eur_no_vat>",
                                        o4, o5
                                        );
                                }
                                else
                                if (product.productType == ProductType.ptBed)
                                {
                                    // add data
                                    result += String.Format(
                                        "\n\t\t\t\t<price_eur_no_vat>{0}</price_eur_no_vat>",
                                        o4
                                        );
                                }
                                else
                                {
                                    throw new NotImplementedException();
                                }

                                result += "\n\t\t\t</suboption>";

                                row++;
                            }while (true);

                            result += "\n\t\t</suboptions>";
                            result += "\n\t</product>";

                            // Step back, because row will be increased on next step
                            if ((!String.IsNullOrEmpty(ExcelFunctions.GetString(worksheet, row, 1)) && counter > 1))
                            {
                                row--;
                            }
                        }
                    }while (row < product.end);
                }

                row++;
            }while (row < product.end);

            return(result);
        }
Exemple #21
0
 /// <summary>
 /// инициализаци¤ по аналогу
 /// </summary>
 /// <param name="productBlock"></param>
 /// <param name="targetDate"></param>
 /// <param name="originalBlock"></param>
 private void Init(ProductBlock productBlock, DateTime targetDate, ProductBlock originalBlock)
 {
     Init(productBlock, targetDate);
     Name   = $"{originalBlock} (по аналогу: {productBlock})";
     Analog = productBlock;
 }
Exemple #22
0
        public void Print(WordDocumentWriter docWriter, Product product, int?amount = null, ProductBlock block = null)
        {
            var tableProperties = docWriter.CreateTableProperties();

            tableProperties.Alignment = ParagraphAlignment.Left;
            tableProperties.PreferredWidthAsPercentage = 100;
            //выделяем необходимый блок
            if (block != null && product.ProductBlock.Id == block.Id)
            {
                tableProperties.BorderProperties.Color = Colors.Red;
                tableProperties.BorderProperties.Width = 3;
            }
            docWriter.StartTable(2, tableProperties);

            //Заголовок
            docWriter.StartTableRow();
            Font fontBold = docWriter.CreateFont();

            fontBold.Bold = true;
            var header = amount == null ? $"{product}" : $"{product} x {amount} шт.";

            docWriter.PrintTableCell(header, docWriter.CellProps(2, null, Colors.AliceBlue), null, fontBold);
            docWriter.EndTableRow();

            //строки параметров
            foreach (var parameter in product.ProductBlock.GetOrderedParameters())
            {
                docWriter.StartTableRow();
                docWriter.PrintTableCell($"{parameter.ParameterGroup}");
                docWriter.PrintTableCell($"{parameter}");
                docWriter.EndTableRow();
            }

            //печать зависимого оборудования
            foreach (var dependent in product.DependentProducts)
            {
                docWriter.StartTableRow();
                docWriter.StartTableCell(docWriter.CellProps(2, Padding.PadAll(0.25f)));
                Print(docWriter, dependent.Product, dependent.Amount, block);
                docWriter.EndTableCell();
                docWriter.EndTableRow();
            }

            docWriter.EndTable();
        }
Exemple #23
0
        public void Init()
        {
            _breaker = new Parameter {
                ParameterGroup = _eqType, Value = "выключатель"
            };
            _transformator = new Parameter {
                ParameterGroup = _eqType, Value = "трансформатор"
            };
            _drive = new Parameter {
                ParameterGroup = _eqType, Value = "привод выключателя"
            };
            _drivesReducer = new Parameter {
                ParameterGroup = _eqType, Value = "редкутор"
            };

            _v110 = new Parameter {
                ParameterGroup = _voltage, Value = "110кВ"
            }.AddRequiredPreviousParameters(new[] { _breaker });
            _v220 = new Parameter {
                ParameterGroup = _voltage, Value = "220кВ"
            }.AddRequiredPreviousParameters(new[] { _breaker });
            _v500 = new Parameter {
                ParameterGroup = _voltage, Value = "500кВ"
            }.AddRequiredPreviousParameters(new[] { _breaker });

            _c2500 = new Parameter {
                ParameterGroup = _current, Value = "2500А"
            }.
            AddRequiredPreviousParameters(new[] { _breaker, _v110 }).
            AddRequiredPreviousParameters(new[] { _breaker, _v220 });
            _c3150 = new Parameter {
                ParameterGroup = _current, Value = "3150А"
            }.
            AddRequiredPreviousParameters(new[] { _breaker, _v110 }).
            AddRequiredPreviousParameters(new[] { _breaker, _v220 }).
            AddRequiredPreviousParameters(new[] { _breaker, _v500 });
            _c0001 = new Parameter {
                ParameterGroup = _current, Value = "1А"
            }.AddRequiredPreviousParameters(new[] { _transformator });
            _c0005 = new Parameter {
                ParameterGroup = _current, Value = "5А"
            }.AddRequiredPreviousParameters(new[] { _transformator });

            _transCurrent = new Parameter {
                ParameterGroup = _transformatorType, Value = "TT"
            }.AddRequiredPreviousParameters(new[] { _transformator });
            _transVoltage = new Parameter {
                ParameterGroup = _transformatorType, Value = "ТН"
            }.AddRequiredPreviousParameters(new[] { _transformator });

            _groups = new List <ParameterGroup> {
                _eqType, _voltage, _current, _transformatorType
            };
            _parameters = new List <Parameter> {
                _breaker, _transformator, _drive, _drivesReducer, _v110, _v220, _v500, _c2500, _c3150, _c0001, _c0005, _transCurrent, _transVoltage
            };



            _preSelectedProductBlock = new ProductBlock {
                Parameters = new List <Parameter> {
                    _breaker, _v500, _c3150
                }
            };

            //_productBlockSelector = new ProductBlockSelector(_parameters);
        }