Использование конкретного класса в методе куда приходит Шаблон класса

У меня есть интерфейс:

public interface IModelSort<T> where T : class     {         IEnumerable<T> GetModelSort<K>(IEnumerable<T> model, Func<T, K> predSort, bool asc);     } 

Класс наследованный от этого интефрейса:

public IEnumerable<T> GetModelSort<K>(IEnumerable<T> model, Func<T, K> predSort, bool asc)         {             return asc ? model.OrderBy(predSort) : model.OrderByDescending(predSort);         } 

И есть метод который обращается к этому классу.

public IEnumerable<T> GetSortedModel<T, K>(IEnumerable<T> model, Func<T, K> predSort, bool asc) where T : class         {             return new ModelSort<T>().GetModelSort(model, predSort, asc);         } 

И я не хочу передавать сюда уже готовый предикат, я хочу его тут собирать, что бы освободить от лишней логики контроллер и сделать эту логику тут. Но так как этому методу не известен класс который к нему придёт он не знает выражения

predSort = i => i.SomeValue; 

Подскажите как нибудь можно реализовать сбор предикатов не в контроллере а в этом методе или где нибудь рядом с ним.

SQL if else statements with multiple select

I have a SP in SQl like below

ALTER PROCEDURE [dbo].[spGetCurrencyDetails] @CompanyId int,@Id int, @strCode varchar(1) = ''  AS BEGIN     SET NOCOUNT ON;          if @strCode='Z'              (select a.Companyid,a.CurrencyID curID,c.Symbol,e.SellingRate from acompanyMaster a             left outer join aCurrencyMaster c on a.companyid=c.companyid and a.CurrencyID=c.CurrencyID             left outer join ExchangeRateDetail e on a.companyid=e.companyid and a.CurrencyID=e.CurrencyID              where a.companyID=@CompanyID)         else if @strCode='C'             (select a.Companyid,a.CurrencyID curID,c.Symbol,e.SellingRate from acustomermaster a             left outer join aCurrencyMaster c on a.companyid=c.companyid and a.CurrencyID=c.CurrencyID             left outer join ExchangeRateDetail e on a.companyid=e.companyid and a.CurrencyID=e.CurrencyID             Where a.customerID = @Id and a.companyid=@CompanyID)         else if @strCode='D'             (select a.Companyid,a.depcurrencyid curID,c.Symbol,e.SellingRate from adepartmentMaster a             left outer join aCurrencyMaster c on a.companyid=c.companyid and a.depcurrencyid=c.CurrencyID             left outer join ExchangeRateDetail e on a.companyid=e.companyid and a.depcurrencyid=e.CurrencyID             where a.DepartmentID=@Id and a.CompanyID=@CompanyID)         else if @strCode='V'             (select a.Companyid,a.CurrencyID curID,c.Symbol,e.SellingRate from avendorMaster a             left outer join aCurrencyMaster c on a.companyid=c.companyid and a.CurrencyID=c.CurrencyID             left outer join ExchangeRateDetail e on a.companyid=e.companyid and a.CurrencyID=e.CurrencyID             Where a.VendorId = @Id and a.companyid=@CompanyID)         else if @strCode='A'             (select a.Companyid,a.CurrencyID curID,c.Symbol,e.SellingRate from aaccountmaster a             left outer join aCurrencyMaster c on a.companyid=c.companyid and a.CurrencyID=c.CurrencyID             left outer join ExchangeRateDetail e on a.companyid=e.companyid and a.CurrencyID=e.CurrencyID             Where a.accountID = @Id and a.companyid=@CompanyID)         else if @strCode='I'             (select aaccountmaster.currencyid curID from apackagesettings              left outer join aaccountmaster on aaccountmaster.accountid=apackagesettings.inventoryid              and apackagesettings.companyid = aaccountmaster.companyid and  aaccountmaster.CompanyId =@CompanyID)         else             (select a.Companyid,a.CurrencyID curID,c.Symbol,e.SellingRate from aCurrencyMaster a             left outer join aCurrencyMaster c on a.companyid=c.companyid and a.CurrencyID=c.CurrencyID             left outer join ExchangeRateDetail e on a.companyid=e.companyid and a.CurrencyID=e.CurrencyID             Where a.CurrencyID = @Id and a.companyid=@CompanyID)       SET NOCOUNT OFF;  END 

