Exemple #1
1
        private Int16 GetTagCanonicalType(string itemName)
        {
            const int ItemCanonicalDataTypeProperty = 1;

            TreeNode rootNode = uiGroupsTab_AllFoldersTreeView.SelectedNode;
            while (rootNode.Parent != null)
            {
                rootNode = rootNode.Parent;
            }

            var opcServer = Settings.OpcServers.Where(os => rootNode.FullPath == os.ServerName).Single();
            string urlstring = opcServer.URL;
            Server server = new Server(new Factory(), new URL(urlstring));
            server.Connect();

            ItemIdentifier [] itemIdentifiers = new ItemIdentifier[] {new ItemIdentifier(itemName)};
            PropertyID[] propertyIDs = new PropertyID[] { new PropertyID(ItemCanonicalDataTypeProperty) };

            var result = server.GetProperties(itemIdentifiers, propertyIDs, true);

            server.Disconnect();

            var resultType = result[0][0].Value.GetType();
            PropertyInfo nameProperty = resultType.GetProperty("Name");
            string name = nameProperty.GetValue(result[0][0].Value, null) as string;

            switch (name.ToLower())
            {
                case "string":
                case "char":
                    return 0;
                case "int16":
                case "int32":
                case "int64":
                case "uint16":
                case "uint32":
                case "uint64":
                    return 1;
                case "boolean":
                    return 2;
                case "decimal":
                case "double":
                    return 3;
                case "datetime":
                case "datetimeoffset":
                    return 4;
                default:
                    return 0;
            }
        }
 public void FillTagsTable(BrowseElement _element)
 {
     this.TagsDT.Clear();
     if (_element != null)
     {
         ItemIdentifier itemID         = new ItemIdentifier(_element.ItemPath, _element.ItemName);
         BrowsePosition browsePosition = new BrowsePosition(itemID, this.m_filters);
         if (_element.HasChildren)
         {
             BrowseElement[] array = this.server.Browse(itemID, this.m_filters, out browsePosition);
             if (array != null)
             {
                 BrowseElement[] array2 = array;
                 for (int i = 0; i < array2.Length; i++)
                 {
                     BrowseElement browseElement = array2[i];
                     if (!browseElement.ItemName.Contains("alrosa_w") && !browseElement.ItemName.Contains("List of"))
                     {
                         this.Browse(browseElement);
                     }
                 }
             }
         }
     }
 }
        public static void ShowItemAwardPopup(this Level level, ItemIdentifier itemIdentifier)
        {
            switch (itemIdentifier.LootType)
            {
            case LootType.ConstOrb:
                level.AddScript((ScriptAction)typeof(ScriptAction).CreateInstance(true, itemIdentifier.OrbType, itemIdentifier.OrbSlot));
                break;

            case LootType.ConstFamiliar:
                level.AddScript((ScriptAction)typeof(ScriptAction).CreateInstance(true, itemIdentifier.Familiar));
                break;

            case LootType.ConstRelic:
                level.AddScript((ScriptAction)typeof(ScriptAction).CreateInstance(true, itemIdentifier.Relic));
                break;

            case LootType.ConstEquipment:
                level.AddScript((ScriptAction)typeof(ScriptAction).CreateInstance(true, itemIdentifier.Equipment));
                break;

            case LootType.ConstUseItem:
                level.AddScript((ScriptAction)typeof(ScriptAction).CreateInstance(true, itemIdentifier.UseItem, 1));
                break;

            case LootType.ConstStat:
                RequestToastPopupForStats(level, itemIdentifier);
                break;

            default:
                throw new NotImplementedException($"RelicOrOrbGetPopup is not implemented for LootType {itemIdentifier.LootType}");
            }
        }
Exemple #4
0
        private static void ConvertListIndexToEntityIds(ContentGroup contentGroup, ItemIdentifier reqItem,
                                                        string contentTypeStaticName)
        {
            var part = contentGroup[reqItem.Group.Part];

            reqItem.ContentTypeName = contentTypeStaticName;
            if (!reqItem.Group.Add &&               // not in add-mode
                part.Count > reqItem.Group.Index && // has as many items as desired
                part[reqItem.Group.Index] != null)  // and the slot has something
            {
                reqItem.EntityId = part[reqItem.Group.Index].EntityId;
            }

            // tell the UI that it should not actually use this data yet, keep it locked
            if (!reqItem.Group.Part.ToLower().Contains(AppConstants.PresentationLower))
            {
                return;
            }

            reqItem.Group.SlotCanBeEmpty = true;     // all presentations can always be locked

            if (reqItem.EntityId != 0)
            {
                return;
            }

            reqItem.Group.SlotIsEmpty = true;     // if it is blank, then lock this one to begin with

            reqItem.DuplicateEntity =
                reqItem.Group.Part.ToLower() == AppConstants.PresentationLower
                        ? contentGroup.Template.PresentationDemoEntity?.EntityId
                        : contentGroup.Template.ListPresentationDemoEntity?.EntityId;
        }
Exemple #5
0
        public override void PackagedResource(Type itemType, ItemIdentifier itemId, Resource resource)
        {
            {
                var item     = PersistenceManager.Default.RetrieveItem <Template>(itemId);
                var encoding = Core.Settings.Encoding;

                var    contents    = resource.ResourceContents;
                string fileContent = string.Empty;

                if (contents == null || contents.Length <= 0)
                {
                    string p = Context.Current.MapPath(resource.PackageFromPath);

                    if (System.IO.File.Exists(p))
                    {
                        contents    = System.IO.File.ReadAllBytes(p);
                        fileContent = encoding.GetString(contents);
                    }
                }
                else
                {
                    fileContent = encoding.GetString(contents);
                }

                if (fileContent != string.Empty)
                {
                    fileContent = ReplaceMacrosInstring(fileContent, true, item);
                    resource.ResourceContents = encoding.GetBytes(fileContent);
                }
            }
        }
        private static ISyncable SyncableItemFromDeviceItem(DeviceItemViewModel deviceItem)
        {
            Dictionary        props      = PropertyMapping.MediaPropertiesFromZmdbProperties(deviceItem.ZmdbProperties);
            SyncableMediaItem item       = new SyncableMediaItem(deviceItem.Name, props);
            ItemIdentifier    identifier = new ItemIdentifier {
                IdValue     = deviceItem.ZmdbId,
                ItemIdSpace = IdSpaceConstants.ZmdbId
            };

            item.ItemId     = identifier;
            item.LastUpdate = DateTime.UtcNow;
            switch (deviceItem.ItemType)
            {
            case DeviceItemType.Photo:
                item.Properties.SetObjectForKey(true, "Picture", null);
                return(item);

            case DeviceItemType.Music:
            case DeviceItemType.AudioPodcast:
                item.Properties.SetObjectForKey(true, "Audio", null);
                return(item);

            case DeviceItemType.Video:
            case DeviceItemType.VideoPodcast:
                item.Properties.SetObjectForKey(true, "Has Video", null);
                return(item);
            }
            return(item);
        }
