// WoActionLog is Readonly - NonCreatable, NonDeletable, NonUpdatable public static void Execute(CorrigoService service, WoActionLog toUpdate) { if (toUpdate == null || service == null) { return; } toUpdate.Comment = (toUpdate.Comment ?? "") + "."; Console.WriteLine(); Console.WriteLine($"Updating WoActionLog with id={toUpdate.Id.ToString()}"); var resultUpdate = service.Execute(new UpdateCommand { Entity = toUpdate, PropertySet = new PropertySet { Properties = new[] { "Comment" } } }); if (resultUpdate == null) { Console.WriteLine("Update of WoActionLog failed"); return; } if (resultUpdate.ErrorInfo != null && !string.IsNullOrEmpty(resultUpdate.ErrorInfo.Description)) { Console.WriteLine(resultUpdate.ErrorInfo.Description); Console.WriteLine("Update of WoActionLog failed"); return; } Console.WriteLine("WoActionLog is updated"); }
public static void Restore(CorrigoService service, WoActionLog toRestore) { if (toRestore == null || service == null) { return; } Console.WriteLine(); Console.WriteLine($"Restoring WoActionLog with id={toRestore.Id}"); var restoreResult = service.Execute(new RestoreCommand { EntitySpecifier = new EntitySpecifier { Id = toRestore.Id, EntityType = EntityType.WoActionLog } }); if (restoreResult == null) { Console.WriteLine("Update of WoActionLog failed"); return; } if (restoreResult.ErrorInfo != null && !string.IsNullOrEmpty(restoreResult.ErrorInfo.Description)) { Console.WriteLine(restoreResult.ErrorInfo.Description); Console.WriteLine("Restore of WoActionLog failed"); return; } Console.WriteLine("WoActionLog is restored"); }
// WoActionLog is Readonly - NonCreatable, NonDeletable, NonUpdatable public static WoActionLog Execute(CorrigoService service) { Console.WriteLine(); Debug.Print("Creating WoActionLog"); Console.WriteLine("Creating WoActionLog"); var toCreate = new WoActionLog { Comment = "Test" + $".ByWSDK.{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}", }; var resultData = service.Execute(new CreateCommand { Entity = toCreate }); if (resultData == null) { Debug.Print("Creation of new WoActionLog failed"); Console.WriteLine("Creation of new WoActionLog failed"); Console.WriteLine(); return(null); } var commandResponse = resultData as OperationCommandResponse; int?id = (commandResponse != null && commandResponse.EntitySpecifier != null) ? commandResponse.EntitySpecifier.Id : null; if (id.HasValue && resultData.ErrorInfo == null) { toCreate.Id = id.Value; Debug.Print($"Created new WoActionLog with Id={id.ToString()}"); Console.WriteLine($"Created new WoActionLog with Id={id.ToString()}"); Console.WriteLine(); return(toCreate); } Debug.Print("Creation of new WoActionLog failed"); Console.WriteLine("Creation of new WoActionLog failed"); Console.WriteLine(); if (resultData.ErrorInfo != null && !string.IsNullOrEmpty(resultData.ErrorInfo.Description)) { Debug.Print(resultData.ErrorInfo.Description); Console.WriteLine(resultData.ErrorInfo.Description); } return(null); }
public static void CRUDExample(CorrigoService service) { if (service == null) { return; } Console.WriteLine("WoActionLog is Readonly - NonCreatable, NonDeletable, NonUpdatable"); WoActionLog woal = Create.Execute(service); CorrigoEntity[] latestWOs = GetLatestWOs(service, 15); if (latestWOs == null || latestWOs.Length == 0) { return; } CorrigoEntity[] actionLogs = Read.RetrieveByQuery(service, latestWOs); if (actionLogs != null && actionLogs.Length > 0) { int actionLogIdWithProperty = GetWoActionLogIdWithProperty(service); WoActionLog actionLog = Read.Retrieve(service, (actionLogIdWithProperty > 0)? actionLogIdWithProperty : actionLogs[0].Id); if (actionLog == null) { return; } Delete.Execute(service, actionLog.Id); // WoActionLog is Readonly - NonCreatable, NonDeletable, NonUpdatable Update.Restore(service, actionLog); // WoActionLog is Readonly - NonCreatable, NonDeletable, NonUpdatable Update.Execute(service, actionLog); // WoActionLog is Readonly - NonCreatable, NonDeletable, NonUpdatable } }
public static WoActionLog Retrieve(CorrigoService service, int id) { Console.WriteLine(); Console.WriteLine($"Retrieve WoActionLog with id={id}"); CorrigoEntity result = null; try { result = service.Retrieve( new EntitySpecifier { EntityType = EntityType.WoActionLog, Id = id }, new PropertySet { Properties = new string[] { "Id", "WorkOrderId", "TypeId", "Actor.*", "ActionDate", "Comment", "ActionReasonId", "UiTypeId", "TimeZone", "SystemDateUtc", "ObjectId", "Properties.*" } } //new AllProperties() ); } catch (Exception e) { if (!string.IsNullOrEmpty(e.Message)) { Console.WriteLine(e.Message); } } if (result == null) { Console.WriteLine("Retrieve failed"); return(null); } WoActionLog toReturn = result as WoActionLog; if (toReturn == null) { Console.WriteLine("Retrieve failed"); return(null); } int padRightNumber = 45; Console.WriteLine(string.Concat("WoActionLog.Id=".PadRight(padRightNumber), toReturn.Id.ToString())); Console.WriteLine(string.Concat("WoActionLog.WorkOrderId=".PadRight(padRightNumber), toReturn.WorkOrderId.ToString())); var wo = service.Retrieve(new EntitySpecifier { EntityType = EntityType.WorkOrder, Id = toReturn.WorkOrderId }, new AllProperties()) as WorkOrder; if (wo != null) { Console.WriteLine(string.Concat("WorkOrder.Number= ".PadRight(padRightNumber), $"'{wo.Number}'")); } Console.WriteLine(string.Concat("WoActionLog.TypeId=".PadRight(padRightNumber), toReturn.TypeId.ToString())); if (toReturn.Actor != null) { Console.WriteLine(string.Concat("WoActionLog.Actor.Id=".PadRight(padRightNumber), toReturn.Actor.Id.ToString())); Console.WriteLine(string.Concat("WoActionLog.Actor.DisplayAs=".PadRight(padRightNumber), toReturn.Actor.DisplayAs ?? "")); Console.WriteLine(string.Concat("WoActionLog.Actor.TypeId=".PadRight(padRightNumber), toReturn.Actor.TypeId.ToString())); } Console.WriteLine(string.Concat("WoActionLog.ActionDate=".PadRight(padRightNumber), toReturn.ActionDate.ToString())); Console.WriteLine(string.Concat("WoActionLog.Comment=".PadRight(padRightNumber), toReturn.Comment ?? "")); Console.WriteLine(string.Concat("WoActionLog.ActionReasonId=".PadRight(padRightNumber), toReturn.ActionReasonId.ToString())); Console.WriteLine(string.Concat("WoActionLog.UiTypeId=".PadRight(padRightNumber), toReturn.UiTypeId.ToString())); Console.WriteLine(string.Concat("WoActionLog.TimeZone=".PadRight(padRightNumber), toReturn.TimeZone.ToString())); Console.WriteLine(string.Concat("WoActionLog.SystemDateUtc=".PadRight(padRightNumber), toReturn.SystemDateUtc.ToString())); Console.WriteLine(string.Concat("WoActionLog.ObjectId=".PadRight(padRightNumber), toReturn.ObjectId.ToString())); int i = 0; if (toReturn.Properties != null && toReturn.Properties.Length > 0) { foreach (var property in toReturn.Properties) { Console.WriteLine(string.Concat($"WoActionLog.Properties[{i}].Id=".PadRight(padRightNumber), property.Id)); Console.WriteLine(string.Concat($"WoActionLog.Properties[{i}].TypeId=".PadRight(padRightNumber), property.TypeId)); Console.WriteLine(string.Concat($"WoActionLog.Properties[{i}].ValueStr=".PadRight(padRightNumber), property.ValueStr ?? "")); Console.WriteLine(string.Concat($"WoActionLog.Properties[{i}].ValueInt=".PadRight(padRightNumber), property.ValueInt)); i++; } } Console.WriteLine(); return(toReturn); }