I'm currently working on a POC MDS/MDM WCF service and have a question regarding validation. Does anyone have an example of calling the MDS web api to kick of validating the MDS model? I know i have to add a service reference to MDS in order to gain access to the proxies, i was just hoping for a simple example of using the api.
https://msdn.microsoft.com/en-us/library/microsoft.masterdataservices.serviceclient.validationprocess(v=sql.110).aspx
//ValidationProcess For an entity
public Collection<ValidationIssue> ValidationProcess(string ModelName, string verName, string EntityName, string memCode)
{
//Instantiate all of request and response objects
ValidationProcessRequest Request = new ValidationProcessRequest();
ValidationProcessResponse Response = new ValidationProcessResponse();
//Instantiate the Criteria and Options objects
Request.ValidationProcessCriteria = new ValidationProcessCriteria();
Request.ValidationProcessOptions = new ValidationProcessOptions();
//Set Model and Version Identifiers - these will be required in all instances
Request.ValidationProcessCriteria.ModelId = new Identifier { Name = ModelName };
Request.ValidationProcessCriteria.VersionId = new Identifier { Name = verName };
Request.ValidationProcessCriteria.EntityId = new Identifier { Name = EntityName };
Request.ValidationProcessCriteria.Members = new Collection<MemberIdentifier>();
Request.ValidationProcessCriteria.Members.Add(new MemberIdentifier { Code = memCode });
//Options can return validation results or trigger the commit of a version (when validation is already successful)
Request.ValidationProcessOptions.ReturnValidationResults = true;
Response = mds_Proxy.ValidationProcess(Request);
return Response.ValidationIssueList;
}
Related
I'm trying to apply a template (not use a template) using the .NET SDK and I can't seem to get it. I have seen one or two other articles on here but neither is using the SDK. Can anyone help me solve this using the SDK?
My situation is this: I have a template defined that contains all of my anchor tags with placement info. When I apply the template via the UI, it works fine and the tags get placed appropriately. When I upload the same document via the API, the tags are not applied.
I have tried to replicate what is shown in these articles using Composite Templates with no success:
How do I apply a server template to envelope document in DocuSign API?
Docusign API - Create envelope, apply template, prefill values
In one of the articles, the OP said the envelope needed to be a Draft. I tried that, but then I haven't been able to change it to "sent" after that.
Here's some of the relevant code from my ASP.NET Web Forms test project. In this project, I'm using a asp:FileUpload control to grab the file contents and then I call the SendFileToDocusign() method:
private void SendFileToDocusign(byte[] fileData, string accessToken)
{
//Create a signer recipient to sign the document, identified by name and email
//We set the clientUserId to enable embedded signing for the recipient
Signer tmpSigner1 = new Signer {
Email = "me#me.com", Name = "Test Tester",
ClientUserId = "1000", RecipientId = "1", RoleName = "Signer1", CustomFields = new List<string> { "Buyer1" }
};
//Step 1. Create the envelope definition
EnvelopeDefinition tmpEnvDef = MakeEnvelopeAndApplyTemplate(fileData, new List<Signer> { tmpSigner1 });
//Step 2. Call DocuSign to create the envelope
ApiClient tmpClient = new ApiClient(DOCUSIGN_API_BASEPATH);
tmpClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken);
EnvelopesApi tmpEnvelopesApi = new EnvelopesApi(tmpClient);
EnvelopeSummary tmpResults = tmpEnvelopesApi.CreateEnvelope(DOCUSIGN_ACCOUNTID, tmpEnvDef);
string tmpEnvelopeID = tmpResults.EnvelopeId;
//Step 3. create the recipient view, the Signing Ceremony
RecipientViewRequest tmpViewRequest = MakeRecipientViewRequest(tmpSigner1);
//call the CreateRecipientView API
ViewUrl tmpRecipView = tmpEnvelopesApi.CreateRecipientView(DOCUSIGN_ACCOUNTID, tmpEnvelopeID, tmpViewRequest);
Response.Redirect(tmpRecipView.Url);
}
private EnvelopeDefinition MakeEnvelopeAndApplyTemplate(byte[] fileData, List<Signer> signers)
{
EnvelopeDefinition tmpEnv = new EnvelopeDefinition(EmailSubject:"We don't really use the Subject Line here");
Document tmpDoc = new Document();
Recipients tmpRecipients = new Recipients(Signers:signers);
CompositeTemplate tmpCompTemplate = new CompositeTemplate("1");
string tmpfileDataB64 = Convert.ToBase64String(fileData);
tmpDoc.DocumentBase64 = tmpfileDataB64;
tmpDoc.Name = "Test file";//can be different from actual file name
tmpDoc.FileExtension = "pdf";
tmpDoc.DocumentId = "1";
InlineTemplate tmpInlineTemplate = new InlineTemplate();
tmpInlineTemplate.Sequence = "1";
tmpInlineTemplate.Recipients = tmpRecipients;
ServerTemplate tmpServerTemplate = new ServerTemplate("2", DOCUSIGN_TEMPLATE_ID);
tmpCompTemplate.ServerTemplates = new List<ServerTemplate>() { tmpServerTemplate };
tmpCompTemplate.InlineTemplates = new List<InlineTemplate>() { tmpInlineTemplate };
tmpCompTemplate.Document = tmpDoc;
tmpEnv.CompositeTemplates = new List<CompositeTemplate>() { tmpCompTemplate };
//Request that the envelope be sent by setting |status| to "sent".
//To request that the envelope be created as a draft, set to "created"
tmpEnv.Status = "sent";
return tmpEnv;
}
Thanks for any help you can offer.
Your code has to handle the recipients correctly.
The roleName must match between recipients pre-defined in the template and the ones you add in your code.
I don't see in your code that part.
The example you use is for composite template. The relevant code for this is in a regular template example but it's the same.
https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/eSignature/Controllers/Eg009UseTemplateController.cs
TemplateRole signer1 = new TemplateRole();
signer1.Email = signerEmail;
signer1.Name = signerName;
signer1.RoleName = "signer";
TemplateRole cc1 = new TemplateRole();
cc1.Email = ccEmail;
cc1.Name = ccName;
cc1.RoleName = "cc";
CRM 2016 exposes odata/web api, and has functions and actions out of the box.
With the organization service, we can issue a request like this:
// Create the van required resource object.
RequiredResource vanReq = new RequiredResource
{
ResourceId = _vanId,
ResourceSpecId = _specId
};
// Create the appointment request.
AppointmentRequest appointmentReq = new AppointmentRequest
{
RequiredResources = new RequiredResource[] { vanReq },
Direction = SearchDirection.Backward,
Duration = 60,
NumberOfResults = 10,
ServiceId = _plumberServiceId,
// The search window describes the time when the resouce can be scheduled.
// It must be set.
SearchWindowStart = DateTime.Now.ToUniversalTime(),
SearchWindowEnd = DateTime.Now.AddDays(7).ToUniversalTime(),
UserTimeZoneCode = 1
};
// Verify whether there are openings available to schedule the appointment using this resource
SearchRequest search = new SearchRequest
{
AppointmentRequest = appointmentReq
};
SearchResponse searched = (SearchResponse)_serviceProxy.Execute(search);
if (searched.SearchResults.Proposals.Length > 0)
{
Console.WriteLine("Openings are available to schedule the resource.");
}
Is it possible to mimic this functionality using functions/action or any other odata functionality?
I believe that the request should be something like this:
crmOrg/api/v8.1/Search(AppointmentRequest=#request)?#request=
However, I'm not sure how to encode the rest of the request.
The parameter goes like:
http://yourcrm.org/org/api/data/v8.1/Search(AppointmentRequest=#ar)/?#ar={SearchWindowStart:%272017-01-01%27,Duration:60,NumberOfResults:10}
it is url encoded json of serialized AppointmentRequest class.
{
SearchWindowStart:'2017-01-01',
Duration: 60,
NumberOfResults:10,
etc...
}
More info here: https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.appointmentrequest.aspx
ODATA reference: http://odata.github.io/WebApi/04-06-function-parameter-support/
I am creating posts using WordPressSharp, but fail to set private custom field values that begin with an underscore upon creating the post.
I have read a ton of posts about modifying the file meta.php on the WordPress-site to alter register_meta and/or is_protected_meta, but have still not managed to get those custom fields to save the data I pass when creating the post.
using (var client = new WordPressClient(new WordPressSiteConfig
{
BaseUrl = "http://example.com",
Username = "username",
Password = "pass",
BlogId = 1
}))
{
Term t = new Term();
t = client.GetTerm("category", 6);
var terms = new List<Term>();
terms.Add(t);
var customFields = new[]
{
new CustomField
{
Key = "_ct_text_5401d2f94abc9",
Value = "123"
}
};
var post = new Post
{
PostType = "video",
Title = "title",
Content = "description",
PublishDateTime = DateTime.Now,
Status = "draft",
CustomFields = customFields
};
var id = client.NewPost(post);
}
The post is created successfully without issues, but why the private custom field is not getting the value set?
I have tried using both XMLRPC version 3 as well as 2.5, which is a common answer, but it does not apply to this particular issue.
Actually finally found a solution to the issue. I have removed the protection of the custom fields through the addition of the below line to functions.php
add_filter( 'is_protected_meta', '__return_false' );
I do not know if this is the optimal solution security-wise, but it works.
I am writing a similar testing framework like this one: https://github.com/ivaylokenov/MyTested.WebApi but for ASP.NET 5 MVC 6 (using 6.0.0-beta8).
I have a hard time trying to invoke the controller's TryValidateModel to validate the ModelState of a given object. It worked without any pain on ASP.NET Web API 2 controller. Which properties should I instantiate on the controller class in order for the method to validate with the default conventions. I receive either null reference exception or valid model state no matter the model and the property attributes.
I've been searching in the MVC source code for a couple of hours with no luck. I have tried to set the AddMvc() services on the controller - not working for me. I even tried their testing controller type located HERE (the GetController private method) but with no luck. Here is the source I am currently using:
// TODO: for real this is how we configure controller?
var detailsProviders = new IMetadataDetailsProvider[]
{
new DefaultBindingMetadataProvider(new ModelBindingMessageProvider
{
MissingBindRequiredValueAccessor = name => $"A value for the '{ name }' property was not provided.",
MissingKeyOrValueAccessor = () => $"A value is required.",
ValueMustNotBeNullAccessor = value => $"The value '{ value }' is invalid.",
}),
new DefaultValidationMetadataProvider(),
new DataAnnotationsMetadataProvider(),
// new DataMemberRequiredBindingMetadataProvider(), TODO: not available in version 8 but it is in the source code of MVC
};
var compositeDetailsProvider = new DefaultCompositeMetadataDetailsProvider(detailsProviders);
var metadataProvider = new DefaultModelMetadataProvider(compositeDetailsProvider);
var httpContext = new DefaultHttpContext();
var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
var viewData = new ViewDataDictionary(metadataProvider, new ModelStateDictionary());
var tempData = new TempDataDictionary(new HttpContextAccessor(), new SessionStateTempDataProvider());
var bindingContext = new ActionBindingContext()
{
ModelBinder = new GenericModelBinder(),
ValueProvider = new CompositeValueProvider(new IValueProvider[0]),
InputFormatters = new List<IInputFormatter>(),
ValidatorProvider = new DataAnnotationsModelValidatorProvider(
options: null,
stringLocalizerFactory: null)
};
this.Controller.ActionContext = actionContext;
this.Controller.BindingContext = bindingContext;
this.Controller.MetadataProvider = metadataProvider;
this.Controller.ViewData = viewData;
this.Controller.TempData = tempData;
this.Controller.ObjectValidator = new DefaultObjectValidator(new IExcludeTypeValidationFilter[0], metadataProvider);
Any help will be appreciated. Thank you in advance!
Turns out it is actually a bug in ASP.NET MVC and the team will fix it for the next RC2 version: https://github.com/aspnet/Mvc/issues/3586
I use the PayPal Express Checkout SOAP service. For example here's a trimmed down version of the code to redirect the user to PayPal Sandbox when checking out:
var client = new PayPalAPIAAInterfaceClient();
var credentials = new CustomSecurityHeaderType() {
Credentials = new UserIdPasswordType() { ... }
};
var paymentDetails = new PaymentDetailsType() {
OrderTotal = new BasicAmountType() {
Value = string.Format("{0:0.00}", 100m)
}
};
var request = new SetExpressCheckoutReq() {
SetExpressCheckoutRequest = new SetExpressCheckoutRequestType() {
SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType() {
PaymentDetails = new PaymentDetailsType[] { paymentDetails },
CancelURL = "http://www.mysite.com" + Url.Action("Cancelled", "PayPalCheckout"),
ReturnURL = "http://www.mysite.com" + Url.Action("Index", "PayPalCheckout")
},
Version = "60.0"
}
};
var response = client.SetExpressCheckout(ref credentials, request);
return Redirect(string.Format("{0}?cmd=_express-checkout&token={1}", "https://www.sandbox.paypal.com/cgi-bin/webscr", response.Token));
I then handle the data when the user is returned to the ReturnUrl. This was taken from some code I found on another website.
I now need to add a refund facility to my site. I was wondering if anyone else has done this? I've tried searching online but can't seem to find anything that helps. I also tried doing it myself but the API isn't very intuitive.
I'd appreciate the help. Thanks
It would just need to be a RefundTransaction API call that you would need to execute. Are you trying to have your return page issue a refund based on a condition, or are you trying to create a GUI type of interface to allow someone to issue a refund for a transaction? Have you looked at the code samples for this within the SDK's that PayPal offers? You should be able to use this code.