问:
Why do I get, and how do I solve this "String to object of type <objecttype>" error
I am (being an absolute beginner), trying to create a simple tool, that creates some objects and links them.
The objects are:
Customers
Licenses (2 types, extends class)

The idea is to use (one of) the customer company name when creating a license, so the license is linked to a customer.
I use ArrayLists to store the data.

I tried to use the getter for Customer cCompany, but when I try to actually create a new license object, I get errors about incompatible types (String to object of type customer)

How can I fix that error?

Any help is highly appreciated, but please explain well, me being an absolute beginner. I probably overcomplicate stuff....

Some code extracts:

From Main:

```<code>public class Main {

    public static void main(String[] args) {
        //Create customers
        List <Customer> customers = new ArrayList <> (10);
        customers.add(new Customer("TestCompany","John Doe",1234567890,"John@testcompany.com"));

....

//Create Elvis licenses (based on superclass License)
List <ElvisLicense> ellicenses = new ArrayList <> (10);
ellicenses.add(new ElvisLicense("TestCompany","VendorA",1234,"1234-A","Solutions Server gold","1234-dtbk-87654-nlof",10, true , true));
</code>```

Class: Customer:

```<code>class Customer {
    String cCompany;
    private String cName;
    private int cPhone;
    private String cEmail;

    public Customer( String cCompany, String cName,int cPhone, String cEmail)
    {
    this.cCompany = cCompany;
    this.cName = cName;
    this.cPhone = cPhone;
    this.cEmail = cEmail;
    }

    //This getter should be used to link the license to the customer (Done in License.java)
    public String getcCompany() {
        return cCompany;
    }
</code>```

Class License (Superclass)

```<code>class License {
// Used no modifier to set access for Class/Package and Subclass inside the package
Customer licenseCompany;
String lVendor;
int lContractNumber;
String lCertificateNumber;
String lProductName;
String lLicenseKey;
int lNumberOfSeats;

    public License(Customer cCompany, String lVendor, int lContractNumber, String lCertificateNumber,
            String lProductName, String lLicenseKey, int lNumberOfSeats)
    {
    licenseCompany = cCompany;
    this.lVendor = lVendor;
    this.lVendor = lVendor;
    this.lContractNumber = lContractNumber;
    this.lCertificateNumber = lCertificateNumber;
    this.lProductName = lProductName;
    this.lLicenseKey = lLicenseKey;
    this.lNumberOfSeats = lNumberOfSeats;
    }

    public Customer getLicenseCompany() {
        return licenseCompany;
    }

    public void setLicenseCompany(Customer licenseCompany) {
        this.licenseCompany = licenseCompany;
    }

//preparations to allow for example printing the content of an arraylist element
    @Override
    public String toString(){
    return "Customer name " + getLicenseCompany()  + "\n" + "Vendor name " + getlVendor()  + "\n" + "Contract number: " + getlContractNumber() + "\n"
               + "Certificate number: " + getlCertificateNumber() + "\n" +
                "Product name " + getlProductName()  + "\n" + "Licence key: " + getlLicenseKey() + "\n"
               + "Number of seats: " + getlNumberOfSeats();
}

}
</code>```

And the extended class:

```<code>public class ElvisLicense extends License{

private boolean elIsBundle;
private boolean elIsSubscription;

public ElvisLicense(
        Customer licenseCompany,
        String lVendor,
        int lContractNumber,
        String lCertificateNumber,
        String lProductName,
        String lLicenseKey,
        int lNumberOfSeats,
        boolean elIsBundle,
        boolean elIsSubscription
        )

    {
    super(
            licenseCompany,
            lVendor,
            lContractNumber,
            lCertificateNumber,
            lProductName,
            lLicenseKey,
            lNumberOfSeats);

    this.elIsBundle = elIsBundle;
    this.elIsSubscription = elIsSubscription;
    }

.....

@Override
public String toString(){
    return "Customer name " + licenseCompany  + "\n"
            + "Vendor name " + lVendor  + "\n"
            + "Contract number: " + lContractNumber + "\n"
            + "Certificate number: " + lCertificateNumber + "\n"
            + "Product name " + lProductName  + "\n"
            + "Licence key: " + lLicenseKey + "\n"
            + "Number of seats: " + lNumberOfSeats + "\n"
            + "Number of seats: " + elIsBundle + "\n"
            + "Number of seats: " + elIsSubscription;
}

}
</code>```

I expect that the Customername is used when creating a new license.

答:
What you need to do is to use one of the Customer objects you have already created when creating the ElvisLicense object. To more easily find that customer by name I suggest you store them in a map instead of a list with the name as a key.

```<code>Map<String, Customer> customerMap = new HashMap<>();
Customer customer = new Customer("TestCompany","John Doe",1234567890,"John@testcompany.com"));
customerMap.put(customer.getcCompany(), customer);
</code>```

so when creating the license you look up the customer

```<code>List <ElvisLicense> ellicenses = new ArrayList <> (10);
Customer customer = customerMap.get("TestCompany");
if (customer != null) {
    ElvisLicense license = new ElvisLicense(customer,"VendorA",1234,"1234-A","Solutions Server gold","1234-dtbk-87654-nlof",10, true , true));
    ellicenses.add(license);
} else {
   //If the customer isn't found you need some kind of error handling, better than below :)
   System.out.println("Can't create a license, no customer found");
}
</code>```

Body:
I am (being an absolute beginner), trying to create a simple tool, that creates some objects and links them.
The objects are:
Customers
Licenses (2 types, extends class)

The idea is to use (one of) the customer company name when creating a license, so the license is linked to a customer.
I use ArrayLists to store the data.

I tried to use the getter for Customer cCompany, but when I try to actually create a new license object, I get errors about incompatible types (String to object of type customer)

How can I fix that error?

Any help is highly appreciated, but please explain well, me being an absolute beginner. I probably overcomplicate stuff....

Some code extracts:

From Main:

public class Main {

