Example #1
0
    private void PopulateSpecificationPanel()
    {
        string txt = "";

        if (specificationIDs.Count != 0)
        {
            foreach (string id in specificationIDs)
            {
                SpecificationItem specificationItem = DataAccessContext.SpecificationItemRepository.GetOne(
                    StoreContext.Culture, id);

                if (uxProductIDLabel.Text == "0")
                {
                    txt += "<tr class='RowDiv'> <td class='ItemListTD'><div class='CompareProductSpecification CompareLabel'>" +
                           specificationItem.DisplayName + "</div></td></tr>";
                }
                else
                {
                    txt += "<tr class='RowDiv'> <td class='ItemListTD'><div class='CompareProductSpecification'>" +
                           GetSpecificationValue(uxProductIDLabel.Text, specificationItem) + "</div></td></tr>";
                }
            }
            uxSpecificationLiteral.Text = txt;
        }
    }
Example #2
0
    private string GetSpecificationValue(string productID, SpecificationItem specificationItem)
    {
        Product currentProduct = DataAccessContext.ProductRepository.GetOne(
            StoreContext.Culture, productID, StoreContext.CurrentStore.StoreID);

        return(currentProduct.GetSpecificationItemValue(specificationItem.SpecificationItemID));
    }
Example #3
0
    private void PopulateControls()
    {
        Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, StoreContext.CurrentStore.StoreID);

        foreach (ProductSpecification item in product.ProductSpecifications)
        {
            SpecificationItem specificationItem = DataAccessContext.SpecificationItemRepository.GetOne(
                StoreContext.Culture, item.SpecificationItemID);

            Label label = new Label();
            label.ID       = "SpecificationNameLabel" + item.SpecificationItemID;
            label.Text     = "  " + specificationItem.DisplayName + " : ";
            label.CssClass = "SpecItemName";
            uxSpecificationItemTR.Controls.Add(label);

            label          = new Label();
            label.ID       = "SpecificationValueLabel" + item.SpecificationItemID;
            label.Text     = "  " + item.Value;
            label.CssClass = "SpecItemValue";
            uxSpecificationItemTR.Controls.Add(label);

            Panel panel = new Panel();
            panel.CssClass = "Clear";
            uxSpecificationItemTR.Controls.Add(panel);
        }
    }
