/// <sumary>
        /// </summary>
        private void actualizaCamposPersonalizados()
        {
            using (ProjectCont1)
            {
                Guid Id = new Guid("888c9a81-5fce-e911-b081-00155db8343c");
                CustomFieldCollection        customFields = ProjectCont1.CustomFields;
                EnterpriseResourceCollection resources    = ProjectCont1.EnterpriseResources;
                ProjectCont1.Load(ProjectCont1.EnterpriseResources.GetByGuid(Id));
                ProjectCont1.ExecuteQuery();

                var cfInternalName = "Custom_aaf4156c7804e511943500155d569905";
                foreach (EnterpriseResource res in resources)
                {
                    string[] Newval = new string[] { "Entry_333982d27604e511943500155d569905" };
                    res[cfInternalName] = Newval;
                }

                ProjectCont1.EnterpriseResources.Update();
                ProjectCont1.ExecuteQuery();


                /*
                 * CustomField cfPersonType;
                 * String cfPersonTypeInternalName;
                 * cfPersonType = customFields.First(c => c.Name == "Resource_HR_Person_Type");
                 * cfPersonTypeInternalName = cfPersonType.InternalName; */
            }
        }
        public void GetCustomFieldOptions()
        {
            CustomFieldCollection customFields = TestSetup.KayakoApiService.CustomFields.GetCustomFields();

            Assert.IsNotNull(customFields, "No custom fields were returned");
            Assert.IsNotEmpty(customFields, "No custom fields were returned");

            int idToUse = -1;

            foreach (CustomField customField in customFields)
            {
                CustomFieldOptionCollection customFieldOptions = TestSetup.KayakoApiService.CustomFields.GetCustomFieldOptions(customField.CustomFieldId);
                if (customFieldOptions.Count > 0)
                {
                    idToUse = customField.CustomFieldId;
                    break;
                }
            }

            if (idToUse != -1)
            {
                CustomFieldOptionCollection customFieldOptions = TestSetup.KayakoApiService.CustomFields.GetCustomFieldOptions(idToUse);

                Assert.IsNotNull(customFieldOptions, "No custom fields were returned");
                Assert.IsNotEmpty(customFieldOptions, "No custom fields were returned");
            }
            else
            {
                throw new Exception("No custom field options found");
            }
        }
        public void GetCustomFields()
        {
            CustomFieldCollection customFields = TestSetup.KayakoApiService.CustomFields.GetCustomFields();

            Assert.IsNotNull(customFields, "No custom fields were returned");
            Assert.IsNotEmpty(customFields, "No custom fields were returned");
        }
Beispiel #4
0
 /// <summary>
 /// Creates an object representing a single video within Brightcove's system.
 /// </summary>
 public BrightcoveVideo()
 {
     Tags         = new List <string>();
     CustomFields = new CustomFieldCollection();
     Renditions   = new List <BrightcoveRendition>();
     CuePoints    = new List <BrightcoveCuePoint>();
     ItemState    = ItemState.Active;
     Economics    = Economics.Free;
 }
 /// <summary>
 /// Creates an object representing a single video within Brightcove's system.
 /// </summary>
 public BrightcoveVideo()
 {
     Tags = new List<string>();
     CustomFields = new CustomFieldCollection();
     Renditions = new List<BrightcoveRendition>();
     CuePoints = new List<BrightcoveCuePoint>();
     ItemState = ItemState.Active;
     Economics = Economics.Free;
 }
    public CustomFieldCollection GetFieldsCollection()
    {
        CustomFieldCollection collection = new CustomFieldCollection();

        collection["fieldA"] = 1;
        collection["fieldB"] = true;
        collection["fieldC"] = DateTime.Now;
        collection["fieldD"] = "hello";
        return(collection);
    }
        protected CollectionBase  GenerateCustomFieldCollectionFromReader(IDataReader returnData)
        {
            CustomFieldCollection cfCollection = new CustomFieldCollection();

            while (returnData.Read())
            {
                CustomField cf = new CustomField((int)returnData["CustomFieldId"], (int)returnData["ProjectId"], (string)returnData["CustomFieldName"], (ValidationDataType)returnData["CustomFieldDataType"], (bool)returnData["CustomFieldRequired"], (string)returnData["CustomFieldValue"]);
                cfCollection.Add(cf);
            }
            return(cfCollection);
        }