Here according to value of @strCode each loop is selected, and each using different set of tables and returning different column values.

This working fine now, but it is taking more time to load.

How do I make this run faster? is it possible to use a switch case condition so that it will only check the desired condition only

please help

What does Arg {Inf I(d)} means?

I am currently studying the phase-field method for fracture modeling. In an article by Miehe -“Thermodynamically consistent phase-field models of fracture: Variational principles and multi-field FE implementation”, I came across on an identity that I don’t understand basically it says:

enter image description here

Can anyone tell me what does that mean? I added image because I don’t know how to add this identity in another way.

GMail and Yahoo not accepting DSN option from RCPT extended commands

i’m sending mail from my mail server using python sendmail along with NOTIFY,RET,ENVID options. When i send a mail in above said procedure to an outlook mail id i’m receiving dsn. But when i send a mail to either gmail or yahoo im not receiving dsn.

SMTP log when sent to outlook

send: 'ehlo ip-172-31-89-244.ec2.internal\r\n' reply: '250-VE1EUR03FT018.mail.protection.outlook.com Hello [34.203.167.82]\r\n' reply: '250-SIZE 49283072\r\n' reply: '250-PIPELINING\r\n' reply: '250-DSN\r\n' reply: '250-ENHANCEDSTATUSCODES\r\n' reply: '250-STARTTLS\r\n' reply: '250-8BITMIME\r\n' reply: '250-BINARYMIME\r\n' reply: '250-CHUNKING\r\n' reply: '250 SMTPUTF8\r\n' reply: retcode (250); Msg: VE1EUR03FT018.mail.protection.outlook.com Hello [34.203.167.82] SIZE 49283072 PIPELINING DSN ENHANCEDSTATUSCODES STARTTLS 8BITMIME BINARYMIME CHUNKING SMTPUTF8 send: 'mail FROM:<dsn-76@example.com> size=1392 RET=HDRS ENVID=76\r\n' reply: '250 2.1.0 Sender OK\r\n' reply: retcode (250); Msg: 2.1.0 Sender OK send: u'rcpt TO:<abc@outlook.com> NOTIFY=SUCCESS,FAILURE,DELAY\r\n' reply: '250 2.1.5 Recipient OK\r\n' reply: retcode (250); Msg: 2.1.5 Recipient OK send: 'data\r\n' reply: '354 Start mail input; end with <CRLF>.<CRLF>\r\n' reply: retcode (354); Msg: Start mail input; end with <CRLF>.<CRLF> data: (354, 'Start mail input; end with <CRLF>.<CRLF>') send: 'Content-Type: multipart/alternative;\r\n boundary="===============4828387674099477551=="\r\nMIME-Version: 1.0\r\nDate: Thu, 17 Jan 2019 12:21:49 +0530\r\nFrom: abc@example.com\r\nMessage-Id: <CAEFoQ7qve5kck0xaMnQwi-QNiTJqVSCN1qVDu_9F1kCy0kUpGA@mail.gmail.com>\r\nOriginal-Envelope-Id: 76\r\nResent-Date: Thu, 17 Jan 2019 12:21:49 +0530\r\nResent-From: srikanth vr1 <srikanthvr2@gmail.com>\r\nResent-Message-Id: <CAEFoQ7qve5kck0xaMnQwi-QNiTJqVSCN1qVDu_9F1kCy0kUpGA@mail.gmail.com>\r\nSubject: REGISTERED: test\r\nTo: abc@outlook.com\r\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; \r\n d=example.com; i=@example.com; \r\n q=dns/txt; s=dkim; t=1547707909; h=content-type : \r\n mime-version : date : from : message-id : resent-date : \r\n resent-from : resent-message-id : subject : to : date : \r\n from : subject; \r\n bh=4u6uddMjage5G2IhNFHSL+jOjAVzjaLpUnrgPqdbTdU=; \r\n b=q0n8iNOyPgkVYKuuGDcIRsobyr6ySnjIvApWqr30i6u/zLQGBu9KMEwZ\r\n deOyZlfWIo7tYoGUJYy5McqqevpwfCqVTeE1ButctqE9k6d+ggQZf6Zjqq\r\n PL2Rt4TJNmUY3hrpWvMYi353FnZ0N44tBLeRFDzJT1UV2/LIQRD/kwbmE=\r\n\r\n--===============4828387674099477551==\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset="us-ascii"\r\nContent-Transfer-Encoding: 7bit\r\n\r\ntest\r\n\r\n--===============4828387674099477551==\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset="us-ascii"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n<div dir="ltr">test</div>\r\n\r\n--===============4828387674099477551==--\r\n.\r\n' reply: '250 2.6.0 <CAEFoQ7qve5kck0xaMnQwi-QNiTJqVSCN1qVDu_9F1kCy0kUpGA@mail.gmail.com> [InternalId=36941013765396, Hostname=VE1EUR03HT108.eop-EUR03.prod.protection.outlook.com] 8366 bytes in 0.875, 9.337 KB/sec Queued mail for delivery -> 250 2.1.5\r\n' reply: retcode (250); Msg: 2.6.0 <CAEFoQ7qve5kck0xaMnQwi-QNiTJqVSCN1qVDu_9F1kCy0kUpGA@mail.gmail.com> [InternalId=36941013765396, Hostname=VE1EUR03HT108.eop-EUR03.prod.protection.outlook.com] 8366 bytes in 0.875, 9.337 KB/sec Queued mail for delivery -> 250 2.1.5 data: (250, '2.6.0 <CAEFoQ7qve5kck0xaMnQwi-QNiTJqVSCN1qVDu_9F1kCy0kUpGA@mail.gmail.com> [InternalId=36941013765396, Hostname=VE1EUR03HT108.eop-EUR03.prod.protection.outlook.com] 8366 bytes in 0.875, 9.337 KB/sec Queued mail for delivery -> 250 2.1.5') send: 'quit\r\n' reply: '221 2.0.0 Service closing transmission channel\r\n' reply: retcode (221); Msg: 2.0.0 Service closing transmission channel 

