/// <summary>
        /// 数据验证
        /// </summary>
        /// <param name="complexItem"></param>
        private void ValidateData(ComplexItem complexItem)
        {
            if (complexItem.ITEM_NAME.Trim() == "")
            {
                throw new CustomException("组合项目名称不能为空");
            }

            if (complexItem.ITEM_UNIT.Trim() == "")
            {
                throw new CustomException("组合项目单位不能为空");
            }

            if (complexItem.STATITEM_CODE.Trim() == "")
            {
                throw new CustomException("统计大类不能为空");
            }

            if (complexItem.PRICE == 0)
            {
                throw new CustomException("组合项目价格不能为0");
            }

            if (complexItem.Details.Count == 0)
            {
                throw new CustomException("组合项目明细至少需要指定一个收费项目");
            }
        }
 /// <summary>
 /// Shows a detailed view for array values.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 //TODO make it visible after implementing complex values.
 private void m_CMS_View_Click(object sender, System.EventArgs e)
 {
     if (m_ItemListLV.SelectedItems.Count > 0)
     {
         ListViewItem listItem = m_ItemListLV.SelectedItems[0];
         object       tag      = listItem.Tag;
         if (tag != null && tag.GetType() == typeof(OpcDa::ItemValueResult))
         {
             OpcDa::ItemValueResult item = (OpcDa::ItemValueResult)tag;
             if (item.Value != null)
             {
                 ComplexItem complexItem = ComplexTypeCache.GetComplexItem(item);
                 if (complexItem != null)
                 {
                     EditComplexValueDlg dialog = (EditComplexValueDlg)m_viewers[listItem];
                     if (dialog == null)
                     {
                         m_viewers[listItem] = dialog = new EditComplexValueDlg();
                         dialog.Disposed    += new System.EventHandler(OnViewerClosed);
                     }
                     dialog.ShowDialog(complexItem, item.Value, true, false);
                 }
                 else if (item.Value.GetType().IsArray)
                 {
                     new EditArrayDlg().ShowDialog(item.Value, true);
                 }
             }
         }
     }
 }
Beispiel #3
0
        public void MapperPropertyReminderTests_AllPropertiesSet_AllSet_ShouldReturnTrue()
        {
            // Arange
            var complexItem = new ComplexItem
            {
                MyDateTime     = DateTime.Now,
                MyDouble       = 1d,
                MyInnerComplex = new InnerComplexItem
                {
                    MyInnerDateTime = DateTime.Now,
                    MyInnerDouble   = 1d,
                    MyInnerInt      = 1,
                    MyInnerString   = "a value"
                },
                MyInt    = 1,
                MyObject = String.Empty,
                MyString = "a value"
            };

            // Act

            // Assert

            Assert.IsTrue(MapperReminder.AllPropertiesSet(complexItem));
        }
Beispiel #4
0
 private void ViewMI_Click(object sender, System.EventArgs e)
 {
     if (this.PropertiesLV.SelectedItems.Count > 0)
     {
         object tag = this.PropertiesLV.SelectedItems[0].Tag;
         if (tag != null && tag.GetType() == typeof(ItemProperty))
         {
             ItemProperty itemProperty = (ItemProperty)tag;
             if (itemProperty.Value != null)
             {
                 if (itemProperty.ID == Property.VALUE)
                 {
                     ComplexItem complexItem = ComplexTypeCache.GetComplexItem(this.m_element);
                     if (complexItem != null)
                     {
                         new EditComplexValueDlg().ShowDialog(complexItem, itemProperty.Value, true, true);
                     }
                 }
                 else if (itemProperty.Value.GetType().IsArray)
                 {
                     new EditArrayDlg().ShowDialog(itemProperty.Value, true);
                 }
             }
         }
     }
 }