Example #4
0
        private void PersistUseCase(UseCaseDiagram useCaseDiagram, UseCaseItem useCaseData, int identifier, IEnumerable <UseCase> oldVersionUseCases = null)
        {
            var useCaseEntity = new UseCase();

            useCaseEntity.Id            = useCaseData.Cell.Id;
            useCaseEntity.X             = useCaseData.Cell.Position.X;
            useCaseEntity.Y             = useCaseData.Cell.Position.Y;
            useCaseEntity.Identifier    = identifier;
            useCaseEntity.Version       = useCaseDiagram.Version;
            useCaseEntity.IsLastVersion = true;

            foreach (var contentData in useCaseData.Contents)
            {
                var useCaseContent = new UseCaseContent();
                useCaseContent.Id          = Guid.NewGuid();
                useCaseContent.Name        = contentData.Name;
                useCaseContent.Description = contentData.Description;
                useCaseContent.Path        = contentData.Path;
                useCaseContent.Locale      = contentData.Locale;

                useCaseEntity.Contents.Add(useCaseContent);
                _useCaseContentRepository.Add(useCaseContent);
            }

            foreach (var postCondition in useCaseData.PostConditions)
            {
                PersistPostCondition(useCaseEntity, postCondition);
            }

            foreach (var preCondition in useCaseData.PreConditions)
            {
                PersistPreCondition(useCaseEntity, preCondition);
            }

            if (oldVersionUseCases == null || !oldVersionUseCases.Any(o => o.Id == useCaseEntity.Id))
            {
                var specificationItem = new SpecificationItem();
                specificationItem.Id        = useCaseEntity.Id;
                specificationItem.Label     = $"{UseCase.PREFIX}{useCaseEntity.Identifier}";
                specificationItem.Active    = true;
                specificationItem.Type      = SpecificationItemType.UseCase;
                specificationItem.PackageId = useCaseDiagram.SpecificationItem.PackageId;
                _specificationItemRepository.Add(specificationItem);
                useCaseEntity.SpecificationItem = specificationItem;
            }
            else
            {
                var oldUseCase = oldVersionUseCases.FirstOrDefault(o => o.Id == useCaseEntity.Id);
                useCaseEntity.SpecificationItem           = oldUseCase.SpecificationItem;
                useCaseEntity.SpecificationItem.PackageId = useCaseDiagram.SpecificationItem.PackageId;
            }

            useCaseEntity.UseCaseDiagram = useCaseDiagram;
            useCaseEntity.ProjectId      = useCaseDiagram.ProjectId;

            useCaseDiagram.Entities.Add(useCaseEntity);
            _useCaseRepository.Add(useCaseEntity);

            _useCaseEntityRepository.Add(useCaseEntity);
        }
    private bool IsProductExistInGroup(SpecificationItem specItem)
    {
        IList <SpecificationItemValue> specItemValueList = DataAccessContext.SpecificationItemValueRepository.GetBySpecificationItemID(StoreContext.Culture, specItem.SpecificationItemID);
        string startPrice = MinPrice;
        string endPrice   = MaxPrice;

        foreach (SpecificationItemValue specItemValue in specItemValueList)
        {
            int itemCount = DataAccessContext.ProductRepository.GetFacetCount(
                StoreContext.Culture,
                GetCategoryList(),
                GetDepartmentListWithLeaf(),
                GetManufacturerID(),
                startPrice,
                endPrice,
                GetSpecItemValueList(GetAllSpecKey(), specItemValue),
                "",
                BoolFilter.ShowTrue,
                StoreContext.CurrentStore.StoreID);

            if (itemCount > 0)
            {
                return(true);
            }
        }

        return(false);
    }
    private IList <SpecificationItem> GetSpecItem()
    {
        string categoryID = Request.QueryString["cat"];

        IList <String> productList = DataAccessContext.ProductRepository.GetProductIDListByCategoryDepartment(
            GetCategoryList(),
            GetDepartmentListWithLeaf(),
            GetManufacturerID(),
            BoolFilter.ShowTrue,
            StoreContext.CurrentStore.StoreID);

        IList <SpecificationItem> specItemList = new List <SpecificationItem>();

        if (productList.Count > 0)
        {
            IList <string> productSpecList = DataAccessContext.ProductRepository.GetProductSpecificationsIDByProductIDs(productList);

            foreach (string productSpec in productSpecList)
            {
                SpecificationItem specItem = DataAccessContext.SpecificationItemRepository.GetOne(StoreContext.Culture, productSpec);

                if (specItem.UseInFacetedSearch && IsSpecVisible(specItem) && IsProductExistInGroup(specItem))
                {
                    specItemList.Add(specItem);
                }
            }
        }
        return(specItemList);
    }
Example #7
0
    protected void uxGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Add")
            {
                SpecificationItem item = SetupSpecificationItemDetails();
                if (IsSpecificationItemNameExist(item.Name))
                {
                    uxMessage.DisplayError(Resources.ProductSpecificationMessages.DuplicateNameError);
                    return;
                }

                DataAccessContext.SpecificationItemRepository.Save(item);
                uxMessage.DisplayMessage(Resources.ProductSpecificationMessages.ItemAddSuccess);
                RefreshGrid();
            }
            else if (e.CommandName == "Edit")
            {
                uxGrid.ShowFooter   = false;
                uxAddButton.Visible = true;
            }
        }
        catch (Exception ex)
        {
            uxMessage.DisplayException(ex);
        }
    }
