Ejemplo n.º 1
0
        /// <summary>
        /// This method will import / update a list of videos into the Brightcove Video Library
        /// </summary>
        /// <param name="Videos">
        /// The Videos to import / update
        /// </param>
        /// <returns>
        /// returns a list of the new videos imported
        /// </returns>
        public static UpdateInsertPair <VideoItem> ImportToSitecore(this AccountItem account, List <BCVideo> Videos, UpdateType utype)
        {
            UpdateInsertPair <VideoItem> uip = new UpdateInsertPair <VideoItem>();

            //set all BCVideos into hashtable for quick access
            Hashtable ht = new Hashtable();

            foreach (VideoItem exVid in account.VideoLib.Videos)
            {
                if (!ht.ContainsKey(exVid.VideoID.ToString()))
                {
                    //set as string, Item pair
                    ht.Add(exVid.VideoID.ToString(), exVid);
                }
            }

            //Loop through the data source and add them
            foreach (BCVideo vid in Videos)
            {
                try {
                    //remove access filter
                    using (new Sitecore.SecurityModel.SecurityDisabler()) {
                        VideoItem currentItem;

                        //if it exists then update it
                        if (ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE)))
                        {
                            currentItem = (VideoItem)ht[vid.id.ToString()];

                            //add it to the new items
                            uip.UpdatedItems.Add(currentItem);

                            using (new EditContext(currentItem.videoItem, true, false)) {
                                SetVideoFields(ref currentItem.videoItem, vid);
                            }
                        }
                        //else just add it
                        else if (!ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW)))
                        {
                            //Create new item
                            TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Video"];

                            currentItem = new VideoItem(account.VideoLib.videoLibraryItem.Add(vid.name.StripInvalidChars(), templateType));

                            //add it to the new items
                            uip.NewItems.Add(currentItem);

                            using (new EditContext(currentItem.videoItem, true, false)) {
                                SetVideoFields(ref currentItem.videoItem, vid);
                            }
                        }
                    }
                } catch (System.Exception ex) {
                    //HttpContext.Current.Response.Write(vid.name + "<br/>");
                    throw new Exception("Failed on video: " + vid.name + ". " + ex.ToString());
                }
            }

            return(uip);
        }
Ejemplo n.º 2
0
 private void Update()
 {
     if (updateType.Equals(UpdateType.Update))
     {
         UpdateFSM(Time.deltaTime);
     }
 }
        /// <summary>
        /// This handles syncing the local info with brightcove
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            pnlNewMessage.Visible    = false;
            pnlUpdateMessage.Visible = false;

            UpdateType utype = UpdateType.NEW;

            if (radUpdate.SelectedValue.Equals("update"))
            {
                utype = UpdateType.UPDATE;
            }
            else if (radUpdate.SelectedValue.Equals("both"))
            {
                utype = UpdateType.BOTH;
            }

            //import/update the playlists
            List <BCPlaylist> playlists             = bc.FindAllPlaylists().Playlists;
            UpdateInsertPair <PlaylistItem> playUIP = accountItem.ImportToSitecore(playlists, utype);

            if (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))
            {
                pnlNewMessage.Visible = true;
                ltlNewPlaylists.Text  = playUIP.NewItems.Count.ToString();
            }
            if (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))
            {
                //show message over how many things changed
                pnlUpdateMessage.Visible = true;
                ltlUpdatedPlaylists.Text = playUIP.UpdatedItems.Count.ToString();
            }

            //display the current video and playlist count
            ltlTotalPlaylists.Text = accountItem.PlaylistLib.Playlists.Count.ToString();
        }
