小编Din*_*uka的帖子

为Azure存储帐户连接字符串生成连接字符串

我知道您可以使用以下方法获取连接字符串:

 <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=mystorage;AccountKey=MY_ACCOUNT_KEY" />
Run Code Online (Sandbox Code Playgroud)

然后使用以下方法检索它:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
Run Code Online (Sandbox Code Playgroud)

而且我知道如何使用SqlConnectionStringBuilder建立连接字符串:

System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder();
builder["DefaultEndpointsProtocol"] = "https";
builder["AccountName"] = "mystorage";
builder["AccountKey"] = "MY_ACCOUNT_KEY";
string conString = builder.ConnectionString;
Run Code Online (Sandbox Code Playgroud)

但是,这显然不适用于存储连接字符串。它说SqlConnectionStringBuilder不支持DefaultEndpointsProtocol或我指定的3个键中的任何一个。如何使用这些键制作字符串?

asp.net web-services web-applications azure azure-storage

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

Azure 管理中断/部分 blob 上传

我正在使用以下方式将 bob 上传到我的 azure 云存储。我面临的问题是,如果用户退出 Web 应用程序或上传被中断,部分上传的 blob 仍会保留在存储中。在 Azure 中处理中断的 blob 上传的方法是什么?

代码:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(cloudString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
container.CreateIfNotExists();
container.SetPermissions(
new BlobContainerPermissions
{
        PublicAccess = BlobContainerPublicAccessType.Blob
 });
CloudBlockBlob blockBlob = container.GetBlockBlobReference(uniqueBlobName);
blockBlob.UploadFromByteArray(f, 0, f.Length);
Run Code Online (Sandbox Code Playgroud)

asp.net azure azure-storage asp.net-web-api azure-mobile-services

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

Java REST API:从API方法返回多个对象

我试图在Eclipse中使用JAX-RS从Java REST API方法返回多个对象(如String,Boolean,MyOwnClass等).

这就是我现在所拥有的:

我的API方法

@Path("/")
public class myAPI {

    @GET
    @Produces({ "application/xml", "application/json" })
    @Path("/getusers")
    public Response GetAllUsers() {

        //Data Type #1 I need to send back to the clients
        RestBean result = GetAllUsers();

        //Data Type #2 I need to send with in the response
        Boolean isRegistered = true;

        //The following code line doesn't work. Probably wrong way of doing it
        return Response.ok().entity(result, isRegistered).build();
    }
}
Run Code Online (Sandbox Code Playgroud)

RestBean类:

public class RestBean {
    String status = "";
    String description = ""; …
Run Code Online (Sandbox Code Playgroud)

java rest google-app-engine jax-rs restful-architecture

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

Swift - 本地通知不会被触发

我编码斯威夫特3,我只是试图发送一个通知,现在没有任何延迟或间隔.但是通知永远不会被触发.这是我的代码..

ViewController代码

import UserNotifications

class HomeViewController: UIViewController{
    var isGrantedNotificationAccess:Bool = false

    override func viewDidLoad() {
        super.viewDidLoad()

        UNUserNotificationCenter.current().requestAuthorization(
            options: [.alert,.sound,.badge],
            completionHandler: { (granted,error) in
                self.isGrantedNotificationAccess = granted
        })

        if isGrantedNotificationAccess{
            triggerNotification()
        }
    }

    //triggerNotification func goes here
}
Run Code Online (Sandbox Code Playgroud)

triggerNotification函数:

func triggerNotification(){
    let content = UNMutableNotificationContent()
    content.title = NSString.localizedUserNotificationString(forKey: "Notification Testing", arguments: nil)
    content.body = NSString.localizedUserNotificationString(forKey: "This is a test", arguments: nil)
    content.sound = UNNotificationSound.default()
    content.badge = (UIApplication.shared.applicationIconBadgeNumber + 1) as NSNumber;
    let trigger = UNTimeIntervalNotificationTrigger(
        timeInterval: 1.0,
        repeats: false) …
Run Code Online (Sandbox Code Playgroud)

xcode notifications ios uilocalnotification swift

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

从Android到Web API的POST数据返回404

我正在尝试将来自我的Android客户端的数据作为POST请求发送到我的Web API后端,但它返回404响应代码.这是我的代码:

后端:

[HttpPost]
[Route("api/postcomment")]
public IHttpActionResult PostComment(string comment, string email, string actid)
{
       string status = CC.PostNewComment(comment, email, actid);
       return Ok(status);
}
Run Code Online (Sandbox Code Playgroud)

Android代码:

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://MYWEBADDRESS.azure-mobile.net/api/postcomment");
String mobileServiceAppId = "AZURE_SERVICE_APP_ID";

try {

        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("comment", comment));
        nameValuePairs.add(new BasicNameValuePair("email", currEmail));
        nameValuePairs.add(new BasicNameValuePair("actid", currActID));

        httppost.setHeader("Content-Type", "application/json");
        httppost.setHeader("ACCEPT", "application/json");
        httppost.setHeader("X-ZUMO-APPLICATION", mobileServiceAppId);

        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairs);
        httppost.setEntity(formEntity);

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

} 
catch (Exception e) …
Run Code Online (Sandbox Code Playgroud)

asp.net rest android asp.net-web-api azure-mobile-services

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

ASP.NET:通过 Web 方法获取当前 URL?

我正在尝试通过 Web 方法检索当前页面的 URL。下面的代码适用于普通的 C# 方法,例如 Page_Load,但不适用于 Web 方法。

[WebMethod(EnableSession=true)]
public static void UpdateProjectName(string name)
{
        string project_id = HttpContext.Current.Request.Url.ToString();
}
Run Code Online (Sandbox Code Playgroud)

我收到一个空字符串 ("") 作为 project_id。我究竟做错了什么?

c# asp.net web-services webmethod asp.net-web-api

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

将Firebase快照投射到Swift 3对象

我正在从Firebase数据库中检索对象,我需要将它们强制转换为自定义结构类对象

类:

struct Request {
    var Address: String!
    var Position: Position!
    var RequestID: String!
    var Status: String!
}
Run Code Online (Sandbox Code Playgroud)

从我的Firebase数据库获取快照的函数:

self.ref.child("requests").observe(.childAdded, with: { snapshot in

    //I need to cast this snapshot object to a new Request object here

    let dataChange = snapshot.value as? [String:AnyObject]

    print(dataChange)

})
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

firebase firebase-realtime-database swift3

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

无法在 Mac OSX 上设置 Maven

我是 Mac OSX 新手,正在运行 Yosemite。我正在尝试使用此官方指南来设置 Maven ,以便设置 Google Cloud Messaging 后端。这就是我所做的:

1)下载Maven zip(版本:apache-maven-3.3.9)并解压