    public static void main(String[] args) {
        //Create customers
        List <Customer> customers = new ArrayList <> (10);
        customers.add(new Customer("TestCompany","John Doe",1234567890,"John@testcompany.com"));

....

//Create Elvis licenses (based on superclass License)
List <ElvisLicense> ellicenses = new ArrayList <> (10);
ellicenses.add(new ElvisLicense("TestCompany","VendorA",1234,"1234-A","Solutions Server gold","1234-dtbk-87654-nlof",10, true , true));

Class: Customer:

class Customer {
    String cCompany;
    private String cName;
    private int cPhone;
    private String cEmail;

    public Customer( String cCompany, String cName,int cPhone, String cEmail)
    {
    this.cCompany = cCompany;
    this.cName = cName;
    this.cPhone = cPhone;
    this.cEmail = cEmail;
    }

    //This getter should be used to link the license to the customer (Done in License.java)
    public String getcCompany() {
        return cCompany;
    }

Class License (Superclass)

class License {
// Used no modifier to set access for Class/Package and Subclass inside the package
Customer licenseCompany;
String lVendor;
int lContractNumber;
String lCertificateNumber;
String lProductName;
String lLicenseKey;
int lNumberOfSeats;

    public License(Customer cCompany, String lVendor, int lContractNumber, String lCertificateNumber,
            String lProductName, String lLicenseKey, int lNumberOfSeats)
    {
    licenseCompany = cCompany;
    this.lVendor = lVendor;
    this.lVendor = lVendor;
    this.lContractNumber = lContractNumber;
    this.lCertificateNumber = lCertificateNumber;
    this.lProductName = lProductName;
    this.lLicenseKey = lLicenseKey;
    this.lNumberOfSeats = lNumberOfSeats;
    }

    public Customer getLicenseCompany() {
        return licenseCompany;
    }

    public void setLicenseCompany(Customer licenseCompany) {
        this.licenseCompany = licenseCompany;
    }

//preparations to allow for example printing the content of an arraylist element
    @Override
    public String toString(){
    return "Customer name " + getLicenseCompany()  + "\n" + "Vendor name " + getlVendor()  + "\n" + "Contract number: " + getlContractNumber() + "\n"
               + "Certificate number: " + getlCertificateNumber() + "\n" +
                "Product name " + getlProductName()  + "\n" + "Licence key: " + getlLicenseKey() + "\n"
               + "Number of seats: " + getlNumberOfSeats();
}

}

And the extended class:

public class ElvisLicense extends License{

private boolean elIsBundle;
private boolean elIsSubscription;

public ElvisLicense(
        Customer licenseCompany,
        String lVendor,
        int lContractNumber,
        String lCertificateNumber,
        String lProductName,
        String lLicenseKey,
        int lNumberOfSeats,
        boolean elIsBundle,
        boolean elIsSubscription
        )

    {
    super(
            licenseCompany,
            lVendor,
            lContractNumber,
            lCertificateNumber,
            lProductName,
            lLicenseKey,
            lNumberOfSeats);

    this.elIsBundle = elIsBundle;
    this.elIsSubscription = elIsSubscription;
    }

.....

@Override
public String toString(){
    return "Customer name " + licenseCompany  + "\n"
            + "Vendor name " + lVendor  + "\n"
            + "Contract number: " + lContractNumber + "\n"
            + "Certificate number: " + lCertificateNumber + "\n"
            + "Product name " + lProductName  + "\n"
            + "Licence key: " + lLicenseKey + "\n"
            + "Number of seats: " + lNumberOfSeats + "\n"
            + "Number of seats: " + elIsBundle + "\n"
            + "Number of seats: " + elIsSubscription;
}

}

I expect that the Customername is used when creating a new license.

Body:
What you need to do is to use one of the Customer objects you have already created when creating the ElvisLicense object. To more easily find that customer by name I suggest you store them in a map instead of a list with the name as a key.

Map<String, Customer> customerMap = new HashMap<>();
Customer customer = new Customer("TestCompany","John Doe",1234567890,"John@testcompany.com"));
customerMap.put(customer.getcCompany(), customer);

so when creating the license you look up the customer

List <ElvisLicense> ellicenses = new ArrayList <> (10);
Customer customer = customerMap.get("TestCompany");
if (customer != null) {
    ElvisLicense license = new ElvisLicense(customer,"VendorA",1234,"1234-A","Solutions Server gold","1234-dtbk-87654-nlof",10, true , true));
    ellicenses.add(license);
} else {
   //If the customer isn't found you need some kind of error handling, better than below :)
   System.out.println("Can't create a license, no customer found");
}


来源: stackexchange

问:
How to updata redis cache using node js
I tried redis cache in node js code.its working fine but its throwing warring msg.how to update redis cache in node js.

Warning msg

node_redis: Deprecated: The GET command contains a "undefined" argument.
This is converted to a "undefined" string now and will return an error from v.3.0 on.
Please handle this in your code to make sure everything works as you intended it to.

package.json

```<code>"dependencies": {
    "express": "^4.17.0",
    "fs": "0.0.1-security",
    "joi": "^14.3.1",
    "mongodb": "^3.2.5",
    "mongodb-autoincrement": "^1.0.1",
    "nodemon": "^1.19.1",
    "querystring": "^0.2.0",
    "redis": "^2.8.0",
    "url": "^0.11.0",
    "util": "^0.12.0"
}
</code>```

答:
I think Its help you, You can update Redis cache by following method.</p>

```<code>const redis = require('redis');
// create and connect redis client to local instance.
const client = redis.createClient(6379);

//key to store results in Redis store
const redisKey = 'user:data';

client.setex(redisKey, 3600, JSON.stringify({name: "Jelly Fish"}));
</code>```

ContentLicense: CC BY-SA 4.0

Title: How to updata redis cache using node js

Body:
I tried redis cache in node js code.its working fine but its throwing warring msg.how to update redis cache in node js.

Warning msg

node_redis: Deprecated: The GET command contains a "undefined" argument.
This is converted to a "undefined" string now and will return an error from v.3.0 on.
Please handle this in your code to make sure everything works as you intended it to.

package.json

"dependencies": {
    "express": "^4.17.0",
    "fs": "0.0.1-security",
    "joi": "^14.3.1",
    "mongodb": "^3.2.5",
    "mongodb-autoincrement": "^1.0.1",
    "nodemon": "^1.19.1",
    "querystring": "^0.2.0",
    "redis": "^2.8.0",
    "url": "^0.11.0",
    "util": "^0.12.0"
}

Body:
I think Its help you, You can update Redis cache by following method.

const redis = require('redis');
// create and connect redis client to local instance.
const client = redis.createClient(6379);

//key to store results in Redis store
const redisKey = 'user:data';

client.setex(redisKey, 3600, JSON.stringify({name: "Jelly Fish"}));


问:
Not in search string - It works when it is
Hope you can help.
I have column A and B
In A, I need to replace all text containing "Forsikringspræmie" with "" (Blank)

This code works. Sub KSV_Remove_Forsikringspræmie()

But in Column B, I need the Opposit, to happen.
And the code Sub KSV_Remove_Not_Forsikringspræmie() dosent work.

```<code>Sub KSV_Remove_Forsikringspræmie()
    Dim KSV_SrchRng As Range, cel As Range
    Set KSV_SrchRng = Range("A1:A99")
    For Each cel In KSV_SrchRng
      If InStr(1, cel.Value, "Forsikringspræmie") > 0 Then
         cel.Value = ""
      End If
    Next cel
End Sub

Sub KSV_Remove_Not_Forsikringspræmie()
    Dim KSV_SrchRng As Range, cel As Range
    Set KSV_SrchRng = Range("B1:B99")
    For Each cel In KSV_SrchRng
      If InStr(1, cel.Value, Not "Forsikringspræmie") Then
         cel.Value = ""
      End If
    Next cel
End Sub
</code>```

答:
In response to your comment to Greg's post (comment reads: with one little error it now deletes every cell, since the cells containing "Forsikringspræmie" they are numberede eg. "Forsikringspræmie1, Forsikringspræmie2" etc.... and a wild card dosent work.)... if you want to replace and keep the numbers that were in the cell, try the Replace function, such that:

```<code>With Columns(1)
    .Replace what:="Forsikringspræmie", replacement:="", searchorder:=xlByColumns, MatchCase:=False
End With
</code>```

Body:
Hope you can help.
I have column A and B
In A, I need to replace all text containing "Forsikringspræmie" with "" (Blank)

This code works. Sub KSV_Remove_Forsikringspræmie()

But in Column B, I need the Opposit, to happen.
And the code Sub KSV_Remove_Not_Forsikringspræmie() dosent work.

Sub KSV_Remove_Forsikringspræmie()
    Dim KSV_SrchRng As Range, cel As Range
    Set KSV_SrchRng = Range("A1:A99")
    For Each cel In KSV_SrchRng
      If InStr(1, cel.Value, "Forsikringspræmie") > 0 Then
         cel.Value = ""
      End If
    Next cel
End Sub

Sub KSV_Remove_Not_Forsikringspræmie()
    Dim KSV_SrchRng As Range, cel As Range
    Set KSV_SrchRng = Range("B1:B99")
    For Each cel In KSV_SrchRng
      If InStr(1, cel.Value, Not "Forsikringspræmie") Then
         cel.Value = ""
      End If
    Next cel
End Sub

Body:
In response to your comment to Greg's post (comment reads: with one little error it now deletes every cell, since the cells containing "Forsikringspræmie" they are numberede eg. "Forsikringspræmie1, Forsikringspræmie2" etc.... and a wild card dosent work.)... if you want to replace and keep the numbers that were in the cell, try the Replace function, such that:

With Columns(1)
    .Replace what:="Forsikringspræmie", replacement:="", searchorder:=xlByColumns, MatchCase:=False
End With


问:
Add IF condition to clickable images to ascertain a pixel value
We have 2 images that we fetched from JSON:

1.Mask image [  name starts with mask_ ]

2.Car image [ name starts with other than mask_ ]

Requirement :

onclick Mask image , i want to display file upload dialog box. it's working fine. but onclick car image, i don't want to display file upload dialog box.

Issue :

onclick car image,  file upload dialog box is displaying. but Car image should't be clickable because it's name started with "other than mask_"

I tried $('.masked-img').css('pointer-events', 'none'); but it did't helped me.

Below is Snippet :

var target;
const imageUrl = "https://i.imgur.com/RzEm1WK.png";

let jsonData = {
  "layers": [{
    "x": 0,
    "height": 612,
    "layers": [{
        "x": 70,
        "src": "ax0HVTs.png",
        "y": 199,
        "height": 296,
        "width": 429,
        "name": "mask_1"
      },
      {
        "name": "car",
        "x": 25,
        "src": "iEA642D.jpg",
        "height": 324,
        "width": 471,
        "y": 22

      }
    ],
    "y": 0,
    "width": 612
  }]
};

const containerElement = $('#container');
const fileUp = $('#fileup');
let mask;

$(function() {
  // Upload image onclick mask image
  containerElement.click(function(e) {
    var res = e.target;
    target = res.id;
    if (e.target.getContext) {
      // click only inside Non Transparent part
      var pixel = e.target.getContext('2d').getImageData(e.offsetX, e.offsetY, 1, 1).data;
      if (pixel[3] === 255) {
        setTimeout(() => {
          $('#fileup').click();
        }, 20);
      }
    }
  });

  // Fetch mask images from json file - IGNORE this code

  function getAllSrc(layers) {
    let arr = [];
    layers.forEach(layer => {
      if (layer.src) {
        arr.push({
          src: layer.src,
          x: layer.x,
          y: layer.y,
          height: layer.height,
          width: layer.width,
          name: layer.name
        });
      } else if (layer.layers) {
        let newArr = getAllSrc(layer.layers);
        if (newArr.length > 0) {
          newArr.forEach(({
            src,
            x,
            y,
            height,
            width,
            name
          }) => {
            arr.push({
              src,
              x: (layer.x + x),
              y: (layer.y + y),
              height,
              width,
              name: (name)
            });
          });
        }
      }
    });
    return arr;
  }

  function json(data) {
    var width = 0;
    var height = 0;

    let arr = getAllSrc(data.layers);
    let layer1 = data.layers;
    width = layer1[0].width;
    height = layer1[0].height;
    let counter = 0;
    let table = [];

    // container dimensions
    containerElement.css('width', width + "px").css('height', height + "px").addClass('temp');
    //end

    for (let {
        src,
        x,
        y,
        name
      } of arr) {

      //Get Height and width of mask image [ edit button ]
      var ImagePosition = arr;
      //code end

      var imageUrl1 = imageUrl;

      var mask = $(".container").mask({
        imageUrl: name.indexOf('mask_') !== -1 ? imageUrl1 : undefined,

        // Fetch Mask images
        maskImageUrl: 'http://i.imgur.com/' + src,
        // end

        onMaskImageCreate: function(img) {
          // Mask image positions
          img.css({
            "position": "absolute",
            "left": x + "px",
            "top": y + "px"
          });
          // end

        },
        id: counter
      });
      // here
      table.push(mask);
      fileup.onchange = function() {

        let mask2 = table[target];
        const newImageLoadedId = mask2.loadImage(URL.createObjectURL(fileup.files[0]));
        document.getElementById('fileup').value = "";

      };
      counter++;
    }
    return mask;
  }
  mask = json(jsonData);
}); // end of function

// Image code

(function($) {
  window.JQmasks = [];
  $.fn.mask = function(options) {
    // This is the easiest way to have default options.
    var settings = $.extend({
      // These are the defaults.
      maskImageUrl: undefined,
      imageUrl: undefined,
      scale: 1,
      id: new Date().getUTCMilliseconds().toString(),
      x: 0, // image start position
      y: 0, // image start position
      onMaskImageCreate: function(div) {},
    }, options);

    // Create the image properties
    settings.maskImage = new Image
    settings.image = new Image

    // set the cross-origin attributes
    settings.maskImage.setAttribute('crossOrigin', 'anonymous');
    settings.image.setAttribute('crossOrigin', 'anonymous');

    settings.maskImage.onload = function() {
      // once the mask is loaded, load the image
      container.loadImage(settings.imageUrl)
      container.drawMask()
    }

    settings.image.onload = function() {
      // once the image is loaded, render to canvas

      container.drawImage()
    }

    var container = $(this);

    let prevX = 0,
      prevY = 0,
      draggable = false,
      img,
      canvas,
      context,
      image,
      timeout,
      initImage = false,
      startX = settings.x,
      startY = settings.y,
      div;

    container.drawMask = function() {
      if (!settings.maskImage) return true;
      canvas.width = settings.maskImage.width;
      canvas.height = settings.maskImage.height;
      context.save();
      context.beginPath();
      context.globalCompositeOperation = "source-over";
      // draw the masked image after scaling
      if (settings.maskImage) context.drawImage(settings.maskImage, 0, 0, settings.maskImage.width, settings.maskImage.height);
      context.restore()
    };

    container.drawImage = function() {

      const img = settings.image

      settings.x = (canvas.width - (img.width * settings.scale)) / 2
      settings.y = (canvas.height - (img.height * settings.scale)) / 2

      context.globalCompositeOperation = 'source-atop';
      if (img) context.drawImage(img, settings.x, settings.y, img.width * settings.scale, img.height * settings.scale);
      context.restore()
      initImage = false;
    }

    // change the draggable image

    container.loadImage = function(imageUrl) {
      if (!imageUrl) return true;
      settings.y = startY;
      settings.x = startX;
      prevX = prevY = 0;

      initImage = true;

      settings.image.src = imageUrl; // CHANGED

      // sirpepole Add this
      return settings.id;
    };

    container.loadMaskImage = function(imageUrl, from) {

      canvas = document.createElement("canvas");
      context = canvas.getContext('2d');
      canvas.setAttribute("draggable", "true");
      canvas.setAttribute("id", settings.id);
      // settings.maskImageUrl = imageUrl;
      settings.maskImage.src = imageUrl // CHANGED

      div = $("
", {
        "class": "masked-img"
      }).append(canvas);

      // div.find("canvas").on('touchstart mousedown', function(event)
      div.find("canvas").on('dragstart', function(event) {
        if (event.handled === false) return;
        event.handled = true;
        container.onDragStart(event);
      });

      div.find("canvas").on('touchend mouseup', function(event) {
        if (event.handled === false) return;
        event.handled = true;
        container.selected(event);
      });

      div.find("canvas").bind("dragover", container.onDragOver);

      container.append(div);
      if (settings.onMaskImageCreate)
        settings.onMaskImageCreate(div);

      // container.loadImage(settings.imageUrl);
      // Moved this to the settings.maskImage.onload
    };
    if (settings.maskImageUrl) {
      container.loadMaskImage(settings.maskImageUrl);
    }
    JQmasks.push({
      item: container,
      id: settings.id
    })
    // Edit image
    div.addClass('masked-img' + settings.id);
    div.attr('data-id', settings.id);
    // ends
    return container;
  };
}(jQuery));```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
  background: silver;
  position: relative;
}

.container img {
  position: absolute;
  top: 0;
  bottom: 250px;
  left: 0;
  right: 0;
  margin: auto;
  z-index: 999;
}

.masked-img {
  overflow: hidden;
  position: relative;
}</code>```

