public override DataItem CreateData(UndoRedoManager undoRedo)
        {
            var item = new StructItem(this, undoRedo);

            foreach (var att in Attributes)
            {
                var attItem = att.CreateData(undoRedo);
                item.Attributes.Add(attItem);
            }

            if (!Nullable)
            {
                CreateChildren(item, undoRedo);
            }

            foreach (var child in item.Attributes)
            {
                child.UpdateVisibleIfBinding();
            }
            foreach (var child in item.Children)
            {
                child.UpdateVisibleIfBinding();
            }

            return(item);
        }
        public void CreateChildren(StructItem item, UndoRedoManager undoRedo)
        {
            foreach (var def in Children)
            {
                var      name      = def.Name;
                DataItem childItem = def.CreateData(undoRedo);

                item.Children.Add(childItem);
            }
        }
            public override void CaseANamedType(ANamedType node)
            {
                //Remember.. if you are the child of a fieldDecl, that field may have been moved
                if (!node.IsPrimitive())//GalaxyKeywords.Primitives.words.Any(word => word == node.GetName().Text)))
                {
                    AStructDecl decl = finalTrans.data.StructTypeLinks[node];
                    Item currentItem = GetIncludeItem(node);
                    if (Util.GetAncestor<AFieldDecl>(node) != null)
                    {
                        Item i = allItems.OfType<FieldItem>().FirstOrDefault(item => item.FieldDecl == Util.GetAncestor<AFieldDecl>(node));
                        if (i != null)
                            currentItem = i;
                    }
                    if (Util.GetAncestor<AStructDecl>(node) != null)
                    {
                        Item i =
                            allItems.OfType<StructItem>().FirstOrDefault(
                                item => item.StructDecl == Util.GetAncestor<AStructDecl>(node));
                        if (i != null)
                            currentItem = i;
                    }
                    Item declItem = ((Item)allItems.OfType<StructItem>().FirstOrDefault(item => item.StructDecl == decl)) ??
                                allItems.OfType<IncludeItem>().First(
                                    item => item.Current == Util.GetAncestor<AASourceFile>(decl));

                    List<Item> cPath = currentItem.Path;
                    List<Item> dPath = declItem.Path;

                    for (int i = 0; i < Math.Min(cPath.Count, dPath.Count); i++)
                    {
                        if (cPath[i] != dPath[i])
                        {//FORK!!!!
                            //We have a fork. make sure that the field is visible
                            int cI = cPath[i - 1].Children.IndexOf(cPath[i]);
                            int dI = dPath[i - 1].Children.IndexOf(dPath[i]);

                            if (dI < cI)
                            {//The decl is okay
                                break;
                            }

                            //Move the decl up
                            if (declItem is StructItem)
                            {
                                declItem.Parent.Children.Remove(declItem);
                                declItem.Parent = cPath[i - 1];
                            }
                            else
                            {
                                declItem = new StructItem(decl, cPath[i - 1], new List<Item>());
                                allItems.Add(declItem);
                            }
                            cPath[i - 1].Children.Insert(cI, declItem);
                            break;
                        }
                        if (i == cPath.Count - 1)
                        {
                            if (i == dPath.Count - 1)
                            {
                                //The decl and use is in same file. Ensure that the decl is before
                                if (Util.TokenLessThan(decl.GetName(), node.GetToken()))
                                    break;
                                //Add the decl item
                                declItem = new StructItem(decl, cPath[i], new List<Item>());
                                allItems.Add(declItem);
                                cPath[i].Children.Add(declItem);
                                break;
                            }
                            else
                            {
                                //The decl is included here or somewhere deeper. But above the use
                                break;
                            }
                        }
                        else if (i == dPath.Count - 1)
                        {
                            //We have reached the file where the decl is, but the use is included deeper, so it is above. Insert decl
                            int cI = cPath[i].Children.IndexOf(cPath[i + 1]);
                            declItem = new StructItem(decl, cPath[i], new List<Item>());
                            allItems.Add(declItem);
                            cPath[i].Children.Insert(cI, declItem);
                            break;
                        }
                    }

                }
                base.CaseANamedType(node);
            }
        public override DataItem LoadData(XElement element, UndoRedoManager undoRedo)
        {
            var item = new StructItem(this, undoRedo);

            if (Collapse)
            {
                var split = element.Value.Split(new string[] { Seperator }, StringSplitOptions.None);

                if (split.Length == Children.Count)
                {
                    for (int i = 0; i < split.Length; i++)
                    {
                        var      data      = split[i];
                        var      def       = Children[i] as PrimitiveDataDefinition;
                        DataItem childItem = def.LoadFromString(data, undoRedo);
                        item.Children.Add(childItem);
                    }
                }
                else
                {
                    foreach (var def in Children)
                    {
                        var child = def.CreateData(undoRedo);
                        item.Children.Add(child);
                    }
                }
            }
            else
            {
                var createdChildren = new List <DataItem>();

                var commentTexts = Children.Where(e => e is CommentDefinition).Select(e => (e as CommentDefinition).Text);

                foreach (var def in Children)
                {
                    var name = def.Name;

                    var els = !(def is CommentDefinition) ? element.Elements(name) : new List <XElement>();

                    if (els.Count() > 0)
                    {
                        var prev = els.First().PreviousNode as XComment;
                        if (prev != null)
                        {
                            var comment = new CommentDefinition().LoadData(prev, undoRedo);
                            if (!commentTexts.Contains(comment.TextValue))
                            {
                                item.Children.Add(comment);
                            }
                        }

                        if (def is CollectionDefinition)
                        {
                            CollectionItem childItem = (CollectionItem)def.LoadData(els.First(), undoRedo);
                            if (childItem.Children.Count == 0)
                            {
                                var dummyEl = new XElement(els.First().Name);
                                foreach (var el in els)
                                {
                                    dummyEl.Add(el);
                                }

                                childItem = (CollectionItem)def.LoadData(dummyEl, undoRedo);
                            }

                            item.Children.Add(childItem);
                        }
                        else
                        {
                            DataItem childItem = def.LoadData(els.First(), undoRedo);
                            item.Children.Add(childItem);
                        }
                    }
                    else
                    {
                        DataItem childItem = def.CreateData(undoRedo);
                        item.Children.Add(childItem);
                    }
                }

                if (element.LastNode is XComment)
                {
                    var comment = new CommentDefinition().LoadData(element.LastNode as XComment, undoRedo);
                    if (!commentTexts.Contains(comment.TextValue))
                    {
                        item.Children.Add(comment);
                    }
                }
            }

            foreach (var att in Attributes)
            {
                var      el      = element.Attribute(att.Name);
                DataItem attItem = null;

                if (el != null)
                {
                    attItem = att.LoadData(new XElement(el.Name, el.Value.ToString()), undoRedo);
                }
                else
                {
                    attItem = att.CreateData(undoRedo);
                }
                item.Attributes.Add(attItem);
            }

            foreach (var child in item.Attributes)
            {
                child.UpdateVisibleIfBinding();
            }
            foreach (var child in item.Children)
            {
                child.UpdateVisibleIfBinding();
            }

            return(item);
        }
        public override void DoSaveData(XElement parent, DataItem item)
        {
            StructItem si = item as StructItem;

            if (Collapse)
            {
                var name = Name;
                var data = "";

                foreach (var child in si.Children)
                {
                    var primDef = child.Definition as PrimitiveDataDefinition;

                    data += primDef.WriteToString(child) + Seperator;
                }

                data = data.Remove(data.Length - Seperator.Length, Seperator.Length);

                var el = new XElement(name, data);
                parent.Add(el);

                foreach (var att in si.Attributes)
                {
                    var primDef         = att.Definition as PrimitiveDataDefinition;
                    var asString        = primDef.WriteToString(att);
                    var defaultAsString = primDef.DefaultValueString();

                    if (att.Name == "Name" || !primDef.SkipIfDefault || asString != defaultAsString)
                    {
                        el.SetAttributeValue(att.Name, asString);
                    }
                }
            }
            else
            {
                var name = Name;

                var el = new XElement(name);
                parent.Add(el);

                foreach (var att in si.Attributes)
                {
                    var primDef         = att.Definition as PrimitiveDataDefinition;
                    var asString        = primDef.WriteToString(att);
                    var defaultAsString = primDef.DefaultValueString();

                    if (att.Name == "Name" || !primDef.SkipIfDefault || asString != defaultAsString)
                    {
                        el.SetAttributeValue(att.Name, asString);
                    }
                }

                foreach (var child in si.Children)
                {
                    var childDef = child.Definition;
                    if (!Children.Contains(childDef) && !(childDef is CommentDefinition))
                    {
                        throw new Exception("A child has a definition that we dont have! Something broke!");
                    }

                    if (childDef is CommentDefinition && !((CommentDefinition)childDef).CanEdit)
                    {
                        continue;                         // dont save out the default comments
                    }

                    child.Definition.SaveData(el, child);
                }
            }
        }
