HP Trim web service- how to request a record.? - trim

I am dealing with HP Trim web service with no support at all. I have to set a request of file using web service. i think i have to set following properties but i am not sure what operation this will be added in.
rcqCurrentLoc(Current Location):
rcqDetails(Details):
rcqEndDate(Date of Final Request):
rcqFrequency(Frequency):
rcqFrequencyType(Frequency Type):
rcqHomeLoc(Home Location):
rcqNotes(Notes):
rcqRecord(Object):
rcqRequestDate(Date Object Needed):
rcqRequestor(Requested By):
Can someone please help me on this?

I was looking at wrong properties. The request properties are following
uri(Unique Identifier):
reqEndDate(Date of Final Request):
reqFrequency(Frequency):
reqFrequencyType(Frequency Type):
reqName(Request Info):
reqNotes(Notes):
reqRequestDate(Date Needed):
reqRequestor(Requested By):
and the code is
public void AddFileRequest(string FileUri,string RequestorUserId, DateTime DateNeeded)
{
List<InputProperty> properties = new List<InputProperty>();
InputProperty property = new InputProperty();
property.Name = ReqRequstor;
property.Val = GetUserUri(RequestorUserId);
properties.Add(property);
property = new InputProperty();
property.Name = ReqRequestDate;
property.Val = DateNeeded.ToString();
properties.Add(property);
ShortcutRecordUri uri = new ShortcutRecordUri();
uri.Uri = FileUri;
uri.IsForUpdate = true;
CreateChildItem create = new CreateChildItem();
create.ChildObjectType = ObjectTypeRequest;
create.Items = properties.ToArray();
TrimRequest request = new TrimRequest();
request.Items = new Operation[] { uri, create };
ExecuteRequest(request);
}

Related

Azure Resource Manager DNS: Sample code to create a DNS record

I'm currently trying to move out from using old Microsoft.Azure.Management.Dns package to the new Azure.ResourceManager.Dns.
However I've been having issues in our code that creates Dns records such as an Arecord.
I've tried to go through the official documentation https://learn.microsoft.com/en-us/dotnet/api/azure.resourcemanager.dns.dnsarecordcollection.createorupdate?view=azure-dotnet
But the classes that represent an Arecord are either read only or private so I have no idea how to update this simple lines:
RecordSet set = DnsManagementClient.client.RecordSets.Get(resourceGroupName, zone, recordSetName, RecordType.A);
set.ARecords = set.ARecords ?? new List<ARecord>();
set.ARecords.Add(new ARecord(ipAddress));
DnsManagementClient.client.RecordSets.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, zone, recordSetName, RecordType.A, set, ifNoneMatch: "*");
Currently documentation only talks about Zones, can an example be added to the official documentation on how to add or update a DNS record (A,CNAME,etc..)
https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/dns/Azure.ResourceManager.Dns
I'm expecting a method to create an A record that let's you specify an IP address, and currently all the classes that potentially can be used to do that are either read-only or internal.
DnsARecordData has an internal list of Arecords, DnsARecordData.DnsARecords is where we can invoke the Add method to create the record. The reason DnsARecordData doesn't have a setter method is due to the .Net framework design guideline..
An example of how to create an A record using Azure.Resourcemanager.Dns can be found here:
// Create or update A record
string myARecordName = "myrecord";
DnsARecordData dnsARecordData = new() {TtlInSeconds = (long)TimeSpan.FromHours(1).TotalSeconds};
dnsARecordData.DnsARecords.Add(new DnsARecordInfo { IPv4Address = IPAddress.Parse("127.0.0.1") });
DnsARecordCollection dnsARecordCollection1 = dnsZoneResource.GetDnsARecords();
dnsARecordCollection1.CreateOrUpdate(WaitUntil.Completed, myARecordName, dnsARecordData);
// Create or update CName pointing to A record
string myCnameName = "mycname";
DnsCnameRecordData dnsCnameRecordData = new() { Cname = $"{myARecordName}.{DnsZone}", TtlInSeconds = (long)TimeSpan.FromMinutes(10).TotalSeconds, };
DnsCnameRecordCollection cnameRecordCollection = dnsZoneResource.GetDnsCnameRecords();
cnameRecordCollection.CreateOrUpdate(WaitUntil.Completed, myCnameName, dnsCnameRecordData);
I tried in my environment and got below results:
You can create A record set using Azure.ResourceManager.Dns package. The version of NuGet package is beta-1.
NuGet Package:
Azure.ResourceManager.Dns 1.0.0 beta-1
Code:
using Azure;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Dns;
using Azure.ResourceManager.Resources;
using System.Net;
ArmClient armClient = new ArmClient(new DefaultAzureCredential());
SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();
// first we need to get the resource group
string rgName = "rg-name";
ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);
string dnsZoneName = "dns name";
DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones();
DnsZoneData data1 = new DnsZoneData("Global")
{
};
ArmOperation<DnsZoneResource> lro = await dnsZoneCollection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data1);
DnsZoneResource dnsZone = lro.Value;
RecordSetACollection recordSetACollection = dnsZone.GetRecordSetAs();
string name = "cname1";
var parm = new ARecordSetData();
parm.TTL =600;
parm.ARecords = new List<ARecord>();
parm.ARecords.Add(new ARecord("1.2.3.4"));
ArmOperation<RecordSetAResource> recordSetAResource = recordSetACollection.CreateOrUpdate(WaitUntil.Completed, name,parm);
RecordSetAResource recordSetAs = recordSetAResource.Value;
Console:
Portal:
For more reference:
azure-sdk-for-net/Sample2_ManagingRecordSetPtrs.md at dvbb-mgmt-track2-dns-2 ยท dvbb/azure-sdk-for-net (github.com)

