小编Mar*_*nHN的帖子

使用C#中的Windows API设置主监视器

我正在尝试使用Windows API来设置主监视器.它似乎不起作用 - 我的屏幕只是轻弹而没有任何反应.

    public const int DM_ORIENTATION = 0x00000001;
public const int DM_PAPERSIZE = 0x00000002;
public const int DM_PAPERLENGTH = 0x00000004;
public const int DM_PAPERWIDTH = 0x00000008;
public const int DM_SCALE = 0x00000010;
public const int DM_POSITION = 0x00000020;
public const int DM_NUP = 0x00000040;
public const int DM_DISPLAYORIENTATION = 0x00000080;
public const int DM_COPIES = 0x00000100;
public const int DM_DEFAULTSOURCE = 0x00000200;
public const int DM_PRINTQUALITY = 0x00000400;
public const int DM_COLOR = 0x00000800;
public const int DM_DUPLEX …
Run Code Online (Sandbox Code Playgroud)

c# windows sdk

7
推荐指数
3
解决办法
1万
查看次数

每天从SQL DB中选择数据

我在电子商务商店里有一张包含订单信息的表格.架构看起来像这样:

[订单]
Id | SubTotal | TaxAmount | ShippingAmount | DateCreated

该表仅包含每个订单的数据.因此,如果一天没有任何订单,那天没有销售数据.

我想选择过去30天的每日小计,包括那些没有销售的日子.

结果集如下所示:

日期| SalesSum
2009-08-01 | 15235
2009-08-02 | 0
2009-08-03 | 340
2009-08-04 | 0
...

这样做,只给出了订单日期的数据:

select DateCreated as Date, sum(ordersubtotal) as SalesSum
from Orders
group by DateCreated
Run Code Online (Sandbox Code Playgroud)

您可以创建一个名为Dates的表,并从该表中选择并加入Orders表.但我真的想避免这种情况,因为在处理不同的时区和事情时它不能很好地运作......

请不要笑.SQL不是我的那种东西...... :)

sql

7
推荐指数
1
解决办法
5899
查看次数

ASP.NET MVC中的模型绑定嵌套集合

我正在使用Steve Sanderson的BeginCollectionItem助手和ASP.NET MVC 2来模拟绑定项目的集合.

只要集合项的模型不包含其他集合,这样就可以了.

我有这样的模型:

-Product
--Variants
--- IncludedAttributes

每当我渲染和模型绑定Variants集合时,它都可以正常工作.但是使用IncludedAttributes集合,我无法使用BeginCollectionItem帮助器,因为id和names值将不会遵循为其父Variant生成的id和names值:

<div class="variant">
    <input type="hidden" value="bbd4fdd4-fa22-49f9-8a5e-3ff7e2942126" autocomplete="off" name="Variants.index">
    <input type="hidden" value="0" name="Variants[bbd4fdd4-fa22-49f9-8a5e-3ff7e2942126].SlotAmount" id="Variants_bbd4fdd4-fa22-49f9-8a5e-3ff7e2942126__SlotAmount">
    <table class="included-attributes">
        <input type="hidden" value="0" name="Variants.IncludedAttributes[c5989db5-b1e1-485b-b09d-a9e50dd1d2cb].Id" id="Variants_IncludedAttributes_c5989db5-b1e1-485b-b09d-a9e50dd1d2cb__Id" class="attribute-id">
        <tr>
            <td>
                <input type="hidden" value="0" name="Variants.IncludedAttributes[c5989db5-b1e1-485b-b09d-a9e50dd1d2cb].Id" id="Variants_IncludedAttributes_c5989db5-b1e1-485b-b09d-a9e50dd1d2cb__Id" class="attribute-id">
            </td>
        </tr>
    </table>
</div>
Run Code Online (Sandbox Code Playgroud)

如果你查看表格中第一个隐藏字段的名称,它就是Variants.IncludedAttributes - 它应该是Variants [bbd4fdd4-fa22-49f9-8a5e-3ff7e2942126] .IncludedAttributes [...] ...

这是因为当我第二次调用BeginCollectionItem时(在IncludedAttributes集合上),没有给出关于它的父Variant的项索引值的信息.

我渲染Variant的代码如下所示:

<div class="product-variant round-content-box grid_6" data-id="<%: Model.AttributeType.Id %>">
    <h2><%: Model.AttributeType.AttributeTypeName %></h2>
    <div class="box-content">
    <% using (Html.BeginCollectionItem("Variants")) { %>

        <div class="slot-amount">
            <label class="inline" for="slotAmountSelectList"><%: Text.amountOfThisVariant %>:</label>
            <select id="slotAmountSelectList"><option …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc

7
推荐指数
1
解决办法
7050
查看次数

JQuery 1.5中断比较验证(JQuery Validate 1.8)

升级到JQuery 1.5及更高版本1.5.1后,我的比较验证失败.我正在使用JQuery.Validate 1.7.我的ViewModel具有以下数据注释:

/// <summary>
/// Gets or sets the full name.
/// </summary>
/// <value>The full name.</value>
[Required]
[Display(Name = "fullname", ResourceType = typeof(Milkshake.Commerce.Model.Resources.Text))]
public string FullName { get; set; }

/// <summary>
/// Gets or sets the email.
/// </summary>
/// <value>The email.</value>
[DataType(DataType.EmailAddress)]
[Display(Name = "email", ResourceType = typeof(Milkshake.Commerce.Model.Resources.Text))]
[Required(ErrorMessageResourceName = "EmailRequired", ErrorMessageResourceType = typeof(Milkshake.Commerce.Model.Resources.ValidationMessages))]
[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessageResourceType = typeof(Milkshake.Commerce.Model.Resources.ValidationMessages), ErrorMessageResourceName = "EmailInvalid")]
public string Email { get; set; }

/// <summary>
/// Gets or sets the password. …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-validate asp.net-mvc-3

7
推荐指数
1
解决办法
4289
查看次数

CKEditor - 更改图像源

我为CKEditor做了一些自定义功能.简而言之,它显示了一个带有5个链接的div标签,适用于小型,中型,大型X大型和原始大小.

单击链接时,它会将图像的SRC属性更改为正确的大小.

它有效,但它不会持久留在编辑器中.这就像我通过点击事件目标获得的图像,不是源代码的一部分.

在使用编辑器中的元素进行操作时,如何更改源代码?

我的代码看起来像这样:

$(target).ckeditor(function (editor) {
    $(this.document.$).bind("click", function (event) {
        var target = $(event.target);

        if (target.is("img")) {
            var p = $("<div contenteditable='false' class='image-properties'>" + Milkshake.Resources.Text.size + ": <a class='sizeLink' href='#size1Img'>S</a>&nbsp;<a class='sizeLink' href='#size2Img'>M</a>&nbsp;<a class='sizeLink' href='#size3Img'>L</a>&nbsp;<a class='sizeLink' href='#size4Img'>XL</a>&nbsp;<a class='sizeLink' href='#size5Img'>Org.</a></div>");
            p.css("top", target.position().top);

            var regex = new RegExp(/(size\d{1}img)/i);
            var match = regex.exec(target.attr("src"));

            if (match != null) {
                var imgSrize = match[0];
                p.find("a[href=#" + imgSrize + "]").addClass("selected");
            }

            p.delegate("a", "click", function (e) {
                var link = $(e.target);

                if (!link.is(".selected")) {
                    $(".selected", link.parent()).removeClass("selected"); …
Run Code Online (Sandbox Code Playgroud)

javascript ckeditor

7
推荐指数
1
解决办法
3901
查看次数

EF Code First - 将字典或自定义类型映射为nvarchar

我想首先使用EF代码用于我正在使用带有存储过程的普通旧ADO.NET访问的数据库.

在我的数据库中,我有一些nvarchar(MAX)列应该映射到a和Dictionary<string, string>.

保存到数据库时,它是XML格式的字符串.我使用这种技术来允许例如在线商店中的产品名称的国际化.我不知道任何给定用户想要翻译多少种语言,所以我不能Name为每种语言提供一列.

我还想避免将值存储在一个单独的表中,所以我最终得到了Dictionary - XML方法.

我现在这样做的方法是,每当我与数据库交互时,只将这些列中的任何一个视为字符串.我有一个自定义映射器函数,可以将XML转换为字典,然后返回到XML.

但我似乎无法首先找到使用EF Code执行此操作的方法?有任何想法吗?

entity-framework ef-code-first

7
推荐指数
1
解决办法
1万
查看次数

UIVibrancyEffect在设备上变暗,在模拟器中充满活力

我在iPhone 6上的渲染效果很差.

这是它的样子: 模拟器与设备

我检查了UIAccessibilityIsReduceTransparencyEnabled()它的值,它在设备和模拟器中都返回false.

我添加所有其他元素的背景图像,效果和containerView的代码如下所示:

import Foundation
import UIKit
import PureLayout

class BackgroundImageView : UIView {
    let bgImage = UIImageView(forAutoLayout: ())
    var blurView:UIVisualEffectView!
    var vibrancyView:UIVisualEffectView!

    var containerView: UIView? = nil {
        willSet(container) {
            vibrancyView.contentView.addSubview(container!)
        }
    }

    init(imageName: String) {
        super.init()

        let screenSize: CGRect = UIScreen.mainScreen().bounds

        bgImage.image = UIImage(named: imageName)
        // Scale relative to the size of the iPhone 6 Plus: http://martinnormark.com/smooth-transition-from-launch-image-to-view-controller-in-ios/
        bgImage.transform = CGAffineTransformMakeScale(screenSize.width / 414, screenSize.height / 736)

        self.addSubview(bgImage)

        let blurEffect = UIBlurEffect(style: .Dark)
        self.blurView = UIVisualEffectView(effect: …
Run Code Online (Sandbox Code Playgroud)

iphone ios swift ios8

7
推荐指数
1
解决办法
703
查看次数

jQuery backgroundColor动画

我有一个带有链接和SPAN的DIV.

单击链接时,它使用AJAX呈现项目列表.单击某个项目时,SPAN的内容会发生变化.

我想通过将DIV的背景颜色设置为绿色并使用jQuery将其设置为白色来突出显示此更改.

  var originalColor = elementToUpdate.parentNode.style.backgroundColor;
  elementToUpdate.style.backgroundColor = 'green'; //lastSender.style.color;
  jQuery(elementToUpdate.id).animate({ backgroundColor: '#ffffff' }, 1000);
Run Code Online (Sandbox Code Playgroud)

SPAN的背景在第2行变为绿色,但第3行没有做任何事情.没有错误,或者改变了什么......

有任何想法吗?


编辑:正如Ted Naleid在下面的评论中所述:

另请注意,您必须安装彩色动画插件才能使用(http://plugins.jquery.com/project/color),如果您没有安装它,jQuery无法为颜色设置动画,只有数字属性(至少从1.3.1开始).

jquery animation

6
推荐指数
1
解决办法
3万
查看次数

SQL删除不在的地方

我有一个像这样的关系映射表:

属性bigint
productid bigint

要清除不再使用的关系,我想删除其中productid = x和attributeid不在(@includedIds)的所有recors,如下例所示:

@attributetypeid bigint, 
@productid bigint,
@includedids varchar(MAX)  


DELETE FROM reltable 
WHERE productid = @productid AND 
attributetypeid = @attributetypeid AND 
attributeid NOT IN (@includedids);
Run Code Online (Sandbox Code Playgroud)

当使用包含多于1个id的includedids param运行SQL时 - 像这样:25,26 - 我得到一个SqlException说:

将数据类型varchar转换为bigint时出错.

这当然是由于varchar(max)参数...

我应该如何构建我的删除语句以使其工作?

sql sql-server

6
推荐指数
1
解决办法
1万
查看次数

使用圆形布局滚动集合视图

我使用此博客文章中的代码:http://markpospesel.wordpress.com/2012/10/25/fixing-circlelayout/(github上的代码:https://github.com/mpospese/CircleLayout)

它基本上是Apple在WWDC上提供的CircleLayout项目的修改版本.

我想做的是将滚动功能添加到循环集合视图中.或许它应该被称为旋转.

我要将收藏视图放在屏幕底部,这样你才能看到它的前三分之一.通过滑动滚轮滚动让用户看到所有项目.

我怎样才能做到这一点?集合视图是否支持默认滚动,还是我必须添加识别器并手动执行操作?

ios uicollectionview

6
推荐指数
1
解决办法
8503
查看次数