/// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationTestOperation"/> class.
        /// </summary>
        /// <param name="operation">Configuration of operation.</param>
        public ConfigurationTestOperation(OperationConfiguration operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException("operation");
            }

            Type = operation.OperationType;
        }
Beispiel #2
0
        public void Apply(OperationConfiguration configuration, ODataModelBuilder model)
        {
            ActionConfiguration action = configuration as ActionConfiguration;

            // You only need to create links for bindable actions that bind to a single entity.
            if (action != null && action.IsBindable && action.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Entity && action.GetActionLink() == null)
            {
                string bindingParamterType = action.BindingParameter.TypeConfiguration.FullName;
                action.HasActionLink(entityContext => entityContext.GenerateActionLink(bindingParamterType, action.FullyQualifiedName), followsConventions: true);
            }
        }
        public void Run()
        {
            // sd = new SocketDelegate(CallbackSocket);

            Console.WriteLine("ID router:");
            numberOfRouter = Console.ReadLine().ToString();


            //Uruchomienie agenta
            ManagmentAgent agent = new ManagmentAgent();

            if (numberOfRouter == "2")
            {
                Task.Run(() => agent.Run(numberOfRouter, ref commutationTable, ref borderNodeCommutationTable, ref eonTable));
            }

            Task.Run(() => CC());

            //pobranie wlasnosci zapisanych w pliku konfiguracyjnym
            tmp = OperationConfiguration.ReadAllSettings(mySettings);


            //przeszukanie wszystkich kluczy w liscie
            foreach (var key in tmp)
            {
                if (key.Keysettings.StartsWith(numberOfRouter + "Sending"))
                {
                    //Uruchamiamy watek na kazdym z tworzonych sluchaczy
                    //Task.Run(()=>
                    CreateConnect2(key.SettingsValue, key.Keysettings);//);
                }
            }

            /*  //jezeli klucz zaczyna sie od TableFrom to uzupelniamy liste
             * else if (key.Keysettings.StartsWith("TableFrom"))
             *    tableFrom.Add(key.SettingsValue);
             *
             * //jezeli klucz zaczyna sie od TableTo to uzupelniamy liste
             * else if (key.Keysettings.StartsWith("TableTo"))
             *    tableTo.Add(key.SettingsValue);*/
            ConsoleKeyInfo cki;

            //Petla wykonuje sie poki nie nacisniemy klawisza "esc"
            while (true)
            {
                cki = Console.ReadKey();
                if (cki.Key == ConsoleKey.Escape)
                {
                    _cts.Cancel();
                    break;
                }
            }
        }
        public void CanRemoveOperation()
        {
            // Arrange
            // Act
            ODataModelBuilder      builder   = new ODataModelBuilder();
            ActionConfiguration    action    = builder.Action("Format");
            OperationConfiguration operation = builder.Operations.SingleOrDefault();
            bool removed = builder.RemoveOperation(operation);

            // Assert
            Assert.True(removed);
            Assert.Empty(builder.Operations);
        }
        public void Apply(OperationConfiguration configuration, ODataModelBuilder model)
        {
            FunctionConfiguration function = configuration as FunctionConfiguration;

            // You only need to create links for bindable functions that bind to a single entity.
            if (function != null && function.IsBindable && function.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Entity && function.GetFunctionLink() == null)
            {
                string bindingParamterType = function.BindingParameter.TypeConfiguration.FullName;

                function.HasFunctionLink(entityContext =>
                                         entityContext.GenerateFunctionLink(bindingParamterType, function.Name, function.Parameters.Select(p => p.Name)),
                                         followsConventions: true);
            }
        }
Beispiel #6
0
        private void create_button_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(this.errorMessage.Text) && dataTable.Rows.Count > 0)
            {
                MessageBox.Show("必须解决完错误后,才能新建轮次!", "系统提示");
                return;
            }

            if (dataTable.Rows.Count == 5)
            {
                MessageBox.Show("最大只允许新建5个轮次!", "系统提示!");
                //   this.errorMessage.Text = "最大只允许新建5个轮次!";
                return;
            }

            if (dataTable.Rows.Count > 0)
            {
                DataRow lastRow = dataTable.Rows[dataTable.Rows.Count - 1];
                OperationConfiguration lastRowOperation = lastRow["Operation"] as OperationConfiguration;
                if (lastRowOperation == null)
                {
                    MessageBox.Show("请配置完当前轮次,再新建!", "系统提示");
                    return;
                }
                else
                {
                    //if ((int)lastRowOperation.OperationType == (int)OperationType.Grouping)
                    //{
                    isBelongtoCurrentTubeBatch = false;
                    //}
                }
            }

            System.Data.DataRow dRow = dataTable.NewRow();
            dRow["Sequence"]        = dataTable.Rows.Count + 1;
            dRow["deleteIsVisible"] = Visibility.Visible.ToString();
            dRow["RotationName"]    = "轮次" + dRow["Sequence"].ToString();
            //   operation_column.DisplayIndex = 1;
            dRow["Operation"] = CreateOperation;
            if (isBelongtoCurrentTubeBatch && tubesBatch != null)
            {
                dRow["TubesBatchName"] = tubesBatch.TubesBatchName;
                dRow["TubesBatchID"]   = tubesBatch.TubesBatchID;
            }

            dataTable.Rows.Add(dRow);
            next_button.IsEnabled = false;
            save_button.IsEnabled = true;
        }
        public void IsMapped_HttpHeaderIsEqualToValue_False()
        {
            var proxy = MockRepository.GenerateMock <IConfigurationProxy>();

            proxy.Expect(p => p.GetHeaderValue("name")).Return("v3");
            ConfigurationProvider.Proxy = proxy;

            var target = new OperationConfiguration(HttpMethod.Get, "{id}");

            target.HttpHeader("name").IsEqualToValue("v1", "v2");

            Assert.IsFalse(target.IsMapped(null));

            proxy.VerifyAllExpectations();
        }
Beispiel #8
0
        public void AttemptToRemoveNonExistentEntityReturnsFalse()
        {
            // Arrange
            ODataModelBuilder      builder  = new ODataModelBuilder();
            ODataModelBuilder      builder2 = new ODataModelBuilder();
            OperationConfiguration toRemove = builder2.Function("ToRemove");

            // Act
            bool removedByName = builder.RemoveOperation("ToRemove");
            bool removed       = builder.RemoveOperation(toRemove);

            //Assert
            Assert.False(removedByName);
            Assert.False(removed);
        }
