Import data to enterprise custom field/look up table - c#

I have a problem. I want to import data from SQL/Excel to lookup table and let enterprise custom field to look it up.
I'm using Microsoft Project 2016 Professional/Online.
I've used C# samples to read tables and their entries. But I'm not able to add to the tables. Maybe someone has suggestions/samples for this kind of problem?
SvcLookupTable.LookupTableDataSet lutDs = new SvcLookupTable.LookupTableDataSet();
LookupEntryCreationInformation creationInfo = new LookupEntryCreationInformation();
LookupEntryValue entryValue = new LookupEntryValue();
Guid entryTableGuid = new Guid("417552b5-7877-e711-80ce-00155d40cd19");
Console.WriteLine("---------------Lookup Tables---------------");
LookupTableCollection lookupTables = projContext.LookupTables;
projContext.Load(lookupTables);
projContext.ExecuteQuery();
entryValue.TextValue = "ITS";
creationInfo.Value = entryValue;
creationInfo.Id = entryTableGuid;
LookupTableCollection lookupTablesColl = projContext.LookupTables;
projContext.Load(lookupTables);
projContext.ExecuteQuery();
int numTables = projContext.LookupTables.Count;
LookupTable lookTable = lookupTables[numTables-1];
Guid rowGuid = new Guid();
foreach (Microsoft.ProjectServer.Client.LookupTable lt in lookupTables)
{
Console.WriteLine(lt.Name + " {" + lt.Id + "}");
ImportLookupTable importTable = new ImportLookupTable();
importTable.AddLookupTableValues(lutDs, rowGuid, rowGuid,"ITS","Skyr");
projContext.Load(lt.Entries);
projContext.ExecuteQuery();
foreach (LookupEntry entry in lt.Entries)
{
Console.WriteLine(" " + entry.FullValue + " {" + entry.Id + "}");
}
}

Related

AWS Athena SDK with C#, how run DDL instructions?

I using the https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Athena/NAthena.html sdk nuget https://github.com/aws/aws-sdk-net/ in order to query S3 bucket files, the thing is I need to create dataCatalog/databases and tables per demand (inside my program), I found a method to create dataCatalogs, but there is no such thing for databases or tables, only query methods. I'm confusing and want to know how can I do such thing.
Indeed there is no specific method for creating databases and tables, for that you will need to use QueryExecution requests
For databases:
var query = $"CREATE DATABASE IF NOT EXISTS DatabaseName " +
"COMMENT 'some comment' " +
"WITH DBPROPERTIES ('creator'='Me', 'Extra.'='some extra info');";
var request = new StartQueryExecutionRequest
{
QueryString = query,
ResultConfiguration = new ResultConfiguration
{
OutputLocation = _settings.DDLOutputLocation
}
};
For tables:
var query = "CREATE EXTERNAL TABLE IF NOT EXISTS " +
"TableName ( " +
"column1 int, " +
"column2 string, " +
"column3 int, " +
"column4 binary) " +
"ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe' " +
$"LOCATION '{_settings.TableDataSourceLocation}'";
var request = new StartQueryExecutionRequest
{
QueryString = query,
QueryExecutionContext = new QueryExecutionContext
{
Catalog = _settings.CatalogName,
Database = _settings.DatabaseName
},
ResultConfiguration = new ResultConfiguration
{
OutputLocation = _settings.DDLOutputLocation
}
};

Discord.Net how to go to the next line in an embed with text formatting?

I've been looking for this but I cannot seem to find the answer.
What I want to accomplish is the following:
Right now when I reply with my embed it shows for example:
footbal,baseball
But what I want it to be is the following:
football,
baseball
Spread over 2 different lines.
Does anyone know how to do this with text Code?
Thank you in advance
Here is the code:
var value = "";
int price = 0;
foreach (var Item in content)
{
value += Item.Item1 + ": " + Item.Item2.ToString();
price += Item.Item2;
}
return new EmbedFieldBuilder()
{
Name = category + " - " + price,
Value = value
};
Worked for me with simple "\n" or Environment.NewLine:
var embed = new EmbedBuilder
{
Author = new EmbedAuthorBuilder() { Name = "AuthorNameHere" },
Title = "Sports",
Color = Color.Orange,
Description = "Football" + "\n\n" + "Baseball"
}.Build();
//var channel = GetYourNeededChannel();
await channel.SendMessageAsync("", false, embed);
Also works with fields in embed:
Fields = new List<EmbedFieldBuilder>()
{
new EmbedFieldBuilder()
{
Name = "TestField1",
Value = "FieldValue1" + "\n\n" + "FieldValue2"
}
}