Example #8
0
    protected string GetDisplayText(object groupName)
    {
        if (groupName.ToString().ToLower() == "price")
        {
            if (String.IsNullOrEmpty(MaxPrice))
            {
                return(StoreContext.Currency.FormatPrice(ConvertUtilities.ToDecimal(MinPrice)) + GetLanguageText("andabove"));
            }

            return(StoreContext.Currency.FormatPrice(ConvertUtilities.ToDecimal(MinPrice)) + " - " + StoreContext.Currency.FormatPrice(ConvertUtilities.ToDecimal(MaxPrice)));
        }
        else if (groupName.ToString() == "[$Category]")
        {
            Category category = DataAccessContext.CategoryRepository.GetOne(StoreContext.Culture, Request.QueryString["cat"]);
            return(category.Name);
        }
        else if (groupName.ToString() == "[$Department]")
        {
            Department department = DataAccessContext.DepartmentRepository.GetOne(StoreContext.Culture, Request.QueryString["dep"]);
            return(department.Name);
        }
        else if (groupName.ToString() == "[$Manufacturer]")
        {
            Manufacturer manufacturer = DataAccessContext.ManufacturerRepository.GetOne(StoreContext.Culture, Request.QueryString["manu"]);
            return(manufacturer.Name);
        }
        else
        {
            SpecificationItem      specItem  = DataAccessContext.SpecificationItemRepository.GetOneByName(StoreContext.Culture, groupName.ToString());
            SpecificationItemValue specValue = DataAccessContext.SpecificationItemValueRepository.GetOneBySpecItemIDAndValue(StoreContext.Culture, specItem.SpecificationItemID, Request.QueryString[groupName.ToString()]);
            return(specValue.DisplayValue);
        }
    }
Example #9
0
 public static ItemLinkViewModel FromModel(SpecificationItem origin, SpecificationItem target)
 {
     return(new ItemLinkViewModel
     {
         Origin = SpecificationItemViewModel.FromModel(origin),
         Target = SpecificationItemViewModel.FromModel(target)
     });
 }
Example #10
0
 public static UseCaseArtifactViewModel FromModel(UseCase useCase, SpecificationItem specificationItem)
 {
     return(new UseCaseArtifactViewModel
     {
         UseCase = UseCaseViewModel.FromModel(useCase),
         SpecificationItem = SpecificationItemViewModel.FromModel(specificationItem)
     });
 }
Example #11
0
    private void CreateDummyRow(IList <SpecificationItem> list)
    {
        SpecificationItem specificationItem = new SpecificationItem(uxLanguageControl.CurrentCulture);

        specificationItem.SpecificationItemID = "-1";
        specificationItem.Name = string.Empty;

        list.Add(specificationItem);
    }
Example #12
0
 public static SpecificationItemViewModel FromModel(SpecificationItem item)
 {
     return(new SpecificationItemViewModel
     {
         Id = item.Id,
         Package = PackageViewModel.FromModel(item.Package),
         Label = item.Label,
         Type = item.Type,
         TypeLabel = GetTypeLabel(item.Type),
     });
 }
Example #13
0
    private SpecificationItem SetupSpecificationItemDetails()
    {
        SpecificationItem item = new SpecificationItem(uxLanguageControl.CurrentCulture);

        item.Name                 = ((TextBox)uxGrid.FooterRow.FindControl("uxNameText")).Text.Trim();
        item.DisplayName          = ((TextBox)uxGrid.FooterRow.FindControl("uxDisplayNameText")).Text.Trim();
        item.Description          = ((TextBox)uxGrid.FooterRow.FindControl("uxDescriptionText")).Text.Trim();
        item.Type                 = (SpecificationItemControlType)Enum.Parse(typeof(SpecificationItemControlType), ((DropDownList)uxGrid.FooterRow.FindControl("uxTypeDrop")).SelectedValue);
        item.UseInFacetedSearch   = ((CheckBox)uxGrid.FooterRow.FindControl("uxUseInFacetedSearchCheck")).Checked;
        item.SpecificationGroupID = SpecificationGroupID;
        return(item);
    }