Esempio n. 6
0
        } // Cancel

        //Подсасываем всю необходимую инфу для отображения товара (скопипизжено ToModeAcceptedItem())
        protected bool QuestItem()
        {
            //private bool ToModeAcceptedItem(string ItemID, string IDDoc, Mode ToMode, int InPartyCount, bool OnShelf)

            //DataRow[] DR;
            AdressConditionItem = null;

            string    TextQuery = "SELECT VALUE as val FROM _1sconst (nolock) WHERE ID = $Константа.ОснЦентрСклад ";
            DataTable DT;

            if (!SS.ExecuteWithRead(TextQuery, out DT))
            {
                return(false);
            }
            BufferWarehouse = DT.Rows[0]["val"].ToString();

            //Если был дисконнект, то это проявиться после нижеследующего запроса
            //и дальше будет, не приемка, а редактирование карточки, для этого запрос и помещен в начало
            if (!LoadUnits(Item.InvCode))
            {
                return(false);
            }

            //FExcStr - несет смысл
            AcceptedItem = new StructItem();
            AcceptedItem.GenerateBarcode = false;

            #region Вроде не нужно

            /* if (NewBarcodes == null)
             * {
             *  NewBarcodes = new List<string>();
             * }
             * else
             * {
             *  NewBarcodes.Clear();
             * }*/

            //Определяем имеется ли данный товар в списке принимаемых
            //CurrentRowAcceptedItem = null;
            //int AllCount = 0;


            /* if (ToMode == Mode.Acceptance)
             * {
             *   DR = FNotAcceptedItems.Select("ID = '" + ItemID + "'");
             *   if (DR.Length > 1 && IDDoc != "")
             *   {
             *       foreach (DataRow dr in DR)
             *       {
             *           if (dr["IDDOC"].ToString() == IDDoc)
             *           {
             *               if (CurrentRowAcceptedItem == null)
             *               {
             *                   CurrentRowAcceptedItem = dr;
             *               }
             *           }
             *           AllCount += (int)dr["Count"];
             *       }
             *   }
             *   else if (DR.Length > 0) //Один товар или не указана строка документа
             *   {
             *       CurrentRowAcceptedItem = DR[0];
             *       foreach (DataRow dr in DR)
             *       {
             *           AllCount += (int)dr["Count"];
             *       }
             *   }
             *   //иначе это скан товара не из списка!
             * }*/



            //БЛОКИРУЕМ ТОВАР
            //if (!LockItem(ItemID))
            //{
            //    return false;
            //}
            #endregion

            #region Запрос ОПРЕДЕЛЯЕМ ОСТАТКИ И АДРЕСА
            TextQuery =
                "DECLARE @curdate DateTime; " +
                "SELECT @curdate = DATEADD(DAY, 1 - DAY(curdate), curdate) FROM _1ssystem (nolock); " +
                "SELECT " +
                "CAST(sum(CASE WHEN Main.Warehouse = :MainWarehouse THEN Main.Balance ELSE 0 END) as int) as BalanceMain, " +
                "CAST(sum(CASE WHEN Main.Warehouse = :BufferWarehouse THEN Main.Balance ELSE 0 END) as int) as BalanceBuffer, " +
                "ISNULL((" +
                "SELECT top 1 " +
                "Section.descr " +
                "FROM _1sconst as Const (nolock) " +
                "LEFT JOIN $Спр.Секции as Section (nolock) " +
                "ON Section.id = left(Const.value, 9) " +
                "WHERE " +
                "Const.id = $Спр.ТоварныеСекции.Секция " +
                "and Const.date <= :DateNow " +
                "and Const.OBJID in (" +
                "SELECT id FROM $Спр.ТоварныеСекции " +
                "WHERE " +
                "$Спр.ТоварныеСекции.Склад = :MainWarehouse " +
                "and parentext = :Item)" +
                "ORDER BY " +
                "Const.date DESC, Const.time DESC, Const.docid DESC), '<не задан>') as AdressMain, " +
                "ISNULL((" +
                "SELECT top 1 " +
                "Section.descr " +
                "FROM _1sconst as Const (nolock) " +
                "LEFT JOIN $Спр.Секции as Section (nolock) " +
                "ON Section.id = left(Const.value, 9) " +
                "WHERE " +
                "Const.id = $Спр.ТоварныеСекции.Секция " +
                "and Const.date <= :DateNow " +
                "and Const.OBJID in (" +
                "SELECT id FROM $Спр.ТоварныеСекции " +
                "WHERE " +
                "$Спр.ТоварныеСекции.Склад = :BufferWarehouse " +
                "and parentext = :Item)" +
                "ORDER BY " +
                "Const.date DESC, Const.time DESC, Const.docid DESC), '<не задан>') as AdressBuffer " +
                "FROM (" +
                "SELECT " +
                "$Рег.ОстаткиТоваров.Склад as Warehouse, " +
                "$Рег.ОстаткиТоваров.Товар as Item, " +
                "$Рег.ОстаткиТоваров.ОстатокТовара as Balance " +
                "FROM " +
                "RG$Рег.ОстаткиТоваров (nolock) " +
                "WHERE " +
                "period = @curdate " +
                "and $Рег.ОстаткиТоваров.Товар = :Item " +
                "and $Рег.ОстаткиТоваров.Склад in (:MainWarehouse, :BufferWarehouse) " +
                "UNION ALL " +
                "SELECT " +
                ":MainWarehouse, :Item, 0 " +
                ") as Main " +
                "GROUP BY Main.Item";
            SQL1S.QuerySetParam(ref TextQuery, "DateNow", DateTime.Now);
            SQL1S.QuerySetParam(ref TextQuery, "Item", Item.ID);
            SQL1S.QuerySetParam(ref TextQuery, "BufferWarehouse", BufferWarehouse);
            SQL1S.QuerySetParam(ref TextQuery, "MainWarehouse", Const.MainWarehouse);
            DT.Clear();
            if (!SS.ExecuteWithRead(TextQuery, out DT))
            {
                return(false);
            }
            #endregion

            AcceptedItem.BalanceMain   = (int)DT.Rows[0]["BalanceMain"];
            AcceptedItem.BalanceBuffer = (int)DT.Rows[0]["BalanceBuffer"];
            AcceptedItem.AdressMain    = DT.Rows[0]["AdressMain"].ToString();
            AcceptedItem.AdressBuffer  = DT.Rows[0]["AdressBuffer"].ToString();
            AcceptedItem.IsRepeat      = false;

            Dictionary <string, object> DataMapWrite = new Dictionary <string, object>();

            #region Запрос Подсосем остатки в разрезе адресов и состояний
            TextQuery =
                "DECLARE @curdate DateTime; " +
                "SELECT @curdate = DATEADD(DAY, 1 - DAY(curdate), curdate) FROM _1ssystem (nolock); " +
                "SELECT " +
                "min(Section.descr) as Adress, " +
                "CASE " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = -10 THEN '-10 Автокорректировка' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = -2 THEN '-2 В излишке' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = -1 THEN '-1 В излишке (пересчет)' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 0 THEN '00 Не существует' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 1 THEN '01 Приемка' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 2 THEN '02 Хороший на месте' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 3 THEN '03 Хороший (пересчет)' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 4 THEN '04 Хороший (движение)' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 7 THEN '07 Бракованный на месте' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 8 THEN '08 Бракованный (пересчет)' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 9 THEN '09 Бракованный (движение)' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 12 THEN '12 Недостача' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 13 THEN '13 Недостача (пересчет)' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 14 THEN '14 Недостача (движение)' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 17 THEN '17 Недостача подтвержденная' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 18 THEN '18 Недостача подт.(пересчет)' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 19 THEN '19 Недостача подт.(движение)' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 22 THEN '22 Пересорт излишек' " +
                "WHEN RegAOT.$Рег.АдресОстаткиТоваров.Состояние = 23 THEN '23 Пересорт недостача' " +
                "ELSE rtrim(cast(RegAOT.$Рег.АдресОстаткиТоваров.Состояние as char)) + ' <неизвестное состояние>' END as Condition, " +
                "cast(sum(RegAOT.$Рег.АдресОстаткиТоваров.Количество ) as int) as Count " +
                "FROM " +
                "RG$Рег.АдресОстаткиТоваров as RegAOT (nolock) " +
                "LEFT JOIN $Спр.Секции as Section (nolock) " +
                "ON Section.id = RegAOT.$Рег.АдресОстаткиТоваров.Адрес " +
                "WHERE " +
                "RegAOT.period = @curdate " +
                "and RegAOT.$Рег.АдресОстаткиТоваров.Товар = :ItemID " +
                "and RegAOT.$Рег.АдресОстаткиТоваров.Склад = :Warehouse " +
                "GROUP BY " +
                "RegAOT.$Рег.АдресОстаткиТоваров.Адрес , " +
                "RegAOT.$Рег.АдресОстаткиТоваров.Товар , " +
                "RegAOT.$Рег.АдресОстаткиТоваров.Состояние " +
                "HAVING sum(RegAOT.$Рег.АдресОстаткиТоваров.Количество ) <> 0 " +
                "ORDER BY Adress, Condition";
            SQL1S.QuerySetParam(ref TextQuery, "DateNow", DateTime.Now);
            SQL1S.QuerySetParam(ref TextQuery, "ItemID", Item.ID);
            SQL1S.QuerySetParam(ref TextQuery, "Warehouse", Const.MainWarehouse);
            if (!SS.ExecuteWithRead(TextQuery, out AdressConditionItem))
            {
                AdressConditionItem = null;
            }
            #endregion

            #region Запрос Я не знаю что это...
            TextQuery =
                "SELECT " +
                "Goods.Descr as ItemName," +
                "Goods.$Спр.Товары.ИнвКод as InvCode, " +
                "Goods.$Спр.Товары.Артикул as Article, " +
                "Goods.$Спр.Товары.КоличествоДеталей as Details, " +
                "Goods.$Спр.Товары.БазоваяЕдиницаШК as BaseUnitID, " +
                "Goods.$Спр.Товары.МинПартия as MinParty, " +
                "Goods.$Спр.Товары.Опт_Цена as Price,  " +
                //"Goods.$Спр.Товары." + (ToMode == Mode.Acceptance ? "Прих_Цена" : "Опт_Цена") + " as Price,  " +
                //"isnull(RefSections.$Спр.ТоварныеСекции.РазмерХранения , 0) as StoregeSize " +
                "isnull(RefSections.$Спр.ТоварныеСекции.РасчетныйРХ , 0) as StoregeSize " +
                "FROM $Спр.Товары as Goods (nolock) " +
                "left join $Спр.ТоварныеСекции as RefSections (nolock) " +
                "on RefSections.parentext = Goods.id and RefSections.$Спр.ТоварныеСекции.Склад = :warehouse " +
                "WHERE Goods.id = :Item ";
            SQL1S.QuerySetParam(ref TextQuery, "Item", Item.ID);
            SQL1S.QuerySetParam(ref TextQuery, "warehouse", Const.MainWarehouse);
            DT.Clear();
            if (!SS.ExecuteWithRead(TextQuery, out DT))
            {
                return(false);
            }
            #endregion

            AcceptedItem.Details    = (int)(decimal)DT.Rows[0]["Details"];
            AcceptedItem.NowDetails = AcceptedItem.Details;

            AcceptedItem.ID                = Item.InvCode;
            AcceptedItem.Name              = DT.Rows[0]["ItemName"].ToString();
            AcceptedItem.InvCode           = DT.Rows[0]["InvCode"].ToString();
            AcceptedItem.Acticle           = DT.Rows[0]["Article"].ToString();
            AcceptedItem.BaseUnitID        = DT.Rows[0]["BaseUnitID"].ToString();
            AcceptedItem.MinParty          = (int)(decimal)DT.Rows[0]["MinParty"];
            AcceptedItem.Count             = 0;
            AcceptedItem.Price             = (decimal)DT.Rows[0]["Price"];
            AcceptedItem.Acceptance        = false;
            AcceptedItem.ToMode            = OldMode.CurrentMode;
            AcceptedItem.BindingAdressFlag = false;
            AcceptedItem.StoregeSize       = (int)(decimal)DT.Rows[0]["StoregeSize"];
            AcceptedItem.CurrentBalance    = AcceptedItem.BalanceMain;


            #region Если это необходимо, то определяем количество товара для склада инвентаризации
            if (AcceptedItem.ToMode != Mode.Inventory || InventoryWarehouse.ID == Const.MainWarehouse)
            {
                AcceptedItem.CurrentBalance = AcceptedItem.BalanceMain;
            }
            else if (InventoryWarehouse.ID == BufferWarehouse)
            {
                AcceptedItem.CurrentBalance = AcceptedItem.BalanceBuffer;
            }
            else
            {
                //Остатков этого склада нет!
                TextQuery =
                    "DECLARE @curdate DateTime; " +
                    "SELECT @curdate = DATEADD(DAY, 1 - DAY(curdate), curdate) FROM _1ssystem (nolock); " +
                    "SELECT sum(Main.Balance) as Balance " +
                    "FROM " +
                    "(SELECT " +
                    "$Рег.ОстаткиТоваров.Товар as Item, " +
                    "$Рег.ОстаткиТоваров.ОстатокТовара as Balance " +
                    "FROM " +
                    "RG$Рег.ОстаткиТоваров (nolock) " +
                    "WHERE " +
                    "period = @curdate " +
                    "and $Рег.ОстаткиТоваров.Товар = :ItemID " +
                    "and $Рег.ОстаткиТоваров.Склад = :Warehouse " +
                    "UNION ALL " +
                    "SELECT :ItemID, 0 " +
                    ") as Main " +
                    "GROUP BY Main.Item;";
                SQL1S.QuerySetParam(ref TextQuery, "DateNow", DateTime.Now);
                SQL1S.QuerySetParam(ref TextQuery, "ItemID", Item.ID);
                SQL1S.QuerySetParam(ref TextQuery, "Warehouse", InventoryWarehouse.ID);
                if (!SS.ExecuteWithRead(TextQuery, out DT))
                {
                    return(false);
                }
                AcceptedItem.CurrentBalance = (int)(decimal)DT.Rows[0]["Balance"];
            }
            #endregion

            #region А теперь имя склада!
            if (AcceptedItem.ToMode != Mode.Inventory)
            {
                TextQuery =
                    "SELECT descr as Name FROM $Спр.Склады (nolock) WHERE ID = :Warehouse";
                SQL1S.QuerySetParam(ref TextQuery, "Warehouse", Const.MainWarehouse);
                if (!SS.ExecuteWithRead(TextQuery, out DT))
                {
                    return(false);
                }
                AcceptedItem.CurrentWarehouseName = DT.Rows[0]["Name"].ToString();
            }
            else
            {
                AcceptedItem.CurrentWarehouseName = InventoryWarehouse.Name;
            }
            #endregion

            #region c Mode.Transfer думаю пока не нужно

            /*if (OldMode.CurrentMode == Mode.Transfer)
             * {
             *  if (ATDoc.ToWarehouseSingleAdressMode)
             *  {
             *      DR = FTransferReadyItems.Select("ID = '" + AcceptedItem.ID + "'");
             *      if (DR.Length > 0)
             *      {
             *          AcceptedItem.BindingAdress = DR[0]["Adress1"].ToString();
             *          AcceptedItem.BindingAdressName = DR[0]["AdressName"].ToString();
             *          AcceptedItem.BindingAdressFlag = true;
             *      }
             *      else if (!Employer.CanMultiadress && AcceptedItem.CurrentBalance > 0)
             *      {
             *          //ОПРЕДЕЛИМ РЕКОМЕНДУЕМЫЙ АДРЕС
             *          TextQuery =
             *              "SELECT top 1 " +
             *              " left(const.value, 9) as Adress, " +
             *              " section.descr as AdressName " +
             *              "FROM _1sconst as const(nolock) " +
             *              "LEFT JOIN $Спр.Секции as Section (nolock) " +
             *                      "ON Section.id = left(value, 9) " +
             *              "WHERE " +
             *                  "const.id = $Спр.ТоварныеСекции.Секция " +
             *                  "and const.date <= :DateNow " +
             *                  "and const.OBJID in (" +
             *                                 "SELECT id FROM $Спр.ТоварныеСекции (nolock) " +
             *                                  "WHERE " +
             *                                      "$Спр.ТоварныеСекции.Склад = :Warehouse " +
             *                                      "and parentext = :Item) " +
             *              "ORDER BY " +
             *                  "const.date DESC, const.time DESC, const.docid DESC ";
             *          SQL1S.QuerySetParam(ref TextQuery, "DateNow", DateTime.Now);
             *          SQL1S.QuerySetParam(ref TextQuery, "Item", Item.ID);
             *          SQL1S.QuerySetParam(ref TextQuery, "Warehouse", ATDoc.ToWarehouseID);
             *          if (!SS.ExecuteWithRead(TextQuery, out DT))
             *          {
             *              return false;
             *          }
             *          if (DT.Rows.Count == 1)
             *          {
             *              AcceptedItem.BindingAdress = DT.Rows[0]["Adress"].ToString();
             *              AcceptedItem.BindingAdressName = DT.Rows[0]["AdressName"].ToString();
             *              AcceptedItem.BindingAdressFlag = true;
             *          }
             *      }
             *  }
             * }*/
            #endregion

            #region Заполнение FExcStr. Для подпитки это не нужно

            /*if (AcceptedItem.ToMode == Mode.Acceptance)
             * {
             *  FExcStr = "РЕДАКТИРОВАНИЕ КАРТОЧКИ! ТОВАРА НЕТ В СПИСКЕ ПРИНИМАЕМЫХ!";
             * }
             * else if (AcceptedItem.ToMode == Mode.Inventory)
             * {
             *  FExcStr = "РЕДАКТИРОВАНИЕ КАРТОЧКИ!";
             * }
             * else if (AcceptedItem.ToMode == Mode.SampleInventory)
             * {
             *  FExcStr = "ОБРАЗЕЦ! " + FExcStr;
             * }
             * else if (AcceptedItem.ToMode == Mode.SamplePut)
             * {
             *  FExcStr = "ОБРАЗЕЦ (выкладка)! " + FExcStr;
             * }
             * else if (AcceptedItem.ToMode == Mode.Transfer || AcceptedItem.ToMode == Mode.NewInventory || AcceptedItem.ToMode == Mode.Harmonization || AcceptedItem.ToMode == Mode.HarmonizationPut)
             * {
             *  if (OnShelf)
             *  {
             *     // RefItem Item = new RefItem(this); (уже объялен)
             *      Item.FoundID(AcceptedItem.ID);
             *      RefSection BindingAdress = new RefSection(this);
             *      BindingAdress.FoundID(AcceptedItem.BindingAdress);
             *
             *      if (AcceptedItem.BindingAdressFlag)
             *      {
             *          FExcStr = "НА ПОЛКУ! Отсканируйте адрес!"; // по умолчинию так ставим, а ниже условия которые могут этот текст поменять
             *
             *          if (!Item.ZonaHand.Selected && !BindingAdress.AdressZone.Selected)
             *          {
             *              FExcStr = "НА ПОЛКУ! Отсканируйте адрес: " + AcceptedItem.BindingAdressName;
             *          }
             *          else if (Item.ZonaHand.Selected && BindingAdress.AdressZone.Selected)
             *          {
             *              if (Item.ZonaHand.ID == BindingAdress.AdressZone.ID)
             *              {
             *                  FExcStr = "НА ПОЛКУ! Отсканируйте адрес: " + AcceptedItem.BindingAdressName;
             *              }
             *          }
             *      }
             *      else if (AcceptedItem.ToMode == Mode.Harmonization)
             *      {
             *          //ну не пиздец ли это???
             *          FExcStr = "В ТЕЛЕЖКУ! Отсканируйте адрес!";
             *      }
             *      else
             *      {
             *          FExcStr = "НА ПОЛКУ! Отсканируйте адрес!";
             *      }
             *  }
             *  else
             *  {
             *      DR = FTransferReadyItems.Select("ID = '" + AcceptedItem.ID + "'");
             *      if (DR.Length == 0)
             *      {
             *          FExcStr = "В ТЕЛЕЖКУ!";
             *      }
             *      else
             *      {
             *          AcceptedItem.IsRepeat = true;
             *          FExcStr = "ВНИМАНИЕ! УЖЕ СЧИТАЛСЯ! (В ТЕЛЕЖКУ)";
             *      }
             *  }
             *  AcceptedItem.Count      = InPartyCount;
             *  AcceptedItem.OnShelf    = OnShelf;
             * }*/
            #endregion

            #region Пишем в обслуживание скс. Для подпитки - не нужно

            /*
             * FCurrentMode = Mode.AcceptedItem;
             * //begin internal command
             * DataMapWrite["Спр.СинхронизацияДанных.ДатаСпрВход1"]    = ExtendID(Employer.ID, "Спр.Сотрудники");
             * DataMapWrite["Спр.СинхронизацияДанных.ДатаСпрВход2"]    = ExtendID(ItemID, "Спр.Товары");
             * DataMapWrite["Спр.СинхронизацияДанных.ДатаВход1"]       = "OpenItem (Открыл карточку)";
             * if (!ExecCommandNoFeedback("Internal", DataMapWrite))
             * {
             *  return false;
             * }
             * //end internal command
             * return true;
             *
             * if (FlagBarcode == 0)
             * {
             *  FExcStr = AcceptedItem.InvCode.Trim() + " найден в ручную!";
             * }
             * else if (FlagBarcode == 1)
             * {
             *  FExcStr = AcceptedItem.InvCode.Trim() + " найден по штрихкоду!";
             * }
             * else //FlagBarcode == 2
             * {
             *  FExcStr = AcceptedItem.InvCode.Trim() + " найден по ШК МЕСТА!";
             * }
             * DataRow[] DRAI = FAcceptedItems.Select("ID = '" + ItemID + "' and IDDOC = '" + IDDoc + "'");
             * if (DRAI.Length > 0)
             * {
             *  FExcStr = "ПОВТОРНАЯ приемка!!! " + FExcStr;
             * }
             * //Добавляем что принимается не все
             * if (AllCount > AcceptedItem.Count)
             * {
             *  int Coef = 1;
             *  DR = FUnits.Select("OKEI = '"  + OKEIPackage + "'");
             *  foreach(DataRow dr in DR)
             *  {
             *      Coef = (int)dr["Coef"];
             *      break;
             *  }
             *  FExcStr += " " + GetStrPackageCount(AcceptedItem.Count, Coef) + " из " + GetStrPackageCount(AllCount, Coef);
             * }
             * //begin internal command
             * DataMapWrite["Спр.СинхронизацияДанных.ДатаСпрВход1"]    = ExtendID(Employer.ID, "Спр.Сотрудники");
             * DataMapWrite["Спр.СинхронизацияДанных.ДатаСпрВход2"]    = ExtendID(ItemID, "Спр.Товары");
             * DataMapWrite["Спр.СинхронизацияДанных.ДокументВход"]    = ExtendID(IDDoc, "АдресПеремещение");
             * DataMapWrite["Спр.СинхронизацияДанных.ДатаВход1"]       = "OpenItemAccept (Открыл карточку для приемки)";
             * if (!ExecCommandNoFeedback("Internal", DataMapWrite))
             * {
             *  return false;
             * }*/
            //end internal command
            #endregion

            return(true);
        }