Youtube Gdata Users Feed Stop Working

I have one application which is gathering the videos from youtube users.
since 3 days it is stopped and not gatehring videos and the only one video in listview is showing the youtube url: "https://www.youtube.com/devicesupport"
I have read that url but still not understand why it is not working. If someone has same issue I will appreciate to help me out.
My code:
private void Get_Video_Of_Searched_User()
{
using (new CWaitCursor())
{
int TotalVideoFound = 0;
string VideoID = string.Empty;
string YouTube_User = this.Txt_Youtube_UserName.Text;
int StartIndex = (Current_Page * 50) + 1;
YouTubeService ytsService = new YouTubeService(strAppName, strKey);
Uri urlEntryUrl = default(Uri);
urlEntryUrl = new Uri("https://gdata.youtube.com/feeds/api/users/" + YouTube_User + "/uploads?&max-results=50&start-index=" + StartIndex.ToString() + "");
FeedQuery fqResults = new FeedQuery();
fqResults.Uri = urlEntryUrl;
Feed<Video> vidFeed = new Feed<Video>(ytsService, fqResults);
try
{
TotalVideoFound = vidFeed.TotalResults;
}
catch
{
MessageBox.Show("Incorrect Username.");
return;
}
if (StartIndex == 1)
Lbl_TotalVideos.Text = "Total Videos: (" + TotalVideoFound.ToString() + ")";
Enable_Disable_Next_And_Previous_Buttons(TotalVideoFound);
SortedDictionary<string, string> ListViewItems = new SortedDictionary<string, string>();
Dict_User_Links_With_Title.Clear();
foreach (Video vidEntry in vidFeed.Entries)
{
if (ListViewItems.ContainsKey(vidEntry.Title) == true) continue;
ListViewItems.Add(vidEntry.Title, vidEntry.ViewCount.ToString());
VideoID = vidEntry.Id;
if (!Dict_User_Links_With_Title.ContainsKey(VideoID.Substring(VideoID.LastIndexOf(":") + 1)))
Dict_User_Links_With_Title.Add(VideoID.Substring(VideoID.LastIndexOf(":") + 1), vidEntry.Title);
}
ListView_User_Video_Links.Items.Clear();
string[] MyListItems = new string[2];
foreach (KeyValuePair<string, string> entry in ListViewItems)
{
MyListItems[0] = entry.Key;
MyListItems[1] = entry.Value;
ListView_User_Video_Links.Items.Add(new ListViewItem(MyListItems));
}
string TotalViews = Get_Youtube_User_Total_Views(YouTube_User);
this.Total_Views_For_User.Text = "Total Views: (" + TotalViews + ")";
}
}
Version 3 of the YouTube Data API has concrete quota numbers listed in the Google API Console where you register for your API Key. You can use 30,000 units/second/user and 50,000,000 per day.
If you hit the limits, Google will stop returning results until your quota is reset.

How do I access a tasks collection on user stories using Rally .NET toolkit?

