コード例 #1
0
        public void EmitItem(object item)
        {
            if (item is AxisAxisAxisAxisAxis)
            {
                AxisAxisAxisAxisAxis axis = (AxisAxisAxisAxisAxis)item;
                if (deletesToIgnore.Contains(AchsenImportUtils.GuidFromImportString(axis.TID)))
                {
                    if (!axis.OPERATIONSpecified)
                    {
                        axis.OPERATIONSpecified = true;
                        axis.OPERATION          = OperationType.UPDATE;
                    }
                    else
                    {
                        switch (axis.OPERATION)
                        {
                        case OperationType.INSERT:
                            axis.OPERATION = OperationType.UPDATE;
                            break;

                        case OperationType.DELETE:
                            return;
                        }
                    }
                }
                dataHandler.ReceivedAxis(new AchseWrapper(axis));
            }
            else if (item is AxisAxisAxisAxisAxisSegment)
            {
                AxisAxisAxisAxisAxisSegment axisSegment = (AxisAxisAxisAxisAxisSegment)item;
                if (deletesToIgnore.Contains(AchsenImportUtils.GuidFromImportString(axisSegment.TID)))
                {
                    if (!axisSegment.OPERATIONSpecified)
                    {
                        axisSegment.OPERATIONSpecified = true;
                        axisSegment.OPERATION          = OperationType.UPDATE;
                    }
                    else
                    {
                        switch (axisSegment.OPERATION)
                        {
                        case OperationType.INSERT:
                            axisSegment.OPERATION = OperationType.UPDATE;
                            break;

                        case OperationType.DELETE:
                            return;
                        }
                    }
                }
                dataHandler.ReceivedAxissegment(new AchsenSegmentWrapper(axisSegment));
            }
            else if (item is AxisAxisAxisAxisSector)
            {
                AxisAxisAxisAxisSector axisSector = (AxisAxisAxisAxisSector)item;
                if (deletesToIgnore.Contains(AchsenImportUtils.GuidFromImportString(axisSector.TID)))
                {
                    if (!axisSector.OPERATIONSpecified)
                    {
                        axisSector.OPERATIONSpecified = true;
                        axisSector.OPERATION          = OperationType.UPDATE;
                    }
                    else
                    {
                        switch (axisSector.OPERATION)
                        {
                        case OperationType.INSERT:
                            axisSector.OPERATION = OperationType.UPDATE;
                            break;

                        case OperationType.DELETE:
                            return;
                        }
                    }
                }
                dataHandler.ReceivedSector(new AchsenSektorWrapper(axisSector));
            }
        }
コード例 #2
0
        public void CleanInsertDeletes(FileStream fileStream)
        {
            HashSet <Guid> insertset = new HashSet <Guid>();
            HashSet <Guid> deleteset = new HashSet <Guid>();

            using (XmlReader reader = XmlReader.Create(fileStream))
            {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (reader.Name == "Axis.Axis.Axis" ||
                            reader.Name == "Axis.Axis.AxisSegment" ||
                            reader.Name == "Axis.Axis.Sector")
                        {
                            XElement el = XElement.ReadFrom(reader)
                                          as XElement;
                            if (el != null)
                            {
                                MyRoot myRoot = parseMyRoot(el);
                                object item   = myRoot.Item;
                                if (item is AxisAxisAxisAxisAxis)
                                {
                                    AxisAxisAxisAxisAxis axis = (AxisAxisAxisAxisAxis)item;
                                    if (axis.OPERATIONSpecified)
                                    {
                                        switch (axis.OPERATION)
                                        {
                                        case OperationType.INSERT:
                                            insertset.Add(AchsenImportUtils.GuidFromImportString(axis.TID));
                                            break;

                                        case OperationType.DELETE:
                                            deleteset.Add(AchsenImportUtils.GuidFromImportString(axis.TID));
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        insertset.Add(AchsenImportUtils.GuidFromImportString(axis.TID));
                                    }
                                }
                                else if (item is AxisAxisAxisAxisAxisSegment)
                                {
                                    AxisAxisAxisAxisAxisSegment axisSegment = (AxisAxisAxisAxisAxisSegment)item;
                                    if (axisSegment.OPERATIONSpecified)
                                    {
                                        switch (axisSegment.OPERATION)
                                        {
                                        case OperationType.INSERT:
                                            insertset.Add(AchsenImportUtils.GuidFromImportString(axisSegment.TID));
                                            break;

                                        case OperationType.DELETE:
                                            deleteset.Add(AchsenImportUtils.GuidFromImportString(axisSegment.TID));
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        insertset.Add(AchsenImportUtils.GuidFromImportString(axisSegment.TID));
                                    }
                                }
                                else if (item is AxisAxisAxisAxisSector)
                                {
                                    AxisAxisAxisAxisSector axisSector = (AxisAxisAxisAxisSector)item;

                                    if (axisSector.OPERATIONSpecified)
                                    {
                                        switch (axisSector.OPERATION)
                                        {
                                        case OperationType.INSERT:
                                            insertset.Add(AchsenImportUtils.GuidFromImportString(axisSector.TID));
                                            break;

                                        case OperationType.DELETE:
                                            deleteset.Add(AchsenImportUtils.GuidFromImportString(axisSector.TID));
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        insertset.Add(AchsenImportUtils.GuidFromImportString(axisSector.TID));
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
            }
            foreach (Guid deleteId in deleteset)
            {
                if (insertset.Contains(deleteId))
                {
                    this.deletesToIgnore.Add(deleteId);
                }
            }
            fileStream.Seek(0, SeekOrigin.Begin);
        }