MPXJ C# MSPID: Mark task as done (100% complete) [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
We're using the C# version of MPXJ, but rather than examining an existing Project file we're using it to produce a new file purely from code (extracting data from a third party system) for import to Project via MSPDIWriter.
The goal is to have Tasks that report as completed in the other system show up with 100% completion and the ✔ checkmark next to them on the Gantt view when the XML is loaded in Project. This is working as expected only when the total Duration assigned to a task is zero days; for any other duration when Project opens the Task's percentage complete is set to 0%.
Our devs aren't Project people, so it's not clear to us which properties will affect this behaviour:
Task childTask = parent.AddTask();
childTask.Name = sourceItem.Title;
Duration duration = Duration.getInstance(sourceItem.Days, TimeUnit.DAYS);
childTask.PercentageComplete = new java.lang.Integer(childItem.PercentageComplete);
childTask.PercentageWorkComplete = childTask.PercentageComplete;
ResourceAssignment assignment = childTask.AddResourceAssignment(resource);
assignment.Work = duration;
assignment.RemainingWork = duration;
assignment.percentageWorkComplete = childTask.PercentageComplete;
childTask.EffortDriven = false;
childTask.Priority = childItem.Priority;
childTask.Duration = duration;
childTask.BaselineDuration = duration;
if (childItem.PercentComplete == 100)
{
childTask.RemainingWork = Duration.getInstance(0, TimeUnit.DAYS);
}

This sample code works through the steps to create a file from scratch with various combinations of un-started, partially complete, and completed tasks both with and without resource assignments. There is a C# version but I must admit that I haven't kept the two in line. The Java version is probably the more complete, hopefully it should be fairly straightforward to get a working C# version.
I'd suggest starting with these samples and generate MSPDI files from them first, verifying that you get the expected result when the files are imported into MS Project. Hopefully you'll then be able to update your code based on the approach taken in the sample files.
One thing to watch for is that there were some improvements made recently to MSPDI generation relating to getting percent complete to appear correctly so it would be worth verifying that you are working with the most recent version of MPXJ (7.9.2 at the time of writing).

Related

Better way than playerprefs? [duplicate]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I was wondering... What's the best way to save data in Unity games. JSONs? If so, how? Thanks
Here are some of the different Ways and Methods to Save data for Unity Projects:
Platform-Independent: One way of saving data in Unity3D in a Platform-independent way is to use the PlayerPrefs class. PlayerPrefs is a static class and it is very easy to use but not reliable.
PERSISTENCE - SAVING AND LOADING DATA using DontDestroyOnLoad, PlayerPrefs, and data serialization Video Tutorial by unity.
Server Side: You can also use a Server for saving data (like a combination of PHP and MySQL Database). You can use it to save Score Data, user profiles, inventory, etc., Learn More From Unity Wiki. You can also use third-party solutions like firebase etc.
For saving the in-game data to a Hard drive in a format that can be understood and loaded later on, use a .NET/Mono feature known as Serialization. Learn More
Simple JSON guide about Unity is available at Unity Wiki or officially you can see JSON serialization
SQLite (an embedded database for your app) is another great option for you to get the Free Package, it is simple and easy (and my favorite) if you know SQL.
Scriptable Object: it's a data container. Useful for unchanging data. Suitable for large unchanging data and amazingly reduce your project's memory.
The above is taken from my blog post on Data Saving Techniques for Unity3d Applications.
You can use many assets that are available for free and paid in asset store.
Save Game Free - XML and JSON saving and loading.
Syntax:
Saver.Save<T> (T data, string fileName);
Example:
Saver.Save<MyData> (myData, "myData"); // The .json extension will be added automatically
Save Game Pro - Binary saving and loading. fast and secure. Easy to use.
Syntax:
SaveGame.Save<T> (T data, string identifier);
Example:
SaveGame.Save<int> (score, "score");
If you want to store your data in server there is a simple way with PHP and MySQL. What you have to do is:
STEP 1:
Get what ever data you want from your server just in single string (code is below):
<?php
//SERVER CONNECTION
$server_name = "localhost";
$server_user = "Er.Ellison";
$server_pass = "supersecretPassword";
$server_db = "game_test_db";
$connection = new mysqli($server_name , $server_user , $server_pass , $server_db);
if(!$connection) {
die("Connection failed !" . mysqli_connect_error());
}
// QUERY
$query = "SELECT * FROM items";
$result = mysqli_query($connection , $query);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)){
echo "id:" . $row['id'] . "|username:" . $row['username'] . "|type:" . $row['type'] . "|score:" . $row['score'] . ";";
}
}
?>
And note that you MUST SEPARATE ANY string you want with a ; or any thing that you are comfortable with that and remember that we going to use it in C# in Unity.
STEP 2:
Now you should get the data from your web like this (it will be a long string):
STEP 3:
Now go to the Unity and create a C# script and attached that to what ever object in your scene and open the script up, then use this kind of code to manipulate the data that you retrieved from your database:
public class DataLoader : MonoBehaviour {
public string[] items;
// Use this for initialization
IEnumerator Start () {
WWW itemsData = new WWW ("http://localhost/_game/test/itemsdata.php");
yield return itemsData;
string itemsDataStrign = itemsData.text;
print (itemsDataStrign);
items = itemsDataStrign.Split (';');
print (GetDataValue(items[0] , "cost:"));
}
string GetDataValue(string data, string index) {
string value = data.Substring (data.IndexOf(index) + index.Length);
if (value.Contains ("|")) {
value = value.Remove (value.IndexOf("|"));
}
return value;
}
}
STEP 4:
You just NOW retrieved data from database, check the image from unity console:
I made this for who that may be, like me, stuck in database problems!