I get:
Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given
key was not present in the dictionary.
when iterating over user story query results and try to access story["Tasks"]
foreach (var story in queryStoryResults.Results)
{
Console.WriteLine("FormattedID: " + story["FormattedID"]);
Console.WriteLine("Name: " + story["Name"]);
Console.Write("Tasks: " + story["Tasks"]);
}
First, make sure that Tasks are being fetched, along with task specific fields that you want to extract, e.g. State.
Next, a nested loop is needed inside the loop that iterates over user story results.
Here is the code example. It queries on user stories from the current iteration and prints out FormattedID and State of tasks associated with the query results:
namespace RESTexample_storiesFromIteration
{
class Program
{
static void Main(string[] args)
{
//Initialize the REST API
RallyRestApi restApi;
restApi = new RallyRestApi("user#domain.com", "1984", "https://rally1.rallydev.com", "1.43");
//Set our Workspace and Project scopings
String workspaceRef = "/workspace/1111";
String projectRef = "/project/2222";
bool projectScopingUp = false;
bool projectScopingDown = true;
DateTime now = DateTime.Today;
String nowString = now.ToString("yyyy-MM-dd");
Request iterationRequest = new Request("Iteration");
iterationRequest.Workspace = workspaceRef;
iterationRequest.Project = projectRef;
iterationRequest.Fetch = new List<string>()
{
"Name",
"StartDate",
"EndDate",
"Project",
"State"
};
String iterationQueryString = "((StartDate <= \"" + nowString + "\") AND (EndDate >= \"" + nowString + "\"))";
iterationRequest.Query = new Query(iterationQueryString);
QueryResult queryIterationResults = restApi.Query(iterationRequest);
var myIteration = queryIterationResults.Results.First();
var myIterationName = myIteration["Name"];
var myIterationProject = myIteration["Project"];
var myIterationProjectName = myIterationProject["Name"];
Console.WriteLine("Name: " + myIterationName);
Console.WriteLine("Project Ref: " + myIterationProjectName);
Console.WriteLine("State: " + myIteration["State"]);
// Query for Stories
Request storyRequest = new Request("hierarchicalrequirement");
storyRequest.Workspace = workspaceRef;
storyRequest.Project = projectRef;
storyRequest.ProjectScopeUp = projectScopingUp;
storyRequest.ProjectScopeDown = projectScopingDown;
storyRequest.Fetch = new List<string>()
{
"Name",
"ObjectID",
"ScheduleState",
"State",
"FormattedID",
"PlanEstimate",
"Iteration",
"Tasks"
};
storyRequest.Query = new Query("Iteration.Name", Query.Operator.Equals, myIterationName);
QueryResult queryStoryResults = restApi.Query(storyRequest);
foreach (var s in queryStoryResults.Results)
{
Console.WriteLine("----------");
Console.WriteLine("FormattedID: " + s["FormattedID"]);
Console.WriteLine("Name: " + s["Name"]);
Console.WriteLine("PlanEstimate: " + s["PlanEstimate"]);
var tasks = s["Tasks"];
foreach (var t in tasks)
{
Console.WriteLine("Task: " + t["FormattedID"] + " " + t["State"]);
}
}
}
}
}

client.get("me/statuses") returns empty "data" array using C# Facebook SDK 5.0.3

Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get("/me").
But when retrieving the status, I should get aan arraylist "data" with all the status messages according to the facebook Graph API, but instead my data array is empty and I get a 'Index out of bounds' exception.
Does anyone have an idea what my problem could be?
if (Request.Params["code"] != null)
{
var client = new FacebookClient(GetAccessToken());
dynamic me = client.Get("/me");
imgUser.ImageUrl = "https://graph.facebook.com/" + me.id + "/picture";
lblUsername.Text = me.name;
lblHometown.Text = me.hometown.name;
lblBirthday.Text = me.birthday;
lblCurrenttown.Text = me.location.name;
lblEmail.Text = me.email;
lblOpleidingen.Text = "";
lblOpleidingen.Text += me.education[1].type + ": " + me.education[1].school.name + ", " + me.education[1].year.name + "<br />"
+ me.education[0].type + ": " + me.education[0].school.name + ", " + me.education[0].year.name;
lblSex.Text = me.gender;
dynamic status = client.get("/me/statuses");
txtStatus.Text = status.data[0].message;
}
It requires the read_stream permission. Ensure you have it.
Your permission array should look like follows:
string[] extendedPermissions = new[] { "user_about_me", "read_stream" };
if (extendedPermissions != null && extendedPermissions.Length > 0)
{
var scope = new StringBuilder();
scope.Append(string.Join(",", extendedPermissions));
parameters["scope"] = scope.ToString();
}
furthermore your second get() should be capitalized: Get()
dynamic status = client.get("/me/statuses");
dynamic status = client.Get("/me/statuses");

Categories