Exemple #7
0
        void Document_AfterUnPublish(Document sender, umbraco.cms.businesslogic.UnPublishEventArgs e)
        {
            ItemIdentifier itemId     = new ItemIdentifier(sender.UniqueId.ToString(), ItemProviders.ProviderIDCollection.documentItemProviderGuid);
            ItemIdentifier propertyId = new ItemIdentifier(sender.UniqueId.ToString(), ItemProviders.ProviderIDCollection.propertyDataItemProviderGuid);

            sendToCache(new[] { itemId, propertyId });
        }
Exemple #8
0
        /* PACKAGING */
        public Item Package(ItemIdentifier itemId)
        {
            var  provider = Umbraco.Courier.Core.ProviderModel.ItemProviderCollection.Instance.GetProvider(itemId.ProviderId, Database, ExecutionContext);
            Item it       = Core.Cache.ItemCacheManager.Instance.GetItem(itemId, provider);

            if (it == null)
            {
                it = provider.Package(itemId);
                if (it != null)
                {
                    Core.Cache.ItemCacheManager.Instance.StoreItemAsync(it, provider);
                }
            }


            if (it == null)
            {
                return(null);
            }
            // throw new Exception(String.Format("Failed to package {0} with provider {1}", itemId.Id, provider.Name));

            //this only for internal logging of the queue on remote contexts
            provider.ExecutionContext.CurrentPackaging.Queue.Add(it.ItemId);
            return(it);
        }
Exemple #9
0
        /// <summary>
        /// Returns the complex item for the specified item id.
        /// </summary>
        public static ComplexItem GetComplexItem(ItemIdentifier itemID)
        {
            if (itemID == null)
            {
                return(null);
            }

            lock (typeof(ComplexTypeCache))
            {
                ComplexItem item = new ComplexItem(itemID);

                try
                {
                    item.Update(m_server);
                }
                catch
                {
                    // item is not a valid complex data item.
                    item = null;
                }

                m_items[itemID.Key] = item;
                return(item);
            }
        }
Exemple #10
0
        public override bool ShouldExecute(Type itemType, ItemIdentifier itemId, Resource resource, Core.Enums.ItemEvent eventType)
        {
            if (itemType == typeof(Template) && resource.PackageFromPath.ToLower().EndsWith(".master")  )
                return true;

            return false;
        }
Exemple #11
0
        public string SaveResourceContents(ItemIdentifier itemId, Type itemType, Resource resource, string revisionAlias)
        {
            throw new NotImplementedException();

            var relPath      = resource.ExtractToPath;
            var fileContents = resource.ResourceContents;
        }
Exemple #12
0
        // Token: 0x06000365 RID: 869 RVA: 0x0000958C File Offset: 0x0000858C
        public static string GetTypeDescription(ItemIdentifier itemID)
        {
            if (itemID == null)
            {
                return(null);
            }
            string result;

            lock (typeof(ComplexTypeCache))
            {
                string      text        = null;
                ComplexItem complexItem = ComplexTypeCache.GetComplexItem(itemID);
                if (complexItem != null)
                {
                    text = (string)ComplexTypeCache.m_descriptions[complexItem.TypeItemID.Key];
                    if (text != null)
                    {
                        return(text);
                    }
                    text = ((string)(m_descriptions[complexItem.TypeItemID.Key] = complexItem.GetTypeDescription(m_server)));
                }
                result = text;
            }
            return(result);
        }
Exemple #13
0
        // Token: 0x06000364 RID: 868 RVA: 0x00009518 File Offset: 0x00008518
        public static string GetTypeDictionary(ItemIdentifier itemID)
        {
            if (itemID == null)
            {
                return(null);
            }
            string result;

            lock (typeof(ComplexTypeCache))
            {
                string text = (string)ComplexTypeCache.m_dictionaries[itemID.Key];
                if (text != null)
                {
                    result = text;
                }
                else
                {
                    ComplexItem complexItem = ComplexTypeCache.GetComplexItem(itemID);
                    if (complexItem != null)
                    {
                        text = complexItem.GetTypeDictionary(ComplexTypeCache.m_server);
                    }
                    result = text;
                }
            }
            return(result);
        }
Exemple #14
0
        public override void PackagedResource(Type itemType, ItemIdentifier itemId, Resource resource)
        {           
            {
                var item = PersistenceManager.Default.RetrieveItem<Template>(itemId);
                var encoding = Core.Settings.Encoding;

                var contents = resource.ResourceContents;
                string fileContent = string.Empty;

                if (contents == null || contents.Length <= 0)
                {
                    string p = Context.Current.MapPath(resource.PackageFromPath);

                    if (System.IO.File.Exists(p))
                    {
                        contents = System.IO.File.ReadAllBytes(p);
                        fileContent = encoding.GetString(contents);
                    }
                }
                else
                    fileContent = encoding.GetString(contents);

                if (fileContent != string.Empty)
                {

                    fileContent = ReplaceMacrosInstring(fileContent, true, item);
                    resource.ResourceContents = encoding.GetBytes(fileContent);
                }
            }
        }
        void ShowResult(SearchCategory cat, ISearchDataSource result)
        {
            incompleteResults.Add(Tuple.Create(cat, result));

            incompleteResults.Sort((x, y) => {
                return(categories.IndexOf(x.Item1).CompareTo(categories.IndexOf(y.Item1)));
            }
                                   );

            if (incompleteResults.Count == categories.Count)
            {
                results.Clear();
                results.AddRange(incompleteResults);
                topItem = null;
                for (int i = 0; i < results.Count; i++)
                {
                    if (results[i].Item2.ItemCount == 0)
                    {
                        continue;
                    }
                    if (topItem == null || topItem.DataSource.GetWeight(topItem.Item) < results[i].Item2.GetWeight(0))
                    {
                        topItem = new ItemIdentifier(results[i].Item1, results[i].Item2, 0);
                    }
                }
                selectedItem = topItem;

                ShowTooltip();
                isInSearch = false;
                AnimatedResize();
            }
        }
Exemple #16
0
        /// <summary>
        /// Fetches the type description for the item.
        /// </summary>
        public static string GetTypeDictionary(ItemIdentifier itemID)
        {
            if (itemID == null)
            {
                return(null);
            }

            lock (typeof(ComplexTypeCache))
            {
                string dictionary = (string)m_dictionaries[itemID.Key];

                if (dictionary != null)
                {
                    return(dictionary);
                }

                ComplexItem item = GetComplexItem(itemID);

                if (item != null)
                {
                    dictionary = item.GetTypeDictionary(m_server);
                }

                return(dictionary);
            }
        }