Beispiel #5
0
        public Peak_Performance.Models.Workout createWorkout()
        {
            try
            {
                Peak_Performance.Models.Workout workout = new Workout();
                workout.Team        = db.Teams.Find(this.team);
                workout.TeamID      = db.Teams.Find(this.team).ID;
                workout.WorkoutDate = this.date;

                List <Complex> complexes = new List <Complex>();
                foreach (ComplexViewModel comp in this.complexes)
                {
                    Peak_Performance.Models.Complex complex = new Complex();
                    complex.Workout = workout;
                    List <ComplexItem> complexItems = new List <ComplexItem>();
                    foreach (ExerciseViewModel ex in comp.complex)
                    {
                        if (db.Exercises.FirstOrDefault(e => e.Name == ex.name) != null)
                        {
                            Peak_Performance.Models.ComplexItem item = new ComplexItem();
                            item.Complex     = complex;
                            item.Exercis     = db.Exercises.FirstOrDefault(e => e.Name == ex.name);
                            item.ComplexReps = ex.reps;
                            item.ComplexSets = ex.sets;
                            item.LiftWeight  = ex.weight;
                            item.RunDistance = ex.distance;
                            item.RunSpeed    = ex.speed;
                            item.RunTime     = ex.time;
                            complexItems.Add(item);
                            db.ComplexItems.Add(item);
                        }
                        else
                        {
                            Peak_Performance.Models.ComplexItem item = new ComplexItem();
                            item.Complex      = complex;
                            item.ExerciseName = ex.name;
                            item.ComplexReps  = ex.reps;
                            item.ComplexSets  = ex.sets;
                            item.LiftWeight   = ex.weight;
                            item.RunDistance  = ex.distance;
                            item.RunSpeed     = ex.speed;
                            item.RunTime      = ex.time;
                            complexItems.Add(item);
                            db.ComplexItems.Add(item);
                        }
                    }
                    complex.ComplexItems = complexItems;
                    complexes.Add(complex);
                    db.Complexes.Add(complex);
                }
                workout.Complexes = complexes;
                db.Workouts.Add(workout);
                db.SaveChanges();
                return(workout);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #6
0
        public void MapperPropertyReminderTests_AllPropertiesSet_AllDefault_ShouldReturnFalse()
        {
            // Arange
            var complexItem = new ComplexItem();

            // Act

            // Assert
            Assert.IsFalse(MapperReminder.AllPropertiesSet(complexItem));
        }
Beispiel #7
0
        public void ComplexValue()
        {
            var expression    = Utils.CreateEmptyExpression();
            var serialization = Utils.GetSerialization(expression);
            var value         = new ComplexItem();
            var listItem      = new CollectionItemEntity(expression, 0, value);
            var result        = listItem.ToString();

            Assert.Equal($"[0].{value.GetHashCode()}", result);
        }
            public FindScopeInsertionEdits(ComplexItem root) : base(root)
            {
                // Before we start, we need to know the full set of keyframe names declared in this document
                var keyframesIdentifiersVisitor = new FindKeyframesIdentifiersVisitor(root);

                keyframesIdentifiersVisitor.Visit();
                _keyframeIdentifiers = keyframesIdentifiersVisitor.KeyframesIdentifiers
                                       .Select(x => x.Text)
                                       .ToHashSet(StringComparer.Ordinal); // Keyframe names are case-sensitive
            }
Beispiel #9
0
        public void Value_Null()
        {
            var expression    = Utils.CreateEmptyExpression();
            var serialization = Utils.GetSerialization(expression);

            this.field = null;
            var fieldEntity = new FieldEntity(expression, this, GetFieldByName("field"));
            var result      = fieldEntity.ToString();

            Assert.Equal("field", result);
        }
        private int FindFirstCleanTokenAfterParent(ComplexItem parentItem)
        {
            int tokenIndex = Tokens.FindInsertIndex(parentItem.AfterEnd, beforeExisting: true);

            // Have to skip comments because that's what the token stream will do while parsing
            while (tokenIndex < Tokens.Count && Tokens[tokenIndex].IsComment)
            {
                tokenIndex++;
            }

            return(tokenIndex);
        }
Beispiel #11
0
        public void Value_Null_Parent_WithoutType()
        {
            var expression    = Utils.CreateEmptyExpression();
            var serialization = Utils.GetSerialization(expression);

            serialization.ShowType = ShowTypeOptions.None;

            this.field = null;
            var fieldEntity = new FieldEntity(expression, null, GetFieldByName("field"));
            var result      = fieldEntity.ToString();

            Assert.Equal("field", result);
        }
        /// <summary>
        /// Find the item that will contain all of the incremental parsing changes.
        /// This never returns null.
        /// </summary>
        private IIncrementalParseItem GetIncrementalParseParent(int start, int length)
        {
            for (ComplexItem item = StyleSheet.ComplexItemFromRange(start, length); item != null; item = item.Parent)
            {
                if (item is IIncrementalParseItem)
                {
                    return((IIncrementalParseItem)item);
                }
            }

            // Could be typing in whitespace outside all items, so try using the root StyleSheet
            return(StyleSheet);
        }
        /// <summary>
        /// Returns the child index for the first item that will be replaced by incremental parsing.
        /// </summary>
        private int FindFirstChildToReparse(ComplexItem parentItem, int firstDirtyTokenIndex)
        {
            CssToken token = Tokens[firstDirtyTokenIndex];

            int childIndex = parentItem.Children.FindInsertIndex(token.Start, beforeExisting: true);

            if (childIndex > 0)
            {
                // Always go to the previous child because it might want to use the new tokens.
                childIndex--;
            }

            return(childIndex);
        }
Beispiel #14
0
        public void MapperPropertyReminderTests_AllPropertiesSet_DefaultStringProperty_ShouldReturnFalse()
        {
            // Arange
            var complexItem = new ComplexItem
            {
                MyDateTime     = DateTime.Now,
                MyDouble       = 1d,
                MyInnerComplex = new InnerComplexItem(),
                MyInt          = 1,
                MyObject       = String.Empty,
            };

            // Act

            // Assert
            Assert.IsFalse(MapperReminder.AllPropertiesSet(complexItem));
        }
        /// <summary>
        /// Returns the child index for the first item that was unchanged by the token update.
        /// </summary>
        private int FindFirstCleanChild(ComplexItem parentItem, int firstCleanTokenIndex)
        {
            int childIndex = parentItem.Children.Count;

            if (firstCleanTokenIndex < Tokens.Count)
            {
                CssToken token = Tokens[firstCleanTokenIndex];

                // The parent must contain the token (the root StyleSheet contains everything)
                if (parentItem.Parent == null || parentItem.ContainsRange(token.Start, token.Length))
                {
                    childIndex = parentItem.Children.FindInsertIndex(token.Start, beforeExisting: true);
                }
            }

            return(childIndex);
        }
        private int FindTokenToStartParsing(ComplexItem parent, int child)
        {
            if (parent.Parent == null && child == 0)
            {
                // The user typed in the whitespace before the start of the root StyleSheet node.
                // Always start parsing from the first token.
                return(0);
            }

            if (child >= parent.Children.Count)
            {
                // Only hit when there are no children (like when typing in a blank StyleSheet)
                return(Tokens.FindInsertIndex(parent.AfterEnd, beforeExisting: true));
            }

            return(Tokens.FindInsertIndex(parent.Children[child].Start, beforeExisting: true));
        }
Beispiel #17
0
 private void ViewComplexType(System.Windows.Forms.TreeNode node)
 {
     if (this.IsBrowseElementNode(node))
     {
         try
         {
             ComplexItem complexItem = ComplexTypeCache.GetComplexItem((BrowseElement)node.Tag);
             if (complexItem != null)
             {
                 new EditComplexValueDlg().ShowDialog(complexItem, null, true, true);
             }
         }
         catch (System.Exception ex)
         {
             System.Windows.Forms.MessageBox.Show(ex.Message);
         }
     }
 }
        internal static ParseItem ParseNumber(ComplexItem parent, ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            ParseItem pv;

            if (tokens.Peek(1).TokenType == CssTokenType.Units)
            {
                pv = itemFactory.Create <UnitValue>(parent);
            }
            else
            {
                pv = itemFactory.Create <NumericalValue>(parent);
            }

            if (pv != null && !pv.Parse(itemFactory, text, tokens))
            {
                pv = null;
            }

            return(pv);
        }
Beispiel #19
0
        private void WriteComplexItem(ITextProvider textProvider, ComplexItem ci, bool dumpClassifications)
        {
            Type type = ci.GetType();

            _sb.Append(' ', _indent * 4);
            _sb.Append(type.Name);
            WriteParseErrors(ci);
            _sb.Append("\r\n");

            _indent++;

            foreach (ParseItem p in ci.Children)
            {
                WriteItem(textProvider, p, dumpClassifications);
            }

            if (_indent > 0)
            {
                _indent--;
            }
        }
        /// <summary>
        /// 增加一个组合项目
        /// </summary>
        public void AddComplexItem()
        {
            try
            {
                ComplexItem complexItem = new ComplexItem();
                complexItem.ITEM_NAME     = formView.Complex_Name;
                complexItem.ITEM_UNIT     = formView.Complex_Item_Unit;
                complexItem.PRICE         = formView.Complex_Price;
                complexItem.PY_CODE       = formView.Complex_Py_Code;
                complexItem.WB_CODE       = formView.Complex_Wb_Code;
                complexItem.STATITEM_CODE = formView.Complex_Statitem_Code;
                complexItem.VALID_FLAG    = formView.Complex_Valid_Flag;
                complexItem.Details       = formView.ComplexDetail;

                ServiceItemController controller = new ServiceItemController();
                controller.AddComplexItemByHospital(complexItem);
            }
            catch (Exception err)
            {
                throw err;
            }
        }
 /// <summary>
 /// Shows a detailed view for array values.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void ViewMI_Click(object sender, System.EventArgs e)
 {
     if (ItemListLV.SelectedItems.Count > 0)
     {
         object tag = ItemListLV.SelectedItems[0].Tag;
         if (tag != null && tag.GetType() == typeof(OpcDa::ItemValueResult))
         {
             OpcDa::ItemValueResult item = (OpcDa::ItemValueResult)tag;
             if (item.Value != null)
             {
                 ComplexItem complexItem = ComplexTypeCache.GetComplexItem(item);
                 if (complexItem != null)
                 {
                     new EditComplexValueDlg().ShowDialog(complexItem, item.Value, true, true);
                 }
                 else if (item.Value.GetType().IsArray)
                 {
                     new EditArrayDlg().ShowDialog(item.Value, true);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Inserts comments into the StyleSheet that were in the range of changed text
        /// </summary>
        private void InsertComments(IEnumerable <Comment> comments, IList <ParseItem> newChildren)
        {
            if (comments != null)
            {
                foreach (ParseItem comment in comments)
                {
                    ComplexItem parent = StyleSheet.ComplexItemFromRange(comment.Start, comment.Length) ?? StyleSheet;

                    if (!(parent is Comment))
                    {
                        parent.InsertChildIntoSubtree(comment);

                        // Don't save the comment if its parent or itself is already in the list
                        bool alreadyAdded = false;

                        for (ParseItem commentParent = comment; commentParent != null; commentParent = commentParent.Parent)
                        {
                            if (newChildren.Contains(commentParent))
                            {
                                alreadyAdded = true;
                                break;
                            }
                        }

                        if (!alreadyAdded)
                        {
                            newChildren.Add(comment);
                        }
                    }
                    else // the comment is already in the tree, so we passed the reparsed text
                    {
                        Debug.Assert(parent.Start == comment.Start && parent.Length == comment.Length);
                        break;
                    }
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// Called when the edit array button is clicked.
        /// </summary>
        private void EditBTN_Click(object sender, System.EventArgs e)
        {
            try
            {
                object value = null;

                ComplexItem complexItem = ComplexTypeCache.GetComplexItem(m_itemID);

                if (complexItem != null)
                {
                    value = new EditComplexValueDlg().ShowDialog(complexItem, m_value, m_readOnly, true);
                }

                else if (m_value.GetType().IsArray)
                {
                    value = new EditArrayDlg().ShowDialog(m_value, m_readOnly);
                }

                if (m_readOnly || value == null)
                {
                    return;
                }

                // update the array.
                Set(value, m_readOnly);

                // send change notification.
                if (ValueChanged != null)
                {
                    ValueChanged(this, m_value);
                }
            }
            catch (System.Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Beispiel #24
0
            private void VisitDescendants(ComplexItem container)
            {
                foreach (var child in container.Children)
                {
                    switch (child)
                    {
                    case Selector selector:
                        VisitSelector(selector);
                        break;

                    case AtDirective atDirective:
                        VisitAtDirective(atDirective);
                        break;

                    case Declaration declaration:
                        VisitDeclaration(declaration);
                        break;

                    default:
                        VisitDefault(child);
                        break;
                    }
                }
            }
        public static ParseItem ParseUnknown(
            ComplexItem parent,
            ItemFactory itemFactory,
            ITextProvider text,
            TokenStream tokens,
            ParseErrorType?errorType = null)
        {
            ParseItem pi            = null;
            bool      alreadyParsed = false;

            // For a single unknown token, let this switch fall through where a
            // ParseErrorItem will get created. For multiple unknown tokens, deal with
            // them in this switch and let them automatically get wrapped in an unknown block.

            CssClassifierContextType contextType = CssClassifierContextType.Default;

            switch (tokens.CurrentToken.TokenType)
            {
            case CssTokenType.Url:
                pi = itemFactory.Create <UrlItem>(parent);
                break;

            case CssTokenType.Function:
                pi            = Function.ParseFunction(parent, itemFactory, text, tokens);
                alreadyParsed = true;
                break;

            case CssTokenType.OpenFunctionBrace:
            case CssTokenType.OpenSquareBracket:
            case CssTokenType.OpenCurlyBrace:
                pi = itemFactory.Create <UnknownBlock>(parent);
                break;

            case CssTokenType.String:
            case CssTokenType.MultilineString:
            case CssTokenType.InvalidString:
                contextType = CssClassifierContextType.String;
                break;
            }

            if (pi == null)
            {
                pi = new TokenItem(tokens.CurrentToken, contextType);
            }

            if (!alreadyParsed && !pi.Parse(itemFactory, text, tokens))
            {
                Debug.Fail("Parse of an unknown item failed.");

                // I've done all I can do to deal with this unknown token, but now
                // it must be totally ignored so that parsing doesn't get into an infinite loop.
                tokens.AdvanceToken();
                pi = null;
            }

            if (pi != null && errorType.HasValue)
            {
                pi.AddParseError(errorType.Value, ParseErrorLocation.WholeItem);
            }

            return(pi);
        }
 protected virtual ParseItem CreateArgumentObject(ComplexItem parent, ItemFactory itemFactory, int argumentNumber)
 {
     return(itemFactory.Create <FunctionArgument>(this));
 }
        internal static Function ParseFunction(ComplexItem parent, ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            Function fn;

            if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "rgb(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionColor>(parent);
                ((FunctionColor)fn).ColorFunction = ColorFunctionType.Rgb;
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "rgba(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionColor>(parent);
                ((FunctionColor)fn).ColorFunction = ColorFunctionType.Rgba;
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "hsl(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionColor>(parent);
                ((FunctionColor)fn).ColorFunction = ColorFunctionType.Hsl;
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "hsla(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionColor>(parent);
                ((FunctionColor)fn).ColorFunction = ColorFunctionType.Hsla;
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "attr(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionAttr>(parent);
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "calc(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionCalc>(parent);
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "counter(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionCounter>(parent);
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "expression(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionExpression>(parent);
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "format(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionFormat>(parent);
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "local(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionLocal>(parent);
            }
            else if (TextRange.CompareDecoded(tokens.CurrentToken.Start, tokens.CurrentToken.Length, text, "var(", ignoreCase: true))
            {
                fn = itemFactory.CreateSpecific <FunctionVar>(parent);
            }
            else
            {
                fn = itemFactory.CreateSpecific <Function>(parent);
            }

            if (fn != null && !fn.Parse(itemFactory, text, tokens))
            {
                fn = null;
            }

            return(fn);
        }
Beispiel #28
0
 public Visitor(ComplexItem root)
 {
     _root = root ?? throw new ArgumentNullException(nameof(root));
 }
Beispiel #29
0
 public EnsureNoImports(string filePath, SourceText sourceText, ComplexItem root, List <RazorDiagnostic> diagnostics) : base(root)
 {
     _filePath    = filePath;
     _sourceText  = sourceText;
     _diagnostics = diagnostics;
 }
Beispiel #30
0
 public FindKeyframesIdentifiersVisitor(ComplexItem root) : base(root)
 {
 }