Here's my problem. I have a SSIS package that takes 1 parameter on input called SegmentID. But I cant pass it from the c# code. I'm searching for2 days so far, and here's a solution I came up with, which should work, but doesn't - SSIS package fails at the stage of getting parameter. What a hell am I doing wrong?
using (SqlConnection con = GetConnection())
{
var integrationServices = new IntegrationServices(con);
if (integrationServices.Catalogs.Contains("SSISDB"))
{
var catalog = integrationServices.Catalogs["SSISDB"];
if (catalog.Folders.Contains("PSO"))
{
var folder = catalog.Folders["PSO"];
if (folder.Projects.Contains("PSO_SSIS"))
{
var project = folder.Projects["PSO_SSIS"];
project.Parameters["SegmentID"].Set(ParameterInfo.ParameterValueType.Literal, segmentID);
if (project.Packages.Contains("Main.dtsx"))
{
var package = project.Packages["Main.dtsx"];
long executionIdentifier = package.Execute(false, null);
return catalog.Executions[executionIdentifier];
}
}
}
}
}
Thanks, guys, but i figured it out. You have to do something like this:
var setValueParameters = new Collection<PackageInfo.ExecutionValueParameterSet>();
setValueParameters.Add(new PackageInfo.ExecutionValueParameterSet
{
ObjectType = 20,
ParameterName = "SegmentID",
ParameterValue = 1
});
and then call:
long executionIdentifier = package.Execute(false, null, setValueParameters);
Why it confused me so much is that I thought that this thing is just for system parameters, like logging level or something, and NOWHERE was mentioned that the code for user parameters is 20, and this construction can be used for assigning them. Hope it'll help somebody to avoid butthurt I had for 2 days.
Related
I'm having an issue consuming a web service and hoped someone could shed some light.
I have everything I need working with the exception of an enum.
Generated Reference.cs contains:
public enum SearchType {
sales,
lettings,
}
My controller method has the following:
if (model.ValuationType == "lettings")
{
Debug.WriteLine("in the lettings route");
request = new ValuationRequest
{
ValuationType = SearchType.lettings,
Postcode = model.Postcode,
FromDate = DateTime.Now.AddDays(1),
ToDate = DateTime.Now.AddDays(14)
};
}
else
{
Debug.WriteLine("in the sales route");
request = new ValuationRequest
{
ValuationType = SearchType.sales,
Postcode = model.Postcode,
FromDate = DateTime.Now.AddDays(1),
ToDate = DateTime.Now.AddDays(14)
};
}
var valuationAppointments =
WebUtility.GetValuationAppointments(request);
and within GetValuationAppointments the utility simply does the following:
public static Appointment[] GetValuationAppointments(ValuationRequest request)
{
Debug.WriteLine(request.ValuationType);
Debug.WriteLine(request.Postcode);
Debug.WriteLine(request.FromDate);
Debug.WriteLine(request.ToDate);
service = new MyWebService();
var valuationAppointments = service.GetValuationAppointments(request);
return valuationAppointments;
}
Now the debug from those write lines is showing everything exactly as I would have expected and returns appointments correctly, however, they are always sales. Even if lettings is passed through from the model to the service. My guess is something about the enum type is being completely ignored and so the service is defaulting to sales.
Visual Studio shows no warnings about ValuationType = SearchType.lettings and anything else I try with that line throws errors.
Any ideas at all why this ValuationType = SearchType.lettings is the only field failing?
evidence from debug:
in the lettings route
lettings
GU4 7QG
29/08/2018 10:47:21
11/09/2018 10:47:21
Appreciate any help!
The issue was that I wasn't specifying some mandatory field
SearchTypeSpecified = true;
fixed the issue!
Cheers all the same folks.
I downloaded via nuget the package Orc.SystemInfo (Orc.SystemInfo). I managed to display some SystemInfoElements as a list. However no name is provided (name in List is null). I think there is a problem with the LanguageService. I already googled for this problem but I was unable to find a solution.
Here is my code so far (Linq-Pad)
void Main()
{
var service = new Orc.SystemInfo.WindowsManagementInformationService();
var dotnet = new Orc.SystemInfo.DotNetFrameworkService();
var db = new Orc.SystemInfo.DbProvidersService();
ILanguageService lang = new Catel.Services.LanguageService();
var info = new Orc.SystemInfo.SystemInfoService(service, dotnet, lang, db);
var infoList = info.GetSystemInfo();
infoList.Dump();
}
Thank you for your help!
You can simply resolve the ISystemInfo service using the ServiceLocator and all should be taken care of for you.
I'm trying to query the search API of Rally, here is my c# code:
var searchRequest = new Request()
{
ArtifactName = "search",
Limit = 25,
Project = "/project/" + CurrentProject,
ProjectScopeDown = true,
ProjectScopeUp = true,
PageSize = 25,
Fetch = new List<string>() { "true" }
};
searchRequest.AddParameter("keywords", "foo");
QueryResult queryTaskResult = api.Query(searchRequest);
this works as expected and returns result, however i want to pass a parameter of compact=true, which will return slightly different data (mainly a standard web link to the item).
var searchRequest = new Request()
{
ArtifactName = "search",
Limit = 25,
Project = "/project/" + CurrentProject,
ProjectScopeDown = true,
ProjectScopeUp = true,
PageSize = 25,
Fetch = new List<string>() { "true" }
};
searchRequest.AddParameter("keywords", "foo");
///this is the new item
searchRequest.AddParameter("compact", "true");
QueryResult queryTaskResult = api.Query(searchRequest);
However when i fire this request I get the following error
Rally.RestApi.Json.DynamicJsonObject' does not contain a definition for 'Errors'
However when I try to do this request in the browser it works fine.
Any help as to what I'm doing wrong would be greatly appreciated!
Why do you want to do this?
What I want to do is build up a link to the WEB view of the object, eg:
https://rally1.rallydev.com/#/{CurrentProject}d/detail/{ObjectType}/{ObjectId}
I already know the CurrentProject, I need to know the ObjectType and the ObjectId
I have found, when i pass compact=true, the _ref provides this, '/defect/1234567' but this throws an exception.
If I do not pass compact=true, the _ref returns the API reference 'https://rally1.rallydev.com/slm/webservice/v2.x/defect/1234567'
Unfortunately the compact functionality was added to WSAPI after the .NET toolkit was created and we've never updated it to support it.
I filed a github issue here: https://github.com/RallyTools/RallyRestToolkitFor.NET/issues/37
compact=true was mainly a performance optimization to reduce the size of responses in large result sets.
Other than performance is there a reason you'd like to use it?
I try to create a new EPT (project server 2013) using C# CSOM library.
But It has following error occurred.
"PJClientCallableException: EnterpriseProjectTypeInvalidCreatePDPUid"
Couple of article tell to change the "IsCreate=true". But it does not success for me. Here is the code what I have done.
public void CreateEnterpriseProjectType(Guid eptGuid, string eptName, string eptDescription)
{
ProjectContext pwaContext = new ProjectContext(this.PWA_URL);
EnterpriseProjectTypeCreationInformation eptData = new EnterpriseProjectTypeCreationInformation();
eptData.Id = eptGuid;
eptData.Name = eptName;
eptData.Description = eptDescription;
eptData.IsDefault = false;
eptData.IsManaged = true;
eptData.WorkspaceTemplateName = "PROJECTSITE#0";
eptData.ProjectPlanTemplateId = Guid.Empty;
eptData.WorkflowAssociationId = Guid.Empty;
eptData.Order = 4;
List<ProjectDetailPageCreationInformation> projectDetailPages = new
List<ProjectDetailPageCreationInformation>() {
new ProjectDetailPageCreationInformation() {
Id = pwaContext.ProjectDetailPages[1].Id, IsCreate = true }
};
eptData.ProjectDetailPages = projectDetailPages;
pwaContext.Load(pwaContext.EnterpriseProjectTypes);
pwaContext.ExecuteQuery();
EnterpriseProjectType newEpt = pwaContext.EnterpriseProjectTypes.Add(eptData);
pwaContext.EnterpriseProjectTypes.Update();
pwaContext.ExecuteQuery();
}
Can anyone explain the issue or provide the working code part.
I would like to suggest the following:
Define an enterprise project type:
string basicEpt = "Enterprise Project"; // Basic enterprise project type.
int timeoutSeconds = 10; // The maximum wait time for a queue job, in seconds.
And then, when you create the new project, work like this:
ProjectCreationInformation newProj = new ProjectCreationInformation();
newProj.Id = Guid.NewGuid();
newProj.Name = "Project Name";
newProj.Description = "Test creating a project with CSOM";
newProj.Start = DateTime.Today.Date;
// Setting the EPT GUID is optional. If no EPT is specified, Project Server
// uses the default EPT.
newProj.EnterpriseProjectTypeId = GetEptUid(basicEpt);
PublishedProject newPublishedProj = projContext.Projects.Add(newProj);
QueueJob qJob = projContext.Projects.Update();
// Calling Load and ExecuteQuery for the queue job is optional.
// projContext.Load(qJob);
// projContext.ExecuteQuery();
JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds);
When the last line of that piece of code ends, the project must be created and published in order to define tasks or whatever.
I don't know what is happening to your code, seems great.
Hope it helps to you,
I'm trying to create a new Website using the nuget package Microsoft.WindowsAzure.Management.WebSites (Version 3.0.0)
This tutorial has been helpful (even though its Java):
http://azure.microsoft.com/fi-fi/documentation/articles/java-create-azure-website-using-java-sdk/
except it suggests to use the WebSpaceNames.WestUSWebSpace constant.
var hostingPlanParams = new WebHostingPlanCreateParameters
{
Name = this.webhostingPlanName,
NumberOfWorkers = 1,
SKU = SkuOptions.Free,
WorkerSize = WorkerSizeOptions.Small
};
var result = new WebSiteManagementClient(this.Credentials)
.WebHostingPlans
.CreateAsync(WebSpaceNames.WestUSWebSpace, hostingPlanParams, CancellationToken.None)
.Result
This will result in an exception: NotFound: Cannot find WebSpace with name westuswebspace.
I actually want to create a custom WebSpace.
Except I can't find any method for it. See MSDN
So the only way I can make this work is using an existing WebSpace, that had created through the manage.windowsazure.com site. Which defeats the whole purpose of automating this.
The only Create[...] Method on IWebSpaceOperations is CreatePublishingUserAsync which I have tried running this as well but it results in an exception This operation is not supported for subscriptions that have co-admins. Which is pretty annoying in itself, doesn't make much sense to me, but is not really the core of my question.
I resolved this by using the prerelease package: PM> Install-Package Microsoft.Azure.Management.WebSites -Pre
Which works perfectly well. Except that it's only a pre-release of cause
// Create Web Hosting Plan
var hostingPlanParams = new WebHostingPlanCreateOrUpdateParameters
{
WebHostingPlan = new WebHostingPlan()
{
Name = "WebHostingPlanName",
Location = "Australia Southeast",
Properties = new WebHostingPlanProperties
{
NumberOfWorkers = 1,
Sku = SkuOptions.Standard,
WorkerSize = WorkerSizeOptions.Small
}
},
};
var result = this.ManagementContext.WebSiteManagementClient.WebHostingPlans.CreateOrUpdateAsync(
"ResourceGroupName",
"WebHostingPlanName",
CancellationToken.None).Result;
// Create Website
var websiteParams = new WebSiteCreateOrUpdateParameters
{
WebSite = new WebSiteBase
{
Location = "Australia Southeast",
Name = "WebSiteName",
Properties = new WebSiteBaseProperties
{
ServerFarm = "WebHostingPlanName"
}
}
};
var siteResult = this.ManagementContext.WebSiteManagementClient.WebSites.CreateOrUpdateAsync(
"ResourceGroupName",
"WebSiteName",
null,
websiteParams,
CancellationToken.None).Result;
If you want to use deployment slots you have to take this under consideration:
https://github.com/Azure/azure-sdk-for-net/issues/1088