SMTP log when sent to gmail

send: 'ehlo ip-172-31-89-244.ec2.internal\r\n' reply: '250-mx.google.com at your service, [34.203.167.82]\r\n' reply: '250-SIZE 157286400\r\n' reply: '250-8BITMIME\r\n' reply: '250-STARTTLS\r\n' reply: '250-ENHANCEDSTATUSCODES\r\n' reply: '250-PIPELINING\r\n' reply: '250-CHUNKING\r\n' reply: '250 SMTPUTF8\r\n' reply: retcode (250); Msg: mx.google.com at your service, [34.203.167.82] SIZE 157286400 8BITMIME STARTTLS ENHANCEDSTATUSCODES PIPELINING CHUNKING SMTPUTF8 send: 'mail FROM:<dsn-77@example.com> size=1394 RET=HDRS ENVID=77\r\n' reply: '250 2.1.0 OK p19-v6si3114094ejj.94 - gsmtp\r\n' reply: retcode (250); Msg: 2.1.0 OK p19-v6si3114094ejj.94 - gsmtp send: u'rcpt TO:<abc@gmail.com> NOTIFY=SUCCESS,FAILURE,DELAY\r\n' reply: '250 2.1.5 OK p19-v6si3114094ejj.94 - gsmtp\r\n' reply: retcode (250); Msg: 2.1.5 OK p19-v6si3114094ejj.94 - gsmtp send: 'data\r\n' reply: '354  Go ahead p19-v6si3114094ejj.94 - gsmtp\r\n' reply: retcode (354); Msg: Go ahead p19-v6si3114094ejj.94 - gsmtp data: (354, 'Go ahead p19-v6si3114094ejj.94 - gsmtp') send: 'Content-Type: multipart/alternative;\r\n boundary="===============2153953495280056619=="\r\nMIME-Version: 1.0\r\nDate: Thu, 17 Jan 2019 12:28:54 +0530\r\nFrom: abc@example.com\r\nMessage-Id: <CAEFoQ7p5QHdEEjDHLaMh-GnSjcwqFKG7ASdFqaVoUZz6-3DVcw@mail.gmail.com>\r\nOriginal-Envelope-Id: 77\r\nResent-Date: Thu, 17 Jan 2019 12:28:54 +0530\r\nResent-From: srikanth vr1 <abc@gmail.com>\r\nResent-Message-Id: <CAEFoQ7p5QHdEEjDHLaMh-GnSjcwqFKG7ASdFqaVoUZz6-3DVcw@mail.gmail.com>\r\nSubject: REGISTERED: test\r\nTo: abc@gmail.com\r\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; \r\n d=example.com; i=@example.com; \r\n q=dns/txt; s=dkim; t=1547708334; h=content-type : \r\n mime-version : date : from : message-id : resent-date : \r\n resent-from : resent-message-id : subject : to : date : \r\n from : subject; \r\n bh=4r/lVPfZ7dZjsNwHEGhBbR/HBl5Nd6TIhMAgBJYGzsI=; \r\n b=hNRVKYa7d2DK7MD6nEPKEZrG3oR7ZTZkCLly9FfQWC+kHJzA91q72nXG\r\n eVxupk1VBcATvceewzW06VUXhKBMdciKPfqzJoATm90oQEYxiDLEp8dWeM\r\n TjWKPM7//yNimuoyMzFdnFumk6tIlf+MOiDZ8CZi28p3ulUcDOV2qm0EM=\r\n\r\n--===============2153953495280056619==\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset="us-ascii"\r\nContent-Transfer-Encoding: 7bit\r\n\r\ntest\r\n\r\n--===============2153953495280056619==\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset="us-ascii"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n<div dir="ltr">test</div>\r\n\r\n--===============2153953495280056619==--\r\n.\r\n' reply: '250 2.0.0 OK 1547708335 p19-v6si3114094ejj.94 - gsmtp\r\n' reply: retcode (250); Msg: 2.0.0 OK 1547708335 p19-v6si3114094ejj.94 - gsmtp data: (250, '2.0.0 OK 1547708335 p19-v6si3114094ejj.94 - gsmtp') send: 'quit\r\n' reply: '221 2.0.0 closing connection p19-v6si3114094ejj.94 - gsmtp\r\n' reply: retcode (221); Msg: 2.0.0 closing connection p19-v6si3114094ejj.94 - gsmtp 

