示例#1
0
        private void OnEditCategoryItems(string value)
        {
            if (SelectedCategory != null)
            {
                IList <IOrderable> values = new List <IOrderable>(_workspace.All <MenuItem>().OrderBy(x => x.GroupCode + x.Name)
                                                                  .Where(x => !SelectedCategory.ContainsMenuItem(x))
                                                                  .Select(x => new ScreenMenuItem {
                    MenuItemId = x.Id, Name = x.Name, MenuItem = x
                }));

                SelectedCategory.ScreenMenuItems.ToList().ForEach(x => x.MenuItem = Dao.SingleWithCache <MenuItem>(y => y.Id == x.MenuItemId));

                IList <IOrderable> selectedValues = new List <IOrderable>(SelectedCategory.ScreenMenuItems);

                var choosenValues = InteractionService.UserIntraction.ChooseValuesFrom(values, selectedValues, Resources.ProductList,
                                                                                       string.Format(Resources.AddProductsToCategoryHint_f, SelectedCategory.Name), Resources.Product, Resources.Products);

                foreach (var screenMenuItem in SelectedCategory.ScreenMenuItems.ToList())
                {
                    if (!choosenValues.Contains(screenMenuItem) && screenMenuItem.Id > 0)
                    {
                        _workspace.Delete(screenMenuItem);
                    }
                }

                SelectedCategory.ScreenMenuItems.Clear();

                foreach (ScreenMenuItem item in choosenValues)
                {
                    SelectedCategory.ScreenMenuItems.Add(item);
                }

                SelectedCategory.UpdateDisplay();
            }
        }
示例#2
0
 public void RemoveListOfObjects <T>(T[] items) where T : class
 {
     for (int i = 0; i < items.Length; i++)
     {
         _workspace.Delete <T>(items[i]);
     }
 }
示例#3
0
 private void OnDeleteTransactionItem(string obj)
 {
     if (SelectedTransactionItem.Model.Id > 0)
     {
         _workspace.Delete(SelectedTransactionItem.Model);
     }
     Model.TransactionItems.Remove(SelectedTransactionItem.Model);
     TransactionItems.Remove(SelectedTransactionItem);
 }
示例#4
0
 public void RemoveTicketItems(IEnumerable <TicketItem> selectedItems)
 {
     foreach (var ticketItem in selectedItems)
     {
         Ticket.TicketItems.Remove(ticketItem);
         if (Ticket.Id > 0)
         {
             ticketItem.Properties.ToList().ForEach(_workspace.Delete);
             _workspace.Delete(ticketItem);
         }
     }
 }
示例#5
0
        private void OnSelectActions(string obj)
        {
            IList <IOrderable> selectedValues = new List <IOrderable>(Model.Actions);
            var selectedIds           = selectedValues.Select(x => ((ActionContainer)x).AppActionId);
            IList <IOrderable> values = new List <IOrderable>(_workspace.All <AppAction>(x => !selectedIds.Contains(x.Id)).Select(x => new ActionContainer(x)));

            var choosenValues = InteractionService.UserIntraction.ChooseValuesFrom(values, selectedValues, Resources.ActionList,
                                                                                   Resources.SelectActions, Resources.Action, Resources.Actions);

            foreach (var action in Model.Actions.ToList())
            {
                var laction = action;
                if (choosenValues.FirstOrDefault(x => ((ActionContainer)x).AppActionId == laction.AppActionId) == null)
                {
                    if (action.Id > 0)
                    {
                        _workspace.Delete(action);
                    }
                }
            }

            Model.Actions.Clear();
            choosenValues.Cast <ActionContainer>().ToList().ForEach(x => Model.Actions.Add(x));
            _actions = new ObservableCollection <ActionContainerViewModel>(Model.Actions.Select(x => new ActionContainerViewModel(x, this)));

            RaisePropertyChanged("Actions");
        }