Example #14
0
    protected string GetGroupName(object groupName)
    {
        if (groupName.ToString().ToLower() == "price" ||
            groupName.ToString() == "[$Category]" ||
            groupName.ToString() == "[$Department]" ||
            groupName.ToString() == "[$Manufacturer]")
        {
            return(groupName.ToString() + " : ");
        }
        SpecificationItem specItem = DataAccessContext.SpecificationItemRepository.GetOneByName(StoreContext.Culture, groupName.ToString());

        return(specItem.DisplayName + " : ");
    }
Example #15
0
    protected bool IsTypeTextbox(object specificationItemID)
    {
        SpecificationItem item = DataAccessContext.SpecificationItemRepository.GetOne(uxLanguageControl.CurrentCulture, specificationItemID.ToString());

        if (item.Type.ToString().Equals("Textbox"))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public bool IsSpecVisible(SpecificationItem specItem)
    {
        string[] queryKey = Request.QueryString.AllKeys;

        foreach (string key in queryKey)
        {
            if (key.ToLower() == specItem.Name.ToLower())
            {
                return(false);
            }
        }

        return(true);
    }
Example #17
0
    private IList <SpecificationItemValue> GetSpecItemValueList(IList <string> specKeyList)
    {
        IList <SpecificationItemValue> specItemValueList = new List <SpecificationItemValue>();

        foreach (string specKey in specKeyList)
        {
            string specValue = Request.QueryString[specKey];

            SpecificationItem specItem = DataAccessContext.SpecificationItemRepository.GetOneByName(StoreContext.Culture, specKey);

            SpecificationItemValue specItemValue = DataAccessContext.SpecificationItemValueRepository.GetOneBySpecItemIDAndValue(StoreContext.Culture, specItem.SpecificationItemID, specValue);
            specItemValueList.Add(specItemValue);
        }

        return(specItemValueList);
    }
Example #18
0
        public void Handle(CreateUseCaseDiagramCommand command)
        {
            var id = Guid.NewGuid();

            var projectId = _currentProjectContextId.Get();

            if (projectId == null)
            {
                throw new Exception(Sentences.noProjectInContext);
            }

            var package = _packageRepository.Get(command.PackageId.Value);

            if (!package.Active)
            {
                throw new Exception(Sentences.thisPackageWasRemoved);
            }

            var nextId = _useCaseDiagramNextIdQueryHandler.Handle(projectId.Value);

            var specificationItem = new SpecificationItem();

            specificationItem.Id        = id;
            specificationItem.Active    = true;
            specificationItem.Type      = SpecificationItemType.UseCaseDiagram;
            specificationItem.PackageId = command.PackageId.Value;
            specificationItem.Label     = $"UCD{nextId}";

            var useCaseDiagram = new UseCaseDiagram();

            useCaseDiagram.Id = id;

            useCaseDiagram.SpecificationItem = specificationItem;
            useCaseDiagram.ProjectId         = projectId.Value;
            useCaseDiagram.Version           = 1;
            useCaseDiagram.IsLastVersion     = true;
            useCaseDiagram.Identifier        = nextId;

            _useCaseDiagramItemsPersister.Persist(useCaseDiagram, command);

            _useCaseDiagramRepository.Add(useCaseDiagram);
            _specifiationItemRepository.Add(specificationItem);
        }
Example #19
0
    protected void uxGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            string id          = ((Label)uxGrid.Rows[e.RowIndex].FindControl("uxSpecificationItemIDLabel")).Text.Trim();
            string name        = ((TextBox)uxGrid.Rows[e.RowIndex].FindControl("uxNameText")).Text.Trim();
            string displayName = ((TextBox)uxGrid.Rows[e.RowIndex].FindControl("uxDisplayNameText")).Text.Trim();
            string description = ((TextBox)uxGrid.Rows[e.RowIndex].FindControl("uxDescriptionText")).Text.Trim();
            SpecificationItemControlType controlType = (SpecificationItemControlType)Enum.Parse(typeof(SpecificationItemControlType), ((Label)uxGrid.Rows[e.RowIndex].FindControl("uxTypeText")).Text);
            bool useInFacetedSearch = ((CheckBox)uxGrid.Rows[e.RowIndex].FindControl("uxUseInFacetedSearchCheck")).Checked;

            if (!String.IsNullOrEmpty(id))
            {
                SpecificationItem item = DataAccessContext.SpecificationItemRepository.GetOne(uxLanguageControl.CurrentCulture, id);
                if (!item.Name.Equals(name) && IsSpecificationItemNameExist(name))
                {
                    uxMessage.DisplayError(Resources.ProductSpecificationMessages.DuplicateNameError);
                    return;
                }
                item.Name               = name;
                item.DisplayName        = displayName;
                item.Description        = description;
                item.Type               = controlType;
                item.UseInFacetedSearch = useInFacetedSearch;

                DataAccessContext.SpecificationItemRepository.Save(item);
                uxGrid.EditIndex = -1;
                uxMessage.DisplayMessage(Resources.ProductSpecificationMessages.ItemUpdateSuccess);

                RefreshGrid();
            }
        }
        catch (Exception ex)
        {
            uxMessage.DisplayException(ex);
        }
        finally
        {
            // Avoid calling Update() automatically by GridView
            e.Cancel = true;
        }
    }
        public EditSpecItemWindow(string projectPath, int strNum, int currentSave, int nextSave)
        {
            InitializeComponent();

            project = new ProjectDB(projectPath);

            specItem = new SpecificationItem();

            specItem = project.GetSpecItem(strNum, currentSave);

            specItem.id = (new Global()).makeID(strNum, nextSave);

            formatTextBox.Text       = specItem.format;
            zonaTextBox.Text         = specItem.zona;
            positionTextBox.Text     = specItem.position;
            oboznachenieTextBox.Text = specItem.oboznachenie;
            nameTextBox.Text         = specItem.name;
            quantityTextBox.Text     = specItem.quantity;
            noteTextBox.Text         = specItem.note;
        }