You can see in gmail log DSN in not coming in list of options being used. same thing happening with yahoo too.

Thanks in advance

Are there common problems between rounting and mat-dialogs in Angular?

What I wanted to do was to open a mat-dialog by clicking on an icon. This mat-dialog is a split panel that has to the left side buttons that can be clicked and to the right side a content space where other components are supposed to be loaded on click on the specific button. Now, I followed the guidelines of the original documentation for routing on https://angular.io/guide/router , but when I clicked the first icon to open the dialog, it’s style was changed and it didn’t open in form of a dialog anymore. Now I figured I could just keep the dialog style by changing the url within the method of calling the dialog like this

dialogRef.afterOpened().subscribe(result => {       this.router.navigate(['/dialog']);     });    dialogRef.afterClosed().subscribe(result => {      this.router.navigate(['']);     }); 

Like this the url changed with opening anf closing the dialog the way I wanted. But I’ve got another routing-module with another component, which is working perfectly fine, before opening the dialog,but does not work anymore afterwards. And now the loading of the component via routing and using <router-outlet> in the html tag does not work either. Now, my question is if there are some general problems with mat-dialog and routing that I might solve by using a different way? Is it necassary to code a custom dialog (not using mat-dialog)? I had everything working fine before with a service, though I thought changing the url and opening the components by navigation would be a lot less code and a nicer solution.

Hopefully, someone can explain this problem to me and what is actually happening. I might provide more general code, but like I said I pretty much followed the official documentation. Thanks in advance!

Is TSP a more detailed form of the “Set Inclusion” question?


Set Inclusion

GIVEN: set of cards, some with blue backs, and each with a positive, integer face value.

QUESTION: Are there any [blue-backed cards] with a [face value <= L]?

  • 2 independent variables: [blue/white cards], [integer face values]

Function A: Select a blue-backed card

  • face value depends on which card you select
  • each blue card potentially has face value <= L
    • thus, worst-case = [check all blue cards]

