Exemple #1
0
        // Поехали!!!
        public bool Execute(ActionCallingContext oActionCallingContext)
        {
            string objectNames = "";

            oActionCallingContext.GetParameter("objects", ref objectNames);
            // Получим объект текущей строки. Конечно, объектов может быт несколько, но не в этом отчете...
            StorableObject cable = StorableObject.FromStringIdentifier(objectNames);
            // Получим свойство 20237 "Топология: Трасса маршрутизации"
            string sCABLING_PATH = cable.Properties[20237];

            MatchCollection matches      = regex.Matches(sCABLING_PATH);
            String          filteredPath = "";

            var enumerator = matches.GetEnumerator();

            if (enumerator.MoveNext())
            {
                filteredPath = ((Match)enumerator.Current).Value;
                while (enumerator.MoveNext())
                {
                    filteredPath += ";" + (Match)enumerator.Current;
                }
            }

            string[] strings = new string[1];
            strings[0] = filteredPath;
            oActionCallingContext.SetStrings(strings);
            return(true);
        }
 /// <summary>
 /// Получить выбранный на графической схеме объект
 /// </summary>
 /// <returns>Выбранный на схеме объект</returns>
 public static StorableObject GetSelectedObject()
 {
     SelectionSet selection = GetSelectionSet();
     const bool isFirstObject = true;
     StorableObject selectedObject = selection.
         GetSelectedObject(isFirstObject);
     return selectedObject;
 }
        public bool IsMatching(StorableObject objectToCheck)
        {
            Connection c = (Connection)objectToCheck;

            if (c.EndSymbolReference is Function && c.StartSymbolReference is Function)
            {
                return(true);
            }
            return(false);
        }