Beispiel #8
0
        public override EventResult <EnterpriseResource> Execute()
        {
            EventResult <EnterpriseResource> result = new EventResult <EnterpriseResource>();

            Param.Util.LoadEnterpriseResources();
            EnterpriseResource    resource = Param.Util.ProjContext.EnterpriseResources[0];
            CustomFieldCollection cusCol   = resource.CustomFields;

            Param.Util.ProjContext.Load(cusCol);
            Param.Util.ProjContext.ExecuteQuery();
            result.ForResearch = resource.FieldValues;
            result.Result      = resource;
            return(result);
        }
        public void Setup()
        {
            _kayakoApiRequest = new Mock<IKayakoApiRequest>();
            _customFieldController = new CustomFieldController(_kayakoApiRequest.Object);

            _responseCustomFieldCollection = new CustomFieldCollection
                {
                    new CustomField(),
                    new CustomField()
                };

            _responseCustomFieldOptionsCollection = new CustomFieldOptionCollection
                {
                    new CustomFieldOption(),
                    new CustomFieldOption()
                };
        }
        public void Setup()
        {
            _kayakoApiRequest = new Mock<IKayakoApiRequest>();
            _customFieldController = new CustomFieldController(_kayakoApiRequest.Object);

            _responseCustomFieldCollection = new CustomFieldCollection
                {
                    new CustomField(),
                    new CustomField()
                };

            _responseCustomFieldOptionsCollection = new CustomFieldOptionCollection
                {
                    new CustomFieldOption(),
                    new CustomFieldOption()
                };
        }
Beispiel #11
0
        public void Update(CustomFieldCollection data)
        {
            var updateCollection = data.ItemsToUpdate;
            var deleteCollection = data.ItemsToDelete;
            var insertCollection = data.ItemsToAdd;

            if (updateCollection != null)
            {
                Update(updateCollection);
            }
            if (deleteCollection != null)
            {
                Delete(deleteCollection);
            }
            if (insertCollection != null)
            {
                Insert(insertCollection);
            }
        }
        public void CustomFieldCollectionDeserialization()
        {
            var customFieldCollection = new CustomFieldCollection
                {
                    new CustomField
                        {
                            CustomFieldId = 1,
                            CustomFieldGroupId = 1,
                            Title = "Customer ID",
                            FieldType = CustomFieldFieldType.Text,
                            FieldName = "cn4ezfbjzyoj",
                            DefaultValue = "",
                            IsRequired = false,
                            UserEditable = false,
                            StaffEditable = true,
                            RegexValidate = "",
                            DisplayOrder = 1,
                            EncryptInDatabase = false,
                            Description = ""
                        },
                    new CustomField
                        {
                            CustomFieldId = 2,
                            CustomFieldGroupId = 1,
                            Title = "Product",
                            FieldType = CustomFieldFieldType.Select,
                            FieldName = "llcut44uri9d",
                            DefaultValue = "",
                            IsRequired = false,
                            UserEditable = false,
                            StaffEditable = true,
                            RegexValidate = "",
                            DisplayOrder = 2,
                            EncryptInDatabase = false,
                            Description = ""
                        }
                };

            var expectedCustomFieldCollection = XmlDataUtility.ReadFromFile<CustomFieldCollection>("TestData/CustomFieldCollection.xml");

            AssertUtility.ObjectsEqual(expectedCustomFieldCollection, customFieldCollection);
        }
        public void CustomFieldCollectionDeserialization()
        {
            var customFieldCollection = new CustomFieldCollection
            {
                new CustomField
                {
                    CustomFieldId      = 1,
                    CustomFieldGroupId = 1,
                    Title             = "Customer ID",
                    FieldType         = CustomFieldFieldType.Text,
                    FieldName         = "cn4ezfbjzyoj",
                    DefaultValue      = "",
                    IsRequired        = false,
                    UserEditable      = false,
                    StaffEditable     = true,
                    RegexValidate     = "",
                    DisplayOrder      = 1,
                    EncryptInDatabase = false,
                    Description       = ""
                },
                new CustomField
                {
                    CustomFieldId      = 2,
                    CustomFieldGroupId = 1,
                    Title             = "Product",
                    FieldType         = CustomFieldFieldType.Select,
                    FieldName         = "llcut44uri9d",
                    DefaultValue      = "",
                    IsRequired        = false,
                    UserEditable      = false,
                    StaffEditable     = true,
                    RegexValidate     = "",
                    DisplayOrder      = 2,
                    EncryptInDatabase = false,
                    Description       = ""
                }
            };

            var expectedCustomFieldCollection = XmlDataUtility.ReadFromFile <CustomFieldCollection>("TestData/CustomFieldCollection.xml");

            AssertUtility.ObjectsEqual(expectedCustomFieldCollection, customFieldCollection);
        }
		/// <summary>
		/// Creates an object representing a single video within Brightcove's system.
		/// </summary>
		public BrightcoveVideo(string shortDescription)
		{
			Tags = new List<string>();
			CustomFields = new CustomFieldCollection();
			Renditions = new List<BrightcoveRendition>();
			CuePoints = new List<BrightcoveCuePoint>();
			ItemState = ItemState.Active;
			Economics = Economics.Free;
            if(string.IsNullOrEmpty(shortDescription)  || shortDescription.Trim()==string.Empty)
                throw new ArgumentNullException(shortDescription);
            //required field
            ShortDescription = shortDescription;
		}
 public abstract bool    SaveCustomFieldValues(int issueId, CustomFieldCollection fields);