示例#6
0
        /// <summary>
        ///     Exports the source table using the query filter to the table in the output workspace.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="tableName">Name of the output table.</param>
        /// <param name="workspace">The output workspace.</param>
        /// <param name="requiredFields">The required fields.</param>
        /// <param name="handle">The handle.</param>
        /// <param name="surrogate">The surrogate for the event handler.</param>
        /// <param name="invalid">The errors that occured during the export.</param>
        /// <param name="errors">The field errors.</param>
        /// <returns>
        ///     Returns a <see cref="IFeatureClass" /> representing the feature class that was exported.
        /// </returns>
        public static ITable Export(this ITable source, IQueryFilter filter, string tableName, IWorkspace workspace, IFields requiredFields, int handle, FeatureProgress surrogate, out IEnumInvalidObject invalid, out IEnumFieldError errors)
        {
            var ds    = (IDataset)source;
            var input = ds.Workspace.Define(ds.Name, new TableNameClass());

            var output = workspace.Define(tableName, new TableNameClass());

            workspace.Delete(output);

            IFieldChecker fieldChecker = new FieldCheckerClass();

            fieldChecker.InputWorkspace    = ds.Workspace;
            fieldChecker.ValidateWorkspace = workspace;

            IFields targetFields;

            fieldChecker.Validate(requiredFields, out errors, out targetFields);

            var featureDataConverter = new FeatureDataConverterClass();

            if (surrogate != null)
            {
                surrogate.Advise(featureDataConverter);
            }

            invalid = featureDataConverter.ConvertTable(input, filter, null, output, targetFields, "", 1000, handle);

            return(((IName)output).Open() as ITable);
        }
示例#7
0
        void IProductRepository.Delete(int id)
        {
            var product = _workspace.Get <Product, int>(id);

            _workspace.Delete(product);
            _workspace.SaveChanges();
        }
示例#8
0
        public Task DeleteAsync(User user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            foreach (var userRole in user.Roles.ToArray())
            {
                _workspace.Delete(userRole);
            }

            _workspace.Delete(user);
            _workspace.SaveChanges();
            return(Task.FromResult(0));
        }
示例#9
0
文件: Route.cs 项目: wey12138/Wave
        /// <summary>
        ///     Converts the event route source to a stand-alone feature class.
        /// </summary>
        /// <param name="outputTableName">The name of the output feature class.</param>
        /// <param name="filter">The filter used to limit the number of features converted.</param>
        /// <param name="workspace">The workspace that will contain the feature class.</param>
        /// <returns>
        ///     Returns a <see cref="IFeatureClass" /> representing the results of the conversion.
        /// </returns>
        public IFeatureClass Convert(string outputTableName, IQueryFilter filter, IWorkspace workspace)
        {
            var source      = (IFeatureClass)this.FeatureClass;
            var geometryDef = ((IClone)source.GetGeometryDef()) as IGeometryDef;

            IFieldChecker   checker = new FieldCheckerClass();
            IEnumFieldError errors;
            IFields         fields;

            checker.InputWorkspace    = workspace;
            checker.ValidateWorkspace = workspace;
            checker.Validate(source.Fields, out errors, out fields);

            var outputClassName = workspace.Define(outputTableName, new FeatureClassNameClass());

            workspace.Delete(outputClassName);

            var dataConverter  = new FeatureDataConverterClass();
            var invalidObjects = dataConverter.ConvertFeatureClass((IDatasetName)this.Name, filter, null, null, outputClassName, geometryDef, fields, "", 1000, 0);

            if (invalidObjects.AsEnumerable().Any())
            {
                return(null);
            }

            var route = workspace.GetFeatureClass(outputTableName);

            return(route);
        }
        void ICategoryRepository.Delete(int id)
        {
            var product = _workspace.Get <Category, int>(id);

            _workspace.Delete(product);
            _workspace.SaveChanges();
        }
示例#11
0
 private void OnDeleteMap(string obj)
 {
     if (SelectedMap.Id > 0)
     {
         _workspace.Delete(SelectedMap.Model);
     }
     _itemsSource.Remove(SelectedMap.Model);
     Maps.Remove(SelectedMap);
 }
示例#12
0
 public void RemoveWidget(Widget widget)
 {
     if (_resoureceWorkspace == null)
     {
         return;
     }
     _resoureceWorkspace.Delete <Widget>(x => x.Id == widget.Id);
     _resoureceWorkspace.CommitChanges();
 }