<input id="fileup" name="fileup" type="file" style="display:none" />

```

Here is Codepen, Fiddle & Full code in pastebin

We implemented similar feature that displaying "+" icon only on mask images....

答:
Your for...Of loops are helped in this question, by mapping you are fetch mask images
and using help of includes function you can search it and after you can add pointer-events CSS property.

ImagePosition.map(function (cur, index) {
    var available = cur.name.includes('mask_');

    if (!available) {
        $('.masked-img' + index).css('pointer-events', 'none');
    }
});
```

Body:
We have 2 images that we fetched from JSON:

1.Mask image [  name starts with mask_ ]

2.Car image [ name starts with other than mask_ ]

Requirement :

onclick Mask image , i want to display file upload dialog box. it's working fine. but onclick car image, i don't want to display file upload dialog box.

Issue :

onclick car image,  file upload dialog box is displaying. but Car image should't be clickable because it's name started with "other than mask_"

I tried $('.masked-img').css('pointer-events', 'none'); but it did't helped me.

Below is Snippet :

var target;
const imageUrl = "https://i.imgur.com/RzEm1WK.png";

let jsonData = {
  "layers": [{
    "x": 0,
    "height": 612,
    "layers": [{
        "x": 70,
        "src": "ax0HVTs.png",
        "y": 199,
        "height": 296,
        "width": 429,
        "name": "mask_1"
      },
      {
        "name": "car",
        "x": 25,
        "src": "iEA642D.jpg",
        "height": 324,
        "width": 471,
        "y": 22

      }
    ],
    "y": 0,
    "width": 612
  }]
};

const containerElement = $('#container');
const fileUp = $('#fileup');
let mask;

$(function() {
  // Upload image onclick mask image
  containerElement.click(function(e) {
    var res = e.target;
    target = res.id;
    if (e.target.getContext) {
      // click only inside Non Transparent part
      var pixel = e.target.getContext('2d').getImageData(e.offsetX, e.offsetY, 1, 1).data;
      if (pixel[3] === 255) {
        setTimeout(() => {
          $('#fileup').click();
        }, 20);
      }
    }
  });

  // Fetch mask images from json file - IGNORE this code

  function getAllSrc(layers) {
    let arr = [];
    layers.forEach(layer => {
      if (layer.src) {
        arr.push({
          src: layer.src,
          x: layer.x,
          y: layer.y,
          height: layer.height,
          width: layer.width,
          name: layer.name
        });
      } else if (layer.layers) {
        let newArr = getAllSrc(layer.layers);
        if (newArr.length > 0) {
          newArr.forEach(({
            src,
            x,
            y,
            height,
            width,
            name
          }) => {
            arr.push({
              src,
              x: (layer.x + x),
              y: (layer.y + y),
              height,
              width,
              name: (name)
            });
          });
        }
      }
    });
    return arr;
  }

  function json(data) {
    var width = 0;
    var height = 0;

    let arr = getAllSrc(data.layers);
    let layer1 = data.layers;
    width = layer1[0].width;
    height = layer1[0].height;
    let counter = 0;
    let table = [];

    // container dimensions
    containerElement.css('width', width + "px").css('height', height + "px").addClass('temp');
    //end

    for (let {
        src,
        x,
        y,
        name
      } of arr) {

      //Get Height and width of mask image [ edit button ]
      var ImagePosition = arr;
      //code end

      var imageUrl1 = imageUrl;

      var mask = $(".container").mask({
        imageUrl: name.indexOf('mask_') !== -1 ? imageUrl1 : undefined,

        // Fetch Mask images
        maskImageUrl: 'http://i.imgur.com/' + src,
        // end

        onMaskImageCreate: function(img) {
          // Mask image positions
          img.css({
            "position": "absolute",
            "left": x + "px",
            "top": y + "px"
          });
          // end

        },
        id: counter
      });
      // here
      table.push(mask);
      fileup.onchange = function() {

        let mask2 = table[target];
        const newImageLoadedId = mask2.loadImage(URL.createObjectURL(fileup.files[0]));
        document.getElementById('fileup').value = "";

      };
      counter++;
    }
    return mask;
  }
  mask = json(jsonData);
}); // end of function

// Image code

(function($) {
  window.JQmasks = [];
  $.fn.mask = function(options) {
    // This is the easiest way to have default options.
    var settings = $.extend({
      // These are the defaults.
      maskImageUrl: undefined,
      imageUrl: undefined,
      scale: 1,
      id: new Date().getUTCMilliseconds().toString(),
      x: 0, // image start position
      y: 0, // image start position
      onMaskImageCreate: function(div) {},
    }, options);

    // Create the image properties
    settings.maskImage = new Image
    settings.image = new Image

    // set the cross-origin attributes
    settings.maskImage.setAttribute('crossOrigin', 'anonymous');
    settings.image.setAttribute('crossOrigin', 'anonymous');

    settings.maskImage.onload = function() {
      // once the mask is loaded, load the image
      container.loadImage(settings.imageUrl)
      container.drawMask()
    }

    settings.image.onload = function() {
      // once the image is loaded, render to canvas

      container.drawImage()
    }

    var container = $(this);

    let prevX = 0,
      prevY = 0,
      draggable = false,
      img,
      canvas,
      context,
      image,
      timeout,
      initImage = false,
      startX = settings.x,
      startY = settings.y,
      div;

    container.drawMask = function() {
      if (!settings.maskImage) return true;
      canvas.width = settings.maskImage.width;
      canvas.height = settings.maskImage.height;
      context.save();
      context.beginPath();
      context.globalCompositeOperation = "source-over";
      // draw the masked image after scaling
      if (settings.maskImage) context.drawImage(settings.maskImage, 0, 0, settings.maskImage.width, settings.maskImage.height);
      context.restore()
    };

    container.drawImage = function() {

      const img = settings.image

      settings.x = (canvas.width - (img.width * settings.scale)) / 2
      settings.y = (canvas.height - (img.height * settings.scale)) / 2

      context.globalCompositeOperation = 'source-atop';
      if (img) context.drawImage(img, settings.x, settings.y, img.width * settings.scale, img.height * settings.scale);
      context.restore()
      initImage = false;
    }

    // change the draggable image

    container.loadImage = function(imageUrl) {
      if (!imageUrl) return true;
      settings.y = startY;
      settings.x = startX;
      prevX = prevY = 0;

      initImage = true;

      settings.image.src = imageUrl; // CHANGED

      // sirpepole Add this
      return settings.id;
    };

    container.loadMaskImage = function(imageUrl, from) {

      canvas = document.createElement("canvas");
      context = canvas.getContext('2d');
      canvas.setAttribute("draggable", "true");
      canvas.setAttribute("id", settings.id);
      // settings.maskImageUrl = imageUrl;
      settings.maskImage.src = imageUrl // CHANGED

      div = $("
", {
        "class": "masked-img"
      }).append(canvas);

      // div.find("canvas").on('touchstart mousedown', function(event)
      div.find("canvas").on('dragstart', function(event) {
        if (event.handled === false) return;
        event.handled = true;
        container.onDragStart(event);
      });

      div.find("canvas").on('touchend mouseup', function(event) {
        if (event.handled === false) return;
        event.handled = true;
        container.selected(event);
      });

      div.find("canvas").bind("dragover", container.onDragOver);

      container.append(div);
      if (settings.onMaskImageCreate)
        settings.onMaskImageCreate(div);

      // container.loadImage(settings.imageUrl);
      // Moved this to the settings.maskImage.onload
    };
    if (settings.maskImageUrl) {
      container.loadMaskImage(settings.maskImageUrl);
    }
    JQmasks.push({
      item: container,
      id: settings.id
    })
    // Edit image
    div.addClass('masked-img' + settings.id);
    div.attr('data-id', settings.id);
    // ends
    return container;
  };
}(jQuery));

.container {
  background: silver;
  position: relative;
}

.container img {
  position: absolute;
  top: 0;
  bottom: 250px;
  left: 0;
  right: 0;
  margin: auto;
  z-index: 999;
}

.masked-img {
  overflow: hidden;
  position: relative;
}

<input id="fileup" name="fileup" type="file" style="display:none" />

Here is Codepen, Fiddle & Full code in pastebin

We implemented similar feature that displaying "+" icon only on mask images....


问:
Separation of SEO-friendly URLs
I need to create a site (e-shop) in Laravel using SEO-friendly and hierarchical URLs.

Some examples are:

www.example.com/cat1/cat11 (which points to a category product-listing)

www.example.com/cat1/cat11/cat111 (which points to a category product-listing)

www.example.com/cat1/cat11/cat111/product-title (which points to a product-details page)

www.example.com/contact-us (which points to a page)

I can parse the above URLs and find the needed slug, but I am not sure which controller will be responsible for each route.

Possible thoughts:

1) Add prefix to each URL type, in order to know the controller
e.g.

www.example.com/categories/cat1/cat11/cat111 > CategoryController

www.example.com/products/cat1/cat11/cat111/product-title > ProductController

www.example.com/page/contact-us > PageController

2) Pre-generate and store in a table all the site's URLs. The table can contain two columns: the URL (cat1/cat11/cat111) and the model:id (category:8)
A global controller will parse the URL and using the table can load the required model & id.

Any other idea?

答:
We were already faced with this problem multiple times. I think there is no "best way". It depends on the given circumstances.

The structure /products/cat1/cat11/cat111/product-title should be used carefully. It could lead to duplicate content issues when not adding the canonical tag properly.

We ended with the following setup:

www.site.com/shop/product-title > Route::get('/shop/{slug}', [\App\Http\Controllers\ProductController::class, 'show'])->name('product.show');

www.site.com/shop/categories/cat1/cat11/cat111 > Route::get('/shop/categories/{slugNum}', [\App\Http\Controllers\CategoryController::class, 'show'])->name('category.show')->where('slugNum', '(.*)');