i added a list box in asp.net , i need to get the option set values from ms crm to list box

I am new to ASP.Net I added a list box in asp.net , I need to get the option set values from ms crm to list box
I don't know how to return the value for this can anybody help me
public static string GetMtefrecord()
{
var service = CRMWrapper.GetCRMService();
RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Entity,
LogicalName = "tec_new_mtfmtir",
};
RetrieveEntityResponse retrieveBankAccountEntityResponse = (RetrieveEntityResponse)service.Execute(retrieveBankAccountEntityRequest);
//return retrieveBankAccountEntityResponse.LogicalName.ToString();
}
If your optionset is a global optionset, you can retrieve it using the RetrieveOptionSetRequest message. Here is a bit of sample code
RetrieveOptionSetRequest retrieveOptionSetRequest =
new RetrieveOptionSetRequest
{
Name = _globalOptionSetName //Put your optionsetname here
};
// Execute the request.
RetrieveOptionSetResponse retrieveOptionSetResponse =
(RetrieveOptionSetResponse)_serviceProxy.Execute(
retrieveOptionSetRequest);
OptionMetadata[] optionList =
((OptionSetMetadata) retrieveOptionSetResponse.OptionSetMetadata).Options.ToArray();

I am trying to configure LDAP as JNDI Resource in Pivotal