2)正如指南所说,我需要将 bin 目录添加到我的 PATH 变量中。所以我在终端中执行了以下操作

export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60

export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH
Run Code Online (Sandbox Code Playgroud)

终端没有返回任何响应。然而,当我检查 Maven 是否已安装时,使用:

mvn-版本

我收到一条消息说:

-bash:mvn:找不到命令

我究竟做错了什么?我是否正确按照步骤设置了 Maven?

编辑:

MVN Bin目录路径为:

/用户/Earthling/文档/项目/MobiProject/apache-maven-3.3.9

java macos bash maven google-cloud-messaging

0
推荐指数
1
解决办法
7654
查看次数

CodeIgniter:提交表单后避免刷新?

我基本上是将表单值提交给我的控制器,而我正在使用CodeIgniter Framework.但是,当我将值发送到我的控制器的函数时,页面将更改为控制器并离开index.php(当前页面)

index.php文件:

<form action="<?php echo base_url();?>index.php/LoginController/loginuser" method="post">
            <input id="login_emailbox" name="login_emailbox" type="text" class="form-control welcome-login-email" placeholder="Email" required="">
            <input id="login_passbox" name="login_passbox" type="password" class="form-control welcome-login-password" placeholder="Password" required="">
            <button id="loginbtn" type="submit" class="btn btn-info" style="margin-left: 30px">Login</button>
