Create Timesheet using PSI Project Server 2013 - General Invalid Operation - c#

I'm trying to use the TimeSheet.CreateTimesheet method from msdn but unfortunately I receive the General Invalid Operation error from my console.
I suspect it's a permissions problem, because of I have followed all of the instructions posted in the entrance from msdn linked before.
Here are the MAIN code:
// Here are the variables
SvcTimeSheet.TimesheetDataSet timesheetDs;
SvcTimeSheet.TimeSheet timeSheetSvc = new SvcTimeSheet.TimeSheet();
timeSheetSvc.UseDefaultCredentials = true;
timeSheetSvc.Url = PROJECT_SERVER_URI + TIMESHEET_SERVICE_PATH;
Guid myUid = resourceSvc.GetCurrentUserUid();
SvcAdmin.TimePeriodDataSet timeperiodDs = adminSvc.ReadPeriods(SvcAdmin.PeriodState.Open);
Guid periodUid = timeperiodDs.TimePeriods[0].WPRD_UID;
// Here are the Timesheet creation method
timesheetDs = new SvcTimeSheet.TimesheetDataSet();
SvcTimeSheet.TimesheetDataSet.HeadersRow headersRow = timesheetDs.Headers.NewHeadersRow();
headersRow.RES_UID = myUid;
headersRow.TS_UID = Guid.NewGuid();
headersRow.WPRD_UID = periodUid;
headersRow.TS_CREATOR_RES_UID = myUid;
headersRow.TS_NAME = "Timesheet ";
headersRow.TS_COMMENTS = "Random comment text here";
headersRow.TS_ENTRY_MODE_ENUM = (byte)PSLibrary.TimesheetEnum.EntryMode.Weekly;
timesheetDs.Headers.AddHeadersRow(headersRow);
// Create the timesheet with the default line types that are specified by the admin.
timeSheetSvc.CreateTimesheet(timesheetDs, SvcTimeSheet.PreloadType.Assignments);
timesheetDs = timeSheetSvc.ReadTimesheet(headersRow.TS_UID);
When timeSheetSvc.CreateTimesheet(timesheetDs, SvcTimeSheet.PreloadType.Assignments); it is called, I get the General Invalid Operation.
Anybody knows what that means? Or where can I find further information about?
EDIT:
Here are the screenshot from my PSI Console, that parses the error:
Thanks in advance,

Related

Status is RUNNING all the time for loading CSV file from Storage to BiGQuery using C#

I've created the TableReference by providing project_id, dataset_id and the name of the table.
BigQueryClient cltBigQueryByDP = BigQueryClient.Create(_strProjectId, _gCredentials);
Google.Apis.Bigquery.v2.Data.TableReference reference = cltBigQueryByDP.GetTableReference("project_id", "dataset_id", "table_name");
Then, I created Schema.
TableSchema schema = new TableSchema() using TableFieldSchema.
BigQueryJob job = cltBigQueryByDP.CreateLoadJob("gs://bucket_name/File_name.txt", reference, schema, new CreateLoadJobOptions()
{
SourceFormat = FileFormat.Csv,
FieldDelimiter = "|",
CreateDisposition = CreateDisposition.CreateIfNeeded,
SkipLeadingRows = 0
});
There is no error generated so far however it shows job.Status.State = RUNNING all the time.
I've been struggling for few hours but no clue to find root cause.
Please help.

WSDL generated service reference returning null

