Project Server 2010 - ApproveNonProjectTime method GeneralItemDoesNotExist error - c#

I try to approve non project time in a console application with the ApproveNonProjectTime method (http://msdn.microsoft.com/en-us/library/websvctimesheet.timesheet.approvenonprojecttime%28v=office.12%29.aspx).
My code is very simple :
class Program
{
const string projectServerUri = "http://morpheus-sp/pwa/";
const string resourceServicePath = "_vti_bin/psi/Timesheet.asmx";
static void Main(string[] args)
{
TimesheetWebSvc.TimeSheet timesheetSvc = new TimesheetWebSvc.TimeSheet();
timesheetSvc.Url = projectServerUri + resourceServicePath;
timesheetSvc.Credentials = CredentialCache.DefaultCredentials;
timesheetSvc.ApproveNonProjectTime(new Guid[] { new Guid("D6909043-18A7-4FF6-83BB-67EFDF17A279")}, null);
}
}
When I execute it I have this error message :
System.Web.Services.Protocols.SoapException: ProjectServerError(s) LastError=GeneralItemDoesNotExis
However I took the TS_LINE_UID directly in my DB and its status is Pending Approval.
Have you a solution ?
Thank you,
Justin

Related

error extracting text from Azure Computer Vision API

I am testing out the Azure Computer Vision API to try extract handwritten text from a local .jpg file. I am following the following example: https://learn.microsoft.com/en-us/azure/cognitive-services/computer-vision/quickstarts-sdk/csharp-sdk
Unfortunately when I run my code, I get an exception thrown: System.AggregateException: "this.Endpoint" cannot be null
My test code currently:
class Program
{
static string subscriptionKey = Environment.GetEnvironmentVariable("{SUBSCRIPTION-KEY}");
static string endpoint = Environment.GetEnvironmentVariable("https://{MY-ENDPOINT}.cognitiveservices.azure.com/");
private const string EXTRACT_TEXT_LOCAL_IMAGE = "vision3.jpg";
public static ComputerVisionClient Authenticate(string endpoint, string key)
{
ComputerVisionClient client =
new ComputerVisionClient(new ApiKeyServiceClientCredentials(key))
{ Endpoint = endpoint };
return client;
}
static void Main()
{
Console.WriteLine("Azure Cognitive Services Computer Vision - .NET quickstart example");
Console.WriteLine();
ComputerVisionClient client = Authenticate(endpoint, subscriptionKey);
//ExtractTextUrl(client, EXTRACT_TEXT_URL_IMAGE).Wait();
ExtractTextLocal(client, EXTRACT_TEXT_LOCAL_IMAGE).Wait();
}
public static async Task ExtractTextLocal(ComputerVisionClient client, string localImage)
{
Console.WriteLine("----------------------------------------------------------");
Console.WriteLine("EXTRACT TEXT - LOCAL IMAGE");
Console.WriteLine();
// Helps calucalte starting index to retrieve operation ID
const int numberOfCharsInOperationId = 36;
Console.WriteLine($"Extracting text from local image {Path.GetFileName(localImage)}...");
Console.WriteLine();
using (Stream imageStream = File.OpenRead(localImage))
{
// Read the text from the local image
BatchReadFileInStreamHeaders localFileTextHeaders = await client.BatchReadFileInStreamAsync(imageStream);
// Get the operation location (operation ID)
string operationLocation = localFileTextHeaders.OperationLocation;
// Retrieve the URI where the recognized text will be stored from the Operation-Location header.
string operationId = operationLocation.Substring(operationLocation.Length - numberOfCharsInOperationId);
// Extract text, wait for it to complete.
int i = 0;
int maxRetries = 10;
ReadOperationResult results;
do
{
results = await client.GetReadOperationResultAsync(operationId);
Console.WriteLine("Server status: {0}, waiting {1} seconds...", results.Status, i);
await Task.Delay(1000);
if (maxRetries == 9)
{
Console.WriteLine("Server timed out.");
}
}
while ((results.Status == TextOperationStatusCodes.Running ||
results.Status == TextOperationStatusCodes.NotStarted) && i++ < maxRetries);
// Display the found text.
Console.WriteLine();
var textRecognitionLocalFileResults = results.RecognitionResults;
foreach (TextRecognitionResult recResult in textRecognitionLocalFileResults)
{
foreach (Line line in recResult.Lines)
{
Console.WriteLine(line.Text);
}
}
Console.WriteLine();
}
}
}
edit:
From trying to debug, it looks like both subscriptionKey and endpoint variables are null from the beginning, even though I initialized them instantly. Why is this?
edit2:
When I hardcode the subscriptionKey and endpoint in Main():
ComputerVisionClient client = Authenticate("https://{END-POINT}.cognitiveservices.azure.com/", "{SUBSCRIPTION-KEY}");
It works fine. Can anybody tell me why my 2 static string variables do not work? As I do not want to hardcode these variables
Not sure what you want these two lines to accomplish -
static string subscriptionKey = Environment.GetEnvironmentVariable("{SUBSCRIPTION-KEY}");
static string endpoint = Environment.GetEnvironmentVariable("https://{MY-ENDPOINT}.cognitiveservices.azure.com/");
You either pick up environment variables or assign string literals, you're trying to... do a combination of the two?
Maybe read those secrets from appsettings.json instead.
This is for future people who are following the tutorials and stuck at the environment variables like me, to add new variables from visual studio go to your project properties >> Debug
then add new key and value as provided to you check here to see image explanation
Please try adding the below code before sending the request to API or at the starting of code execution.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;

Cause of "500 No individual errors" in Google Play Store edit commit

I have a simple tool in C# which uses the Google.Apis.AndroidPublisher.v3 nuget package to deploy an app to the Internal Testing track as the last step in my automated build. It worked without problems from mid-July when I wrote the tool until mid-September (last successful execution: 2018-09-17). Then I didn't touch the app for a couple of weeks; as of last Friday (2018-09-28), the tool fails with a Google.GoogleApiException with no inner exception, message
Google.Apis.Requests.RequestError
[500]
No individual errors
and stack trace
at Google.Apis.Requests.ClientServiceRequest`1.<ParseResponse>d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Google.Apis.Requests.ClientServiceRequest`1.Execute()
at MyProject.Tools.PlayStoreUploader.Program.Deploy(AndroidPublisherService service, String packageName, String releaseName, FileInfo apkFile, Int32 mainObbVersionCode, FileInfo patchObbFile, String releaseNotes) in C:\dev\MyProject\Tools\MyProject.Tools.PlayStoreUploader\Program.cs:line 211
at MyProject.Tools.PlayStoreUploader.Program.Main(String[] args) in C:\dev\MyProject\Tools\MyProject.Tools.PlayStoreUploader\Program.cs:line 126
The Deploy method, which essentially does all the work, is
private static void Deploy(
AndroidPublisherService service,
string packageName,
string releaseName,
FileInfo apkFile,
int mainObbVersionCode,
FileInfo patchObbFile,
string releaseNotes)
{
var edits = service.Edits;
// Create a new edit
string editId = edits.Insert(null /* no body */, packageName).Execute().Id;
// Upload new apk
int apkVersion;
using (Stream strm = apkFile.OpenRead())
{
var uploadRequest = edits.Apks.Upload(packageName, editId, strm, MimeTypeApk);
uploadRequest.Upload();
apkVersion = uploadRequest.ResponseBody.VersionCode.Value;
}
// Attach an existing main obb
edits.Expansionfiles.Update(
new ExpansionFile { ReferencesVersion = mainObbVersionCode },
packageName,
editId,
apkVersion,
UpdateRequest.ExpansionFileTypeEnum.Main).
Execute();
// Attach a new patch file
if (patchObbFile != null)
{
using (Stream strm = patchObbFile.OpenRead())
{
edits.Expansionfiles.Upload(
packageName,
editId,
apkVersion,
// This Google API is clearly auto-generated by a badly written tool, because it duplicates the enums.
UploadMediaUpload.ExpansionFileTypeEnum.Patch,
strm,
MimeTypeObb).
Upload();
}
}
// Assign apk to "Internal test" track.
var release = new TrackRelease
{
Name = releaseName,
VersionCodes = new long?[] { apkVersion },
ReleaseNotes = new List<LocalizedText> { new LocalizedText { Language = "en", Text = releaseNotes } },
Status = TrackReleaseStatus.Completed
};
edits.Tracks.Update(
new Track { Releases = new List<TrackRelease> { release } },
packageName,
editId,
TrackIdentifier.Internal).
Execute();
// Publish
edits.Commit(packageName, editId).Execute();
}
Relevant constants are
const string MimeTypeApk = "application/vnd.android.package-archive";
const string MimeTypeObb = "application/octet-stream";
// As documented at https://developers.google.com/android-publisher/tracks
static class TrackIdentifier
{
public const string Alpha = "alpha";
public const string Beta = "beta";
public const string Internal = "internal";
public const string Production = "production";
}
// As (poorly) documented at https://developers.google.com/android-publisher/api-ref/edits/tracks#resource
// See also https://android-developers.googleblog.com/2018/06/automating-your-app-releases-with.html
static class TrackReleaseStatus
{
/// <summary>Not yet rolled out to anyone</summary>
public const string Draft = "draft";
/// <summary> For staged rollouts to a small percentage of users</summary>
public const string InProgress = "inProgress";
/// <summary> Suspends a staged rollout</summary>
public const string Halted = "halted";
/// <summary> Full rollout</summary>
public const string Completed = "completed";
}
The exception is thrown in the penultimate line of Deploy, edits.Commit(packageName, editId).Execute();. That rules out authentication failure as a cause, since the earlier calls succeeded. The possible failure causes listed by the documentation for edits/commit are
You open another edit for the same app after you open this edit
Any other user commits an edit for the app while your edit is open
You or any other user makes a change to the app through the Developer Console while your edit is open
but I'm certain that none of those apply.
What else would explain why I can set up the edit, including uploading APK and OBB, but not commit it?
This sounds like a bug in the Play console, as demonstrated by the 500 error code which means "Internal Error".
When situations like this occur I would recommend contacting Play Console support to let them know of the problem. You can do this via the help menu in the Play Console, which is behind the "?" (question mark) icon.

Coap.Net - Starting

I'm currently trying to start with CoAP in C#. The library I'm using is CoAP.Net (→ https://github.com/smeshlink/CoAP.NET).
Unfortunately, I didn't even succeed with the example published in the "Quick Start"-Section on GitHub.
My Server Code:
class Program
{
static void Main(string[] args)
{
CoapServer server = new CoapServer();
server.Add(new HelloWorldRessouce());
server.Start();
}
}
and a ressource-class in the Server solution:
class HelloWorldRessouce : CoAP.Server.Resources.Resource
{
public HelloWorldRessouce() : base("hello-world")
{
Attributes.Title = "GET a friendly greeting!";
}
protected override void DoGet (CoapExchange exchange)
{
exchange.Respond("Hello World fron CoAP.NET!");
}
}
On the client-side I've got the following:
static void Main(string[] args)
{
CoapClient client = new CoapClient();
Request request = new Request(Method.GET);
//request.URI = new Uri("coap://[::1]/hello-world");
request.URI = new Uri("coap://192.168.178.48:5683/hello-world");
request.Send();
// wait for response
Response response = request.WaitForResponse();
}
Here is the Console-Output from the Server:
DEBUG - Starting CoAP server
DEBUG - BlockwiseLayer uses MaxMessageSize: 1024 and
DefaultBlockSize:512
DBEUG - Starting endpoint bound to [::ffff:0:0]:5683
Press any key...
Here is the Console-Output from the Client:
Console-Output - Client
I'm pretty sure, the problems are on the Client-side...
It would be awesome, if there's someone to help me get this example running. Or maybe, someone can give me a few Noob-Examples. The example-files don't really help me with this problem...
Thanks everybody...
Cheers, Mirco
Okay, it seems as if there was the dumbest user at work...^^
Server-side:
static void Main(string[] args)
{
CoapServer server = new CoapServer();
server.Add(new HelloWorldRessouce());
server.Start();
}
after "server.Start();" the program is finished and the server turns off.
By adding a "Console.ReadKey();" afterwards, everything is fine.
If someone has any noob-examples espacially about the configuration, they are still appreciated.
Thanks everybody ;)

AggregateException on Cluster.OpenBucket method in Couchbase

I am trying out Couchbase database, I've followed the tutorial here:
http://developer.couchbase.com/documentation/server/4.0/sdks/dotnet-2.2/hello-couchbase.html
I've installed the nugget from Package manager, and started to code. But as I am trying to call Cluster.OpenBucket function I am getting :
An unhandled exception of type 'System.AggregateException' occurred in Couchbase.NetClient.dll
"A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond"
That's my code:
class DbMgr
{
private static readonly Cluster Cluster = new Cluster();
const string BUCKET_NAME = "This-Is-A-Bucket-Name";
public void Init()
{
//This is where I get exception....
using (var bucket = Cluster.OpenBucket(BUCKET_NAME, ""))
{
var document = new Document<dynamic>
{
Id = "Hello",
Content = new
{
name = "Couchbase"
}
};
}
}
}
Any Ideas?

WebSockets in firefox

For implementing my websocket server in C# I'm using Alchemy framework. I'm stuck with this issue. In the method OnReceive when I try to deserialize json object, I get a FormatException:
"Incorrect format of the input string." (maybe it's different in english, but I'm getting a localized exception message and that's my translation :P). What is odd about this is that when I print out the context.DataFrame I get: 111872281.1341000479.1335108793.1335108793.1335108793.1; __ad which is a substring of the cookies sent by the browser: __gutp=entrystamp%3D1288455757%7Csid%3D65a51a83cbf86945d0fd994e15eb94f9%7Cstamp%3D1288456520%7Contime%3D155; __utma=111872281.1341000479.1335108793.1335108793.1335108793.1; __adtaily_ui=cupIiq90q9.
JS code:
// I'm really not doing anything more than this
var ws = new WebSocket("ws://localhost:8080");
C# code:
static void Main(string[] args) {
int port = 8080;
WebSocketServer wsServer = new WebSocketServer(port, IPAddress.Any) {
OnReceive = OnReceive,
OnSend = OnSend,
OnConnect = OnConnect,
OnConnected = OnConnected,
OnDisconnect = OnDisconnect,
TimeOut = new TimeSpan(0, 5, 0)
};
wsServer.Start();
Console.WriteLine("Server started listening on port: " + port + "...");
string command = string.Empty;
while (command != "exit") {
command = Console.ReadLine();
}
Console.WriteLine("Server stopped listening on port: " + port + "...");
wsServer.Stop();
Console.WriteLine("Server exits...");
}
public static void OnReceive(UserContext context) {
string json = "";
dynamic obj;
try {
json = context.DataFrame.ToString();
Console.WriteLine(json);
obj = JsonConvert.DeserializeObject(json);
} catch (Exception e) {
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
return;
}
}
On the C# side I'm using Newtonsoft.Json, though it's not a problem with this library...
EDIT:
One more thing - I browsed through the code in here: https://github.com/Olivine-Labs/Alchemy-Websockets-Example and found nothing - I mean, I'm doing everything the same way authors did in this tutorial...
EDIT:
I was testing the above code in Firefox v 17.0.1, and it didn't work, so I tested it under google chrome, and it works. So let me rephrase the question - what changes can be made in js, so that firefox would not send aforementioned string?
I ran into the same issue - simply replacing
var ws = new WebSocket("ws://localhost:8080");
with
var ws = new WebSocket("ws://127.0.0.1:8080");
fixed the issue for me.
In C# console app I connect the client to the server using :
var aClient = new WebSocketClient(#"ws://127.0.0.1:81/beef");
Your code above is connecting using
var ws = new WebSocket("ws://localhost:8080");
There could be one of two issues -
First is to see if WebSocketClient works instead.
To make sure your url is of the format ws://ur:port/context. This threw me off for a while.

Categories

Resources