我想从这个Linq查询得到的是所有广告的列表,其中最近关联的日志与a LogType.IsStatus == true
具有LogType.Name
已确认或已更新.要清楚,广告有许多日志,每个日志有一个LogType.到目前为止,我有以下内容,但它在LastOrDefault上给出了一个错误System.NotSupportedException.
var adverts = (from a in database.Adverts
let lastLog = (from l in a.Logs
where l.LogType.IsStatus == true
orderby l.Created_at
select l).LastOrDefault()
where (lastLog != null)
&&
(lastLog.LogType.Name == "Confirmed" || lastLog.LogType.Name == "Renewed")
orderby a.Created_at descending
select a).ToList();
Run Code Online (Sandbox Code Playgroud) 总而言之,我试图将一些功能添加到作为Windows服务运行的自定义更新程序中.我遇到了一些问题,我试图更新的应用程序可能正在运行,如果是,我需要执行一些自定义操作.
我遇到的问题是EnumDesktopWindows api调用只返回在本地系统上下文中运行的进程.
现在,这对我来说至关重要的是为什么要这样做等等(我想 - 虽然希望进一步解释).
但是,如何通过服务实现此功能?
这是我正在使用的代码的基础知识:
public static IntPtr[] EnumDesktopWindows()
{
WinAPI._desktopWindowHandles = new List<IntPtr>();
WinAPI.EnumDelegate enumfunc = new WinAPI.EnumDelegate(EnumWindowsCallBack);
IntPtr hDesktop = IntPtr.Zero; // current desktop
bool success = WinAPI.EnumDesktopWindows(hDesktop, enumfunc, IntPtr.Zero);
if (success)
{
IntPtr[] handles = new IntPtr[_desktopWindowHandles.Count];
_desktopWindowHandles.CopyTo(handles);
return handles;
}
else
{
int errorCode = Marshal.GetLastWin32Error();
string errorMessage = String.Format("EnumDesktopWindows failed with code {0}.", errorCode);
throw new Exception(errorMessage);
}
}
Run Code Online (Sandbox Code Playgroud)
可能是因为我把这一切都搞错了,问题就出现了?:
IntPtr hDesktop = IntPtr.Zero;
Run Code Online (Sandbox Code Playgroud) 我正在实现Zend Regex Routing,我必须对url执行多次检查.例如,如果这是我的网址:
HTTP://localhost/application/public/index.php/module/controller/action
这是我的bootstrap文件中的正则表达式条件,当url不包含"login"时匹配:
$router->addRoute('ui', new Zend_Controller_Router_Route_Regex(
'^((?!login/).)*$',
array(
'module' => 'mod1',
'controller' => 'cont1',
'action' => 'action1'
),
array( )
));
Run Code Online (Sandbox Code Playgroud)
现在我也想识别模式:([^-]*)/([^-]*)/([^-]*)
从知道模块,控制器和动作的URL,以便我可以路由到它.
如何实现?
我对Android开发很新,只是遇到了偏好.我找到了PreferenceScreens并希望用它创建一个登录功能.我唯一的问题是我不知道热,我可以在PreferenceScreen上添加一个"登录"按钮.以下是我的Preference View的样子:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
...
<PreferenceScreen android:title="@string/login" android:key="Login">
<EditTextPreference android:persistent="true" android:title="@string/username" android:key="Username"></EditTextPreference>
<EditTextPreference android:title="@string/password" android:persistent="true" android:password="true" android:key="Password"></EditTextPreference>
</PreferenceScreen>
...
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
Button应位于两个ExitTextPreferences下面.
这个问题有一个简单的解决方案吗?我找到的一个解决方案无法正常工作,因为我使用子偏好屏幕.
我发现我可以这样添加按钮:
<PreferenceScreen android:title="@string/login" android:key="Login">
<EditTextPreference android:persistent="true" android:title="@string/username" android:key="Username"></EditTextPreference>
<EditTextPreference android:title="@string/password" android:persistent="true" android:password="true" android:key="Password"></EditTextPreference>
<Preference android:layout="@layout/loginButtons" android:key="loginButtons"></Preference>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
并且布局文件(loginButtons.xml)看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:weightSum="10"
android:baselineAligned="false" android:orientation="horizontal">
<Button android:text="Login" android:layout_width="fill_parent"
android:layout_weight="5" android:layout_height="wrap_content"
android:id="@+id/loginButton" android:layout_gravity="left"></Button>
<Button android:text="Password?" android:layout_width="fill_parent"
android:layout_weight="5" android:layout_height="wrap_content"
android:id="@+id/forgottenPasswordButton"></Button>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
所以现在按钮出现但我无法在代码中访问它们.我尝试使用findViewById(),但这返回null.我有什么想法可以访问这些按钮?
这是我的Gemfile配置:
group :development, :test do
gem 'rspec-rails'
gem 'factory_girl', '~>2.0.0.beta1'
gem 'factory_girl_rails', :git => 'https://github.com/thoughtbot/factory_girl_rails.git', :tag => 'v1.1.beta1'
end
Run Code Online (Sandbox Code Playgroud)
这是我的spec_helper.rb
:
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require "factory_girl"
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
Dir[Rails.root.join("spec/factories/**/*.rb")].each {|f| require f}
Run Code Online (Sandbox Code Playgroud)
我将factories
文件夹添加到LOAD_PATH,因为我想将它们保存在单独的文件夹中.
这是我的factories.rb
档案:
需要File.expand_path(File.dirname(FILE)+'../../spec_helper')
Factory.define(:user) …
Run Code Online (Sandbox Code Playgroud) 我试过这个
typedef void (* __stdcall MessageHandler)(const Task*);
Run Code Online (Sandbox Code Playgroud)
这编译但给了我这个警告(VS2003):
警告C4229:使用的时间错误:忽略数据上的修饰符
我想用stdcall调用约定声明一个指向函数的指针?我究竟做错了什么?
我们有一个大的PHP系统,我正在改为OOP,并希望使用AJAX来更新登录用户的网页.我完全是自学成才,并且对HTML,CSS和PHP有很好的理解.
尝试用PHP学习AJAX正在打败我.在尝试了一组自制的脚本来测试无法正常运行的AJAX之后,我就去了互联网上寻找示例而无法使用它.这是在我的开发Mac上运行MAMP并使用我的主机保存当前系统.
我的问题是,有没有人有一个简单的'你好世界'的HTML和PHP脚本,他们知道我可以尝试确认我可以运行已知的东西.
非常感谢科林
我在我的应用程序中出现问题..使用XML文件我得到地理位置来绘制两个位置之间的路径..但它只显示我的路线,如果距离小于300公里..否则它没有绘制完整的路径..
任何解决方案,用于将xml文件分成块或任何替代方案.因为它给出的方向即使对于长距离也是完美的......那么问题是什么?我不明白..
请帮忙..
编辑:我发现KML文件中存在问题.如果有一个很长的距离,它提供两个线串标签,每个都有坐标列表,全路径分为几个部分.如下
<GeometryCollection>
<LineString>
<coordinates>
70.799640,22.283370,... </coordinates>
</LineString>
<LineString>
<coordinates>
73.005940,21.536300,....</coordinates>
</LineString>
</GeometryCollection>
这就是为什么它只会在地图上绘制一个Route的后半部分..所以..任何人都知道如何解决这个问题..
编辑: -
public class DrivingDirectionsGoogleKML extends DrivingDirections
{
@Override
protected void startDrivingTo (GeoPoint startPoint, GeoPoint endPoint, Mode mode, IDirectionsListener listener)
{
new LoadDirectionsTask(startPoint, endPoint).execute(mode);
}
private class LoadDirectionsTask extends AsyncTask<Mode, Void, RouteImpl>
{
private static final String BASE_URL = "http://maps.google.com/maps?f=d&hl=en";
private static final String ELEMENT_PLACEMARK = "Placemark";
private static final String ELEMENT_NAME = "name";
private static final String ELEMENT_DESC = "description";
private static …
Run Code Online (Sandbox Code Playgroud) 我已经阅读了原始数据类型和对象引用按值传递的每个位置?
我试过在谷歌搜索为什么java支持不通过引用传递,但我只是得到java不支持通过引用传递,我找不到它背后的任何原因.
为什么不能通过引用传递原始数据类型?
编辑:大多数人已经关闭了我的问题,假设它是主观的和议论性的.
嗯,它不是,它有一个明确的答案,我的问题是为什么你不能创建一个抽象类的对象,它也不是重复,因为大多数答案只是明确地说不.
谢谢.
我有一个看似错误的假设.我过去的'主要'语言是C++,在C++中,我可以在伪中执行函数参数绑定:
// declaration
void f(int param1, int param2);
// usage
func<void, int> boundfunc = bind(f, 1, _1)
func(2) // equivalent to f(1, 2)
Run Code Online (Sandbox Code Playgroud)
有趣的是,如果我用函数调用替换1
定义boundfunc
,那么在绑定站点调用该函数调用,而不是调用func
.
因此,当我试图巩固我脑海中的currying概念时,我将其与C++中的绑定进行比较,并且我假设(错误地)使用非''name'参数进行currying将等同于同一个想法 - 在'bind site处调用".当然,这不是正在发生的事情,我很好奇为什么f
和g
以下表现相同.我显然错过了一些东西......
import scala.util.Random
class X { println("Constructing"); val r = new Random }
def f(limit: Int)(x: X) = x.r.nextInt(limit)
def g(limit: Int)(x: => X) = x.r.nextInt(limit)
def r = f(100)(new X) // Doesn't print "Constructing"
def s = g(100)(new X) // …
Run Code Online (Sandbox Code Playgroud)