示例#13
0
文件: Route.cs 项目: wey12138/Wave
        /// <summary>
        ///     Locates the polygon features along the route and writes the result to a new line event table.
        /// </summary>
        /// <param name="locatePolygonsAlongRouteName">Name of the locate polygons along route.</param>
        /// <param name="polygons">The polygons to locate.</param>
        /// <param name="keepZeroLengthEvents">
        ///     if set to <c>true</c> allows you to keep or not keep the zero length line events in
        ///     the output event table.  The zero length line events result from a case where the geometric intersection of the
        ///     route (line) and the polygon is a point.
        /// </param>
        /// <param name="properties">
        ///     Parameter consisting of the route location fields and the type of events that will be written
        ///     to the output event table.
        /// </param>
        /// <param name="filter">An optional filter used to use a subset of the polygon data.</param>
        /// <param name="keepAllFields">
        ///     Allows you to include or disinclude the attributes of the point feature class.  If this is
        ///     set to False, the output event table will only contain the route event properties.
        /// </param>
        /// <param name="workspace">The workspace that will contain the event data table.</param>
        /// <returns>
        ///     Returns a <see cref="ITable" /> representing the event table of the results.
        /// </returns>
        public ITable Locate(string locatePolygonsAlongRouteName, IFeatureClass polygons, bool keepZeroLengthEvents, IRouteMeasureLineProperties properties, IQueryFilter filter, bool keepAllFields, IWorkspace workspace)
        {
            var locator = this.GetRouteLocatorOperations(filter, polygons);

            var outputClassName = workspace.Define(locatePolygonsAlongRouteName, new TableNameClass());

            workspace.Delete(outputClassName);

            return(locator.LocatePolygonFeatures((IRouteEventProperties)properties, keepAllFields, keepZeroLengthEvents, outputClassName, "", null));
        }
示例#14
0
文件: Route.cs 项目: wey12138/Wave
        /// <summary>
        ///     Locate line features along the route and writes the result to a new line event table.
        /// </summary>
        /// <param name="locateLinesAlongRouteName">The name of the event table of the located features.</param>
        /// <param name="lines">The lines to locate.</param>
        /// <param name="clusterTolerance">
        ///     The cluster tolerance which is a numeric value
        ///     representing the maximum tolerated distance between the input lines and the target routes.
        /// </param>
        /// <param name="properties">
        ///     Parameter consisting of the route location fields and the type of events that will be written
        ///     to the output event table.
        /// </param>
        /// <param name="filter">An optional filter used to use a subset of the line data.</param>
        /// <param name="keepAllFields">
        ///     Allows you to include or disinclude the attributes of the point feature class.  If this is
        ///     set to False, the output event table will only contain the route event properties.
        /// </param>
        /// <param name="workspace">The workspace that will contain the event data table.</param>
        /// <returns>
        ///     Returns a <see cref="ITable" /> representing the event table of the results.
        /// </returns>
        public ITable Locate(string locateLinesAlongRouteName, IFeatureClass lines, double clusterTolerance, IRouteMeasureLineProperties properties, IQueryFilter filter, bool keepAllFields, IWorkspace workspace)
        {
            var locator = this.GetRouteLocatorOperations(filter, lines);

            var outputClassName = workspace.Define(locateLinesAlongRouteName, new TableNameClass());

            workspace.Delete(outputClassName);

            return(locator.LocateLineFeatures(clusterTolerance, (IRouteEventProperties)properties, keepAllFields, outputClassName, "", null));
        }