www.site.com/contact-us > Route::get('/{any}', [\App\Http\Controllers\PageController::class, 'show'])->name('page.show')->where('any', '.*')->fallback();

Hope this helps.

Title: Separation of SEO-friendly URLs


问:
Debug Vue.js App with VS Code. Error Unverified Breakpoint
I have the following problem. I want to debug my Vue.js project with VS Code and Chrome. So I follow the official guide on the website Guide but it dont work. The Problem is that I always get the error :

```<code> unverified breakpoint
</code>```

What do I wrong?

This is my vue.config.js

```<code>    module.exports = {
    configureWebpack: {
      devtool: 'source-map'
    }
  }
</code>```

This is my debugging stetting:

```<code>    {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "vuejs: chrome",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}/src",
            "breakOnLoad": true,
            "sourceMapPathOverrides": {
                "webpack:/src/*": "${webRoot}/*",
                "webpack:///./*": "${webRoot}/*",
                "webpack:///src/*": "${webRoot}/*",
                "webpack:///*": "*",
                "webpack:///./~/*": "${webRoot}/node_modules/*",
                "meteor://app/*": "${webRoot}/*"
            }
        }
    ]
}
</code>```

And this is my package.json

```<code>    "name": "test-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
</code>```

When I try npm run serve I get the error message unverified breakpoint and my breakpoint is never be hit.

I use the vue-cli 3 to generate the project.

Can someone help me pls?

Update

Maybe something is wrong with the path. Because when i run .scripts in the debugger console in VS Code I get paths like this

```<code>(c:\Users\XY\Desktop\Vue\route-app\webpack:\src\main.ts)
</code>```

But there is no folder webpack:. But I have no idea why he is thinking that there is a folder. He make this in every file.

And in my tsconfig.js I already have "sourceMap": true.

Update 2

When I check the checkbox All Exceptions, VS Code show me all Exceptions in my App (they are catched). But my Breakpoints still dont work.

Update 3

My project looks like this

```<code>C:\Users\User\Desktop\Vue\route-app
|
-----.vscode
     |
     -----launch.json
|
-----node_modules
     |
     ----- modules etc.
|
-----public
     |
     ----- index.html
     |
     ----- manifest.json
     |
     ----- favicon.ico
|
-----src
     |
     ----- components
           |
           ----- all my components.vue files
     |
     ----- views
           |
           ----- all my views.vue files (this files are for routing)
     |
     ----- App.vue
     |
     ----- main.ts
     |
     ----- registerServiceWorker.ts
     |
     ----- router.ts
     |
     ----- shims-tsx.d.ts
     |
     ----- shims-vue.d.ts
     |
     ----- store.ts
|
-----.postcssrc.js
|
-----babel.config.js
|
-----package-lock.json
|
-----package.json
|
-----tsconfig.json
|
-----tslint.json
|
-----vue.config.js
</code>```

答:
For me my webroot folder was not set correctly.

My vue files browser is set to:

```<code>D:\Workspace
</code>```

The project is in that folder as

```<code>D:\Workspace\vue_project1
</code>```

The webroot setting in the launch.json had to change to:

```<code>"webRoot": "${workspaceFolder}/vue_project1"
</code>```

Body:
I have the following problem. I want to debug my Vue.js project with VS Code and Chrome. So I follow the official guide on the website Guide but it dont work. The Problem is that I always get the error :

 unverified breakpoint

What do I wrong?

This is my vue.config.js

    module.exports = {
    configureWebpack: {
      devtool: 'source-map'
    }
  }

This is my debugging stetting:

    {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "vuejs: chrome",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}/src",
            "breakOnLoad": true,
            "sourceMapPathOverrides": {
                "webpack:/src/*": "${webRoot}/*",
                "webpack:///./*": "${webRoot}/*",
                "webpack:///src/*": "${webRoot}/*",
                "webpack:///*": "*",
                "webpack:///./~/*": "${webRoot}/node_modules/*",
                "meteor://app/*": "${webRoot}/*"
            }
        }
    ]
}

And this is my package.json

    "name": "test-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },

When I try npm run serve I get the error message unverified breakpoint and my breakpoint is never be hit.

I use the vue-cli 3 to generate the project.

Can someone help me pls?

Update

Maybe something is wrong with the path. Because when i run .scripts in the debugger console in VS Code I get paths like this

(c:\Users\XY\Desktop\Vue\route-app\webpack:\src\main.ts)

But there is no folder webpack:. But I have no idea why he is thinking that there is a folder. He make this in every file.

And in my tsconfig.js I already have "sourceMap": true.

Update 2

When I check the checkbox All Exceptions, VS Code show me all Exceptions in my App (they are catched). But my Breakpoints still dont work.

Update 3

My project looks like this

C:\Users\User\Desktop\Vue\route-app
|
-----.vscode
     |
     -----launch.json
|
-----node_modules
     |
     ----- modules etc.
|
-----public
     |
     ----- index.html
     |
     ----- manifest.json
     |
     ----- favicon.ico
|
-----src
     |
     ----- components
           |
           ----- all my components.vue files
     |
     ----- views
           |
           ----- all my views.vue files (this files are for routing)
     |
     ----- App.vue
     |
     ----- main.ts
     |
     ----- registerServiceWorker.ts
     |
     ----- router.ts
     |
     ----- shims-tsx.d.ts
     |
     ----- shims-vue.d.ts
     |
     ----- store.ts
|
-----.postcssrc.js
|
-----babel.config.js
|
-----package-lock.json
|
-----package.json
|
-----tsconfig.json
|
-----tslint.json
|
-----vue.config.js

Body:
For me my webroot folder was not set correctly.

My vue files browser is set to:

D:\Workspace

The project is in that folder as

D:\Workspace\vue_project1

The webroot setting in the launch.json had to change to:

"webRoot": "${workspaceFolder}/vue_project1"


问:
Airflow User Access management
I am evaluating Airflow as a Job scheduling tool.
1) Can we create few users like admin, developer and readonly user?
2) Can we implement access control to the Airflow UI
3) Can we control access to the dags folder? Is there any dag Deployment mechanism</p>

答:
Taken from Airflow read the docs.

This is all functional if your Airflow version is 1.10 or higher. You must set rbac= True in your airflow.cfg file. I believe if you are updating airflow and not installing fresh, you must also run airflow create_user to create the admin user.

Can we create few users like admin, developer and readonly user?

Yes. There are five roles created for Airflow by default: Public, Admin, Viewer, User, Op.

Public has no permissions at all.

Admin has the full set of permissions

Viewer:  for users without DAG ownership. They have read access to DAGs, but cannot perform any action that could potentially change the state of the database.

User: this is for users with DAG ownership. They have both read and write access to DAGs, therefore can perform actions such as starting/stopping scheduled DAGs, running DAGs ad-hoc, clearing historical DagRuns or marking DagRuns as success/failure, etc.

Op: this is for devops that handle Airflow deployment and maintain its uptime. They have access to airflow configuration files via the UI, and can modify shared objects like Variables and Connections.

Can we implement access control to the Airflow UI?

You can restrict usage to the server Airflow is hosted on, restricting access by SSH authentication. Users then must be tunneled into the server to view the UI.

Can we control access to the dags folder?

Yes through user groups on the Airflow server.

Is there any dag Deployment mechanism

No not to my knowledge, but this is relatively easy to implement. Commit your updated DAGS to an online repository like SVN/Git. Use a bash script to check for new updates and pull the updated ones down for deployment.

Check out airflow security section for more information.

Title: Airflow User Access management


问:
Iterate 3 items in Angular Carousel in a Page as in the example dynamically
I want to display angular Carousel dynamically showing three items in the page as the example given here https://github.com/lijoos/angular-carousal But all the items are getting displayed in a single page instead of pagination happening as per the example in the link above

I have tried as per the example given in https://github.com/lijoos/angular-carousal

```<code><mat-card class="mat-parent">
    <carousel>
        <div class="carousel-inner" align="center" role="listbox">

            <slide>
                <div class="carousel-item" style="display: block; width: 100%;"   >
                    <div class="col-md-4"  *ngFor="let vehicle of vehichleArry;let i = index" >
                        <mat-card class="example-card">
                            <img mat-card-image src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(34).jpg" alt="Photo of a Shiba Inu">
                            <mat-card-content>
                                <div class="card-body">
                                    <h4 class="card-title">{{vehichleArry[i].vehicleType}}</h4>
                                    <p>Some quick example text to build on the card title and make up the bulk of the card's
                                        content.
                                    </p>
                                    <button mat-raised-button color="primary" (click)="navigate(vehicle)">Primary</button>
                                </div>
                            </mat-card-content>
                        </mat-card>
                    </div>
                    <div class="col-md-4" *ngIf="vehichleArry[i+1]" >
                            <mat-card class="example-card">
                                <img mat-card-image src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(34).jpg" alt="Photo of a Shiba Inu">
                                <mat-card-content>
                                    <div class="card-body">
                                        <h4 class="card-title">{{vehichleArry[i+1].vehicleType}}</h4>
                                        <p>Some quick example text to build on the card title and make up the bulk of the card's
                                            content.
                                        </p>
                                        <button mat-raised-button color="primary" (click)="navigate(vehicle)">Primary</button>
                                    </div>
                                </mat-card-content>
                            </mat-card>
                        </div>

                  <div class="col-md-4" *ngIf="vehichleArry[i+2]" >
                        <mat-card class="example-card">
                            <img mat-card-image src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(34).jpg" alt="Photo of a Shiba Inu">
                            <mat-card-content>
                                <div class="card-body">
                                    <h4 class="card-title">{{vehichleArry[i+2].vehicleType}}</h4>
                                    <p>Some quick example text to build on the card title and make up the bulk of the card's
                                        content.
                                    </p>
                                    <button mat-raised-button color="primary" (click)="navigate(vehicle)">Primary</button>
                                </div>
                            </mat-card-content>
                        </mat-card>
                    </div>
              </div>
            </slide>

           </div>
    </carousel>
</mat-card>
</code>```

Expected Result is I have an array of objects which should be shown three at a time in a page whereas the actual results show all the items in the page.

答: Iterated the slide tag and it worked perfectly.

Body:
I want to display angular Carousel dynamically showing three items in the page as the example given here https://github.com/lijoos/angular-carousal But all the items are getting displayed in a single page instead of pagination happening as per the example in the link above

I have tried as per the example given in https://github.com/lijoos/angular-carousal

<mat-card class="mat-parent">
    <carousel>

            <slide>

                        <mat-card class="example-card">

                            <mat-card-content>

{{vehichleArry[i].vehicleType}}

Some quick example text to build on the card title and make up the bulk of the card's
                                        content.

                                    <button mat-raised-button color="primary" (click)="navigate(vehicle)">Primary</button>

                            </mat-card-content>
                        </mat-card>

                            <mat-card class="example-card">

                                <mat-card-content>

{{vehichleArry[i+1].vehicleType}}