C# library to generate ICal (ics) files [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Is there any API that I can use and post event data to (for example with querystrings) and get back a file that the visitor can download and add to his calender?
I can of course write the script myself, but if there is a open API I could save some time.
You could use iCal4j
You asked for a webservice of some sort, and I do not know of one, but if you are using .NET, you can create your own using this library:
http://www.codeproject.com/KB/vb/vcalendar.aspx
Maybe it's an option for you to generate and send an e-mail to the user containing the appointments you want the to add. By doing this you:
Haven't jo use any API
Use the build in auto-parsing feature of Apple Mail (Mac OS & iOS)
Stay compatible to other users which might not use iCal
I just used DDay.iCal which works fine for C#. You can see some documentation here on how to read/parse from an .ics file, and this is what i used to create a new file, checked it works on Outlook and on the iOS email application:
public static string GetCalendarAsString(string subject, DateTime start, DateTime end,
string location, string timeZoneName)
{
var calendar = new iCalendar();
var timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneName);
calendar.AddTimeZone(iCalTimeZone.FromSystemTimeZone(timeZone));
var evt = new Event
{
Start = new iCalDateTime(start),
End = new iCalDateTime(end),
Location = location,
Summary = subject,
IsAllDay = false
};
calendar.Events.Add(evt);
var serializer = new iCalendarSerializer();
return serializer.SerializeToString(calendar);
}
you can use several other properties, although I only needed these
You can download iCal4J using http://sourceforge.net/projects/ical4j/files/iCal4j/1.0/ical4j-1.0.zip/download