Im have some issues with a service reference to an external source (added it using the supplied wsdl in Visual Studio 2015).
The situation is that the request i run seems to reach the server fine. I also seems to get a response of the expected xml format (added TextWriterTraceListener). But the OutType class i get back in the code (in this case the GetBankCertificateOutType) is always null.
The console application ive built to illustrate is very simple, utilizing the public test account. It looks as follows:
static void Main(string[] args)
{
//instantiates client from the service reference
var client = new PkiServicePortTypeClient();
var time = DateTime.UtcNow;
Random r = new Random();
string reqId = r.Next(100, 999).ToString();
var outType = client.GetBankCertificate(*full params on github*);
//This line will throw nullexception since outType is always null
//BUT a valid response is actually received (although returning aa application statusCode that represents error at this stage)
var response = outType.GetBankCertificateResponse;
}
Ive tried to locate the problem but have been unsuccessful sofar. So wanted to see if someone has some good tip on how to debug this or perhaps has a solution.
I built a complete, minimal, console sample project (including the source wsdl) to illustrtate the issue which is located here.
I've downloaded and inspected your solution, and I found this in trace.log
GetBankCertificateRequest at tribute {http://www.w3.org/XML/1998/namespace}id had invalid value '360817' of type '{http://www .w3.org/2001/XML Schema}ID'
After I played with id value of GetBankCertificateRequest I got back the right value (instead of null).
var outType = client.GetBankCertificate(new GetBankCertificateInType {
RequestHeader = new RequestHeaderType {
SenderId = "360817",
CustomerId = "360817",
RequestId = reqId,
Environment = EnvironmentType.test,
EnvironmentSpecified = true,
InterfaceVersion = "1",
Timestamp = time
},
GetBankCertificateRequest = new GetBankCertificateRequest {
BankRootCertificateSerialNo = "1111110002",
//id = "",
RequestId = reqId,
Timestamp = time
}
});
There is no description for this property according to documentation (PKI service description v2.3.pdf) except some xml type annotation (xml:id). The concrete schema description is missing.

NetSuite SuiteTalk TransactionSearchAdvanced: recordList equals null

I have a small C# console application who's sole purpose is to receive records from a "Saved Search" in NetSuite(via SuiteTalk). I've been able to successfully connect and receive records from NetSuite for my Saved Search(the search runs fine through the web interface too), however when I attempt to access the results of the "Saved Search" through my application, I am unable to view them because the search object that is returned does not contain any data in the "recordList" property:
//Connect
var dataCenterAwareNetSuiteService = new DataCenterAwareNetSuiteService("XXXXXX");
dataCenterAwareNetSuiteService.Timeout = 1000 * 60 * 60 * 2;
//Adds Credentials etc...
dataCenterAwareNetSuiteService.tokenPassport = createTokenPassport();
//Setup Preferences
var prefs = new Preferences();
prefs.warningAsErrorSpecified = true;
prefs.warningAsError = false;
dataCenterAwareNetSuiteService.preferences = prefs;
var searchPrefs = new SearchPreferences();
dataCenterAwareNetSuiteService.searchPreferences = searchPrefs;
dataCenterAwareNetSuiteService.searchPreferences.pageSize = 5;
dataCenterAwareNetSuiteService.searchPreferences.pageSizeSpecified = true;
dataCenterAwareNetSuiteService.searchPreferences.bodyFieldsOnly = false;
dataCenterAwareNetSuiteService.searchPreferences.returnSearchColumns = false;
//Search
var tranSearchAdv = new TransactionSearchAdvanced();
var tranSearchRow = new TransactionSearchRow();
var tranSearchRowBasic = new TransactionSearchRowBasic();
tranSearchAdv.savedSearchId = "XXXX";
tranSearchRowBasic.internalId =
new SearchColumnSelectField[] { new SearchColumnSelectField() };
tranSearchRowBasic.tranId =
new SearchColumnStringField[] { new SearchColumnStringField() };
tranSearchRowBasic.dateCreated =
new SearchColumnDateField[] { new SearchColumnDateField() };
tranSearchRowBasic.total =
new SearchColumnDoubleField[] { new SearchColumnDoubleField() };
tranSearchRowBasic.entity =
new SearchColumnSelectField[] { new SearchColumnSelectField() };
tranSearchRow.basic = tranSearchRowBasic;
tranSearchAdv.columns = tranSearchRow;
//No errors,
//this works correctly and returns the "Saved Search" with the correct "totalRecords"
//but results.recordList == null while results.totalRecords = 10000000+
var results = dataCenterAwareNetSuiteService.search(tranSearchAdv);
I appears to me that the "recordList" object is the principal way data is retrieved from the results of a search(Related Java Example, Another Here). This is also the way the example API does it.
I have run this on multiple "Saved Search's" with the same results. I don't understand how you can have more than one record in "totalRecords" and yet the "recordList" remains null? Is there some configuration option that has to be set to allow me to access this property. Or maybe it's a security thing, the API user I have setup should have full access, is there anything else that need to be granted access?
NetSuite SuiteTalk is not well documented, and most of the examples online are not in C#, and not dealing with the issues that I'm experiencing. These factors make it very difficult to determine why the previously mentioned behavior is occurring, or even, to discover any alternative methods for retrieving the resulting data from the source "Saved Search".
Does anyone have any insight into this behavior? Is this the correct method of retrieving results from SuiteTalk? Is there any configuration from the API or Web Side that needs to be changed?
Update 1
I've also tried using the alternative way of getting result data by accessing the "searchRowList" object from the "SearchResult" object(suggested by #AdolfoGarza) However it returns mostly empty fields(null) similar to the "recordList" property I do not see a way to retrieve "Saved Search" data from this method.
Try getting the results with results.searchRowList.searchRow , thats how it works in php.
I was able to resolve the issue by removing this line in the code:
tranSearchRow.basic = tranSearchRowBasic;
Then like #AdolfoGarza reccomended, retrieving the results from "basic" field in "results.searchRowList"
For some reason the template API that I was using was setting up a "TransactionSearchAdvanced" referencing a blank "TransactionSearchBasic" record, not sure why but this was causing the results from "searchRowList" to be null. After removing it I now get non-null values in the proper fields.
As for "recordList", it's still null, not sure why, but as I have my data I don't think I'll continue to dig into this.

VMware vCenter API with C# - InitiateFileTransferToGuest fails

I'm trying to use the InitiateFileTransferToGuest method to send a file to a VM. Unfortunately, I'm getting stuck. Here's the related code where VClient is the VimClient with an already successfull connection:
GuestOperationsManager VMOpsManager = new GuestOperationsManager(VClient, VClient.ServiceContent.GuestOperationsManager);
GuestFileManager VMFileManager = new GuestFileManager(VClient, VClient.ServiceContent.FileManager);
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, VClient.ServiceContent.AuthorizationManager);
NamePasswordAuthentication Auth = new NamePasswordAuthentication()
{
Username = "username",
Password = "password",
InteractiveSession = false
};
VMAuthManager.ValidateCredentialsInGuest(CurrentVM.MoRef, Auth);
System.IO.FileInfo FileToTransfer = new System.IO.FileInfo("C:\\userlist.txt");
GuestFileAttributes GFA = new GuestFileAttributes()
{
AccessTime = FileToTransfer.LastAccessTimeUtc,
ModificationTime = FileToTransfer.LastWriteTimeUtc
};
string TransferOutput = VMFileManager.InitiateFileTransferToGuest(CurrentVM.MoRef, Auth, "C:\\userlist.txt", GFA, FileToTransfer.Length, false);
First error shows up when getting to the ValidateCredentialsInGuest method. I get this message:
An unhandled exception of type 'VMware.Vim.VimException' occurred in VMware.Vim.dll Additional information: The request refers to an unexpected or unknown type.
If I remove that validation, I get the same error when trying to run InitiateFileTransferToGuest. I've been browsing the API documentation, and threads in VMware forums and a lot of places to be honest. The only pieces of code I've seen posted where it works were in Java and Perl, but the API implementation is a little different than C#. Any idea where to look?
Thank you!
I made it work after testing and making up stuff. I guessed the MoRef for both AuthManager and FileManager doing the following:
ManagedObjectReference MoRefFileManager = new ManagedObjectReference("guestOperationsFileManager");
GuestFileManager VMFileManager = new GuestFileManager(VClient, MoRefFileManager);
ManagedObjectReference MoRefAuthManager = new ManagedObjectReference("guestOperationsAuthManager");
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, MoRefAuthManager);
Now it's working, and I have no idea how.