I get some data with ldap authentication. I can do this correctly with this code.
List<Employees> emps=new ArrayList<Employees>();
String url = "ldap://xxx:389";
String base = "dc=xxx,dc=xxx,dc=xx";
String userDn = "username";
String password = "pass";
try {
LdapContextSource ctxSrc = new LdapContextSource();
ctxSrc.setUrl(url);
ctxSrc.setBase(base);
ctxSrc.setUserDn(userDn);
ctxSrc.setPassword(password);
ctxSrc.afterPropertiesSet();
LdapTemplate lt = new LdapTemplate(ctxSrc);
AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "Person"));
List<String> list = lt.search("", filter.encode(), new ContactAttributeMapperJSON());
emps = new Gson().fromJson(list.toString(), new TypeToken<List<Employees>>() {
}.getType());
this code works correctly. But i want hide my username and pass. So i get datas from content.xml(Pivotal).This is my content.xml:
<Resource name="ldap/LdapResource" auth="Container"
type="javax.naming.ldap.LdapContext"
factory="xxx"
singleton="false"
java.naming.factory.initial="com.sun.jndi.ldap.LdapCtxFactory"
java.naming.provider.url="ldap://xx:389"
java.naming.security.authentication="simple"
java.naming.security.principal="username"
java.naming.security.credentials="pass." />
And my new code block :
List<Employees> emps = new ArrayList<Employees>();
try {
Context initialContext = new InitialContext();
LdapContext ldapContext = (LdapContext) initialContext.lookup("java:comp/env/ldap/LdapResource");
*LdapTemplate lt = new LdapTemplate(ldapContext);*
AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "Person"));
List<String> list = lt.search("", filter.encode(), new ContactAttributeMapperJSON());
emps = new Gson().fromJson(list.toString(), new TypeToken<List<Employees>>() {
}.getType());
here is my problem. I cant LdapTemplate with LdapContext. It works only LdapContextSource and I cant cast LdapContext to LdapContextSource. What should i do ?
Sorry for my bad English. Thank You.
What I've done in that exact same situation is to create a java.naming.spi.ObjectFactory subclass that returns an LdapContextSource instance using the properties given in the Resource element. You can use the standard LDAP JNDI attributes from 'java.naming.Context' or use your own.
Only thing I still have to work out is how to deal with java.naming.security.authentication and java.naming.security.protocol.

Reading all components from folder and subfolder

I am working on Tridon 2009 using .NET Templating C# 2.0
I need to read all the components from folders and its subfolder.
If in my code I write:
OrganizationalItem imageFolder =
(OrganizationalItem)m_Engine.GetObject(comp.OrganizationalItem.Id);
I am able to read all the components in subfolder from the place where indicator component is present, but I am not able to read other components present in the folder where indicator is present.
But If I write
OrganizationalItem imageFolder = (OrganizationalItem)m_Engine.GetObject(
comp.OrganizationalItem.OrganizationalItem.Id);
then I am able to read only folder where indicator component is present.
Below is my code.
XmlDocument doc = xBase.createNewXmlDocRoot("ImageLibrary");
XmlElement root = doc.DocumentElement;
Filter filter = new Filter();
Component comp = this.GetComponent();
filter.Conditions["ItemType"] = ItemType.Folder;
filter.Conditions["Recursive"] = "true";
OrganizationalItem imageFolder =
(OrganizationalItem)m_Engine.GetObject(comp.OrganizationalItem.Id);
XmlElement itemList = imageFolder.GetListItems(filter);
foreach (XmlElement itemImg in itemList)
{
filter.Conditions["ItemType"] = ItemType.Component;
filter.Conditions["BasedOnSchema"] = comp.Schema.Id;
OrganizationalItem imgFolder =
(OrganizationalItem)m_Engine.GetObject(itemImg.GetAttribute("ID")
.ToString());
XmlElement imageLibs = imgFolder.GetListItems(filter);
doc = this.createImageNodes(imageLibs, doc, filter, comp);
foreach (XmlElement imglib in imageLibsList)
{
XmlElement imageroot = doc.CreateElement("Image");
XmlElement uploadeddateNode = doc.CreateElement("DateUploaded");
Component imgComp =
(Component)m_Engine.GetObject(imglib.GetAttribute("ID"));
}
}
Please suggest.
I see a lot of superfluous code on your snippet regarding the question "Reading all components from folder and subfolder"
But answering the question itself, when you are doing:
OrganizationalItem imageFolder = (OrganizationalItem)m_Engine.GetObject(comp.OrganizationalItem.Id);
Your are not being able to read components present on that folder, because you have previously set the filter to folders only on the following line:
filter.Conditions["ItemType"] = ItemType.Folder;
Solution:
If you want to retrieve all components on the "indicator component" folder and below, you need to set the filter on your first search as following:
filter.Conditions["Recursive"] = "true";
filter.Conditions["ItemType"] = ItemType.Component;
filter.Conditions["BasedOnSchema"] = comp.Schema.Id;
And perform the search:
OrganizationalItem imageFolder = (OrganizationalItem)m_Engine.GetObject(comp.OrganizationalItem.Id);
XmlElement itemList = imageFolder.GetListItems(filter);
Pretty basic stuff. Try to avoid using Filter class, since it was deprecated in 2009, and use GetListItems as much as possible as fetching lists is ALWAYS faster.
public class GetComponentsInSameFolder : ITemplate
{
public void Transform(Engine engine, Package package)
{
TemplatingLogger log = TemplatingLogger.GetLogger(GetType());
if (package.GetByName(Package.ComponentName) == null)
{
log.Info("This template should only be used with Component Templates. Could not find component in package, exiting");
return;
}
var c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
var container = (Folder)c.OrganizationalItem;
var filter = new OrganizationalItemItemsFilter(engine.GetSession()) { ItemTypes = new[] { ItemType.Component } };
// Always faster to use GetListItems if we only need limited elements
foreach (XmlNode node in container.GetListItems(filter))
{
string componentId = node.Attributes["ID"].Value;
string componentTitle = node.Attributes["Title"].Value;
}
// If we need more info, use GetItems instead
foreach (Component component in container.GetItems(filter))
{
// If your filter is messed up, GetItems will return objects that may
// not be a Component, in which case the code will blow up with an
// InvalidCastException. Be careful with filter.ItemTypes[]
Schema componentSchema = component.Schema;
SchemaPurpose purpose = componentSchema.Purpose;
XmlElement content = component.Content;
}
}
}
I'd think you'd want to collect sub folders and recursively call your function for each of them, which seems like what you're trying to achieve.
Is this function called createImageNodes() and where do you set imageLibsList?
It looks like you're treating each item as a folder in your first loop, what about the components?