Beispiel #9
0
        private static EdmOperationImport CreateActionImport(
            OperationConfiguration operationConfiguration,
            EdmEntityContainer container,
            IEdmTypeReference returnReference,
            IEdmExpression expression,
            IEdmPathExpression pathExpression)
        {
            EdmAction operation = new EdmAction(
                operationConfiguration.Namespace,
                operationConfiguration.Name,
                returnReference,
                operationConfiguration.IsBindable,
                pathExpression);

            return(new EdmActionImport(container, operationConfiguration.Name, operation, expression));
        }
Beispiel #10
0
        private void InitField()
        {
            if (!string.IsNullOrEmpty(editOperationId))
            {
                OperationConfiguration item = controller.GetOperation(new Guid(editOperationId));

                this.name_textBox.Text           = item.OperationName;
                this.type_comboBox.SelectedIndex = item.OperationType;
                string scriptName = item.ScriptFileName;
                if (!string.IsNullOrEmpty(scriptName))
                {
                    string[] scripts = scriptName.Split(',');
                    foreach (string script in scripts)
                    {
                        files_listBox.Items.Add(script);
                    }
                }

                this.editOperation_ScriptFileName = item.ScriptFileName;
                this.sequence_textBox.Text        = item.OperationSequence.ToString();
                this.display_checkBox.IsChecked   = item.DisplayFlag;
                this.runTime_textBox.Text         = item.RunTime.ToString();
                this.startFileName_textBox.Text   = item.StartOperationFileName;
                this.endFileName_textBox.Text     = item.EndOperationFileName;

                if (type_comboBox.SelectedIndex == (int)OperationType.Grouping)
                {
                    operationList_stackPanel.Children.Clear();
                    List <OperationConfiguration> operationList = controller.GetAllOperations();
                    foreach (OperationConfiguration operation in operationList)
                    {
                        CheckBox operationCheckbox = new CheckBox()
                        {
                            Content = operation.OperationName, DataContext = operation, Margin = new Thickness(10, 10, 0, 0)
                        };
                        if (item.SubOperationIDs.Contains(operation.OperationID.ToString()))
                        {
                            operationCheckbox.IsChecked = true;
                        }

                        operationCheckbox.Click += new RoutedEventHandler(operationCheckbox_Click);
                        operationList_stackPanel.Children.Add(operationCheckbox);
                    }
                }
            }
        }
 public OperationConfiguration GetOperation(Guid operationID)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             OperationConfiguration record = entities.OperationConfigurations.Where(c => c.OperationID == operationID).FirstOrDefault();
             return(record);
         }
     }
     catch (Exception e)
     {
         string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
         LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->GetOperation", SessionInfo.ExperimentID);
         throw;
     }
 }
 public bool Create(OperationConfiguration configuration)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             entities.AddToOperationConfigurations(configuration);
             entities.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
         LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->Create", SessionInfo.ExperimentID);
         return(false);
     }
 }
 private static void AddParameter(
     ODataConventionModelBuilder builder,
     OperationConfiguration configuration,
     Type pType,
     string name)
 {
     if (pType.IsPrimitiveType())
     {
         var primitiveType = builder.AddPrimitiveType(pType);
         configuration.AddParameter(name, primitiveType);
     }
     else
     {
         if (pType.IsCollection())
         {
             if (pType.GenericTypeArguments[0].GetTypeInfo()
                 .IsPrimitive)
             {
                 var parameterType = builder.AddPrimitiveType(
                     pType.GenericTypeArguments[0]);
                 var collectionTypeConfig = new CollectionTypeConfiguration(
                     parameterType,
                     pType.GenericTypeArguments[0]);
                 configuration.AddParameter(name, collectionTypeConfig);
             }
             else
             {
                 var parameterType = builder.AddEntityType(
                     pType.GenericTypeArguments[0]);
                 var collectionTypeConfig = new CollectionTypeConfiguration(
                     parameterType,
                     pType.GenericTypeArguments[0]);
                 configuration.AddParameter(name, collectionTypeConfig);
             }
         }
         else
         {
             var parameterType = builder.AddEntityType(pType);
             configuration.AddParameter(name, parameterType);
         }
     }
 }
        public bool UpdateActiveStatus(Guid operationId, bool status)
        {
            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    OperationConfiguration record = entities.OperationConfigurations.Where(p => p.OperationID == operationId).FirstOrDefault();
                    record.ActiveStatus = status;

                    entities.SaveChanges();
                    return(true);
                }
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->UpdateActiveStatus", SessionInfo.ExperimentID);
                return(false);
            }
        }
Beispiel #15
0
        internal HostOperation(
            OperationConfiguration <TRequest, TResponse> operation,
            HostOperationSettings settings)
        {
            ServiceName  = settings.ServiceName;
            ExchangeName = settings.ExchangeName;
            Serializer   = settings.Serializer;
            Logger       = settings.Logger;

            _operation  = operation;
            _connection = settings.Connection;
            _model      = _connection.CreateModel();

            var queueName = QueueName;

            _model.QueueDeclare(queueName, true, false, false);
            _model.QueueBind(queueName, ExchangeName, operation.OperationName);

            var consumer = new EventingBasicConsumer(_model);

            _model.BasicConsume(queueName, false, consumer);
            consumer.Received += OnMessageReceived;
        }
Beispiel #16
0
        public void Run(string number, ref CommutationTable commutationTable,
                        ref BorderNodeCommutationTable borderNodeCommutationTable,
                        ref EONTable eonTable)
        {
            this.eonTable                   = eonTable;
            this.commutationTable           = commutationTable;
            this.borderNodeCommutationTable = borderNodeCommutationTable;
            //Zmienna do przechowywania klucza na adres wychodzacy powiazany z socketem sluchaczem
            string settingsString = "";


            //pobranie wlasnosci zapisanych w pliku konfiguracyjnym
            tmp = OperationConfiguration.ReadAllSettings(mySettings);


            //przeszukanie wszystkich kluczy w liscie


            //Uruchamiamy watek na kazdym z tworzonych sluchaczy


            //    CreateConnect("127.0.0.14","1NMS");
            CreateConnect(ConfigurationManager.AppSettings[number + "NMS"], number + "NMS");



            ConsoleKeyInfo cki;

            while (true)
            {
                cki = Console.ReadKey();
                if (cki.Key == ConsoleKey.Escape)
                {
                    break;
                }
            }
        }
