我有服务,我需要每5分钟运行一次.我已经有代码来安排在设备启动时重复警报.它有效但是
安装应用程序并运行它时,我的警报不会运行.需要重启debice.这是预料之中的.
如果我开始在活动开始时重复闹钟,那么我不确定我是否已经从设备启动中发出警报.我会得到"双打"吗?它会运行2个警报吗?
基本上,我想确保如果用户重新启动设备或电池芯片等,我会开始报警.但是,当安装应用程序以启动它时,我也不想让他们重启设备.或者,例如,如果用户"强制关闭"然后运行应用程序 - 它将不再运行此服务,但它需要.而且,我不想要双跑.我每5分钟就需要一次.
如何/需要这样做?
我正在使用mef创建WCF Web服务。服务外观如下:
[Export]
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class MobileService
{
[Import]
public IEmailService EmailService { get; set; }
[Import]
public ILoggerService LoggerService { get; set; }
[Import]
public IContextManager ContextManager { get; set; }
Run Code Online (Sandbox Code Playgroud)
这是获取服务实例的代码的外观:
// Get Service instace via MEF
public object GetInstance(InstanceContext instanceContext, Message message)
{
var lazyInstance = Container.GetExports(ServiceType, null, null).FirstOrDefault();
var instance = lazyInstance.Value;
return instance;
}
Run Code Online (Sandbox Code Playgroud)
MEF创建了EmailService,LoggerService,如果可以的话,它们会在服务有效期内快乐地生活。
现在,ContextManager是另一种动物。在GetInstance中-我真的很想“杀死”它并重新创建。ContextManager在构造过程中研究URL和标题,并填充“上下文”。使用像我一样的代码-它是第一次创建的,永远不会被破坏。如何改变这种行为?
谢谢!
我使用Blend为TextBox创建了一个模板的副本.我需要在ValidationErrorElement中编辑Path.Data.我怎么做?我可以看到XAML,但我无法弄清楚如何使用设计器编辑这个路径数据.

在自定义控件内我试图绑定我的ItemsControl.ItemsSource并获取错误.以下是模板的外观:
<Style TargetType="controls:IdattFilterBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:IdattFilterBox">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
<ItemsControl x:Name="PART_ItemsControl">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Caption}" />
<ComboBox Grid.Column="1">
<ComboBoxItem Content="Contains" />
<ComboBoxItem Content="Begins with" />
<ComboBoxItem Content="Ends with" />
</ComboBox>
<TextBox Grid.Column="2" Text="{Binding FieldFilter1, Mode=TwoWay}" />
<TextBox Grid.Column="3" Text="{Binding FieldFilter2, Mode=TwoWay}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
<Border Grid.ColumnSpan="2" x:Name="ValidationErrorElement" BorderBrush="#FFDB000C" BorderThickness="1" CornerRadius="1" Visibility="Collapsed">
<ToolTipService.ToolTip>
<ToolTip x:Name="validationTooltip" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" PlacementTarget="{Binding RelativeSource={RelativeSource …Run Code Online (Sandbox Code Playgroud) 我有以下种子输入数据:
这就是公司工资单如何发展的例子.
现在,我只有1个日期输入,例如12/30(今天)我需要输出当前支付期的日期范围:12月17日到12月30日
同样的,如果我输入1月3日 - 我应该回到2012年12月31日到1月13日
T-SQL中有没有快捷方式,或者我必须做循环?
编辑:总结问题.如果我们知道何时开始支付周期(过去) - 我如何计算给定日期的支付期开始?
我正在研究客户端应用程序以利用SOAP Web服务.添加SOAP Web服务作为服务引用.它连接到IBM服务器和服务器需要WS-Security基本身份验证.
使用默认设置调用并收到错误(无身份验证标头)
修改后的代码看起来像这样:
var service = new RealTimeOnlineClient();
service.ClientCredentials.UserName.UserName = "xxxxx";
service.ClientCredentials.UserName.Password = "yyyyy";
Run Code Online (Sandbox Code Playgroud)
现在,当我看到Fiddler中的响应 - 工作正常(我从服务器得到预期的信封)时,我得到了适当的信封.
但是,我从WCF得到例外:
Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security.
在SO上快速搜索和一堆答案将我指向微软的HotFix,他们在那里添加了新的属性EnableUnsecuredResponse.问题是 - 我无法弄清楚在我的代码或配置中应用此属性的位置.添加到securityweb.config中的标记不起作用(错误输出找不到属性).
据我所知,.NET 3.5中出现了修补程序,2009 - …
我需要将整个故事板的屏幕截图作为图像.那可能吗?我需要它给我的设计师.
理想情况下,我想获得一个大图像,进行一些更改(数字视图等)并将其保存为JPG
我正在使用网络服务获取有关路线里程的数据.然后我使用反序列化器来解析它.以下是JSON的外观:
[{"__type":"CalculateMilesReport:http:\/\/pcmiler.alk.com\/APIs\/v1.0","RouteID":null,"TMiles":445.5]
Run Code Online (Sandbox Code Playgroud)
有了这个回应,我有几个问题.为什么包装成集合,如何设置对象模型?它还抱怨特殊的__type属性.所以,我做了"黑客"和"准备"字符串:
// Cut off first and last charachters [] - they send objects as arrays
rawJSON = rawJSON.Substring(1, rawJSON.Length - 2);
// Hide "__type" attribute as it messes up serializer with namespace
rawJSON = rawJSON.Replace("__type", "type");
Run Code Online (Sandbox Code Playgroud)
然后一切都使用这个对象:
[DataContract]
public class PCMilerResponse
{
[DataMember(Name = "Errors", EmitDefaultValue = false)]
public PCMilerError[] Errors { get; set; }
[DataMember(Name = "TMiles", EmitDefaultValue = false)]
public decimal DrivingDistance { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
现在我修改了对Web服务的调用,我得到了以下响应
[
{"__type":"CalculateMilesReport:http:\/\/pcmiler.alk.com\/APIs\/v1.0","RouteID":null,"TMiles":445.5},
{"__type":"GeoTunnelReport:http:\/\/pcmiler.alk.com\/APIs\/v1.0","RouteID":null,"GeoTunnelPoints":
[{"Lat":"34.730466","Lon":"-92.247147"},{"Lat":"34.704863","Lon":"-92.29329"},{"Lat":"34.676312","Lon":"-92.364654"},{"Lat":"29.664271","Lon":"-95.236735"}]
}
]
Run Code Online (Sandbox Code Playgroud)
现在有理由为什么有数组和"__type".但我不确定如何编写对象来正确解析它.我想需要应用特殊属性,可能需要通用数组吗?有关如何正确反序列化的任何帮助?
PS我可以做更多的黑客攻击并替换那些使其成为对象的字符串,但我不知道是否有"正确"的方法来处理它.
.net c# json datacontractserializer datacontractjsonserializer
我需要完成以下工作。我有允许的字符列表(这是QBO API v3 .NET SDK中带有特殊字符的 QB 问题)
var goodChars = "ABCD...abcd...~_-...";
void string Sanitize(string input)
{
// TODO: Need to take input and replace all chars not included in "goodChars" with a space
}
Run Code Online (Sandbox Code Playgroud)
我知道如何用RegEx查找坏字符,但这就像倒退一样,我不需要查看匹配项。我需要查看不匹配的内容,并仅替换那些不匹配的内容。
我想将屏幕分成2个垂直段.底部工具栏应该是固定的 - 假设我想要LinearLayout无论如何都要保持在底部.
最重要的是 - 我希望ScrollView能够长大到工具栏,然后允许滚动.否则 - 它可以完全为空,但工具栏仍然需要在底部.
我怎样才能做到这一点?
.net ×3
c# ×3
android ×2
silverlight ×2
wcf ×2
json ×1
mef ×1
soap ×1
sql ×1
sql-server ×1
string ×1
t-sql ×1
uistoryboard ×1
web-services ×1
xaml ×1
xcode ×1