Some quick example text to build on the card title and make up the bulk of the card's
                                            content.

                                        <button mat-raised-button color="primary" (click)="navigate(vehicle)">Primary</button>

                                </mat-card-content>
                            </mat-card>

                        <mat-card class="example-card">

                            <mat-card-content>

{{vehichleArry[i+2].vehicleType}}

Some quick example text to build on the card title and make up the bulk of the card's
                                        content.

                                    <button mat-raised-button color="primary" (click)="navigate(vehicle)">Primary</button>

                            </mat-card-content>
                        </mat-card>

            </slide>

    </carousel>
</mat-card>

Expected Result is I have an array of objects which should be shown three at a time in a page whereas the actual results show all the items in the page.


问:
R Holt Winters Error in decompose 'no or less than 2 periods'
I have an R Time Series at the weekly level starting at Jan 7, 2013 and ending at May 23 2016.

I created the time series using the following code:

```<code>    start_date <- min(Orders_All_weekly$Week_Start)

    Orders_Weekly.ts <- ts(Orders_All_weekly$Sales, start = decimal_date(ymd(start_date)), freq = (365.25/7))

    Orders_Weekly.stl <- stl(Orders_Weekly.ts, s.window = 'periodic')
</code>```

I am attempting to run a Holt Winters time series on these data, and I am receiving the error

```<code>Orders_Weekly.hw <- HoltWinters(Orders_Weekly.stl)

Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) :
  time series has no or less than 2 periods
</code>```

I have seen several people post this error and the common response has been that the data did not, in fact, have at least two periods...which is necessary for this procedure.  Unless I'm completely misunderstanding the meaning of this (which is possible) I have more than the required two periods.  My data are at the weekly level, and I have 3+ years of observations.

Am I setting this up incorrectly?  Or is the error essentially saying there is no seasonality?

```<code>ID   Week_Start     Sales
1   2013-04-08  932662.9
3   2013-05-13 1021574.4
4   2013-05-20  913812.9
5   2013-06-17 1086239.1
7   2013-08-26  762829.3
8   2013-11-18 1085033.0
9   2013-12-02  897158.4
10  2013-12-09  776733.7
11  2013-12-23  867362.8
12  2013-02-04  666362.0
13  2013-02-18  748603.2
15  2013-07-22 1005986.7
16  2013-09-02  896582.8
17  2013-10-28  868364.8
18  2014-01-06  814648.7
19  2014-02-10  847342.4
20  2014-02-17  869374.3
21  2014-03-17  827677.6
22  2014-03-24  897462.3
23  2014-03-31  850542.4
24  2014-04-21 1139619.4
25  2014-07-28  889043.3
26  2014-08-04 1097560.6
27  2014-09-08 1029379.4
28  2014-10-13  998094.8
29  2014-11-10 1238445.9
30  2014-12-15 1204006.6
31  2014-07-14 1106800.6
32  2014-09-01  730030.8
33  2014-10-06 1085331.8
34  2014-05-05 1072926.8
35  2014-05-19  863283.7
36  2015-01-19 1095186.1
37  2015-02-02  866258.2
38  2015-02-16 1006247.0
39  2015-03-23 1214339.7
40  2015-04-20 1181482.9
41  2015-05-18 1112542.4
42  2015-06-01 1188714.7
43  2015-07-20 1216050.4
45  2015-08-17  848302.8
46  2015-08-24 1081198.9
47  2015-09-14  916539.8
48  2015-09-28  957177.8
49  2015-10-26  964467.1
50  2015-11-02 1063949.1
51  2015-01-12  879343.9
53  2015-03-09 1245047.9
55  2015-11-16  913514.4
56  2015-02-09 1108247.6
57  2015-12-28 1014929.2
58  2016-01-25  946786.3
59  2016-02-01  891230.8
60  2016-02-29 1274039.8
61  2016-03-07  847501.8
62  2016-04-04 1057844.1
64  2016-04-11 1207347.4
65  2016-04-18 1159690.4
66  2016-05-02 1394727.6
67  2016-05-23 1044129.3
68  2013-03-04 1040017.1
69  2013-03-11  984574.2
70  2013-04-15 1054174.1
72  2013-04-29  952720.1
73  2013-05-06 1000977.1
74  2013-06-03 1091743.6
75  2013-07-01  955164.8
76  2013-08-12  808803.7
77  2013-09-23  960096.4
78  2013-09-30  814014.4
79  2013-10-14  743264.9
81  2013-01-28  956396.4
84  2013-10-21  959058.5
85  2013-11-11  915108.6
90  2013-01-14  867140.6
91  2014-01-27  910063.7
92  2014-03-10  963144.2
93  2014-04-07  975789.6
95  2014-04-28 1030313.7
97  2014-05-26 1139089.3
99  2014-06-09 1077980.6
100 2014-06-30 1019326.6
101 2014-09-15  666787.6
103 2014-11-03 1059089.4
105 2014-11-24  705428.6
106 2014-12-22  889368.8
108 2014-06-23 1046989.4
110 2015-02-23 1327066.4
112 2015-04-13 1110673.9
115 2015-06-08 1177799.1
116 2015-07-06 1314697.7
118 2015-07-27 1094805.6
119 2015-08-03  882394.2
120 2015-09-21 1159233.2
121 2015-10-19 1171636.9
122 2015-11-23 1036050.9
125 2015-12-21  984050.8
128 2016-01-04 1371348.3
129 2016-01-11 1086225.4
131 2016-02-22 1077692.4
137 2013-03-18  854699.1
141 2013-05-27 1011870.1
142 2013-08-05  893878.4
143 2013-12-16  801215.2
148 2013-10-07  805962.8
150 2013-11-04  801729.8
152 2013-08-19  726361.0
155 2014-02-24  979288.7
158 2014-04-14 1006729.5
161 2014-07-07 1102600.4
162 2014-08-11  979494.5
164 2014-10-20  901047.1
166 2014-10-27 1260062.0
169 2014-12-29 1022656.2
171 2014-08-18  976136.5
175 2015-03-02  897352.6
177 2015-03-30 1059103.8
178 2015-05-11 1033694.4
179 2015-06-29 1037959.4
182 2015-09-07 1230050.6
183 2015-10-12  975898.2
185 2015-12-07 1057603.4
186 2015-12-14  953718.2
189 2015-04-06 1233091.9
190 2015-04-27 1176994.2
192 2015-01-26 1256182.6
196 2016-01-18  955919.5
197 2016-02-15  954623.5
198 2016-03-14  740724.2
199 2013-01-07  924205.2
201 2013-02-11  672150.0
202 2013-03-25  769391.5
205 2013-06-10  870971.1
206 2013-06-24 1043166.2
208 2013-07-15 1106379.4
210 2013-09-09  916382.0
215 2013-04-22  934307.5
217 2013-12-30  974004.0
219 2014-01-13  972211.2
220 2014-01-20  952294.8
221 2014-02-03  946820.6
225 2014-06-02 1182837.6
228 2014-08-25  912550.8
234 2014-03-03 1013797.0
245 2015-06-15  946565.2
246 2015-07-13 1139633.6
248 2015-08-10 1080701.8
249 2015-08-31 1052796.2
253 2015-11-30  980493.4
259 2016-03-28 1105384.2
264 2016-02-08  897832.2
267 2013-02-25  766646.8
269 2013-04-01  954419.8
281 2013-11-25  852430.6
286 2013-09-16  997656.1
290 2014-07-21 1171519.8
294 2014-09-29  804772.4
298 2014-12-01  813872.0
299 2014-12-08 1005479.1
304 2014-06-16  981782.5
312 2015-03-16 1009182.7
315 2015-05-25 1166947.6
329 2015-01-05  903062.3
337 2016-03-21 1299648.7
338 2016-04-25 1132090.1
341 2013-01-21  818799.7
364 2014-05-12 1035870.7
367 2014-09-22 1234683.8
381 2015-06-22  990619.5
383 2015-10-05 1175100.6
385 2015-11-09 1095345.9
395 2016-05-16 1121192.5
399 2016-05-09 1175343.4
407 2013-07-08 1035513.8
430 2014-11-17 1024473.3
443 2015-05-04 1063411.6
476 2013-07-29  809045.3
</code>```

答:
I'm not sure if this completely answers the question but I was able to get a result out of your data with the slightly modified code below.

Hope this helps!

One point, I first sorted the data by date, assuming this was part of your intent.

```<code>Orders_Sorted <- Orders_Weekly[order(Orders_Weekly$Week_Start),] # Sort by date (unless you want to keep the data out of date order for some reason)
Orders_Weekly.ts <- ts(Orders_Sorted$Sales, frequency = (365.25/7)) # Convert df to time series
Orders_Weekly.hw <- HoltWinters(x=Orders_Weekly.ts, beta = FALSE, gamma = FALSE) # Run HW
plot(Orders_Weekly.hw) # Show plot of HW output
</code>```

This produces the plot below.

Plot of Holt-Winters exponential smoothing of data

ContentLicense: CC BY-SA 3.0

Body:
I have an R Time Series at the weekly level starting at Jan 7, 2013 and ending at May 23 2016.

I created the time series using the following code:

    start_date <- min(Orders_All_weekly$Week_Start)

    Orders_Weekly.ts <- ts(Orders_All_weekly$Sales, start = decimal_date(ymd(start_date)), freq = (365.25/7))

    Orders_Weekly.stl <- stl(Orders_Weekly.ts, s.window = 'periodic')

I am attempting to run a Holt Winters time series on these data, and I am receiving the error

Orders_Weekly.hw <- HoltWinters(Orders_Weekly.stl)

Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) :
  time series has no or less than 2 periods

I have seen several people post this error and the common response has been that the data did not, in fact, have at least two periods...which is necessary for this procedure.  Unless I'm completely misunderstanding the meaning of this (which is possible) I have more than the required two periods.  My data are at the weekly level, and I have 3+ years of observations.

Am I setting this up incorrectly?  Or is the error essentially saying there is no seasonality?