Beispiel #17
0
 private static void AddOperationParameters(EdmOperation operation, OperationConfiguration operationConfiguration, Dictionary <Type, IEdmType> edmTypeMap)
 {
     foreach (ParameterConfiguration parameter in operationConfiguration.Parameters)
     {
         bool isParameterNullable = parameter.Nullable;
         IEdmTypeReference parameterTypeReference = GetEdmTypeReference(edmTypeMap, parameter.TypeConfiguration, nullable: isParameterNullable);
         if (parameter.IsOptional)
         {
             if (parameter.DefaultValue != null)
             {
                 operation.AddOptionalParameter(parameter.Name, parameterTypeReference, parameter.DefaultValue);
             }
             else
             {
                 operation.AddOptionalParameter(parameter.Name, parameterTypeReference);
             }
         }
         else
         {
             IEdmOperationParameter operationParameter = new EdmOperationParameter(operation, parameter.Name, parameterTypeReference);
             operation.AddParameter(operationParameter);
         }
     }
 }
        /// <summary>
        /// Funkcja do obslugi socketow i wiadomosci przychochacych oraz wychodzacych
        /// </summary>
        /// <remarks>
        /// W funkcji tej zczytujemy dane o laczach oraz kierowaniu z pliku konfiguracyjnego
        /// Uruchamiamy sluchacza na kazdym z adresow podanych w pliku cofiguracyjnym, a po nawiazaniu polaczenia przychodzacego odrazu probujemy
        /// nawiazac polaczenie wychodzace na sokecie wychodzacym
        /// Kazdy sluchac dziala na oddzielnym watku
        /// </remarks>
        private static void messageHandling()
        {
            //Zmienna do przechowywania klucza na adres wychodzacy powiazany z socketem sluchaczem
            string settingsString = "";

            //Zmienna do przechowywania numeru po ktorym identyfikujemy klucz na socket wychodzacy
            string str;

            //pobranie wlasnosci zapisanych w pliku konfiguracyjnym
            tmp = OperationConfiguration.ReadAllSettings(readSettings);

            //przeszukanie wszystkich kluczy w liscie
            foreach (var key in tmp)
            {
                if (key.Keysettings.StartsWith("Listener"))
                {
                    //Uruchamiamy watek na kazdym z tworzonych sluchaczy
                    var task = Task.Run(() =>
                    {
                        ListenAsync(key.SettingsValue, key.Keysettings);
                    });
                }

                //jezeli klucz zaczyna sie od TableFrom to uzupelniamy liste
                else if (key.Keysettings.StartsWith("TableFrom"))
                {
                    tableFrom.Add(key.SettingsValue);
                }

                //jezeli klucz zaczyna sie od TableTo to uzupelniamy liste
                else if (key.Keysettings.StartsWith("TableTo"))
                {
                    tableTo.Add(key.SettingsValue);
                }
            }
        }