Ejemplo n.º 4
0
        public static UpdateInsertPair <PlaylistItem> ImportToSitecore(this AccountItem account, List <BCPlaylist> Playlists, UpdateType utype)
        {
            UpdateInsertPair <PlaylistItem> uip = new UpdateInsertPair <PlaylistItem>();

            //set all BCVideos into hashtable for quick access
            Hashtable ht = new Hashtable();

            foreach (PlaylistItem exPlay in account.PlaylistLib.Playlists)
            {
                if (!ht.ContainsKey(exPlay.playlistItem.ToString()))
                {
                    //set as string, Item pair
                    ht.Add(exPlay.PlaylistID.ToString(), exPlay);
                }
            }

            //Loop through the data source and add them
            foreach (BCPlaylist play in Playlists)
            {
                try {
                    //remove access filter
                    using (new Sitecore.SecurityModel.SecurityDisabler()) {
                        PlaylistItem currentItem;

                        //if it exists then update it
                        if (ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE)))
                        {
                            currentItem = (PlaylistItem)ht[play.id.ToString()];

                            //add it to the new items
                            uip.UpdatedItems.Add(currentItem);

                            using (new EditContext(currentItem.playlistItem, true, false)) {
                                SetPlaylistFields(ref currentItem.playlistItem, play);
                            }
                        }
                        //else just add it
                        else if (!ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW)))
                        {
                            //Create new item
                            TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Playlist"];
                            currentItem = new PlaylistItem(account.PlaylistLib.playlistLibraryItem.Add(play.name.StripInvalidChars(), templateType));

                            //add it to the new items
                            uip.NewItems.Add(currentItem);

                            using (new EditContext(currentItem.playlistItem, true, false)) {
                                SetPlaylistFields(ref currentItem.playlistItem, play);
                            }
                        }
                    }
                } catch (System.Exception ex) {
                    throw new Exception("Failed on playlist: " + play.name + ". " + ex.ToString());
                }
            }

            return(uip);
        }
Ejemplo n.º 5
0
		/// <summary>
		/// This method will import / update a list of videos into the Brightcove Video Library
		/// </summary>
		/// <param name="Videos">
		/// The Videos to import / update
		/// </param>
		/// <returns>
		/// returns a list of the new videos imported
		/// </returns>
		public static UpdateInsertPair<VideoItem> ImportToSitecore(this AccountItem account, List<BCVideo> Videos, UpdateType utype) {

			UpdateInsertPair<VideoItem> uip = new UpdateInsertPair<VideoItem>();

			//set all BCVideos into hashtable for quick access
			Hashtable ht = new Hashtable();
			foreach (VideoItem exVid in account.VideoLib.Videos) {
				if (!ht.ContainsKey(exVid.VideoID.ToString())) {
					//set as string, Item pair
					ht.Add(exVid.VideoID.ToString(), exVid);
				}
			}

			//Loop through the data source and add them
			foreach (BCVideo vid in Videos) {

				try {
					//remove access filter
					using (new Sitecore.SecurityModel.SecurityDisabler()) {

						VideoItem currentItem;

						//if it exists then update it
						if (ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))) {
							currentItem = (VideoItem)ht[vid.id.ToString()];

							//add it to the new items
							uip.UpdatedItems.Add(currentItem);

							using (new EditContext(currentItem.videoItem, true, false)) {
								SetVideoFields(ref currentItem.videoItem, vid);
							}
						}
							//else just add it
						else if (!ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))) {
							//Create new item
							TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Video"];

							currentItem = new VideoItem(account.VideoLib.videoLibraryItem.Add(vid.name.StripInvalidChars(), templateType));

							//add it to the new items
							uip.NewItems.Add(currentItem);

							using (new EditContext(currentItem.videoItem, true, false)) {
								SetVideoFields(ref currentItem.videoItem, vid);
							}
						}
					}
				} catch (System.Exception ex) {
					//HttpContext.Current.Response.Write(vid.name + "<br/>");
					throw new Exception("Failed on video: " + vid.name + ". " + ex.ToString());
				}
			}

			return uip;
		}
Ejemplo n.º 6
0
		public static UpdateInsertPair<PlaylistItem> ImportToSitecore(this AccountItem account, List<BCPlaylist> Playlists, UpdateType utype) {

			UpdateInsertPair<PlaylistItem> uip = new UpdateInsertPair<PlaylistItem>();

			//set all BCVideos into hashtable for quick access
			Hashtable ht = new Hashtable();
			foreach (PlaylistItem exPlay in account.PlaylistLib.Playlists) {
				if (!ht.ContainsKey(exPlay.playlistItem.ToString())) {
					//set as string, Item pair
					ht.Add(exPlay.PlaylistID.ToString(), exPlay);
				}
			}

			//Loop through the data source and add them
			foreach (BCPlaylist play in Playlists) {

				try {
					//remove access filter
					using (new Sitecore.SecurityModel.SecurityDisabler()) {

						PlaylistItem currentItem;

						//if it exists then update it
						if (ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))) {
							currentItem = (PlaylistItem)ht[play.id.ToString()];

							//add it to the new items
							uip.UpdatedItems.Add(currentItem);

							using (new EditContext(currentItem.playlistItem, true, false)) {
								SetPlaylistFields(ref currentItem.playlistItem, play);
							}
						}
							//else just add it
						else if (!ht.ContainsKey(play.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))) {
							//Create new item
							TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Playlist"];
							currentItem = new PlaylistItem(account.PlaylistLib.playlistLibraryItem.Add(play.name.StripInvalidChars(), templateType));

							//add it to the new items
							uip.NewItems.Add(currentItem);

							using (new EditContext(currentItem.playlistItem, true, false)) {
								SetPlaylistFields(ref currentItem.playlistItem, play);
							}
						}
					}
				} catch (System.Exception ex) {
					throw new Exception("Failed on playlist: " + play.name + ". " + ex.ToString());
				}
			}

			return uip;
		}