Function B: Select a face value <= L

  • blue back depends on which card you select
  • each card w/ face value <= L potentially has blue back
    • thus, worst-case = [check all cards w/ face value <= L]

Function B cannot exist. There is no way to verify that a selected card has a blue back, since don’t know key info:

  • How are cards marked with a blue back?

WORST-CASE: turn over all blue-backed cards (Function A)


Travelling Salesman

GIVEN: complete graph, G(V,E), where all edges are positive, integer values.

DEFINITION: “config”

  • {A, B, u, v} where u & v are 2 vertices, and A & B are the remaining vertices split up as evenly as possible

DEFINITION: “optimal tour of a config”

  • shortest path from u to v, only going thru each vertex in A once, and
  • shortest path from v to u, only going thru each vertex in B once

Assume we have a function, f, that returns the optimal tour for a given config, in constant time.

A smallest tour must be the optimal tour of one of the configs in G.
Any config could produce the smallest tour.

NOTE: Each tour is an edge-set that can form |V|/2 or |V| configs, for even or odd |V|, respectively.


A COMPLETE GRAPH is equivalent to: set of cards, some with blue backs, and each with a positive, integer face value.

  • each card represents a set of edges with size = |V|
  • blue backs mark any edge-sets that are an optimal tour for a config
  • face value is the sum of the edge-set represented by the card

QUESTION: Are there any [blue-backed cards] with a [face value <= L]?

  • 2 independent variables: [blue/white cards], [integer face values]

Consider case where L = length of smallest tour.

  • Only need look at blue cards (edge-sets that are an optimal tour for a config)
  • Only need look at cards w/ face value = L (edge-sets with sum = L)

Function A: Select blue-backed card

  • face value depends on which card you select
  • each blue card potentially has face value = L
    • thus, worst-case = [check all blue cards]

Function B: Select a card with face value = L

  • blue back depends on which card you select
  • each card w/ face value = L potentially has blue back
    • thus, worst-case = [check all cards w/ face value = L]

Unlike “Set Inclusion”, now you can verify that a selected card for Function B has a blue back, by running f on the selected card’s configs.

However, controlling either variable, [choosing blue card] or [choosing card w/ face value = L], causes the other to be uncontrollable.

WORST-CASE:

  • FACE-DOWN Approach: turn over all cards with blue back (Function A)
  • FACE-UP Approach: turn over all cards with face value = L (Function B)

So the final question: Is TSP-Decision a version of “Set Inclusion” that has enough information to define a Function B?

If so, does this mean that the worst-case running time of TSP-Decision is lower-bounded by the smaller of the 2 domains of Functions A and B? i.e. min{number of blue cards, number of cards with face value = L} — still only for the case where L = length of smallest tour.

How print more than one page in VB?

What should i change in my code to see more than one page in Print preview and also print more than one page?

Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDoc.PrintPage     Static intStart As Integer     Dim font0 As New Font("arial", 24, FontStyle.Underline)     Dim fntText As Font = font0     Dim txtHeight As Integer     Dim LeftMargin As Integer = PrintDoc.DefaultPageSettings.Margins.Left     Dim TopMargin As Integer = PrintDoc.DefaultPageSettings.Margins.Top     txtHeight = PrintDoc.DefaultPageSettings.PaperSize.Height - PrintDoc.DefaultPageSettings.Margins.Top - PrintDoc.DefaultPageSettings.Margins.Bottom      Dim LinesPerPage As Integer = CInt(Math.Round(txtHeight / (fntText.Height + 0.025)))       e.Graphics.DrawRectangle(Pens.White, e.MarginBounds)     Dim intLineNumber As Integer     e.Graphics.DrawString("Support", font0, Brushes.Black, 75, 50)     For intCounter = intStart To lstLinesToPrint.Count - 1          e.Graphics.DrawString(lstLinesToPrint(intCounter), fntText, Brushes.Black, LeftMargin, fntText.Height * intLineNumber + TopMargin)         intLineNumber += 1         If intLineNumber > LinesPerPage - 1 Then             intStart = intCounter             e.HasMorePages = True             Exit For         End If      Next 

End Sub