小编fib*_*ics的帖子

无法建立连接,因为目标计算机主动拒绝它127.0.0.1:3446

我正在使用WCF4.0模板 - REST.我正在尝试创建一个使用流上传文件的方法.

问题总是发生在

Stream serverStream = request.GetRequestStream();
Run Code Online (Sandbox Code Playgroud)

流媒体类:

namespace LogicClass
{
    public class StreamClass : IStreamClass
    {
        public bool UploadFile(string filename, Stream fileStream)
        {
            try
            {
                FileStream fileToupload = new FileStream(filename, FileMode.Create);
                byte[] bytearray = new byte[10000];
                int bytesRead, totalBytesRead = 0;
                do
                {
                    bytesRead = fileStream.Read(bytearray, 0, bytearray.Length);
                    totalBytesRead += bytesRead;
                } while (bytesRead > 0);

                fileToupload.Write(bytearray, 0, bytearray.Length);
                fileToupload.Close();
                fileToupload.Dispose();
            }
            catch (Exception ex) { throw new Exception(ex.Message); }
            return true;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

REST项目:

[WebInvoke(UriTemplate …
Run Code Online (Sandbox Code Playgroud)

c# rest wcf httpwebrequest

67
推荐指数
2
解决办法
46万
查看次数

如何使用LINQ选择哪些不存在?

我必须列出要分配给" 员工 "的所有" 班次 "数据,但如果员工数据中已存在班次数据,则不得包括班次数据.我们来看看图片样本.

还没有过滤

此查询解决了该问题.我在这里找到了这个:
Scott的博客

select * from shift where not exists 
(select 1 from employeeshift where shift.shiftid = employeeshift.shiftid
and employeeshift.empid = 57);  
Run Code Online (Sandbox Code Playgroud)

让我们看看结果:

过滤

现在我的问题是,我怎么能在linQ中做到这一点?我正在使用实体框架.
希望有人能提供帮助.非常感谢!!!

c# sql linq entity-framework

49
推荐指数
2
解决办法
10万
查看次数

找不到与绑定WebHttpBinding的端点的方案https匹配的基址.注册的基地址方案是[http]

我已经通过几个网站建议解决这个问题,但我仍然无法摆脱它.

我的WebConfig:

<bindings>
  <webHttpBinding>
    <binding name="SecureBasicRest">
      <security mode="Transport" />
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="svcBehavior">
      <serviceMetadata httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="svcEndpoint">
      <webHttp helpEnabled="true"/>
      <enableWebScript/>
    </behavior>
  </endpointBehaviors>
</behaviors>
<services>
  <service name="SvcContract.Authenticate" behaviorConfiguration="svcBehavior">
    <endpoint binding="webHttpBinding" bindingConfiguration="SecureBasicRest"
              behaviorConfiguration="svcEndpoint" name="webHttp"
              contract="SvcContract.Authenticate" />
  </service>
</services>  
Run Code Online (Sandbox Code Playgroud)

希望有人能提供帮助.提前致谢!.

编辑

我必须使用
https:// localhost:6188/Authenticate/Login?username = user&password = pass&ip = 127.0.0.1

c# rest https wcf web-config

43
推荐指数
2
解决办法
12万
查看次数

如何在特定时区转换DateTime?

我发现很难理解UTC是如何工作的.

我必须做以下事情,但如果我得到了正确的结果,我仍然感到困惑.

目标:

  1. 确保数据库中的所有已保存日期均为UTC格式
  2. 更新DefaultTimezone是在马尼拉时间
  3. 确保所有返回的日期都在马尼拉时间

所以代码是:

public ConvertDate(DateTime? dateTime)
{
    if (dateTime != null)
    {
        Value = (DateTime)dateTime;
        TimeZone = GetFromConfig.DefaultTimeZone(); 
    }
}


public ConvertDate(DateTime? dateTime, int GMTTimeZone)
{
    if (dateTime != null)
    {
        Value = (DateTime)dateTime;
        TimeZone = GMTTimeZone;
    }
}


public int TimeZone
{
    get { return m_TimeZone; }
    set { m_TimeZone = value; }
}


DateTime m_Value;
public DateTime Value
{
    get { return m_Value; }
    set 
    { 
        m_Value = value;
        DateTime converted = m_Value.ToUniversalTime().ToLocalTime();
    } …
Run Code Online (Sandbox Code Playgroud)

c# datetime utc

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

7zip Ultra LZMA2压缩

如何将此设置转换为命令?

在此输入图像描述

结果如下:

// Manual Compression (see the image above)
Compressed Size: 12,647,451 bytes

// Ultra
7z a -t7z Files.7z -mx9 -aoa
Compressed Size: 12,676,886 bytes

// LZMA2
7z a -t7z Files.7z -m9=LZMA2 -aoa
Compressed Size: 14,237,515 bytes  
Run Code Online (Sandbox Code Playgroud)

我在这里看:http:
//sevenzip.sourceforge.jp/chm/cmdline/switches/method.htm

我将把它放在一个批处理文件中.

compression command-line 7zip batch-file

28
推荐指数
3
解决办法
4万
查看次数

使用WebGet的可选UriTemplate参数

我试过这些

WCF服务URI模板中的可选参数?Kamal Rawat在博客中发表| 2012年9月4日的.NET 4.5本节介绍如何在WCF Servuce URI inShare中传递可选参数

WCF中URITemplate中的可选查询字符串参数

但没有什么对我有用.这是我的代码:

    [WebGet(UriTemplate = "RetrieveUserInformation/{hash}/{app}")]
    public string RetrieveUserInformation(string hash, string app)
    {

    }
Run Code Online (Sandbox Code Playgroud)

如果填充参数,它可以工作:

https://127.0.0.1/Case/Rest/Qr/RetrieveUserInformation/djJUd9879Hf8df/Apple  
Run Code Online (Sandbox Code Playgroud)

但如果app没有价值 就行不通

https://127.0.0.1/Case/Rest/Qr/RetrieveUserInformation/djJUd9879Hf8df  
Run Code Online (Sandbox Code Playgroud)

我想做app可选的.怎么做到这一点?
这是app没有值时的错误:

Endpoint not found. Please see the service help page for constructing valid requests to the service.  
Run Code Online (Sandbox Code Playgroud)

c# rest wcf

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

从两个不同的服务器数据库INSERT INTO

我试图将testdabse.invoice表的数据复制到basecampdev.invoice表. testdabsebasecampdev在服务器中的本地数据库.

它说,我将数据复制到另一个表的查询不起作用

Invalid object name 'basecampdev.dbo.invoice'.  
Run Code Online (Sandbox Code Playgroud)

我一直在阅读这个文档,但发现很难理解和理解.

这些是从服务器给出的信息

Server type: Database Engine
Server name: server.database.windows.net (this is not the real name)
Authentication: SQL Server Authentication
Login: myusername
Password: mypassword  
Run Code Online (Sandbox Code Playgroud)

如何连接到服务器以便我能够运行此查询

INSERT INTO [basecampdev].[dbo].[invoice]
           ([InvoiceNumber]
           ,[TotalAmount]
           ,[IsActive]
           ,[CreatedBy]
           ,[UpdatedBy]
           ,[CreatedDate]
           ,[UpdatedDate]
           ,[Remarks])
SELECT [InvoiceNumber]
           ,[TotalAmount]
           ,[IsActive]
           ,[CreatedBy]
           ,[UpdatedBy]
           ,[CreatedDate]
           ,[UpdatedDate]
           ,[Remarks] FROM [testdabse].[dbo].[invoice]
Run Code Online (Sandbox Code Playgroud)

屏幕截图

在此输入图像描述

sql sql-server openrowset

19
推荐指数
3
解决办法
14万
查看次数

使用PhoneGap的QR码扫描仪

我已经成功地遵循了这个主题
Phonegap 3.0.0:BarcodeScanner Plugin

但它似乎无法扫描Qr代码.这是从手机拍摄的屏幕:

在此输入图像描述

我试过扫描条形码图像,它工作正常.但不是QR图像.
任何的想法?

编辑

    var scanner = cordova.require("com.phonegap.plugins.barcodescanner.barcodescanner");

    scanner.scan(
        function (result) {
            alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
        },
        function (error) {
            alert("Scanning failed: " + error);
        }
    );  
Run Code Online (Sandbox Code Playgroud)

编辑2
DuuhhH !!! 问题是QR图像,它没有边际,肖恩欧文说.

qr-code barcode-scanner cordova

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

最好的应用程序来缩小Javascript代码和CSS代码

在执行这些任务时,最好的,安全的,100%免费的工具是什么?它被问过很多次,但我想问那些有经验的用户.

javascript css minify

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

正则表达式从右到左阅读

我正在寻找一个简短的代码,可以将逗号放入一组数字,直到我来到这个网站.

代码:

function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}  
Run Code Online (Sandbox Code Playgroud)

工作真的很棒.有这个例子的数字集:

addCommas('83475934.89');  
Run Code Online (Sandbox Code Playgroud)

将返回"83,475,934.89",但当我阅读代码时,我希望它返回,8,3,4,7,5,934.89但这个网站解释了这一点

\d+结合使用\d{3}将匹配一组3个数字,前面跟着任意数量的数字.这使得搜索从右到左替换.

我很困惑.这段代码如何从右到左阅读?另外,是什么$1$2意味着什么呢?

javascript regex

14
推荐指数
2
解决办法
8825
查看次数