Example #21
0
        /// <summary>
        /// Получение наименования из атрибута с установкой значения "Есть сталь"
        /// </summary>
        public static void GetSpecificationItemNameFromAttr(SpecificationItem specificationItem, string attrValue)
        {
            var hasSteel = false;

            if (attrValue.Contains("$") & attrValue.Contains("?"))
            {
                var splitStr = attrValue.Split('$');
                if (splitStr.Length == 4)
                {
                    try
                    {
                        specificationItem.HasSteel        = true;
                        specificationItem.SteelVisibility = Visibility.Visible;
                        specificationItem.BeforeName      = splitStr[0];
                        specificationItem.TopName         = splitStr[1];
                        specificationItem.AfterName       = splitStr[3];
                        specificationItem.SteelDoc        = splitStr[2].Split('?')[0];
                        specificationItem.SteelType       = splitStr[2].Split('?')[1];
                        hasSteel = true;
                    }
                    catch
                    {
                        hasSteel = false;
                    }
                }
            }

            if (!hasSteel)
            {
                specificationItem.HasSteel        = false;
                specificationItem.SteelVisibility = Visibility.Collapsed;
                specificationItem.SteelType       = string.Empty;
                specificationItem.SteelDoc        = string.Empty;
                specificationItem.BeforeName      = attrValue;
                specificationItem.AfterName       = string.Empty;
                specificationItem.TopName         = string.Empty;
            }
        }
 /// <summary>
 /// Open a specification item
 /// </summary>
 /// <param name="target"></param>
 private void Open(SpecificationItem target)
 {
     NavigateTo(string.Format("{0}{1}", target.Name.Replace("Specification", ""), Path.GetExtension(target.Item.Name)));
 }
