寻找有关使用SDK的v6发布开放图表操作的一些帮助.我已经淘了几天了,找不到任何如何做到这一点的例子.到目前为止,我有:
protected void btnDyno_Click(object sender, EventArgs e)
{
FacebookSDKInterface fbData = new FacebookSDKInterface();
var fb = new FacebookClient(fbData.FacebookAccessToken);
dynamic parameters = new ExpandoObject();
parameters.appnamespace = "thedynoroom";
parameters.action = "added";
parameters.object_name = "dyno_run";
parameters.object_url = "http://thedynoroom.com/DesktopModules/Incite/InciteCore/FBObject.aspx";
try
{
dynamic result = fb.Post("me/", parameters);
lblPostMessageResult.Text = result;
txtMessage.Text = string.Empty;
}
catch (FacebookApiException ex)
{
lblPostMessageResult.Text = ex.Message;
}
}
Run Code Online (Sandbox Code Playgroud)
我知道这是不正确的,因为我只是在猜测,因为我无法找到任何关于此的文档.除了http://csharpsdk.org之外还有其他文档吗?
在此先感谢您的帮助!乍得
更新:好的,终于想通了......如果,在你的Facebook开发人员图表仪表板中,你的行动的获取代码链接如下所示:
curl -F 'access_token=blahblahblah' \
-F 'dyno_run=http://samples.ogp.me/266692056752346' \
'https://graph.facebook.com/me/thedynoroom:add'
Run Code Online (Sandbox Code Playgroud)
然后你的代码应该是这样的:
dynamic parameters = new ExpandoObject();
parameters.dyno_run = "http://samples.ogp.me/266692056752346"; …Run Code Online (Sandbox Code Playgroud) 我正在为客户开发基于Web的库存解决方案,并且将涉及手持移动计算机.我从未开发过在其中一个设备上的浏览器上运行的Web应用程序.我们正在查看的设备具有以下操作系统之一:
我的问题是:
任何这些操作系统选择的经验或建议,优点,缺点?
在尝试读取记录时,我一直在与EF斗争,然后在同一个事务中删除这些记录.我最初使用的是EntityState.Deleted方法,它会产生错误:
操作失败:无法更改关系,因为一个或多个外键属性不可为空.当对关系进行更改时,相关的外键属性将设置为空值.如果外键不支持空值,则必须定义新关系,必须为外键属性分配另一个非空值,或者必须删除不相关的对象.
但是,如果我将它改为我在下面,使用.Remove(),那么一切都很好.
这是有问题的方法.请注意,我确实有一个使用.Deleted方法的通用存储库,该方法在此方案之前一直很好用(读取然后删除相同的记录.)
//Delete Allocation Need and AllocatedContainers for alloc need id
public ActionConfirmation<int> DeleteAllocRecords(int intFacilityId, AllocNeedSourceTypes needSourceType, int intNeedSourceId)
{
var context = new InventoryMgmtContext();
var repository = new AllocationNeedRepository(context);
//Delete Allocation Need and hence children in Allocated Containers
var srcType = needSourceType.ToString();
List<AllocationNeed> allocNeeds = repository.SearchFor(
x => x.FacilityId == intFacilityId
&& x.NeedSourceType == srcType
&& x.NeedSourceId == intNeedSourceId
).ToList();
//var deleteRepository = new Repository<AllocationNeed>(); <--tried separate instance of context to delete...no worky.
foreach …Run Code Online (Sandbox Code Playgroud) .net c# entity-framework exception-handling entity-framework-5
OrderBy子句的问题对排序没有任何影响.我已经在调试器中完成了这个工作,并确保这是一种情况,即代码的排序行被命中并且在订单之后查看结果尚未应用.
public static IEnumerable<DDLOptions<TValueType>> GetDDLOptionsViewModel<TClass, TValueType>(
IEnumerable<TClass> list,
Func<TClass, TValueType> value,
Func<TClass, string> displayText,
bool sort = true
)
{
List<DDLOptions<TValueType>> ddlOptions;
ddlOptions = list.Select(
l => new DDLOptions<TValueType>
{
Value = value(l),
DisplayText = displayText(l)
}
).ToList(); <========== Works if I put the Order By here.
if (sort)
{
ddlOptions.OrderBy(l => l.DisplayText); <===== Does NOT work here.
}
return ddlOptions;
}
Run Code Online (Sandbox Code Playgroud) 我有这样的层次结构:
- Order
- order details
- work order header
- work order details
Run Code Online (Sandbox Code Playgroud)
我想选择没有工单详细信息的工单.
到目前为止我有这个,但它返回一级,订单详细信息......我希望下一级,工作订单标题.
IEnumerable<OrderDetail> odWithoutWoDtls = order.OrderDetails.Where(od => od.WorkOrderHeaders.Any(woh => woh.WorkOrderDetails.Count() == 0));
Run Code Online (Sandbox Code Playgroud) 刚刚用扩展方法弄湿我正在开发一些映射逻辑,将应用程序Invoice转换为Quickbooks Invoice.认为拥有.Convert()扩展方法可能是个好主意.
public static QBInvoice Convert(this InvoiceHeader importedInvoice)
Run Code Online (Sandbox Code Playgroud)
转换只是一个类到另一个类的字段映射.但后来我在某处读到扩展方法是扩展原始类,而不是将其转换为另一个类.因此我要问的原因.我在技术上知道我能做到,但这是最佳实践合规还是禁忌?
我有一个使用过的类ConfirmNonInventoryViewModel,但后来不得不提出另一个非常相似但具有一个不同属性的对象类型(随着功能的增加可能会有更多独特的属性).
所以我想将这个原始类转换为基类,然后创建2个派生类来解释2个唯一对象变体.但是因为我已经使用原始类并且不想要它的代码,所以开发人员不直接使用该基类,我认为将其标记为abstract将阻止它被使用并且仅使其如此可以使用派生的变体.
但这给了我一些错误Inconsistent Accessibility: base class is less accessible than derived class.所以我想我误解了抽象类的用途.
如何满足上述要求?
public class ConfirmWorkOrderNonInventoryViewModel : ConfirmNonInventoryViewModel
{
[Display(Name = "Part:")]
public int WorkOrderDetailId { get; set; }
}
public class ConfirmShipOrderNonInventoryViewModel : ConfirmNonInventoryViewModel
{
[Display(Name = "Order:")]
public int OrderHeaderId { get; set; }
}
abstract class ConfirmNonInventoryViewModel
{
[Display(Name = "Part:")]
public int OrderDetailId { get; set; }
[Display(Name = "Material:")]
public string ItemDescription { get; set; }
[Display(Name = "Est …Run Code Online (Sandbox Code Playgroud) 在我的项目类库(dll)中如何使用automapper苦苦挣扎.请参阅下面我的整体解决方案的结构.
WebApp启动,在Global.asax App Start中,调用AutoMapper.Configure()方法以添加映射配置文件.现在我只是添加Services.AutoMapperViewModelProfile.但我需要以某种方式说明每个WebStoreAdapters中的配置文件(下例中的BigCommerce和Shopify).我希望不要在WebApp中添加对每个WebStoreAdapter的引用,只是为了能够在AutoMapperConfig中添加配置文件.如果我在WebStoreFactory中添加对AutoMapper.Initialize的另一个调用,它将覆盖WebApp中的一个.
还有另一种方式,我错过了或完全偏离这里以其他方式?
WebApp
- AutoMapperConfig
- AddProfile Services.AutoMapperViewModelProfile
Services.dll
- AutoMapperViewModelProfile
Scheduler.dll (uses HangFire to execute cron jobs to get data from shop carts. Its UI is accessed via the WebApp)
WebStoreAdapter.dll
-WebStoreFactory
BigCommerceAdapter.dll
- AutoMapperBigCommerceDTOProfile
ShopifyAdapter.dll
- AutoMapperShopifyDTOProfile
Run Code Online (Sandbox Code Playgroud)
从Global.asax调用初始化:
public static class AutoMapperConfiguration
{
public static void Configure()
{
Mapper.Initialize(am =>
{
am.AddProfile<AutoMapperViewModelProfile>();
});
}
}
Run Code Online (Sandbox Code Playgroud)
轮廓:
public class AutoMapperViewModelProfile : Profile
{
public override string ProfileName
{
get { return this.GetType().ToString(); }
}
protected override …Run Code Online (Sandbox Code Playgroud) 希望删除特定的查询字符串参数.文件夹名称可以不同,并且specs参数的长度可以随数字的任何组合而变化.只要有specs参数,无论值如何,都会剥离该参数并重定向到http://example.com/folder
示例输入:
http://example.com/folder1?specs=10,13,14,18,20,29http://example.com/folder2?specs=14,18,20将重定向到(分别):
http://example.com/folder1http://example.com/folder2不要删除任何其他查询字符串参数.即
http://example.com/folder1?page=1不会被重定向.
尽管看起来像使用IIS重写规则测试工具时那样尝试了规则,但没有工作:
<rule name="SpecsSpiderCrawl" stopProcessing="true">
<match url="(\/\/.*\/)(.*)\?" />
<conditions>
<add input="{QUERY_STRING}" pattern="specs=.*" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:2}" appendQueryString="false" redirectType="Permanent" />
</rule>
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个标准方法来处理基于cookie中存储的值填充视图模型,这些值用作搜索条件的用户默认值.
在将字符串cookie值转换为属性类型时遇到问题,因此可以适当地更新视图模型.收到以下错误:
Invalid cast from 'System.String' to 'System.Reflection.RuntimePropertyInfo'.
Run Code Online (Sandbox Code Playgroud)
这是我有的:
public TViewModel GetUserSearchCriteriaDefaults<TViewModel>(TViewModel viewModel)
where TViewModel : class
{
Type type = viewModel.GetType();
string className = viewModel.GetType().Name;
PropertyInfo[] properties = type.GetProperties();
if (Request.Cookies[className] != null)
{
string rawValue;
foreach (PropertyInfo property in properties)
{
if (!String.IsNullOrEmpty(Request.Cookies[className][property.Name]))
{
rawValue = Server.HtmlEncode(Request.Cookies[className][property.Name]);
Type propertyType = property.GetType();
var convertedValue = Convert.ChangeType(rawValue, propertyType); <---- Error from this line
property.SetValue(viewModel, convertedValue);
}
}
}
return viewModel;
}
Run Code Online (Sandbox Code Playgroud) c# ×7
linq ×2
.net ×1
asp.net ×1
asp.net-mvc ×1
automapper ×1
automapper-4 ×1
generics ×1
iis ×1
iis-8 ×1
regex ×1