Beispiel #16
0
        // This function shows how to list facts about the MS Project site
        public void ListContextData()
        {
            Console.WriteLine("\nListing context data...\n");

            Console.WriteLine("---------------All Projects---------------");
            context.Load(context.Projects);
            context.ExecuteQuery();

            foreach (PublishedProject proj in context.Projects)
            {
                Console.WriteLine(proj.Name);
            }

            Console.WriteLine("---------------All Site Users---------------");
            UserCollection siteUsers = context.Web.SiteUsers;

            context.Load(siteUsers);
            context.ExecuteQuery();

            var peopleManager = new PeopleManager(context);

            foreach (var user in siteUsers)
            {
                try
                {
                    PersonProperties userProfile = peopleManager.GetPropertiesFor(user.LoginName);
                    context.Load(userProfile);
                    context.ExecuteQuery();

                    Console.WriteLine(userProfile.DisplayName + " (" + userProfile.Email + ")");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error loading user: "******" --> " + ex.Message);
                }
            }


            Console.WriteLine("---------------All Site User Resources---------------");
            EnterpriseResourceCollection resources = context.EnterpriseResources;

            context.Load(resources);
            context.ExecuteQuery();

            foreach (EnterpriseResource res in resources)
            {
                Console.WriteLine(res.Name + " {" + res.Id + "}");
            }

            Console.WriteLine("---------------Custom Fields---------------");
            CustomFieldCollection customFields = context.CustomFields;

            context.Load(customFields);
            context.ExecuteQuery();
            foreach (CustomField cf in customFields)
            {
                Console.WriteLine(cf.Name + " {" + cf.Id + "}");
            }

            Console.WriteLine("---------------Lookup Tables---------------");
            LookupTableCollection lookupTables = context.LookupTables;

            context.Load(lookupTables);
            context.ExecuteQuery();
            foreach (LookupTable lt in lookupTables)
            {
                Console.WriteLine(lt.Name + " {" + lt.Id + "}");

                context.Load(lt.Entries);
                context.ExecuteQuery();
                foreach (LookupEntry entry in lt.Entries)
                {
                    Console.WriteLine("    " + entry.FullValue + " {" + entry.Id + "}");
                }
            }
        }