Esempio n. 7
0
            public override void CaseANamedType(ANamedType node)
            {
                //Remember.. if you are the child of a fieldDecl, that field may have been moved
                if (!node.IsPrimitive())//GalaxyKeywords.Primitives.words.Any(word => word == node.GetName().Text)))
                {
                    AStructDecl decl        = finalTrans.data.StructTypeLinks[node];
                    Item        currentItem = GetIncludeItem(node);
                    if (Util.GetAncestor <AFieldDecl>(node) != null)
                    {
                        Item i = allItems.OfType <FieldItem>().FirstOrDefault(item => item.FieldDecl == Util.GetAncestor <AFieldDecl>(node));
                        if (i != null)
                        {
                            currentItem = i;
                        }
                    }
                    if (Util.GetAncestor <AStructDecl>(node) != null)
                    {
                        Item i =
                            allItems.OfType <StructItem>().FirstOrDefault(
                                item => item.StructDecl == Util.GetAncestor <AStructDecl>(node));
                        if (i != null)
                        {
                            currentItem = i;
                        }
                    }
                    Item declItem = ((Item)allItems.OfType <StructItem>().FirstOrDefault(item => item.StructDecl == decl)) ??
                                    allItems.OfType <IncludeItem>().First(
                        item => item.Current == Util.GetAncestor <AASourceFile>(decl));

                    List <Item> cPath = currentItem.Path;
                    List <Item> dPath = declItem.Path;

                    for (int i = 0; i < Math.Min(cPath.Count, dPath.Count); i++)
                    {
                        if (cPath[i] != dPath[i])
                        {//FORK!!!!
                            //We have a fork. make sure that the field is visible
                            int cI = cPath[i - 1].Children.IndexOf(cPath[i]);
                            int dI = dPath[i - 1].Children.IndexOf(dPath[i]);

                            if (dI < cI)
                            {//The decl is okay
                                break;
                            }

                            //Move the decl up
                            if (declItem is StructItem)
                            {
                                declItem.Parent.Children.Remove(declItem);
                                declItem.Parent = cPath[i - 1];
                            }
                            else
                            {
                                declItem = new StructItem(decl, cPath[i - 1], new List <Item>());
                                allItems.Add(declItem);
                            }
                            cPath[i - 1].Children.Insert(cI, declItem);
                            break;
                        }
                        if (i == cPath.Count - 1)
                        {
                            if (i == dPath.Count - 1)
                            {
                                //The decl and use is in same file. Ensure that the decl is before
                                if (Util.TokenLessThan(decl.GetName(), node.GetToken()))
                                {
                                    break;
                                }
                                //Add the decl item
                                declItem = new StructItem(decl, cPath[i], new List <Item>());
                                allItems.Add(declItem);
                                cPath[i].Children.Add(declItem);
                                break;
                            }
                            else
                            {
                                //The decl is included here or somewhere deeper. But above the use
                                break;
                            }
                        }
                        else if (i == dPath.Count - 1)
                        {
                            //We have reached the file where the decl is, but the use is included deeper, so it is above. Insert decl
                            int cI = cPath[i].Children.IndexOf(cPath[i + 1]);
                            declItem = new StructItem(decl, cPath[i], new List <Item>());
                            allItems.Add(declItem);
                            cPath[i].Children.Insert(cI, declItem);
                            break;
                        }
                    }
                }
                base.CaseANamedType(node);
            }
