I am trying to retrieve data from my smartsheet using SmartsheetClient. But when I try to access comments against a row, the comments are null. Following is my code:
string accessToken = "accesstokenvalue";
long sheetId = 121212221;
SmartsheetClient smartSheetClient = new SmartsheetBuilder().SetAccessToken(accessToken).Build();
IEnumerable<SheetLevelInclusion> inclusion = new SheetLevelInclusion[] { SheetLevelInclusion.ATTACHMENTS, SheetLevelInclusion.COLUMN_TYPE, SheetLevelInclusion.OBJECT_VALUE, SheetLevelInclusion.ROW_WRITER_INFO, SheetLevelInclusion.CONTACT_REFERENCES, SheetLevelInclusion.CROSS_SHEET_REFERENCES, SheetLevelInclusion.DISCUSSIONS, SheetLevelInclusion.FILTERS, SheetLevelInclusion.FILTER_DEFINITIONS, SheetLevelInclusion.FORMAT, SheetLevelInclusion.OWNER_INFO, SheetLevelInclusion.ROW_PERMALINK, SheetLevelInclusion.ROW_WRITER_INFO, SheetLevelInclusion.SOURCE };
Sheet sheet = smartSheetClient.SheetResources.GetSheet(sheetId, inclusion, null, null, null, null, null, null);
Reference Image:
Thanks
I could be wrong but I believe you'll have to list discussions on the row for that:
PaginatedResult<Discussion> discussions = smartsheet.SheetResources.RowResources.DiscussionResources.ListDiscussions(sheetId, sheet1.Rows[0].Id.Value, new DiscussionInclusion[] { DiscussionInclusion.COMMENTS }, null);
Related
I am Trying to launch the detail page of directory contacts(Some organigation contacts) with contact id. for local contacts it is working fine but not working for organigation contacts.
Here is my code. (name is contact name ,idstr is directory id )
lookupByName = ContactsContract.Contacts.CONTENT_FILTER_URI.buildUpon().appendEncodedPath(name)
.appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, idStr).build();
mCursor = mContext.getContentResolver().query(lookupByName, new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME, ContactsContract.PhoneLookup._ID}, null, null, null);
if (mCursor.moveToFirst()) {
idPhone =
Long.valueOf(mCursor.getString(
mCursor.getColumnIndex(ContactsContract.PhoneLookup._ID)));
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(ContentUris.
withAppendedId(ContactsContract.Contacts.CONTENT_URI, idPhone ));
startActivity(intent);
Please help me.
Thanks in advance.
This is tricky, but managed to get it working
You need to get the contact's LOOKUP_KEY, build a LookupUri from it, append the DIRECTORY_PARAM_KEY to the LookupUri, and put that in the intent's setData.
String name = "hello";
String directoryId = "5"
Uri uri = Contacts.CONTENT_FILTER_URI.buildUpon().appendPath(name).appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, directoryId).build();
String[] projection = new String[]{Contacts._ID, Contacts.DISPLAY_NAME, Contacts.LOOKUP_KEY};
Cursor cur = getContentResolver().query(uri, projection, null, null, null);
DatabaseUtils.dumpCursor(cur); // debug
// add some safety checks first obviously...
cur.moveToFirst();
String lookup = cur.getString(2);
Uri lookupUri = Contacts.getLookupUri(cur.getLong(0), lookup).buildUpon().appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, directoryId).build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(lookupUri);
startActivity(intent);
public void refresh()
{
ContentResolver contentResolver = getContentResolver();
Cursor smsInboxCursor = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null, null, null);
int indexBody = smsInboxCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
int indexAddress = smsInboxCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
if (indexBody < 0 || !smsInboxCursor.moveToFirst()) return;
arrayAdapter.clear();
do {
String str = smsInboxCursor.getString(indexBody) +
"\n" + smsInboxCursor.getString(indexAddress) + "\n";
arrayAdapter.add(str);
} while (smsInboxCursor.moveToNext());
}
in the above mentioned code, I want to display my mobile contact names with contact number in listview by using ArrayAdapter. now I obtain the solution in unsorted manner. But I want to display my contacts in sorted order. Can any one help me...
Easiest way to do that is to specify the sort order as part of your database query. Like so:
Cursor smsInboxCursor = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
You can use SQLite's ORDER BY syntax here.
Alternatively, you can use Collections.sort to sort your array directly.
I am using the edmgen.exe tool like this:
"%windir%\Microsoft.NET\Framework\v4.0.30319\edmgen.exe" /mode:fullgeneration
/c:"Data Source=%datasourceserver%; Initial Catalog=School; Integrated Security=SSPI"
/project:School /entitycontainer:SchoolEntities /namespace:SchoolModel /language:CSharp
above code includes the views in the ef model. I don't want any views to be included, similar to screenshot below. How can this be done?
Looks like there is no way to do this using edmgen. Using reflector, I found that edmgen uses System.Data.Entity.Design.dll to do its work, and you can exclude the db views & functions programatically like this:
var essg = new EntityStoreSchemaGenerator("System.Data.SqlClient", ConfigurationManager.ConnectionStrings["MST"].ConnectionString, "EFModel");
essg.GenerateForeignKeyProperties = true;
var filter1 = new EntityStoreSchemaFilterEntry(null, null, null, EntityStoreSchemaFilterObjectTypes.Table, EntityStoreSchemaFilterEffect.Allow);
var filter2 = new EntityStoreSchemaFilterEntry(null, null, null, EntityStoreSchemaFilterObjectTypes.View, EntityStoreSchemaFilterEffect.Exclude);
var filter3 = new EntityStoreSchemaFilterEntry(null, null, null, EntityStoreSchemaFilterObjectTypes.Function, EntityStoreSchemaFilterEffect.Exclude);
var filters = new EntityStoreSchemaFilterEntry[] { filter1, filter2, filter3 };
var errors1 = essg.GenerateStoreMetadata(filters);
I'm trying to call a stored procedure from EntityFramework which uses Table-value parameter.
But when I try to do function import I keep getting a warning message saying -
The function 'InsertPerson' has a parameter 'InsertPerson_TVP' at
parameter index 0 that has a data type 'table type' which is currently
not supported for the target .NET Framework version. The function was
excluded.
I did a initial search here and found few posts which says It's possible in EntityFrameWork with some work arounds and few saying it's not supported in current versions.
Does any one know a better approach or solution for this problem?
I ended up doing this, Please note we are working on EF DataContext(not ObjectContext)
Executing a Stored procedure with output parameter
using (DataContext context = new DataContext())
{
////Create table value parameter
DataTable dt = new DataTable();
dt.Columns.Add("Displayname");
dt.Columns.Add("FirstName");
dt.Columns.Add("LastName");
dt.Columns.Add("TimeStamp");
DataRow dr = dt.NewRow();
dr["Displayname"] = "DisplayName";
dr["FirstName"] = "FirstName";
dr["LastName"] ="LastName";
dr["TimeStamp"] = "TimeStamp";
dt.Rows.Add(dr);
////Use DbType.Structured for TVP
var userdetails = new SqlParameter("UserDetails", SqlDbType.Structured);
userdetails.Value = dt;
userdetails.TypeName = "UserType";
////Parameter for SP output
var result = new SqlParameter("ResultList", SqlDbType.NVarChar, 4000);
result.Direction = ParameterDirection.Output;
context.Database.ExecuteSqlCommand("EXEC UserImport #UserDetails, #ResultList OUTPUT", userdetails, result);
return result == null ? string.Empty : result.Value.ToString();
}
My Table-Value-Parameter (UDT Table) script looks like this:
CREATE TYPE [dbo].[UserType] AS TABLE (
[DisplayName] NVARCHAR (256) NULL,
[FirstName] NVARCHAR (256) NULL,
[LastName] NVARCHAR (256) NULL,
[TimeStamp] DATETIME NULL
)
And my store procedure begins like
CREATE PROCEDURE UserImport
-- Add the parameters for the stored procedure here
#UserDetails UserType Readonly,
#ResultList NVARCHAR(MAX) output
AS
For Stored procedure without output parameter we don't need any ouput parameter added/passed to SP.
Hope it helps some one.
Perhaps we could also consider the SqlQuery method:
[Invoke]
public SomeResultType GetResult(List<int> someIdList)
{
var idTbl = new DataTable();
idTbl.Columns.Add("Some_ID");
someIdList.ForEach(id => idTbl.Rows.Add(id));
var idParam = new SqlParamter("SomeParamName", SqlDbType.Structured);
idParam.TypeName = "SomeTBVType";
idParam.Value = idTbl;
// Return type will be IEnumerable<T>
var result = DbContext.Database.SqlQuery<SomeResultType>("EXEC SomeSPName, #SomeParamName", idParam);
// We can enumerate the result...
var enu = result.GetEnumerator();
if (!enu.MoveNext()) return null;
return enu.Current;
}
var detailTbl = new DataTable();
detailTbl.Columns.Add("DetailID");
detailTbl.Columns.Add("Qty");
txnDetails.ForEach(detail => detailTbl.Rows.Add(detail.DetailID, detail.Qty));
var userIdParam = new System.Data.SqlClient.SqlParameter("#UserID", SqlDbType.Int);
userIdParam.Value = 1;
var detailParam = new System.Data.SqlClient.SqlParameter("#Details", SqlDbType.Structured);
detailParam.TypeName = "DetailUpdate";
detailParam.Value = detailTbl;
var txnTypeParam = new System.Data.SqlClient.SqlParameter("#TransactionType", SqlDbType.VarChar);
txnTypeParam.Value = txnType;
var result = await db.Database.ExecuteSqlCommandAsync("MySP #UserID, #Details, #TransactionType", userIdParam, detailParam, txnTypeParam);
if(result >= 0)
return StatusCode(HttpStatusCode.OK);
else
return StatusCode(HttpStatusCode.InternalServerError);
I can't find how to get all the todos of a calendar in Lightning. I thought the functions getItem() and getItems() from the calICalendar Interface (here) were the solution but I could not make it work properly.
You are going in the right direction. You just need to pass the flag that you want todos only. An example can be found here.
To elaborate more on your example below, there are a few syntax errors and you might need different flags. I'm not sure why the alert is needed, that sounds to me like the event loop is not being spun. In what context are you calling these bits?
Try this:
var arrayItems = new Array();
var todoListener = {
onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {},
onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
arrayItems = arrayItems.concat(aItems);
}
};
var filter = aCalendar.ITEM_FILTER_TYPE_TODO | aCalendar.ITEM_FILTER_COMPLETED_ALL;
aCalendar.getItems(filter, 0, null, null, todoListener);
Thanks to your example, I understood how to implement the listener which was my main problem.
So here what I code :
var arrayItem = new Array; ;
var todoListener =
{
onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {},
onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems)
{
for (let i=0; i < aCount; i++)
{
arrayItem.push(aItems[i]);
}
}
};
var filter = aCalendar.ITEM_FILTER_ALL_ITEMS;
filter |= aCalendar.ITEM_FILTER_TYPE_TODO;
aCalendar.getItems(filter, 0, null, null, todoListener);
However, I have a really weird issue here. Actually, I do not get the todos with this code. I have to add an alert("something"); after the getItems() method to get my arrayItem filled up. Else, it is empty.