Пример #1
0
        public static Space Execute(CorrigoService service, int id)
        {
            var entitySpecifier = new EntitySpecifier
            {
                EntityType = EntityType.Space,
                Id         = id
            };

            var properies = new PropertySet
            {
                Properties = new[]
                {
                    "CustomerId",
                    "Id",
                    "StatusId",
                    "StartDate",
                    "EndDate",
                    "MoveOutDate",
                    "Instructions",
                    "Asset.*",
                    "Community.*",
                    "Addresses.*",
                }
            };

            var result = service.Retrieve(entitySpecifier, properies);

            return(result as Space);
        }
Пример #2
0
        public static void Execute(CorrigoService service, int woid)
        {
            var specifier = new EntitySpecifier
            {
                EntityType = EntityType.WorkOrder,
                Id         = woid
            };

            string[] properties = { nameof(WorkOrder.Estimate) + ".*" };
            var      workOrder  = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            }) as WorkOrder;

            workOrder.Estimate = null;
            var command = new UpdateCommand
            {
                Entity      = workOrder,
                PropertySet = new PropertySet {
                    Properties = properties
                }
            };

            var response = service.Execute(command) as OperationCommandResponse;

            Debug.Print(response?.ErrorInfo?.Description
                        ?? $"Successfully deleted WoEstimate for WorkOrder with id '{woid}'");
        }
Пример #3
0
        public static void Execute(CorrigoService service, int woid, QuoteStatus newStatus)
        {
            var specifier = new EntitySpecifier
            {
                EntityType = EntityType.WorkOrder,
                Id         = woid
            };

            string[] properties = { nameof(WorkOrder.Estimate) + ".*" };
            var      workOrder  = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            }) as WorkOrder;

            var oldStatus = workOrder.Estimate.StatusId;

            workOrder.Estimate.StatusId = newStatus;

            var command = new UpdateCommand
            {
                Entity      = workOrder,
                PropertySet = new PropertySet {
                    Properties = new[] { "Estimate.StatusId" }
                }
            };

            var response = service.Execute(command) as OperationCommandResponse;

            Debug.Print(response?.ErrorInfo?.Description
                        ?? $"Successfully updated an Estimate from status {oldStatus} to {newStatus}");
        }
Пример #4
0
        public static WorkOrderCost Retrieve(CorrigoService service, int workOrderId)
        {
            Debug.Print($"Retrieving WorkOrderCost object for WorkOrder with id '{workOrderId}': ");

            var specifier = new EntitySpecifier {
                EntityType = EntityType.WorkOrderCost, Id = workOrderId
            };

            string[] properties =
            {
                "CustomerNte",
                "ChargeCode.Id",
                "Items.CostCategoryId",
                "Items.Quantity",
                "Items.Amount"
            };

            var response = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            })
                           as WorkOrderCost;

            Debug.Print(response == null ? "Failure!" : "Success!");

            return(response);
        }
Пример #5
0
        public static Customer Execute(CorrigoService service, int id)
        {
            var entity = new EntitySpecifier
            {
                EntityType = EntityType.Customer,
                Id         = id
            };

            var properties = new[]
            {
                "DisplayAs",
                "Name",
                "Dba",
                "Instructions",
                "TenantCode",
                "TaxExempt",
                "Spaces.*",
                "CustomFields.*",
                "Notes.*",
                "Addresses.*",
                "GroupsBridge.*",
                "Contacts.*",
                "Contract.*",
                "WorkZone.*"
            };

            var response = service.Retrieve(entity, new PropertySet {
                Properties = properties
            });

            return(response as Customer);
        }
Пример #6
0
        public static Location Retrieve(CorrigoService service, int locationId)
        {
            var locationSpecifier = new EntitySpecifier
            {
                EntityType = EntityType.Location,
                Id         = locationId
            };

            string[] properties =
            {
                nameof(Location.Id),
                nameof(Location.Address) + ".*",
                nameof(Location.Info) + ".*",
                nameof(Location.IsTemplate),
                nameof(Location.ModelId),
                nameof(Location.Name),
                nameof(Location.Orphan),
                nameof(Location.ParentId),
                nameof(Location.RootId)
            };

            var response = service.Retrieve(locationSpecifier, new PropertySet {
                Properties = properties
            })
                           as Location;

            return(response);
        }
Пример #7
0
        public static WoPriority Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine($"Retrieve WoPriority with id={id.ToString()}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.WoPriority,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties =
                        new string[]
                    {
                        "Id", "DisplayAs", "IsEmergency", "RespondInMinutes", "DueInMinutes",
                        "AcknowledgeInMinutes"
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!String.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            WoPriority toReturn = result as WoPriority;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            Console.WriteLine(String.Concat("WoPriority.Id=".PadRight(30), toReturn.Id.ToString()));
            Console.WriteLine(String.Concat("WoPriority.DisplayAs=".PadRight(30), String.IsNullOrEmpty(toReturn.DisplayAs) ? "" : toReturn.DisplayAs));
            Console.WriteLine(String.Concat("WoPriority.IsEmergency=".PadRight(30), toReturn.IsEmergency.ToString(), "  //Escalate"));
            Console.WriteLine(String.Concat("WoPriority.RespondInMinutes =".PadRight(30), toReturn.RespondInMinutes.ToString(), "  //Response minutes."));
            Console.WriteLine(String.Concat("WoPriority.DueInMinutes=".PadRight(30), toReturn.DueInMinutes.ToString(), "  //Complete minutes."));
            Console.WriteLine(String.Concat("WoPriority.AcknowledgeInMinutes=".PadRight(30), toReturn.AcknowledgeInMinutes.ToString(), "  //Complete minutes."));
            Console.WriteLine();

            return(toReturn);
        }
Пример #8
0
        public static Contract Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve Contract with id={id}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.Contract,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "Id",
                        "DisplayAs"
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            Contract toReturn = result as Contract;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 35;

            Console.WriteLine(string.Concat("Contract.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("Contract.DisplayAs=".PadRight(padRightNumber), toReturn.DisplayAs ?? ""));

            Console.WriteLine();

            return(toReturn);
        }
Пример #9
0
 /// <summary>
 /// WZ Use Case 2: Retrieving WZ using wz Id
 /// Operation: Retrieve
 /// Gets work zone by id
 ///
 /// Fields to retrieve:
 ///   Work Zone: Id, Number, Name, IsOffline.
 ///
 /// Sort by: Customer Id, Ascending
 /// </summary>
 /// <param name="corrigoService"></param>
 /// <param name="customerName"></param>
 public static WorkZone RetrieveWorkZoneById(CorrigoService corrigoService, int id)
 {
     return(corrigoService.Retrieve(new EntitySpecifier {
         EntityType = EntityType.WorkZone, Id = id
     },
                                    new PropertySet
     {
         Properties = new[] {
             "Id",
             "Number",
             "DisplayAs",
             "IsOffline"
         }
     }) as WorkZone);
 }
Пример #10
0
        public static WoAssignment Retrieve(CorrigoService service, int?id)
        {
            var entitySpecifier = new EntitySpecifier
            {
                EntityType = EntityType.WoAssignment,
                Id         = id
            };

            string[] properties = { "WorkOrderId", "EmployeeId", "IsPrimary" };
            var      response   = service.Retrieve(entitySpecifier, new PropertySet {
                Properties = properties
            })
                                  as WoAssignment;

            return(response);
        }
Пример #11
0
        public static RepairCode Retrieve(CorrigoService service, int id)
        {
            Debug.Print("Retrieving repair code entity:");

            var specifier = new EntitySpecifier {
                EntityType = EntityType.RepairCode, Id = id
            };

            string[] properties = { "Id", "DisplayAs", "ParentId", "IsRemoved", "Codes.*" };
            var      response   = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            })
                                  as RepairCode;

            Debug.Print(response == null ? "Failure!" : "Success!");

            return(response);
        }