ID   Week_Start     Sales
1   2013-04-08  932662.9
3   2013-05-13 1021574.4
4   2013-05-20  913812.9
5   2013-06-17 1086239.1
7   2013-08-26  762829.3
8   2013-11-18 1085033.0
9   2013-12-02  897158.4
10  2013-12-09  776733.7
11  2013-12-23  867362.8
12  2013-02-04  666362.0
13  2013-02-18  748603.2
15  2013-07-22 1005986.7
16  2013-09-02  896582.8
17  2013-10-28  868364.8
18  2014-01-06  814648.7
19  2014-02-10  847342.4
20  2014-02-17  869374.3
21  2014-03-17  827677.6
22  2014-03-24  897462.3
23  2014-03-31  850542.4
24  2014-04-21 1139619.4
25  2014-07-28  889043.3
26  2014-08-04 1097560.6
27  2014-09-08 1029379.4
28  2014-10-13  998094.8
29  2014-11-10 1238445.9
30  2014-12-15 1204006.6
31  2014-07-14 1106800.6
32  2014-09-01  730030.8
33  2014-10-06 1085331.8
34  2014-05-05 1072926.8
35  2014-05-19  863283.7
36  2015-01-19 1095186.1
37  2015-02-02  866258.2
38  2015-02-16 1006247.0
39  2015-03-23 1214339.7
40  2015-04-20 1181482.9
41  2015-05-18 1112542.4
42  2015-06-01 1188714.7
43  2015-07-20 1216050.4
45  2015-08-17  848302.8
46  2015-08-24 1081198.9
47  2015-09-14  916539.8
48  2015-09-28  957177.8
49  2015-10-26  964467.1
50  2015-11-02 1063949.1
51  2015-01-12  879343.9
53  2015-03-09 1245047.9
55  2015-11-16  913514.4
56  2015-02-09 1108247.6
57  2015-12-28 1014929.2
58  2016-01-25  946786.3
59  2016-02-01  891230.8
60  2016-02-29 1274039.8
61  2016-03-07  847501.8
62  2016-04-04 1057844.1
64  2016-04-11 1207347.4
65  2016-04-18 1159690.4
66  2016-05-02 1394727.6
67  2016-05-23 1044129.3
68  2013-03-04 1040017.1
69  2013-03-11  984574.2
70  2013-04-15 1054174.1
72  2013-04-29  952720.1
73  2013-05-06 1000977.1
74  2013-06-03 1091743.6
75  2013-07-01  955164.8
76  2013-08-12  808803.7
77  2013-09-23  960096.4
78  2013-09-30  814014.4
79  2013-10-14  743264.9
81  2013-01-28  956396.4
84  2013-10-21  959058.5
85  2013-11-11  915108.6
90  2013-01-14  867140.6
91  2014-01-27  910063.7
92  2014-03-10  963144.2
93  2014-04-07  975789.6
95  2014-04-28 1030313.7
97  2014-05-26 1139089.3
99  2014-06-09 1077980.6
100 2014-06-30 1019326.6
101 2014-09-15  666787.6
103 2014-11-03 1059089.4
105 2014-11-24  705428.6
106 2014-12-22  889368.8
108 2014-06-23 1046989.4
110 2015-02-23 1327066.4
112 2015-04-13 1110673.9
115 2015-06-08 1177799.1
116 2015-07-06 1314697.7
118 2015-07-27 1094805.6
119 2015-08-03  882394.2
120 2015-09-21 1159233.2
121 2015-10-19 1171636.9
122 2015-11-23 1036050.9
125 2015-12-21  984050.8
128 2016-01-04 1371348.3
129 2016-01-11 1086225.4
131 2016-02-22 1077692.4
137 2013-03-18  854699.1
141 2013-05-27 1011870.1
142 2013-08-05  893878.4
143 2013-12-16  801215.2
148 2013-10-07  805962.8
150 2013-11-04  801729.8
152 2013-08-19  726361.0
155 2014-02-24  979288.7
158 2014-04-14 1006729.5
161 2014-07-07 1102600.4
162 2014-08-11  979494.5
164 2014-10-20  901047.1
166 2014-10-27 1260062.0
169 2014-12-29 1022656.2
171 2014-08-18  976136.5
175 2015-03-02  897352.6
177 2015-03-30 1059103.8
178 2015-05-11 1033694.4
179 2015-06-29 1037959.4
182 2015-09-07 1230050.6
183 2015-10-12  975898.2
185 2015-12-07 1057603.4
186 2015-12-14  953718.2
189 2015-04-06 1233091.9
190 2015-04-27 1176994.2
192 2015-01-26 1256182.6
196 2016-01-18  955919.5
197 2016-02-15  954623.5
198 2016-03-14  740724.2
199 2013-01-07  924205.2
201 2013-02-11  672150.0
202 2013-03-25  769391.5
205 2013-06-10  870971.1
206 2013-06-24 1043166.2
208 2013-07-15 1106379.4
210 2013-09-09  916382.0
215 2013-04-22  934307.5
217 2013-12-30  974004.0
219 2014-01-13  972211.2
220 2014-01-20  952294.8
221 2014-02-03  946820.6
225 2014-06-02 1182837.6
228 2014-08-25  912550.8
234 2014-03-03 1013797.0
245 2015-06-15  946565.2
246 2015-07-13 1139633.6
248 2015-08-10 1080701.8
249 2015-08-31 1052796.2
253 2015-11-30  980493.4
259 2016-03-28 1105384.2
264 2016-02-08  897832.2
267 2013-02-25  766646.8
269 2013-04-01  954419.8
281 2013-11-25  852430.6
286 2013-09-16  997656.1
290 2014-07-21 1171519.8
294 2014-09-29  804772.4
298 2014-12-01  813872.0
299 2014-12-08 1005479.1
304 2014-06-16  981782.5
312 2015-03-16 1009182.7
315 2015-05-25 1166947.6
329 2015-01-05  903062.3
337 2016-03-21 1299648.7
338 2016-04-25 1132090.1
341 2013-01-21  818799.7
364 2014-05-12 1035870.7
367 2014-09-22 1234683.8
381 2015-06-22  990619.5
383 2015-10-05 1175100.6
385 2015-11-09 1095345.9
395 2016-05-16 1121192.5
399 2016-05-09 1175343.4
407 2013-07-08 1035513.8
430 2014-11-17 1024473.3
443 2015-05-04 1063411.6
476 2013-07-29  809045.3

Body:
I'm not sure if this completely answers the question but I was able to get a result out of your data with the slightly modified code below.

Hope this helps!

One point, I first sorted the data by date, assuming this was part of your intent.

Orders_Sorted <- Orders_Weekly[order(Orders_Weekly$Week_Start),] # Sort by date (unless you want to keep the data out of date order for some reason)
Orders_Weekly.ts <- ts(Orders_Sorted$Sales, frequency = (365.25/7)) # Convert df to time series
Orders_Weekly.hw <- HoltWinters(x=Orders_Weekly.ts, beta = FALSE, gamma = FALSE) # Run HW
plot(Orders_Weekly.hw) # Show plot of HW output

This produces the plot below.

Plot of Holt-Winters exponential smoothing of data


问:
How can I read a stream of key=value pairs in bash if the values can be empty?
So I have several properties files that contains keys and values in the following format:

```<code>Key1=value1
Key2=Value2
etc..
</code>```

So when I run this command to get the keys:

```<code>ssh 172.16.1.1 "grep -v '^#' /src/PTB.properties" | awk -F "=" '{print $1}'
</code>```

I get the following output

```<code>userField
User
srcIP
srcPort
dstIP
dstPort
date
time
</code>```

And when I run the same command but with {print $2} at the end to get the values:

```<code>ssh 172.16.1.1 "grep -v '^#' /src/PTB.properties" | awk -F "=" '{print $2}'
</code>```

I get the following output:

```<code>User-Name
Full-Name
Source-IP-Address
Source-UDP-Port

Target-UDP-Port
Date
Time
</code>```

So what I want to say is that some keys don't have a value.

That being said, I am running the following command to get those keys and values:

```<code>while IFS= read -r line; do
    USER_PARAMETERS_KEYS+=( "$line" )
done < <( ssh $ip "grep -v '^#' ${PARAMETER_PATH[$i]}" | awk -F "=" '{print $1}' )

while IFS= read -r line; do
    USER_PARAMETERS_VALUES+=( "$line" )
done < <( ssh $ip "grep -v '^#' ${PARAMETER_PATH[$i]}" | awk -F "=" '{print $2}' )
</code>```

My problem is that USER_PARAMETERS_VALUES is not saving the null values. For example after running this command, there are only 7 items in USER_PARAMETERS_VALUES instead of 8 because the Key dstIP is empty.

Any idea how can I solve this issue? Thanks.

答:
Wouldn't it make more sense to capture the whole line and parse it locally?

```<code>while IFS== read -r key value; do
     keys+=("$key")
     values+=("$value")
done < <(ssh 172.16.1.1 "grep -v '^#' /src/PTB.properties")
</code>```

This also avoids the race condition you get where the remote file could change between the first and the second time you read it.

Having said that, a minimal change would be to have Awk print quotes around any empty value.

Body:
So I have several properties files that contains keys and values in the following format:

Key1=value1
Key2=Value2
etc..

So when I run this command to get the keys:

ssh 172.16.1.1 "grep -v '^#' /src/PTB.properties" | awk -F "=" '{print $1}'

I get the following output

userField
User
srcIP
srcPort
dstIP
dstPort
date
time

And when I run the same command but with {print $2} at the end to get the values:

ssh 172.16.1.1 "grep -v '^#' /src/PTB.properties" | awk -F "=" '{print $2}'

I get the following output:

User-Name
Full-Name
Source-IP-Address
Source-UDP-Port

Target-UDP-Port
Date
Time

So what I want to say is that some keys don't have a value.

That being said, I am running the following command to get those keys and values:

while IFS= read -r line; do
    USER_PARAMETERS_KEYS+=( "$line" )
done < <( ssh $ip "grep -v '^#' ${PARAMETER_PATH[$i]}" | awk -F "=" '{print $1}' )

while IFS= read -r line; do
    USER_PARAMETERS_VALUES+=( "$line" )
done < <( ssh $ip "grep -v '^#' ${PARAMETER_PATH[$i]}" | awk -F "=" '{print $2}' )

My problem is that USER_PARAMETERS_VALUES is not saving the null values. For example after running this command, there are only 7 items in USER_PARAMETERS_VALUES instead of 8 because the Key dstIP is empty.

Any idea how can I solve this issue? Thanks.

Body:
Wouldn't it make more sense to capture the whole line and parse it locally?

while IFS== read -r key value; do
     keys+=("$key")
     values+=("$value")
done < <(ssh 172.16.1.1 "grep -v '^#' /src/PTB.properties")

This also avoids the race condition you get where the remote file could change between the first and the second time you read it.

Having said that, a minimal change would be to have Awk print quotes around any empty value.


问:
How to learn Jackson to cast inheritors of abstract class?
I have a class:

```<code>@EqualsAndHashCode(callSuper = true)
@Data
public class AppealTemplateDto extends AbstractDto {

    private List<AbstractFieldDto> fields;
}
</code>```

This class contains list of AbstractFieldDto inheritors, e.g.:

```<code>@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class InputFieldDto extends AbstractFieldDto {

    private String fieldType = FieldType.INPUT.name();
    private String text;
}
</code>```

Totally, there are near 6-7 inheritors, & AbstractTemplateDto may contain any set of them.

Controller:

```<code>@PostMapping
public ResponseEntity<AppealTemplateDto> create(@RequestBody AppealTemplateDto dto) {
    return ResponseEntity.ok(service.save(dto));
}
</code>```

When Jackson trying to parse AppealTemplateDto, it crashes with exception:

Caused by:
  com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot
  construct instance of
  ru.appeal.template.dto.field.AbstractFieldDto
  (no Creators, like default construct, exist): abstract types either
  need to be mapped to concrete types, have custom deserializer, or
  contain additional type information

As I understand, Jackson can't define, how to cast incoming AbstractFieldDto. Please, advice me, what to do?

