⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 installer1.cs

📁 很不错的公文流转系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
						FieldNameList=ofield.Attributes["FieldName"].Value;
					else
						FieldNameList+=","+ofield.Attributes["FieldName"].Value;
				}
				
				oSqlDataAdapter=new System.Data.SqlClient.SqlDataAdapter("select "+FieldNameList+" from "+ TableName ,conn);
				oSqlCommandBuilder.DataAdapter=oSqlDataAdapter;
				odataset.ReadXml(this.currentSystemDir+@"\PowerOI\"+TableName+".xml");
				odataset.Tables[0].TableName=TableName;
				try
				{
					oSqlDataAdapter.Update(odataset,TableName);
				}
				catch(System.Data.SqlClient.SqlException ee)
				{
					OI.Modules.ErrorLog.WriteLog(ee.Message+"\n\r"+ee.StackTrace);
					throw ee;
				}

				odataset.Clear();
				odataset.Tables.RemoveAt(0);
				FieldNameList="";
				oSqlDataAdapter.Dispose();
			}
			
			oSqlCommandBuilder.Dispose();
			conn.Close();
			conn.Dispose();

			//安装TreeView
			
//			System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
//			psi.WorkingDirectory = this.currentSystemDir;
//			psi.FileName = this.currentSystemDir + @"\PowerOI\iewebcontrols.msi ";
//			psi.UseShellExecute=true; //msi文件,如是exe不用设
//			System.Diagnostics.Process.Start(psi);
			

			

		}
		public override void Commit(IDictionary savedState)
		{
			base.Commit (savedState);
			dbServer=this.Context.Parameters["ServerName"];//安装数据库的服务器地址
			dbUser=this.Context.Parameters["InStallAdmin"];//管理员ID
			dbKey=this.Context.Parameters["InstallPassword"];//管理员密码
			dbName= this.Context.Parameters["DataBaseName"];//安装的数据库名称
			loginName=this.Context.Parameters["DataBaseName"];//数据库登录名
			loginPassword=this.GetPassword();//随机登录密码
			currentDir=this.Context.Parameters["dir"];//安装的虚拟目录的物理路径
			if(currentDir.Substring(currentDir.Length-1,1)=="\\")
				currentDir=currentDir.Substring(0,currentDir.Length-1);
			//currentSystemDir=System.IO.Directory.GetCurrentDirectory();//系统目录,一般为c:\winnt\system32
			currentSystemDir=Environment.GetFolderPath(Environment.SpecialFolder.System);//系统目录,一般为c:\winnt\system32


			//获取虚拟目录名
			System.IO.DirectoryInfo oDirectoryInfo=new DirectoryInfo(this.currentDir);
			string virtualDir=oDirectoryInfo.Name;//虚拟目录名

			


			//更新配置文件web.Config			
			File.SetAttributes(this.currentDir+@"\Web.Config",System.IO.FileAttributes.Normal);//取消文件的只读属性
			System.Xml.XmlDocument oXmlDocument=new System.Xml.XmlDocument();

			oXmlDocument.Load(this.currentDir+@"\Web.Config");
			System.Xml.XmlElement rootElement=oXmlDocument.DocumentElement;
			string str;
			
			str="/configuration/appSettings/add[@key='conn']";
			System.Xml.XmlNode oXmlNode1=rootElement.SelectSingleNode(str);
			if(oXmlNode1!=null)
				oXmlNode1.Attributes["value"].Value="server="+this.dbServer+";database="+this.dbName+";uid="+this.loginName+";pwd="+this.loginPassword;

			str="/configuration/appSettings/add[@key='errPage']";
			System.Xml.XmlNode oXmlNode2=rootElement.SelectSingleNode(str);
			if(oXmlNode2!=null)
				oXmlNode2.Attributes["value"].Value="/"+virtualDir+"/ErrorForm.aspx";

			str="/configuration/appSettings/add[@key='photoPath']";
			System.Xml.XmlNode oXmlNode3=rootElement.SelectSingleNode(str);
			if(oXmlNode3!=null)
				oXmlNode3.Attributes["value"].Value="/"+virtualDir+"/UpFile/Images";

			str="/configuration/appSettings/add[@key='reportAccessories']";
			System.Xml.XmlNode oXmlNode4=rootElement.SelectSingleNode(str);
			if(oXmlNode4!=null)
				oXmlNode4.Attributes["value"].Value="/"+virtualDir+"/UpFile/ReportAccessories";

			str="/configuration/appSettings/add[@key='documents']";
			System.Xml.XmlNode oXmlNode5=rootElement.SelectSingleNode(str);
			if(oXmlNode5!=null)
				oXmlNode5.Attributes["value"].Value="/"+virtualDir+"/UpFile/documents";

			str="/configuration/appSettings/add[@key='ReadDocuments']";
			System.Xml.XmlNode oXmlNode8=rootElement.SelectSingleNode(str);
			if(oXmlNode8!=null)
				oXmlNode8.Attributes["value"].Value="/"+virtualDir+"/upfile/documents";


			str="/configuration/appSettings/add[@key='stream']";
			System.Xml.XmlNode oXmlNode6=rootElement.SelectSingleNode(str);
			if(oXmlNode6!=null)
				oXmlNode6.Attributes["value"].Value=this.currentDir+"/UpFile/Stream";

			str="/configuration/appSettings/add[@key='weboffice']";
			System.Xml.XmlNode oXmlNode7=rootElement.SelectSingleNode(str);
			if(oXmlNode7!=null)
				oXmlNode7.Attributes["value"].Value="/"+virtualDir+"";

			oXmlDocument.Save(this.currentDir+@"\Web.Config");			
			
			//设置权限
		
//			if(System.IO.Directory.Exists(this.currentDir+@"\UpFile"))
//			{	
//				setFileNormalAttribute(new System.IO.DirectoryInfo(this.currentDir+@"\UpFile"));
//				System.IO.Directory.Delete(this.currentDir+@"\UpFile",true);
//			}
//			OI.IISManager oIISManager=new OI.IISManager();
//			oIISManager.VirtualDir="/"+virtualDir;			
//			oIISManager.Connect();
//			OI.VirtualDirectory newVirtualDirectory=new OI.VirtualDirectory("UpFile");
//			newVirtualDirectory.AccessWrite=true;
//			newVirtualDirectory.AccessScript=false;
//			newVirtualDirectory.Path=this.currentDir+@"\UpFile";
//			try
//			{
//				oIISManager.Delete("UpFile");
//			}
//			catch
//			{
//			}
//			oIISManager.Create(newVirtualDirectory);

//			System.IO.Directory.CreateDirectory(this.currentDir+@"\UpFile\Stream");
//			System.IO.Directory.CreateDirectory(this.currentDir+@"\UpFile\reportAccessories");
//			System.IO.Directory.CreateDirectory(this.currentDir+@"\UpFile\documents");
//			System.IO.File.Move(this.currentSystemDir+@"\PowerOI\default.config",this.currentDir+@"\UpFile\Stream\default.config");
//			System.IO.File.Move(this.currentSystemDir+@"\PowerOI\44130ac6-6f68-485d-9e1a-1b99e9a7e0cc.config",this.currentDir+@"\UpFile\Stream\44130ac6-6f68-485d-9e1a-1b99e9a7e0cc.config");

//			
//			
			
			//创建快捷方式
			string path=Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
			path+="/派尔OI智能办公系统.url";

			if(System.IO.File.Exists(path))
			{
				System.IO.File.SetAttributes(path,System.IO.FileAttributes.Normal);
				System.IO.File.Delete(path);
			}
			System.IO.StreamWriter oStreamWriter=new StreamWriter(path);
			oStreamWriter.WriteLine("[InternetShortcut]");
			oStreamWriter.WriteLine("URL=http://localhost/"+virtualDir);
			oStreamWriter.Close();
			//删除临时文件
			System.IO.File.Delete(this.currentSystemDir+@"\PowerOI\sql.xml");
			System.Xml.XmlDocument dataXmlDocument=new System.Xml.XmlDocument();
			dataXmlDocument.Load(this.currentSystemDir+@"\PowerOI\data.xml");
			string cXmlPath="/Tables/Table";
			foreach(System.Xml.XmlNode oNode in dataXmlDocument.DocumentElement.SelectNodes(cXmlPath))
			{
				if(System.IO.File.Exists(this.currentSystemDir+@"\PowerOI\"+oNode.Attributes["Name"].Value+".xml"))
				{
					System.IO.File.Delete(this.currentSystemDir+@"\PowerOI\"+oNode.Attributes["Name"].Value+".xml");
				}
			}
			System.IO.File.Delete(this.currentSystemDir+@"\PowerOI\data.xml");
			System.IO.File.Delete(System.IO.Directory.GetCurrentDirectory()+@"\PowerOI\BCEC709A-9639-409b-9EC5-194E6EF5F64F.ini");
			
		}
		private void setFileNormalAttribute(System.IO.DirectoryInfo directory)
		{
			directory.Attributes=System.IO.FileAttributes.Normal;
			foreach(System.IO.FileSystemInfo file in directory.GetFileSystemInfos())
			{
				file.Attributes=System.IO.FileAttributes.Normal;
				if(System.IO.Directory.Exists(file.FullName))
					this.setFileNormalAttribute(new System.IO.DirectoryInfo(file.FullName));
			}
			
			

		}
		public override void Rollback(IDictionary savedState)
		{
			base.Rollback (savedState);
			dbServer=this.Context.Parameters["ServerName"];//安装数据库的服务器地址
			dbUser=this.Context.Parameters["InStallAdmin"];//管理员ID
			dbKey=this.Context.Parameters["InstallPassword"];//管理员密码
			dbName= this.Context.Parameters["DataBaseName"];//安装的数据库名称
			loginName=this.Context.Parameters["DataBaseName"];//数据库登录名
			loginPassword=this.GetPassword();//随机登录密码
			currentDir=this.Context.Parameters["dir"];//安装的虚拟目录的物理路径
			if(currentDir.Substring(currentDir.Length-1,1)=="\\")
				currentDir=currentDir.Substring(0,currentDir.Length-1);
			//currentSystemDir=System.IO.Directory.GetCurrentDirectory();//系统目录,一般为c:\winnt\system32
			currentSystemDir=Environment.GetFolderPath(Environment.SpecialFolder.System);//系统目录,一般为c:\winnt\system32
	
	

			//删除临时文件
			System.IO.File.Delete(this.currentSystemDir+@"\PowerOI\sql.xml");
			System.Xml.XmlDocument oXmlDocument=new System.Xml.XmlDocument();
			oXmlDocument.Load(this.currentSystemDir+@"\PowerOI\data.xml");
			string cXmlPath="/Tables/Table";
			foreach(System.Xml.XmlNode oNode in oXmlDocument.DocumentElement.SelectNodes(cXmlPath))
			{
				if(System.IO.File.Exists(this.currentSystemDir+@"\PowerOI\"+oNode.Attributes["Name"].Value+".xml"))
				{
					System.IO.File.Delete(this.currentSystemDir+@"\PowerOI\"+oNode.Attributes["Name"].Value+".xml");
				}
			}
			System.IO.File.Delete(this.currentSystemDir+@"\PowerOI\data.xml");
			System.IO.File.Delete(System.IO.Directory.GetCurrentDirectory()+@"\PowerOI\BCEC709A-9639-409b-9EC5-194E6EF5F64F.ini");

			
		}




		#region 组件设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();

		}
		#endregion

	
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -