コード例 #1
0
        public static CustomField2 Execute(CorrigoService service, CorrigoEntity entity,
                                           CustomFieldDescriptor customFieldDescriptor)
        {
            string label    = "IFS-1119";
            string href     = "https://jira.qa.corrigo.com:55445/browse/IFS-1119";
            string urlValue = $"<a href=\"{href}\">{label}</a>";

            var customField = new CustomField2
            {
                Descriptor = new CustomFieldDescriptor {
                    Id = customFieldDescriptor.Id
                },
                ObjectId     = entity.Id,
                ObjectTypeId = customFieldDescriptor.ActorTypeId,
                Value        = urlValue
            };
            var command = new CreateCommand {
                Entity = customField
            };
            var response = service.Execute(command) as OperationCommandResponse;

            customField.Id = response?.EntitySpecifier?.Id ?? 0;

            return(customField);
        }
コード例 #2
0
        public static void Restore(CorrigoService service, CustomField2 toRestore)
        {
            if (toRestore == null || service == null)
            {
                return;
            }
            Console.WriteLine();
            Console.WriteLine($"Restoring CustomField2 with id={toRestore.Id.ToString()}");

            var restoreResult = service.Execute(new RestoreCommand
            {
                EntitySpecifier = new EntitySpecifier {
                    Id = toRestore.Id, EntityType = EntityType.CustomField2
                }
            });

            if (restoreResult == null)
            {
                Console.WriteLine("Update of CustomField2 failed");
                return;
            }

            if (restoreResult.ErrorInfo != null && !string.IsNullOrEmpty(restoreResult.ErrorInfo.Description))
            {
                Console.WriteLine(restoreResult.ErrorInfo.Description);
                Console.WriteLine("Restore of CustomField2 failed");
                return;
            }

            Console.WriteLine("CustomField2 is restored");
        }
コード例 #3
0
        public static void Execute(CorrigoService service, CustomField2 customField)
        {
            string label    = "upd-IFS-1119 ";
            string href     = "https://jira.qa.corrigo.com:55445/browse/IFS-1119";
            string urlValue = $"<a href=\"{href}\">{label}</a>";

            customField.Value = urlValue;

            var command = new UpdateCommand
            {
                Entity      = customField,
                PropertySet = new PropertySet {
                    Properties = new[] { "Value" }
                }
            };
            var response = service.Execute(command) as OperationCommandResponse;
        }
コード例 #4
0
        /// <summary>
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            unchecked
            {
                // ReSharper disable NonReadonlyMemberInGetHashCode
                var hashCode = HostAddress != null?HostAddress.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (UserId != null ? UserId.GetHashCode() : 0);
                //hashCode = (hashCode * 397) ^ (Password != null ? Password.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ MaxResult;
                hashCode = (hashCode * 397) ^ (ReportName != null ? ReportName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (CustomField1 != null ? CustomField1.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (CustomField2 != null ? CustomField2.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (CustomField3 != null ? CustomField3.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (CustomField4 != null ? CustomField4.GetHashCode() : 0);
                return(hashCode);
                // ReSharper restore NonReadonlyMemberInGetHashCode
            }
        }
コード例 #5
0
        public static int Execute(CorrigoService service, int woid)
        {
            var entity = new CustomField2
            {
                Descriptor = new CustomFieldDescriptor {
                    Id = 9
                },
                ObjectId     = woid,
                ObjectTypeId = ActorType.WO,
                Value        = "10"
            };
            var command = new CreateCommand {
                Entity = entity
            };
            var response = service.Execute(command) as OperationCommandResponse;

            var id = response?.EntitySpecifier?.Id ?? 0;

            Debug.Print(response.ErrorInfo?.Description ?? $"Successfully created custom field with id {id}");

            return(id);
        }
コード例 #6
0
        /// <summary>
        /// For creation of new Custom Field is used latest WorkOrder.
        /// By default creation, update, deletion of Custom Fields is disabled.
        /// To enable creation, update, deletion mode for Custom Fields set isCreateUpdateDelete = true.
        /// </summary>
        /// <param name="service"></param>
        /// <param name="isCreateUpdateDelete">by default is false</param>
        public static void CRUDExample(CorrigoService service,
                                       bool isCreateUpdateDelete = false)
        {
            if (service == null)
            {
                return;
            }

            //
            // Get Custom Field Descriptor with properties (Custom Field: JIRA LINK; Domain: Work Order; Data Type : URL)
            //
            CustomFieldDescriptor customFieldDescriptor = GetCustomFieldDescriptor(service, "JIRA LINK", ActorType.WO, CfType.Url);

            if (customFieldDescriptor == null || !(customFieldDescriptor.Id > 0))
            {
                Console.WriteLine("Custom Field Descriptor is undefined");
                return;
            }

            //Get latest WO
            CorrigoEntity[] latestWO = GetLatestWOs(service, 1);
            if (!latestWO.Any())
            {
                Console.WriteLine("No existing Work Order was found");
                return;
            }

            //
            // Retrieve Custom field specified by descriptor for given Work Order.
            //
            CustomField2 cf = Read.Retrieve(service, latestWO[0], customFieldDescriptor);

            if (cf == null && isCreateUpdateDelete)
            {
                //
                // Create Custom field specified by descriptor for given Work Order.
                //
                cf = Create.Execute(service, latestWO[0], customFieldDescriptor);
            }

            if (cf != null && isCreateUpdateDelete)
            {
                cf = Read.Retrieve(service, latestWO[0], customFieldDescriptor);

                //
                // Update Custom field
                //
                Update.Execute(service, cf);

                //
                // Delete Custom Field
                //
                Delete.Execute(service, cf.Id);

                //Update.Restore(service, cf); // CustomField2 is not restorable.
            }

            //
            // Retrive 10 Custom Fields with Data Type : URL
            //
            Read.RetrieveByQuery(service); // retrieve is limited to 10 records
        }