I can't get my group , in create the campaigns
var campaign = Manager.Campaigns.AddAsync(new Campaign
{
Settings = _campaignSettings,
Recipients = new Recipient
{
ListId = ListID,
SegmentOptions = new SegmentOptions
{
Match = Match.Any,
Conditions = new List<Condition>
{
new Condition{Type=ConditionType.Interests ,Field = "interests-bfb01be5fa",Operator = Operator.InterestContains, Value = "5cde411d26" }
}
}
},
Type = CampaignType.Regular,
}).Result;
The Picture group doesn't select:
The Picture i manually selected the group:
I have a answer .
It work after changed the value
Value = new Dictionary<int , string>{ { 1 , "5cde411d26" } } } // If Have two group , can be 2 , "Group ID"
Related
I try add subscription method to my project where customer can subscription product from other user. But i have problem because when i use it:
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "subscription",
SuccessUrl = "https://example.com/success",
CancelUrl = "https://example.com/cancel",
PaymentIntentData = new SessionPaymentIntentDataOptions
{
ApplicationFeeAmount = 123,
},
};
var requestOptions = new RequestOptions
{
StripeAccount = "{{CONNECTED_ACCOUNT_ID}}",
};
var service = new SessionService();
Session session = service.Create(options, requestOptions);
But I have error „You can not pass payment_intent_data in subscription mode".
Can i add application fee amount with linked account to subscription? Is payment usually the only option?
PS. I create my product like this:
var options = new ProductCreateOptions
{
Name = "new product",
DefaultPriceData = new ProductDefaultPriceDataOptions
{
UnitAmount = price,
Currency = "pln"
},
Expand = new List<string> { "default_price" }
};
var requestOptions = new RequestOptions
{
StripeAccount = stripeAccountId,
};
_productService.Create(options, requestOptions);
You'd use https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-application_fee_percent instead.
var options = new Stripe.Checkout.SessionCreateOptions
{
...
SubscriptionData = new Stripe.Checkout.SessionSubscriptionDataOptions
{
ApplicationFeePercent = 10
},
};
...
I want to return the List of records with Id and name, where the name will be appended with the domain as name(domain) if the names are non-unique and it will again append with code if domain is also non-unique, such as name(domain)(code).
To be Clear
name - for unique names,
name(domain) - for duplicated names
name(domain)(code) - for duplicated codes.
Below are the sample data and expected data
**Sample Data**
var filter = new List<Record>()
{
new Record { Id = 011, Name = "OAKLAWN", Code = 123, Domain = "p1000"},
new Record { Id = 012, Name = "OAKLAWN", Code = 124 , Domain = "p2000"},
new Record { Id = 013, Name = "OAKLAWN", Code = 125 , Domain = "p3000"},
new Record { Id = 014, Name = "OAKLAWN", Code = 126 , Domain = "p4000"},
new Record { Id = 015, Name = "OAKLAWN", Code = 127 , Domain = "p5000"},
new Record { Id = 016, Name = "PEAKLAWN", Code = 111 , Domain = "p6000"},
new Record { Id = 017, Name = "PERKLAWN", Code = 124 , Domain = "p6000"},
new Record { Id = 018, Name = "QUCKLAWN", Code = 122 , Domain = "p6000"}
};
**expected return data**
{ Id = 011, Name = "OAKLAWN(p1000)"},
{ Id = 012, Name = "OAKLAWN(p2000)(124)"},
{ Id = 013, Name = "OAKLAWN(p3000)"},
{ Id = 014, Name = "OAKLAWN(p2000)(126)"},
{ Id = 015, Name = "OAKLAWN(p5000)"},
{ Id = 016, Name = "PEAKLAWN"},
{ Id = 017, Name = "PERKLAWN"},
{ Id = 018, Name = "QUCKLAWN"}
How can I achieve this using c# LINQ.
.NET fiddle: https://dotnetfiddle.net/2UdaxY
Thanks.
var records = filter.GroupBy(
r => r.Name,
(key, group) => group.Select(r => new
{
r.Id,
Name = group.Count() == 1
? key
: group.Count(x => x.Domain == r.Domain) == 1
? $"{key}({r.Domain})"
: $"{key}({r.Domain})({r.Code})"
})
)
.SelectMany(r => r)
.ToArray();
.NET fiddle: https://dotnetfiddle.net/tIPZOR
I am trying to populate a DropDownList based on roles. I have a view in SQL with the value and text of each item based on the user role (Windows Auth) and can populate the DropDownList if a user was in all roles with:
using (var db=new GPSE_2.DAL.GPSE2Entities())
{
var locations = (from loc in db.LocationLOBViews
orderby loc.LocationNumber
select new { loc.DataValue, loc.DataText});
ddlShops.DataValueField = "DataValue" ;
ddlShops.DataTextField = "DataText";
ddlShops.DataSource = locations.ToList();
DataBind();
}
I would like to add items only the logged in user is a member of. Users can be in multiple groups(roles).
For instance, the logged in user is in a group called Location 01 LOB 100 and they are also in a group called Location 01 LOB 200 and also in Location o2 LOB 100. Only those options should appear in the DropDownList.
I was able to loop through the roles the user is in by the code below.
string UPN = UserPrincipal.Current.UserPrincipalName.ToString();
WindowsIdentity wi = new WindowsIdentity(UPN);
string GroupName;
foreach (IdentityReference group in wi.Groups)
{
GroupName = group.Translate(typeof(NTAccount)).ToString();
if (GroupName.Contains("Location 01 LOB 100"))
{
var item = new ListItem
{
Text = "Location 01 LOB 100",
Value = "01,100"
};
ddlShops.Items.Add(item);
}
}
Now I am trying to combine the 2 I ran into problems adding loc.DataValue and the loc.DataText to the DDL if the query returns results. This is where I an stuck, it adds the string in the quotes instead of the values.
using (var db = new GPSE_2.DAL.GPSE2Entities())
{
string UPN = UserPrincipal.Current.UserPrincipalName.ToString();
WindowsIdentity wi = new WindowsIdentity(UPN);
string GroupName;
foreach (IdentityReference group in wi.Groups)
{
GroupName = group.Translate(typeof(NTAccount)).ToString();
var locations = (from loc in db.LocationLOBViews
where loc.DataValue.Contains(GroupName)
orderby loc.LocationNumber
select new { loc.DataValue, loc.DataText });
if (locations !=null)
{
var item = new ListItem
{
Text = "DataText",
Value = "DataValue"
};
ddlShops.Items.Add(item);
}
}
}
Thanks,
-Doug
I got it working by creating a list of groups the user is in and then populating the Drop Down List with the appropriate information.
private List<string> GetGroups()
{
string UPN = UserPrincipal.Current.UserPrincipalName.ToString();
List<string> result = new List<string>();
WindowsIdentity wi = new WindowsIdentity(UPN);
foreach (IdentityReference group in wi.Groups)
{
string GroupName = group.Translate(typeof(NTAccount)).ToString();
//if text location and lob is in the name add to results
if (GroupName.Contains("Location") && GroupName.Contains("LOB"))
{
string DataValue1 = GroupName.Substring(GroupName.Length - 3);
string DataValue2 = GroupName.Substring(GroupName.Length - 10, 2);
string DataValue = DataValue2 + "," + DataValue1;
result.Add(DataValue);
}
}
result.Sort();
return result;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
using (var db = new GPSE2Entities())
{
for (int i = 0; i < GetGroups().ToArray().Length; i++)
{
string DataValue = GetGroups().ToArray()[i].ToString();
var locations = (from loc in db.LocationLOBViews
where loc.DataValue == DataValue
orderby loc.LocationNumber
select loc).FirstOrDefault();
if (locations != null)
{
var item = new ListItem
{
Text = locations.DataText,
Value = locations.DataValue
};
ddlShops.Items.Add(item);
}
}
}
ddlShops.Items.Insert(0, "--Select Location and LOB--");
}
}
I am trying to use AWS SDK for .NET Core.
Create a table to count views on videos.
Add a view count for a day.
Increment existing count for a day.
Query for video counts between two dates for a video.
.NET Core AWS SDK uses Async methods which are not documented in AWS. There is a feature request on their github page for this to happen.... but it is dated from last year. (https://github.com/aws/aws-sdk-net/issues/787)
CREATE THE TABLE
This works and creates a table on the AWS Console.
var ctRequest = new CreateTableRequest
{
AttributeDefinitions = new List<AttributeDefinition>()
{
new AttributeDefinition
{
AttributeName = "ViewUid",
AttributeType = ScalarAttributeType.S
},
new AttributeDefinition
{
AttributeName = "ViewDate",
AttributeType = ScalarAttributeType.S
}
},
KeySchema = new List<KeySchemaElement>
{
new KeySchemaElement
{
AttributeName = "ViewUid",
KeyType = KeyType.HASH //Partition key
},
new KeySchemaElement
{
AttributeName = "ViewDate",
KeyType = KeyType.RANGE
}
},
ProvisionedThroughput = new ProvisionedThroughput
{
ReadCapacityUnits = 5,
WriteCapacityUnits = 6
},
TableName = _settings.AWSDynamoDBViewCountTable
};
var response = _client.CreateTableAsync(ctRequest).Result;
UPDATE AND ITEM WITH AUTO-INCREMENT A FIELD
This, sadly, is where i hit issues. The old docs are found here under the Atomic Counter section. (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LowLevelDotNetItemCRUD.html)
Invalid ConditionExpression: Syntax error; token: \"SET\", near: \"SET
VC\"
var viewData = new Document();
viewData["ViewUid"] = videoUid; //Table entry UID
viewData["VideoId"] = videoId; // Video ID
viewData["ViewDate"] = date;
viewData["ViewCount"] = 0;
//Document result = await _viewCountTable.PutItemAsync(viewData);
Expression expr = new Expression();
expr.ExpressionStatement = "SET #VC = #VC + :val";
expr.ExpressionAttributeValues[":val"] = 1;
expr.ExpressionAttributeNames["#VC"] = "ViewCount";
var updateConfig = new UpdateItemOperationConfig() {
ConditionalExpression = expr,
ReturnValues = ReturnValues.UpdatedNewAttributes
};
var result = await _viewCountTable.UpdateItemAsync(viewData, updateConfig);
return result;
QUERY FOR DATE RANGE
Get one video's view count for a date range.
string queryTimeSpanStartString = dateFrom.ToString(AWSSDKUtils.ISO8601DateFormat);
string queryTimeSpanEndString = dateTo.ToString(AWSSDKUtils.ISO8601DateFormat);
var request = new QueryRequest
{
TableName = _settings.AWSDynamoDBViewCountTable,
KeyConditions = new Dictionary<string, Condition>()
{
{
"VideoId", new Condition()
{
ComparisonOperator = "EQ",
AttributeValueList = new List<AttributeValue>()
{
new AttributeValue { S = videoId }
}
}
},
{
"ViewDate",
new Condition
{
ComparisonOperator = "BETWEEN",
AttributeValueList = new List<AttributeValue>()
{
new AttributeValue { S = queryTimeSpanStartString },
new AttributeValue { S = queryTimeSpanEndString }
}
}
}
}
};
var response = await _client.QueryAsync(request);
Any help would be appreciated.
I was able to update the ViewCount with the following code:
string tableName = "videos";
var request = new UpdateItemRequest
{
Key = new Dictionary<string, AttributeValue>() { { "ViewUid", new AttributeValue { S = "replaceVideoIdhere" } } },
ExpressionAttributeNames = new Dictionary<string, string>()
{
{"#Q", "ViewCount"}
},
ExpressionAttributeValues = new Dictionary<string, AttributeValue>()
{
{":incr", new AttributeValue {N = "1"}}
},
UpdateExpression = "SET #Q = #Q + :incr",
TableName = tableName
};
var response = await _dynamoDbClient.UpdateItemAsync(request);
I created a table called "videos" with a partition key named "ViewUid" as string. Let me know if this works for you.
I'm trying to specify a Product/Service list item for invoice line items of invoices that I am importing to QuickBooks Online (QBO) company file and I am getting an error.
Error I receive is:
Intuit.Ipp.Exception.IdsException: InternalServerError ---> Intuit.Ipp.Exception.EndpointNotFoundException: Ids service endpoint was not found.
The exception doesn't give any further breakdown as to if what I'm doing is valid or not.
My unit test method:
[TestMethod()]
public void CreateTest()
{
Entities.Invoice invoice = new Entities.Invoice();
invoice.ReferenceId = Guid.NewGuid().ToString("N").Substring(0, 10);
invoice.CreatedDate = DateTime.Now;
invoice.CustomerId = 1;
invoice.LineItems.Add(new InvoiceLine() { ItemName = "Initial Funding", Description = "Initial Funding", Amount = 5500 });
invoice.LineItems.Add(new InvoiceLine() { ItemName = "Lien Fee", Description = "Lien Fee", Amount = 100 });
IPPRestProfile restProfile = new IPPRestProfile(realmId, accessToken, accessTokenSecret, Intuit.Ipp.Core.IntuitServicesType.QBO, consumerKey, consumerSecret);
IPP.Invoices target = new IPP.Invoices(restProfile);
Intuit.Ipp.Data.Invoice actual = target.Create(invoice);
if (actual != null)
{
Console.WriteLine("QB Invoice ID: {0}", actual.Id);
Console.WriteLine("QB Sync Token: {0}", actual.SyncToken);
Console.WriteLine("================================================");
ObjectDumper.Write(actual, 4);
}
}
The method that the unit test calls:
public Intuit.Ipp.Data.Invoice Create(Entities.Invoice invoice)
{
// Check pre-conditions
if (invoice == null) { throw new ArgumentException("Invoice object is required.", "invoice"); }
var qboInvoice = new Intuit.Ipp.Data.Invoice();
BuildInvoiceEntity(qboInvoice, invoice);
return _Service.Add(qboInvoice) as Intuit.Ipp.Data.Invoice;
}
And finally the build invoice method:
private void BuildInvoiceEntity(Intuit.Ipp.Data.Invoice qboInvoice, Entities.Invoice invoice)
{
if (qboInvoice != null && invoice != null)
{
IQuickBooksHeader header = invoice as IQuickBooksHeader;
if (String.IsNullOrEmpty(header.Id))
{
qboInvoice.DocNumber = invoice.ReferenceId;
qboInvoice.TxnDate = invoice.CreatedDate;
qboInvoice.TxnDateSpecified = true;
// Customer
qboInvoice.CustomerRef = new ReferenceType()
{
type = objectNameEnumType.Customer.ToString(),
Value = invoice.CustomerId.ToString()
};
// AR Account
qboInvoice.ARAccountRef = new ReferenceType()
{
type = objectNameEnumType.Account.ToString(),
name = "Accounts Receivable"
};
}
if (invoice.LineItems.Count > 0)
{
Intuit.Ipp.Data.Line[] invoiceLineCollection = new Intuit.Ipp.Data.Line[invoice.LineItems.Count];
for (int i = 0; i < invoice.LineItems.Count; i++)
{
var line = invoice.LineItems[i];
var qboInvoiceLine = new Intuit.Ipp.Data.Line()
{
Amount = line.Amount,
AmountSpecified = true,
Description = line.Description,
DetailType = LineDetailTypeEnum.SalesItemLineDetail,
DetailTypeSpecified = true,
AnyIntuitObject = new SalesItemLineDetail()
{
ItemRef = new ReferenceType()
{
name = line.ItemName,
},
ItemElementName = ItemChoiceType.UnitPrice,
AnyIntuitObject = line.Amount
}
};
invoiceLineCollection[i] = qboInvoiceLine;
}
qboInvoice.Line = invoiceLineCollection;
}
}
}
If I remove this piece of code from my build method:
ItemRef = new ReferenceType()
{
name = line.ItemName,
},
the invoice is successfully added with the default "Services" list item for the Product/Service of the invoice line items.
The online documentation for the IPP .NET SDK V3 is vague on what to specify for ReferenceType. What is wrong about just specifying the name of the list item? If I'm wrong about how I'm trying to specify a Product/Service list item for invoice line items, what is the correct way?
After days of researching, I never did find an answer as to why I can't just use the name like I wanted to, even though it works that way when specifying an AccountRef. But I digress, here is my solution:
// Hold a collection of QBO items
private ReadOnlyCollection<Item> _Items;
// I set the collection in the constructor only once
public Invoices(Entities.IPPRestProfile restProfile)
{
if (restProfile == null)
throw new ArgumentException("IPPRestProfile object is required.", "restProfile");
OAuthRequestValidator oAuthValidator = new OAuthRequestValidator(restProfile.OAuthAccessToken, restProfile.OAuthAccessTokenSecret,
restProfile.ConsumerKey, restProfile.ConsumerSecret);
ServiceContext context = new ServiceContext(restProfile.RealmId, restProfile.DataSource, oAuthValidator);
_Service = new DataService(context);
_Items = (new QueryService<Item>(context)).ExecuteIdsQuery("SELECT * FROM Item", QueryOperationType.query);
}
Whenever I build my invoice I query the collection for the Id of the item by name:
private void BuildInvoiceEntity(Intuit.Ipp.Data.Invoice qboInvoice, Entities.Invoice invoice)
{
...
// Get the Id value of the item by name
string itemTypeId = _Items.Where(o => o.Name == line.ItemName).FirstOrDefault().Id;
// Specify the Id value in the item reference of the SalesItemLineDetail
var qboInvoiceLine = new Intuit.Ipp.Data.Line()
{
Amount = (decimal)amount,
AmountSpecified = true,
Description = line.Description,
DetailType = LineDetailTypeEnum.SalesItemLineDetail,
DetailTypeSpecified = true,
AnyIntuitObject = new SalesItemLineDetail()
{
ItemRef = new ReferenceType() { Value = itemTypeId },
AnyIntuitObject = (decimal)line.Rate,
ItemElementName = ItemChoiceType.UnitPrice
}
};
...
}
Hopefully this helps point someone in the right direction to a possible better solution.