Exemple #17
0
        public string SaveResourceContents(ItemIdentifier itemId, Type itemType, Resource resource, string revisionAlias)
        {
            //encrypt login and password
            string loginName = "";
            string pass      = "";

            getloginAndPass(UserId, ref loginName, ref pass);
            string _url = getWSUrl(this.Url);


            if (!Core.Settings.disableBase64Encoding)
            {
                resource.ResourceAsBase64 = Convert.ToBase64String(resource.ResourceContents);
                resource.ResourceContents = new byte[0];
            }

            string typestr = string.Empty;

            if (itemType != null)
            {
                typestr = itemType.ToString();
            }

            RepositoryWebservice repo = new RepositoryWebservice(_url);
            string path = repo.SaveResourceContents(itemId, typestr, resource, revisionAlias, loginName, pass);

            repo.Dispose();

            return(path);
        }
Exemple #18
0
        /// <summary>
        /// Fetches the type description for the item.
        /// </summary>
        public static string GetTypeDescription(ItemIdentifier itemID)
        {
            if (itemID == null)
            {
                return(null);
            }

            lock (typeof(ComplexTypeCache))
            {
                string description = null;

                ComplexItem item = GetComplexItem(itemID);

                if (item != null)
                {
                    description = (string)m_descriptions[item.TypeItemID.Key];

                    if (description != null)
                    {
                        return(description);
                    }

                    m_descriptions[item.TypeItemID.Key] = description = item.GetTypeDescription(m_server);
                }

                return(description);
            }
        }
Exemple #19
0
        void Media_AfterSave(Media sender, umbraco.cms.businesslogic.SaveEventArgs e)
        {
            ItemIdentifier itemId     = new ItemIdentifier(sender.UniqueId.ToString(), ItemProviders.ProviderIDCollection.mediaItemProviderGuid);
            ItemIdentifier propertyId = new ItemIdentifier(sender.UniqueId.ToString(), ItemProviders.ProviderIDCollection.mediapropertyDataItemProviderGuid);

            sendToCache(new[] { itemId, propertyId });
        }
Exemple #20
0
        public bool TransferResource(string sessionKey, ItemIdentifier itemId, string type, Resource resource, bool overwrite, string user, string pass)
        {
            //Auth login and IP
            AuthorizeClient(user, pass);

            ResourceTransfer rt = new ResourceTransfer();

            rt.ItemType  = type;
            rt.OverWrite = overwrite;
            rt.ItemID    = itemId;

            rt.Resource = resource;
            rt.Resource.ResourceAsBase64 = string.Empty;

            if (!Core.Settings.disableBase64Encoding)
            {
                rt.Resource.ResourceContents = Convert.FromBase64String(resource.ResourceAsBase64);
            }

            if (!Core.Settings.disableZip)
            {
                rt.Resource.ResourceContents = Compression.Decompress(rt.Resource.ResourceContents);
            }

            LocalRepo.SessionKey = sessionKey;
            return(LocalRepo.TransferResource(rt));
        }
Exemple #21
0
        private void Branch(IServerPath sourceServerPath, IServerPath targetServerPath, bool createBranchObject, VersionSpec versionSpec)
        {
            var server = this.VersionControlServer;

            server.CreateBranch(sourceServerPath.AsString(),
                                targetServerPath.AsString(),
                                versionSpec,
                                null,
                                "Branch from " + sourceServerPath.AsString(),
                                null,
                                null,
                                new Mapping[0]
                                );


            if (createBranchObject)
            {
                var itemIdentifier = new ItemIdentifier(targetServerPath.AsString());
                if (!server.QueryBranchObjects(itemIdentifier, RecursionType.None).Any())
                {
                    server.CreateBranchObject(new BranchProperties(itemIdentifier));
                }
            }

            _tfsCache.Refresh();
        }
Exemple #22
0
        private static void ConvertListIndexToEntityIds(ItemIdentifier identifier, ContentGroup contentGroup)
        {
            var part = contentGroup[identifier.Group.Part];

            if (!identifier.Group.Add &&               // not in add-mode
                part.Count > identifier.Group.Index && // has as many items as desired
                part[identifier.Group.Index] != null)  // and the slot has something
            {
                identifier.EntityId = part[identifier.Group.Index].EntityId;
            }

            // tell the UI that it should not actually use this data yet, keep it locked
            if (!identifier.Group.Part.ToLower().Contains(AppConstants.PresentationLower))
            {
                return;
            }

            // the following steps are only for presentation items
            identifier.Group.SlotCanBeEmpty = true; // all presentations can always be locked

            if (identifier.EntityId != 0)
            {
                return;
            }

            identifier.Group.SlotIsEmpty = true; // if it is blank, then lock this one to begin with

            identifier.DuplicateEntity =
                identifier.Group.Part.ToLower() == AppConstants.PresentationLower
                    ? contentGroup.Template.PresentationDemoEntity?.EntityId
                    : contentGroup.Template.ListPresentationDemoEntity?.EntityId;
        }