ASP.NET C# Filter Data from Soap Service

I have a Soap service that I added to my .NET project via Service Reference.
problemReporting.soapClient s = new problemReporting.soapClient();
problemReporting.NullRequest nr = new NullRequest();
problemReporting.ProblemDescription[] getDescList = s.getProblemDescriptionList(nr);
if (!IsPostBack)
{
rbProblemList.DataSource = getDescList;
rbProblemList.DataTextField = "description";
rbProblemList.DataValueField = "code";
rbProblemList.DataBind();
}
This returns a DropDownList of 23 items. (This list could grow in the future.) The service is returning an array of objects, where each object contains Category, Code, and Description.
How can I create a separate method that will return ONLY the 4 categories that exists in this array? I am unable to find any examples of how to create a method that will filter the data from a soap service.
Thank you in advance for any assistance.
This is basically the same code from another question you asked:
ASP.NET C# Filter DropDownList based on specific Category of Items from Soap Service
problemReporting.soapClient s = new problemReporting.soapClient();
problemReporting.NullRequest nr = new NullRequest();
problemReporting.ProblemDescription[] getDescList = s.getProblemDescriptionList(nr);
List<string> categories = new List<string>();
categories.Add("Category1");
categories.Add("Category2");
categories.Add("Category3");
var filteredResults = FilterCategories(categories, getDescList);
if (!IsPostBack)
{
rbProblemList.DataSource = filteredResults;
rbProblemList.DataTextField = "description";
rbProblemList.DataValueField = "code";
rbProblemList.DataBind();
}
public ProblemDescription[] FilterCategories(List<string> categories, ProblemDescription[] data )
{
var cats = from desc in data
where categories.Contains(desc.category)
select desc;
return cats;
}

Resources