Beispiel #19
0
        public void Apply(OperationConfiguration configuration, ODataModelBuilder model)
        {
            ActionConfiguration action = configuration as ActionConfiguration;

            if (action == null || !action.IsBindable)
            {
                return;
            }

            // You only need to create links for bindable actions that bind to a single entity.
            if (action.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Entity && action.GetActionLink() == null)
            {
                if (action.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Entity &&
                    action.GetActionLink() == null)
                {
                    string bindingParameterType = action.BindingParameter.TypeConfiguration.FullName;
                    action.HasActionLink(
                        entityContext =>
                        entityContext.GenerateActionLink(bindingParameterType, action.FullyQualifiedName),
                        followsConventions: true);
                }
            }
            else if (action.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Collection &&
                     action.GetFeedActionLink() == null)
            {
                if (((CollectionTypeConfiguration)action.BindingParameter.TypeConfiguration).ElementType.Kind ==
                    EdmTypeKind.Entity)
                {
                    string bindingParameterType = action.BindingParameter.TypeConfiguration.FullName;
                    action.HasFeedActionLink(
                        feedContext =>
                        feedContext.GenerateActionLink(bindingParameterType, action.FullyQualifiedName),
                        followsConventions: true);
                }
            }
        }
 public void GetSingleSubOperations(Guid operationID, ref List <OperationConfiguration> operations)
 {
     using (WanTaiEntities entities = new WanTaiEntities())
     {
         OperationConfiguration operation = entities.OperationConfigurations.FirstOrDefault(P => P.OperationID == operationID);
         if (operation != null)
         {
             if (operation.OperationType == 0)
             {
                 operations.Add(operation);
             }
             else
             {
                 string subOperationIDs = operation.SubOperationIDs;
                 if (!string.IsNullOrEmpty(subOperationIDs))
                 {
                     string[] IDs = subOperationIDs.Split(new char[] { ',' });
                     Guid     guid;
                     for (int i = 0; i < IDs.Length; i++)
                     {
                         try
                         {
                             guid = Guid.Parse(IDs[i]);
                             GetSingleSubOperations(guid, ref operations);
                         }
                         catch (Exception ex)
                         {
                             LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, ex.Message, null, this.GetType().ToString() + "->" + "GetSingleSubOperations(Guid operationID, ref List<OperationConfiguration> operations)", null);
                             continue;
                         }
                     }
                 }
             }
         }
     }
 }
        private void BuildControllerOperations <TDto>(ODataModelBuilder odataModelBuilder, TypeInfo apiController)
            where TDto : class
        {
            string controllerName = GetControllerName(apiController);
            EntitySetConfiguration <TDto> entitySet = odataModelBuilder.EntitySet <TDto>(controllerName);

            foreach (MethodInfo method in apiController.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                IActionHttpMethodProvider actionHttpMethodProvider =
                    method.GetCustomAttributes().OfType <FunctionAttribute>().Cast <IActionHttpMethodProvider>()
                    .Union(method.GetCustomAttributes().OfType <ActionAttribute>().Cast <IActionHttpMethodProvider>())
                    .ExtendedSingleOrDefault($"Finding ${nameof(IActionHttpMethodProvider)} attribute in {method.Name}");

                if (actionHttpMethodProvider != null)
                {
                    bool isFunction = actionHttpMethodProvider is FunctionAttribute;
                    bool isAction   = actionHttpMethodProvider is ActionAttribute;

                    if (!isFunction && !isAction)
                    {
                        continue;
                    }

                    List <DefaultAutoODataModelBuilderParameterInfo> operationParameters = new List <DefaultAutoODataModelBuilderParameterInfo>();

                    if (isFunction)
                    {
                        foreach (ParameterInfo parameter in method.GetParameters())
                        {
                            if (parameter.ParameterType.GetTypeInfo() == typeof(CancellationToken).GetTypeInfo() || typeof(ODataQueryOptions).IsAssignableFrom(parameter.ParameterType.GetTypeInfo()))
                            {
                                continue;
                            }
                            operationParameters.Add(new DefaultAutoODataModelBuilderParameterInfo {
                                Name = parameter.Name, Type = parameter.ParameterType.GetTypeInfo()
                            });
                        }
                    }
                    else if (isAction)
                    {
                        ParameterInfo parameter = method
                                                  .GetParameters()
                                                  .ExtendedSingleOrDefault($"Finding parameter of {method.Name}", p => p.ParameterType.GetTypeInfo() != typeof(CancellationToken).GetTypeInfo() && !typeof(ODataQueryOptions).IsAssignableFrom(p.ParameterType.GetTypeInfo()));

                        if (parameter != null)
                        {
                            foreach (PropertyInfo prop in parameter.ParameterType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
                            {
                                operationParameters.Add(new DefaultAutoODataModelBuilderParameterInfo {
                                    Name = prop.Name, Type = prop.PropertyType.GetTypeInfo()
                                });
                            }
                        }
                    }

                    OperationConfiguration operationConfiguration = null;

                    if (isAction)
                    {
                        operationConfiguration = entitySet.EntityType.Collection.Action(method.Name);
                    }
                    else if (isFunction)
                    {
                        operationConfiguration = entitySet.EntityType.Collection.Function(method.Name);
                    }

                    foreach (DefaultAutoODataModelBuilderParameterInfo operationParameter in operationParameters)
                    {
                        TypeInfo parameterType = operationParameter.Type;

                        if (operationParameter.Type.GetTypeInfo() != typeof(string).GetTypeInfo() &&
                            typeof(IEnumerable).GetTypeInfo().IsAssignableFrom(operationParameter.Type))
                        {
                            if (parameterType.IsArray)
                            {
                                throw new InvalidOperationException($"Use IEnumerable<{parameterType.GetElementType().GetTypeInfo().Name}> instead of {parameterType.GetElementType().GetTypeInfo().Name}[] for parameter {operationParameter.Name} of {operationParameter.Name} in {controllerName} controller");
                            }

                            if (parameterType.IsGenericType)
                            {
                                parameterType = parameterType.GetGenericArguments().ExtendedSingle($"Finding parameter type from generic arguments of {parameterType.Name}").GetTypeInfo();
                            }

                            ParameterConfiguration parameter = (ParameterConfiguration)_collectionParameterMethodInfo
                                                               .MakeGenericMethod(parameterType)
                                                               .Invoke(operationConfiguration, new object[] { operationParameter.Name });
                            parameter.Nullable = operationParameter.IsOptional;
                        }
                        else
                        {
                            operationConfiguration.Parameter(parameterType, operationParameter.Name).Nullable = operationParameter.IsOptional;
                        }
                    }

                    TypeInfo type = method.ReturnType.GetTypeInfo();

                    if (type.Name != "Void" && type.Name != typeof(Task).GetTypeInfo().Name)
                    {
                        operationConfiguration.ReturnNullable = false;

                        bool isCollection = false;

                        if (typeof(Task).GetTypeInfo().IsAssignableFrom(type))
                        {
                            if (type.IsGenericType)
                            {
                                type = type.GetGenericArguments().ExtendedSingle($"Finding Return type of {method.Name}").GetTypeInfo();
                            }
                        }

                        if (typeof(SingleResult).GetTypeInfo().IsAssignableFrom(type))
                        {
                            if (type.IsGenericType)
                            {
                                type = type.GetGenericArguments().ExtendedSingle($"Finding Return type of {method.Name}").GetTypeInfo();
                            }
                        }

                        if (typeof(string) != type && typeof(IEnumerable).IsAssignableFrom(type))
                        {
                            if (type.IsGenericType)
                            {
                                type = type.GetGenericArguments().ExtendedSingle($"Finding Return type of {method.Name}").GetTypeInfo();
                            }
                            else if (type.IsArray)
                            {
                                type = type.GetElementType().GetTypeInfo();
                            }
                            isCollection = true;
                        }

                        if (DtoMetadataWorkspace.Current.IsDto(type))
                        {
                            type = DtoMetadataWorkspace.Current.GetFinalDtoType(type);

                            if (isCollection == true)
                            {
                                if (isAction)
                                {
                                    ((ActionConfiguration)operationConfiguration).ReturnsCollectionFromEntitySet <TDto>(controllerName);
                                }
                                else
                                {
                                    ((FunctionConfiguration)operationConfiguration).ReturnsCollectionFromEntitySet <TDto>(controllerName);
                                }
                            }
                            else
                            {
                                if (isAction)
                                {
                                    ((ActionConfiguration)operationConfiguration).ReturnsFromEntitySet <TDto>(controllerName);
                                }
                                else if (isFunction)
                                {
                                    ((FunctionConfiguration)operationConfiguration).ReturnsFromEntitySet <TDto>(controllerName);
                                }
                            }
                        }
                        else
                        {
                            if (isCollection == false)
                            {
                                if (isAction)
                                {
                                    ((ActionConfiguration)operationConfiguration).Returns(type);
                                }
                                else if (isFunction)
                                {
                                    ((FunctionConfiguration)operationConfiguration).Returns(type);
                                }
                            }
                            else
                            {
                                operationConfiguration.GetType()
                                .GetTypeInfo()
                                .GetMethod("ReturnsCollection")
                                .MakeGenericMethod(type)
                                .Invoke(operationConfiguration, Array.Empty <object>());
                            }
                        }
                    }
                    else
                    {
                        if (isFunction)
                        {
                            throw new InvalidOperationException($"Function {method.Name} in {apiController.Name} must have a return type, use action instead");
                        }

                        operationConfiguration.ReturnNullable = true;
                    }
                }
            }
        }
 public HMC6352(ushort address = DefaultAddress)
     : base(new Configuration(address, ClockSpeed))
 {
     OperationConfig = new OperationConfiguration();
 }
Beispiel #23
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                errorMessage.Text = "";
                List <RotationInfo> rotationList = controller.GetCurrentRotationInfos(SessionInfo.ExperimentID);
                if (rotationList.Count() > 0)
                {
                    this.create_button.IsEnabled = false;
                    if (SessionInfo.NextButIndex == 1)
                    {
                        this.next_button.IsEnabled = true;
                    }
                    else
                    {
                        this.next_button.IsEnabled = false;
                    }
                    this.save_button.IsEnabled      = false;
                    operation_viewcolumn.Visibility = System.Windows.Visibility.Visible;
                    operation_column.Visibility     = System.Windows.Visibility.Hidden;

                    foreach (RotationInfo rotation in rotationList)
                    {
                        System.Data.DataRow dRow = dataTable.NewRow();
                        dRow["Sequence"] = dataTable.Rows.Count + 1;
                        if (rotation.TubesBatchID != null)
                        {
                            dRow["TubesBatchID"] = rotation.TubesBatchID;
                            TubesBatch _tubeBatch = controller.GetTubesBatchByID((Guid)rotation.TubesBatchID);
                            dRow["TubesBatchName"] = _tubeBatch.TubesBatchName;
                        }

                        dRow["OperationName"] = rotation.OperationName;
                        dRow["Operation"]     = new OperationConfiguration()
                        {
                            OperationID = rotation.OperationID, OperationName = rotation.OperationName
                        };
                        dRow["RotationName"]    = rotation.RotationName;
                        dRow["deleteIsVisible"] = Visibility.Hidden.ToString();
                        dataTable.Rows.Add(dRow);
                    }
                }
                else
                {
                    this.create_button.IsEnabled    = true;
                    this.next_button.IsEnabled      = false;
                    this.save_button.IsEnabled      = true;
                    isBelongtoCurrentTubeBatch      = true;
                    operation_viewcolumn.Visibility = System.Windows.Visibility.Hidden;
                    operation_column.Visibility     = System.Windows.Visibility.Visible;

                    operation_viewcolumn.Visibility = System.Windows.Visibility.Hidden;
                    operation_column.Visibility     = System.Windows.Visibility.Visible;

                    tubesBatch = controller.GetLastTubesBatch();

                    List <OperationConfiguration> operationList = controller.GetDisplayedOperationConfigurations();
                    operation_column.ItemsSource = operationList;
                    CreateOperation = operationList[0];
                }
            }
            catch
            {
                MessageBox.Show("系统错误!", "系统提示!");

                //this.errorMessage.Text = "系统错误!";
            }
        }