Esempio n. 8
0
        public static void Apply(AAProgram ast, FinalTransformations finalTrans)
        {
            //Build list of file dependacies
            Phase1 phase1 = new Phase1(finalTrans);

            ast.Apply(phase1);
            var dependancies = phase1.dependancies;

            if (dependancies.Keys.Count == 0)
            {
                return;
            }
            AASourceFile root = Util.GetAncestor <AASourceFile>(finalTrans.mainEntry) ??
                                dependancies.Keys.FirstOrDefault(file => !file.GetName().Text.Contains("\\")) ??
                                dependancies.Keys.First(file => true);

            //Remove files unreachable from root
            //On second thought, dont. there might be static refferences the other way which needs to be included

            /*{
             *  List<AASourceFile> reachable = GetReachable(root, dependancies);
             *  AASourceFile[] keys = new AASourceFile[dependancies.Count];
             *  dependancies.Keys.CopyTo(keys, 0);
             *  foreach (AASourceFile key in keys)
             *  {
             *      if (!reachable.Contains(key))
             *          dependancies.Remove(key);
             *  }
             * }*/


            //Push common depancies up

            /*
             * root -> (item1 -> (item3), item2 -> (item4 -> (item3)))
             *
             * root -> (item3, item1, item2 -> (item4))
             */

            //Add unreachable to the root
            while (true)
            {
                List <AASourceFile> reachable = new List <AASourceFile>();
                GetReachable(root, dependancies, ref reachable);
                if (reachable.Count == dependancies.Count + (reachable.Contains(null) ? 1 : 0))
                {
                    break;
                }
                AASourceFile[] keys = new AASourceFile[dependancies.Count];
                dependancies.Keys.CopyTo(keys, 0);
                foreach (AASourceFile key in keys)
                {
                    if (!reachable.Contains(key))
                    {
                        AASourceFile k = key;
                        //See if you can find another unreachable file which need this file
                        Dictionary <AASourceFile, int> decendantCounts = new Dictionary <AASourceFile, int>();
                        decendantCounts.Add(k, CountDecendants(k, dependancies, new List <AASourceFile>()));
                        while (true)
                        {
                            AASourceFile file = null;
                            foreach (KeyValuePair <AASourceFile, List <AASourceFile> > dependancy in dependancies)
                            {
                                if (decendantCounts.ContainsKey(dependancy.Key))
                                {
                                    continue;
                                }
                                if (!dependancy.Value.Contains(k))
                                {
                                    continue;
                                }
                                file = dependancy.Key;
                                break;
                            }

                            //AASourceFile file = dependancies.FirstOrDefault(item => item.Value.Contains(k)).Key;
                            if (file == null)
                            {
                                break;
                            }
                            decendantCounts.Add(file, CountDecendants(file, dependancies, new List <AASourceFile>()));
                            k = file;
                        }
                        foreach (KeyValuePair <AASourceFile, int> decendantItem in decendantCounts)
                        {
                            if (decendantItem.Value > decendantCounts[k])
                            {
                                k = decendantItem.Key;
                            }
                        }

                        dependancies[root].Add(k);
                        break;
                    }
                }
            }
            //It is moved down here because cycles are not removed in unreachable
            RemoveCycles(root, dependancies, new List <AASourceFile> {
                root
            });


            //Convert to tree to make it easier
            List <Item> allItems        = new List <Item>();
            IncludeItem rootIncludeItem = MakeTree(root, dependancies, allItems, null);

            bool[] removed = new bool[allItems.Count];
            for (int i = 0; i < removed.Length; i++)
            {
                removed[i] = false;
            }
            int removedCount = 0;

            //Ensure that each include is only included one place
            for (int i = 0; i < allItems.Count; i++)
            {
                if (removed[i])
                {
                    continue;
                }

                IncludeItem item1 = (IncludeItem)allItems[i];
                for (int j = i + 1; j < allItems.Count; j++)
                {
                    if (removed[j])
                    {
                        continue;
                    }
                    IncludeItem item2 = (IncludeItem)allItems[j];

                    if (item1.Current == item2.Current)
                    {
                        List <Item> path1 = item1.Path;
                        List <Item> path2 = item2.Path;



                        for (int k = 0; k < Math.Min(path1.Count, path2.Count); k++)
                        {
                            if (path1[k] != path2[k])
                            {
                                int insertAt = Math.Min(path1[k - 1].Children.IndexOf(path1[k]),
                                                        path2[k - 1].Children.IndexOf(path2[k]));


                                item1.Parent.Children.Remove(item1);
                                LinkedList <IncludeItem> toRemove = new LinkedList <IncludeItem>();
                                toRemove.AddLast(item2);
                                while (toRemove.Count > 0)
                                {
                                    IncludeItem item = toRemove.First.Value;
                                    toRemove.RemoveFirst();
                                    item.Parent.Children.Remove(item);
                                    //allItems.Remove(item);
                                    removedCount++;
                                    removed[item.ListIndex] = true;
                                    foreach (IncludeItem child in item.Children)
                                    {
                                        toRemove.AddLast(child);
                                    }
                                }
                                //j--;



                                path1[k - 1].Children.Insert(insertAt, item1);
                                item1.Parent = path1[k - 1];



                                break;
                            }
                        }
                    }
                }
            }

            List <Item> newAllItems = new List <Item>(allItems.Count - removedCount);

            for (int i = 0; i < allItems.Count; i++)
            {
                if (!removed[i])
                {
                    newAllItems.Add(allItems[i]);
                }
            }
            allItems = newAllItems;

            //Move the null node to nr [0]
            foreach (IncludeItem item in allItems)
            {
                if (item.Current == null)
                {
                    int  itemIndex = item.Parent.Children.IndexOf(item);
                    Item item0     = item.Parent.Children[0];
                    item.Parent.Children[0]         = item;
                    item.Parent.Children[itemIndex] = item0;
                    break;
                }
            }

            //Insert method decls and move structs & fields up as needed
            ast.Apply(new Phase2(finalTrans, allItems));

            //Insert the headers in the files

            if (Options.Compiler.OneOutputFile)
            {
                //for (int i = 0; i < allItems.Count; i++)
                int i = 0;
                while (allItems.Count > 0)
                {
                    if (allItems[i] is IncludeItem)
                    {
                        IncludeItem includeItem = (IncludeItem)allItems[i];
                        //Dont want the standard lib
                        if (includeItem.Current == null)
                        {
                            i++;
                            continue;
                        }
                        //If it has children with children, then pick another first
                        if (includeItem.Children.Any(child => child.Children.Count > 0))
                        {
                            i++;
                            continue;
                        }
                        if (includeItem.Children.Count == 0)
                        {
                            if (includeItem.Parent == null)
                            {
                                break;
                            }
                            i++;
                            continue;
                        }
                        i = 0;
                        //Put all children into this
                        while (includeItem.Children.Count > 0)
                        {
                            int childNr = includeItem.Children.Count - 1;
                            allItems.Remove(includeItem.Children[childNr]);
                            if (includeItem.Children[childNr] is FieldItem)
                            {
                                FieldItem aItem = (FieldItem)includeItem.Children[childNr];
                                Node      node  = aItem.FieldDecl;
                                node.Parent().RemoveChild(node);
                                includeItem.Current.GetDecl().Insert(0, node);
                            }
                            else if (includeItem.Children[childNr] is StructItem)
                            {
                                StructItem aItem = (StructItem)includeItem.Children[childNr];
                                Node       node  = aItem.StructDecl;
                                node.Parent().RemoveChild(node);
                                includeItem.Current.GetDecl().Insert(0, node);
                            }
                            else if (includeItem.Children[childNr] is MethodDeclItem)
                            {
                                MethodDeclItem aItem = (MethodDeclItem)includeItem.Children[childNr];
                                AMethodDecl    aNode = new AMethodDecl();
                                if (aItem.RealDecl.GetStatic() != null)
                                {
                                    aNode.SetStatic(new TStatic("static"));
                                }
                                aNode.SetReturnType(Util.MakeClone(aItem.RealDecl.GetReturnType(), finalTrans.data));
                                aNode.SetName(new TIdentifier(aItem.RealDecl.GetName().Text));
                                foreach (AALocalDecl formal in aItem.RealDecl.GetFormals())
                                {
                                    AALocalDecl clone = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, Util.MakeClone(formal.GetType(), finalTrans.data), new TIdentifier(formal.GetName().Text), null);
                                    aNode.GetFormals().Add(clone);
                                }
                                includeItem.Current.GetDecl().Insert(0, aNode);
                            }
                            else if (includeItem.Children[childNr] is IncludeItem)
                            {
                                IncludeItem aChild = (IncludeItem)includeItem.Children[childNr];
                                if (aChild.Current == null)
                                {
                                    AIncludeDecl node = new AIncludeDecl(new TInclude("include"),
                                                                         new TStringLiteral("\"TriggerLibs/NativeLib\""));
                                    includeItem.Current.GetDecl().Insert(0, node);
                                }
                                else
                                {
                                    PDecl[] decls = new PDecl[aChild.Current.GetDecl().Count];
                                    aChild.Current.GetDecl().CopyTo(decls, 0);
                                    for (int k = decls.Length - 1; k >= 0; k--)
                                    {
                                        includeItem.Current.GetDecl().Insert(0, decls[k]);
                                    }
                                    aChild.Current.Parent().RemoveChild(aChild.Current);
                                    //i = -1;
                                }
                            }
                            includeItem.Children.RemoveAt(childNr);
                        }
                    }
                }
            }
            else
            {
                foreach (IncludeItem includeItem in allItems.OfType <IncludeItem>())
                {
                    for (int i = includeItem.Children.Count - 1; i >= 0; i--)
                    {
                        Node node;
                        if (includeItem.Children[i] is IncludeItem)
                        {
                            IncludeItem aItem = (IncludeItem)includeItem.Children[i];
                            node = new AIncludeDecl(new TInclude("include"),
                                                    new TStringLiteral("\"" + (aItem.Current == null ? "TriggerLibs/NativeLib" : aItem.Current.GetName().Text.Replace("\\", "/")) + "\""));
                            if (aItem.Current == null && finalTrans.mainEntry != null)
                            {
                                //Search for user defined initlib
                                bool foundInvoke = false;
                                foreach (ASimpleInvokeExp invokeExp in finalTrans.data.SimpleMethodLinks.Keys)
                                {
                                    if (invokeExp.GetName().Text == "libNtve_InitLib" && invokeExp.GetArgs().Count == 0)
                                    {
                                        /*finalTrans.errors.Add(new ErrorCollection.Error(invokeExp.GetName(),
                                         *                                              Util.GetAncestor<AASourceFile>(
                                         *                                                  invokeExp),
                                         *                                              "You are invoking libNtve_InitLib() yourself somewhere. It will not be auto inserted.",
                                         *                                              true));*/
                                        foundInvoke = true;
                                        break;
                                    }
                                }

                                if (!foundInvoke)
                                {
                                    //Init the lib
                                    ASimpleInvokeExp initExp = new ASimpleInvokeExp();
                                    initExp.SetName(new TIdentifier("libNtve_InitLib"));
                                    finalTrans.data.ExpTypes[initExp] = new AVoidType(new TVoid("void"));
                                    foreach (AMethodDecl method in finalTrans.data.Libraries.Methods)
                                    {
                                        if (method.GetName().Text == "libNtve_InitLib" && method.GetFormals().Count == 0)
                                        {
                                            finalTrans.data.SimpleMethodLinks[initExp] = method;
                                        }
                                    }
                                    AABlock block = (AABlock)finalTrans.mainEntry.GetBlock();
                                    block.GetStatements().Insert(0, new AExpStm(new TSemicolon(";"), initExp));
                                }
                            }
                        }
                        else if (includeItem.Children[i] is FieldItem)
                        {
                            FieldItem aItem = (FieldItem)includeItem.Children[i];
                            node = aItem.FieldDecl;
                            node.Parent().RemoveChild(node);
                        }
                        else if (includeItem.Children[i] is StructItem)
                        {
                            StructItem aItem = (StructItem)includeItem.Children[i];
                            node = aItem.StructDecl;
                            node.Parent().RemoveChild(node);
                        }
                        else if (includeItem.Children[i] is MethodDeclItem)
                        {
                            MethodDeclItem aItem = (MethodDeclItem)includeItem.Children[i];
                            AMethodDecl    aNode = new AMethodDecl();
                            if (aItem.RealDecl.GetStatic() != null)
                            {
                                aNode.SetStatic(new TStatic("static"));
                            }
                            aNode.SetReturnType(Util.MakeClone(aItem.RealDecl.GetReturnType(), finalTrans.data));
                            aNode.SetName(new TIdentifier(aItem.RealDecl.GetName().Text));
                            foreach (AALocalDecl formal in aItem.RealDecl.GetFormals())
                            {
                                AALocalDecl clone = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, Util.MakeClone(formal.GetType(), finalTrans.data), new TIdentifier(formal.GetName().Text), null);
                                aNode.GetFormals().Add(clone);
                            }
                            node = aNode;
                        }
                        else
                        {
                            throw new Exception("FixIncludes.Apply: Unexpected item type");
                        }

                        includeItem.Current.GetDecl().Insert(0, node);
                    }
                }
            }
        }