How can I load kongregate chat in my webbrowser? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have a simple program, and I am trying to load the kongregate chat into a WebBrowser, but it is not working...
When I first start it up, it navigates to a game, and then it gives me 4 Script Error, and the chat just sits there saying: "Joining room...". I don't think it is a problem with the browser settings, because it works on internet explorer. Is there something that is messed up with my WebBrowser? I have let it sit there for a few minutes, and it still does not work. I have set the suppressScriptErrors to true and false, and it still does not fix it.
FYI: I am not doing anything bad with my program, like cheating, or spamming, or anything like that, I just want the webpage to show up, and sometimes I like to be able to have things copied, so I put a few TextBoxes to the right of it, so I can paste it into chat, if I won't to post a few things...
This article has the solution to your problem. It appears that the WebBrowser control in Visual Studio launches in IE7 mode by default. That's why you get javescript errors with the control but, not in your browser. I highly suggest you read the article linked that the top. Luckily, there is a fix. The following code was taken from another stackoverflow answer to a question that indirectly addresses your issue. Here is that link, and here is the code.
string installkey = #"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
string entryLabel = Path.GetFileName(Application.ExecutablePath);
System.OperatingSystem osInfo = System.Environment.OSVersion;
string version = osInfo.Version.Major.ToString() + '.' + osInfo.Version.Minor.ToString();
uint editFlag = (uint)((version == "6.2") ? 0x2710 : 0x2328); // 6.2 = Windows 8 and therefore IE10
RegistryKey existingSubKey = Registry.LocalMachine.OpenSubKey(installkey, false); // readonly key
if (existingSubKey == null) {
existingSubKey = Registry.LocalMachine.CreateSubKey(installkey, RegistryKeyPermissionCheck.Default); // readonly key
}
if (existingSubKey.GetValue(entryLabel) == null) {
existingSubKey = Registry.LocalMachine.OpenSubKey(installkey, true); // writable key
existingSubKey.SetValue(entryLabel, unchecked((int)editFlag), RegistryValueKind.DWord);
}
Also, the article I mentioned up top says that you should create an entry for the VS host process for your app too or it won't work in debug mode. Good luck and I hope this solves your issue!

C# code completion with NRefactory 5

I just found out about NRefactory 5 and I would guess, that it is the most suitable solution for my current problem. At the moment I'm developing a little C# scripting application for which I would like to provide code completion. Until recently I've done this using the "Roslyn" project from Microsoft. But as the latest update of this project requires .Net Framework 4.5 I can't use this any more as I would like the app to run under Win XP as well. So I have to switch to another technology here.
My problem is not the compilation stuff. This can be done, with some more effort, by .Net CodeDomProvider as well. The problem ist the code completion stuff. As far as I know, NRefactory 5 provides everything that is required to provide code completion (parser, type system etc.) but I just can't figure out how to use it. I took a look at SharpDevelop source code but they don't use NRefactory 5 for code completion there, they only use it as decompiler. As I couldn't find an example on how to use it for code completion in the net as well I thought that I might find some help here.
The situation is as follows. I have one single file containing the script code. Actually it is not even a file but a string which I get from the editor control (by the way: I'm using AvalonEdit for this. Great editor!) and some assemblies that needs to get referenced. So, no solution files, no project files etc. just one string of source code and the assemblies.
I've taken a look at the Demo that comes with NRefactory 5 and the article on code project and got up with something like this:
var unresolvedTypeSystem = syntaxTree.ToTypeSystem();
IProjectContent pc = new CSharpProjectContent();
// Add parsed files to the type system
pc = pc.AddOrUpdateFiles(unresolvedTypeSystem);
// Add referenced assemblies:
pc = pc.AddAssemblyReferences(new CecilLoader().LoadAssemblyFile(
System.Reflection.Assembly.GetAssembly(typeof(Object)).Location));
My problem is that I have no clue on how to go on. I'm not even sure if it is the right approach to accomplish my goal. How to use the CSharpCompletionEngine? What else is required? etc. You see there are many things that are very unclear at the moment and I hope you can bring some light into this.
Thank you all very much in advance!
I've just compiled and example project that does C# code completion with AvalonEdit and NRefactory.
It can be found on Github here.
Take a look at method ICSharpCode.NRefactory.CSharp.CodeCompletion.CreateEngine. You need to create an instance of CSharpCompletionEngine and pass in the correct document and the resolvers. I managed to get it working for CTRL+Space compltition scenario. However I am having troubles with references to types that are in other namespaces. It looks like CSharpTypeResolveContext does not take into account the using namespace statements - If I resolve the references with CSharpAstResolver, they are resolved OK, but I am unable to correctly use this resolver in code completition scenario...
UPDATE #1:
I've just managed to get the working by obtaining resolver from unresolved fail.
Here is the snippet:
var mb = new DefaultCompletionContextProvider(doc, unresolvedFile);
var resolver3 = unresolvedFile.GetResolver(cmp, loc); // get the resolver from unresolvedFile
var engine = new CSharpCompletionEngine(doc, mb, new CodeCompletionBugTests.TestFactory(resolver3), pctx, resolver3.CurrentTypeResolveContext );
Update #2:
Here is the complete method. It references classes from unit test projects, sou you would need to reference/copy them into your project:
public static IEnumerable<ICompletionData> DoCodeComplete(string editorText, int offset) // not the best way to put in the whole string every time
{
var doc = new ReadOnlyDocument(editorText);
var location = doc.GetLocation(offset);
string parsedText = editorText; // TODO: Why there are different values in test cases?
var syntaxTree = new CSharpParser().Parse(parsedText, "program.cs");
syntaxTree.Freeze();
var unresolvedFile = syntaxTree.ToTypeSystem();
var mb = new DefaultCompletionContextProvider(doc, unresolvedFile);
IProjectContent pctx = new CSharpProjectContent();
var refs = new List<IUnresolvedAssembly> { mscorlib.Value, systemCore.Value, systemAssembly.Value};
pctx = pctx.AddAssemblyReferences(refs);
pctx = pctx.AddOrUpdateFiles(unresolvedFile);
var cmp = pctx.CreateCompilation();
var resolver3 = unresolvedFile.GetResolver(cmp, location);
var engine = new CSharpCompletionEngine(doc, mb, new CodeCompletionBugTests.TestFactory(resolver3), pctx, resolver3.CurrentTypeResolveContext );
engine.EolMarker = Environment.NewLine;
engine.FormattingPolicy = FormattingOptionsFactory.CreateMono();
var data = engine.GetCompletionData(offset, controlSpace: false);
return data;
}
}
Hope it helps,
Matra
NRefactory 5 is being used in SharpDevelop 5. The source code for SharpDevelop 5 is currently available in the newNR branch on github. I would take a look at the CSharpCompletionBinding class which has code to display a completion list window using information from NRefactory's CSharpCompletionEngine.

