Exemplo n.º 1
0
        /// <summary>
        /// Edit or update the Out of Office forward users
        /// </summary>
        /// <param name="workType">The work type</param>
        /// <param name="oofSetting_workType">The Out of Office setting work type</param>
        /// <returns>The Forward users</returns>
        public Destinations editOOFUsers(WorkType workType, Dictionary <string, object> oofSetting_workType)
        {
            Destinations destinations = new Destinations();
            ArrayList    arrayList    = (ArrayList)oofSetting_workType["destinations"];

            foreach (Destination destination in workType.Destinations)
            {
                foreach (Dictionary <string, object> dictionary in arrayList)
                {
                    DestinationType destinationType = (DestinationType)Enum.Parse(typeof(DestinationType), dictionary["destinationType"].ToString());
                    if (dictionary["id"] != null)
                    {
                        string b = dictionary["id"].ToString();
                        if (destination.ID.ToString() == b)
                        {
                            destination.DestinationType = destinationType;
                            destination.Name            = dictionary["name"].ToString();
                            destinations.Add(destination);
                            break;
                        }
                    }
                    else
                    {
                        destinations.Add(new Destination(dictionary["name"].ToString(), destinationType));
                    }
                }
            }
            return(destinations);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Prepares the destinations.
 /// </summary>
 protected override void PrepareDestinations()
 {
     if (Destinations.Count == 0)
     {
         Destinations.Add(NuGetConstants.DefaultFeedUrl);
     }
 }
Exemplo n.º 3
0
 private void ProcessDestinations()
 {
     string[] vDestinations;
     foreach (KeyValuePair <string, string> vDestination in NuGetDestinations.PushDestinations)
     {
         vDestinations =
             vDestination.Value.Split
                 (Consts.SEMICOLON, StringSplitOptions.RemoveEmptyEntries);
         if (vDestinations.Length == 0)
         {
             continue;
         }
         List <NuGetRepository> vRepos = new List <NuGetRepository>();
         foreach (string vRepo in vDestinations)
         {
             NuGetRepository vFoundRepository =
                 Repositories
                 .FirstOrDefault
                 (
                     r =>
                     r.RepositoryName.Equals
                         (vRepo, StringComparison.OrdinalIgnoreCase)
                 );
             if (vFoundRepository == null)
             {
                 continue;
             }
             vRepos.Add(vFoundRepository);
         }
         Destinations.Add(vDestination.Key, vRepos);
     }
 }
Exemplo n.º 4
0
		/// <summary>
		/// Will add a new LoggingDestination to the pool of targets.  
		/// </summary>
		/// <param name="newDest">Either an existing or a custom Destination that implements the ILoggingDestination interface.</param>
		public static void AddDestination(ILoggingDestination newDest)
		{
			if (!Destinations.ContainsKey(_nonGenericTypDestination))
				Destinations.Add(_nonGenericTypDestination, new List<IDestination>());

			Destinations[_nonGenericTypDestination].Add(newDest);
		}
Exemplo n.º 5
0
 void InitDestinations()
 {
     foreach (var destination in DB.Instance.Destinations)
     {
         Destinations.Add(new DestinationVisitPurposeSelection(destination));
     }
 }
Exemplo n.º 6
0
        protected override void PrepareDestinations()
        {
            if (Destinations.Count == 0)
            {
                Destinations.Add(".");
            }

            for (int i = 0; i < Destinations.Count; i++)
            {
                if (IsDirectory(Destinations[i]))
                {
                    //destination is current directory
                    if (string.IsNullOrWhiteSpace(Destinations[i]) || Destinations[i] == ".")
                    {
                        Destinations[i] = Directory.GetCurrentDirectory();
                    }

                    // not a UNC Path
                    if (!Destinations[i].StartsWith(@"\\"))
                    {
                        Destinations[i] = Path.GetFullPath(Destinations[i]);
                    }
                }
            }
        }
Exemplo n.º 7
0
 public void SetSingleDirectDest(string dest)
 {
     Destinations.Clear();
     Destinations.Add(new DestData()
     {
         Destination = dest
     });
 }
Exemplo n.º 8
0
        public void UnselectDestination(DestinationVisitPurposeSelection destination)
        {
            //move destination from/to list
            Destinations.Add(destination);
            SelectedDestinations.Remove(destination);

            //re-sort lists
            SortDestinationList(Destinations);
            SortDestinationList(SelectedDestinations);
        }
Exemplo n.º 9
0
        /// <summary>
        /// </summary>
        public void LoadDestinations()
        {
            DirectoryInfo di = new DirectoryInfo(Path.Combine("XML Data", "Destinations"));

            FileInfo[] fiArr = di.GetFiles("*.xml");
            foreach (FileInfo fileInfo in fiArr)
            {
                int id = Convert.ToInt32(Path.GetFileNameWithoutExtension(fileInfo.Name));
                Destinations.Add(id, this.PlayFieldsLoadXml(fileInfo.FullName));
            }
        }
Exemplo n.º 10
0
 void LoadDestinations()
 {
     using (IUnitOfWork unit = new UnitOfWork())
     {
         var dists = unit.Outboxes.GetAll().Select(x => x.GoingTo).Distinct();
         foreach (var dist in dists)
         {
             Destinations.Add(dist);
         }
     }
 }
Exemplo n.º 11
0
		/// <summary>
		/// Now hidden, you shouldn't need to use this method directly, only use the shortcut methods below
		/// </summary>
		/// <param name="level">The severity level of the log statement.</param>
		/// <param name="message">The message you wish to convey in the log entry.</param>
		/// <param name="ex">Optional, pass if you have an exception you want to add to the log entry.</param>
		private static void Log(LogLevels level, string message, Exception ex = null)
		{
			if (!Destinations.ContainsKey(_nonGenericTypDestination))
				Destinations.Add(_nonGenericTypDestination, new List<IDestination>());

			if (Destinations[_nonGenericTypDestination].Count == 0)
				AddDestination(new FileDestination($"Default Log {DateTime.Now:yyyy-MM-dd hh-mm}.log"));

			foreach (ILoggingDestination dest in Destinations[_nonGenericTypDestination])
				if (dest.ValidateMessageLevel(level))
					dest.Log(level, message, ex);
		}
        public void AddDestinationBinding(String destinationName)
        {
            lock (Parent)
            {
                if (Parent.ContainsDestination(destinationName))
                {
                    DestinationInfo dInfo = Parent.GetDestination(destinationName);
                    dInfo.BindingGroupIds.Add(Id);

                    Destinations.Add(dInfo);
                    ReconstructFastDestinationArray();
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Add or save new exception user for the Out of Office status
        /// </summary>
        /// <param name="oofException">The Out of Office exception users</param>
        /// <returns>The Exception users</returns>
        public Destinations addNewExceptionUser(Dictionary <string, object> oofException)
        {
            Destinations destinations = new Destinations();
            ArrayList    arrayList    = (ArrayList)oofException["users"];

            for (int i = 0; i < arrayList.Count; i++)
            {
                Dictionary <string, object> dictionary = (Dictionary <string, object>)arrayList[i];
                string          value = (string)dictionary["destinationType"];
                DestinationType type  = (DestinationType)Enum.Parse(typeof(DestinationType), value);
                string          name  = (string)dictionary["name"];
                destinations.Add(new Destination(name, type));
            }
            return(destinations);
        }
Exemplo n.º 14
0
        /// <summary>
        /// A method that reads the cities from the current file
        /// </summary>
        private void GetCities()
        {
            // Makes sure the file is valid
            if (CurrentFile != null && !CurrentFile.Exists)
            {
                MessageBox.Show("There is no valid file selected", "No Valid File",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // Clear any previous data
            Origin = null;
            Destinations.Clear();

            string[]     temp;
            StreamReader reader = new StreamReader(CurrentFile.FullName);

            // Skip the first four lines
            for (int x = 0; x < 4; x++)
            {
                reader.ReadLine();
            }

            // Get the number of destinations
            temp = reader.ReadLine().Split(' ');
            int cityCount = int.Parse(temp[1]);

            // Skip two more lines
            for (int y = 0; y < 2; y++)
            {
                reader.ReadLine();
            }

            // Read the data for the origin city
            temp   = reader.ReadLine().Split(' ');
            Origin = new City(int.Parse(temp[0]),
                              double.Parse(temp[1]),
                              double.Parse(temp[2]));

            // Read the data for each city
            for (int z = 0; z < cityCount - 1; z++)
            {
                temp = reader.ReadLine().Split(' ');
                Destinations.Add(new City(int.Parse(temp[0]),
                                          double.Parse(temp[1]),
                                          double.Parse(temp[2])));
            }
        }
Exemplo n.º 15
0
        public void Share(string serialNo, IList <string> destUsers)
        {
            var item = GetWorklistItemBySerial(serialNo);


            if (item == null || destUsers == null || destUsers.Count == 0)
            {
                throw new InvalidOperationException("SHARE-FN: parameter was not found.");
            }

            var destinations = new Destinations();

            destUsers.Each(p =>
            {
                destinations.Add(new Destination(p, DestinationType.User));
            });
            item.Delegate(destinations);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Get The Out Of Office work type exception
        /// </summary>
        /// <param name="exceptionDtos">The Work type exceptions</param>
        /// <returns>The work type exception</returns>
        public WorkTypeExceptions GetWorkTypeExceptions(IList <WorkTypeExceptionDto> exceptionDtos)
        {
            WorkTypeExceptions worktypeExceptions = new WorkTypeExceptions();

            foreach (WorkTypeExceptionDto exceptionDto in exceptionDtos)
            {
                var          exception    = new WorkTypeException();
                Destinations destinations = new Destinations();
                foreach (DestinationDto dest in exceptionDto.Destinations)
                {
                    var destination = new Destination(dest.LoginName.FQNWithK2Label(), DestinationType.User);
                    destinations.Add(destination);
                }
                exception.Name             = exceptionDto.Name;
                exception.Destinations     = destinations;
                exception.WorklistCriteria = this.configureWorklistCriteria(exceptionDto.ProcessPath, exceptionDto.Activity);
                worktypeExceptions.Add(exception);
            }

            return(worktypeExceptions);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Adds a destination based on a connection string.
        /// </summary>
        /// <param name="connectionString">Connection string.</param>
        /// <returns>The protocol that was created and added. Null if empty connection string.</returns>
        /// <exception cref="System.ArgumentException">The protocol corresponding to the Type parameter in the connection string was not found.</exception>
        public static IProtocol AddDestinationFromConnectionString(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                return(null);
            }

            var connectionStringParts = ConnectionStringParser.Parse(connectionString);
            var type = connectionStringParts[@"Type"];

            if (!_availableProtocols.Value.ContainsKey(type))
            {
                throw new ArgumentException(string.Format("No protocol factory found for type '{0}'.", type), "connectionString");
            }

            var factory  = _availableProtocols.Value[type];
            var protocol = factory.FromConnectionString(connectionString);

            Destinations.Add(protocol);
            return(protocol);
        }
Exemplo n.º 18
0
        public void StartK2OOF()
        {
            string conStringIIF = this.AppConfig.IIFConnectionString;

            using (SqlConnection con = new SqlConnection(conStringIIF))
            {
                con.Open();
                string querySelect = "SELECT";
                querySelect = querySelect + " [Src].[Id], [Src].[FromDate], [Src].[ToDate]";
                querySelect = querySelect + " , [Src].[FromFQN], [Src].[ToFQN]";
                querySelect = querySelect + " , [Src].[IsActive], [Src].[IsCanceled], [Src].[IsExpired]";
                querySelect = querySelect + " , [Src].[IsStartedInK2], [Src].[IsEndedInK2]";
                querySelect = querySelect + " FROM [dbo].[Vw_TaskDelegation_NeedK2Started] AS [Src]";

                List <TaskDelegation> listTaskDelegation = new List <TaskDelegation>();

                using (SqlCommand cmd = con.CreateCommand())
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = querySelect;

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        int indexOf_Id            = dr.GetOrdinal("Id");
                        int indexOf_FromDate      = dr.GetOrdinal("FromDate");
                        int indexOf_ToDate        = dr.GetOrdinal("ToDate");
                        int indexOf_FromFQN       = dr.GetOrdinal("FromFQN");
                        int indexOf_ToFQN         = dr.GetOrdinal("ToFQN");
                        int indexOf_IsActive      = dr.GetOrdinal("IsActive");
                        int indexOf_IsCanceled    = dr.GetOrdinal("IsCanceled");
                        int indexOf_IsExpired     = dr.GetOrdinal("IsExpired");
                        int indexOf_IsStartedInK2 = dr.GetOrdinal("IsStartedInK2");
                        int indexOf_IsEndedInK2   = dr.GetOrdinal("IsEndedInK2");

                        while (dr.Read())
                        {
                            TaskDelegation data = new TaskDelegation();
                            data.Id            = dr.GetInt64(indexOf_Id);
                            data.FromDate      = dr.GetDateTime(indexOf_FromDate);
                            data.ToDate        = dr.GetDateTime(indexOf_ToDate);
                            data.FromFQN       = dr.GetString(indexOf_FromFQN);
                            data.ToFQN         = dr.GetString(indexOf_ToFQN);
                            data.IsActive      = dr.GetBoolean(indexOf_IsActive);
                            data.IsCanceled    = dr.GetBoolean(indexOf_IsCanceled);
                            data.IsExpired     = dr.GetBoolean(indexOf_IsExpired);
                            data.IsStartedInK2 = dr.GetBoolean(indexOf_IsStartedInK2);
                            data.IsEndedInK2   = dr.GetBoolean(indexOf_IsEndedInK2);

                            listTaskDelegation.Add(data);
                        }
                    }
                }

                Exception innerEx = null;

                foreach (TaskDelegation taskDelegation in listTaskDelegation)
                {
                    try
                    {
                        using (Connection k2Con = new Connection())
                        {
                            k2Con.Open(this.AppConfig.K2Server);
                            k2Con.ImpersonateUser(taskDelegation.FromFQN);

                            WorklistCriteria worklistCriteria = new WorklistCriteria();
                            worklistCriteria.Platform = "ASP";
                            Destinations worktypeDestinations = new Destinations();
                            worktypeDestinations.Add(new Destination(taskDelegation.ToFQN, DestinationType.User));
                            WorkType workType = new WorkType("TaskDelegationWork_" + taskDelegation.Id.ToString(), worklistCriteria, worktypeDestinations);

                            WorklistShare worklistShare = new WorklistShare();
                            worklistShare.ShareType = ShareType.OOF;

                            worklistShare.StartDate = taskDelegation.FromDate;
                            worklistShare.EndDate   = taskDelegation.ToDate;

                            worklistShare.WorkTypes.Add(workType);
                            k2Con.ShareWorkList(worklistShare);

                            k2Con.SetUserStatus(UserStatuses.OOF);

                            string queryUpdate = "UPDATE [dbo].[TaskDelegation] SET";
                            queryUpdate = queryUpdate + " [IsActive] = 1";
                            queryUpdate = queryUpdate + ", [IsExpired] = 0";
                            queryUpdate = queryUpdate + ", [IsStartedInK2] = 1";
                            queryUpdate = queryUpdate + " WHERE [Id] = @Id";

                            using (SqlCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandType = CommandType.Text;
                                cmd.CommandText = queryUpdate;
                                cmd.Parameters.Add(this.NewSqlParameter("Id", SqlDbType.BigInt, taskDelegation.Id));

                                cmd.ExecuteNonQuery();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        innerEx = ex;
                    }
                }

                if (innerEx != null)
                {
                    throw new Exception("An error occured. " + innerEx.Message, innerEx);
                }

                con.Close();
            }
        }
        // Example from page - http://help.k2.com/onlinehelp/k2blackpearl/DevRef/4.6.9/default.htm#How_to_set_a_users_Out_of_Office_Status.html%3FTocPath%3DRuntime%2520APIs%2520and%2520Services%7CWorkflow%7CWorkflow%2520Client%2520API%7CWorkflow%2520Client%2520API%2520Samples%7C_____10
        /// <summary>
        /// Add OOF share for current user
        /// </summary>
        private void AddOutOfOffice()
        {
            string destinationUser = base.GetStringProperty(Constants.SOProperties.OutOfOffice.DestinationUser);

            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];

            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;


            using (Connection k2Con = this.ServiceBroker.K2Connection.GetWorkflowClientConnection())
            {
                WorklistShares wsColl = k2Con.GetCurrentSharingSettings(ShareType.OOF);

                //  Throw error if multiple configurations (WorklistShare objects) detected, as this method cannot support that
                if (wsColl.Count > 1)
                {
                    throw new ApplicationException(Resources.MultipleOOFConfigurations);
                }
                else if (wsColl.Count == 1) //  If configuration exist already, add to it
                {
                    WorklistShare worklistshare = wsColl[0];
                    int           capacity      = worklistshare.WorkTypes[0].Destinations.Count;

                    string[] existingDestinations = new string[capacity];

                    for (int i = 0; i < capacity; i++)
                    {
                        existingDestinations[i] = worklistshare.WorkTypes[0].Destinations[i].Name.ToUpper().Trim();
                    }

                    if (Array.IndexOf(existingDestinations, destinationUser.ToUpper().Trim()) == -1)
                    {
                        worklistshare.WorkTypes[0].Destinations.Add(new Destination(destinationUser, DestinationType.User));
                    }

                    bool result = k2Con.ShareWorkList(worklistshare);

                    DataRow dr = results.NewRow();
                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = destinationUser;
                    results.Rows.Add(dr);;
                }
                else   // New user, create configuration for OOF
                {
                    // ALL Work that remains which does not form part of any "WorkTypeException" Filter
                    WorklistCriteria worklistcriteria = new WorklistCriteria();
                    worklistcriteria.Platform = "ASP";

                    // Send ALL Work based on the above Filter to the following User
                    Destinations worktypedestinations = new Destinations();
                    worktypedestinations.Add(new Destination(destinationUser, DestinationType.User));

                    // Link the filters and destinations to the Work
                    WorkType worktype = new WorkType("MyWork_" + k2Con.User.FQN, worklistcriteria, worktypedestinations);

                    WorklistShare worklistshare = new WorklistShare();
                    worklistshare.ShareType = ShareType.OOF;
                    worklistshare.WorkTypes.Add(worktype);

                    bool result = k2Con.ShareWorkList(worklistshare);
                    k2Con.SetUserStatus(UserStatuses.Available);

                    DataRow dr = results.NewRow();
                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = destinationUser;
                    results.Rows.Add(dr);
                }

                k2Con.Close();
            }
        }
        // Example from page - http://help.k2.com/onlinehelp/k2blackpearl/DevRef/4.6.9/default.htm#How_to_set_a_users_Out_of_Office_Status.html%3FTocPath%3DRuntime%2520APIs%2520and%2520Services%7CWorkflow%7CWorkflow%2520Client%2520API%7CWorkflow%2520Client%2520API%2520Samples%7C_____10
        /// <summary>
        /// Add OOF share for current user
        /// </summary>
        private void AddOutOfOffice()
        {
            string destinationUser = base.GetStringProperty(Constants.SOProperties.OutOfOffice.DestinationUser);

            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];
            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);

                WorklistShares wsColl = k2Con.GetCurrentSharingSettings(ShareType.OOF);

                //  Throw error if multiple configurations (WorklistShare objects) detected, as this method cannot support that
                if (wsColl.Count > 1)
                {
                    throw new ApplicationException(Constants.ErrorMessages.MultipleOOFConfigurations);
                }

                //  If configuration exist already, add to it
                else if (wsColl.Count == 1)
                {

                    WorklistShare worklistshare = wsColl[0];

                    int capacity = worklistshare.WorkTypes[0].Destinations.Count;

                    string[] existingDestinations = new string[capacity];

                    for (int i = 0; i < capacity; i++)
                    {
                        existingDestinations[i] = worklistshare.WorkTypes[0].Destinations[i].Name.ToUpper().Trim();
                    }

                    if (Array.IndexOf(existingDestinations, destinationUser.ToUpper().Trim()) == -1)
                    {
                        worklistshare.WorkTypes[0].Destinations.Add(new Destination(destinationUser, DestinationType.User));
                    }

                    bool result = k2Con.ShareWorkList(worklistshare);

                    DataRow dr = results.NewRow();

                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = destinationUser;

                    results.Rows.Add(dr); ;

                }
                // New user, create configuration for OOF
                else
                {

                    // ALL Work that remains which does not form part of any "WorkTypeException" Filter
                    WorklistCriteria worklistcriteria = new WorklistCriteria();
                    worklistcriteria.Platform = "ASP";

                    // Send ALL Work based on the above Filter to the following User
                    Destinations worktypedestinations = new Destinations();
                    worktypedestinations.Add(new Destination(destinationUser, DestinationType.User));

                    // Link the filters and destinations to the Work
                    WorkType worktype = new WorkType("MyWork_" + k2Con.User.FQN, worklistcriteria, worktypedestinations);

                    WorklistShare worklistshare = new WorklistShare();
                    worklistshare.ShareType = ShareType.OOF;
                    worklistshare.WorkTypes.Add(worktype);

                    bool result = k2Con.ShareWorkList(worklistshare);
                    k2Con.SetUserStatus(UserStatuses.Available);

                    DataRow dr = results.NewRow();

                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = destinationUser;

                    results.Rows.Add(dr);

                }

                k2Con.Close();
            }
        }
Exemplo n.º 21
0
        private void AddOutOfOffice()
        {
            string userFQN         = base.GetStringProperty(Constants.SOProperties.OutOfOffice.UserFQN, true);
            string destinationUser = base.GetStringProperty(Constants.SOProperties.OutOfOffice.DestinationUser, true);

            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];

            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            WorkflowManagementServer mngServer = new WorkflowManagementServer();

            using (mngServer.CreateConnection())
            {
                mngServer.Open(BaseAPIConnectionString);

                WorklistShares wsColl = mngServer.GetCurrentSharingSettings(userFQN, ShareType.OOF);

                //  Throw error if multiple configurations (WorklistShare objects) detected, as this method cannot support that
                if (wsColl.Count > 1)
                {
                    throw new ApplicationException(Constants.ErrorMessages.MultipleOOFConfigurations);
                }

                //  If configuration exist already, add to it
                if (wsColl.Count == 1)
                {
                    WorklistShare worklistshare = wsColl[0];
                    worklistshare.WorkTypes[0].Destinations.Add(new Destination(destinationUser, DestinationType.User));
                    bool result = mngServer.ShareWorkList(userFQN, worklistshare);
                    if (!result)
                    {
                        throw new ApplicationException(Constants.ErrorMessages.FailedToSetOOF);
                    }
                    DataRow dr = results.NewRow();
                    dr[Constants.SOProperties.OutOfOffice.UserFQN]         = userFQN;
                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = destinationUser;

                    results.Rows.Add(dr);;
                }
                // New user, create configuration for OOF
                else
                {
                    // ALL Work that remains which does not form part of any "WorkTypeException" Filter
                    WorklistCriteria worklistcriteria = new WorklistCriteria();
                    worklistcriteria.Platform = "ASP";

                    // Send ALL Work based on the above Filter to the following User
                    Destinations worktypedestinations = new Destinations();
                    worktypedestinations.Add(new Destination(destinationUser, DestinationType.User));

                    // Link the filters and destinations to the Work
                    WorkType worktype = new WorkType("MyWork", worklistcriteria, worktypedestinations);

                    WorklistShare worklistshare = new WorklistShare();
                    worklistshare.ShareType = ShareType.OOF;
                    worklistshare.WorkTypes.Add(worktype);

                    bool result = mngServer.ShareWorkList(userFQN, worklistshare);
                    if (!result)
                    {
                        throw new ApplicationException(Constants.ErrorMessages.FailedToSetOOF);
                    }
                    result = mngServer.SetUserStatus(userFQN, UserStatuses.Available);
                    if (!result)
                    {
                        throw new ApplicationException(Constants.ErrorMessages.FailedToSetOOF);
                    }

                    DataRow dr = results.NewRow();
                    dr[Constants.SOProperties.OutOfOffice.UserFQN]         = userFQN;
                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = destinationUser;
                    results.Rows.Add(dr);
                }
            }
        }
Exemplo n.º 22
0
        // Example from page - http://help.k2.com/onlinehelp/k2blackpearl/DevRef/4.6.9/default.htm#How_to_set_a_users_Out_of_Office_Status.html%3FTocPath%3DRuntime%2520APIs%2520and%2520Services%7CWorkflow%7CWorkflow%2520Client%2520API%7CWorkflow%2520Client%2520API%2520Samples%7C_____10
        private void AddOutOfOffice()
        {
            string userFQN = base.GetStringProperty(Constants.Properties.OutOfOffice.UserFQN);
            string destinationUser = base.GetStringProperty(Constants.Properties.OutOfOffice.DestinationUser);

            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];
            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            WorkflowManagementServer mngServer = new WorkflowManagementServer();

            using (mngServer.CreateConnection())
            {
                mngServer.Open(BaseAPIConnectionString);

                WorklistShares wsColl = mngServer.GetCurrentSharingSettings(userFQN, ShareType.OOF);

                //  Throw error if multiple configurations (WorklistShare objects) detected, as this method cannot support that
                if (wsColl.Count > 1)
                {
                    throw new ApplicationException(Constants.ErrorMessages.MultipleOOFConfigurations);
                }

                //  If configuration exist already, add to it
                if (wsColl.Count == 1)
                {

                    WorklistShare worklistshare = wsColl[0];
                    worklistshare.WorkTypes[0].Destinations.Add(new Destination(destinationUser, DestinationType.User));
                    bool result = mngServer.ShareWorkList(userFQN, worklistshare);

                    DataRow dr = results.NewRow();
                    dr[Constants.Properties.OutOfOffice.UserFQN] = userFQN;
                    dr[Constants.Properties.OutOfOffice.DestinationUser] = destinationUser;
                    dr[Constants.Properties.OutOfOffice.CallSuccess] = result;
                    results.Rows.Add(dr); ;

                }
                // New user, create configuration for OOF
                else
                {
                    // ALL Work that remains which does not form part of any "WorkTypeException" Filter
                    WorklistCriteria worklistcriteria = new WorklistCriteria();
                    worklistcriteria.Platform = "ASP";

                    // Send ALL Work based on the above Filter to the following User
                    Destinations worktypedestinations = new Destinations();
                    worktypedestinations.Add(new Destination(destinationUser, DestinationType.User));

                    // Link the filters and destinations to the Work
                    WorkType worktype = new WorkType("MyWork", worklistcriteria, worktypedestinations);

                    WorklistShare worklistshare = new WorklistShare();
                    worklistshare.ShareType = ShareType.OOF;
                    worklistshare.WorkTypes.Add(worktype);

                    bool result = mngServer.ShareWorkList(userFQN, worklistshare);
                    mngServer.SetUserStatus(userFQN, UserStatuses.Available);

                    DataRow dr = results.NewRow();
                    dr[Constants.Properties.OutOfOffice.UserFQN] = userFQN;
                    dr[Constants.Properties.OutOfOffice.DestinationUser] = destinationUser;
                    dr[Constants.Properties.OutOfOffice.CallSuccess] = result;
                    results.Rows.Add(dr);
                }

            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Create or set the Out Of Office of current user
        /// </summary>
        /// <param name="wrapper">The Out Of Office criteria</param>
        /// <returns>Success(true) or Fail(False)</returns>
        public bool SetOutOfOffice(OOFWrapper wrapper)
        {
            if (wrapper.WorkType == null)
            {
                using (Connection workflowClient = this.GetWorkflowClient()) {
                    workflowClient.SetUserStatus(Convert.ToBoolean(wrapper.Status) ? UserStatuses.Available : UserStatuses.OOF);
                }

                return(false);
            }

            using (Connection workflowClient = this.GetWorkflowClient()) {
                bool           isNew          = false;
                WorklistShares worklistShares = new WorklistShares();
                worklistShares = workflowClient.GetCurrentSharingSettings(ShareType.OOF);
                WorklistShare worklistShare = null;
                if (worklistShares.Count > 0)
                {
                    worklistShare           = worklistShares[0];
                    worklistShare.ShareType = ShareType.OOF;
                }
                else
                {
                    isNew = true;
                }

                if (worklistShare == null)
                {
                    worklistShare           = new WorklistShare();
                    worklistShare.ShareType = ShareType.OOF;
                    isNew = true;
                }


                worklistShare.StartDate = wrapper.StartDate;
                worklistShare.EndDate   = wrapper.EndDate;

                WorkTypes workTypes = worklistShare.WorkTypes;
                WorkType  workType  = new WorkType();

                if (workTypes.Count > 0)
                {
                    workType = workTypes[0];
                }
                else
                {
                    workType = new WorkType();
                    workTypes.Add(workType);
                }
                workType.Name = Guid.NewGuid().ToString();
                Destinations destinations = new Destinations();

                foreach (DestinationDto dest in wrapper.WorkType.Destinations)
                {
                    if (SecurityLabelUtils.IsCorrectUserName(dest.LoginName))
                    {
                        var destination = new K2.Destination(SecurityLabelUtils.GetNameWithLabel(dest.LoginName), DestinationType.User);
                        destinations.Add(destination);
                    }
                }

                workType.Destinations       = destinations;
                workType.WorkTypeExceptions = GetWorkTypeExceptions(wrapper.WorkType.WorkTypeExceptions);
                worklistShare.WorkTypes     = workTypes;

                if (isNew)
                {
                    workflowClient.ShareWorkList(worklistShare);
                }
                workflowClient.UpdateWorkType(worklistShare.WorkTypes[0]);
                workflowClient.SetUserStatus(Convert.ToBoolean(wrapper.Status) ? UserStatuses.Available : UserStatuses.OOF);
            }

            return(true);
        }
Exemplo n.º 24
0
 //Method for adding airports
 public void AddDestination(Airport des)
 {
     Destinations.Add(des.Code, des);
     //Add this airport as destination to other
     des.Destinations.Add(Code, this);
 }
Exemplo n.º 25
0
        public void linkSpots(string[] maze)
        {
            Spot[,] spots = new Spot[maze.Length, getLongestLine(maze)];
            int x = 0;
            int y = 0;

            foreach (String line in maze)
            {
                y = 0;
                foreach (char symbol in line.ToCharArray())
                {
                    Spot spot = null;
                    switch (symbol)
                    {
                    case 'x':
                        spot = new Destination();
                        Destinations.Add((Destination)spot);
                        break;

                    case '.':
                        spot = new Floor();
                        break;

                    case 'o':
                        spot = new Floor();
                        Crate crate = new Crate(spot);
                        spot.ContainsItem = crate;
                        Crates.Add(crate);
                        break;

                    case '~':
                        spot = new Trap();
                        break;

                    case '@':
                        spot = new Floor();
                        Truck truck = new Truck(spot);
                        spot.ContainsItem = truck;
                        _truck            = truck;
                        break;

                    case '$':
                        spot = new Floor();
                        Colleague colleague = new Colleague(spot);
                        spot.ContainsItem = colleague;
                        _colleague        = colleague;
                        break;

                    case '#':
                        spot = new Wall();
                        break;

                    case '0':
                        spot = new Destination();
                        Destinations.Add((Destination)spot);
                        crate             = new Crate(spot);
                        spot.ContainsItem = crate;
                        Crates.Add(crate);
                        break;

                    case ' ':
                        spot         = new Floor();
                        spot.IsEmpty = true;
                        break;
                    }

                    spots[x, y] = spot;
                    y++;
                }
                x++;
            }

            for (int i = 0; i < spots.GetLength(0); i++)
            {
                for (int j = 0; j < spots.GetLength(1); j++)
                {
                    Spot spot = spots[i, j];

                    if (spot == null)
                    {
                        continue;
                    }

                    spot.UpSpot    = getSpot(spots, i - 1, j);
                    spot.RightSpot = getSpot(spots, i, j + 1);
                    spot.DownSpot  = getSpot(spots, i + 1, j);
                    spot.LeftSpot  = getSpot(spots, i, j - 1);

                    if (i == 0 && j == 0)
                    {
                        _first = spot;
                    }
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Create or set the Out Of Office of current user
        /// </summary>
        /// <param name="wrapper">The Out Of Office criteria</param>
        /// <returns>Success(true) or Fail(False)</returns>
        public bool SetOutOfOffice(OOFWrapper wrapper)
        {
            if (wrapper.WorkType == null)
            {
                _connection.SetUserStatus(Convert.ToBoolean(wrapper.Status) ? UserStatuses.Available : UserStatuses.OOF);
                return(false);
            }


            bool           isNew          = false;
            WorklistShares worklistShares = new WorklistShares();

            worklistShares = _connection.GetCurrentSharingSettings(ShareType.OOF);
            WorklistShare worklistShare = null;

            if (worklistShares.Count > 0)
            {
                worklistShare           = worklistShares[0];
                worklistShare.ShareType = ShareType.OOF;
            }
            else
            {
                isNew = true;
            }

            if (worklistShare == null)
            {
                worklistShare           = new WorklistShare();
                worklistShare.ShareType = ShareType.OOF;
                isNew = true;
            }


            worklistShare.StartDate = wrapper.StartDate;
            worklistShare.EndDate   = wrapper.EndDate;

            WorkTypes workTypes = worklistShare.WorkTypes;
            WorkType  workType  = new WorkType();

            if (workTypes.Count > 0)
            {
                workType = workTypes[0];
            }
            else
            {
                workType = new WorkType();
                workTypes.Add(workType);
            }
            workType.Name = Guid.NewGuid().ToString();
            Destinations destinations = new Destinations();

            foreach (DestinationDto dest in wrapper.WorkType.Destinations)
            {
                var destination = new Destination(dest.LoginName.FQNWithK2Label(), DestinationType.User);
                destinations.Add(destination);
            }

            workType.Destinations       = destinations;
            workType.WorkTypeExceptions = GetWorkTypeExceptions(wrapper.WorkType.WorkTypeExceptions);
            worklistShare.WorkTypes     = workTypes;

            if (isNew)
            {
                _connection.ShareWorkList(worklistShare);
            }
            _connection.UpdateWorkType(worklistShare.WorkTypes[0]);
            _connection.SetUserStatus(Convert.ToBoolean(wrapper.Status) ? UserStatuses.Available : UserStatuses.OOF);


            return(true);
        }
Exemplo n.º 27
0
 public void AddDestination(TrainStation des)
 {
     Destinations.Add(des.Code, des);
     //add this destination to the one coming in
     des.Destinations.Add(Code, this);
 }
Exemplo n.º 28
0
 public void AddDestination(IReportDestination destination)
 {
     Destinations.Add(destination);
     destination.WriteHeader((from dc in _dtAllFailures.Columns.Cast <DataColumn>() select dc.ColumnName).ToArray());
 }