private IEnumerable <LogModel> PagingCatCountry(CategoryCriteria criteria, int page, int size, out long rowsCount)
        {
            string valueName, valueCode;

            valueName = valueCode = criteria.Query != null?criteria.Query.ToLower() : "";

            Expression <Func <CatCountryLog, bool> > countryEx = x => (x.NewObject.NameEn.ToLower().Contains(valueName) ||
                                                                       x.NewObject.Code.ToLower().Contains(valueCode)) &&
                                                                 (x.PropertyCommon.DatetimeModified >= criteria.FromDate || criteria.FromDate == null) &&
                                                                 (x.PropertyCommon.DatetimeModified <= criteria.ToDate || criteria.ToDate == null);
            var filterCountry = Builders <CatCountryLog> .Filter.Where(countryEx);

            var queryCurrencyResult = mongoContext.CatCountries.Find(filterCountry);

            rowsCount = queryCurrencyResult.CountDocuments();
            var data = queryCurrencyResult.Skip(page * size).Limit(size).ToList().Select(x => new LogModel
            {
                Id              = x.Id,
                UserUpdated     = x.PropertyCommon.UserModified,
                Action          = ConvertAction.ConvertLinqAction(x.PropertyCommon.ActionType),
                DatetimeUpdated = x.PropertyCommon.DatetimeModified,
                PropertyChange  = x.PropertyCommon.PropertyChange,
                ObjectId        = x.NewObject.Id.ToString(),
                Name            = x.NewObject.Code ?? x.NewObject.NameEn,
                Code            = int.TryParse(x.NewObject?.Id.ToString(), out int n) == true ? null : x.NewObject?.Id.ToString()
            });
Exemplo n.º 2
0
        private static IEnumerable <Selection> UnsupportedParserFeatureAutosplitToFile(
            AbstractTableWriter writer, string output, IEnumerable <Selection> selections)
        {
            var outputOptions = output.Split(new[] { "#" }, StringSplitOptions.RemoveEmptyEntries);

            if (outputOptions.Length != 2)
            {
                return(null);
            }

            var form = outputOptions[0];
            var path = outputOptions[1];
            var dir  = Path.GetDirectoryName(path);
            var nam  = Path.GetFileNameWithoutExtension(path);
            var ext  = Path.GetExtension(path);

            if (!string.IsNullOrWhiteSpace(dir) && !Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            var export = new ConvertAction();

            foreach (var cluster in selections)
            {
                export.Execute(cluster,
                               new[] { $"{form}#\"{Path.Combine(dir, $"{nam}_{cluster.Displayname.EnsureFileName()}{ext}")}\"" },
                               writer);
            }

            return(null);
        }
        private IEnumerable <LogModel> PagingCatStage(CategoryCriteria criteria, int page, int size, out long rowsCount)
        {
            Expression <Func <CatStageLog, bool> > stageEx = x => x.NewObject.Code.Contains(criteria.Query ?? "") &&
                                                             x.NewObject.StageNameEn.Contains(criteria.Query ?? "") &&
                                                             (x.PropertyCommon.DatetimeModified >= criteria.FromDate || criteria.FromDate == null) &&
                                                             (x.PropertyCommon.DatetimeModified <= criteria.ToDate || criteria.ToDate == null);
            var filterStage = Builders <CatStageLog> .Filter.Where(stageEx);

            var queryCurrencyResult = mongoContext.CatStages.Find(filterStage);

            rowsCount = queryCurrencyResult.CountDocuments();
            var data = queryCurrencyResult.Skip(page * size).Limit(size).ToList().Select(x => new LogModel
            {
                Id              = x.Id,
                UserUpdated     = x.PropertyCommon.UserModified,
                Action          = ConvertAction.ConvertLinqAction(x.PropertyCommon.ActionType),
                DatetimeUpdated = x.PropertyCommon.DatetimeModified,
                PropertyChange  = x.PropertyCommon.PropertyChange,
                ObjectId        = x.NewObject.Id.ToString(),
                Name            = x.NewObject.StageNameEn,
                Code            = null
            });

            return(data);
        }
Exemplo n.º 4
0
        private static IEnumerable <Selection> UnsupportedParserRandomFeatureToFile(
            AbstractTableWriter writer, string output, RandomSelectionBlock block)
        {
            var outputOptions = output.Split(new[] { "#" }, StringSplitOptions.RemoveEmptyEntries);

            if (outputOptions.Length != 2)
            {
                return(null);
            }

            var export = new ConvertAction();

            export.Execute(block.RandomSelection, new[] { output }, writer);

            var form = outputOptions[0];
            var path = outputOptions[1];
            var nam  = Path.GetFileNameWithoutExtension(path);
            var ext  = Path.GetExtension(path);
            var dir  = Path.GetDirectoryName(path);

            if (!string.IsNullOrWhiteSpace(dir) && !Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            export.Execute(block.RandomInvertSelection, new[] { $"{form}#\"{Path.Combine(dir, $"{nam}_inverse{ext}")}\"" },
                           writer);
            return(null);
        }
Exemplo n.º 5
0
            public override MetaObject Convert(ConvertAction action, MetaObject[] args)
            {
                if (ImplementsActions(StandardActionKinds.Convert))
                {
                    return(CallMethodUnary(action, "Convert"));
                }

                return(base.Convert(action, args));
            }
Exemplo n.º 6
0
    static List <T> ConvertTypes <U, T>(IEnumerable <U> inp, ConvertAction <U, T> action)
    {
        List <T> res = new List <T>();

        foreach (U val in inp)
        {
            res.Add(action(val));
        }
        return(res);
    }
Exemplo n.º 7
0
        protected override object Convert(ConvertAction action)
        {
            Type targetType = action.ToType;

            if (targetType == typeof(IEnumerable)) {
                return this;
            }

            return base.Convert(action);
        }
Exemplo n.º 8
0
 public override MetaObject Convert(ConvertAction action, MetaObject[] args)
 {
     return new MetaObject(
         Expression.Call(
             Expression.Convert(Expression, LimitType),
             typeof(Duck).GetMethod("Convert", new Type[] { typeof(ConvertAction) }),
             Expression.Constant(action)
         ),
         Restrictions.TypeRestriction(Expression, LimitType)
     );
 }
        private IEnumerable <LogModel> PagingCatPlace(CategoryCriteria criteria, int page, int size, out long rowsCount)
        {
            string type = string.Empty;

            switch (criteria.TableType)
            {
            case CategoryTable.Warehouse:
                type = CatPlaceConstant.Warehouse;
                break;

            case CategoryTable.PortIndex:
                type = CatPlaceConstant.Port;
                break;

            case CategoryTable.Province:
                type = CatPlaceConstant.Province;
                break;

            case CategoryTable.District:
                type = CatPlaceConstant.District;
                break;

            case CategoryTable.Ward:
                type = CatPlaceConstant.Ward;
                break;
            }
            Expression <Func <CatPlaceLog, bool> > placeEx = x => x.NewObject.Code.Contains(criteria.Query ?? "") &&
                                                             x.NewObject.NameEn.Contains(criteria.Query ?? "") &&
                                                             (x.PropertyCommon.DatetimeModified >= criteria.FromDate || criteria.FromDate == null) &&
                                                             (x.PropertyCommon.DatetimeModified <= criteria.ToDate || criteria.ToDate == null) &&
                                                             (x.NewObject.PlaceTypeId.Contains(type ?? ""));
            var filterPlace = Builders <CatPlaceLog> .Filter.Where(placeEx);

            var queryCurrencyResult = mongoContext.CatPlaces.Find(filterPlace);

            rowsCount = queryCurrencyResult.CountDocuments();
            var data = queryCurrencyResult.Skip(page * size).Limit(size).ToList().Select(x => new LogModel
            {
                Id              = x.Id,
                UserUpdated     = x.PropertyCommon.UserModified,
                Action          = ConvertAction.ConvertLinqAction(x.PropertyCommon.ActionType),
                DatetimeUpdated = x.PropertyCommon.DatetimeModified,
                PropertyChange  = x.PropertyCommon.PropertyChange,
                ObjectId        = x.NewObject.Id.ToString(),
                Name            = x.NewObject?.NameEn,
                Code            = x.NewObject?.Code
            });

            return(data);
        }
        private IEnumerable <LogModel> PagingCatCurrencyExchange(CategoryCriteria criteria, int page, int size, out long rowsCount)
        {
            var filterCurrencyExchange = Builders <CatCurrencyExchangeLog> .Filter.Where(_ => true);

            var queryCurrencyResult = mongoContext.CatCurrencyExchanges.Find(filterCurrencyExchange);

            rowsCount = queryCurrencyResult.CountDocuments();
            var data = queryCurrencyResult.Skip(page * size).Limit(size).ToList().Select(x => new LogModel
            {
                Id              = x.Id,
                UserUpdated     = x.PropertyCommon.UserModified,
                Action          = ConvertAction.ConvertLinqAction(x.PropertyCommon.ActionType),
                DatetimeUpdated = x.PropertyCommon.DatetimeModified,
                PropertyChange  = x.PropertyCommon.PropertyChange,
                ObjectId        = x.NewObject.Id.ToString(),
                Name            = x.NewObject.CurrencyFromId
            });

            return(data);
        }
Exemplo n.º 11
0
        internal MaterialHierarchyPopup(Object[] targets)
        {
            this.targets = targets;
            target       = targets[0] as Material;
            targetGUID   = AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(target));

            k_MinNameWidth = k_MinWindowWidth - (k_TitleWidth + k_SplitWidth + k_OverridesWidth + k_LocksWidth);
            k_MaxNameWidth = k_MaxWindowWidth - (k_TitleWidth + k_SplitWidth + k_OverridesWidth + k_LocksWidth);

            convertState = ConvertAction.None;
            searchFilter = new SearchFilter()
            {
                classNames = new string[] { "Material" },
                searchArea = SearchFilter.SearchArea.AllAssets
            };
            debounce = Delayer.Debounce(_ =>
            {
                SearchFilterChanged();
                editorWindow.Repaint();
            });

            Init();
        }
Exemplo n.º 12
0
        public override void OnGUI(Rect rect)
        {
            // Escape closes the window
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                editorWindow.Close();
                GUIUtility.ExitGUI();
            }

            if (!DrawHeader())
            {
                return;
            }

            float height = k_HeaderHeight;

            if (target.isVariant)
            {
                height += DrawVariantHierarchy();
            }

            height += DrawChildrenLabel(height);

            if (displayChildren)
            {
                DrawChildren(height);
            }

            if (convertState == ConvertAction.Flatten)
            {
                convertState = ConvertAction.None;
                Undo.RecordObject(target, "Flatten Material Variant");
                target.parent = null;
                Init();
            }
        }
Exemplo n.º 13
0
Arquivo: Duck.cs Projeto: dun3/dun3
 public virtual object Convert(ConvertAction action)
 {
     return Generator.GenerateProxy(action.ToType, this);
 }
Exemplo n.º 14
0
 /// <summary>
 /// When overridden in a derived class provides the non-Meta implementation of converting the
 /// Dynamic object to another type.
 /// 
 /// When not overridden the call site requesting the action determines the behavior.
 /// </summary>
 protected virtual object Convert(ConvertAction action)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 15
0
            public override MetaObject Convert(ConvertAction action, MetaObject[] args)
            {
                if (ImplementsActions(StandardActionKinds.Convert)) {
                    return CallMethodUnary(action, "Convert");
                }

                return base.Convert(action, args);
            }
Exemplo n.º 16
0
        bool DrawHeader()
        {
            Rect headerRect = GUILayoutUtility.GetRect(20, windowWidth, k_HeaderHeight, k_HeaderHeight);

            EditorGUI.DrawRect(headerRect, Colors.headerBackground);

            float labelSize = Styles.boldRightAligned.CalcSize(Styles.instanceLabel).x;

            Rect labelRect   = new Rect(k_OffsetX, headerRect.y + k_Padding, labelSize, EditorGUIUtility.singleLineHeight);
            Rect contentRect = new Rect(labelRect.x + labelRect.width + k_Padding, labelRect.y, windowWidth, labelRect.height);

            GUI.Label(labelRect, Styles.instanceLabel, Styles.boldRightAligned);
            DoObjectLabel(contentRect, target, EditorStyles.boldLabel);

            labelRect.y = labelRect.height + 2 * k_Padding;
            if (convertState == ConvertAction.None)
            {
                labelRect.width = k_ConvertLabelWidth;
                int result = EditorGUI.Popup(labelRect, target.isVariant ? 1 : 0, Styles.headerPopupOptions);
                if (result == 0 && target.isVariant)
                {
                    convertState = ConvertAction.Flatten;
                }
                if (result == 1 && !target.isVariant)
                {
                    convertState = ConvertAction.Convert;
                }
            }
            else if (convertState == ConvertAction.Convert)
            {
                GUI.enabled     = false;
                labelRect.width = 200f;
                EditorGUI.Button(labelRect, Styles.convertingLabel);
                GUI.enabled = true;

                // Conversion helper
                labelRect.y     = k_HeaderHeight;
                labelRect.width = windowWidth;
                EditorGUI.LabelField(labelRect, Styles.conversionHelpLabel);

                labelRect.x = windowWidth - 14;
                if (GUI.Button(labelRect, GUIContent.none, EditorStyles.toolbarSearchFieldCancelButton))
                {
                    convertState = ConvertAction.None;
                }

                labelRect.x = k_OffsetX;
                var oldLabelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 70;
                EditorGUI.BeginChangeCheck();
                var parent = target.parent;
                MaterialEditor.ParentField(new Rect(k_OffsetX, labelRect.yMax + k_Padding, windowWidth - 2 * k_OffsetX, k_EntryHeight), targets);
                if (EditorGUI.EndChangeCheck() && parent != target.parent)
                {
                    convertState = ConvertAction.None;
                    Init();
                }
                EditorGUIUtility.labelWidth = oldLabelWidth;
                return(false);
            }

            return(true);
        }
Exemplo n.º 17
0
 /// <summary>
 /// When overridden in a derived class provides the non-Meta implementation of converting the
 /// Dynamic object to another type.
 ///
 /// When not overridden the call site requesting the action determines the behavior.
 /// </summary>
 protected virtual object Convert(ConvertAction action)
 {
     throw new NotSupportedException();
 }