Ejemplo n.º 7
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (updateSource.Equals(UpdateType.IGC))
            {
                while (broadcast_listener.HasPendingMessage)
                {
                    var message = broadcast_listener.AcceptMessage();
                    if (message.Tag == broadcast_tag)
                    {
                        string action = message.Data.ToString();

                        if (action == "start")
                        {
                            float velocity = 0.1f;
                            if (piston.Velocity == 0)
                            {
                                piston.Velocity = velocity;
                            }
                            else if (piston.Velocity == velocity)
                            {
                                piston.Velocity = velocity - (velocity * 2);
                            }
                        }
                        else if (action == "halt")
                        {
                            piston.Velocity = 0f;;
                        }
                        else if (action == "drill")
                        {
                            drill.Enabled = !drill.Enabled;
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Compares two send local list requests for equality.
        /// </summary>
        /// <param name="SendLocalListRequest">A send local list request to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(SendLocalListRequest SendLocalListRequest)
        {
            if (SendLocalListRequest is null)
            {
                return(false);
            }

            return(ListVersion.Equals(SendLocalListRequest.ListVersion) &&
                   UpdateType.Equals(SendLocalListRequest.UpdateType) &&
                   LocalAuthorizationList.Count().Equals(SendLocalListRequest.LocalAuthorizationList.Count()));
        }
        /// <summary>
        /// This does not work ... for now, don't handle container changes
        /// </summary>
        /// <param name="type"></param>
        /// <param name="directoryEntry"></param>
        /// <param name="attributes"></param>
        /// <param name="config"></param>
        private static void HandleContainerChange(UpdateType type,
                                                  DirectoryEntry directoryEntry, ICollection <ConnectorAttribute> attributes,
                                                  ActiveDirectoryConfiguration config)
        {
            Name nameAttribute = ConnectorAttributeUtil.GetNameFromAttributes(attributes);

            if (nameAttribute == null)
            {
                // no name, so must not be a container change
                return;
            }

            if (!type.Equals(UpdateType.REPLACE))
            {
                // this only make sense for replace.  you can't
                // add a name or delete a name
                return;
            }

            String oldContainer = GetParentDn(directoryEntry.Path);
            String newContainer = GetParentDn(nameAttribute.GetNameValue());

            if (!NormalizeLdapString(oldContainer).Equals(NormalizeLdapString(newContainer)))
            {
                if (newContainer != null)
                {
                    try
                    {
                        if (!NormalizeLdapString(oldContainer).Equals(
                                NormalizeLdapString(newContainer)))
                        {
                            String newContainerLdapPath = ActiveDirectoryUtils.GetLDAPPath(
                                config.LDAPHostName, newContainer);
                            DirectoryEntry newContainerDe = new DirectoryEntry(newContainerLdapPath,
                                                                               config.DirectoryAdminName, config.DirectoryAdminPassword);
                            directoryEntry.MoveTo(newContainerDe);
                        }
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }
        }
        internal static void SetValue <T>(UpdateType type,
                                          DirectoryEntry directoryEntry, string name, T value)
        {
            if (!type.Equals(UpdateType.REPLACE))
            {
                // Only allow replace on single value attributes,
                // and for now, all terminal services are single value
                ThrowInvalidUpdateType(name);
            }

            if (value == null)
            {
                throw new ArgumentException();
            }

            // invoke set on 'name' with 'value'
            directoryEntry.InvokeSet(name, value);
        }
Ejemplo n.º 11
0
        public int getCompetenceLevel(string competenceId, UpdateType type)
        {
            if (!isInitialized)
            {
                initialize();
            }

            if (!isInitialized)
            {
                return(-1);
            }

            int pos = type.Equals(UpdateType.ASSESSMENT) ? 0 : 1;

            int level = getCompetenceLevels()[competenceId][pos];

            return(level);
        }
        private static void HandleNameChange(UpdateType type,
                                             DirectoryEntry directoryEntry,
                                             ICollection <ConnectorAttribute> attributes)
        {
            Name nameAttribute = ConnectorAttributeUtil.GetNameFromAttributes(attributes);

            if (nameAttribute != null)
            {
                // this only make sense for replace.  you can't
                // add a name or delete a name
                if (type.Equals(UpdateType.REPLACE))
                {
                    String oldName = directoryEntry.Name;
                    String newName = GetRelativeName(nameAttribute);
                    if (!NormalizeLdapString(oldName).Equals(NormalizeLdapString(newName)))
                    {
                        directoryEntry.Rename(newName);
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public void Main(string argument, UpdateType updateSource)
        {
            Echo(updateSource.Equals(UpdateFrequency.Update10) ? "Stopped" : "Running");

            if (_commandLine.TryParse(argument).Equals("stop"))
            {
                Runtime.UpdateFrequency = UpdateFrequency.None;
            }

            if (_commandLine.TryParse(argument).Equals("fix"))
            {
                Me.CustomData = "Battery.Empty";
            }

            LoadData();

            if ((updateSource & UpdateType.Update10) != 0 && !_commandLine.TryParse(argument).Equals("stop"))
            {
                StartStopHydrogenEngine();
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// </summary>
        /// <param name="type"></param>
        /// <param name="directoryEntry"></param>
        /// <param name="attributes"></param>
        /// <param name="config"></param>
        private static void HandleNameAndContainerChange(UpdateType type, 
            DirectoryEntry directoryEntry, ICollection<ConnectorAttribute> attributes,
            ActiveDirectoryConfiguration config)
        {
            Name nameAttribute = ConnectorAttributeUtil.GetNameFromAttributes(attributes);
            if(nameAttribute == null)
            {
                // no name, so must not be a container change
                return;
            }

            if (!type.Equals(UpdateType.REPLACE))
            {
                // this only make sense for replace.  you can't
                // add a name or delete a name
                return;
            }

            String oldName = directoryEntry.Name;
            String newName = GetRelativeName(nameAttribute);
            bool nameChanged = !NormalizeLdapString(oldName).Equals(NormalizeLdapString(newName), StringComparison.OrdinalIgnoreCase);

            String oldContainer = GetParentDn(directoryEntry.Path);
            String newContainer = GetParentDn(nameAttribute.GetNameValue());
            bool containerChanged = !NormalizeLdapString(oldContainer).Equals(NormalizeLdapString(newContainer), StringComparison.OrdinalIgnoreCase);

            if (!nameChanged && !containerChanged)
            {
                return;
            }

            if (nameChanged && !containerChanged)           // rename without moving
            {
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Renaming {0} to {1}", oldName, newName);
                directoryEntry.Rename(newName);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Rename OK");
                return;
            }

            // so this is move with or without rename

            // step 1: if WITH rename, we have to rename the entry to a temporary name first

            String temporaryName = null;
            if (nameChanged)
            {
                temporaryName = oldName + "-" + RandomStr();
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Renaming {0} to a temporary name of {1}", oldName, temporaryName);
                directoryEntry.Rename(temporaryName);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Rename OK");
            }

            // step 2: do the move

            try
            {
                String newContainerLdapPath = ActiveDirectoryUtils.GetLDAPPath(config.LDAPHostName, newContainer);
                DirectoryEntry newContainerDe = new DirectoryEntry(newContainerLdapPath, config.DirectoryAdminName, config.DirectoryAdminPassword);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Moving from {0} to {1} ({2})", oldContainer, newContainer, newContainerLdapPath);
                directoryEntry.MoveTo(newContainerDe);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Move OK");
                newContainerDe.Dispose();
            }
            catch (Exception e)
            {
                LOGGER.TraceEvent(TraceEventType.Information, CAT_DEFAULT, "Exception caught when moving: {0}", e);
                if (nameChanged)
                {
                    LOGGER.TraceEvent(TraceEventType.Information, CAT_DEFAULT, "Renaming back from temporary name of {0} to {1}", temporaryName, oldName);
                    directoryEntry.Rename(oldName);
                    LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Rename OK");
                }
                throw e;
            }

            // step 3: if WITH rename, then rename from temporary name to the new name
            if (nameChanged)
            {
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Renaming from temporary name of {0} to a new name of {1}", temporaryName, newName);
                directoryEntry.Rename(newName);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Rename OK");
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// </summary>
        /// <param name="type"></param>
        /// <param name="directoryEntry"></param>
        /// <param name="attributes"></param>
        /// <param name="config"></param>
        private static void HandleNameAndContainerChange(UpdateType type,
                                                         DirectoryEntry directoryEntry, ICollection <ConnectorAttribute> attributes,
                                                         ActiveDirectoryConfiguration config)
        {
            Name nameAttribute = ConnectorAttributeUtil.GetNameFromAttributes(attributes);

            if (nameAttribute == null)
            {
                // no name, so must not be a container change
                return;
            }

            if (!type.Equals(UpdateType.REPLACE))
            {
                // this only make sense for replace.  you can't
                // add a name or delete a name
                return;
            }

            String oldName     = directoryEntry.Name;
            String newName     = GetRelativeName(nameAttribute);
            bool   nameChanged = !NormalizeLdapString(oldName).Equals(NormalizeLdapString(newName), StringComparison.OrdinalIgnoreCase);

            String oldContainer     = GetParentDn(directoryEntry.Path);
            String newContainer     = GetParentDn(nameAttribute.GetNameValue());
            bool   containerChanged = !NormalizeLdapString(oldContainer).Equals(NormalizeLdapString(newContainer), StringComparison.OrdinalIgnoreCase);

            if (!nameChanged && !containerChanged)
            {
                return;
            }

            if (nameChanged && !containerChanged)           // rename without moving
            {
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Renaming {0} to {1}", oldName, newName);
                directoryEntry.Rename(newName);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Rename OK");
                return;
            }

            // so this is move with or without rename

            // step 1: if WITH rename, we have to rename the entry to a temporary name first

            String temporaryName = null;

            if (nameChanged)
            {
                temporaryName = oldName + "-" + RandomStr();
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Renaming {0} to a temporary name of {1}", oldName, temporaryName);
                directoryEntry.Rename(temporaryName);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Rename OK");
            }

            // step 2: do the move

            try
            {
                String         newContainerLdapPath = ActiveDirectoryUtils.GetLDAPPath(config.LDAPHostName, newContainer);
                DirectoryEntry newContainerDe       = new DirectoryEntry(newContainerLdapPath, config.DirectoryAdminName, config.DirectoryAdminPassword);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Moving from {0} to {1} ({2})", oldContainer, newContainer, newContainerLdapPath);
                directoryEntry.MoveTo(newContainerDe);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Move OK");
                newContainerDe.Dispose();
            }
            catch (Exception e)
            {
                LOGGER.TraceEvent(TraceEventType.Information, CAT_DEFAULT, "Exception caught when moving: {0}", e);
                if (nameChanged)
                {
                    LOGGER.TraceEvent(TraceEventType.Information, CAT_DEFAULT, "Renaming back from temporary name of {0} to {1}", temporaryName, oldName);
                    directoryEntry.Rename(oldName);
                    LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Rename OK");
                }
                throw e;
            }

            // step 3: if WITH rename, then rename from temporary name to the new name
            if (nameChanged)
            {
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Renaming from temporary name of {0} to a new name of {1}", temporaryName, newName);
                directoryEntry.Rename(newName);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Rename OK");
            }
        }
        /// <summary>
        /// This does not work ... for now, don't handle container changes
        /// </summary>
        /// <param name="type"></param>
        /// <param name="directoryEntry"></param>
        /// <param name="attributes"></param>
        /// <param name="config"></param>
        private static void HandleContainerChange(UpdateType type, 
            DirectoryEntry directoryEntry, ICollection<ConnectorAttribute> attributes,
            ActiveDirectoryConfiguration config)
        {
            Name nameAttribute = ConnectorAttributeUtil.GetNameFromAttributes(attributes);
            if(nameAttribute == null)
            {
                // no name, so must not be a container change
                return;
            }

            if (!type.Equals(UpdateType.REPLACE))
            {
                // this only make sense for replace.  you can't
                // add a name or delete a name
                return;
            }

            String oldContainer = GetParentDn(directoryEntry.Path);
            String newContainer = GetParentDn(nameAttribute.GetNameValue());

            if (!NormalizeLdapString(oldContainer).Equals(NormalizeLdapString(newContainer), StringComparison.OrdinalIgnoreCase))
            {
                if (newContainer != null)
                {
                    try
                    {
                        if (!NormalizeLdapString(oldContainer).Equals(
                            NormalizeLdapString(newContainer), StringComparison.OrdinalIgnoreCase))
                        {
                            String newContainerLdapPath = ActiveDirectoryUtils.GetLDAPPath(
                                config.LDAPHostName, newContainer);
                            DirectoryEntry newContainerDe = new DirectoryEntry(newContainerLdapPath,
                                config.DirectoryAdminName, config.DirectoryAdminPassword);
                            directoryEntry.MoveTo(newContainerDe);
                            newContainerDe.Dispose();
                        }
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public void Main(string argument, UpdateType updateSource)
        {
            write_settings();

            if (updateSource.Equals(UpdateType.Update100))
            {
                drill_pistons_command("status");

                //pistons at max, connector connected
                condition1 = drill_pistons_group_current_distance == drill_pistons_group_max_distance;
                condition2 = drill_connector_status == "Connected";
                if (condition1 & condition2)
                {
                    drill_status = "wait";
                    drill_drills_command("stop");
                    drill_landing_gears_command("status");
                    if (drill_landing_gears_locked == true)
                    {
                        Runtime.UpdateFrequency = UpdateFrequency.None;
                        drill_connector.Disconnect();
                        drill_connector_status = "Unconnected";
                        drill_pistons_command("retract");
                    }
                    write_settings();
                }

                //drill connected and ready
                condition1 = drill_status == "ready";
                condition2 = drill_connector_status == "Connected";
                if (condition1 & condition2)
                {
                    drill_status = "stopped";
                    drill_drills_command("start");
                    drill_status = "running";
                    write_settings();
                }
            }
            else if (updateSource.Equals(UpdateType.Update1))
            {
                //drill wait but unconnected
                condition1 = drill_status == "wait";
                condition2 = drill_connector_status == "reconnecting";
                if (condition1 & condition2)
                {
                    drill_connector.Connect();
                    if (drill_connector.Status.ToString() == "Connected")
                    {
                        drill_status            = "ready";
                        drill_connector_status  = "Connected";
                        Runtime.UpdateFrequency = UpdateFrequency.Update100;
                        write_settings();
                    }
                }
            }
            else if (updateSource.Equals(UpdateType.Trigger) | updateSource.Equals(UpdateType.Terminal))
            {
                write_settings();

                if (argument != "")
                {
                    drill_status = argument;
                }

                verify_availability();

                //switch running state
                if (drill_status == "running")
                {
                    drill_drills_command("stop");
                    drill_status = "stopped";
                }
                else if (drill_status == "stopped")
                {
                    drill_drills_command("start");
                    drill_status = "running";
                }
                else if (drill_status == "wait")
                {
                    drill_pistons_command("reconnect");
                    drill_connector_status  = "reconnecting";
                    Runtime.UpdateFrequency = UpdateFrequency.Update1;
                }
                else
                {
                    drill_status = "stopped";
                    drill_drills_command("stop");
                    drill_status = "stopped";
                }
            }

            //write settings to Programmable block Custom Data field and LCD
            write_settings();
        }
 private static void HandleNameChange(UpdateType type, 
     DirectoryEntry directoryEntry,
     ICollection<ConnectorAttribute> attributes)
 {
     Name nameAttribute = ConnectorAttributeUtil.GetNameFromAttributes(attributes);
     if (nameAttribute != null)
     {
         // this only make sense for replace.  you can't
         // add a name or delete a name
         if (type.Equals(UpdateType.REPLACE))
         {
             String oldName = directoryEntry.Name;
             String newName = GetRelativeName(nameAttribute);
             if (!NormalizeLdapString(oldName).Equals(NormalizeLdapString(newName), StringComparison.OrdinalIgnoreCase))
             {
                 directoryEntry.Rename(newName);
             }
         }
     }
 }