</form>
Run Code Online (Sandbox Code Playgroud)

LoginController.php:

class LoginController extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        $this->load->helper('html');
        $this->load->helper('url');
        $this->load->view('header');
        $this->load->view('footer');

        $this->load->view('index.php');
    }


    public function loginuser(){
        echo $_POST['login_emailbox'];
        echo $_POST['login_passbox'];
    }

}
Run Code Online (Sandbox Code Playgroud)

我在运行时采取的步骤:

1)我通过=> http://localhost/codeig/index.php/LoginController/index浏览到index.php

2)填写表格并点击提交.值将提交给函数:loginuser

3)页面被重定向到'loginuser'函数

如何避免这种情况并基本上将值发送到控制器中的loginuser函数而不刷新当前页面?

php forms codeigniter

0
推荐指数
1
解决办法
2804
查看次数

C# 手动对列表中的父/子树元素进行排序

我正在尝试生成一个元素列表,如果可视化,这些元素将生成树结构。

例子:

Element 1 -> 1, 0 //ID is 1 & Parent ID is 0 (0 = root)
Element 2 -> 2, 0 //ID is 2 & Parent ID is 0 (0 = root)
Element 3 -> 3, 1 //ID is 3 & Parent ID is 1
Element 4 -> 4, 3
Element 5 -> 5, 2
Run Code Online (Sandbox Code Playgroud)

如果要用这种结构来可视化一棵树:

在此输入图像描述

为了实现这一点,节点类如下:

public class Node
{
    public string id;
    public string parentId;
    public List<Node> children = new List<Node>();  
}
Run Code Online (Sandbox Code Playgroud)

与树类似,一个节点可能包含一个父节点,也可能包含多个其他子节点

任务是将元素排序到适当的层次结构并将子元素添加到其各自父级的子级集合中。我的想法有2种方法:

1) 循环法 …

c# algorithm treeview tree recursion

0
推荐指数
1
解决办法
3354
查看次数

GitHub无法为我的功能分支重新定基:“由于冲突,该分支无法重新定标”

即使当我的功能分支从最新版本的分支出来时master,当我尝试重新建立PR(从功能X到主版本)的基础时,我仍然看到:

由于发生冲突,无法重新建立 该分支的基础,由于在从head分支重新应用单个提交时遇到冲突,因此无法在基础分支之上自动执行该分支的提交。

我了解可以通过以下方式解决此问题:

git checkout master
git rebase feature/x
(resolve conflicts)
Run Code Online (Sandbox Code Playgroud)

但是,直接推到master已锁定,我需要进行PR。feature/x通过拉取请求成功能够将分支重新建立为master 的步骤是什么?

git github

0
推荐指数
2
解决办法
2994
查看次数

如何将此JSON结果解析为对象?

我需要将此JSON字符串解析为我的"WeatherJson"类型的对象.但是我不知道如何解析字符串中的阵列,如"'天气’: [{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}].实体类会是什么样子?

JSON字符串:

{
  "coord": {"lon":79.85,"lat":6.93},
  "sys": {
    "type": 1, 
    "id": 7864, 
    "message": 0.0145,
    "country": "LK",
    "sunrise": 1435883361,
    "sunset": 1435928421
  },
  "weather": [
     {"id":802, "main":"Clouds", "description":"scattered clouds", "icon":"03d"}
  ],
  "base": "stations",
  "main": {
    "temp": 302.15,
    "pressure": 1013,
    "humidity": 79,
    "temp_min": 302.15,
    "temp_max": 302.15
  },
  "visibility":10000,
  "wind": { "speed": 4.1, "deg": 220 },
  "clouds": { "all": 40 },
  "dt": 1435893000,
  "id":1248991,
  "name":"Colombo",
  "cod":200
}
Run Code Online (Sandbox Code Playgroud)

编辑

我需要从代码中检索以下值:

WeatherJson w = new WeatherJson();
Console.WriteLine(w.weather.description);
//that above line was retrieved and stored …
Run Code Online (Sandbox Code Playgroud)

.net c# json json.net

-1
推荐指数
1
解决办法
1108
查看次数