Beispiel #1
0
        public async Task <Entity> CreateAsync(Entity entity)
        {
            var createRequest  = new createRequest(_autotaskIntegrations, new[] { entity });
            var createResponse = await _autoTaskClient.createAsync(createRequest).ConfigureAwait(false);

            var errorCount = createResponse.createResult.Errors.Length;

            if (errorCount > 0)
            {
                _logger.LogError($"There was an error creating the entity. {errorCount} errors occurred.");
                for (var errorNum = 0; errorNum < errorCount; errorNum++)
                {
                    _logger.LogError($"Error {errorNum + 1}: {createResponse.createResult.Errors[errorNum].Message}");
                }
                _logger.LogError("Entity: " + JsonConvert.SerializeObject(entity));
                var message = $"Errors occurred during creation of the AutoTask entity: {string.Join(";", createResponse.createResult.Errors.Select(e => e.Message))}";
                throw new AutoTaskApiException(BuildExceptionMessage(message));
            }

            var createdEntity = createResponse?.createResult?.EntityResults?.FirstOrDefault();

            _logger.LogDebug($"Successfully created entity with Id: {createdEntity?.id.ToString() ?? "UNKNOWN!"}");
            if (createdEntity == null)
            {
                throw new AutoTaskApiException(BuildExceptionMessage("Did not get a result back after creating the AutoTask entity."));
            }
            return(createdEntity);
        }
 /// <summary>
 /// 创建微会员二维码
 /// </summary>
 /// <param name="orgId">微会员ID</param>
 /// <returns>ErrType</returns>
 public ErrType CreateOrgTicket(string orgId)
 {
     try
     {
         createRequest request = new createRequest(orgId);
         createResponse response = OrgTicketService.create(request);
         var ret = response.createReturn;
         if (ret.ToString() == "true")
             return GeneralErr.Success;
         else
             return GeneralErr.Error;
     }
     catch (Exception e)
     {
         return GeneralErr.Error;
     }
 } 
Beispiel #3
0
        static string CreateRequest()
        {
            Console.WriteLine("\nIn CreateRequest");

            //Convert request bean to the client stub
            Request request = new Request();

            request.requestType = "Bug";

            //Set Required Fields
            SimpleField[] fields = new SimpleField[6];
            //Description
            fields[0]             = new SimpleField();
            fields[0].token       = "REQ.DESCRIPTION";
            fields[0].stringValue = new String[] { "WebService Test" };

            //Department
            fields[1]             = new SimpleField();
            fields[1].token       = "REQ.DEPARTMENT_NAME";
            fields[1].stringValue = new String[] { "Finance" };

            //Module
            fields[2]             = new SimpleField();
            fields[2].token       = "REQD.VP.MODULE";
            fields[2].stringValue = new String[] { "Module A" };

            //Platform
            fields[3]             = new SimpleField();
            fields[3].token       = "REQD.VP.PLATFORM";
            fields[3].stringValue = new String[] { "Unix" };

            //Impact
            fields[4]             = new SimpleField();
            fields[4].token       = "REQD.VP.IMPACT";
            fields[4].stringValue = new String[] { "Warning" };

            //Reproducible
            fields[5]             = new SimpleField();
            fields[5].token       = "REQD.VP.REPRO";
            fields[5].stringValue = new String[] { "Y" };

            //Add fields to request
            request.simpleFields = fields;

            //Set Notes
            Note[] notes = new Note[1];
            notes[0]              = new Note();
            notes[0].author       = "admin";
            notes[0].content      = "WebService Test Note";
            notes[0].creationDate = DateTime.Now;

            //Add notes to request
            request.notes = notes;

            //Call Webservice
            createRequest cr = new createRequest();

            cr.requestObj = request;
            createRequestResponse response = serviceProxy.createRequest(cr);

            Console.WriteLine("createRequest Succeeded");
            Console.WriteLine("Request: " + [email protected] + " Status: " + [email protected]);
            return([email protected]);
        }