Exemple #23
0
        /// <summary>
        /// 写数
        /// </summary>
        /// <param name="itemValues"></param>
        public bool Write(Dictionary <string, object> dicItemValues)
        {
            if (this.Subscription == null)
            {
                return(false);
            }

            ItemValue[] itemValuesWrite = new ItemValue[dicItemValues.Count];

            int i = 0;

            foreach (var item in dicItemValues)
            {
                ItemIdentifier itemIdentifier = this.Subscription.Items.Where(a => a.ItemName == item.Key).FirstOrDefault();

                if (itemIdentifier != null)
                {
                    itemValuesWrite[i]       = new ItemValue(itemIdentifier);
                    itemValuesWrite[i].Value = item.Value;

                    i++;
                }
            }

            if (itemValuesWrite.Where(a => a != null).Count() > 0)
            {
                itemValuesWrite = itemValuesWrite.Where(a => a != null).ToArray();
                var aaa = this.Subscription.Write(itemValuesWrite);
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Sends an asynchronous request to read the attributes of an item.
        /// </summary>
        /// <param name="startTime">The beginning of the history period to read.</param>
        /// <param name="endTime">The end of the history period to be read.</param>
        /// <param name="item">The item to read (must include the server handle).</param>
        /// <param name="attributeIDs">The attributes to read.</param>
        /// <param name="requestHandle">An identifier for the request assigned by the caller.</param>
        /// <param name="callback">A delegate used to receive notifications when the request completes.</param>
        /// <param name="request">An object that contains the state of the request (used to cancel the request).</param>
        /// <returns>A set of results containing any errors encountered when the server validated the attribute ids.</returns>
        public ResultCollection ReadAttributes(
            Time startTime,
            Time endTime,
            ItemIdentifier item,
            int[]                      attributeIDs,
            object requestHandle,
            ReadAttributesEventHandler callback,
            out IRequest request)
        {
            if (m_server == null)
            {
                throw new NotConnectedException();
            }

            ResultCollection results = ((IServer)m_server).ReadAttributes(
                startTime,
                endTime,
                item,
                attributeIDs,
                requestHandle,
                callback,
                out request);

            return(results);
        }
Exemple #25
0
        private static void ConvertListIndexToEntityIds(ItemIdentifier identifier, BlockConfiguration blockConfiguration)
        {
            var part = blockConfiguration[identifier.Group.Part];

            if (!identifier.ListAdd()) // not in add-mode
            {
                var idx = identifier.ListIndex();
                if (part.Count > idx && // has as many items as desired
                    part[idx] != null)  // and the slot has something
                {
                    identifier.EntityId = part[idx].EntityId;
                }
            }

            // tell the UI that it should not actually use this data yet, keep it locked
            if (!identifier.Group.Part.ToLowerInvariant().Contains(ViewParts.PresentationLower))
            {
                return;
            }

            // the following steps are only for presentation items
            identifier.Group.SlotCanBeEmpty = true; // all presentations can always be locked

            if (identifier.EntityId != 0)
            {
                return;
            }

            identifier.Group.SlotIsEmpty = true; // if it is blank, then lock this one to begin with

            identifier.DuplicateEntity =
                identifier.Group.Part.ToLowerInvariant() == ViewParts.PresentationLower
                    ? blockConfiguration.View.PresentationItem?.EntityId
                    : blockConfiguration.View.HeaderPresentationItem?.EntityId;
        }
        private void recursiveTreeFill(Server server, string itemId)
        {
            BrowsePosition position;
            BrowseFilters  filters = new BrowseFilters()
            {
                BrowseFilter = browseFilter.all
            };

            ItemIdentifier item = (itemId == null) ? new ItemIdentifier() : new ItemIdentifier(itemId);

            BrowseElement[] browseElements = server.Browse(item, filters, out position);

            repository.Add(itemId, browseElements);

            for (int index = 0; index < browseElements.Length; index++)
            {
                BrowseElement browsedElement = browseElements[index];
                string        itemName       = browsedElement.ItemName;
                if (browsedElement.HasChildren)
                {
                    recursiveTreeFill(server, itemName);
                }
                else
                {
                    if (!repository.ContainsKey(itemId))
                    {
                        repository.Add(itemId, new BrowseElement[] { });
                    }
                }
            }
        }
Exemple #27
0
        internal static IEntity ConstructEmptyEntity(int appId, ItemIdentifier header, ContentTypeRuntime typeRead)
        {
            var type = typeRead.Get(header.ContentTypeName);
            var ent  = EntityBuilder.EntityTemplate(appId, header.Guid, header.EntityId, 0, type);

            return(ent);
        }
Exemple #28
0
        public override void ExtractingDataType(DataType item)
        {
            base.ExtractingDataType(item);

            if (shouldRun(item))
            {
                var valueArray = item.Prevalues[0].Value.Split('|');
                var ids        = valueArray[5].Split(',');

                bool   changed = false;
                string newIds  = "";

                foreach (var id in ids)
                {
                    if (!string.IsNullOrEmpty(id))
                    {
                        var tempItemId = new ItemIdentifier(id, ItemProviders.StyleSheetItemProvider.Instance().Id);
                        var stylesheet = CurrentItemProvider.DatabasePersistence.RetrieveItem <Stylesheet>(tempItemId);

                        if (stylesheet != null)
                        {
                            newIds += stylesheet.Id.ToString() + ",";
                            changed = true;
                        }
                    }
                }

                if (changed)
                {
                    newIds                  = newIds.Trim(',');
                    valueArray[5]           = newIds;
                    item.Prevalues[0].Value = string.Join("|", valueArray);
                }
            }
        }
Exemple #29
0
        public void Should_equal_on_identifier()
        {
            var a = new ItemIdentifier(EInventoryRelicType.Dash);
            var b = new ItemIdentifier(EInventoryRelicType.Dash);

            Assert.That(a, Is.EqualTo(b));
        }
Exemple #30
0
        public Item Package(ItemIdentifier itemId)
        {
            //encrypt login and password
            string loginName = "";
            string pass      = "";

            getloginAndPass(UserId, ref loginName, ref pass);
            string _url = getWSUrl(this.Url);

            RepositoryWebservice repo = new RepositoryWebservice(_url);

            //repo.Commit(loginName, pass);
            byte[] item = Convert.FromBase64String(repo.Package(this.SessionKey, itemId, loginName, pass));
            repo.Dispose();

            if (item == null || item.Length <= 0)
            {
                return(null);
            }

            var  provider = Umbraco.Courier.Core.ProviderModel.ItemProviderCollection.Instance.GetProvider(itemId.ProviderId);
            Item it       = provider.Deserialize(itemId, item);

            return(it);
        }
Exemple #31
0
        void Template_AfterDelete(Template sender, umbraco.cms.businesslogic.DeleteEventArgs e)

        {
            ItemIdentifier itemId = new ItemIdentifier(sender.Alias, ItemProviders.ProviderIDCollection.templateItemProviderGuid);

            clearCache(itemId);
        }
Exemple #32
0
        public string Hash(ItemIdentifier itemId)
        {
            //encrypt login and password
            string loginName = "";
            string pass      = "";

            getloginAndPass(UserId, ref loginName, ref pass);
            string _url = getWSUrl(this.Url);

            RepositoryWebservice repo = new RepositoryWebservice(_url);

            repo.Credentials = new System.Net.NetworkCredential(loginName, pass);

            string hash = string.Empty;

            try
            {
                hash = repo.GetItemHash(this.SessionKey, itemId, loginName, pass);
            }
            catch { }

            repo.Dispose();

            return(hash);
        }
        /// <summary>
        /// Copy object values into controls.
        /// </summary>
        public void Set(OpcDa::ItemValue value)
        {
            // check for null value.
            if (value == null)
            {
                SetDefaults(); return;
            }
            // cast value to item object.
            OpcDa::ItemValue item = (OpcDa::ItemValue)value;

            // save item identifier (including client and server handles).
            m_identifier                 = new ItemIdentifier(item);
            ItemNameTB.Text              = item.ItemName;
            ItemPathTB.Text              = item.ItemPath;
            ValueCTRL.ItemID             = new ItemIdentifier(item);
            ValueCTRL.Value              = item.Value;
            ValueSpecifiedCB.Checked     = item.Value != null;
            QualitySpecifiedCB.Checked   = item.QualitySpecified;
            QualityBitsCTRL.Value        = item.Quality.QualityBits;
            LimitBitsCTRL.Value          = item.Quality.LimitBits;
            VendorBitsCTRL.Value         = item.Quality.VendorBits;
            TimestampCTRL.Value          = TimestampCTRL.MinDate;
            TimestampSpecifiedCB.Checked = item.TimestampSpecified;
            // set timestamp - jump through some hoops to handle invalid values.
            if (item.TimestampSpecified)
            {
                TimestampCTRL.Value = (item.Timestamp > TimestampCTRL.MinDate) ? item.Timestamp : TimestampCTRL.MinDate;
            }
        }
 public override void Execute(ItemIdentifier itemId, SerializableDictionary<string, string> Parameters)
 {
     try
     {
         Cache.ClearCacheByKeySearch("UmbracoDataTypeDefinition");
     }
     catch (Exception ex)
     {
         RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "ClearDataTypeCache", ex.ToString(), LogItemEntryType.Error);
     }
 }
Exemple #35
0
        public override Item HandlePack(ItemIdentifier id)
        {
            Company item = this.DatabasePersistence.RetrieveItem<Company>(id);

            //here we could also add dependencies or resources
            //item.Resources.Add("/file/path/to/something.jpg");

            //Dependency dep = new Dependency("Something that needs to be installed before company is" "id", new Guid());
            //item.Dependencies.Add(dep);

            return item;
        }
        public override void Packaging(Item item)
        {
            ContentPropertyData cpd = (ContentPropertyData)item;
            foreach (var cp in cpd.Data)
            {
                if (keyValuePrevalueEditors.Values.Contains(cp.PreValueEditor.ToLower()) && cp.Value != null)
                {
                    string[] vals = cp.Value.ToString().Split(',');
                    string newVals = string.Empty;

                    ItemIdentifier itemid = new ItemIdentifier(cp.DataType.ToString(), ProviderIDCollection.dataTypeItemProviderGuid);
                    DataType dt = PersistenceManager.Default.RetrieveItem<DataType>(itemid);

                    bool nonConvert = false;
                    int convertTestVal = 0;
                    if (!int.TryParse(string.Join("", vals), out convertTestVal))
                        nonConvert = true;

                    if (dt != null)
                    {
                        foreach (string s in vals)
                        {
                            int id;
                            if (int.TryParse(s, out id))
                            {
                                if (id > 0)
                                {
                                    var val = dt.Prevalues.Where(x => x.Id == id).FirstOrDefault();
                                    if (val != null)
                                        newVals += val.Value + ",";
                                }
                            }
                            else if(dt.Prevalues.Where(x => x.Value == s).Any())
                            {
                                newVals += s + ",";
                            }
                        }

                        newVals = newVals.Trim(',');

                        //this is a nasty hack but no way around it due to the idiotic way keyvalue types can store stuff
                        if (nonConvert)
                            newVals = "¤" + newVals;

                        cp.Value = newVals;
                    }
                }
            }
        }
        public RepositoryActionResponse Extract(string sessionKey, byte[] item, ItemIdentifier itemId, bool overwrite, string user, string pass)
        {
            //Auth login and IP
            AuthorizeClient(user, pass);

            var p = ItemProviderCollection.Instance.GetProvider(itemId.ProviderId);
            var i = p.Deserialize(itemId, item);

            if (string.IsNullOrEmpty(sessionKey))
                sessionKey = "default";

            LocalRepo.SessionKey = sessionKey;
            var status = LocalRepo.ExtractItem(i, overwrite);

            return status;
        }
Exemple #38
0
        public override void ExtractingResource(Type itemType, ItemIdentifier itemId, Resource resource)
        { 
                var item = PersistenceManager.Default.RetrieveItem<Template>(itemId);
                var encoding = Core.Settings.Encoding;

                var contents = resource.ResourceContents;

                if (contents != null && contents.Length > 0)
                {
                    string fileContent = encoding.GetString(contents);

                    if (!string.IsNullOrEmpty(fileContent))
                    {
                        fileContent = ReplaceMacrosInstring(fileContent, false, item);
                        resource.ResourceContents = encoding.GetBytes(fileContent);
                    }
                }
            
        }
Exemple #39
0
        public override void PackagedResource(Type itemType, ItemIdentifier itemId, Resource resource)
        {
            var fileContent = ResourceAsString(resource);
                if (fileContent != string.Empty)
                {
                        //macros
                        Helpers.MacroResolver res = new Helpers.MacroResolver();
                        res.RegisterNodeDependencies = false;
                        res.RegisterMacroDependencies = false;
                        res.context = this.ExecutionContext;

                        fileContent = res.ReplaceMacroElements(fileContent, true, null);

                        //links
                        Helpers.LocalLinkResolver les = new Helpers.LocalLinkResolver();
                        les.RegisterLinksAsDependencies = false;
                        fileContent = les.ReplaceLocalLinks(fileContent, true, null);

                        resource.ResourceContents = Core.Settings.Encoding.GetBytes(fileContent);
                }
        }
Exemple #40
0
        private void ReindexContent(Guid contentGuid, ItemIdentifier itemId)
        {
            umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(contentGuid);
            if (d != null)
            {
                XmlNode n = d.ToXml(new XmlDocument(), true);
                if (n != null)
                {
                    XElement docXnode = XDocument.Parse(n.OuterXml).Root;
                    if (d.Published)
                    {
                        //only if published should it be added to indexes which doesnt support published content
                        try
                        {
                            ExamineManager.Instance.ReIndexNode(docXnode, IndexTypes.Content,
                               ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
                                   .Where(x => x.EnableDefaultEventHandler));
                        }
                        catch (Exception ex)
                        {
                            RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateLuceneIndexes", ex.ToString(), LogItemEntryType.Error);
                        }
                    }

                    //add to all indexes supporting unpublished content
                    try
                    {
                        ExamineManager.Instance.ReIndexNode(docXnode, IndexTypes.Content,
                           ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
                               .Where(x => x.SupportUnpublishedContent
                                   && x.EnableDefaultEventHandler));
                    }
                    catch (Exception ex)
                    {
                        RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateLuceneIndexes", ex.ToString(), LogItemEntryType.Error);
                    }
                }
            }
        }
        public override void Extracting(Item item)
        {
            ContentPropertyData cpd = (ContentPropertyData)item;
            foreach (var cp in cpd.Data)
            {
                if (keyValuePrevalueEditors.Values.Contains(cp.PreValueEditor.ToLower()) && cp.Value != null)
                {
                    //nonConvert indicator
                    string value = cp.Value.ToString();
                    bool nonConvert = value.StartsWith("¤");
                    value = value.TrimStart('¤');

                    string[] vals = value.Split(',');
                    string newVals = string.Empty;

                    ItemIdentifier itemid = new ItemIdentifier(cp.DataType.ToString(), ProviderIDCollection.dataTypeItemProviderGuid);

                    if (nonConvert)
                        cp.Value = value.Trim(',');
                    else
                    {
                        DataType dt = PersistenceManager.Default.RetrieveItem<DataType>(itemid);
                        if (dt != null)
                        {
                            foreach (string s in vals)
                            {
                                var val = dt.Prevalues.Where(x => x.Value == s).FirstOrDefault();
                                if (val != null)
                                {
                                    newVals += val.Id.ToString() + ",";
                                }
                            }
                            cp.Value = newVals.Trim(',');
                        }
                    }
                }
            }
        }
		public void Update (SearchPopupSearchPattern pattern)
		{
			// in case of 'string:' it's not clear if the user ment 'tag:pattern'  or 'pattern:line' therefore guess
			// 'tag:', if no valid tag is found guess 'pattern:'
			if (!string.IsNullOrEmpty (pattern.Tag) && string.IsNullOrEmpty (pattern.Pattern) && !categories.Any (c => c.IsValidTag (pattern.Tag))) {
				pattern = new SearchPopupSearchPattern (null, pattern.Tag, pattern.LineNumber, pattern.Column, pattern.UnparsedPattern);
			}

			this.pattern = pattern;
			if (src != null)
				src.Cancel ();
			HideTooltip ();
			src = new CancellationTokenSource ();
			isInSearch = true;
			if (results.Count == 0) {
				QueueDraw ();
			}
			var collectors = new List<SearchResultCollector> ();
			var token = src.Token;
			foreach (var _cat in categories) {
				var cat = _cat;
				if (!string.IsNullOrEmpty (pattern.Tag) && !cat.IsValidTag (pattern.Tag))
					continue;
				var col = new SearchResultCollector (_cat);
				collectors.Add (col);
				col.Task = cat.GetResults (col, pattern, token);
			}

			Task.WhenAll (collectors.Select (c => c.Task)).ContinueWith (t => {
				if (token.IsCancellationRequested)
					return;
				var newResults = new List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> (collectors.Count);
				foreach (var col in collectors) {
					if (col.Task.IsCanceled) {
						continue;
					} else if (col.Task.IsFaulted) {
						LoggingService.LogError ($"Error getting search results for {col.Category}", col.Task.Exception);
					} else {
						newResults.Add (Tuple.Create (col.Category, col.Results));
					}
				}

				List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> failedResults = null;
				ItemIdentifier topResult = null;
				for (int i = 0; i < newResults.Count; i++) {
					var tuple = newResults [i];
					try {
						if (tuple.Item2.Count == 0)
							continue;
						if (topResult == null || topResult.DataSource [topResult.Item].Weight < tuple.Item2 [0].Weight)
							topResult = new ItemIdentifier (tuple.Item1, tuple.Item2, 0);
					} catch (Exception e) {
						LoggingService.LogError ("Error while showing result " + i, e);
						if (failedResults == null)
							failedResults = new List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> ();
						failedResults.Add (newResults [i]);
						continue;
					}
				}

				if (failedResults != null)
					failedResults.ForEach (failedResult => newResults.Remove (failedResult));

				Application.Invoke (delegate {
					ShowResults (newResults, topResult);
					isInSearch = false;
					AnimatedResize ();
				});
			}, token);
		}
		void SelectLastCatgory ()
		{
			var r = results.LastOrDefault (r2 => r2.Item2.ItemCount > 0 && !(r2.Item2.ItemCount == 1 && topItem.Category == r2.Item1));
			if (r == null)
				return;
			selectedItem = new ItemIdentifier (
				r.Item1,
				r.Item2,
				r.Item2.ItemCount - 1
			);
			QueueDraw ();
		}
		void SelectPrevCategory ()
		{
			if (selectedItem == null)
				return;
			var i = SelectedCategoryIndex;
			if (i > 0) {
				selectedItem = new ItemIdentifier (
					results [i - 1].Item1,
					results [i - 1].Item2,
					0
				);
				if (selectedItem.Equals (topItem)) {
					if (topItem.DataSource.ItemCount > 1) {
						selectedItem = new ItemIdentifier (
							results [i - 1].Item1,
							results [i - 1].Item2,
							1
						);
					} else if (i > 1) {
						selectedItem = new ItemIdentifier (
							results [i - 2].Item1,
							results [i - 2].Item2,
							0
						);
					}
				}
			} else {
				selectedItem = topItem;
			}
			QueueDraw ();
		}
		void SelectNextCategory ()
		{
			if (selectedItem == null)
				return;
			var i = SelectedCategoryIndex;
			if (selectedItem.Equals (topItem)) {
				if (i > 0) {
					selectedItem = new ItemIdentifier (
						results [0].Item1,
						results [0].Item2,
						0
					);

				} else {
					if (topItem.DataSource.ItemCount > 1) {
						selectedItem = new ItemIdentifier (
							results [0].Item1,
							results [0].Item2,
							1
						);
					} else if (i < results.Count - 1) {
						selectedItem = new ItemIdentifier (
							results [i + 1].Item1,
							results [i + 1].Item2,
							0
						);
					}
				}
			} else {
				while (i < results.Count - 1 && results [i + 1].Item2.ItemCount == 0)
					i++;
				if (i < results.Count - 1) {
					selectedItem = new ItemIdentifier (
						results [i + 1].Item1,
						results [i + 1].Item2,
						0
					);
				}
			}
			QueueDraw ();	
		}
		void SelectItemDown ()
		{
			if (selectedItem == null)
				return;

			if (selectedItem.Equals (topItem)) {
				for (int j = 0; j < results.Count; j++) {
					if (results[j].Item2.ItemCount == 0 || results[j].Item2.ItemCount == 1 && topItem.DataSource == results[j].Item2)
						continue;
					selectedItem = new ItemIdentifier (
						results [j].Item1,
						results [j].Item2,
						0
						);
					if (selectedItem.Equals (topItem))
						goto normalDown;
					break;
				}
				ShowTooltip ();
				QueueDraw ();
				return;
			}
		normalDown:
			var i = SelectedCategoryIndex;

			// check real upper bound
			if (selectedItem != null) {
				var curAbsoluteIndex = selectedItem == topItem ? 1 : 0;
				for (int j = 0; j < i; j++) {
					curAbsoluteIndex += Math.Min (maxItems, results [j].Item2.ItemCount);
				}
				curAbsoluteIndex += selectedItem.Item + 1;
				if (curAbsoluteIndex + 1 > calculatedItems)
					return;
			}

			var upperBound = Math.Min (maxItems, selectedItem.DataSource.ItemCount);
			if (selectedItem.Item + 1 < upperBound) {
				if (topItem.DataSource == selectedItem.DataSource && selectedItem.Item == upperBound - 1)
					return;
				selectedItem = new ItemIdentifier (selectedItem.Category, selectedItem.DataSource, selectedItem.Item + 1);
			} else {
				for (int j = i + 1; j < results.Count; j++) {
					if (results[j].Item2.ItemCount == 0 || results[j].Item2.ItemCount == 1 && topItem.DataSource == results[j].Item2)
						continue;
					selectedItem = new ItemIdentifier (
						results [j].Item1,
						results [j].Item2,
						0
						);
					if (selectedItem.Equals (topItem)) {
						selectedItem = new ItemIdentifier (
							results [j].Item1,
							results [j].Item2,
							1
							);
					}

					break;
				}
			}
			ShowTooltip ();
			QueueDraw ();
		}
		void SelectItemUp ()
		{
			if (selectedItem == null || selectedItem == topItem)
				return;
			int i = SelectedCategoryIndex;
			if (selectedItem.Item > 0) {
				selectedItem = new ItemIdentifier (selectedItem.Category, selectedItem.DataSource, selectedItem.Item - 1);
				if (i > 0 && selectedItem.Equals (topItem)) {
					SelectItemUp ();
					return;
				}
			} else {
				if (i == 0) {
					selectedItem = topItem;
				} else {
					do {
						i--;
						selectedItem = new ItemIdentifier (
							results [i].Item1,
							results [i].Item2,
							Math.Min (maxItems, results [i].Item2.ItemCount) - 1
						);
						if (selectedItem.Category == topItem.Category && selectedItem.Item == topItem.Item && i > 0) {
							i--;
							selectedItem = new ItemIdentifier (
								results [i].Item1,
								results [i].Item2,
								Math.Min (maxItems, results [i].Item2.ItemCount) - 1
							);
						}
							
					} while (i > 0 && selectedItem.DataSource.ItemCount <= 0);

					if (selectedItem.DataSource.ItemCount <= 0) {
						selectedItem = topItem;
					}
				}
			}
			ShowTooltip ();
			QueueDraw ();
		}
		void ShowResult (SearchCategory cat, ISearchDataSource result)
		{
			incompleteResults.Add (Tuple.Create (cat, result));

			incompleteResults.Sort ((x, y) => {
				return categories.IndexOf (x.Item1).CompareTo (categories.IndexOf (y.Item1));
			}
			);

			if (incompleteResults.Count == categories.Count) {
				results.Clear ();
				results.AddRange (incompleteResults);
				List<Tuple<SearchCategory, ISearchDataSource>> failedResults = null;
				topItem = null;

				for (int i = 0; i < results.Count; i++) {
					var tuple = results [i];
					try {
						if (tuple.Item2.ItemCount == 0)
							continue;
						if (topItem == null || topItem.DataSource.GetWeight (topItem.Item) < tuple.Item2.GetWeight (0))
							topItem = new ItemIdentifier(tuple.Item1, tuple.Item2, 0);
					} catch (Exception e) {
						LoggingService.LogError ("Error while showing result " + i, e);
						if (failedResults == null)
							failedResults = new List<Tuple<SearchCategory, ISearchDataSource>> ();
						failedResults.Add (results [i]);
						continue;
					}
				}
				selectedItem = topItem;

				if (failedResults != null)
					failedResults.ForEach (failedResult => results.Remove (failedResult));

				ShowTooltip ();
				isInSearch = false;
				AnimatedResize ();
			}
		}
Exemple #49
0
        public string SaveResourceContents(ItemIdentifier itemId, Type itemType, Resource resource, string revisionAlias)
        {
            throw new NotImplementedException();

            var relPath = resource.ExtractToPath;
            var fileContents = resource.ResourceContents;
        }
		void ShowResult (SearchCategory cat, ISearchDataSource result)
		{
			incompleteResults.Add (Tuple.Create (cat, result));

			incompleteResults.Sort ((x, y) => {
				return categories.IndexOf (x.Item1).CompareTo (categories.IndexOf (y.Item1));
			}
			);

			if (incompleteResults.Count == categories.Count) {
				results.Clear ();
				results.AddRange (incompleteResults);
				topItem = null;
				for (int i = 0; i < results.Count; i++) {
					if (results[i].Item2.ItemCount == 0)
						continue;
					if (topItem == null || topItem.DataSource.GetWeight (topItem.Item) <  results[i].Item2.GetWeight (0)) 
						topItem = new ItemIdentifier (results[i].Item1, results[i].Item2, 0);
				}
				selectedItem = topItem;

				ShowTooltip ();
				isInSearch = false;
				AnimatedResize ();
			}
		}
Exemple #51
0
        private void ReindexMedia(Guid mediaGuid, ItemIdentifier itemId)
        {
            umbraco.cms.businesslogic.media.Media m = new umbraco.cms.businesslogic.media.Media(mediaGuid);
            if (m != null)
            {
                //first, clear the cache
                umbraco.library.ClearLibraryCacheForMedia(m.Id);

                XmlNode n = m.ToXml(new XmlDocument(), true);
                if (n != null)
                {
                    XElement mediaXnode = XDocument.Parse(n.OuterXml).Root;
                    //add to all indexes supporting unpublished content
                    try
                    {
                        ExamineManager.Instance.ReIndexNode(mediaXnode, IndexTypes.Media,
                           ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
                               .Where(x => x.EnableDefaultEventHandler));
                    }
                    catch (Exception ex)
                    {
                        RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateLuceneIndexes", ex.ToString(), LogItemEntryType.Error);
                    }
                }
            }
        }
        static dynamic BuildBTree(ItemIdentifier root)
        {
            Cursor origCursor = Cursor.Current;
            IVsThreadedWaitDialog2 dlg = null;
            bool bcanceled;
            int icanceled, idx = 0;
            DateTime minDate = DateTime.MaxValue, maxDate = DateTime.MinValue;

            Cursor.Current = Cursors.WaitCursor;

            dlg = Utilities.CreateThreadedWaitDialog("Collecting information about changesets", "Starting to process changesets...", "status", 100);
            dlg.UpdateProgress("Collecting information about changesets", "Starting to process changesets...", "status", 0, 100, true, out bcanceled);

            var branches = new List<BTreeItem>();
            foreach (var item in Utilities.vcsrv.QueryRootBranchObjects(RecursionType.Full))
            {
                var itm = new BTreeItem
                {
                    Path = item.Properties.RootItem.Item,
                    CreationDate = item.DateCreated,
                    parentPath = item.Properties.ParentBranch == null ? null : item.Properties.ParentBranch.Item,
                    version = (item.Properties.RootItem.Version as ChangesetVersionSpec).ChangesetId,
                    RelatedBranches = Utilities.vcsrv
                        .QueryMergeRelationships(item.Properties.RootItem.Item)
                        .Select(x => new Tuple<BTreeItem, Changeset[]>(new BTreeItem { Path = x.Item }, Utilities.vcsrv
                                .GetMergeCandidates(item.Properties.RootItem.Item, x.Item, RecursionType.Full)
                                .Select(z => z.Changeset).ToArray()))
                        .ToList()
                };

                if (itm.CreationDate < minDate) minDate = itm.CreationDate;
                if (itm.CreationDate > maxDate) maxDate = itm.CreationDate;
                branches.Add(itm);

                dlg.UpdateProgress("Collecting information about changesets", "Processing branch: " + itm.Path, "status", idx++, 100, false, out bcanceled);
                if (bcanceled) break;
            }

            var broot = new BTreeItem();
            foreach(var itm in branches)
            {
                if (itm.parentPath == null)
                {
                    broot.children.Add(itm);
                    itm.parent = broot;
                }
                else
                {
                    itm.parent = branches.FirstOrDefault(x => x.Path == itm.parentPath);
                    if (itm.parent != null)
                        itm.parent.children.Add(itm);
                    else
                        broot.children.Add(itm);
                }

                itm.RelatedBranches = itm.RelatedBranches
                    .Select(x => new Tuple<BTreeItem, Changeset[]>(branches.FirstOrDefault(z => z.Path == x.Item1.Path), x.Item2))
                    .ToList();

                itm.relY = (int)itm.CreationDate.Subtract(minDate).TotalDays;

                foreach (var ch in itm.RelatedBranches.SelectMany(x => x.Item2))
                    if (ch.CreationDate > maxDate) maxDate = ch.CreationDate;
            }

            idx = 0;
            var res = ShowRevHistPackage.TreeDescendants2(broot, ref idx).OrderBy(x => x.relX).ToList();
            res.ForEach(x => Utilities.OutputCommandString(x.relX + " " + (x.parentPath ?? "") + "=" + x.DisplayText));

            Cursor.Current = origCursor;
            dlg.EndWaitDialog(out icanceled);

            return new {
                ylines = (int)(maxDate.Subtract(minDate).TotalDays * 1.1) + 1,
                xlines = idx+1,
                branches = res
            };
        }
Exemple #53
0
        public void InitItems(int clientSubscriptionIndex)
        {
            //iteration index - used for two loops in this method
            int index = 1;

            //iterate through all items in plc to add to dynamic list
            foreach (opccliitem cliitem in opcliitems)
            {
                ItemIdentifier iid = new ItemIdentifier();

                iid.ItemName = cliitem.path;
                switch (cliitem.type.ToString())
                {
                    case "Boolean":
                        iid.DataType = System.Type.GetType("System.Boolean");
                        break;
                    case "Long":
                        iid.DataType = System.Type.GetType("System.Int32");
                        break;
                    case "Word":
                        iid.DataType = System.Type.GetType("System.UInt16");
                        break;
                    case "Short":
                        iid.DataType = System.Type.GetType("System.Int16");
                        break;
                    case "DWord":
                        iid.DataType = System.Type.GetType("System.Uint32");
                        break;
                    case "Float":
                        iid.DataType = System.Type.GetType("System.Single");
                        break;
                    case "Double":
                        iid.DataType = System.Type.GetType("System.Double");
                        break;
                    case "String":
                        iid.DataType = System.Type.GetType("System.String");
                        break;
                }

                iid.ClientHandle = index;

                _itemIdentifiers.Add(iid);

                index++;
            }

            logger.Debug("Adding {1} items to subscription list for PLC: {0}", _name, index - 1);
        }
Exemple #54
0
 /* FETCHING SYSTEM IDs */
 public SystemItem[] GetChildren(ItemIdentifier itemID)
 {
     throw new NotImplementedException();
 }
Exemple #55
0
        public byte[] GetResourceContents(ItemIdentifier itemId, Type itemType, Resource resource, string revisionAlias)
        {
            if (revisionAlias != null)
            {

                //check if the resource has already been packaged before
                resource.ResourceContents = resource.ToByteArray(Core.Settings.revisionsPath + "/" + revisionAlias + "/" +
                                                                    Core.Settings.ResourcesFolderName);
                if (resource.ResourceContents != null)
                    return resource.ResourceContents;
            }

            ItemProvider provider = null;
            if (!string.IsNullOrEmpty(resource.ExtractToPath) && itemType != null)
            {
                provider = Umbraco.Courier.Core.ProviderModel.ItemProviderCollection.Instance.GetProvider(itemId.ProviderId, Database, ExecutionContext);
                ResolutionManager.Instance.PackagingResource(itemId, itemType, resource, provider);
            }

            resource.ResourceContents = resource.ToByteArray("~/");

            //if (!string.IsNullOrEmpty(resource.ExtractToPath) && itemType != null)
            //    ResolutionManager.Instance.PackagedResource(itemId, itemType, resource, provider);

            return resource.ResourceContents;
        }
Exemple #56
0
        /* PACKAGING */
        public Item Package(ItemIdentifier itemId)
        {
            var provider = Umbraco.Courier.Core.ProviderModel.ItemProviderCollection.Instance.GetProvider(itemId.ProviderId, Database, ExecutionContext);
            Item it = Core.Cache.ItemCacheManager.Instance.GetItem(itemId, provider);

            if (it == null)
            {
                it = provider.Package(itemId);
                if (it != null)
                    Core.Cache.ItemCacheManager.Instance.StoreItemAsync(it, provider);
            }

            if (it == null)
                return null;
            // throw new Exception(String.Format("Failed to package {0} with provider {1}", itemId.Id, provider.Name));

            //this only for internal logging of the queue on remote contexts
            provider.ExecutionContext.CurrentPackaging.Queue.Add(it.ItemId);
            return it;
        }
		void ShowResults (List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> newResults, ItemIdentifier topResult)
		{
			results = newResults;
			selectedItem = topItem = topResult;
			ShowTooltip ();
		}
Exemple #58
0
 public bool Exists(ItemIdentifier itemId)
 {
     throw new NotImplementedException();
 }
Exemple #59
0
 /* HASHING */
 public string Hash(ItemIdentifier itemId)
 {
     Item i = Package(itemId);
     if (i == null)
         return string.Empty;
     else{
         return i.GetHash();
     }
 }
Exemple #60
0
        private void UpdateFolderData(TreeNode node)
        {
            if (node == null)
            {
                uiFolderTagsBindingSource.DataSource = null;
                return;
            }

            //Add items to folder, read from OPC Server if first time
            var folderTags = node.Tag as List<BrowseElement>;
            if (folderTags == null)
            {
                TreeNode rootNode = node;
                while (rootNode.Parent != null)
                {
                    rootNode = rootNode.Parent;
                }

                var opcServer = Settings.OpcServers.Where(os => rootNode.FullPath == os.ServerName).Single();
                string urlstring = opcServer.URL;
                Server server = new Server(new Factory(), new URL(urlstring));
                server.Connect();

                BrowsePosition position;
                BrowseFilters filters = new BrowseFilters() { BrowseFilter = browseFilter.all };
                ItemIdentifier itemId = null;

                if (node.FullPath != server.Name)
                {
                    itemId = new ItemIdentifier(node.Name);
                }

                BrowseElement[] elements = server.Browse(itemId, filters, out position);
                server.Disconnect();

                var items = elements.Where(e => e.IsItem);
                if (items.Any())
                {
                    folderTags = items.ToList();
                }
                else
                {
                    folderTags = new List<BrowseElement>();
                }

                var folders = elements.Where(e => e.IsItem == false);
                if(folders.Any())
                {
                    foreach (var element in elements.Where(e => !e.IsItem))
                    {
                        node.Nodes.Add(element.Name).Name = element.ItemName;
                    }
                }

                node.Tag = folderTags;
            }

            //Exlude elements which already are in group
            folderTags = folderTags.ToList();
            var selectedGroup = uiGroupsTab_Groups.SelectedItem as Group;
            if (selectedGroup != null)
            {
                if (selectedGroup.Properties != null)
                {
                    foreach (var property in selectedGroup.Properties)
                    {
                        folderTags.RemoveAll(t => t.ItemName == property.TagName);
                    }
                }
            }

            uiFolderTagsBindingSource.DataSource = folderTags;

            //if (elements != null)
            //{
            //    var itemsIDs = new List<ItemIdentifier>();
            //    foreach (var element in elements)
            //    {
            //        itemsIDs.Add(new ItemIdentifier(element.ItemName));
            //    }

            //    var prid = new List<PropertyID>();
            //    prid.Add(new PropertyID(1));
            //    prid.Add(new PropertyID(2));

            //    var tst = server.GetProperties(itemsIDs.ToArray(), prid.ToArray(), true);
            //}
        }