1.1 if…else语句
if语句用于根据一个布尔表达式的值选择一条语句来执行,其基本格式如下:
if (布尔表达式) { [语句块] }
示例代码:
staticvoid Main(string[] args) { int i = 333; //声明一个int类型变量i if (i > 998) //调用if语句判断i是否大于998 { Console.WriteLine("i大于998"); //如果i大于998则输出“i大于998” } else //否则 { Console.WriteLine("i不大于998"); //输出“i不大于998” } Console.ReadLine(); }
运行结果:
当然了,程序的条件判断式不止一个,可能需要一个嵌套式的if…else语句,也就是在if或else语句中的程序块中加入另一段if语句或者if…else语句。
1.2 switch语句switch语句是多分支选择语句,它根据表达式的值来使程序从多个分支中选择一个用于执行的分支。基本格式为:
switch([表达式 ]) { case[常量表达式]:[语句块] break; case[常量表达式]:[语句块] break; … case[常量表达式]:[语句块] default:[语句块] break; }
示例代码:
staticvoid Main(string[] args) { string MyStr = "用一生下载你"; switch (MyStr) { //如果MyStr值是“用一生下载你”,就执行分支1 case "用一生下载你":Console.WriteLine("用一生下载你"); break; //如果MyStr值是“一生所爱”,就执行分支2 case "一生所爱": Console.WriteLine("一生所爱"); break; //如果MyStr值是“值都不符合以上分支内容,则执行default语句 default : Console.WriteLine("无字符"); break; } Console.ReadLine(); }
运行结果:
2. 迭代语句
2.1 while语句
while语句用于根据条件值执行一条语句零次或多次,当每次while语句中德代码执行完毕时,将重新查看是否符合条件值,若符合则再次执行相同的代码,否则跳出while语句。
示例代码:
staticvoid Main(string[] args) { int s = 0, num = 80; //声明两个int类型变量并初始化 while (s < num) //调用while语句,当s小于num时执行 { s++; //s自增1 if (s >40) //使用if语句判断s是否大于40 { break ; //如果大于40,则使用break语句终止循环 } if (s %2==0) //如果小于40,则调用if语句判断s是否为偶数 { continue; //如果结果又符合条件,则转到下一次循环 } Console.WriteLine (s ); } Console.ReadLine (); }
运行结果:
2.2 do…while语句
do…while语句和while语句类似,不同的是它的判断条件在循环后。do…while循环会在计算条件表达式之前执行。
示例代码:
staticvoid Main(string[] args) { bool term = false; //声明一个bool类型变量term,并初始化为false int[] myArray = new int[5] { 0,1,2,3,4}; //声明一个int数组并初始化 do //调用do...while语句 { for (int i = 0; i < myArray.Length; i++)//调用for语句输出数组中的所有数据 { Console.WriteLine(myArray[i ]); //输出数组中的数据 } } while (term); //设置do...while语句的条件 Console.ReadLine(); }
运行结果:
2.3 for语句
for语句用于计算一个初始化序列,然后当某个条件为真时,重复执行嵌套语句并计算一个迭代表达式序列。如果为假,则终止循环,退出for循环。
示例代码:
static void Main(string[] args) { int[] myint = new int[5]; //声明一个具有5个元素的整型数组 myint[0] = 0; //向数组中添加第一个元素 myint[1] = 1; //向数组中添加第二个元素 myint[2] = 2; //向数组中添加第三个元素 myint[3] = 3; //向数组中添加第四个元素 myint[4] = 4; //向数组中添加第五个元素 for (int i = 0; i < myint.Length; i++) //调用for循环语句 { Console.WriteLine("myint[{0}]的值是:{1}",i ,myint [i]); //输出结果 } Console.ReadLine(); }
fishcat论 RMAN还原归档日志时应注意
1、先备份归档
RMAN> BACKUP
2> FORMAT '/backup/arch_%T_%s_%p'
3> SKIP INACCESSIBLE
4> ARCHIVELOG ALL DELETE INPUT;
Starting backup at 09-JAN-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=72 RECID=6 STAMP=804228455
input archived log thread=1 sequence=73 RECID=7 STAMP=804228639
input archived log thread=1 sequence=74 RECID=8 STAMP=804228749
channel ORA_DISK_1: starting piece 1 at 09-JAN-13
channel ORA_DISK_1: finished piece 1 at 09-JAN-13
piece handle=/backup/arch_20130109_6_1 tag=TAG20130109T045229 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/archive1/1_72_803945866.dbf RECID=6 STAMP=804228455
archived log file name=/archive1/1_73_803945866.dbf RECID=7 STAMP=804228639
archived log file name=/archive1/1_74_803945866.dbf RECID=8 STAMP=804228749
Finished backup at 09-JAN-13
2、上边看到备份了sequence72,73,74的归档文件然后还原72-74
RMAN> restore archivelog sequence between 72 and 74;
Starting restore at 09-JAN-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=72
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=73
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=74
channel ORA_DISK_1: reading from backup piece /backup/arch_20130109_6_1
channel ORA_DISK_1: piece handle=/backup/arch_20130109_6_1 tag=TAG20130109T045229
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 09-JAN-13
3、再次备份归档
RMAN> BACKUP
2> FORMAT '/backup/arch_%T_%s_%p'
3> SKIP INACCESSIBLE
4> ARCHIVELOG ALL DELETE INPUT;
Starting backup at 09-JAN-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=72 RECID=11 STAMP=804228908
input archived log thread=1 sequence=73 RECID=9 STAMP=804228907
input archived log thread=1 sequence=74 RECID=10 STAMP=804228907
input archived log thread=1 sequence=75 RECID=12 STAMP=804228962
channel ORA_DISK_1: starting piece 1 at 09-JAN-13
channel ORA_DISK_1: finished piece 1 at 09-JAN-13
piece handle=/backup/arch_20130109_7_1 tag=TAG20130109T045602 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/archive1/1_72_803945866.dbf RECID=11 STAMP=804228908
archived log file name=/archive1/1_73_803945866.dbf RECID=9 STAMP=804228907
archived log file name=/archive1/1_74_803945866.dbf RECID=10 STAMP=804228907
archived log file name=/archive1/1_75_803945866.dbf RECID=12 STAMP=804228962
Finished backup at 09-JAN-13
4、上面又出现了72-74的备份,查看rman备份集,又现惊人一幕72-74有重复
RMAN> list backup of archivelog all;
List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
6 27.90M DISK 00:00:01 09-JAN-13
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20130109T045229
Piece Name: /backup/arch_20130109_6_1
List of Archived Logs in backup set 6
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 72 585166 08-JAN-13 619196 09-JAN-13
1 73 619196 09-JAN-13 619547 09-JAN-13
1 74 619547 09-JAN-13 619601 09-JAN-13
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
7 27.91M DISK 00:00:02 09-JAN-13
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20130109T045602
Piece Name: /backup/arch_20130109_7_1
List of Archived Logs in backup set 7
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 72 585166 08-JAN-13 619196 09-JAN-13
1 73 619196 09-JAN-13 619547 09-JAN-13
1 74 619547 09-JAN-13 619601 09-JAN-13
1 75 619601 09-JAN-13 619722 09-JAN-13
5、如果手动把还原的归档删除,那么在备份的时候会出现如下情况
RMAN> BACKUP
2> FORMAT '/backup/arch_%T_%s_%p'
3> SKIP INACCESSIBLE
4> ARCHIVELOG ALL DELETE INPUT;
Starting backup at 09-JAN-13
current log archived
using channel ORA_DISK_1
archived log /archive1/1_72_803945866.dbf not found or out of sync with catalog
skipping inaccessible file /archive1/1_72_803945866.dbf
archived log /archive1/1_73_803945866.dbf not found or out of sync with catalog
skipping inaccessible file /archive1/1_73_803945866.dbf
archived log /archive1/1_74_803945866.dbf not found or out of sync with catalog
skipping inaccessible file /archive1/1_74_803945866.dbf
RMAN-06061: WARNING: skipping archived log compromises recoverability
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=76 RECID=16 STAMP=804229192
channel ORA_DISK_1: starting piece 1 at 09-JAN-13
channel ORA_DISK_1: finished piece 1 at 09-JAN-13
piece handle=/backup/arch_20130109_8_1 tag=TAG20130109T045952 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/archive1/1_76_803945866.dbf RECID=16 STAMP=804229192
Finished backup at 09-JAN-13
备份语句中不加SKIP INACCESSIBLE则备份就会时失败
RMAN> BACKUP
2> FORMAT '/backup/arch_%T_%s_%p'
3> ARCHIVELOG ALL DELETE INPUT;
Starting backup at 09-JAN-13
current log archived
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 01/09/2013 05:00:17
RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
ORA-19625: error identifying file /archive1/1_72_803945866.dbf
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
6、遇到删除归档的情况就只能通过crosscheck archivelog处理了,处理后备份正常
RMAN> crosscheck archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=41 device type=DISK
validation failed for archived log
archived log file name=/archive1/1_72_803945866.dbf RECID=15 STAMP=804229133
validation failed for archived log
archived log file name=/archive1/1_73_803945866.dbf RECID=13 STAMP=804229132
validation failed for archived log
archived log file name=/archive1/1_74_803945866.dbf RECID=14 STAMP=804229132
validation succeeded for archived log
archived log file name=/archive1/1_77_803945866.dbf RECID=17 STAMP=804229217
Crosschecked 4 objects
RMAN> delete expired archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=41 device type=DISK
List of Archived Log Copies for database with db_unique_name C1
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
15 &
本文讲述SharePoint 2013如何在不同的环境之间(开发环境,测试环境,生产环境)移植由SharePoint designer 2013 设计的List Workflow。
在SharePoint 2010和2007 中,如果针对某个List 使用 SharePoint designer设计一个Workflow,通常我们有 三个环境(开发环境,测试环境,生产环境),但是我没办法把workflow 从开发环境移植到其他环境,需要在其他环境重复在 SharePoint designer设计该Workflow的步骤,也就是说至少要做三遍的重复劳动。
在SharePoint 2013里面就不需要这样了,只需要简单的几步就可以实现在各个环境中的移植。
但是因为SharePoint 2013环境中既可以 SharePoint 2010版本的工作流也可以运行SharePoint 2013版的新工作流, SharePoint 2010还是不能移植的,只有新建工作流时选择了平台为SharePoint 2013才移植:
但是SharePoint 2013安装好后默认是没有该选项的,需要安装配置Workflow Manager 1.0 ,如何安装配置Workflow Manager 1.0参考http://technet.microsoft.com/en-us/library/jj658588(v=office.15)。
以下步骤假设环境全部就绪:
1. 新建一个列表(命名为ListA)用于帮定工作流
2. 启动SharePoint designer 2013为ListA新建工作流,这里的例子是一个非常简单的工作流
3. 保存并发布该工作流
4.将该工作流另存为模板
5.另存成功的工作流模板在Site Asset中,将该模板导出到本地文件夹
6.将ListA另存为模板,并下载到本地文件夹
7.将ListA的模板上传到要迁移到的目标环境的对应网站的list template中
8. 在目标环境新建以ListA的模板为模板新建列表,同样要命名为ListA,和Site的相对路径要保持一致
9. 上传工作流模板Notification.wsp到目标环境的对应网站的solution 列表中
10. Active 该Solution
11. 在Site Feature找到Notification workflow相关的Feature 并active 该feature.
注意8,9步的顺序不能弄反,否则会出现如下错误:
Unexpected System.InvalidOperationException: System.ArgumentException: WSEventSourceGUID at Microsoft.SharePoint.WorkflowServices.WorkflowSubscriptionStorageEventReceiver.ItemAdded(SPItemEventProperties properties) at Microsoft.SharePoint.WorkflowServices.SPWorkflowPackageFeatureReceiver.FeatureActivated(SPFeatureReceiverProperties
properties) at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce) at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, SPFeatureActivateFlags activateFlags,
Boolean fForce) at Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean fo... 5ba2f29b-0de2-c096-b988-1adcf27a6c6c
01/08/2013 10:24:13.46* w3wp.exe (0x2894) 0x2DC0 SharePoint Foundation Runtime tkau Unexpected ...rce, Boolean fMarkOnly) at Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid
featureId, Int32 compatibilityLevel, String featureName, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean force, Boolean fMarkOnly, SPFeatureDefinitionScope featdefScope) at Microsoft.SharePoint.WebControls.FeatureActivator.ActivateFeature(Guid
featid, Int32 compatibilityLevel, SPFeatureDefinitionScope featdefScope) at Microsoft.SharePoint.WebControls.FeatureActivatorItem.ToggleFeatureActivation() at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 5ba2f29b-0de2-c096-b988-1adcf27a6c6c