Example #23
0
        /// <summary>
        /// Получение "Продукта" из атрибутов блока
        /// </summary>
        /// <param name="tr">Transaction</param>
        /// <param name="objectId">Block id</param>
        public static SpecificationItem GetProductFromBlockByAttributes(Transaction tr, ObjectId objectId)
        {
            var blk = tr.GetObject(objectId, OpenMode.ForRead) as BlockReference;

            if (blk != null)
            {
                // Если это блок
                if (blk.AttributeCollection.Count > 0)
                {
                    var mpPosition    = string.Empty;
                    var mpDesignation = string.Empty;
                    var mpName        = string.Empty;
                    var mpMass        = string.Empty;
                    var mpNote        = string.Empty;
                    foreach (ObjectId id in blk.AttributeCollection)
                    {
                        var attr = tr.GetObject(id, OpenMode.ForRead) as AttributeReference;
                        if (attr != null)
                        {
                            if (attr.Tag.ToLower().Equals("mp:позиция") ||
                                attr.Tag.ToLower().Equals("mp:position"))
                            {
                                mpPosition = attr.TextString;
                            }
                            if (attr.Tag.ToLower().Equals("mp:обозначение") ||
                                attr.Tag.ToLower().Equals("mp:designation"))
                            {
                                mpDesignation = attr.TextString;
                            }
                            if (attr.Tag.ToLower().Equals("mp:наименование") ||
                                attr.Tag.ToLower().Equals("mp:name"))
                            {
                                mpName = attr.TextString;
                            }
                            if (attr.Tag.ToLower().Equals("mp:масса") ||
                                attr.Tag.ToLower().Equals("mp:mass"))
                            {
                                mpMass = attr.TextString;
                            }
                            if (attr.Tag.ToLower().Equals("mp:примечание") ||
                                attr.Tag.ToLower().Equals("mp:note"))
                            {
                                mpNote = attr.TextString;
                            }
                        }
                    }

                    double?mass = double.TryParse(mpMass, out var d) ? d : 0;

                    var specificationItem = new SpecificationItem(
                        null,
                        string.Empty,
                        string.Empty,
                        string.Empty,
                        string.Empty,
                        SpecificationItemInputType.HandInput,
                        string.Empty,
                        string.Empty,
                        string.Empty,
                        mass);

                    GetSpecificationItemNameFromAttr(specificationItem, mpName);
                    specificationItem.Designation = mpDesignation;
                    specificationItem.Position    = mpPosition;
                    specificationItem.Note        = mpNote;

                    return(specificationItem);
                }
            }

            return(null);
        }