答:
The Annotation your are needing are:

```<code>@JsonTypeInfo
@JsonSubType

@JsonTypeName
</code>```

Some explanation: if you have many implementation of your abstract type, Jackson can't guess which type is your json, you need to add a type name in json, for example as a new property (this is one of the strategies):

```<code>//tell to jackson where to find the type name
@JsonTypeInfo(   use = JsonTypeInfo.Id.NAME, include = As.PROPERTY, property = "type")
// tell to jackson the implementations to scan
@JsonSubTypes({
    @JsonSubTypes.Type(value = InputFieldDto.class, name = "input")
    //, ...
})
public class AbstractFieldDto {
}

//tell to jackson what is the type name in json
@JsonTypeName("input")
public class InputFieldDto extends AbstractFieldDto {

    private String fieldType = FieldType.INPUT.name();
    private String text;
}
</code>```

Body:
I have a class:

@EqualsAndHashCode(callSuper = true)
@Data
public class AppealTemplateDto extends AbstractDto {

    private List<AbstractFieldDto> fields;
}

This class contains list of AbstractFieldDto inheritors, e.g.:

@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class InputFieldDto extends AbstractFieldDto {

    private String fieldType = FieldType.INPUT.name();
    private String text;
}

Totally, there are near 6-7 inheritors, & AbstractTemplateDto may contain any set of them.

Controller:

@PostMapping
public ResponseEntity<AppealTemplateDto> create(@RequestBody AppealTemplateDto dto) {
    return ResponseEntity.ok(service.save(dto));
}

When Jackson trying to parse AppealTemplateDto, it crashes with exception:

Caused by:
  com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot
  construct instance of
  ru.appeal.template.dto.field.AbstractFieldDto
  (no Creators, like default construct, exist): abstract types either
  need to be mapped to concrete types, have custom deserializer, or
  contain additional type information

As I understand, Jackson can't define, how to cast incoming AbstractFieldDto. Please, advice me, what to do?

Body:
The Annotation your are needing are:

@JsonTypeInfo
@JsonSubType

@JsonTypeName

Some explanation: if you have many implementation of your abstract type, Jackson can't guess which type is your json, you need to add a type name in json, for example as a new property (this is one of the strategies):

//tell to jackson where to find the type name
@JsonTypeInfo(   use = JsonTypeInfo.Id.NAME, include = As.PROPERTY, property = "type")
// tell to jackson the implementations to scan
@JsonSubTypes({
    @JsonSubTypes.Type(value = InputFieldDto.class, name = "input")
    //, ...
})
public class AbstractFieldDto {
}

//tell to jackson what is the type name in json
@JsonTypeName("input")
public class InputFieldDto extends AbstractFieldDto {

    private String fieldType = FieldType.INPUT.name();
    private String text;
}


问:
The "SignFile" task was not given a value for the required parameter "CertificateThumbprint"
We have a line of business app which is deployed via clickonce. I can build and publish the application without any problems but when I try to use Continuous Integration (Build each check-in) I get the following error:

```<code> 2>C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5):
</code>```

error MSB4044:
  The "SignFile" task was not given a value for the required parameter "CertificateThumbprint".

[C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]

Done executing task "SignFile" -- FAILED.

We sign the application (to be more specific: the ClickOnce manifest) using a code signing certificate which is registered in the AD as Trusted Publisher.

The Certificate is stored in Certificate store on my local workstation. The Certificate is also in the certificate store of the build server (1. In the Personal Store, 2. in the Personal store of the TFSBuildServiceHost Service Account and 3. in the Personal store of the tfs/build server itself).

Where are using Visual Studio 2013 Update 4, C#, .Net 4.5 and TFS 2013 Update 4.

I have no clue what causes this error, any help is appreciated.

EDIT:

I forgot to mention that the tfs build worked fine a few weeks ago. I didn't change a thing, i verified that the project file (Pulse.csproj) hasn't changed and i also had a few successful builds with that exact Pulse.csproj file / build definition. I'm pretty sure that it must be something on the tfs server. I remember that Microsoft had some trouble with some updates regarding the certificate infrastructure could it be related?

EDIT 2:
I tried to build the project via command line using this command:

"C:\Program Files (x86)\MSBuild\12.0\bin\amd64\MSBuild.exe" C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln

The build fails with the following message:

CleanPublishFolder:   Removing directory "bin\Debug\app.publish\".
  _DeploymentComputeClickOnceManifestInfo:   Creating directory "bin\Debug\app.publish".

  Copying file from "obj\Debug\Pulse.exe" to
  "bin\Debug\app.publish\Pulse.exe". C:\Program Files
  (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5):
  error MSB3482: An error occurred while signi ng: SignTool.exe not
  found. [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]
  Done Building Project
  "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (default
  targets) -- FAILED.

Done Building Project
  "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default targets)
  -- FAILED.

Build FAILED.

"C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default target)
  (1) -> "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj"
  (default target) (2) -> (_DeploymentComputeClickOnceManifestInfo
  target) ->   C:\Program Files
  (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5):
  error MSB3482: An error occurred while sig ning: SignTool.exe not
  found. [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]

```<code>0 Warning(s)
1 Error(s)
</code>```

The Signtool definitely exists on the Server. The path to the signtool is: "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\signtool.exe" and "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\signtool.exe"

The most interesting part is that I CAN build the solution using a different msbuild tool.

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
  C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln

EDIT 3:

I installed the  Windows Software Development Kit (SDK) for Windows 8 and now I can build the solution via command line. Thus, the code signing certificate is installed & available.

But the TFS Build fails.

Here is the error output gathered from the tfsbuild logfile:

```<code>      Task "AL"
         C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\AL.exe /culture:de /out:obj\Debug\de\Pulse.resources.dll /platform:AnyCPU /template:obj\Debug\Pulse.exe /embed:obj\Debug\Pulse.View.Localization.CreditsView.de.resources /embed:obj\Debug\Pulse.View.Localization.PulseMainWindow.de.resources
         Microsoft (R) Assembly Linker version 12.0.20806.33440
         Copyright (C) Microsoft Corporation. All rights reserved.

       Done executing task "AL".
     2>Done building target "GenerateSatelliteAssemblies" in project "Pulse.csproj".
     2>Target "CreateSatelliteAssemblies" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "CoreBuild" depends on it):
     2>Done building target "CreateSatelliteAssemblies" in project "Pulse.csproj".
       Target "SetWin32ManifestProperties" skipped. Previously built successfully.
       Target "_DeploymentComputeNativeManifestInfo" skipped, due to false condition; ('$(GenerateClickOnceManifests)'!='true') was evaluated as ('true'!='true').
     2>Target "CleanPublishFolder" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "_DeploymentComputeClickOnceManifestInfo" depends on it):
       Task "RemoveDir" skipped, due to false condition; ('$(PublishDir)'=='$(OutputPath)app.publish\' and Exists('$(PublishDir)')) was evaluated as ('bin\Debug\app.publish\'=='bin\Debug\app.publish\' and Exists('bin\Debug\app.publish\')).
     2>Done building target "CleanPublishFolder" in project "Pulse.csproj".
       Target "_DeploymentGenerateTrustInfo" skipped, due to false condition; ('$(TargetZone)'!='') was evaluated as (''!='').
     2>Target "_DeploymentComputeClickOnceManifestInfo" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "GenerateApplicationManifest" depends on it):
       Task "Copy"
         Creating directory "bin\Debug\app.publish".
         Copying file from "obj\Debug\Pulse.exe" to "bin\Debug\app.publish\Pulse.exe".
       Done executing task "Copy".
       Using "SignFile" task from assembly "Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
       Task "SignFile"
     2>C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5): error MSB4044: The "SignFile" task was not given a value for the required parameter "CertificateThumbprint". [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]
       Done executing task "SignFile" -- FAILED.
     2>Done building target "_DeploymentComputeClickOnceManifestInfo" in project "Pulse.csproj" -- FAILED.
     2>Target "_CheckForCompileOutputs" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "_CleanGetCurrentAndPriorFileWrites" depends on it):
     2>Done building target "_CheckForCompileOutputs" in project "Pulse.csproj".
       Target "_SGenCheckForOutputs" skipped, due to false condition; ('$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('@(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto')) was evaluated as ('Off' == 'On' or (''!='' and 'Off' == 'Auto')).
     2>Target "_CleanGetCurrentAndPriorFileWrites" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "_CleanRecordFileWrites" depends on it):
       Task "ReadLinesFromFile"
       Done executing task "ReadLinesFromFile".
       Task "ConvertToAbsolutePath"
       Done executing task "ConvertToAbsolutePath".
       Task "FindUnderPath"
         Comparison path is "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse".
       Done executing task "FindUnderPath".
       Task "FindUnderPath"
         Comparison path is "C:\Builds\1\Pulse\DefaultBuild\bin\".
       Done executing task "FindUnderPath".
       Task "FindUnderPath"
         Comparison path is "obj\Debug\".
       Done executing task "FindUnderPath".
       Task "RemoveDuplicates"
       Done executing task "RemoveDuplicates".
     2>Done building target "_CleanGetCurrentAndPriorFileWrites" in project "Pulse.csproj".
     2>Target "_CleanRecordFileWrites" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "CoreBuild" depends on it):
       Task "RemoveDuplicates"
       Done executing task "RemoveDuplicates".
       Task "MakeDir"
       Done executing task "MakeDir".
       Task "WriteLinesToFile"
       Done executing task "WriteLinesToFile".
     2>Done building target "_CleanRecordFileWrites" in project "Pulse.csproj".
     2>Done Building Project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (default targets) -- FAILED.
     1>Done executing task "MSBuild" -- FAILED.
     1>Done building target "Build" in project "Pulse.sln" -- FAILED.
     1>Done Building Project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default targets) -- FAILED.

Build FAILED.

       "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default target) (1) ->
       "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (default target) (2) ->
       (_DeploymentComputeClickOnceManifestInfo target) ->
         C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5): error MSB4044: The "SignFile" task was not given a value for the required parameter "CertificateThumbprint". [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]

    0 Warning(s)
    1 Error(s)
</code>```

EDIT 4:

Visual Studio 2013 is not installed on our build server. I've already been through the logfile and found that the TFS Build uses the MSBuild.exe stored in C:\Program Files (x86)\MSBuild\12.0\bin\amd64\ .

Since I can build the project on the build server using the MSBuild.exe than TFS Build does I can be sure that the certificate itself is not an issue.

I created a new build definition without modifying any of the settings but I still get the same error message.

I also repaired the TFS Installation on the build server but no luck.

I compared all *.targets files stored in the C:\Program Files (x86)\MSBuild\12.0\bin\amd64\ Folder on the Server with the *.targets files in the same location on my client machine. There 100% identical.

Needless to say that I can build the project without any problems on my client machine (via VS2013 and command line).

I deleted and re-registered/created the build service/controller/agent. The result is still the same.

I'm stuck here. Any ideas?