Performance Testing Windows/Desktop based Application [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
We have a Windows based Client-Server Application where the Server is located in a Remote Location and it is being accessed from Clients located at another place, the Database used for this SQL Server.
I would like to do a Performance Test of this Application how can I do that ? Is there a tool available for the same ?
Please suggest
Let's talk about your requirements: You note a performance test, what are your core critical measures of success or failure? Do you have a load profile for your application with the business functions, the number of users and their frequency of occurrence? Typically log files or changes in records within the database can provide an objective measure of frequency of business actions.
The issue of requirements goes directly to your inquiry on performance. Are you interested in the difference of network response time from location a to location b, the time for the sql conversation to complete from a to b, or the end user response time at the same? Is this to be measured under load, or only for a single instance at this distant location? How are you factoring in the uncontrolled element of the complex network between the location of the remote client and the server, for this impacts test reproducibility to a very high degree? Or, is it simply enough to take a 'sniffer' trace for a view of time to last byte of request to time to first/last byte of response for some number of samples over time?
Depending upon your requirements different tools are likely to be called for, from passive tools such as a protocol analyzer, to active test tools for network, for database transactions or even for driving the front end client.
I like HP's Performace Center for this.
I'm sure there are others
You can run a performance monitor on the server. Just add appropriate counters to it (SQLServer.Transactions, etc). Also you can save collected info to log-files.
Check this link for details: Understanding SQL Performance Counters
Also you can integrate PerfCounters into your app. Read this: Performance Counters in the .NET Framework
Here is simple example how you can add PerfCounters to your app:
string category = "My Category", counter = "My Counter";
if (!PerformanceCounterCategory.Exists(category))
{
var ccd = new CounterCreationData(counter, "", PerformanceCounterType.NumberOfItems32);
var ccdcol = new CounterCreationDataCollection() { ccd };
PerformanceCounterCategory.Create(category, "", PerformanceCounterCategoryType.SingleInstance, ccdcol);
}
//else
// PerformanceCounterCategory.Delete(category);
var pc = new PerformanceCounter(category, counter, false) { MachineName = ".", RawValue = 0 };
for (int i = 0; i < 10; i++)
{
pc.RawValue = i;
Thread.Sleep(1000);
}

Categories

Resources