Пример #12
0
        public static Actor Retreive(CorrigoService service, int actorId = 11)
        {
            var actorSpecifier = new ActorEntitySpecifier
            {
                EntityType = EntityType.Actor,
                Id         = actorId,
                TypeId     = ActorType.Employee
            };

            string[] properties = { nameof(Actor.TypeId), nameof(Actor.DisplayAs), nameof(Actor.Id) };
            var      actor      = service.Retrieve(actorSpecifier, new PropertySet {
                Properties = properties
            }) as Actor;

            Debug.Print($"Retrieved actor of type {actor.TypeId} with description {actor.DisplayAs}");

            return(actor);
        }
Пример #13
0
        public static int Retreive(CorrigoService service, int woid)
        {
            var entitySpecifier = new EntitySpecifier
            {
                EntityType = EntityType.WorkOrder,
                Id         = woid
            };

            string[] properties = { "LastAction.*", "LastAction.Reason.*" };
            var      workOrder  = service.Retrieve(entitySpecifier, new PropertySet {
                Properties = properties
            })
                                  as WorkOrder;

            WoActionReasonLookup reason = workOrder?.LastAction?.Reason;

            return(reason?.Id ?? 0);
        }
Пример #14
0
        public static int Execute(CorrigoService service, int woid)
        {
            var specifier = new EntitySpecifier
            {
                EntityType = EntityType.WorkOrder,
                Id         = woid
            };

            string[] properties = { nameof(WorkOrder.Estimate) + ".*" };
            var      workOrder  = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            }) as WorkOrder;

            var estimate = new WoEstimate
            {
                Id            = workOrder.Estimate?.Id ?? 0,
                ConcurrencyId = workOrder.Estimate?.ConcurrencyId ?? 0,
                Amount        = new MoneyValue {
                    Value = 10.1m, CurrencyTypeId = CurrencyType.USD
                },
                Comment     = "custom estimate 0",                                      //required
                ContactName = "Con 2 FN",                                               //required
                Reason      = "some custom reason",                                     //required
                StatusId    = QuoteStatus.WaitingForApproval,                           //required
            };

            workOrder.Estimate = estimate;

            var command = new UpdateCommand
            {
                Entity      = workOrder,
                PropertySet = new PropertySet {
                    Properties = properties
                }
            };

            var response   = service.Execute(command) as OperationCommandResponse;
            var estimateId = response?.NestedEntitiesOperationResults?[0]?.EntitySpecifier?.Id ?? 0;

            Debug.Print(response?.ErrorInfo?.Description
                        ?? $"Successfully created an Estimate with id '{estimateId}' for WO with id '{woid}'");

            return(estimateId);
        }
Пример #15
0
        public static WoEstimate Retrieve(CorrigoService service, int estimateId)
        {
            Debug.Print($"Retrieving WoEstimate with id '{estimateId}'");

            var specifier = new EntitySpecifier {
                EntityType = EntityType.WoEstimate, Id = estimateId
            };

            string[] properties =
            {
                "Id",     "ConcurrencyId",
                "Amount", "Comment",      "ContactName","Reason", "StatusId",
            };
            var response = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            })
                           as WoEstimate;

            Debug.Print(response == null ? "Failure!" : "Success!");
            return(response);
        }
Пример #16
0
        public static WoNote Retrieve(CorrigoService service, int noteId)
        {
            var entitySpecifier = new EntitySpecifier {
                EntityType = EntityType.WoNote, Id = noteId
            };

            var propertySet = new PropertySet
            {
                Properties = new[]
                {
                    nameof(WoNote.Id),
                    nameof(WoNote.Body),
                    nameof(WoNote.CreatedDate),
                    //nameof(WoNote.PerformDeletion),
                    nameof(WoNote.NoteTypeId),
                    nameof(WoNote.WorkOrderId),
                    nameof(WoNote.CreatedBy) + ".*"
                }
            };

            var note = service.Retrieve(entitySpecifier, propertySet) as WoNote;

            return(note);
        }
Пример #17
0
        public static WorkOrder Execute(CorrigoService service, int workOrderId)
        {
            var targetProperties = new string[]
            {
                "Id",
                "Number",
                "PoNumber",
                //"StatusId",
                "CompletionNote.Body",
                "Notes.*",
                "RepairCode.*",
                "LastAction.Reason.DisplayAs",
                "LastAction.LastAction.Comment",
                "LastAction.LastAction.Actor.DisplayAs",
                "LastActionDate",
                "CustomFields.Value",
                "CustomFields.Descriptor.Id",
                "CustomFields.Descriptor.Name",

                //"Employee",
                "Employee.ActorTypeId",
                "Items.*"
            };

            var workOrder = (WorkOrder)service.Retrieve(
                new EntitySpecifier
            {
                EntityType = EntityType.WorkOrder,
                Id         = workOrderId
            },
                new PropertySet {
                Properties = targetProperties
            });

            return(workOrder);
        }