Exemple #4
0
        public bool IsMatching(StorableObject objectToCheck)
        {
            if (objectToCheck is Function)//objectToCheck.GetType() == new Function().GetType()
            {
                Function f = (Function)objectToCheck;

                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Получить функцию выбранной клеммы
        /// </summary>
        /// <param name="selectedObject">Выбранный на схеме объект
        /// </param>
        /// <returns>Функция клеммы модуля ввода-вывода</returns>
        public Function GetSelectedClampFunction(StorableObject selectedObject)
        {
            var clampFunction = selectedObject as Function;

            if (clampFunction.Category != Function.Enums.Category.PLCTerminal)
            {
                const string Message = "Выбранная функция не является " +
                                       "клеммой модуля ввода-вывода";
                throw new Exception(Message);
            }

            return(clampFunction);
        }
        /// <summary>
        /// Получить объект выбранный на графической схеме
        /// </summary>
        /// <returns>Выбранный на схеме объект</returns>
        public StorableObject GetSelectedObject()
        {
            SelectionSet   selection      = GetSelectionSet();
            const bool     isFirstObject  = true;
            StorableObject selectedObject = selection.
                                            GetSelectedObject(isFirstObject);

            if (selectedObject is Function == false)
            {
                const string Message = "Выбранный на схеме объект не найден";
                throw new Exception(Message);
            }

            return(selectedObject);
        }
        private static void ReplacePlaceholder(StorableObject foundObject, string identifier)
        {
            // Filter only text objects
            // EPLAN fix (2.6) T1085938
            var existingValues = foundObject.Properties.ExistingValues
                                 .Where(p => !p.Definition.IsInternal &&
                                        !p.Definition.IsReadOnly &&
                                        (
                                            p.Definition.Type == PropertyDefinition.PropertyType.MultilangString ||
                                            p.Definition.Type == PropertyDefinition.PropertyType.String))
                                 .ToList();
            List <PropertyValue> existingValuesWithoutEmpty = new List <PropertyValue>();

            foreach (var propertyValue in existingValues)
            {
                if (propertyValue.Definition.IsIndexed)
                {
                    foreach (int index in propertyValue.Indexes)
                    {
                        if (!propertyValue[index].IsEmpty)
                        {
                            existingValuesWithoutEmpty.Add(propertyValue[index]);
                        }
                    }
                }
                else
                {
                    if (!propertyValue.IsEmpty)
                    {
                        existingValuesWithoutEmpty.Add(propertyValue);
                    }
                }
            }

            // Fix fields without placeholder in search result and replace the eplan specific search brackets
            existingValues = existingValuesWithoutEmpty
                             .Where(obj => obj.ToString().Contains(
                                        identifier.Replace("[", "").Replace("]", "")))
                             .ToList();

            // Replace
            foreach (PropertyValue propertyValue in existingValues)
            {
                //propertyValue.Parent?.Parent?.SmartLock();
                propertyValue.Set("");
            }
        }
        /// <summary>
        /// Поиск функции выбранного объекта
        /// </summary>
        /// <param name="selectedObject">Выбранный объект</param>
        /// <returns></returns>
        private Function SearchSelectedObjectFunction(
            StorableObject selectedObject)
        {
            Function oF = null;

            if (selectedObject is Rectangle rect)
            {
                string oFName = rect.Properties.get_PROPUSER_TEST(1);
                oF = Function.FromStringIdentifier(oFName) as Function;
            }

            if (selectedObject is Function func)
            {
                oF = func;
            }

            return(oF);
        }
Exemple #9
0
        /// <summary>
        /// Получить функцию выбранной клеммы
        /// </summary>
        /// <param name="selectedObject">Выбранный на схеме объект
        /// </param>
        /// <returns>Функция клеммы модуля ввода-вывода</returns>
        public static Function GetClampFunction(
            StorableObject selectedObject)
        {
            if (selectedObject is Function == false)
            {
                const string Message = "Выбранный на схеме объект не " +
                                       "является функцией";
                throw new Exception(Message);
            }

            var clampFunction = selectedObject as Function;

            if (clampFunction.Category != Function.Enums.Category.PLCTerminal)
            {
                const string Message = "Выбранная функция не является " +
                                       "клеммой модуля ввода-вывода";
                throw new Exception(Message);
            }

            return(clampFunction);
        }
Exemple #10
0
        public IEnumerable <IStorageEntity> Select(StorableObject so, int?maxCount)
        {
            var pkName = so.Untag(PartitionKey);
            var rkName = so.Untag(RowKey);

            var qb = new QueryBuilder();

            foreach ((StorableProperty property, string op, object v) in so.EnumConditions())
            {
                if (property.Name == pkName)
                {
                    qb.Add(op, PartitionKey.String, QFormat(Serializer.SerializeKeyValue(v)));
                }
                else if (property.Name == rkName)
                {
                    qb.Add(op, RowKey.String, QFormat(Serializer.SerializeKeyValue(v)));
                }
                else
                {
                    qb.Add(op, property.Name, QFormat(Serializer.SerializeValue(v)));
                }
            }
            return(Select(qb.ToString(), maxCount, so.FieldSelection.List));
        }
Exemple #11
0
        public static void HandleException(Exception exception, string name, UndoStep undoStep = null)
        {
            Decider decider = new Decider();

            string message;

            if (undoStep == null)
            {
                message = "Es ist ein Fehler beim Erzeugen aufgetreten:";
            }
            else
            {
                message = "Es ist ein Fehler beim Erzeugen aufgetreten. Soll die Aktion rückgängig gemacht werden?";
            }

            string        errorText;
            StringBuilder sb = new StringBuilder();

            switch (exception)
            {
            case LockingException e:
                string[] failedLockingObjects = e.GetAllFailed2LockAsString();
                foreach (var id in failedLockingObjects)
                {
                    var storableObject = StorableObject.FromStringIdentifier(id);
                    sb.AppendLine(storableObject.GetType().ToString());
                }

                errorText = $"{message}{Environment.NewLine}{exception.Message}{Environment.NewLine}{Environment.NewLine}{sb}{Environment.NewLine}";
                break;

            default:
                errorText = $"{message}{Environment.NewLine}{exception.Message}{Environment.NewLine}{Environment.NewLine}";
                break;
            }

            // Log
            BaseException bexError = new BaseException($"{name}: {errorText}{Environment.NewLine}{exception}", MessageLevel.Error);

            bexError.FixMessage();

            // Show
            EnumDecisionReturn decision;

            if (undoStep != null)
            {
                decision = decider.Decide(EnumDecisionType.eYesNoDecision, errorText,
                                          name, EnumDecisionReturn.eYES,
                                          EnumDecisionReturn.eYES, name, false, EnumDecisionIcon.eFATALERROR);
            }
            else
            {
                decision = decider.Decide(EnumDecisionType.eOkDecision, errorText,
                                          name, EnumDecisionReturn.eOK,
                                          EnumDecisionReturn.eOK, name, false, EnumDecisionIcon.eFATALERROR);
            }
            switch (decision)
            {
            case EnumDecisionReturn.eYES:
                undoStep?.DoUndo();
                break;
            }
        }
Exemple #12
0
 private void SetUp()
 {
     KartShop         = new StorableObject <Observable.ShoppingCartItem>();
     GlobalDishFilter = new FilterDtoSearchObject {
     };
 }
Exemple #13
0
 public IStorageEntity GetEntity(StorableObject so) => new Entity(cloudTable, so);