Beispiel #24
0
        /// <summary>


        /// </summary>
        /// <param name="adresIPListener">Parametrem jest adres IP na ktorym nasluchujemy  </param>
        ///  /// <param name="key">Parametrem jest warotsc klucza wlasnosci z pliku config  </param>
        public void CreateConnect(string addressConnectIP, string key, CancellationToken cancellationToken = default(CancellationToken))
        {
            Socket socketClient = null;
            Socket listener     = null;


            try
            {
                byte[] bytes = new Byte[128];


                Task.Run(async() =>
                {
                    Stopwatch sw = Stopwatch.StartNew();
                    while (true)
                    {
                        if (zeroTimer == true)
                        {
                            sw = Stopwatch.StartNew();
                            canIClearMyBuffers = false;
                            zeroTimer          = false;
                        }

                        var wait = await Task.Run(async() =>
                        {
                            await Task.Delay(500);
                            sw.Stop();
                            return(sw.ElapsedMilliseconds);
                        });

                        canIClearMyBuffers = true;
                    }
                });

                //Znajac dlugosc slowa "Sending" pobieram z calej nazwy klucza tylko index, ktory wykorzystam aby dopasowac do socketu IN
                ///1-Router
                ///2-Client
                ///3-NMS
                string typeOfSocket   = key.Substring(8, key.Length - 8);
                string numberOfRouter = key.Substring(0, 1);

                //Sklejenie czesci wspolnej klucza dla socketu OUT oraz indeksu
                string settingsString = numberOfRouter + "Listener" + typeOfSocket;

                IPAddress ipAddress =
                    ipAddress = IPAddress.Parse(OperationConfiguration.getSetting(settingsString, mySettings));
                IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);

                // Create a TCP/IP socket.
                listener = new Socket(ipAddress.AddressFamily,
                                      SocketType.Stream, ProtocolType.Tcp);

                if (!listener.IsBound)
                {
                    //zabindowanie na sokecie punktu koncowego
                    listener.Bind(localEndPoint);
                    listener.Listen(100);
                }



                //Nasluchujemy bez przerwy
                while (Last)
                {
                    if (Listening)
                    {
                        //Dodanie socketu do listy socketow OUT
                        socketSendingList.Add(sS.ConnectToEndPoint(addressConnectIP));
                        //oczekiwanie na polaczenie
                        socketClient = listener.Accept();
                        //dodanie do listy sluchaczy po przez delegata
                        socketListenerList.Add(socketClient);
                        Socket send = null;

                        Listening = false;

                        string tmp = string.Empty;
                        //wyznaczenie socketu przez ktory wyslana zostanie wiadomosc
                        if (numberOfRouter == "1")
                        {
                            tmp = "127.0.0.12";
                        }
                        else if (numberOfRouter == "2")
                        {
                            tmp = "127.0.0.10";
                        }
                        else if (numberOfRouter == "3")
                        {
                            tmp = "127.0.0.8";
                        }

                        //Oczekiwanie w petli na przyjscie danych
                        while (true)
                        {
                            byte[] msg;
                            string from = string.Empty;
                            //Odebranie tablicy bajtow na obslugiwanym w watku sluchaczu

                            msg = sl.ProcessRecivedBytes(socketClient);
                            stateReceivedMessageFromCableCloud(msg, socketClient);

                            // Package.extractHowManyPackages(msg);
                            // listByte.Add(msg);

                            //Wykonuje jezeli nadal zestawione jest polaczenie
                            if (socketClient.Connected)
                            {
                                //Uzyskanie czestotliwosci zawartej w naglowku- potrzebna do okreslenia ktorym laczem idzie wiadomosc
                                portNumber = Package.extractPortNumber(msg);
                                from       = takingAddresListenerSocket(socketClient) + " " + portNumber;
                                Package p = new Package(msg);

                                foreach (var socket in socketSendingList)
                                {
                                    //zwracamy socket jeśli host z ktorym sie laczy spelnia warunek zgodnosci adresow z wynikiem kierowania lacza
                                    if (takingAddresSendingSocket(socket) == tmp)
                                    {
                                        send = socket;
                                    }
                                }

                                List <Queue <byte[]> > listOfQueue = new List <Queue <byte[]> >();

                                List <Queue <byte[]> > listOfQueues = commutationField.processPackage(msg);

                                //Jak zwrocila null to jeszcze bufor nie jest pelny
                                if (listOfQueues == null)
                                {
                                    /* if (canIClearMyBuffers == true)
                                     * {
                                     *   byte[] tempBufferIn;
                                     *   for (int z = 0; z < commutationField.bufferIn.queue.Count; z++)
                                     *   {
                                     *       while (commutationField.bufferIn.queue.Count > 0)
                                     *       {
                                     *           tempBufferIn = commutationField.bufferIn.queue.Dequeue();
                                     *           byte[] obytes = commutationField.borderNodeCommutationTable.changePackageHeader2(tempBufferIn, ref commutationField);
                                     *
                                     *           stateSendingMessageToCableCloud(obytes, send);
                                     *           sS.SendingPackageBytes(send, obytes);
                                     *       }
                                     *   }
                                     *   canIClearMyBuffers = false;
                                     *   zeroTimer = true;
                                     *
                                     * }*/
                                    continue;
                                }//w przeciwnym razie zwraca nam liste kolejek
                                else
                                {
                                    for (int i = 0; i < listOfQueues.Count; i++)
                                    {
                                        //Dopoki cos jest w podkolejce
                                        while (listOfQueues[i].Count != 0)
                                        {
                                            //Element z listy kolejek moze byc nullem
                                            if (listOfQueues[i].Count != 0)
                                            {
                                                stateSendingMessageToCableCloud(listOfQueues[i].Peek(), send);
                                                //Zdjecie z kolejki pakietu i wyslanie go
                                                sS.SendingPackageBytes(send, listOfQueues[i].Dequeue());
                                            }
                                            //A jak jest nullem to nic nie robimy
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //Jezeli host zerwie polaczneie to usuwamy go z listy przetrzymywanych socketow, aby rozpoczac proces nowego polaczenia
                                int numberRemove = socketListenerList.IndexOf(socketClient);
                                socketListenerList.RemoveAt(numberRemove);
                                socketSendingList.RemoveAt(numberRemove);
                                break;
                            }
                        }
                        Listening = true;
                    }
                }
            }
            catch (SocketException se)
            {
                Console.WriteLine($"Socket Exception: {se}");
            }
            finally
            {
                // StopListening();
            }
            if (socketClient == null)
            {
            }
        }
Beispiel #25
0
        private void save_button_Click(object sender, RoutedEventArgs e)
        {
            if (!validate())
            {
                return;
            }

            List <RotationInfo> rotationInfoList = new List <RotationInfo>();

            foreach (DataRow row in dataTable.Rows)
            {
                RotationInfo rotationInfo = new RotationInfo();
                rotationInfo.RotationID   = WanTaiObjectService.NewSequentialGuid();
                rotationInfo.ExperimentID = SessionInfo.ExperimentID;
                if (row["TubesBatchID"] != null && !string.IsNullOrEmpty(row["TubesBatchID"].ToString()))
                {
                    rotationInfo.TubesBatchID = new Guid(row["TubesBatchID"].ToString());
                }

                if (row["RotationName"] != null && !string.IsNullOrEmpty(row["RotationName"].ToString()))
                {
                    rotationInfo.RotationName = row["RotationName"].ToString();
                }

                rotationInfo.State      = (short)RotationInfoStatus.Create;
                rotationInfo.CreateTime = DateTime.Now;

                OperationConfiguration operation = row["Operation"] as OperationConfiguration;
                rotationInfo.OperationID   = operation.OperationID;
                rotationInfo.OperationName = operation.OperationName;

                rotationInfo.RotationSequence = (short)row["Sequence"];

                rotationInfoList.Add(rotationInfo);
            }

            if (controller.Create(rotationInfoList))
            {
                //if (SessionInfo.PraperRotation == null)
                //{
                Guid RotationID = Guid.Empty;
                if (SessionInfo.PraperRotation != null)
                {
                    RotationID = SessionInfo.PraperRotation.RotationID;
                }
                SessionInfo.PraperRotation = rotationInfoList.FirstOrDefault();

                FormulaParameters formulaParameters = SessionInfo.RotationFormulaParameters[RotationID];
                SessionInfo.RotationFormulaParameters.Remove(RotationID);
                if (!SessionInfo.RotationFormulaParameters.ContainsKey(SessionInfo.PraperRotation.RotationID))
                {
                    SessionInfo.RotationFormulaParameters.Add(SessionInfo.PraperRotation.RotationID, formulaParameters);
                }
                else
                {
                    SessionInfo.RotationFormulaParameters[SessionInfo.PraperRotation.RotationID] = formulaParameters;
                }
                // }


                //  MessageBox.Show("保存成功!", "系统提示");
                if (NextStepEvent != null)
                {
                    NextStepEvent(sender, e);
                }

                this.next_button.IsEnabled = true;
            }
            else
            {
                MessageBox.Show("保存失败!", "系统提示");
            }
        }
Beispiel #26
0
        private bool validate()
        {
            this.errorMessage.Text = "";

            if (dataTable.Rows.Count == 0)
            {
                MessageBox.Show("请至少配置一个轮次!", "系统提示");
                //  this.errorMessage.Text = "请至少配置一个轮次";
                return(false);
            }

            int index = 0;
            int previous_OperationSequence = 1;

            foreach (DataRow row in dataTable.Rows)
            {
                OperationConfiguration operation = row["Operation"] as OperationConfiguration;
                if (operation == null)
                {
                    MessageBox.Show("请选择操作!", "系统提示");
                    // this.errorMessage.Text = "请选择操作";
                    return(false);
                }

                if (index == 0)
                {
                    if (((int)operation.OperationType != (int)OperationType.Grouping) && operation.OperationSequence != 1)
                    {
                        MessageBox.Show("轮次的操作必须是混样或者完整操作!", "系统提示");
                        // this.errorMessage.Text = "轮次的操作必须是混样或者完整操作";
                        return(false);
                    }
                }
                else if ((int)operation.OperationType == (int)OperationType.Grouping)
                {
                }
                else
                {
                    if (previous_OperationSequence == 0 && operation.OperationSequence != 1)
                    {
                        MessageBox.Show("轮次的操作必须是混样或者完整操作!", "系统提示");
                        // this.errorMessage.Text = "轮次的操作必须是混样或者完整操作";
                        return(false);
                    }
                    else if (operation.OperationSequence != 1 && (operation.OperationSequence != previous_OperationSequence + 1))
                    {
                        MessageBox.Show("轮次的操作必须按照顺序!", "系统提示");
                        //   this.errorMessage.Text = "轮次的操作必须按照顺序";
                        return(false);
                    }
                }

                if ((int)operation.OperationType == (int)OperationType.Grouping)
                {
                    previous_OperationSequence = 0;
                }
                else
                {
                    previous_OperationSequence = operation.OperationSequence;
                }

                index++;
            }

            return(true);
        }
Beispiel #27
0
        private void CmbOperation_SelectionChanged(object sender, RoutedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;
            OperationConfiguration selectedOperation = comboBox.SelectedItem as OperationConfiguration;

            if (selectedOperation == null)
            {
                return;
            }

            int selectedRowIndex = rotation_dataGrid.SelectedIndex;

            if (selectedRowIndex == 0)
            {
                //第一个必须是组合操作或者是混样
                if (selectedOperation != null &&
                    ((int)selectedOperation.OperationType == (int)OperationType.Single && selectedOperation.OperationSequence != 1))
                {
                    MessageBox.Show("第一个轮次的操作必须是混样或者完整操作!", "系统提示!");
                    // this.errorMessage.Text = "第一个轮次的操作必须是混样或者完整操作";
                    return;
                }
            }
            else
            {
                DataRow previous_row             = dataTable.Rows[selectedRowIndex - 1];
                OperationConfiguration operation = previous_row["Operation"] as OperationConfiguration;
                if (operation != null && selectedOperation != null)
                {
                    if (string.IsNullOrEmpty(previous_row["TubesBatchName"] as string) || (selectedOperation.OperationSequence == 1 && selectedRowIndex > 0))
                    {
                        dataTable.Rows[selectedRowIndex]["TubesBatchName"] = null;
                        dataTable.Rows[selectedRowIndex]["TubesBatchID"]   = null;
                        isBelongtoCurrentTubeBatch = false;
                    }
                    else
                    {
                        if (operation.OperationSequence + 1 == selectedOperation.OperationSequence)
                        {
                            isBelongtoCurrentTubeBatch = true;
                            dataTable.Rows[selectedRowIndex]["TubesBatchName"] = tubesBatch.TubesBatchName;
                            dataTable.Rows[selectedRowIndex]["TubesBatchID"]   = tubesBatch.TubesBatchID;
                        }
                        else
                        {
                            isBelongtoCurrentTubeBatch = false;
                            dataTable.Rows[selectedRowIndex]["TubesBatchName"] = null;
                            dataTable.Rows[selectedRowIndex]["TubesBatchID"]   = null;
                        }
                    }

                    if (selectedOperation.OperationType != (int)OperationType.Grouping && (int)operation.OperationType == (int)OperationType.Grouping && selectedOperation.OperationSequence != 1)
                    {
                        MessageBox.Show("轮次的操作必须是混样或者完整操作!", "系统提示!");

                        //   this.errorMessage.Text = "轮次的操作必须是混样或者完整操作";
                        return;
                    }
                    else if (selectedOperation.OperationType != (int)OperationType.Grouping && selectedOperation.OperationSequence != 1 && (operation.OperationSequence + 1 != selectedOperation.OperationSequence))
                    {
                        MessageBox.Show("轮次的操作必须按照顺序!", "系统提示!");
                        //  this.errorMessage.Text = "轮次的操作必须按照顺序";
                        return;
                    }
                }
            }

            this.errorMessage.Text = "";
        }
Beispiel #28
0
        private static void AddOperationLinkBuilder(IEdmModel model, IEdmOperation operation, OperationConfiguration operationConfiguration)
        {
            Contract.Assert(model != null);
            ActionConfiguration   actionConfiguration = operationConfiguration as ActionConfiguration;
            IEdmAction            action = operation as IEdmAction;
            FunctionConfiguration functionConfiguration = operationConfiguration as FunctionConfiguration;
            IEdmFunction          function = operation as IEdmFunction;

            if (operationConfiguration.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Entity)
            {
                //if (actionConfiguration != null && actionConfiguration.GetActionLink() != null && action != null)
                //{
                //    model.SetOperationLinkBuilder(
                //        action,
                //        new OperationLinkBuilder(actionConfiguration.GetActionLink(), actionConfiguration.FollowsConventions));
                //}
                //else if (functionConfiguration != null && functionConfiguration.GetFunctionLink() != null && function != null)
                //{
                //    model.SetOperationLinkBuilder(
                //        function,
                //        new OperationLinkBuilder(functionConfiguration.GetFunctionLink(), functionConfiguration.FollowsConventions));
                //}
            }
            else if (operationConfiguration.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Collection)
            {
                CollectionTypeConfiguration collectionTypeConfiguration =
                    (CollectionTypeConfiguration)operationConfiguration.BindingParameter.TypeConfiguration;

                if (collectionTypeConfiguration.ElementType.Kind == EdmTypeKind.Entity)
                {
                    //if (actionConfiguration != null && actionConfiguration.GetFeedActionLink() != null && action != null)
                    //{
                    //    model.SetOperationLinkBuilder(
                    //        action,
                    //        new OperationLinkBuilder(actionConfiguration.GetFeedActionLink(), actionConfiguration.FollowsConventions));
                    //}
                    //else if (functionConfiguration != null && functionConfiguration.GetFeedFunctionLink() != null && function != null)
                    //{
                    //    model.SetOperationLinkBuilder(
                    //        function,
                    //        new OperationLinkBuilder(functionConfiguration.GetFeedFunctionLink(), functionConfiguration.FollowsConventions));
                    //}
                }
            }
        }
Beispiel #29
0
        public static IEdmModel BuildEdmModel(Type ApiContextType)
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder();

            builder.Namespace = ApiContextType.Namespace;

            var publicProperties = ApiContextType.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (var property in publicProperties)
            {
                var entityClrType = TypeHelper.GetImplementedIEnumerableType(property.PropertyType);
                EntityTypeConfiguration entity = builder.AddEntityType(entityClrType);
                builder.AddEntitySet(property.Name, entity);
            }

            // Get the actions and functions into the model
            var publicMethods = ApiContextType.GetMethods(BindingFlags.Public | BindingFlags.Instance);

            foreach (var method in publicMethods)
            {
                if (!method.IsSpecialName)
                {
                    var entityClrType = TypeHelper.GetImplementedIEnumerableType(method.ReturnType) ?? method.ReturnType;
                    OperationConfiguration     configuration       = null;
                    PrimitiveTypeConfiguration primitiveEntityType = null;
                    EntityTypeConfiguration    entityType          = null;

                    if (entityClrType.GetTypeInfo().IsPrimitive ||
                        entityClrType.GetType() == typeof(decimal) ||
                        entityClrType.GetType() == typeof(string))
                    {
                        primitiveEntityType = builder.AddPrimitiveType(entityClrType);
                    }
                    else
                    {
                        entityType = builder.AddEntityType(entityClrType);
                    }

                    var functionAttribute = method.GetCustomAttribute <ODataFunctionAttribute>();
                    if (functionAttribute != null)
                    {
                        configuration = builder.Function(method.Name);
                        if (functionAttribute.IsBound)
                        {
                            configuration.SetBindingParameterImplementation(functionAttribute.BindingName, entityType);
                        }
                    }

                    var actionAttribute = method.GetCustomAttribute <ODataActionAttribute>();
                    if (actionAttribute != null)
                    {
                        configuration = builder.Action(method.Name);
                        if (actionAttribute.IsBound)
                        {
                            configuration.SetBindingParameterImplementation(actionAttribute.BindingName, entityType);
                        }
                    }

                    if (configuration != null)
                    {
                        if (primitiveEntityType == null)
                        {
                            configuration.ReturnType = entityType;
                        }
                        else
                        {
                            configuration.ReturnType = primitiveEntityType;
                        }

                        configuration.IsComposable     = true;
                        configuration.NavigationSource =
                            builder.NavigationSources.FirstOrDefault(n => n.EntityType == entityType) as NavigationSourceConfiguration;

                        foreach (var parameterInfo in method.GetParameters())
                        {
                            if (parameterInfo.ParameterType.GetTypeInfo().IsPrimitive ||
                                parameterInfo.ParameterType == typeof(decimal) ||
                                parameterInfo.ParameterType == typeof(string))
                            {
                                var primitiveType = builder.AddPrimitiveType(parameterInfo.ParameterType);
                                configuration.AddParameter(parameterInfo.Name, primitiveType);
                            }
                            else
                            {
                                if (parameterInfo.ParameterType.IsCollection())
                                {
                                    if (parameterInfo.ParameterType.GenericTypeArguments[0].GetTypeInfo().IsPrimitive)
                                    {
                                        var parameterType        = builder.AddPrimitiveType(parameterInfo.ParameterType.GenericTypeArguments[0]);
                                        var collectionTypeConfig = new CollectionTypeConfiguration(parameterType, parameterInfo.ParameterType.GenericTypeArguments[0]);
                                        configuration.AddParameter(parameterInfo.Name, collectionTypeConfig);
                                    }
                                    else
                                    {
                                        var parameterType        = builder.AddEntityType(parameterInfo.ParameterType.GenericTypeArguments[0]);
                                        var collectionTypeConfig = new CollectionTypeConfiguration(parameterType, parameterInfo.ParameterType.GenericTypeArguments[0]);
                                        configuration.AddParameter(parameterInfo.Name, collectionTypeConfig);
                                    }
                                }
                                else
                                {
                                    var parameterType = builder.AddEntityType(parameterInfo.ParameterType);
                                    configuration.AddParameter(parameterInfo.Name, parameterType);
                                }
                            }
                        }
                    }
                }
            }

            return(builder.GetEdmModel());
        }
Beispiel #30
0
        private static IEdmExpression GetEdmEntitySetExpression(IDictionary <string, EdmNavigationSource> navigationSources, OperationConfiguration operationConfiguration)
        {
            if (operationConfiguration.NavigationSource != null)
            {
                EdmNavigationSource navigationSource;
                if (navigationSources.TryGetValue(operationConfiguration.NavigationSource.Name, out navigationSource))
                {
                    EdmEntitySet entitySet = navigationSource as EdmEntitySet;
                    if (entitySet != null)
                    {
                        return(new EdmPathExpression(entitySet.Name));
                    }
                }
                else
                {
                    throw Error.InvalidOperation(SRResources.EntitySetNotFoundForName, operationConfiguration.NavigationSource.Name);
                }
            }
            else if (operationConfiguration.EntitySetPath != null)
            {
                return(new EdmPathExpression(operationConfiguration.EntitySetPath));
            }

            return(null);
        }
Beispiel #31
0
        private static void ValidateOperationEntitySetPath(IEdmModel model, IEdmOperationImport operationImport, OperationConfiguration operationConfiguration)
        {
            IEdmOperationParameter operationParameter;
            Dictionary <IEdmNavigationProperty, IEdmPathExpression> relativeNavigations;
            IEnumerable <EdmError> edmErrors;

            if (operationConfiguration.EntitySetPath != null && !operationImport.TryGetRelativeEntitySetPath(model, out operationParameter, out relativeNavigations, out edmErrors))
            {
                throw Error.InvalidOperation(SRResources.OperationHasInvalidEntitySetPath, String.Join("/", operationConfiguration.EntitySetPath), operationConfiguration.FullyQualifiedName);
            }
        }