答:
For those come across this issue using CI with an EV Code Signing Certificate.  EV Code Signing Certificates use a dongle or thumb drive, so you must have a build server on premise and update your project file manually.

In VS, Right click on your project and Unload it.

Right click and Edit the csproj file.

Find or add this entry

<PropertyGroup>
<ManifestCertificateThumbprint>**Your Certificate Thumbprint Here**</ManifestCertificateThumbprint>
</PropertyGroup>

Copy and paste the thumbprint of the certificate from your build server
into the ManifestCertificateThumprint value.

Reload your project
and check in.

Body:
We have a line of business app which is deployed via clickonce. I can build and publish the application without any problems but when I try to use Continuous Integration (Build each check-in) I get the following error:

 2>C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5):

error MSB4044:
  The "SignFile" task was not given a value for the required parameter "CertificateThumbprint".

[C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]

Done executing task "SignFile" -- FAILED.

We sign the application (to be more specific: the ClickOnce manifest) using a code signing certificate which is registered in the AD as Trusted Publisher.

The Certificate is stored in Certificate store on my local workstation. The Certificate is also in the certificate store of the build server (1. In the Personal Store, 2. in the Personal store of the TFSBuildServiceHost Service Account and 3. in the Personal store of the tfs/build server itself).

Where are using Visual Studio 2013 Update 4, C#, .Net 4.5 and TFS 2013 Update 4.

I have no clue what causes this error, any help is appreciated.

EDIT:

I forgot to mention that the tfs build worked fine a few weeks ago. I didn't change a thing, i verified that the project file (Pulse.csproj) hasn't changed and i also had a few successful builds with that exact Pulse.csproj file / build definition. I'm pretty sure that it must be something on the tfs server. I remember that Microsoft had some trouble with some updates regarding the certificate infrastructure could it be related?

EDIT 2:
I tried to build the project via command line using this command:

"C:\Program Files (x86)\MSBuild\12.0\bin\amd64\MSBuild.exe" C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln

The build fails with the following message:

CleanPublishFolder:   Removing directory "bin\Debug\app.publish\".
  _DeploymentComputeClickOnceManifestInfo:   Creating directory "bin\Debug\app.publish".

  Copying file from "obj\Debug\Pulse.exe" to
  "bin\Debug\app.publish\Pulse.exe". C:\Program Files
  (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5):
  error MSB3482: An error occurred while signi ng: SignTool.exe not
  found. [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]
  Done Building Project
  "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (default
  targets) -- FAILED.

Done Building Project
  "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default targets)
  -- FAILED.

Build FAILED.

"C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default target)
  (1) -> "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj"
  (default target) (2) -> (_DeploymentComputeClickOnceManifestInfo
  target) ->   C:\Program Files
  (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5):
  error MSB3482: An error occurred while sig ning: SignTool.exe not
  found. [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]

0 Warning(s)
1 Error(s)

The Signtool definitely exists on the Server. The path to the signtool is: "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\signtool.exe" and "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\signtool.exe"

The most interesting part is that I CAN build the solution using a different msbuild tool.

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
  C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln

EDIT 3:

I installed the  Windows Software Development Kit (SDK) for Windows 8 and now I can build the solution via command line. Thus, the code signing certificate is installed & available.

But the TFS Build fails.

Here is the error output gathered from the tfsbuild logfile:

      Task "AL"
         C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\AL.exe /culture:de /out:obj\Debug\de\Pulse.resources.dll /platform:AnyCPU /template:obj\Debug\Pulse.exe /embed:obj\Debug\Pulse.View.Localization.CreditsView.de.resources /embed:obj\Debug\Pulse.View.Localization.PulseMainWindow.de.resources
         Microsoft (R) Assembly Linker version 12.0.20806.33440
         Copyright (C) Microsoft Corporation. All rights reserved.

       Done executing task "AL".
     2>Done building target "GenerateSatelliteAssemblies" in project "Pulse.csproj".
     2>Target "CreateSatelliteAssemblies" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "CoreBuild" depends on it):
     2>Done building target "CreateSatelliteAssemblies" in project "Pulse.csproj".
       Target "SetWin32ManifestProperties" skipped. Previously built successfully.
       Target "_DeploymentComputeNativeManifestInfo" skipped, due to false condition; ('$(GenerateClickOnceManifests)'!='true') was evaluated as ('true'!='true').
     2>Target "CleanPublishFolder" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "_DeploymentComputeClickOnceManifestInfo" depends on it):
       Task "RemoveDir" skipped, due to false condition; ('$(PublishDir)'=='$(OutputPath)app.publish\' and Exists('$(PublishDir)')) was evaluated as ('bin\Debug\app.publish\'=='bin\Debug\app.publish\' and Exists('bin\Debug\app.publish\')).
     2>Done building target "CleanPublishFolder" in project "Pulse.csproj".
       Target "_DeploymentGenerateTrustInfo" skipped, due to false condition; ('$(TargetZone)'!='') was evaluated as (''!='').
     2>Target "_DeploymentComputeClickOnceManifestInfo" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "GenerateApplicationManifest" depends on it):
       Task "Copy"
         Creating directory "bin\Debug\app.publish".
         Copying file from "obj\Debug\Pulse.exe" to "bin\Debug\app.publish\Pulse.exe".
       Done executing task "Copy".
       Using "SignFile" task from assembly "Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
       Task "SignFile"
     2>C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5): error MSB4044: The "SignFile" task was not given a value for the required parameter "CertificateThumbprint". [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]
       Done executing task "SignFile" -- FAILED.
     2>Done building target "_DeploymentComputeClickOnceManifestInfo" in project "Pulse.csproj" -- FAILED.
     2>Target "_CheckForCompileOutputs" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "_CleanGetCurrentAndPriorFileWrites" depends on it):
     2>Done building target "_CheckForCompileOutputs" in project "Pulse.csproj".
       Target "_SGenCheckForOutputs" skipped, due to false condition; ('$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('@(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto')) was evaluated as ('Off' == 'On' or (''!='' and 'Off' == 'Auto')).
     2>Target "_CleanGetCurrentAndPriorFileWrites" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "_CleanRecordFileWrites" depends on it):
       Task "ReadLinesFromFile"
       Done executing task "ReadLinesFromFile".
       Task "ConvertToAbsolutePath"
       Done executing task "ConvertToAbsolutePath".
       Task "FindUnderPath"
         Comparison path is "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse".
       Done executing task "FindUnderPath".
       Task "FindUnderPath"
         Comparison path is "C:\Builds\1\Pulse\DefaultBuild\bin\".
       Done executing task "FindUnderPath".
       Task "FindUnderPath"
         Comparison path is "obj\Debug\".
       Done executing task "FindUnderPath".
       Task "RemoveDuplicates"
       Done executing task "RemoveDuplicates".
     2>Done building target "_CleanGetCurrentAndPriorFileWrites" in project "Pulse.csproj".
     2>Target "_CleanRecordFileWrites" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "CoreBuild" depends on it):
       Task "RemoveDuplicates"
       Done executing task "RemoveDuplicates".
       Task "MakeDir"
       Done executing task "MakeDir".
       Task "WriteLinesToFile"
       Done executing task "WriteLinesToFile".
     2>Done building target "_CleanRecordFileWrites" in project "Pulse.csproj".
     2>Done Building Project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (default targets) -- FAILED.
     1>Done executing task "MSBuild" -- FAILED.
     1>Done building target "Build" in project "Pulse.sln" -- FAILED.
     1>Done Building Project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default targets) -- FAILED.

Build FAILED.

       "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default target) (1) ->
       "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (default target) (2) ->
       (_DeploymentComputeClickOnceManifestInfo target) ->
         C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5): error MSB4044: The "SignFile" task was not given a value for the required parameter "CertificateThumbprint". [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]

    0 Warning(s)
    1 Error(s)

EDIT 4:

Visual Studio 2013 is not installed on our build server. I've already been through the logfile and found that the TFS Build uses the MSBuild.exe stored in C:\Program Files (x86)\MSBuild\12.0\bin\amd64\ .

Since I can build the project on the build server using the MSBuild.exe than TFS Build does I can be sure that the certificate itself is not an issue.

I created a new build definition without modifying any of the settings but I still get the same error message.

I also repaired the TFS Installation on the build server but no luck.

I compared all *.targets files stored in the C:\Program Files (x86)\MSBuild\12.0\bin\amd64\ Folder on the Server with the *.targets files in the same location on my client machine. There 100% identical.

Needless to say that I can build the project without any problems on my client machine (via VS2013 and command line).

I deleted and re-registered/created the build service/controller/agent. The result is still the same.

I'm stuck here. Any ideas?


问:
Is it possible to apply a decorator to a line in python?
As you may now, the common usage of decorator is for example:

```<code>@log
def func(...)
</code>```

What actualy takes func as parameter returns a function what takes func as an argument, like :

```<code>def log(func):
    def function_wrapper(*args , **kwargs):
    log_enter_func(func, args, kwargs)

    result = func(*args, **kwargs)
    log_exit_func(func, result )
    return result
</code>```

In code above, logging of function calls and returns are fine, without hand- made log (...) entries with just @log decorator over a function.
So its easy to remove after testing, so logging does not consume time.

But is it possible to hang it just to lines of code?
Like for loops, etc, so something like :

```<code>def func(...):
 ...
@log
    for x in range(whatever)
</code>```

Taking the line as soft of a function, accessing in some kinf of args to x, whatever ( variables and code in the line) cause actualy everything is a function in python?

Or maybe there is some kind of method to apply decorator to a method and propagate it to source lines in a function ?

The idea is to make a brief logging of whats happens in every line without lots of hand- written log entries like
log.info(msg)
in many lines of code

Any ideas about that?
I v tryed to inspect the func. __ code __  built- in, but its python byte- code there , not source code...

答:
While it may not be possible to address each line of a function with a decorator, I think you may be able to log each line using the following method:

Python Decorator for printing every line executed by a function

The idea is to create a debug context, then the debug decorator wrapper around the debug_context function. This creates a log of local variables to std.out

Body:
As you may now, the common usage of decorator is for example:

@log
def func(...)

What actualy takes func as parameter returns a function what takes func as an argument, like :

def log(func):
    def function_wrapper(*args , **kwargs):
    log_enter_func(func, args, kwargs)

    result = func(*args, **kwargs)
    log_exit_func(func, result )
    return result

In code above, logging of function calls and returns are fine, without hand- made log (...) entries with just @log decorator over a function.
So its easy to remove after testing, so logging does not consume time.

But is it possible to hang it just to lines of code?
Like for loops, etc, so something like :

def func(...):
 ...
@log
    for x in range(whatever)

Taking the line as soft of a function, accessing in some kinf of args to x, whatever ( variables and code in the line) cause actualy everything is a function in python?

Or maybe there is some kind of method to apply decorator to a method and propagate it to source lines in a function ?

The idea is to make a brief logging of whats happens in every line without lots of hand- written log entries like
log.info(msg)
in many lines of code

Any ideas about that?
I v tryed to inspect the func. __ code __  built- in, but its python byte- code there , not source code...