Example #24
0
        public List <SpecificationItem> groupSpecificationElements(List <SpecificationItem> sList, ref int numberOfValidStrings)
        {
            #region Группировка элементов спецификации из раздела "Прочие" с одинаковым наименованием, которые идут подряд
            List <SpecificationItem> tempList = new List <SpecificationItem>();
            SpecificationItem        tempItem = new SpecificationItem();

            string prevElemName = sList[0].name;
            int    position     = 0;


            tempItem.makeEmpty();
            tempItem.spSection = sList[0].spSection;
            tempItem.position  = (position + 1).ToString();
            tempItem.name      = sList[0].name;
            tempItem.quantity  = "1";
            tempItem.note      = sList[0].designator;
            tempItem.docum     = sList[0].docum;
            tempItem.group     = sList[0].group;


            for (int i = 1; i < numberOfValidStrings; i++)
            {
                if (sList[i].name == prevElemName)
                {
                    tempItem.note    += "," + sList[i].note;
                    tempItem.quantity = (int.Parse(tempItem.quantity) + 1).ToString();
                }
                else
                {
                    tempList.Add(tempItem);
                    position++;
                    tempItem = new SpecificationItem();
                    tempItem.makeEmpty();
                    tempItem.spSection = sList[i].spSection;
                    tempItem.position  = (position + 1).ToString();
                    tempItem.name      = sList[i].name;
                    tempItem.quantity  = "1";
                    tempItem.note      = sList[i].designator;
                    tempItem.docum     = sList[i].docum;
                    tempItem.group     = sList[i].group;
                }
                if (i == (numberOfValidStrings - 1))
                {
                    tempList.Add(tempItem); position++;
                }
                prevElemName = sList[i].name;
            }

            numberOfValidStrings = position;

            for (int i = 0; i < numberOfValidStrings; i++)
            {
                string[] designators = new string[tempList[i].note.Split(new Char[] { ',' }).Length];
                designators = tempList[i].note.Split(new Char[] { ',' });
                if (designators.Length > 2)
                {
                    tempList[i].note = designators[0] + '-' + designators[designators.Length - 1];
                }
            }



            #endregion

            #region Группировка всех элементов спецификации из раздела "Прочие" с одинаковым наименованием

            for (int i = 0; i < numberOfValidStrings; i++)
            {
                for (int j = i + 1; j < numberOfValidStrings; j++)
                {
                    if ((tempList[j].name == tempList[i].name) & (tempList[j].name != String.Empty))
                    {
                        tempList[i].note    += "," + tempList[j].note;
                        tempList[i].quantity = (int.Parse(tempList[i].quantity) + int.Parse(tempList[j].quantity)).ToString();
                        tempList[j].name     = String.Empty;
                    }
                }
            }

            #endregion

            #region Удаление лишних строк и сортировка по алфавиту
            List <SpecificationItem> tempList1 = new List <SpecificationItem>();

            for (int i = 0; i < numberOfValidStrings; i++)
            {
                if (tempList[i].name != String.Empty)
                {
                    tempItem = new SpecificationItem();
                    tempItem.makeEmpty();
                    tempItem.spSection = tempList[i].spSection;
                    tempItem.name      = tempList[i].name;
                    tempItem.quantity  = tempList[i].quantity;
                    tempItem.note      = tempList[i].note;
                    tempItem.docum     = tempList[i].docum;
                    tempItem.group     = tempList[i].group;
                    tempList1.Add(tempItem);
                }
            }

            tempList = new List <SpecificationItem>();
            tempList = tempList1.OrderBy(x => x.name).ToList();

            foreach (SpecificationItem item in tempList)
            {
                item.position = "Авто";
            }

            numberOfValidStrings = tempList.Count;
            #endregion


            #region  азбиение каждой записи на нужное количество строк
            List <SpecificationItem> tempList2 = new List <SpecificationItem>();
            const int maxNameLength            = 35;
            const int maxNoteLength            = 13;
            //Удаление лишних строк
            for (int i = 0; i < numberOfValidStrings; i++)
            {
                if (tempList[i].name != String.Empty)
                {
                    //Разбиение строк, чтобы все надписи вмещались в ячейки.

                    string name     = tempList[i].name;
                    string note     = tempList[i].note;
                    string quantity = tempList[i].quantity;
                    string pos      = tempList[i].position;

                    while ((name != String.Empty) | (note != String.Empty))
                    {
                        tempItem = new SpecificationItem();
                        tempItem.makeEmpty();
                        tempItem.spSection = tempList[i].spSection;
                        if (pos != String.Empty)
                        {
                            tempItem.position = tempList[i].position;
                            pos = String.Empty;
                        }
                        if (quantity != String.Empty)
                        {
                            tempItem.quantity = quantity;
                            quantity          = String.Empty;
                        }

                        string group = tempList[i].group;
                        string docum = tempList[i].docum;

                        //Разбираемся с наименованием
                        if (name.Length > maxNameLength)
                        {
                            if ((name.Length - docum.Length - 1) < maxNameLength)
                            {
                                tempItem.name = name.Substring(0, name.Length - docum.Length - 1);
                                name          = docum;
                                docum         = String.Empty;
                            }
                            else
                            if (group != String.Empty)
                            {
                                tempItem.name = group;
                                name          = name.Replace(group + ' ', String.Empty);
                                group         = String.Empty;
                            }
                            else
                            {
                                string[] words = name.Split(new Char[] { ' ' });
                                tempItem.name = words[0] + ' ';

                                for (int j = 1; j < words.Length; j++)
                                {
                                    if ((tempItem.name.Length + words[j].Length) > maxNameLength)
                                    {
                                        tempItem.name.Substring(0, tempItem.name.Length - 1); // удаляем последний пробел
                                        name = string.Empty;
                                        for (int k = j; k < words.Length; k++)
                                        {
                                            if (k != (words.Length - 1))
                                            {
                                                name += words[k] + ' ';
                                            }
                                            else
                                            {
                                                name += words[k];
                                            }
                                        }
                                        break;
                                    }
                                    else
                                    {
                                        tempItem.name += words[j] + ' ';
                                    }
                                }
                            }
                        }
                        else if (name != String.Empty)
                        {
                            tempItem.name = name;
                            name          = String.Empty;
                        }

                        //Разбираемся с примечанием
                        if (note.Length > maxNoteLength)
                        {
                            string[] designators = note.Split(new Char[] { ',' });
                            tempItem.note = designators[0] + ", ";

                            for (int j = 1; j < designators.Length; j++)
                            {
                                if ((tempItem.note.Length + designators[j].Length) >= maxNoteLength)
                                {
                                    note = string.Empty;
                                    for (int k = j; k < designators.Length; k++)
                                    {
                                        if (k != (designators.Length - 1))
                                        {
                                            note += designators[k] + ',';
                                        }
                                        else
                                        {
                                            note += designators[k];
                                        }
                                    }
                                    break;
                                }
                                else
                                {
                                    tempItem.note += designators[j] + ", ";
                                }
                            }
                        }
                        else if (note != String.Empty)
                        {
                            tempItem.note = note;
                            note          = String.Empty;
                        }


                        tempList2.Add(tempItem);
                    }
                }
            }

            numberOfValidStrings = tempList2.Count();

            #endregion

            return(tempList2);
        }
        public void Handle(SaveRequirementCommand command)
        {
            var requirement = new Requirement();
            var currentUser = _currentUserRetriever.Get();

            requirement.CreatorId     = currentUser.Id;
            requirement.Difficulty    = command.Difficulty.Value;
            requirement.Id            = Guid.NewGuid();
            requirement.IsLastVersion = true;
            requirement.Rank          = command.Rank.Value;

            foreach (var item in command.Items)
            {
                var content = new RequirementContent();
                content.Action      = item.Action;
                content.Subject     = item.Subject;
                content.Condition   = item.Condition;
                content.Id          = requirement.Id;
                content.Locale      = item.Locale;
                content.Version     = 1;
                content.Requirement = requirement;
                _requirementContentRepository.Add(content);
            }

            var currentProjectId = _currentProjectContextId.Get();

            if (currentProjectId == null)
            {
                throw new Exception(Sentences.noProjectInContext);
            }

            var project = _projectRepository.Get(currentProjectId.Value);

            var nextIdQuery = new RequirementNextIdQuery
            {
                ProjectId       = project.Id,
                RequirementType = command.RequirementType
            };

            var identifier = _requirementNextIdQueryHandler.Handle(nextIdQuery);

            var specificationItem = new SpecificationItem();

            specificationItem.Active = true;
            specificationItem.Id     = requirement.Id;
            specificationItem.Type   = SpecificationItemType.Requirement;
            var prefix = RequirementViewModel.GetPrefixFromType(command.RequirementType.Value);

            specificationItem.Label = $"{prefix}{identifier}";

            var package = _packageRepository.Get(command.PackageId.Value);

            if (!package.Active)
            {
                throw new Exception(Sentences.thisPackageWasRemoved);
            }
            specificationItem.Package = package;

            requirement.SpecificationItem = specificationItem;
            requirement.Type    = command.RequirementType.Value;
            requirement.Creator = currentUser;
            requirement.Version = 1;
            requirement.Project = project;

            requirement.Identifier = identifier;

            _specificationItemRepository.Add(specificationItem);
            _requirementRepository.Add(requirement);
        }