ArcObject IWMSServiceDescription.get_LayerDescription C# error

My goal is to connect to a WMS Service and display a layer on my application's map using ESRI's ArcObject API for .NET.
Here is the part of my code I am struggling with:
...
String url = "some value";
String layerTitle = "another value";
...
PropertySet props = new PropertySet();
props.SetProperty("URL", url);
WMSConnectionName connectionName = new WMSConnectionName();
connectionName.ConnectionProperties = props;
WMSMapLayer mapLayer = new WMSMapLayer();
(mapLayer as IDataLayer).Connect(connectionName as IName);
IWMSGroupLayer groupLayer = (IWMSGroupLayer)mapLayer;
IWMSServiceDescription serviceDescription = groupLayer.WMSServiceDescription;
IWMSLayerDescription layerDescription = serviceDescription.get_LayerDescription(0);
groupLayer.CreateWMSLayer(layerDescription);
groupLayer.get_Layer(0).Visible = true;
ILayer layer = (ILayer)groupLayer;
layer.Name = "WxOverlays " + layerTitle;
layer.Visible = true;
At run time I encounter:
System.Runtime.InteropServices.COMException (0x8000FFFF): The supplied
command does not exist in the command pool at
ESRI.ArcGIS.GISClient.IWMSServiceDescription.get_LayerDescription(Int32
index)
A google search revealed that some similar methods in the ArcObject API throw the same exception because they are not supported in C#. Has anyone encountered this before? Anyone see a way around it? Unfortunately, I am stuck using C#, so using Java or something that may have better support from ESRI is out of the question.

Categories