示例#15
0
文件: Route.cs 项目: wey12138/Wave
        /// <summary>
        ///     Locate point features along the route and  writes the result to a new point event table.
        /// </summary>
        /// <param name="locatePointsAlongRouteName">The name of the event table of the located features.</param>
        /// <param name="points">The points to locate.</param>
        /// <param name="searchRadius">
        ///     If the input features are points, the search radius is a numeric value defining how far around each point a search
        ///     will be done to find a target route. If the input features are lines, the search tolerance is really a cluster
        ///     tolerance, which is a numeric value
        ///     representing the maximum tolerated distance between the input lines and the target routes. If the input features
        ///     are polygons, this parameter is ignored since no search radius is used.
        /// </param>
        /// <param name="searchMultipleLocations">
        ///     If the point falls on more than one route for the given search radius, you can
        ///     have the option to create multiple event records that correspond to each route in the search radius vicinity
        /// </param>
        /// <param name="properties">
        ///     Parameter consisting of the route location fields and the type of events that will be written
        ///     to the output event table.
        /// </param>
        /// <param name="filter">An optional filter used to use a subset of the point data.</param>
        /// <param name="keepAllFields">
        ///     Allows you to include or disinclude the attributes of the point feature class.  If this is
        ///     set to False, the output event table will only contain the route event properties.
        /// </param>
        /// <param name="workspace">The workspace that will contain the event data table.</param>
        /// <returns>
        ///     Returns a <see cref="ITable" /> representing the event table of the results.
        /// </returns>
        public ITable Locate(string locatePointsAlongRouteName, IFeatureClass points, double searchRadius, bool searchMultipleLocations, IRouteMeasurePointProperties properties, IQueryFilter filter, bool keepAllFields, IWorkspace workspace)
        {
            var locator = this.GetRouteLocatorOperations(filter, points);

            var outputClassName = workspace.Define(locatePointsAlongRouteName, new TableNameClass());

            workspace.Delete(outputClassName);

            return(locator.LocatePointFeatures(searchRadius, searchMultipleLocations, (IRouteEventProperties)properties, keepAllFields, outputClassName, "", null));
        }
示例#16
0
        public Task DeleteAsync(Role role)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }

            _workspace.Delete(role);
            _workspace.SaveChanges();
            return(Task.FromResult(0));
        }
示例#17
0
 private void OnDeleteInventoryItem(string obj)
 {
     if (SelectedRecipeItem != null)
     {
         if (SelectedRecipeItem.Model.Id > 0)
         {
             _workspace.Delete(SelectedRecipeItem.Model);
         }
         Model.RecipeItems.Remove(SelectedRecipeItem.Model);
         RecipeItems.Remove(SelectedRecipeItem);
     }
 }
示例#18
0
 private void OnDeletePropertyExecuted(string obj)
 {
     if (SelectedProperty == null)
     {
         return;
     }
     if (SelectedProperty.Model.Id > 0)
     {
         _workspace.Delete(SelectedProperty.Model);
     }
     Model.Properties.Remove(SelectedProperty.Model);
     Properties.Remove(SelectedProperty);
 }
示例#19
0
 private void OnDeleteTicketTagExecuted(string obj)
 {
     if (SelectedTicketTag == null)
     {
         return;
     }
     if (SelectedTicketTag.Model.Id > 0)
     {
         _workspace.Delete(SelectedTicketTag.Model);
     }
     Model.TicketTags.Remove(SelectedTicketTag.Model);
     TicketTags.Remove(SelectedTicketTag);
 }
示例#20
0
        private void DeleteEntity <T>(IWorkspace workspace, params string[] commandName) where T : class, IEntityClass
        {
            var name = GetName(commandName, 0);
            var acs  = workspace.All <T>(x => x.Name == name).ToList();

            if (acs.Any())
            {
                foreach (var ac in acs)
                {
                    workspace.Delete(ac);
                    workspace.CommitChanges();
                }
            }

            var name2 = GetName(commandName, 1);

            acs = workspace.All <T>(x => x.Name == name2).ToList();
            if (acs.Any())
            {
                foreach (var ac in acs)
                {
                    workspace.Delete(ac);
                    workspace.CommitChanges();
                }
            }

            var name3 = GetName(commandName, 2);

            acs = workspace.All <T>(x => x.Name == name3).ToList();
            if (acs.Any())
            {
                foreach (var ac in acs)
                {
                    workspace.Delete(ac);
                    workspace.CommitChanges();
                }
            }
        }