Beispiel #17
0
        public JsonResult UpdateCustomFieldCollection(CustomFieldCollection data)
        {
            _customeFieldRepository.Update(data);

            return(Json("Ok"));
        }
        static void Main(string[] args)
        {
            // Lists out the LCFs for a specific project in the PWA instance, consisting of the
            // field type, field name, whether a lookup table is used, and the value and description of each each LCF entry.

            // This app does the following:
            // 1. Retrieves a specific project, task(s), and custom fields associated with the tasks in the project
            // 2. Place the custom field key/value pairs in a dictionary
            // 3. Do the following for each Local Custom Field:
            //    A. Distinguish between simple values and values that use a lookup table for
            //       the friendly values.
            //    B. Filter out partial entries.
            //    C. List the friendly value for the user (simple values)
            //    D. List the friendly value for the user (lookup tables)

            using (projContext)
            {
                // Get login cookie using WebLogin
                var cookies = WebLogin.GetWebLoginCookie(new Uri(SiteUrl));

                projContext.ExecutingWebRequest += delegate(object sender, WebRequestEventArgs e)
                {
                    e.WebRequestExecutor.WebRequest.CookieContainer = new CookieContainer();
                    e.WebRequestExecutor.WebRequest.CookieContainer.SetCookies(new Uri(SiteUrl), cookies);
                };

                // 1. Retrieve the project, tasks, etc.
                var projColl = projContext.LoadQuery(projContext.Projects
                                                     .Where(p => p.Name == SampleProjectName)
                                                     .Include(
                                                         p => p.Id,
                                                         p => p.Name,
                                                         p => p.Tasks,
                                                         p => p.Tasks.Include(
                                                             t => t.Id,
                                                             t => t.Name,
                                                             t => t.CustomFields,
                                                             t => t.CustomFields.IncludeWithDefaultProperties(
                                                                 cf => cf.LookupTable,
                                                                 cf => cf.LookupEntries
                                                                 )
                                                             )
                                                         )
                                                     );

                projContext.ExecuteQuery();

                PublishedProject theProj = projColl.First();


                Console.WriteLine("Name:\t{0}", theProj.Name);
                Console.WriteLine("Id:\t{0}", theProj.Id);
                Console.WriteLine("Tasks count: {0}", theProj.Tasks.Count);
                Console.WriteLine("  -----------------------------------------------------------------------------");


                PublishedTaskCollection taskColl = theProj.Tasks;

                PublishedTask theTask = taskColl.First();

                CustomFieldCollection LCFColl = theTask.CustomFields;

                // 2. Place the task-specific custom field key/value pairs in a dictionary
                Dictionary <string, object> taskCF_Dict = theTask.FieldValues;

                if (LCFColl.Count > 0)
                {
                    Console.WriteLine("\n\tType\t   Name\t\t  L.UP   Value                  Description");
                    Console.WriteLine("\t--------   ------------   ----   --------------------   -----------");

                    // 3. For each custom field, do the follwoing:
                    foreach (CustomField cf in LCFColl)
                    {
                        // 3A. Distinguish LCF values that are simple from those that use lookup tables.
                        if (!cf.LookupTable.ServerObjectIsNull.HasValue ||
                            (cf.LookupTable.ServerObjectIsNull.HasValue && cf.LookupTable.ServerObjectIsNull.Value))
                        {
                            if (taskCF_Dict[cf.InternalName] == null)
                            {   // 3B. Partial implementation. Not usable.
                                String textValue = "is not set";
                                Console.WriteLine("\t{0} {1}  {2}", cf.FieldType, cf.Name, textValue);
                            }
                            else     // 3C. Friendly value for the user (simple).
                            {
                                String textValue = taskCF_Dict[cf.InternalName].ToString();
                                Console.WriteLine("\t{0, -8}   {1, -15}       {2}", cf.FieldType, cf.Name, textValue);
                            }
                        }
                        else         //3D. Friendly value for the user that uses a Lookup table.
                        {
                            Console.Write("\t{0, -8}   {1, -15}", cf.FieldType, cf.Name);

                            String[] entries = (String[])taskCF_Dict[cf.InternalName];

                            foreach (String entry in entries)
                            {
                                var luEntry = projContext.LoadQuery(cf.LookupTable.Entries
                                                                    .Where(e => e.InternalName == entry));

                                projContext.ExecuteQuery();

                                Console.WriteLine("Yes    {0, -22}  {1}", luEntry.First().FullValue, luEntry.First().Description);
                            }
                        }
                    }   // End foreach CustomField
                }
            }

            Console.Write("\nPress any key to exit: ");
            Console.ReadKey(false);
        }   // End of Main