Пример #18
0
        public static Task Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve Task with id={id}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.Task,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "Id",
                        "ModelId",
                        "DisplayAs",
                        "Preventive",
                        "Routine",
                        "Corrective",
                        "Default",
                        "Symptom",
                        "CompletionTime",
                        "Specialty.*",
                        "PunchList.*",
                        "Priority.*",
                        "SelfHelpType",
                        "Instructions",
                        "SelfHelpContent",
                        "PeopleRequired",
                        "SkillLevel",
                        "GlAccount",
                        "Number",
                        "Currencies.*"
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            Task toReturn = result as Task;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 35;

            Console.WriteLine(string.Concat("Task.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("Task.ModelId=".PadRight(padRightNumber), toReturn.ModelId.ToString()));

            var model = service.Retrieve(new EntitySpecifier {
                EntityType = EntityType.Model, Id = toReturn.ModelId
            }, new AllProperties()) as Model;

            if (model != null)
            {
                Console.WriteLine(string.Concat("Model.Name= ".PadRight(padRightNumber), $"'{model.DisplayAs}'"));
            }

            Console.WriteLine(string.Concat("Task.DisplayAs=".PadRight(padRightNumber), toReturn.DisplayAs ?? ""));
            Console.WriteLine(string.Concat("Task.Preventive=".PadRight(padRightNumber), toReturn.Preventive.ToString()));
            Console.WriteLine(string.Concat("Task.Routine=".PadRight(padRightNumber), toReturn.Routine.ToString()));
            Console.WriteLine(string.Concat("Task.Corrective=".PadRight(padRightNumber), toReturn.Corrective.ToString()));
            Console.WriteLine(string.Concat("Task.Default=".PadRight(padRightNumber), toReturn.Default.ToString()));
            Console.WriteLine(string.Concat("Task.Symptom=".PadRight(padRightNumber), toReturn.Symptom.ToString()));
            Console.WriteLine(string.Concat("Task.CompletionTime=".PadRight(padRightNumber), toReturn.CompletionTime.ToString()));

            if (toReturn.Specialty != null)
            {
                Console.WriteLine(string.Concat("Task.Specialty.Id=".PadRight(padRightNumber), toReturn.Specialty.Id.ToString()));
                Console.WriteLine(string.Concat("Task.Specialty.DisplayAs=".PadRight(padRightNumber), toReturn.Specialty.DisplayAs ?? ""));
                Console.WriteLine(string.Concat("Task.Specialty.Instructions=".PadRight(padRightNumber), toReturn.Specialty.Instructions));
            }

            if (toReturn.PunchList != null)
            {
                Console.WriteLine(string.Concat("Task.PunchList.Id=".PadRight(padRightNumber), toReturn.PunchList.Id.ToString()));
                Console.WriteLine(string.Concat("Task.PunchList.DisplayAs=".PadRight(padRightNumber), toReturn.PunchList.DisplayAs ?? ""));
            }

            if (toReturn.Priority != null)
            {
                Console.WriteLine(string.Concat("Task.Priority.Id=".PadRight(padRightNumber), toReturn.Priority.Id.ToString()));
                Console.WriteLine(string.Concat("Task.Priority.DisplayAs=".PadRight(padRightNumber), toReturn.Priority.DisplayAs ?? ""));
            }

            if (toReturn.SelfHelpType != null)
            {
                Console.WriteLine(string.Concat("Task.SelfHelpType=".PadRight(padRightNumber), toReturn.SelfHelpType.ToString()));
            }

            Console.WriteLine(string.Concat("Task.Instructions=".PadRight(padRightNumber), toReturn.Instructions ?? ""));
            Console.WriteLine(string.Concat("Task.SelfHelpContent=".PadRight(padRightNumber), toReturn.SelfHelpContent ?? ""));
            Console.WriteLine(string.Concat("Task.PeopleRequired=".PadRight(padRightNumber), toReturn.PeopleRequired.ToString()));
            Console.WriteLine(string.Concat("Task.SkillLevel=".PadRight(padRightNumber), toReturn.SkillLevel.ToString()));

            Console.WriteLine(string.Concat("Task.GlAccount=".PadRight(padRightNumber), toReturn.GlAccount ?? ""));
            Console.WriteLine(string.Concat("Task.Number=".PadRight(padRightNumber), toReturn.Number ?? ""));

            if (toReturn.Currencies != null)
            {
                for (int i = 0; i < toReturn.Currencies.Length; i++)
                {
                    Console.WriteLine(string.Concat($"Task.Currencies[{i}].Nte=".PadRight(padRightNumber), toReturn.Currencies[i].Nte?.ToString() ?? ""));
                }
            }

            Console.WriteLine();

            return(toReturn);
        }
Пример #19
0
        public static Document Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve Document with id={id}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.Document,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "Id",
                        "ActorId",
                        "ActorTypeId",
                        "Description",
                        "Title",
                        "DocType.*",
                        "EndDate",
                        "StartDate",
                        "UpdatedDate",
                        "ExtensionId",
                        "MimeType",
                        "UpdatedBy.*",
                        "WonId",
                        "WonMemberId",
                        "Blob.*",
                        "DocUrl",
                        "IsPublic",
                        "IsShared",
                        "StorageTypeId"
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            Document toReturn = result as Document;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 35;

            Console.WriteLine(string.Concat("Document.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("Document.ActorId=".PadRight(padRightNumber), toReturn.ActorId.ToString()));
            Console.WriteLine(string.Concat("Document.ActorTypeId=".PadRight(padRightNumber), toReturn.ActorTypeId.ToString()));
            Console.WriteLine(string.Concat("Document.Description=".PadRight(padRightNumber), toReturn.Description ?? ""));
            Console.WriteLine(string.Concat("Document.Title=".PadRight(padRightNumber), toReturn.Title ?? ""));

            if (toReturn.DocType != null)
            {
                Console.WriteLine(string.Concat("Document.DocType.DisplayAs=".PadRight(padRightNumber), toReturn.DocType.DisplayAs ?? ""));
                Console.WriteLine(string.Concat("Document.DocType.Description=".PadRight(padRightNumber), toReturn.DocType.Description ?? ""));
            }

            Console.WriteLine(string.Concat("Document.EndDate=".PadRight(padRightNumber), toReturn.EndDate?.ToString() ?? ""));
            Console.WriteLine(string.Concat("Document.StartDate=".PadRight(padRightNumber), toReturn.StartDate.ToString()));
            Console.WriteLine(string.Concat("Document.UpdatedDate=".PadRight(padRightNumber), toReturn.UpdatedDate.ToString()));
            Console.WriteLine(string.Concat("Document.ExtensionId=".PadRight(padRightNumber), toReturn.ExtensionId.ToString()));
            Console.WriteLine(string.Concat("Document.StorageTypeId=".PadRight(padRightNumber), toReturn.StorageTypeId.ToString()));
            Console.WriteLine(string.Concat("Document.MimeType=".PadRight(padRightNumber), toReturn.MimeType.ToString()));


            if (toReturn.UpdatedBy != null)
            {
                Console.WriteLine(string.Concat("Document.UpdatedBy.DisplayAs=".PadRight(padRightNumber), toReturn.UpdatedBy.DisplayAs ?? ""));
                Console.WriteLine(string.Concat("Document.UpdatedBy.Id=".PadRight(padRightNumber), toReturn.UpdatedBy.Id.ToString()));
            }

            Console.WriteLine(string.Concat("Document.WonId=".PadRight(padRightNumber), toReturn.WonId.ToString()));
            Console.WriteLine(string.Concat("Document.WonMemberId=".PadRight(padRightNumber), toReturn.WonMemberId.ToString()));


            if (toReturn.Blob != null)
            {
                Console.WriteLine(string.Concat("Document.Blob.Id=".PadRight(padRightNumber), toReturn.Blob.Id.ToString()));
                Console.WriteLine(string.Concat("Document.Blob.FileName=".PadRight(padRightNumber), toReturn.Blob.FileName ?? ""));
            }

            Console.WriteLine(string.Concat("Document.DocUrl=".PadRight(padRightNumber), toReturn.DocUrl));
            Console.WriteLine(string.Concat("Document.IsPublic=".PadRight(padRightNumber), toReturn.IsPublic));
            Console.WriteLine(string.Concat("Document.IsShared=".PadRight(padRightNumber), toReturn.IsShared));
            Console.WriteLine(string.Concat("Document.StorageTypeId=".PadRight(padRightNumber), toReturn.StorageTypeId));

            Console.WriteLine();

            return(toReturn);
        }
Пример #20
0
        public static Organization Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve Organization with id={id}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.Organization,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "Id",
                        "DisplayAs",
                        "Number",
                        "Address.*",
                        "ContactAddresses.*",
                        "CustomFields.*",
                        "Notes.*",
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            Organization toReturn = result as Organization;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 55;

            Console.WriteLine(string.Concat("Organization.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("Organization.DisplayAs=".PadRight(padRightNumber), toReturn.DisplayAs ?? ""));
            Console.WriteLine(string.Concat("Organization.Number=".PadRight(padRightNumber), toReturn.Number ?? ""));

            if (toReturn.Address != null)
            {
                Console.WriteLine(string.Concat("Organization.Address.City=".PadRight(padRightNumber), toReturn.Address.City ?? ""));
            }


            Console.WriteLine();

            return(toReturn);
        }
Пример #21
0
        public static Contact Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve Contact with id={id}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.Contact,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "Id",
                        "DisplayAs",
                        "FirstName",
                        "LastName",
                        "TypeId",
                        "CustomerId",
                        "CanViewAnyRequest",
                        "CanCreateRequest ",
                        "PriorityThreshold",
                        "CustomFields.*",
                        "ContactAddresses.*",
                        "GroupsBridge.*",
                        "Username",
                        "Number",
                        "MustResetPassword",
                        "NoAlertEmails",
                        "Comment",
                        "Currencies.*",
                        "UnlimitedAuthorization",
                        "UnlimitedRequest"
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            Contact toReturn = result as Contact;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 35;

            Console.WriteLine(string.Concat("Contact.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("Contact.DisplayAs=".PadRight(padRightNumber), toReturn.DisplayAs ?? ""));
            Console.WriteLine(string.Concat("Contact.FirstName=".PadRight(padRightNumber), toReturn.FirstName ?? ""));
            Console.WriteLine(string.Concat("Contact.LastName=".PadRight(padRightNumber), toReturn.LastName ?? ""));
            Console.WriteLine(string.Concat("Contact.TypeId=".PadRight(padRightNumber), toReturn.TypeId.ToString()));
            Console.WriteLine(string.Concat("Contact.CustomerId=".PadRight(padRightNumber), toReturn.CustomerId.ToString()));
            Console.WriteLine(string.Concat("Contact.CanViewAnyRequest=".PadRight(padRightNumber), toReturn.CanViewAnyRequest.ToString()));
            Console.WriteLine(string.Concat("Contact.CanCreateRequest =".PadRight(padRightNumber), toReturn.CanCreateRequest.ToString()));
            Console.WriteLine(string.Concat("Contact.PriorityThreshold=".PadRight(padRightNumber), toReturn.PriorityThreshold.ToString()));

            if (toReturn.CustomFields != null && toReturn.CustomFields.Length > 0)
            {
                for (int i = 0; i < toReturn.CustomFields.Length; i++)
                {
                    Console.WriteLine(string.Concat($"Contact.CustomFields[{i}].Value=".PadRight(padRightNumber), toReturn.CustomFields[i].Value ?? ""));
                }
            }

            if (toReturn.ContactAddresses != null && toReturn.ContactAddresses.Length > 0)
            {
                for (int i = 0; i < toReturn.ContactAddresses.Length; i++)
                {
                    Console.WriteLine(string.Concat($"Contact.ContactAddresses[{i}].Id=".PadRight(padRightNumber), toReturn.ContactAddresses[i].Id.ToString() ?? ""));
                }
            }

            if (toReturn.GroupsBridge != null && toReturn.GroupsBridge.Length > 0)
            {
                for (int i = 0; i < toReturn.GroupsBridge.Length; i++)
                {
                    Console.WriteLine(string.Concat($"Contact.GroupsBridge[{i}].Id=".PadRight(padRightNumber), toReturn.GroupsBridge[i].Id.ToString() ?? ""));
                }
            }

            Console.WriteLine(string.Concat("Contact.Username="******""));
            Console.WriteLine(string.Concat("Contact.Number=".PadRight(padRightNumber), toReturn.Number ?? ""));
            Console.WriteLine(string.Concat("Contact.MustResetPassword="******"Contact.NoAlertEmails=".PadRight(padRightNumber), toReturn.NoAlertEmails.ToString()));
            Console.WriteLine(string.Concat("Contact.Comment=".PadRight(padRightNumber), toReturn.Comment ?? ""));


            if (toReturn.Currencies != null && toReturn.Currencies.Length > 0)
            {
                for (int i = 0; i < toReturn.Currencies.Length; i++)
                {
                    Console.WriteLine(string.Concat($"Contact.Currencies[{i}].AuthorizationLimit=".PadRight(padRightNumber), toReturn.Currencies[i].AuthorizationLimit?.ToString() ?? ""));
                    Console.WriteLine(string.Concat($"Contact.Currencies[{i}].NotificationThreshold=".PadRight(padRightNumber), toReturn.Currencies[i].NotificationThreshold?.ToString() ?? ""));
                    Console.WriteLine(string.Concat($"Contact.Currencies[{i}].RequestLimit=".PadRight(padRightNumber), toReturn.Currencies[i].RequestLimit?.ToString() ?? ""));
                }
            }

            Console.WriteLine(string.Concat("Contact.UnlimitedAuthorization=".PadRight(padRightNumber), toReturn.UnlimitedAuthorization.ToString()));
            Console.WriteLine(string.Concat("Contact.UnlimitedRequest=".PadRight(padRightNumber), toReturn.UnlimitedRequest.ToString()));

            Console.WriteLine();

            return(toReturn);
        }
Пример #22
0
        public static Specialty Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve Specialty with id={id}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.Specialty,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "Id",
                        "DisplayAs",
                        "WONServiceId",
                        "Instructions",
                        "TaxCode.*",
                        "Currencies.*"
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            Specialty toReturn = result as Specialty;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 35;

            Console.WriteLine(string.Concat("Specialty.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("Specialty.DisplayAs=".PadRight(padRightNumber), toReturn.DisplayAs ?? ""));
            Console.WriteLine(string.Concat("Specialty.WONServiceId=".PadRight(padRightNumber), toReturn.WONServiceId.ToString()));
            Console.WriteLine(string.Concat("Specialty.Instructions=".PadRight(padRightNumber), toReturn.Instructions ?? ""));

            if (toReturn.TaxCode != null)
            {
                Console.WriteLine(string.Concat("Specialty.TaxCode.Id=".PadRight(padRightNumber), toReturn.TaxCode.Id.ToString()));
                Console.WriteLine(string.Concat("Specialty.TaxCode.DisplayAs=".PadRight(padRightNumber), toReturn.TaxCode.DisplayAs ?? ""));
            }

            if (toReturn.Currencies != null)
            {
                for (int i = 0; i < toReturn.Currencies.Length; i++)
                {
                    Console.WriteLine(string.Concat($"Specialty.Currencies[{i}].Nte=".PadRight(padRightNumber), toReturn.Currencies[i].Nte?.ToString() ?? ""));
                    Console.WriteLine(string.Concat($"Specialty.Currencies[{i}].AvgCostAll=".PadRight(padRightNumber), toReturn.Currencies[i].AvgCostAll?.ToString() ?? ""));
                    Console.WriteLine(string.Concat($"Specialty.Currencies[{i}].AvgCostTech=".PadRight(padRightNumber), toReturn.Currencies[i].AvgCostTech?.ToString() ?? ""));
                    Console.WriteLine(string.Concat($"Specialty.Currencies[{i}].AvgCostVendor=".PadRight(padRightNumber), toReturn.Currencies[i].AvgCostVendor?.ToString() ?? ""));
                }
            }

            Console.WriteLine();

            return(toReturn);
        }
Пример #23
0
        public static Employee Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine($"Retrieve Employee with id={id.ToString()}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.Employee,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "FirstName",
                        "LastName",
                        "DisplayAs",
                        "Role.*",
                        "AccessToAllWorkZones",
                        "LanguageId",
                        "ActorTypeId",
                        "Username",
                        "DtPwdChange",
                        "ProviderInvitedOn",
                        "Instructions",
                        "WonMemberId",
                        "WonLocationId",
                        "WonServiceRadius",
                        "IsElectronicPayment",
                        "ProviderStatusId",
                        "LabelId",
                        "FreeTextAllowed",
                        "RadiusUnit",
                        "Password",
                        "Number",
                        "JobTitle",
                        "FederalId",
                        "ExternalId",
                        "ForcePasswordReset",
                        "DefaultPriceList.*",
                        "PriceLists.*",
                        "CustomFields.*", "CustomFields.Descriptor.*",
                        "Organization.*",
                        "ContactAddresses.*",
                        "Address.*",
                        "Teams.*",
                        "WorkZones.*",
                        "Portfolios.*",
                        "CustomerGroups.*",
                        "Specialties.*",
                        "PayRates.*",
                        "StockLocations.*",
                        "Services.*",
                        "AlertSubscriptions.*",
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            Employee toReturn = result as Employee;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 45;

            Console.WriteLine(string.Concat("Employee.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("Employee.FirstName=".PadRight(padRightNumber), toReturn.FirstName ?? ""));
            Console.WriteLine(string.Concat("Employee.LastName=".PadRight(padRightNumber), toReturn.LastName ?? ""));
            Console.WriteLine(string.Concat("Employee.DisplayAs=".PadRight(padRightNumber), toReturn.DisplayAs ?? ""));

            if (toReturn.Role != null)
            {
                Console.WriteLine(string.Concat("Employee.Role.Id=".PadRight(padRightNumber), toReturn.Role.Id.ToString()));
                Console.WriteLine(string.Concat("Employee.Role.DisplayAs=".PadRight(padRightNumber), toReturn.Role.DisplayAs ?? ""));
            }

            Console.WriteLine(string.Concat("Employee.AccessToAllWorkZones=".PadRight(padRightNumber), toReturn.AccessToAllWorkZones));
            Console.WriteLine(string.Concat("Employee.LanguageId=".PadRight(padRightNumber), toReturn.LanguageId));
            Console.WriteLine(string.Concat("Employee.ActorTypeId=".PadRight(padRightNumber), toReturn.ActorTypeId));

            Console.WriteLine(string.Concat("Employee.Username="******""));

            Console.WriteLine(string.Concat("Employee.DtPwdChange=".PadRight(padRightNumber), toReturn.DtPwdChange));
            Console.WriteLine(string.Concat("Employee.ProviderInvitedOn=".PadRight(padRightNumber), !toReturn.ProviderInvitedOn.HasValue? "" : toReturn.ProviderInvitedOn.Value.ToString()));

            Console.WriteLine(string.Concat("Employee.DisplayAs=".PadRight(padRightNumber), toReturn.DisplayAs ?? ""));
            Console.WriteLine(string.Concat("Employee.Instructions=".PadRight(padRightNumber), toReturn.Instructions ?? ""));
            Console.WriteLine(string.Concat("Employee.WonMemberId=".PadRight(padRightNumber), toReturn.WonMemberId));
            Console.WriteLine(string.Concat("Employee.WonLocationId=".PadRight(padRightNumber), toReturn.WonLocationId));
            Console.WriteLine(string.Concat("Employee.WonServiceRadius=".PadRight(padRightNumber), toReturn.WonServiceRadius));
            Console.WriteLine(string.Concat("Employee.IsElectronicPayment=".PadRight(padRightNumber), toReturn.IsElectronicPayment));
            Console.WriteLine(string.Concat("Employee.ProviderStatusId=".PadRight(padRightNumber), toReturn.ProviderStatusId));
            Console.WriteLine(string.Concat("Employee.LabelId=".PadRight(padRightNumber), toReturn.LabelId));
            Console.WriteLine(string.Concat("Employee.FreeTextAllowed=".PadRight(padRightNumber), toReturn.FreeTextAllowed));
            Console.WriteLine(string.Concat("Employee.RadiusUnit=".PadRight(padRightNumber), toReturn.RadiusUnit));
            Console.WriteLine(string.Concat("Employee.Password="******""));
            Console.WriteLine(string.Concat("Employee.Number=".PadRight(padRightNumber), toReturn.Number ?? ""));
            Console.WriteLine(string.Concat("Employee.JobTitle=".PadRight(padRightNumber), toReturn.JobTitle ?? ""));
            Console.WriteLine(string.Concat("Employee.FederalId=".PadRight(padRightNumber), toReturn.FederalId ?? ""));
            Console.WriteLine(string.Concat("Employee.ExternalId=".PadRight(padRightNumber), toReturn.ExternalId ?? ""));
            Console.WriteLine(string.Concat("Employee.ForcePasswordReset=".PadRight(padRightNumber), toReturn.ForcePasswordReset));

            if (toReturn.DefaultPriceList != null)
            {
                Console.WriteLine(string.Concat("Employee.DefaultPriceList.Id=".PadRight(padRightNumber), toReturn.DefaultPriceList.Id));
                Console.WriteLine(string.Concat("Employee.DefaultPriceList.DisplayAs=".PadRight(padRightNumber), toReturn.DefaultPriceList.DisplayAs ?? ""));
            }

            int i = 0;

            if (toReturn.PriceLists != null && toReturn.PriceLists.Length > 0)
            {
                foreach (var price in toReturn.PriceLists)
                {
                    Console.WriteLine(string.Concat($"Employee.PriceLists[{i}].Id=".PadRight(padRightNumber), price.Id));
                    i++;
                }
            }

            if (toReturn.CustomFields != null && toReturn.CustomFields.Length > 0)
            {
                i = 0;
                foreach (var customField in toReturn.CustomFields)
                {
                    Console.WriteLine(string.Concat($"Employee.CustomFields[{i}].Id=".PadRight(padRightNumber), customField.Id));
                    if (customField.Descriptor != null)
                    {
                        Console.WriteLine(string.Concat($"Employee.CustomFields[{i}].Descriptor.Name=".PadRight(padRightNumber), customField.Descriptor.Name ?? ""));
                    }
                    Console.WriteLine(string.Concat($"Employee.CustomFields[{i}].Value=".PadRight(padRightNumber), customField.Value ?? ""));
                    i++;
                }
            }

            if (toReturn.Organization != null)
            {
                Console.WriteLine(string.Concat("Employee.Organization.Id=".PadRight(padRightNumber), toReturn.Organization.Id));
                Console.WriteLine(string.Concat("Employee.Organization.DisplayAs=".PadRight(padRightNumber), toReturn.Organization.DisplayAs));
            }

            if (toReturn.ContactAddresses != null && toReturn.ContactAddresses.Length > 0)
            {
                i = 0;
                foreach (var address in toReturn.ContactAddresses)
                {
                    Console.WriteLine(string.Concat($"Employee.ContactAddresses[{i}].Id=".PadRight(padRightNumber), address.Id));
                    i++;
                }
            }

            if (toReturn.Address != null)
            {
                Console.WriteLine(string.Concat("Employee.Address.Id=".PadRight(padRightNumber), toReturn.Address.Id));
                Console.WriteLine(string.Concat("Employee.Address.City=".PadRight(padRightNumber), toReturn.Address.City ?? ""));
                Console.WriteLine(string.Concat("Employee.Address.Street=".PadRight(padRightNumber), toReturn.Address.Street ?? ""));
            }

            if (toReturn.Teams != null && toReturn.Teams.Length > 0)
            {
                i = 0;
                foreach (var team in toReturn.Teams)
                {
                    Console.WriteLine(string.Concat($"Employee.Teams[{i}].TeamId=".PadRight(padRightNumber), team.TeamId));
                    i++;
                }
            }

            if (toReturn.WorkZones != null && toReturn.WorkZones.Length > 0)
            {
                i = 0;
                foreach (var wz in toReturn.WorkZones)
                {
                    Console.WriteLine(string.Concat($"Employee.WorkZones[{i}].WorkZoneId=".PadRight(padRightNumber), wz.WorkZoneId));
                    i++;
                }
            }

            if (toReturn.Portfolios != null && toReturn.Portfolios.Length > 0)
            {
                i = 0;
                foreach (var portfolio in toReturn.Portfolios)
                {
                    Console.WriteLine(string.Concat($"Employee.Portfolios[{i}].PortfolioId=".PadRight(padRightNumber), portfolio.PortfolioId));
                    i++;
                }
            }

            if (toReturn.CustomerGroups != null && toReturn.CustomerGroups.Length > 0)
            {
                i = 0;
                foreach (var cg in toReturn.CustomerGroups)
                {
                    Console.WriteLine(string.Concat($"Employee.CustomerGroups[{i}].CustomerGroupId=".PadRight(padRightNumber), cg.CustomerGroupId));
                    i++;
                }
            }

            if (toReturn.Specialties != null && toReturn.Specialties.Length > 0)
            {
                i = 0;
                foreach (var sp in toReturn.Specialties)
                {
                    Console.WriteLine(string.Concat($"Employee.Specialties[{i}].SpecialtyId=".PadRight(padRightNumber), sp.SpecialtyId));
                    i++;
                }
            }

            if (toReturn.PayRates != null && toReturn.PayRates.Length > 0)
            {
                i = 0;
                foreach (var pr in toReturn.PayRates)
                {
                    Console.WriteLine(string.Concat($"Employee.PayRates[{i}].LaborCodeId=".PadRight(padRightNumber), pr.LaborCodeId));
                    i++;
                }
            }

            if (toReturn.StockLocations != null && toReturn.StockLocations.Length > 0)
            {
                i = 0;
                foreach (var sl in toReturn.StockLocations)
                {
                    Console.WriteLine(string.Concat($"Employee.StockLocations[{i}].StockLocationId=".PadRight(padRightNumber), sl.StockLocationId));
                    i++;
                }
            }

            if (toReturn.Services != null && toReturn.Services.Length > 0)
            {
                i = 0;
                foreach (var srv in toReturn.Services)
                {
                    Console.WriteLine(string.Concat($"Employee.Services[{i}].ServiceId=".PadRight(padRightNumber), srv.ServiceId));
                    i++;
                }
            }

            if (toReturn.AlertSubscriptions != null && toReturn.AlertSubscriptions.Length > 0)
            {
                i = 0;
                foreach (var alertSubcription in toReturn.AlertSubscriptions)
                {
                    Console.WriteLine(string.Concat($"Employee.AlertSubscriptions[{i}].AlertTypeId=".PadRight(padRightNumber), alertSubcription.AlertTypeId));
                    i++;
                }
            }

            Console.WriteLine();

            return(toReturn);
        }
Пример #24
0
        public static Address2 Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve Address2 with id={id}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.Address2,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "Id",
                        "ActorTypeId",
                        "ActorId",
                        "TypeId",
                        "Street",
                        "Street2",
                        "City",
                        "State",
                        "Zip",
                        "Country",
                        "GeoStatusId",
                        "Latitude",
                        "Longitude",
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            Address2 toReturn = result as Address2;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 35;

            Console.WriteLine(string.Concat("Address2.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("Address2.ActorTypeId=".PadRight(padRightNumber), toReturn.ActorTypeId.ToString()));
            Console.WriteLine(string.Concat("Address2.ActorId=".PadRight(padRightNumber), toReturn.ActorId.ToString()));
            Console.WriteLine(string.Concat("Address2.TypeId=".PadRight(padRightNumber), toReturn.TypeId.ToString()));
            Console.WriteLine(string.Concat("Address2.Street=".PadRight(padRightNumber), toReturn.Street ?? ""));
            Console.WriteLine(string.Concat("Address2.Street2=".PadRight(padRightNumber), toReturn.Street2 ?? ""));
            Console.WriteLine(string.Concat("Address2.City=".PadRight(padRightNumber), toReturn.City ?? ""));
            Console.WriteLine(string.Concat("Address2.State=".PadRight(padRightNumber), toReturn.State ?? ""));
            Console.WriteLine(string.Concat("Address2.Zip=".PadRight(padRightNumber), toReturn.Zip ?? ""));
            Console.WriteLine(string.Concat("Address2.Country=".PadRight(padRightNumber), toReturn.Country ?? ""));
            Console.WriteLine(string.Concat("Address2.GeoStatusId=".PadRight(padRightNumber), toReturn.GeoStatusId.ToString()));
            Console.WriteLine(string.Concat("Address2.Latitude=".PadRight(padRightNumber), toReturn.Latitude.ToString()));
            Console.WriteLine(string.Concat("Address2.Longitude=".PadRight(padRightNumber), toReturn.Longitude.ToString()));

            Console.WriteLine();

            return(toReturn);
        }
Пример #25
0
        private static WorkOrder CreateWorkOrder(CorrigoService service)
        {
            var workZone = (WorkZone)service.Retrieve(
                new EntitySpecifier {
                Id = 28, EntityType = EntityType.WorkZone
            },
                new PropertySet {
                Properties = new[] { "Id", "TimeZone" }
            });

            var workOrder = new WorkOrder
            {
                Items = new[]
                {
                    new WoItem
                    {
                        Asset = new Location {
                            Id = 173
                        },
                        Task = new Task {
                            Id = 14096
                        }
                    }
                },
                Customer = new Customer {
                    Id = 14
                },
                WorkZone = workZone,
                TimeZone = workZone.TimeZone,

                //WorkOrderCost = workOrderCost,

                Priority = new WoPriority {
                    Id = 2
                },
                MainAsset = new Location {
                    Id = 173
                },
                SubType = new WorkOrderType {
                    Id = 4
                },
                StatusId       = WorkOrderStatus.New,
                ContactName    = "Somerset Moehm",
                ContactAddress = new ContactInfo
                {
                    Address     = "San Francisco",
                    ActorTypeId = ActorType.Asset,
                    AddrTypeId  = ContactAddrType.Contact
                },
                TypeCategory = WOType.Request,                 //required
            };

            var command = new WoCreateCommand
            {
                WorkOrder         = workOrder,
                Comment           = string.Empty,
                ComputeAssignment = true,
                ComputeSchedule   = false,
                SkipBillToLogic   = false
            };

            var response = service.Execute(command) as WoActionResponse;

            return(response?.Wo);
        }
Пример #26
0
        /// <summary>
        /// Create Location
        /// </summary>
        /// <param name="corrigoService"></param>
        /// <returns></returns>
        public static Location CreateLocation(CorrigoService corrigoService)
        {
            #region Get Ids for Location required fields: Model, WorkZoneAsset Id

            //
            // Retrieve Asset Id
            //
            int workZoneAssetId = (corrigoService.RetrieveMultiple(
                                       new QueryByProperty
            {
                Count = 1,
                EntityType = EntityType.WorkZone,
                PropertySet = new PropertySet
                {
                    Properties = new string[]
                    {
                        "Asset.Id",
                    }
                },
                Orders = new[]
                {
                    new OrderExpression
                    {
                        OrderType = OrderType.Descending,
                        PropertyName = "Id"
                    }
                },
                //Conditions = new PropertyValuePair[0]
            }).FirstOrDefault() as WorkZone)?.Asset.Id ?? 0;

            if (workZoneAssetId == 0)
            {
                return(null);
            }

            int modelId = corrigoService.RetrieveMultiple(
                new QueryExpression
            {
                EntityType = EntityType.Model,
                Orders     = new[]
                {
                    new OrderExpression
                    {
                        OrderType    = OrderType.Descending,
                        PropertyName = "Id"
                    }
                },
                Count = 1
            }).FirstOrDefault()?.Id ?? 0;


            if (modelId == 0)
            {
                return(null);
            }

            #endregion

            var asset = new Location
            {
                Name    = $"Test location {DateTime.Now}",
                Address = new Address2 {
                    TypeId = StreetAddrType.Primary, Street = $"Test Street {DateTime.Now}"
                },
                ModelId    = modelId,
                Orphan     = true,
                TypeId     = AssetType.Building,
                ParentId   = workZoneAssetId,
                IsTemplate = false
            };
            var command = new CreateCommand {
                Entity = asset
            };
            var response = corrigoService.Execute(command) as OperationCommandResponse;

            var id = response?.EntitySpecifier.Id ?? 0;
            Console.WriteLine(response?.ErrorInfo?.Description ?? $"Successfully created Location with id {id}");

            //Console.ReadKey();

            var location = corrigoService.Retrieve(
                new EntitySpecifier
            {
                EntityType = EntityType.Location,
                Id         = id
            },
                new PropertySet
            {
                Properties = new string[]
                {
                    "*",
                    "Address.*",
                }
            }) as Location;

            return(location);
        }
Пример #27
0
        public static WorkZone Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve WorkZone with id={id}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.WorkZone,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "Id",
                        "DisplayAs",
                        "TimeZone",
                        "AccessOptionsMask",
                        "AdvanceNotice",
                        "Asset.*",
                        "AutoAssignEnabled",
                        "BackupRoutingId",
                        "BillingAccount.*",
                        "BizHours.*",
                        "ContactAddresses.*",
                        "Contract.*",
                        "CpThemeId",
                        "CurrencyTypeId",
                        "CustomFields.*",
                        "DefaultAccess",
                        "Entity",
                        "EscalationRules.*",
                        "IsOffline",
                        "LanguageId",
                        "NoIncompleteItem",
                        "NoIncompletePunchList",
                        "Number",
                        "OnCallRules.*",
                        "Portfolios.*",
                        "Responsibilities.*",
                        "RoundApptTimeTo",
                        "SchedulingWindow",
                        "SpecDispatchRules.*",
                        "TaxRegion.*",
                        "Teams.*",
                        "UiShowProvidersFirst",
                        "UseBizHours",
                        "UseEscalation",
                        "UseHolidays",
                        "UseOnCall",
                        "WoNumberDigits",
                        "WoNumberPrefix",
                        "WorkPlanAutoCancel",
                        "WorkPlanAutoDependency",
                        "WorkPlanChildResolution",
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            WorkZone toReturn = result as WorkZone;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 35;

            Console.WriteLine(string.Concat("WorkZone.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("WorkZone.DisplayAs=".PadRight(padRightNumber), toReturn.DisplayAs ?? ""));
            Console.WriteLine(string.Concat("WorkZone.Asset.Id=".PadRight(padRightNumber), toReturn.Asset?.Id.ToString() ?? ""));
            Console.WriteLine(string.Concat("WorkZone.TimeZone=".PadRight(padRightNumber), toReturn.TimeZone.ToString()));



            Console.WriteLine(string.Concat("WorkZone.Number=".PadRight(padRightNumber), toReturn.Number ?? ""));


            if (toReturn.Contract != null)
            {
                Console.WriteLine(string.Concat("WorkZone.Contract.Id=".PadRight(padRightNumber),
                                                toReturn.Contract.Id.ToString()));
                Console.WriteLine(string.Concat("WorkZone.Contract.DisplayAs=".PadRight(padRightNumber),
                                                toReturn.Contract.DisplayAs));
            }

            if (toReturn.TaxRegion != null)
            {
                Console.WriteLine(string.Concat("WorkZone.TaxRegion.Id=".PadRight(padRightNumber),
                                                toReturn.TaxRegion.Id.ToString()));
                Console.WriteLine(string.Concat("WorkZone.TaxRegion.DisplayAs=".PadRight(padRightNumber),
                                                toReturn.TaxRegion.DisplayAs));
            }

            Console.WriteLine();

            return(toReturn);
        }
Пример #28
0
        public static WorkOrder Execute(CorrigoService service, bool computeAssignment, bool computeSchedule)
        {
            //WorkOrder requires WorkZone for its creation
            //default time zone is UTC-12, therefore provide WorkOrder with time zone from WorkZone

            var workZone = (WorkZone)service.Retrieve(
                new EntitySpecifier {
                Id = WorkZoneId, EntityType = EntityType.WorkZone
            },
                new PropertySet {
                Properties = new[] { "Id", "TimeZone" }
            });

            var workOrder = new WorkOrder
            {
                Items = new[]                   //required
                {
                    new WoItem
                    {
                        Asset = new Location {
                            Id = SpaceUnitSubAssetId
                        },                                                                              //required
                        Task = new Task {
                            Id = TaskId
                        }                                                                                               //required
                    }
                },
                Customer = new Customer {
                    Id = CustomerId
                },                                                          //required
                //WorkZone = workZone,
                //TimeZone = workZone.TimeZone,

                //Priority = new WoPriority { Id = 1 },
                //MainAsset = new Location { Id = SpaceUnitAssetId },
                SubType = new WorkOrderType {
                    Id = SubTypeId
                },                                                             //required
                //StatusId = WorkOrderStatus.New,
                //ContactName = "John Smith",
                ContactAddress = new ContactInfo                  //required for request at least
                {
                    Address = "San Francisco",                    //required
                    //ActorTypeId = ActorType.Asset,
                    AddrTypeId = ContactAddrType.Contact          //required
                },
                TypeCategory = WOType.Request,                    //required

                //CreatedDateUtc = DateTime.UtcNow,
                //DueDateUtc = DateTime.UtcNow,
                //DtUtcOnSiteBy = DateTime.UtcNow,
                //DtScheduledStart = DateTime.UtcNow,
                //ScheduledStartUtc = DateTime.UtcNow,
            };

            var command = new WoCreateCommand
            {
                WorkOrder         = workOrder,
                Comment           = string.Empty,
                ComputeAssignment = computeAssignment,
                ComputeSchedule   = computeSchedule,
                SkipBillToLogic   = false
            };

            var response = service.Execute(command) as WoActionResponse;

            if (response.ErrorInfo != null)
            {
                Debug.Print(response.ErrorInfo.Description);
            }
            return(response?.Wo);
        }
Пример #29
0
        public static BillingAccount Retrieve(CorrigoService service, int id)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve BillingAccount with id={id}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new EntitySpecifier
                {
                    EntityType = EntityType.BillingAccount,
                    Id         = id
                },
                    new PropertySet
                {
                    Properties = new string[]
                    {
                        "Id",
                        "DisplayAs",
                        "PortalImageSetId",
                        "CpThemeId",
                        "IsBillAcct",
                        "Number",
                        "PayTerms",
                        "PayDays",
                        "PayInstr",
                        "IsCreditHold",
                        "AccrualMargin",
                        "SalesRep",
                        "IsTaxExempt",
                        "CorporateEntity.*",
                        "Address.*",
                        "IsInactive",
                        "PayDayWeekday",
                        "PayDayNumber",
                        "BillingContact.*"
                    }
                }
                    //new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            BillingAccount toReturn = result as BillingAccount;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 35;

            Console.WriteLine(string.Concat("BillingAccount.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("BillingAccount.DisplayAs=".PadRight(padRightNumber), toReturn.DisplayAs ?? ""));
            Console.WriteLine(string.Concat("BillingAccount.PortalImageSetId=".PadRight(padRightNumber), !toReturn.PortalImageSetId.HasValue ? "" : toReturn.PortalImageSetId.ToString()));

            Console.WriteLine(string.Concat("BillingAccount.CpThemeId=".PadRight(padRightNumber), !toReturn.CpThemeId.HasValue ? "" : toReturn.CpThemeId.ToString()));

            Console.WriteLine(string.Concat("BillingAccount.IsBillAcct=".PadRight(padRightNumber), toReturn.IsBillAcct));
            Console.WriteLine(string.Concat("BillingAccount.Number=".PadRight(padRightNumber), toReturn.Number ?? ""));

            Console.WriteLine(string.Concat("BillingAccount.PayTerms=".PadRight(padRightNumber), toReturn.PayTerms ?? ""));
            Console.WriteLine(string.Concat("BillingAccount.PayDays=".PadRight(padRightNumber), toReturn.PayDays));

            Console.WriteLine(string.Concat("BillingAccount.PayInstr=".PadRight(padRightNumber), toReturn.PayInstr ?? ""));

            Console.WriteLine(string.Concat("BillingAccount.IsCreditHold=".PadRight(padRightNumber), toReturn.IsCreditHold));
            Console.WriteLine(string.Concat("BillingAccount.AccrualMargin= ".PadRight(padRightNumber), toReturn.AccrualMargin));
            Console.WriteLine(string.Concat("BillingAccount.SalesRep= ".PadRight(padRightNumber), toReturn.SalesRep ?? ""));
            Console.WriteLine(string.Concat("BillingAccount.IsTaxExempt=".PadRight(padRightNumber), toReturn.IsTaxExempt));


            if (toReturn.CorporateEntity != null)
            {
                Console.WriteLine(string.Concat("BillingAccount.CorporateEntity.Id=".PadRight(padRightNumber), toReturn.CorporateEntity.Id.ToString()));
                Console.WriteLine(string.Concat("BillingAccount.CorporateEntity.DisplayAs=".PadRight(padRightNumber), toReturn.CorporateEntity.DisplayAs ?? ""));
            }

            if (toReturn.Address != null)
            {
                Console.WriteLine(string.Concat("BillingAccount.Address.Id=".PadRight(padRightNumber), toReturn.Address.Id.ToString()));
                Console.WriteLine(string.Concat("BillingAccount.Address.Country=".PadRight(padRightNumber), toReturn.Address.Country ?? ""));
                Console.WriteLine(string.Concat("BillingAccount.Address.State=".PadRight(padRightNumber), toReturn.Address.State ?? ""));
                Console.WriteLine(string.Concat("BillingAccount.Address.City=".PadRight(padRightNumber), toReturn.Address.City ?? ""));
                Console.WriteLine(string.Concat("BillingAccount.Address.Street=".PadRight(padRightNumber), toReturn.Address.Street ?? ""));
            }

            Console.WriteLine(string.Concat("BillingAccount.IsInactive=".PadRight(padRightNumber), toReturn.IsInactive));
            Console.WriteLine(string.Concat("BillingAccount.PayDayWeekday=".PadRight(padRightNumber), toReturn.PayDayWeekday));
            Console.WriteLine(string.Concat("BillingAccount.PayDayNumber=".PadRight(padRightNumber), toReturn.PayDayNumber));

            if (toReturn.BillingContact != null)
            {
                Console.WriteLine(string.Concat("BillingAccount.BillingContact.Id=".PadRight(padRightNumber), toReturn.BillingContact.Id.ToString()));
                Console.WriteLine(string.Concat("BillingAccount.BillingContact.DisplayAs=".PadRight(padRightNumber), toReturn.BillingContact.DisplayAs ?? ""));
            }

            Console.WriteLine();

            return(toReturn);
        }
Пример #30
0
        public static AssetTree Retrieve(CorrigoService service, int childId, int parentId)
        {
            Console.WriteLine();
            Console.WriteLine($"Retrieve AssetTree with ChildId={childId} ParentId={parentId}");
            CorrigoEntity result = null;

            try
            {
                result = service.Retrieve(
                    new AssetTreeEntitySpecifier
                {
                    ChildId  = childId,
                    ParentId = parentId
                },
                    //new PropertySet
                    //{
                    //    Properties = new string[]
                    //    {
                    //        "Id",
                    //        "ParentId",
                    //        "ChildId",
                    //        "Child.*",
                    //        //"Child.Address.*",
                    //        "Distance"
                    //    }
                    //}
                    new AllProperties()
                    );
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(e.Message))
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (result == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            AssetTree toReturn = result as AssetTree;

            if (toReturn == null)
            {
                Console.WriteLine("Retrieve failed");
                return(null);
            }

            int padRightNumber = 55;

            Console.WriteLine(string.Concat("AssetTree.Id=".PadRight(padRightNumber), toReturn.Id.ToString()));
            Console.WriteLine(string.Concat("AssetTree.ParentId=".PadRight(padRightNumber), toReturn.ParentId.ToString()));

            if (toReturn.Child != null)
            {
                Console.WriteLine(string.Concat("AssetTree.Child.Name=".PadRight(padRightNumber), toReturn.Child.Name ?? ""));

                if (toReturn.Child.Address != null)
                {
                    Console.WriteLine(string.Concat("AssetTree.Child.Address.Country=".PadRight(padRightNumber), toReturn.Child.Address.Country ?? ""));
                    Console.WriteLine(string.Concat("AssetTree.Child.Address.City=".PadRight(padRightNumber), toReturn.Child.Address.City ?? ""));
                    Console.WriteLine(string.Concat("AssetTree.Child.Address.Street=".PadRight(padRightNumber), toReturn.Child.Address.Street ?? ""));
                }
            }

            Console.WriteLine();

            return(toReturn);
        }