示例#21
0
        /// <summary>
        ///     Identifies those features in the source table that are contained by features in the table being joined.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="join">The spatial table to append fields from.</param>
        /// <param name="isLeftOuterJoin">
        ///     if set to <c>true</c> when a match is required before adding a record from the source
        ///     feature class to the result. If TRUE, all records in the source feature class are added regardless of whether there
        ///     is a match.
        /// </param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="outputName">Name of the output.</param>
        /// <returns>Returns a <see cref="IFeatureClass" /> representing the joined feature class.</returns>
        public static IFeatureClass Within(this IFeatureClass source, ITable join, bool isLeftOuterJoin, IWorkspace workspace, string outputName)
        {
            ISpatialJoin sj = new SpatialJoinClass();

            sj.ShowProcess[true] = 0;
            sj.LeftOuterJoin     = isLeftOuterJoin;
            sj.SourceTable       = (ITable)source;
            sj.JoinTable         = join;

            var ds = workspace.Define(outputName, new FeatureClassNameClass());

            workspace.Delete(ds);

            return(sj.JoinWithin(ds));
        }
        /// <summary>
        ///     Creates a feature class containing points generated from specified vertices or locations of the input features.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="outputTableName">Name of the output table.</param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        /// <param name="location">The location.</param>
        /// <remarks>License ArcGIS Desktop Advanced: Yes</remarks>
        /// <returns>
        ///     Returns a <see cref="IFeatureClass" /> representing the feature class.
        /// </returns>
        private static IFeatureClass CreateVertexPointsImpl(IFeatureClass source, string outputTableName, IWorkspace workspace, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler, string location)
        {
            var tableName = workspace.Define(outputTableName, new FeatureClassNameClass());

            workspace.Delete(tableName);

            FeatureVerticesToPoints gp = new FeatureVerticesToPoints();

            gp.in_features       = source;
            gp.out_feature_class = workspace.GetAbsolutePath(outputTableName);
            gp.point_location    = location;

            var status = gp.Run(trackCancel, eventHandler);

            return(status == esriJobStatus.esriJobSucceeded ? workspace.GetFeatureClass(outputTableName) : null);
        }
        /// <summary>
        ///     Overlays two event tables to create an output event table that represents the union or intersection of the input.
        /// </summary>
        /// <param name="gp">The route event geoprocessor.</param>
        /// <param name="type">The type of overlay to be performed.</param>
        /// <param name="output">
        ///     Parameter consisting of the route location fields and the type of events in the overlay event
        ///     table.
        /// </param>
        /// <param name="outputTableName">The table to be created.</param>
        /// <param name="outputWorkspace">The workspace that will contain the table that has been created.</param>
        /// <param name="trackCancel">Allows the operation be be cancelled.</param>
        /// <returns>Returns a <see cref="ITable" /> representing the table that has been created.</returns>
        private static ITable OverlayImpl(IRouteMeasureEventGeoprocessor2 gp, OverlayType type, IRouteEventProperties2 output, string outputTableName, IWorkspace outputWorkspace, ITrackCancel trackCancel)
        {
            var outputName = new TableNameClass();

            outputName.WorkspaceName = (IWorkspaceName)((IDataset)outputWorkspace).FullName;
            outputName.Name          = outputTableName;

            outputWorkspace.Delete(outputName);

            if (type == OverlayType.Union)
            {
                return(gp.Union2(output, true, outputName, trackCancel, ""));
            }

            return(gp.Intersect2(output, true, outputName, trackCancel, ""));
        }
示例#24
0
 private void OnDeletePortion(string value)
 {
     if (SelectedPortion != null)
     {
         var c = Dao.Count <Recipe>(x => x.Portion.Id == SelectedPortion.Model.Id);
         if (c == 0)
         {
             if (SelectedPortion.Model.Id > 0 && Model.Id > 0)
             {
                 _workspace.Delete(SelectedPortion.Model);
             }
             Model.Portions.Remove(SelectedPortion.Model);
             Portions.Remove(SelectedPortion);
         }
     }
 }
        /// <summary>
        ///     Events will be aggregated where the to-measure of one event matches the from-measure of the next event. This option
        ///     is applicable only for line events.
        /// </summary>
        /// <param name="table">The table whose rows will be aggregated.</param>
        /// <param name="source">Parameter consisting of the route location fields and the type of events in the input event table.</param>
        /// <param name="outputWorkspace"></param>
        /// <param name="outputTableName">The table to be created.</param>
        /// <param name="output">
        ///     Parameter consisting of the route location fields and the type of events in the concatenate event
        ///     table.
        /// </param>
        /// <param name="trackCancel">The object that allows for monitoring the progress.</param>
        /// <param name="concatenateFields">The field(s)used to aggregate rows.</param>
        /// <returns>Returns a <see cref="ITable" /> representing the table that has been created.</returns>
        public static ITable Concatenate(this ITable table, IRouteEventProperties2 source, IWorkspace outputWorkspace, string outputTableName, IRouteEventProperties2 output, ITrackCancel trackCancel, params string[] concatenateFields)
        {
            var outputName = new TableNameClass();

            outputName.WorkspaceName = (IWorkspaceName)((IDataset)outputWorkspace).FullName;
            outputName.Name          = outputTableName;

            outputWorkspace.Delete(outputName);

            IRouteMeasureEventGeoprocessor2 gp = new RouteMeasureGeoprocessorClass();

            gp.InputEventProperties     = source;
            gp.InputTable               = table;
            gp.KeepZeroLengthLineEvents = false;

            return(gp.Concatenate2(output, concatenateFields, outputName, trackCancel, ""));
        }
