精华内容
下载资源
问答
  • 机械类文献An Study of Unit Machine Operations for Tool Paths in High Speed Milling
  • In addition, there may be operations that act on its component elements. 句子组成:that引导定语从句,修饰operations。 翻译:并且也可以作用于数据结构的组成元素。Such a structure is said to have a last-...

    The Fundamentals of Computer Software

    Data StructureExercises

    Multiple choices.

    The attributes of the stack are ( A ).

    A. FIFO??????????????????????? B. LIFO

    C. queue???????????????????? D. built into their circuitry

    Queues that occur everyday life can be seen ( ABCD ).

    A. in an emergency room of a hospital

    B. in certain societies lacking equality

    C. as people waiting for service at a bank

    D. as automobiles waiting for a traffic light

    A stack protocol can be used for ( C ).

    A. subroutine calls

    B. operation of arithmetic expressions

    C. removing the latest element inserted

    D. removing the earliest element inserted

    The operations of a structured data type might act on ( ABCD ).

    A. a stack

    B. the values of the data type

    C. component elements of the data structure

    D. a queue

    Decide whether the following statements are True or False.

    The operations of a structured data type only act on the values of the data type. (×)

    A stack is a data type whose major attributes are determined by the rules governing the insertion and deletion of its elements. (√)

    A stack is a data type whose data structure is said to have a first-in/last-out (FILO) behavior, or protocol. (√)

    The series of jobs awaiting execution is called a queue. (√)

    The main feature of queues is that they follow a first-come/first-served rule. (√)

    Translate and analyze the following sentences.

    A data structure is a data type whose values are composed of component elements that are related by some structure.

    句子组成:whose引导定语从句,composed of… 由…组成。

    翻译:数据结构是一种数据类型,其值是由通过某种结构相互关联的组成元素所构成的。In addition, there may be operations that act on its component elements.

    句子组成:that引导定语从句,修饰operations。

    翻译:并且也可以作用于数据结构的组成元素。Such a structure is said to have a last-in/first-out (LIFO) behavior.

    句子组成:be said to,被动语态。

    翻译:这就是所谓具有后进先出(LIFO)性质或协议的结构。

    There are many applications of the first-in/fi

    展开全文
  • 1984年,Bennett和Brassard设计了第一个量子密钥分发协议,该协议的安全性基于量子不确定性。 从那时起,一直在开展越来越多的研究活动,旨在设计新的,更有效和安全的密钥分发协议。 该工作提出了一种新颖的混合...
  • 【VMware vRealize Suite 2019 部署系列】- 「2」 – 部署 vRealize Operations 8.1 vRealize Operations 8.x小旭10个月前 (04-15)2812℃0评论 http://www.vmlab.org/533.html 目录 【VMware vRealize Suite ...

    【VMware vRealize Suite 2019 部署系列】- 「2」 – 部署 vRealize Operations 8.1

     vRealize Operations 8.x  小旭  10个月前 (04-15)  2812℃  0评论

    http://www.vmlab.org/533.html

    目录

    【VMware vRealize Suite 2019 部署系列】- 「2」 – 部署 vRealize Operations 8.1

    部署环境规划

    网络需求

    软件版本

    硬件资源

    部署 vRealize Operations 8.1

    vRLCM环境准备

    配置介质文件

    vRLCM 部署 vRealize Operations Manager 8.1


     

    部署环境规划

    网络需求

    根据实际情况规划相关IP地址,如:

    业务地址:用于vRealize Automation 部署VM所使用

    192.168.100.x/24

    管理地址:用于整个环境管理所使用

    192.168.110.x/24

    必须为该环境配置DNS解析服务,修改HOST文件方式可能会导致部署失败。同时,需要在DNS上配置正反向DNS解析。

    本手册部署环境如下:

    vCenter Display Name

    FQDN Name

    Mgt IP

    Service

    controlcenter

    controlcenter.corp.local

    192.168.110.10

    AD、DNS、DHCP

    lcm-01a

    lcm-01a.corp.local

    192.168.110.15

    vRLCM

    vidm-01a

    vidm-01a.corp.local

    192.168.110.16

    VIDM

    vcsa-a.corp.local

    192.168.110.20

    vCenter – VIP

    vcsa-01a

    vcsa-01a.corp.local

    192.168.110.21

    vCenter Server

    vcsa-02a

    vcsa-02a.corp.local

    192.168.110.22

    vCenter Server

    psc-01a

    psc-01a.corp.local

    192.168.110.23

    PSC

    psc-02a

    psc-02a.corp.local

    192.168.110.24

    PSC

    nsxmgr-a.corp.local

    192.168.110.25

    NSX Mgr – VIP

    nsxmgr-01a

    nsxmgr-01a.corp.local

    192.168.110.26

    NSX Mgr Node

    nsxmgr-02a

    nsxmgr-02a.corp.local

    192.168.110.27

    NSX Mgr Node

    nsxmgr-03a

    nsxmgr-03a.corp.local

    192.168.110.28

    NSX Mgr Node

    log-a.corp.local

    192.168.110.30

    vRLI – VIP

    log-01a

    log-01a.corp.local

    192.168.110.31

    vRLI Node

    log-02a

    log-02a.corp.local

    192.168.110.32

    vRLI Node

    log-03a

    log-03a.corp.local

    192.168.110.33

    vRLI Node

    vrops-a.corp.local

    192.168.110.70

    vROps – VIP

    vrops-01a

    vrops-01a.corp.local

    192.168.110.71

    vROps Node

    vrops-02a

    vrops-02a.corp.local

    192.168.110.72

    vROps Node

    vrops-app-rc-01a

    vrops-app-rc-01a.corp.local

    192.168.110.75

    App Monitoring

    vrops-app-rc-02a

    vrops-app-rc-02a.corp.local

    192.168.110.76

    App Monitoring

    vra-a.corp.local

    192.168.110.80

    vRA – VIP

    vra-01a

    vra-01a.corp.local

    192.168.110.81

    vRA Node

    vra-02a

    vra-02a.corp.local

    192.168.110.82

    vRA Node

    软件版本

    vSphere Version: VMware vSphere Hypervisor (ESXi) 6.7 U3

    Appliance File: VMware-VMvisor-Installer-6.7.0.update03-14320388.x86_64.iso

    License: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    vCenter Version: VMware vCenter Server 6.7U3

    Appliance File: VMware-VCSA-all-6.7.0-14367737.iso

    License: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    NSX-T Version: VMware NSX-T Data Center 2.5.0

    Appliance File: nsx-unified-appliance-2.5.0.0.0.14663978.ova

    License: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    vRNI Version: VMware vRealize Network Insight 5.0.0

    Appliance File: VMware-vRealize-Network-Insight-5.0.0.1568279774-platform.ova

    License: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    vRLCM Version: VMware vRealize Suite Lifecycle Manager 8.1.0 

    Appliance File: vra-lcm-installer-15996863.iso

    License: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    vRA 8 Version: VMware vRealize Automation 8.1.0

    Appliance File: vra-lcm-installer-15996863.iso

    License: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    vR Ops 8 Version: VMware vRealize Operations 8.1.0  

    Appliance File: vRealize-Operations-Manager-Appliance-8.1.0.15972145_OVF10.ova

    License: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    vRLI 8 Version: VMware vRealize Log Insight 8.1.0

    Appliance File: VMware-vRealize-Log-Insight-8.1.0.0-15994158_OVF10.ova

    License: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    硬件资源

    Component

    vCPU

    Memory (GB)

    Storage (GB)

    Realize Lifecycle Manager

    2

    6

    33

    VMware Identity Manager

    2

    6

    60

    vRealize Automation

    8

    32

    136

    vRealize Operations

    4

    16

    200

    vRealize Log Insight

    4

    8

    530

    注:以下配置为最低要求,具体占用资源根据实际情况修改。

    部署 vRealize Operations 8.1

    vRLCM环境准备

    配置介质文件

    手机屏幕截图  描述已自动生成

    使用浏览器访问并登录vRLCM HTML 的地址,如:https://lcm-01a.corp.local

    1. 认证源:保持为默认 Local User
    2. Username Example: 输入用户名 admin@local , 注:在 2.x 版本时,用户名为 admin@localhost
    3. Password: 根据实际情况输入密码,如:VMware1! ,

    注:这里使用的是部署vRealize Automation 8.1中所使用的vRLCM,所以密码为在【vRealize Easy Installer】的【8 Password Configuration】中设置的密码。

    1. 点击【LOGIN】

    手机屏幕截图  描述已自动生成

    在【My Services】内:

    1. 点击【Lifecycle Operations】

    电脑萤幕的截图  描述已自动生成

    由于vRLCM内并不包含vRealize Operations、vRealize Log Insight的安装介质、升级包、补丁程序等,所以我们需要手动添加进去,添加有2种方式:

    1. 使用My VMware 账号在线下载,注:需要您的账号有相应产品的下载权限。
    2. 离线上传,由于大部分客户都是处于内网环境,所以使用这个方法比较多。

    在【Lifecycle Operations】内:

    1. 点击【Settings】
    2. 在【Servers & Accounts】中,点击【Binary Mapping】

    手机屏幕截图  描述已自动生成

    在【Binary Mapping】的【Product Binaries】内:

    1. 在【Product Name】中查看到当前的平台内只有VMware Identity Manager、vRealize Automation 2个产品组件的OVA文件,所以我们需要Map一下vRealize Operations、vRealize Log Insight的安装介质
    2. 点击【ADD BINARIES】

    手机截图图社交软件的信息  描述已自动生成

    在【Add Product Binary】内:

    1. 在【Product Name】中查看到当前的平台内只有VMware Identity Manager、vRealize Automation 2个产品组件的OVA文件,所以我们需要Map一下vRealize Operations、vRealize Log Insight的安装介质
    2. Location Type:选择安装介质的Map的方式,如:Local

    Local:vRLCM本地路径,支持类型格式:data/path/to/OVAfolder,

    例如:

    1. ssh连接vRLCM在data文件夹下创建ova文件夹;
    2. 讲ova文件上传到ova文件夹内;

    NFS:NFS方式,支持类型格式:'<host>’ :/path/to/OVAfolder

    My VMware:My VMware 账号在线下载,注,需要您的账号有相应产品的下载权限

    Windows ISO:Windows ISO镜像,主要用于vRealize Automation 7.x 版本部署

    1. 点击【DISCOVER】
    2. 在【Name】中选择识别到的镜像文件
    3. 点击【ADD】

    手机截图图社交软件的信息  描述已自动生成

    在【Binary Mapping】的【Product Binaries】内:

    1. 点击【Product binary mapping request successfully submitted. Click here to check request status.】中的【Click here】查看进度。

    手机屏幕截图  描述已自动生成

    在【Binary Mapping】的【Product Binaries】内:

    1. 在【Product Name】中查看到新添加的vRealize Operations、vRealize Log Insight的安装介质

    配置许可证

    手机屏幕截图  描述已自动生成

    在【My Services】内:

    1. 点击【Locker】

    社交网络的手机截图  描述已自动生成

    在【Locker】内:

    1. 点击【License】
    2. 在【License】中,点击【 ADD】,如果使用My VMware 账号联网登录的话,您所购买的许可证也可以自动同步到这里

    手机屏幕截图  描述已自动生成

    在【License】的【Add License】内:

    1. License Alias: 根据实际名称设置软件许可证显示的名称,为了方便管理,建议设置为软件内识别出的许可证的名称,如:VMware vRealize Suite 2019 Enterprise
    2. License Key:根据实际输入软件许可证号,如:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
    3. 点击【VALIDATE】进行许可证的验证
    4. 验证成功后,在【License Details】内显示该许可证的详细信息,注:实例输入发为测试许可,显示出截止日期
    5. 点击【ADD】

    配置证书文件

    手机屏幕截图  描述已自动生成

    在【My Services】内:

    1. 点击【Locker】

    社交网络的手机截图  描述已自动生成在【Certificate】内:

    1. 点击【GENERATE】生成一个证书文件,当然如果已有证书,可以点击【IMPORT】进行导入

    手机屏幕截图  描述已自动生成

    在【Add Certificate】内:

    1. 根据实际情况填写如下信息:

    Name:输入显示的名称,如:vRS2019-vROps

    Common Name (CN) :输入显示的名称,如:vRealize Operations

    Organization (O):输入组织名称,如:Corp

    Organization Unit (OU):输入组织单位,如:Lab

    Country Code (C):输入国家代码,如:CN

    Locality (L):输入位置,如:China

    State (ST):输入州,中国没有州的概念,可以输入省份/直辖市,如:BeiJing

    Key Length:选择加密级别2048 bits或4096 bits,如:2048 bits

    Server Domain/ Hostname:输入服务器的FQDN,如:vrops-0a.corp.local, *.corp.local

    IP Address:输入服务器的对于的IP地址,如: 192.168.110.71

    1. 点击【GENERATE】

    vRLCM 部署 vRealize Operations Manager 8.1

    在【Lifecycle Operations】内:

    1. 点击【Create Environment】创建环境
    2. 在【Common】内,根据实际情况填写相关信息:

    Environment name:输入环境名称,如:Site-A-vROps

    Administrator Email:输入管理员邮箱地址,如:admin@corp.local

    Default Password:选择默认部署的密码,如果未存在密码,可点击右侧的【图片包含 游戏机  描述已自动生成】进行添加,在【Add Password】内:

    1. Password Alias:输入密码的名称,如:vROps Admin Password
    2. Password:输入密码,需要符合密码的复杂度要求,例如:满足至少8位以上,字母大小写、数字、特殊符号。如:VMware1!
    3. Confirm Password:确认密码,如:VMware1!
    4. Password Description:输入密码说明信息,方便忘记密码时找回提示
    5. User Name:输入用户名,可选项,如:admin

    Select Datacenter:选择所要部署的数据中心名称

    JSON Configuration:是否启用JSON部署,如:保持默认

    说明:vRLCM支持导出已部署的配置为JSON文件,该JSON文件可在以后同样部署中使用。

    1. 在【Customer Experience Improvement Program】中勾选【Join the VMware Customer Experience Improvement Program】
    2. 点击【NEXT】

    电脑萤幕的截图  描述已自动生成

    在【Create Environment】-【Select Product】内:

    1. 勾选【vRealize Operations】,并根据实际情况选择以下信息:

    Installation Type:选择安装的类型,由于本次为新部署,所以选择【New Install】

    Version:部署版本选择 8.1.0

    Deployment Type:选择部署规格大小,保持默认如:Extra small

    注:具体配置规划,请参考http://vropssizer.vmware.com/

    Node Count:根据选择规格大小,其部署节点的数量可选范围也不相同。

    Enable HA:选择是否启用HA模式,注:节点数量 ≥ 2 时,该选项才可以启用

    1. 点击【NEXT】

    手机截图图社交软件的信息  描述已自动生成

    在【Create Environment】-【EULA】内:

    1. 滑动到最下面,勾选【I agree to the terms & conditions】
    2. 点击【NEXT】

    社交网络的手机截图  描述已自动生成

    在【Create Environment】的【License】内:

    1. 点击【SELECTA】选择我们添加的许可证文件
    2. 点击【VALIDATE ASSOCIATION】验证许可证
    3. 许可证验证成功后,在【Product(s)】内可以看到部署产品的图标
    4. 点击【NEXT】

    手机屏幕截图  描述已自动生成

    在【Create Environment】的【Certificate】内:

    1. 在【Select Certificate】中选择创建的证书文件,如:vRS2019-vROps
    2. 点击【NEXT】

    手机屏幕截图  描述已自动生成

    在【Create Environment】的【Infrastructure】内:

    1. 根据实际情况选择如下基础架构信息:

    Select vCenter Server:选择所部署的vCenter地址

    Select Cluster:选择所部署的Cluster名称

    Select Folder:选择所部署的vCenter上文件夹名称,可选项

    Select Resource Pool:选择所部署的资源池名称,可选项

    Select Network:选择所部署的网络交换机名称

    Select Datastore:选择所部署的数据存储名称

    Select Disk Mode:选择所部署的磁盘类型

    Integrate with Identity Manager:勾选该选项,产品将于Identity Manager集成,在部署Identity Manager时候的用户可以作为该产品登录的管理员。

    Use Content Library:如果从LCM到vCenters有网络延迟,同时,希望使用内容库,请启用此选项

    1. 点击【NEXT】

    社交网络的手机截图  描述已自动生成1

    在【Create Environment】的【Network】内:

    1. 根据实际情况选择如下网络信息:

    Select vCenter Server:选择所部署的vCenter地址

    Default Gateway:输入网关地址,如:192.168.110.1

    Netmask:输入子网掩码,如:255.255.255.0

    Domain Name:输入Domain名称,如:corp.local

    Domain Search Path:输入Domain搜索路径,如:corp.local

    DNS Servers:输入DNS地址,如果DNS不存在可以点击【ADD NEW SERVER】进行添加,如:192.168.110.10

    Time Sync Mode:选择NTP服务器的方式,Use NTP Server 或者Use Host Time,如: Use Host Time

    1. 点击【NEXT】

    社交网络的手机截图  描述已自动生成

    在【Create Environment】的【Products】内:

    1. 在【Products】中选择【Install vRealize Operations】
    2. 在【Product Properties】内根据实际情况检查所填写的信息:

    Disable TLS Version:选择禁用TLS 版本,如:TLSv1, TLSv1.1

    Certificate:选择证书文件,如:vRS2019-vROps

    Anti-Affinity / Affinity Rule:根据实际情况勾选是否启用亲和性和反亲和性,如果HA或者CA模式请勾选,单节点模式可保持默认

    Product Password:选择部署产品的管理员的密码,如果有新的密码,可点击③【ADD PASSWORD】添加密码

    Integrate with Identity Manager:根据实际情况勾选是否与Identity Manager集成

    Time Sync Mode:选择时间同步方式,如:Use Host Time

    社交网络的手机截图  描述已自动生成

    在【Create Environment】的【Products】内:

    1. 在【Components】内根据实际情况输入相关信息:

    VM Name:输入部署VM的名称,即为vCenter中的清单名称,如:vrops-01a

    FQDN:输入部署FQDN名称,如:vrops-01a.corp.local

    IP Address:输入部署VM的IP地址,如:192.168.110.71

    1. 点击【NEXT】

    社交网络的手机截图  描述已自动生成

    在【Create Environment】的【Precheck】内:

    1. 点击【RUN PRECHECK】后,查看整个检查结果,如果有错误请及时修复
    2. 点击【NEXT】

    手机屏幕截图  描述已自动生成

    在【Create Environment】的【Summary】内:

    1. 检查配置信息是否正常,如存在问题请点击【BACK】进行修正
    2. 点击【EXPORT CONFIGURATION】导出配置文件,以备用后面部署使用
    3. 点击【SUBMIT】

    在【Request Details】中查看部署的进度及过程,如有部署错误请及时修复后点击重试。

    部署完成

    社交网站的手机截图  描述已自动生成

    转载请注明:虚拟实验室 » 【VMware vRealize Suite 2019 部署系列】- 「2」 – 部署 vRealize Operations 8.1

    喜欢 (14)or分享 (0)

    展开全文
  • Spark Streaming之Window Operations 官网:http://spark.apache.org/docs/latest/streaming-programming-guide.html IDEA操作 package g5.learning import org.apache.spark.SparkConf import org.apache.spark....

    Spark Streaming之Window Operations

    官网:http://spark.apache.org/docs/latest/streaming-programming-guide.html

    在这里插入图片描述

    IDEA操作

    package g5.learning
    
    import org.apache.spark.SparkConf
    import org.apache.spark.streaming.{Seconds, StreamingContext}
    
    import scala.collection.mutable.ListBuffer
    
    object WindowApp {
    
      def main(args: Array[String]): Unit = {
    
        //准备工作
        val conf = new SparkConf().setMaster("local[2]").setAppName("WindowApp")
        val ssc = new StreamingContext(conf, Seconds(10))
    
    
        //业务逻辑
        val lines = ssc.socketTextStream("hadoop001", 9999)
       lines.flatMap(_.split(",")).map((_,1)).reduceByKeyAndWindow((a:Int,b:Int) => (a + b), Seconds(10), Seconds(10))
           .print()
        //streaming的启动
        ssc.start() // Start the computation
        ssc.awaitTermination() // Wait for the computation to terminate
    
      }
    }
    

    注意:

    1.数据可以交叉,也可以不交叉,主要是看你配置的参数
    window length - The duration(持续) of the window (3 in the figure).
    sliding interval - The interval at which the window operation is performed (2 in the figure).
    2.这里涉及到3个时间参数,是有一定的关系的
    These two parameters must be multiples of the batch(一批) interval of the source DStream (1 in the figure).
    window length和sliding interval必须是(conf, Seconds(10))这个时间参数的整数倍

    展开全文
  • In that way, all database operations in CreatePerson method becomes atomic (unit of work).  在createperson方法,我们把 person repository和增加总的人使用统计库统计。在本例中,两个存储库共享相同...

    Introduction

    Connection and transaction management is one of the most important concepts in an application that uses a database. When to open a connection, when to start a transaction, how to dispose the connection and so on.. ASP.NET Boilerplate manages database connection and transactions by it's unit of work system.

    连接和事务管理是使用数据库的应用程序中最重要的概念之一。何时打开连接,何时启动事务,如何处理连接等等。ASP.NET样板的工作单元管理数据库连接和事务系统。

    Connection & Transaction Management in ASP.NET Boilerplate

    ASP.NET Boilerplate opens a database connection (it may not be opened immediately, but opened in first database usage, based on ORM provider implementation) and begins a transaction when entering a unit of work method. So, you can use connection safely in this method. At the end of the method, the transaction is commited and the connection is disposed. If the method throws any exception, transaction is rolled back and the connection is disposed. In this way, a unit of work method is atomic (a unit of work). ASP.NET Boilerplate does all of these automatically.

    ASP.NET样板开放数据库连接(它可能不会立即被打开,但是打开了第一数据库的使用,基于ORM提供程序实现),开始一个事务,当进入一个工作单元的方法。因此,在这种方法中可以安全地使用连接。在方法结束时,事务提交和连接终止。如果该方法抛出任何异常,则回滚事务并设置连接。这样,工作单元的方法就是原子(工作单元)。ASP.NET的样板做所有这些自动。

    If a unit of work method calls another unit of work method, both uses same connection & transaction. The first entering method manages connection & transaction, others use it.

    如果一个工作单元方法调用另一个工作单元方法,则它们都使用相同的连接和事务。第一种输入方法管理连接和事务,其他使用它。

    Conventional Unit Of Work Methods(常规的工作单元方法

    Some methods are unit of work methods by default:

    • All MVC, Web API and ASP.NET Core MVC Controller actions.
    • All Application Service methods.
    • All Repository methods.

     Assume that we have an application service method like below:

    public class PersonAppService : IPersonAppService
    {
        private readonly IPersonRepository _personRepository;
        private readonly IStatisticsRepository _statisticsRepository;
    
        public PersonAppService(IPersonRepository personRepository, IStatisticsRepository statisticsRepository)
        {
            _personRepository = personRepository;
            _statisticsRepository = statisticsRepository;
        }
    
        public void CreatePerson(CreatePersonInput input)
        {
            var person = new Person { Name = input.Name, EmailAddress = input.EmailAddress };
            _personRepository.Insert(person);
            _statisticsRepository.IncrementPeopleCount();
        }
    }

    In the CreatePerson method, we're inserting a person using person repository and incrementing total people count using statistics repository. Both of repositories shares same connection and transaction in this example since application service method is unit of work by default. ASP.NET Boilerplate opens a database connection and starts a transaction when entering CreatePerson method and commit the transaction at end of the method if no exception is thrown, rolls back if any exception occurs. In that way, all database operations in CreatePerson method becomes atomic (unit of work). 

    在createperson方法,我们把 person repository和增加总的人使用统计库统计。在本例中,两个存储库共享相同的连接和事务,因为默认情况下应用程序服务方法是工作单元。ASP.NET样板打开一个数据库连接和启动一个事务进入createperson方法和提交事务结束的方法如果没有异常被抛出,回滚如果发生任何异常。这样,在CreatePerson,所有的数据库操作方法成为原子(工作单位)。

    In addition to default conventional unit of work classes, you can add your own convention in PreInitialize method of your module like below:

    除了默认的工作常规单元类,你可以添加你自己的惯例在分发你模块像下面的方法:

    Configuration.UnitOfWork.ConventionalUowSelectors.Add(type => ...);

    You should check type and return true if this type should be a conventional unit of work class.

    Controlling Unit Of Work

    Unit of work implicitly works for the methods defined above. In most cases you don't have to control unit of work manually for web applications. You can explicitly use it if you want to control unit of work somewhere else. There are two approaches for it. 

    工作单元隐式地工作于上面定义的方法。在大多数情况下,您不必手动控制Web应用程序的工作单元。如果想在其他地方控制工作单元,可以显式地使用它。它有两种方法。

    UnitOfWork Attribute

    First and preferred approach is using UnitOfWork attribute. Example:

    [UnitOfWork]
    public void CreatePerson(CreatePersonInput input)
    {
        var person = new Person { Name = input.Name, EmailAddress = input.EmailAddress };
        _personRepository.Insert(person);
        _statisticsRepository.IncrementPeopleCount();
    }

    Thus, CreatePerson methods becomes unit of work and manages database connection and transaction, both repositories use same unit of work. Note that no need to UnitOfWork attribute if this is an application service method. Also see 'unit of work method restrictions' section.

    因此,createperson方法成为工作单位和管理数据库连接和事务,都使用相同的单元库的工作。注意,如果这是一个应用服务的方法不需要UnitOfWork属性。还请参见“工作单元方法限制”部分。

    There are some options of the UnitOfWork attribute. See 'unit of work in detail' section. UnitOfWork attribute can also be used for classes to configure all methods of a class. Method attribute overrides the class attribute if exists.

    有一些选项UnitOfWork属性。参见“详细工作单元”部分。UnitOfWork属性也可用于类配置一个类的所有方法。如果存在,方法属性重写类属性。

    IUnitOfWorkManager

    Second appropaches is using the IUnitOfWorkManager.Begin(...) method as shown below:

    public class MyService
    {
        private readonly IUnitOfWorkManager _unitOfWorkManager;
        private readonly IPersonRepository _personRepository;
        private readonly IStatisticsRepository _statisticsRepository;
    
        public MyService(IUnitOfWorkManager unitOfWorkManager, IPersonRepository personRepository, IStatisticsRepository statisticsRepository)
        {
            _unitOfWorkManager = unitOfWorkManager;
            _personRepository = personRepository;
            _statisticsRepository = statisticsRepository;
        }
    
        public void CreatePerson(CreatePersonInput input)
        {
            var person = new Person { Name = input.Name, EmailAddress = input.EmailAddress };
    
            using (var unitOfWork = _unitOfWorkManager.Begin())
            {
                _personRepository.Insert(person);
                _statisticsRepository.IncrementPeopleCount();
    
                unitOfWork.Complete();
            }
        }
    }

    You can inject and use IUnitOfWorkManager as shown here (Some base classes have already UnitOfWorkManager injected by default: MVC Controllers, application services, domain services...). Thus, you can create morelimited scope unit of works. In this approach, you should call Complete method manually. If you don't call, transaction is rolled back and changes are not saved.

    你可以注入和使用iunitofworkmanager如下所示(一些基类已经unitofworkmanager注入默认:MVC控制器,应用服务、域名服务…)。因此,您可以创建有限范围的装置作品。在这种方法中,您应该手动调用完整方法。如果不调用,事务将回滚,而更改不会保存。

    Begin method has overloads to set unit of work options. It's better and shorter to use UnitOfWork attribute if you don't have a good reason.

    开始方法有重载来设置工作单元选项。最好使用短UnitOfWork属性,如果你没有一个好的理由。

    Unit Of Work in Detail

    Disabling Unit Of Work

    You may want to disable unit of work for conventional unit of work methods . To do that, use UnitOfWorkAttribute's IsDisabled property. Example usage:

    [UnitOfWork(IsDisabled = true)]
    public virtual void RemoveFriendship(RemoveFriendshipInput input)
    {
        _friendshipRepository.Delete(input.Id);
    }
    			

    Normally, you don't want to do that, but in some situations you may want to disable unit of work:

    • You may want to use unit of work in a limited scope with UnitOfWorkScope class described above.
    • 你可能想要与unitofworkscope类以上所描述的在一个有限的范围内使用工作单元。

    Note that if a unit of work method calls this RemoveFriendship method, disabling this method is ignored and it uses the same unit of work with the caller method. So, use disabling by carefully. Also, the code above works well since repository methods are unit of work by default.

    注意,如果一个单位的工作方法调用此removefriendship法,这种方法是忽略,它使用相同的工作单元与来电者的方法禁用。所以,小心地禁用。此外,上面的代码很好地工作,因为默认情况下存储库方法是工作单元。

    Non-Transactional Unit Of Work(非事务性工作单元

    A unit of work is transactional as default (by it's nature). Thus, ASP.NET Boilerplate starts/commits/rollbacks an explicit database-level transaction. In some special cases, transaction may cause problems since it may lock some rows or tables in the database. In this situations, you may want to disable database-level transaction. UnitOfWork attribute can get a boolean value in it's constructor to work as non-transactional. Example usage:

    工作单元是事务性的缺省(根据其性质)。因此,ASP.NET开始/提交/回滚文件显式数据库事务。在某些特殊情况下,事务可能导致问题,因为它可能会锁定数据库中的某些行或表。在这种情况下,您可能希望禁用数据库级事务。UnitOfWork属性可以作为非事务性的构造函数的布尔值。使用示例:

    [UnitOfWork(isTransactional: false)]
    public GetTasksOutput GetTasks(GetTasksInput input)
    {
        var tasks = _taskRepository.GetAllWithPeople(input.AssignedPersonId, input.State);
        return new GetTasksOutput
                {
                    Tasks = Mapper.Map<List<TaskDto>>(tasks)
                };
    }

    I suggest to use this attribute as [UnitOfWork(isTransactional: false)]. I think it's more readable and explicit. But you can use as [UnitOfWork(false)].

    我建议使用此属性为[ UnitOfWork(istransactional:false)]。我认为它更易读,更明确。但是,你可以使用[ UnitOfWork(false)]。

    Note that ORM frameworks (like NHibernate and EntityFramework) internally saves changes in a single command. Assume that you updated a few Entities in a non-transactional UOW. Even in this situation all updates are performed at end of the unit of work with a single database command. But if you execute an SQL query directly, it's performed immediately and not rolled back if your UOW is not transactional.

    注意,ORM框架(如NHibernate和EntityFramework)内保存在一个单一的命令更改。假设你在一个非事务性更新UOW几个实体。即使在这种情况下,所有更新都是在工作单元的末端用一个数据库命令执行的。但如果你执行一个SQL查询,它立即执行,如果你不回滚UOW不是事务性的。

    There is a restriction for non-transactional UOWs. If you're already in a transactional unit of work scope, setting isTransactional to false is ignored (use Transaction Scope Option to create a non-transactional unit of work in a transactional unit of work).

    在非事务性UOWS中有限制。如果你已经在一个事务工作单元的范围,设置istransactional = false 被忽略(使用事务范围选项创建工作非事务性单元在一个事务工作单元)。

    Use non-transactional unit of works carefully since most of the times it should be transactional for data integrity. If your method just reads data, not changes it, it can be safely non-transactional.

    仔细地使用非事务性的工作单元,因为大多数时候它应该是数据完整性的事务处理。如果您的方法只读取数据,而不更改数据,则可以安全地非事务性地处理。

    A Unit Of Work Method Calls Another

    Unit of work is ambient. If a unit of work method calls another unit of work method, they share same connection and transaction. First method manages connection, others use it.

    工作单元是环境。如果一个工作单元方法调用另一个工作单元方法,它们共享相同的连接和事务。第一种方法管理连接,另一些方法使用它。

    Unit Of Work Scope

    You can create a different and isolated transaction in another transaction or can create a non-transactional scope in a transaction. .NET defines TransactionScopeOption for that. You can set Scope option of the unit of work to control it.

    您可以在另一个事务中创建不同的、独立的事务,也可以在事务中创建非事务作用域。transactionscopeoption。net定义为。您可以设置工作单元的范围选项来控制它。

    Automatically Saving Changes(自动保存更改

    If a method is unit of work, ASP.NET Boilerplate saves all changes at the end of the method automatically. Assume that we need method to update name of a person:

    [UnitOfWork]
    public void UpdateName(UpdateNameInput input)
    {
        var person = _personRepository.Get(input.PersonId);
        person.Name = input.NewName;
    }

    That's all, name was changed! We did not even called _personRepository.Update method. O/RM framework keep track of all changes of entities in a unit of work and reflects changes to the database.

    就这样,名字被改变了!我们甚至没有调用_personrepository.update方法。O/RM框架跟踪工作单元中所有实体的变化,并反映对数据库的更改。

    Note that no need to declare UnitOfWork for conventional unit of work methods.

    注意,不需要申明的工作方法常规单元UnitOfWork。

    IRepository.GetAll() Method

    When you call GetAll() out of a repository method, there must be an open database connection since it returns IQueryable. This is needed because of deferred execution of IQueryable. It does not perform database query unless you call ToList() method or use the IQueryable in a foreach loop (or somehow access to queried items). So, when you call ToList() method, database connection must be alive.

    当你调用getall()仓库的方法,必须有一个开放的数据库连接,因为它返回IQueryable。这是因为延期执行IQueryable。它不除非你调用tolist()方法或在foreach循环使用IQueryable执行数据库查询(或者访问查询项目)。所以,当你调用tolist()方法、数据库连接必须活着。

    Consider the example below:

    [UnitOfWork]
    public SearchPeopleOutput SearchPeople(SearchPeopleInput input)
    {
        //Get IQueryable<Person>
        var query = _personRepository.GetAll();
    
        //Add some filters if selected
        if (!string.IsNullOrEmpty(input.SearchedName))
        {
            query = query.Where(person => person.Name.StartsWith(input.SearchedName));
        }
    
        if (input.IsActive.HasValue)
        {
            query = query.Where(person => person.IsActive == input.IsActive.Value);
        }
    
        //Get paged result list
        var people = query.Skip(input.SkipCount).Take(input.MaxResultCount).ToList();
    
        return new SearchPeopleOutput { People = Mapper.Map<List<PersonDto>>(people) };
    }

    Here, SearchPeople method must be unit of work since ToList() method of IQueryable is called in the method body, and database connection must be open when IQueryable.ToList() is executed.

    在这里,searchpeople方法必须工作单位自IQueryable tolist()方法的方法体中,与数据库的连接必须打开时执行tolist() IQueryable。

    In most cases you will use GetAll method safely in a web application, since all controller actions are unit of work by default and thus database connection is available in entire request.

    在大多数情况下,你会在一个Web应用程序安全的使用GetAll,因为所有的控制器操作的默认工作单元,因此可以在整个请求数据库连接

    UnitOfWork Attribute Restrictions(UnitOfWork属性限制)

    You can use UnitOfWork attribute for;

    • All public or public virtual methods for classes those are used over interface (Like an application service used over service interface).
    • All public virtual methods for self injected classes (Like MVC Controllers and Web API Controllers).
    • All protected virtual methods.
    • 用于通过接口使用的类的所有公共或公共虚拟方法(如在服务接口上使用的应用程序服务)。
      用于自注入类的所有公共虚拟方法(如MVC控制器和Web API控制器)。
      所有受保护的虚拟方法。

    It's suggested to always make the method virtual. You can not use it for private methods. Because, ASP.NET Boilerplate uses dynamic proxying for that and private methods can not be seen by derived classes. UnitOfWork attribute (and any proxying) does not work if you don't use dependency injection and instantiate the class yourself.

    建议始终将方法虚拟化。不能用于私有方法。因为,ASP.NET样板使用动态代理,私有方法不能被派生类视。UnitOfWork属性(和任何代理)不工作如果你不使用依赖注入和实例化类自己的。

    Options(选项

    There are some options can be used to change behaviour of a unit of work.

    First, we can change default values of all unit of works in the startup configuration. This is generally done in PreInitialize method of our module.

    首先,我们可以在启动配置中更改所有工作单元的默认值。这一般是在我们的模块的方法进行操作

    public class SimpleTaskSystemCoreModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.UnitOfWork.IsolationLevel = IsolationLevel.ReadCommitted;
            Configuration.UnitOfWork.Timeout = TimeSpan.FromMinutes(30);
        }
    
        //...other module methods
    }

    Second, we can override defaults for a particular unit of work. For that, UnitOfWork attribute constructor and IUnitOfWorkManager.Begin method have overloads to get options.

    其次,我们可以重写特定工作单元的缺省值。为此,UnitOfWork属性构造函数和方法重载iunitofworkmanager。开始获得方法。

    And lastly, you can use startup configuration to configure default unit of work attributes for ASP.NET MVC, Web API and ASP.NET Core MVC Controllers (see their documentation).

    最后,你可以使用启动配置配置ASP.NET MVC的工作属性的默认单位,Web API和ASP.NET核心的MVC控制器(见文献)。

    Methods

    UnitOfWork system works seamlessly and invisibly. But, in some special cases, you need to call it's methods.

    系统可以无缝的和无形UnitOfWork。但是,在某些特殊情况下,您需要调用它的方法。

    You can access to current unit of work in one of two ways:

    您可以通过以下两种方式之一访问当前工作单元:

    • You can directly use CurrentUnitOfWork property if your class is derived from some specific base classes (ApplicationService, DomainService, AbpController, AbpApiController... etc.)
    • You can inject IUnitOfWorkManager into any class and use IUnitOfWorkManager.Current property.
    • 你可以直接使用CurrentUnitOfWork属性,如果你的类是来源特性((ApplicationService, DomainService, AbpController, AbpApiController.…等)
    • 你可以注入IUnitOfWorkManager 到你的任何类,只用 IUnitOfWorkManager.Current 属性

    SaveChanges(保存修改

    ASP.NET Boilerplate saves all changes at end of a unit of work, you don't have to do anything. But, sometimes, you may want to save changes to database in middle of a unit of work operation. An example usage may be saving changes to get Id of a new inserted Entity in EntityFramework.

    You can use SaveChanges or SaveChangesAsync method of current unit of work.

     Note that: if current unit of work is transactional, all changes in the transaction are rolled back if an exception occurs, even saved changes.

    ASP.NET样板保存最后一个工作单元所有的改变,你不需要做任何事。但是,有时您可能希望在工作单元的中间操作中保存对数据库的更改。一个例子使用可保存更改到新插入的ID在EntityFramework的实体。

    你可以使用调用SaveChanges或现在的工作单位savechangesasync方法。

    注意:如果当前工作单元是事务性的,那么如果异常发生,事务中的所有更改都会回滚,甚至保存更改。

    Events

    A unit of work has Completed, Failed and Disposed events. You can register to these events and perform needed operations. For example,yYou may want to run some code when current unit of work successfully completed. Example:

    工作单元完成、失败和处理事件。您可以注册这些事件并执行所需的操作。例如,你可能想运行一些代码,当前的单位工作顺利完成。例子:

    public void CreateTask(CreateTaskInput input)
    {
        var task = new Task { Description = input.Description };
    
        if (input.AssignedPersonId.HasValue)
        {
            task.AssignedPersonId = input.AssignedPersonId.Value;
            _unitOfWorkManager.Current.Completed += (sender, args) => { /* TODO: Send email to assigned person */ };
        }
    
        _taskRepository.Insert(task);
    }

    转载于:https://www.cnblogs.com/smileberry/p/7895107.html

    展开全文
  • UNIT I- Session 4.pdf

    2020-03-20 19:59:14
    Introduction –Basic terminology –Data structures –Data structure operations -ADT –Algorithms: Complexity, Time –Space trade off -Mathematical notations and functions -Asymptotic notations –...
  • UNIT I- Session 1.pdf

    2020-03-20 16:27:04
    Introduction –Basic terminology –Data structures –Data structure operations -ADT –Algorithms: Complexity, Time –Space trade off -Mathematical notations and functions -Asymptotic notations –...
  • Rectified Linear Unit (ReLU)

    千次阅读 2015-11-18 15:57:21
    The Rectified Linear Unit (ReLU) computes the function f(x)=max(0,x)f(x)=max(0,x), which is simply thresholded at zero.There are several pros and cons to using the ReLUs: (Pros) Compared to sigmoid/...
  • 计算机专业英语Unit 7

    2021-06-25 08:13:54
    计算机专业英语Unit 7 The Fundamentals of ComputerSoftwareText 1 Data StructureExercises1. Multiple choices.(1) The attributes of the stack are ( A ).A. FIFO B. LIFOC. queue ...
  • Unit Of Work--工作单元(一)

    千次阅读 2017-12-29 00:37:28
    List m_operations = new List(); public SQLUnitOfWork (IDbConnection connection) { this .m_connection = connection; } public void RegisterAdd ( string sql, params IDataParameter[]...
  • UNIT II- Session 1 and 2.pdf

    2020-03-20 20:01:19
    Introduction –Basic terminology –Data structures –Data structure operations -ADT –Algorithms: Complexity, Time –Space trade off -Mathematical notations and functions -Asymptotic notations –...
  • UNIT I- Session 5,6.pdf

    2020-03-20 20:00:21
    Introduction –Basic terminology –Data structures –Data structure operations -ADT –Algorithms: Complexity, Time –Space trade off -Mathematical notations and functions -Asymptotic notations –...
  • UNIT I- Session 2 (1).pdf

    2020-03-20 16:28:26
    Introduction –Basic terminology –Data structures –Data structure operations -ADT –Algorithms: Complexity, Time –Space trade off -Mathematical notations and functions -Asymptotic notations –...
  • 高中英语必修二unit3课文翻译篇一:高一英语人教版必修二Unit 3 课文内容Unit 3 WHO AM I?Over time I have been changed quite a lot. I began as a calculating machine in France in 1642. Although I was young ...
  • https://blog.thomaspoulet.fr/uniform-sampling-on-unit-hemisphere/ introduction during the rendering process, u will need to sample points over a designated surface. in this first part (meaning there...
  • Graphics processing unit

    千次阅读 2012-08-14 13:28:10
    as "the world's first 'GPU', or Graphics Processing Unit, a single-chip processor with integrated transform, lighting, triangle setup/clipping, and rendering engines that is capable of processing a ...
  • 大学英语综合教程四 Unit 4 课文内容英译中 中英翻译   大家好,我叫亓官劼(qí guān jié ),在CSDN中记录学习的点滴历程,时光荏苒,未来可期,加油~博客地址为:亓官劼的博客 本文原创为亓官劼,请...
  • 大学英语综合教程四 Unit 1至Unit 8课文内容英译中 中英翻译   大家好,我叫亓官劼(qí guān jié ),在CSDN中记录学习的点滴历程,时光荏苒,未来可期,加油~博客地址为:亓官劼的博客 本文原创为亓官劼...
  • <div><p>This PR adds iRODS federated user zone unit tests for all file-related operations for generic resource types and specific resource types that involves metadata extraction from files coming ...
  • Micro-operations An instruction cycle: Fetch sub cycle Access  PC, PC contains address of next instruction Address moved to MAR Address placed on address bus Control unit ...
  • DStream上的操作与RDD的类似,分为Transformations(转换)和Output Operations(输出)两种,此外转换操作中还有一些比较特殊的操作,如:updateStateByKey()、transform()以及各种Window相关的操作。 1. ...
  • Sensitivity and data processing speed are important in spectral domain ... By eliminating the huge Fast Fourier Transform Algorithm (FFT) operations, the operation number of the time-domain interpolati
  • When a processor uses an 8-bit data bus to transfer a 32-bit integer to memory, for example, the integer must be broken into four parts, and four separate data transfer operations are required to ...
  • <div><p>I think there might be a bit of an issue with working with device unit numbers and PCI devices. <p>Consider the following scenario where we add a SCSI controller, a disk, and a virtual NIC, ...
  • 3.2 分离分支的卷积 在这一小节,我们概括六种转换形式(Fig.2)来转换一个具有batch normalization(BN)、branch addition、depth concatenation、multi-scale operations、avarage pooling 和 sequences of ...
  • Create Operations Create Operations可以将文档插入到集合中。 这些插入操作针对单个集合。 在单个文档级别,所有写操作都是原子的。 Insert Documents 语法:db.collection.insertOne() 或db.collection....
  • EF Unit Of Work

    2016-01-11 17:59:00
    // implement the operations below. GetById, Insert, Update..... }  IUnitOfwork public interface IUnitOfWork { IRepository<Student> StudentRepository {get;set} // add other repositories ...
  • static const struct file_operations proc_cacheinfo_operations = { .open = cacheinfo_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, };...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 20,407
精华内容 8,162
关键字:

operationsunit