示例#26
0
 private void OnDelete(string obj)
 {
     if (InteractionService.UserIntraction.AskQuestion(Resources.DeleteSelectedMappingQuestion))
     {
         var map = SelectedPrinterMap.Model;
         PrinterMaps.Remove(SelectedPrinterMap);
         Model.PrinterMaps.Remove(map);
         if (_newPrinterMaps.Contains(map))
         {
             _newPrinterMaps.Remove(map);
         }
         else
         {
             _workspace.Delete(map);
             _workspace.CommitChanges();
         }
     }
 }
示例#27
0
        /// <summary>
        /// Exports the source table using the query filter to the table in the output workspace.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="tableName">Name of the output table.</param>
        /// <param name="workspace">The output workspace.</param>
        /// <param name="requiredFields">The required fields.</param>
        /// <param name="handle">The handle.</param>
        /// <param name="keepFeatureDatset">if set to <c>true</c> when the feature class should be created within feature datset.</param>
        /// <param name="surrogate">The surrogate for the event handler.</param>
        /// <param name="invalid">The errors that occured during the export.</param>
        /// <param name="errors">The field errors.</param>
        /// <returns>
        /// Returns a <see cref="IFeatureClass" /> representing the feature class that was exported.
        /// </returns>
        public static IFeatureClass Export(this IFeatureClass source, IQueryFilter filter, string tableName, IWorkspace workspace, IFields requiredFields, int handle, bool keepFeatureDatset, FeatureProgress surrogate, out IEnumInvalidObject invalid, out IEnumFieldError errors)
        {
            var ds = (IDataset)source;

            var input  = ds.Workspace.Define(ds.Name, new FeatureClassNameClass());
            var output = workspace.Define(tableName, new FeatureClassNameClass());

            if (source.FeatureDataset != null && keepFeatureDatset)
            {
                output.FeatureDatasetName = source.FeatureDataset.FullName as IDatasetName;
            }

            var i           = source.Fields.FindField(source.ShapeFieldName);
            var field       = source.Fields.Field[i];
            var clone       = (IClone)field.GeometryDef;
            var geometryDef = (IGeometryDef)clone.Clone();

            workspace.Delete(output);

            IFieldChecker fieldChecker = new FieldCheckerClass();

            fieldChecker.InputWorkspace    = ds.Workspace;
            fieldChecker.ValidateWorkspace = workspace;

            IFields targetFields;

            fieldChecker.Validate(requiredFields, out errors, out targetFields);

            var featureDataConverter = new FeatureDataConverterClass();

            if (surrogate != null)
            {
                surrogate.Advise(featureDataConverter);
            }

            invalid = featureDataConverter.ConvertFeatureClass(input, filter, null, output, geometryDef, targetFields, "", 1000, handle);

            return(((IName)output).Open() as IFeatureClass);
        }
示例#28
0
        public SettingGetter GetSetting(string valueName)
        {
            ProgramSetting setting;

            try
            {
                setting = _workspace.Single <ProgramSetting>(x => x.Name == valueName);
            }
            catch (Exception)
            {
                _workspace.Delete <ProgramSetting>(x => x.Name == valueName);
                _workspace.CommitChanges();
                setting = null;
            }

            if (_settingCache.ContainsKey(valueName))
            {
                if (setting == null)
                {
                    setting = _settingCache[valueName];
                }
                else
                {
                    _settingCache.Remove(valueName);
                }
            }
            if (setting == null)
            {
                setting = new ProgramSetting {
                    Name = valueName
                };
                _settingCache.Add(valueName, setting);
                _workspace.Add(setting);
                _workspace.CommitChanges();
            }
            return(new SettingGetter(setting));
        }
示例#29
0
        private static void CreateWarehouseTestContext(WarehouseTestContext testContext, IWorkspace workspace)
        {
            workspace.Delete<InventoryTransactionType>(x => x.Id > 0);
            workspace.Delete<Entity>(x => x.Id > 0);

            testContext.Iskender = workspace.Single<MenuItem>(x => x.Name == "İskender");
            testContext.Iskender.Portions[0].MenuItemId = testContext.Iskender.Id;

            testContext.DonerEti = new InventoryItem { Name = "Döner Eti", BaseUnit = "GR", GroupCode = "", TransactionUnit = "KG", TransactionUnitMultiplier = 1000 };
            testContext.Yogurt = new InventoryItem { Name = "Yoğurt", BaseUnit = "GR", GroupCode = "", TransactionUnit = "KG", TransactionUnitMultiplier = 1000 };
            testContext.Pide = new InventoryItem { Name = "Pide", BaseUnit = "Yarım", GroupCode = "", TransactionUnit = "Adet", TransactionUnitMultiplier = 2 };
            testContext.ZeytinYagi = new InventoryItem { Name = "Zeytin Yağı", BaseUnit = "Ölçü", GroupCode = "", TransactionUnit = "Litre", TransactionUnitMultiplier = 100 };

            workspace.Add(testContext.DonerEti);
            workspace.Add(testContext.Yogurt);
            workspace.Add(testContext.Pide);
            workspace.Add(testContext.ZeytinYagi);

            testContext.IskenderRecipe = new Recipe { Name = "İskender Reçetesi", Portion = testContext.Iskender.Portions[0] };
            workspace.Add(testContext.IskenderRecipe);

            testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.DonerEti, Quantity = 120 });
            testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.Yogurt, Quantity = 50 });
            testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.Pide, Quantity = 2 });
            testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.ZeytinYagi, Quantity = 1 });

            testContext.LocalWarehouseAccountType = new AccountType { Name = "Local Warehouse Account Type" };
            testContext.SellerWarehouseAccountType = new AccountType { Name = "Seller Warehouse Account Type" };

            workspace.Add(testContext.LocalWarehouseAccountType);
            workspace.Add(testContext.SellerWarehouseAccountType);

            testContext.WarehouseType = workspace.Single<WarehouseType>(x => x.Name == Resources.Warehouses);
            testContext.WarehouseEntityType = new EntityType { Name = "Warehouse Resource Type" };
            workspace.Add(testContext.WarehouseEntityType);

            testContext.LocalWarehouseAccount = new Account { AccountTypeId = testContext.LocalWarehouseAccountType.Id };
            testContext.Seller1Account = new Account { AccountTypeId = testContext.SellerWarehouseAccountType.Id };
            testContext.Seller2Account = new Account { AccountTypeId = testContext.SellerWarehouseAccountType.Id };

            workspace.Add(testContext.LocalWarehouseAccount);
            workspace.Add(testContext.Seller1Account);
            workspace.Add(testContext.Seller2Account);

            testContext.LocalWarehouse = new Warehouse
                {
                    WarehouseTypeId = testContext.WarehouseType.Id
                };
            testContext.BarWarehouse = new Warehouse
                {
                    WarehouseTypeId = testContext.WarehouseType.Id
                };
            testContext.Seller1Warehouse = new Warehouse
                {
                    WarehouseTypeId = testContext.WarehouseType.Id
                };
            testContext.Seller2Warehouse = new Warehouse
                {
                    WarehouseTypeId = testContext.WarehouseType.Id
                };

            workspace.Add(testContext.LocalWarehouse);
            workspace.Add(testContext.BarWarehouse);
            workspace.Add(testContext.Seller1Warehouse);
            workspace.Add(testContext.Seller2Warehouse);

            testContext.LocalWarehouseEntity = new Entity
                {
                    WarehouseId = testContext.LocalWarehouse.Id,
                    EntityTypeId = testContext.WarehouseEntityType.Id,
                    AccountId = testContext.LocalWarehouseAccount.Id
                };
            testContext.BarWarehouseEntity = new Entity
                {
                    WarehouseId = testContext.BarWarehouse.Id,
                    EntityTypeId = testContext.WarehouseEntityType.Id
                };
            testContext.Seller1WarehouseEntity = new Entity
                {
                    WarehouseId = testContext.Seller1Warehouse.Id,
                    EntityTypeId = testContext.WarehouseEntityType.Id,
                    AccountId = testContext.Seller1Account.Id
                };
            testContext.Seller2WarehouseEntity = new Entity
                {
                    WarehouseId = testContext.Seller2Warehouse.Id,
                    EntityTypeId = testContext.WarehouseEntityType.Id,
                    AccountId = testContext.Seller2Account.Id
                };

            workspace.Add(testContext.LocalWarehouseEntity);
            workspace.Add(testContext.BarWarehouseEntity);
            workspace.Add(testContext.Seller1WarehouseEntity);
            workspace.Add(testContext.Seller2WarehouseEntity);

            testContext.PurchaseAccountTransactionType = new AccountTransactionType
                                                             {
                                                                 SourceAccountTypeId =
                                                                     testContext.SellerWarehouseAccountType.Id,
                                                                 TargetAccountTypeId =
                                                                     testContext.LocalWarehouseAccountType.Id,
                                                                 DefaultTargetAccountId =
                                                                     testContext.LocalWarehouseAccount.Id
                                                             };

            workspace.Add(testContext.PurchaseAccountTransactionType);

            testContext.PurchaseTransactionType = new InventoryTransactionType
                {
                    Name = "PurchaseTransaction",
                    SourceWarehouseTypeId = testContext.WarehouseType.Id,
                    TargetWarehouseTypeId = testContext.WarehouseType.Id,
                    DefaultSourceWarehouseId = testContext.Seller1Warehouse.Id,
                    DefaultTargetWarehouseId = testContext.LocalWarehouse.Id,
                };

            testContext.PurchaseTransactionDocumentType = new InventoryTransactionDocumentType
                {
                    AccountTransactionType = testContext.PurchaseAccountTransactionType,
                    InventoryTransactionType = testContext.PurchaseTransactionType,
                    SourceEntityTypeId = testContext.WarehouseEntityType.Id,
                    TargetEntityTypeId = testContext.WarehouseEntityType.Id,
                    DefaultSourceEntityId = testContext.Seller1WarehouseEntity.Id,
                    DefaultTargetEntityId = testContext.LocalWarehouseEntity.Id
                };

            testContext.BarTransferTransactionType = new InventoryTransactionType
                {
                    Name = "Bar Transfer",
                    SourceWarehouseTypeId = testContext.WarehouseType.Id,
                    TargetWarehouseTypeId = testContext.WarehouseType.Id,
                    DefaultSourceWarehouseId = testContext.LocalWarehouse.Id,
                    DefaultTargetWarehouseId = testContext.BarWarehouse.Id
                };

            testContext.BarTransferTransactionDocumentType = new InventoryTransactionDocumentType
            {
                InventoryTransactionType = testContext.BarTransferTransactionType,
                SourceEntityTypeId = testContext.WarehouseEntityType.Id,
                TargetEntityTypeId = testContext.WarehouseEntityType.Id,
                DefaultSourceEntityId = testContext.LocalWarehouseEntity.Id,
                DefaultTargetEntityId = testContext.BarWarehouseEntity.Id
            };

            workspace.Add(testContext.PurchaseTransactionType);
            workspace.Add(testContext.BarTransferTransactionType);

            testContext.Department = workspace.Single<Department>(x => x.Name == "Restoran");
            testContext.Department.WarehouseId = testContext.LocalWarehouse.Id;

            ApplicationStateSetter.SetCurrentDepartment(testContext.Department.Id);
            WorkPeriodService.StartWorkPeriod("");
            Thread.Sleep(1);
        }
示例#30
0
 public void DeleteEntity <T>(T item) where T : class
 {
     _workspace.Delete <T>(item);
     _workspace.CommitChanges();
 }
示例#31
0
 private void DoDeleteItem(TModel item)
 {
     BeforeDeleteItem(item);
     _workspace.Delete(item);
     _workspace.CommitChanges();
 }