/// <summary> /// 删除系统权限信息 /// </summary> /// <returns></returns> public bool Execute() { Dbconn conn = new Dbconn("MDM"); try { string strAuthorization_ID = m_request.Tables[0].Rows[0]["Authorization_ID"].ToString(); m_request.Tables[0].Columns.Remove("Authorization_ID"); ArrayList listTable = new ArrayList(); listTable.Add("MDM_System_Authorization"); listTable.Add("MDM_System_Menu_AUZ"); conn.BeginTransaction(); conn.TableLock(listTable); if (strAuthorization_ID != "") { string strWhere = " Authorization_ID=" + strAuthorization_ID; conn.Delete("MDM_System_Authorization", strWhere); conn.Delete("MDM_System_Menu_AUZ", strWhere); } conn.CommitTransaction(); return true; } catch { conn.RollbackTransaction(); throw; } }
/// <summary> /// 编辑WS信息 /// </summary> /// <returns></returns> public bool Execute() { Dbconn conn = new Dbconn("WSRR"); try { if(m_request == null || m_request.Tables.Count==0 || m_request.Tables[0].Rows.Count == 0) { return true; } string strParam_ID = m_request.Tables[0].Rows[0]["Param_ID"].ToString(); ArrayList listTable = new ArrayList(); listTable.Add("WS_Param"); conn.BeginTransaction(); conn.TableLock(listTable); string strWhere = " Param_ID = '" + strParam_ID + "'"; conn.Delete("WS_Param", strWhere); conn.CommitTransaction(); return true; } catch { conn.RollbackTransaction(); throw; } }
public DataSet GetData() { Dbconn conn = new Dbconn("WSRR"); string strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); DataTable dt_EditResult = new dsCommon.dtResultDataTable(); DataSet dsRequest = new DataSet(); DataSet ds_Return = new DataSet(); dsRequest = Common.Common.GetDSByExcelXML(strXML); DataTable dt_OPTYPE = dsRequest.Tables["OPTYPE"]; DataTable dt_LIST = dsRequest.Tables["LIST"]; for (int i = 0; i < dt_OPTYPE.Rows.Count; i++) { //获取用户权限信息 if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "GET") { string strUserName = dt_LIST.Rows[0]["UserName"].ToString(); string strSQL = @" SELECT DISTINCT T1.[AUZID] ,T1.[AUZName] ,0 AS Authorization_ID_F , CASE WHEN T2.USERNAME IS NULL THEN '0' ELSE '1' END HavaFlag FROM [WSRR_Manage].[F01_CERT].[AUZ] T1 WITH ( NOLOCK ) LEFT JOIN [WSRR_Manage].[F01_CERT].[UserAUZ] T2 WITH ( NOLOCK ) ON T1.AUZID=T2.AUZID AND T2.USERNAME=@param0"; ds_Return = conn.GetDataSet(strSQL, new string[] { strUserName }); } //更新用户权限 else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "UPDATE") { string strUserName = dt_LIST.Rows[0]["UserName"].ToString(); conn.LockTableList.Add("[WSRR_Manage].[F01_CERT].[UserAUZ]");//锁定表 conn.BeginTransaction(); //1.删除该用户的所有权限 string strWhere = " UserName="******"[WSRR_Manage].[F01_CERT].[UserAUZ]", strWhere); //2.新增勾选的权限 bool insertFlag = conn.Insert("[WSRR_Manage].[F01_CERT].[UserAUZ]", dt_LIST); conn.CommitTransaction(); //删除操作和插入操作都正确的情况下 if (deleteFlag && insertFlag) { dt_EditResult.Rows.Add(new object[] { true, strUserName + "权限更新成功!" }); } else { dt_EditResult.Rows.Add(new object[] { true, strUserName + "权限更新失败!" }); } ds_Return.Tables.Add(dt_EditResult); } } return ds_Return; }
/// <summary> /// 编辑系统属性值信息 /// </summary> /// <returns></returns> public bool Execute() { Dbconn conn = new Dbconn("MDM"); try { string strSystem_ID = m_request.Tables[0].Rows[0]["System_ID"].ToString(); string strSystem_Code = m_request.Tables[0].Rows[0]["System_Code"].ToString(); DataTable dt_Add = new DataTable(); dt_Add.Columns.Add("System_ID"); dt_Add.Columns.Add("System_Code"); dt_Add.Columns.Add("Property_ID"); dt_Add.Columns.Add("Property_Text"); for (int i = 2; i < m_request.Tables[0].Columns.Count; i++) { string strValue = m_request.Tables[0].Rows[0][i].ToString(); if (strValue != "") { dt_Add.Rows.Add(new object[] { strSystem_ID, strSystem_Code, m_request.Tables[0].Columns[i].ToString(),strValue}); } } ArrayList listTable = new ArrayList(); listTable.Add("MDM_System_Property_info"); conn.BeginTransaction(); conn.TableLock(listTable); string strWhere = " System_ID=" + strSystem_ID; conn.Delete("MDM_System_Property_info", strWhere); conn.InsertBYSQLBC("MDM_System_Property_info", dt_Add); conn.CommitTransaction(); return true; } catch { conn.RollbackTransaction(); throw; } }
/// <summary> /// 删除任务参数信息 /// </summary> /// <returns></returns> public bool Execute() { Dbconn conn = new Dbconn("MDM"); //创建连接类 try { if (m_request == null || m_request.Tables.Count == 0 || m_request.Tables[0].Rows.Count == 0) { return true; } string strParam_ID = m_request.Tables[0].Rows[0]["param_id"].ToString(); //获取参数Param_ID string strTASK_ID = m_request.Tables[0].Rows[0]["task_id"].ToString(); //获取参数Task_ID ArrayList listTable = new ArrayList(); listTable.Add("WS_SchedulingParam"); conn.BeginTransaction(); //开启事务 conn.TableLock(listTable); //锁表WS_SchedulingParam string strWhere = " Param_ID = '" + strParam_ID + "'"; //创建where语句 conn.Delete("WS_SchedulingParam", strWhere); //删除参数 //更新主表 DataTable dtScheduling = new DataTable(); dtScheduling.Columns.Add("UpdateTime"); DataRow drScheduling = dtScheduling.NewRow(); drScheduling["UpdateTime"] = DateTime.Now; dtScheduling.Rows.Add(drScheduling); string strSchedulingWhere = " 1=1 AND TASK_ID = '" + strTASK_ID + "'"; conn.Update("WS_Scheduling", dtScheduling, strSchedulingWhere); //更新数据 conn.CommitTransaction(); //提交事务 return true; } catch { conn.RollbackTransaction(); //回滚 throw; } }
/// <summary> /// EnvoTemplates信息的CRUD /// </summary> /// <returns></returns> public DataSet GetData() { DataSet ds_Return = new DataSet(); string strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); if (strXML == "") { throw new Exception("XML不能为空"); } string strEnvo_ID = m_request.Tables[0].Rows[0]["Envo_ID"].ToString(); DataSet ds = Common.Common.GetDSByExcelXML(strXML); DataTable dt_OPTYPE = ds.Tables["OPTYPE"]; Dbconn conn = new Dbconn("HZY_SDK"); if (dt_OPTYPE.Rows[0][0].ToString().ToUpper() == "GET") { if (strEnvo_ID == "") { throw new Exception("Envo_ID不能为空"); } ds_Return = conn.GetDataSet(@" SELECT Template_ID , Envo_ID , Template_Name , --replace(replace(REPLACE([Text],CHAR(9),' '),char(13),'ㄧ'),char(10),'ㄧ') Text , Text , ViewCount , UpdateTime , UpdateUser FROM dbo.EnvoTemplates WHERE Envo_ID=@param0 ORDER BY ViewCount DESC ", new string[] { strEnvo_ID }); } else if (dt_OPTYPE.Rows[0][0].ToString().ToUpper() == "UPDATE") { bool bResult = true; if (ds.Tables["list"].Rows.Count > 0) { string strTemplate_ID = ds.Tables["list"].Rows[0]["Template_ID"].ToString(); if (strTemplate_ID == "") { throw new Exception("Template_ID不能为空"); } ds.Tables["list"].Columns.Remove("Template_ID"); Commom_Ds.SetUpdateInfo(ds.Tables["list"], hzyMessage); conn.BeginTransaction(); if (CheckName(ds.Tables["list"], conn) == false) { conn.RollbackTransaction(); throw new Exception("模板名称已经存在"); } bResult = conn.Update("EnvoTemplates", ds.Tables["list"], "Template_ID='" + strTemplate_ID + "'"); conn.CommitTransaction(); } if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "修改成功" }); } else { dt_EditResult.Rows.Add(new object[] { false, "修改失败" }); } ds_Return.Tables.Add(dt_EditResult); } else if (dt_OPTYPE.Rows[0][0].ToString().ToUpper() == "INSERT") { bool bResult = true; if (ds.Tables["list"].Rows.Count > 0) { ds.Tables["list"].Columns.Remove("Template_ID"); Commom_Ds.SetUpdateInfo(ds.Tables["list"], hzyMessage); conn.BeginTransaction(); if (CheckName(ds.Tables["list"], conn) == false) { conn.RollbackTransaction(); throw new Exception("模板名称已经存在"); } bResult = conn.Insert("EnvoTemplates", ds.Tables["list"]); conn.CommitTransaction(); } if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "修改成功" }); } else { dt_EditResult.Rows.Add(new object[] { false, "修改失败" }); } ds_Return.Tables.Add(dt_EditResult); } else if (dt_OPTYPE.Rows[0][0].ToString().ToUpper() == "DELETE") { bool bResult = true; if (ds.Tables["list"].Rows.Count > 0) { string strTemplate_ID = ds.Tables["list"].Rows[0]["Template_ID"].ToString(); if (strTemplate_ID == "") { throw new Exception("Template_ID不能为空"); } conn.BeginTransaction(); bResult = conn.Delete("EnvoTemplates", "Template_ID='" + strTemplate_ID + "'"); conn.CommitTransaction(); } if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "修改成功" }); } else { dt_EditResult.Rows.Add(new object[] { false, "修改失败" }); } ds_Return.Tables.Add(dt_EditResult); } return ds_Return; }
/// <summary> /// 部署WS /// </summary> /// <returns></returns> public bool Execute() { Dbconn conn = new Dbconn("WSRR"); Dbconn connDeploy = new Dbconn("WSRR_Deploy"); try { if(m_request == null || m_request.Tables.Count==0 || m_request.Tables[0].Rows.Count == 0) { return true; } string strWS_ID = m_request.Tables[0].Rows[0]["WS_ID"].ToString(); string strSQL = ""; DataSet ds = conn.GetDataSet(@" SELECT * FROM dbo.WS WHERE WS_ID=@param0; SELECT * FROM dbo.WS_Param WHERE WS_ID=@param0",new string[]{strWS_ID}); if (ds.Tables.Count !=2 || ds.Tables[0].Rows.Count == 0) { throw new Exception("WS_ID的信息不正确!"); } string strENV = ConfigurationManager.AppSettings["WSRR_ENV"]; if (strENV.ToLower() == "prod") { ds.Tables[0].Rows[0]["WS_Host"] = ds.Tables[0].Rows[0]["WS_Host_Test"].ToString(); } else { ds.Tables[0].Rows[0]["WS_Host"] = ds.Tables[0].Rows[0]["WS_Host_Prod"].ToString(); } ArrayList tableList = new ArrayList(); tableList.Add("WS"); tableList.Add("WS_Param"); connDeploy.BeginTransaction(); connDeploy.TableLock(tableList); connDeploy.Delete("WS", "WS_ID='" + strWS_ID + "'"); connDeploy.Delete("WS_Param", "WS_ID='" + strWS_ID + "'"); connDeploy.Insert("WS", ds.Tables[0]); connDeploy.Insert("WS_Param", ds.Tables[1]); connDeploy.CommitTransaction(); return true; } catch { conn.RollbackTransaction(); throw; } }
public bool Execute() { string strEnv_ID = ""; string strEnv_SN = "HZY_CMT"; Dbconn conn_HZY_SBS = new Dbconn("F22GP_ForSalesPlan"); DataSet ds = conn_HZY_SBS.GetDataSet( @" SELECT --98 AS Env_ID , NULL AS VexSSONewID , b.userid AS App_UserName , RIGHT(sys.fn_VarBinToHexStr(hashbytes('MD5', CONVERT(VARCHAR(100), b.password))), 32) AS App_Password , b.password AS App_PasswordSrc , CASE WHEN b.dptype <> 0 THEN ISNULL(a.depotid,'') + '_' + d_name ELSE b.username END AS App_UserName_CN , GETDATE() Chang_Password_Time , 1 Checked , 'system' Check_User , GETDATE() Check_Time , GETDATE() Createtime , GETDATE() Updatetime, 0 as oprationFlag FROM j_user b LEFT JOIN j_depot a ON a.depotid = b.depotid "); Dbconn connMDM = new Dbconn("VexSSO"); try { ArrayList tableList = new ArrayList(); connMDM.BeginTransaction(); tableList.Add("MDM_System_User"); connMDM.TableLock(tableList); strEnv_ID = connMDM.GetDataTableFirstValue("SELECT [Env_ID] FROM [MDM_System_Env] WHERE Env_SN='" + strEnv_SN + "'").ToString(); DataTable dtMDM = connMDM.GetDataTable(@" SELECT [App_UserID] ,[Env_ID] ,[VexSSONewID] ,[App_UserName] ,[App_Password] ,[App_PasswordSrc] ,[App_UserName_CN] ,[Chang_Password_Time] ,[Checked] ,[Check_User] ,[Check_Time] ,[Createtime] ,[Updatetime] FROM [dbo].[MDM_System_User] WHERE Env_ID='" + strEnv_ID + @"' "); DataTable dtMDMUpdate = dtMDM.Clone(); DataTable dtMDMInsert = dtMDM.Clone(); DataTable dtMDMDelete = dtMDM.Clone(); for (int i = 0; i < dtMDM.Rows.Count; i++) { string strApp_UserName = dtMDM.Rows[i]["App_UserName"].ToString(); DataRow[] dr = ds.Tables[0].Select("App_UserName='******'"); if (dr.Length > 0) { dtMDM.Rows[i]["App_Password"] = dr[0]["App_Password"]; dtMDM.Rows[i]["App_PasswordSrc"] = dr[0]["App_PasswordSrc"]; dtMDM.Rows[i]["App_UserName_CN"] = dr[0]["App_UserName_CN"]; dtMDMUpdate.ImportRow(dtMDM.Rows[i]); dr[0]["oprationFlag"] = "1"; } else { dtMDMDelete.ImportRow(dtMDM.Rows[i]); } } DataRow[] drInsert = ds.Tables[0].Select("oprationFlag=0"); for (int i = 0; i < drInsert.Length; i++) { DataRow dr = dtMDMInsert.NewRow(); dr["Env_ID"] = strEnv_ID; dr["VexSSONewID"] = drInsert[i]["VexSSONewID"]; dr["App_UserName"] = drInsert[i]["App_UserName"]; dr["App_Password"] = drInsert[i]["App_Password"]; dr["App_PasswordSrc"] = drInsert[i]["App_PasswordSrc"]; dr["App_UserName_CN"] = drInsert[i]["App_UserName_CN"]; dr["Chang_Password_Time"] = drInsert[i]["Chang_Password_Time"]; dr["Checked"] = drInsert[i]["Checked"]; dr["Check_User"] = drInsert[i]["Check_User"]; dr["Check_Time"] = drInsert[i]["Check_Time"]; dr["Createtime"] = drInsert[i]["Createtime"]; dr["Updatetime"] = drInsert[i]["Updatetime"]; dtMDMInsert.Rows.Add(dr); } if (dtMDMDelete.Rows.Count > 0) { for (int i = 0; i < dtMDMDelete.Rows.Count; i++) { string strWhere = "App_UserID='" + dtMDMDelete.Rows[i]["App_UserID"] + "'"; connMDM.Delete("MDM_System_User", strWhere); } } if (dtMDMUpdate.Rows.Count > 0) { ArrayList listKey = new ArrayList(); listKey.Add("App_UserID"); connMDM.Update("MDM_System_User", dtMDMUpdate, listKey); } if (dtMDMInsert.Rows.Count > 0) { dtMDMUpdate.Columns.Remove("App_UserID"); connMDM.InsertBYSQLBC("MDM_System_User", dtMDMInsert); } connMDM.CommitTransaction(); return true; } catch { connMDM.RollbackTransaction(); throw; } }
public DataSet GetData() { Dbconn conn = new Dbconn("WSRR"); string strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); DataTable dt_EditResult = new dsCommon.dtResultDataTable(); DataSet dsRequest = new DataSet(); DataSet ds_Return = new DataSet(); dsRequest = Common.Common.GetDSByExcelXML(strXML); DataTable dt_OPTYPE = dsRequest.Tables["OPTYPE"]; DataTable dt_LIST = dsRequest.Tables["LIST"]; for (int i = 0; i < dt_OPTYPE.Rows.Count; i++) { //获取用户权限信息 if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "GET") { string strSQL = @" SELECT [MenuID] ,[MenuName] ,[MenuFatherID] ,[ActionURL] FROM [WSRR_Manage].[F01_CERT].[Menu] "; ds_Return = conn.GetDataSet(strSQL); //ds_Return.Tables[0].Rows.Add(new object[] { "0", "00_根目录", "-1", "-1" }); } //更新 else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "EDIT") { string strMenuID = dt_LIST.Rows[0]["MenuID"].ToString(); bool bResult = false; conn.LockTableList.Add("[WSRR_Manage].[F01_CERT].[Menu]");//锁定表 conn.BeginTransaction();//开始事务 dt_LIST.Columns.Remove("MenuID");//移除属性,标识符列(ID)不能更新 bResult = conn.Update("[WSRR_Manage].[F01_CERT].[Menu]", dt_LIST, "MenuID=" + strMenuID);//update语句 conn.CommitTransaction(); if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "修改成功" }); } else { dt_EditResult.Rows.Add(new object[] { false, "修改失败" }); } ds_Return.Tables.Add(dt_EditResult); } else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT") { string strMenuID = dt_LIST.Rows[0]["MenuID"].ToString(); bool bResult = false; conn.LockTableList.Add("[WSRR_Manage].[F01_CERT].[Menu]");//锁定表 conn.BeginTransaction();//开始事务 dt_LIST.Columns.Remove("MenuID");//移除属性,标识符列(ID)不能更新 bResult = conn.Insert("[WSRR_Manage].[F01_CERT].[Menu]", dt_LIST);//update语句 conn.CommitTransaction(); if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "修改成功" }); } else { dt_EditResult.Rows.Add(new object[] { false, "修改失败" }); } ds_Return.Tables.Add(dt_EditResult); } else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "DELETE") { string strMenuID = dt_LIST.Rows[0]["MenuID"].ToString(); bool bResult = false; conn.LockTableList.Add("[WSRR_Manage].[F01_CERT].[Menu]");//锁定表 conn.BeginTransaction();//开始事务 dt_LIST.Columns.Remove("MenuID");//移除属性,标识符列(ID)不能更新 bResult = conn.Delete("[WSRR_Manage].[F01_CERT].[Menu]" , "MenuID=" + strMenuID);//update语句 conn.CommitTransaction(); if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "修改成功" }); } else { dt_EditResult.Rows.Add(new object[] { false, "修改失败" }); } ds_Return.Tables.Add(dt_EditResult); } } return ds_Return; }
/// <summary> /// 获取MDM应用的数据 /// </summary> /// <returns></returns> public bool Execute() { DateTime dateStart = DateTime.Now; DateTime dateEnd = DateTime.Now; if (m_request != null && m_request.Tables.Count >0 && m_request.Tables[0].Rows.Count == 1) { if (m_request.Tables[0].Columns.Contains("dateStart")) { dateStart = Convert.ToDateTime(m_request.Tables[0].Rows[0]["dateStart"]).AddDays(-1); } if (m_request.Tables[0].Columns.Contains("dateEnd")) { dateEnd = Convert.ToDateTime(m_request.Tables[0].Rows[0]["dateEnd"]).AddDays(-1); } } DateTime currentDate = dateStart; Dbconn conn = new Dbconn("BI_CustomerFlow"); DataTable dtLog = new DataTable(); dtLog.Columns.Add("Execute_Date"); dtLog.Columns.Add("Result"); dtLog.Columns.Add("Message"); dtLog.Columns.Add("Exception"); while (currentDate <= dateEnd) { try { dtLog.Clear(); //获取FTP的数据 GetFTPData(currentDate); conn.LockTableList.Add("T_CustomerFlow"); conn.BeginTransaction(); conn.Delete("T_CustomerFlow", "Local_Date_and_Time between '" + currentDate.ToString("yyyy-MM-dd 00:00:00.000") + "' and '" + currentDate.ToString("yyyy-MM-dd 23:59:59.999") + "' "); //插入数据 conn.InsertBYSQLBC("T_CustomerFlow", m_dtFTP); dtLog.Rows.Add(new object[] { currentDate, true, "", "" }); conn.Insert("Log_GetFTPData", dtLog); //throw new Exception("test"); conn.CommitTransaction(); } catch (Exception ex) { conn.RollbackTransaction(); try { dtLog.Rows.Add(new object[] { currentDate, false, ex.Message, ex.ToString() }); conn.BeginTransaction(); conn.Insert("Log_GetFTPData", dtLog); conn.CommitTransaction(); } catch (Exception ex1) { } try { AMSendWS.MsgCenter cls = new AMSendWS.MsgCenter(); cls.SendMsg("AM", "BI客流数据获取", "马卫清", "信息部服务中心", "BI客流数据获取:执行日期:“" + currentDate.ToString("yyyy-MM-dd") + "”时发生错误:" + ex.ToString(), DateTime.Now.AddDays(-1).ToString()); } catch (Exception ex2) { } } currentDate = currentDate.AddDays(1); } return true; }
/// <summary> /// 编辑系统菜单权限 /// </summary> /// <returns></returns> public bool Execute() { Dbconn conn = new Dbconn("MDM"); try { string strAuthorization_ID = m_request.Tables[0].Rows[0]["Authorization_ID"].ToString(); ArrayList listTable = new ArrayList(); listTable.Add("MDM_System_Menu_AUZ"); conn.BeginTransaction(); conn.TableLock(listTable); string strWhere = " Authorization_ID=" + strAuthorization_ID; conn.Delete("MDM_System_Menu_AUZ", strWhere); ArrayList listMenu = new ArrayList(); for (int i = 0; i < m_request.Tables[0].Rows.Count; i++) { string strMenuId = m_request.Tables[0].Rows[i]["Menu_Id"].ToString(); if (!listMenu.Contains(strMenuId)) { listMenu.Add(strMenuId); } } // for (int i = 0; i < m_request.Tables[0].Rows.Count; i++) // { // string strMenuId = m_request.Tables[0].Rows[i]["Menu_Id"].ToString(); // while (true) // { // if (!listMenu.Contains(strMenuId)) // { // listMenu.Add(strMenuId); // DataTable dt = conn.GetDataTable(@" // SELECT DISTINCT Menu_Father_ID FROM dbo.MDM_System_Menu // WHERE Menu_Id = " + strMenuId + @" // AND Menu_Father_ID != 0", new string[0]); // if (dt.Rows.Count == 0) // { // break; // } // if (dt.Rows[0]["Menu_Father_ID"].ToString() == strMenuId) // { // break; // } // strMenuId = dt.Rows[0]["Menu_Father_ID"].ToString(); // } // else // { // break; // } // } // } for (int i = 0; i < listMenu.Count; i++) { DataTable dt = m_request.Tables[0].Clone(); DataRow dr = dt.NewRow(); dr["Menu_ID"] = listMenu[i]; dr["Authorization_ID"] = strAuthorization_ID; dr["HavaFlag"] = 1; dt.Rows.Add(dr); conn.Insert("MDM_System_Menu_AUZ", dt); } conn.CommitTransaction(); return true; } catch { conn.RollbackTransaction(); throw; } }
/// <summary> /// 新建或修改人员记录 /// </summary> /// <returns></returns> public DataSet SaveRows4(Dbconn conn, String strType) { DataSet ds_Return = new DataSet(); string strActor = m_request.Tables[0].Rows[0]["actor"].ToString(); string strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); DataSet dsXML = Common.Common.GetDSByExcelXML(strXML); DataTable dtOptypes = dsXML.Tables["OPTYPE"]; bool bResult = true; conn.BeginTransaction(); for (int i = 0; i < dtOptypes.Rows.Count; i++) { //如果包含rowindex,就循环移除 if (dsXML.Tables[i + 1].Columns.Contains("rowindex")) { dsXML.Tables[i + 1].Columns.Remove("rowindex"); } //如果子表解析出来的XML,类型有insert,做新增 if (dtOptypes.Rows[i][0].ToString().ToUpper() == "INSERT") { DataTable dt_List1 = dsXML.Tables[i + 1]; if (dt_List1.Rows[0]["c_oid"].ToString() == "") { String strOID = getUniqueKey(conn); if (strOID == "") { dt_EditResult.Rows.Add(new object[] { false, "获取 UNIQUE_KEY失败!" }); ds_Return.Tables.Add(dt_EditResult); return ds_Return; } dt_List1.Rows[0]["c_oid"] = strOID; dt_List1.Rows[0]["c_employeeid"] = strOID; } if (dt_List1.Rows[0]["c_oid_indiaccount"].ToString() == "") { String strOID = getUniqueKey(conn); if (strOID == "") { dt_EditResult.Rows.Add(new object[] { false, "获取 UNIQUE_KEY失败!" }); ds_Return.Tables.Add(dt_EditResult); return ds_Return; } dt_List1.Rows[0]["c_oid_indiaccount"] = strOID; } bResult = conn.Insert("B02_BILL.HR5_EMPLOYEE", dt_List1); } //如果类型包含,update,解析成表,做update else if (dtOptypes.Rows[i][0].ToString().ToUpper() == "UPDATE") { DataTable dt_List2 = dsXML.Tables[i + 1]; if (dt_List2.Rows[0]["c_oid_indiaccount"].ToString() == "") { String strOID = getUniqueKey(conn); if (strOID == "") { dt_EditResult.Rows.Add(new object[] { false, "获取 UNIQUE_KEY失败!" }); ds_Return.Tables.Add(dt_EditResult); return ds_Return; } dt_List2.Rows[0]["c_oid_indiaccount"] = strOID; } //添加更新主键,按照GUID更新 ArrayList ListKey = new ArrayList(); ListKey.Add("hr5_id"); bResult = conn.Update("B02_BILL.HR5_EMPLOYEE", dt_List2, ListKey); } //如果类型包含,DELETE,解析成表,做DELETE else if (dtOptypes.Rows[i][0].ToString().ToUpper() == "DELETE") { DataTable dt_List3 = dsXML.Tables[i + 1]; for (int k = 0; k < dt_List3.Rows.Count; k++) { string strID1 = dt_List3.Rows[k]["hr5_id"].ToString(); bResult = conn.Delete("B02_BILL.HR5_EMPLOYEE", "hr5_id=" + "'" + strID1 + "'"); } } } conn.CommitTransaction(); if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "保存成功!" }); } else { dt_EditResult.Rows.Add(new object[] { false, "保存失败!" }); } ds_Return.Tables.Add(dt_EditResult); return ds_Return; }
public bool Execute() { string strEnv_SN = "Present"; string strEnv_ID = ""; Dbconn conn_EHR = new Dbconn("EHR"); DataSet ds = conn_EHR.GetDataSet( @" SELECT NULL AS VexSSONewID , t2.C_PASSWORD [App_Password], t2.C_PASSWORD App_PasswordSrc, t1.C_CODE App_UserName, t1.C_NAME App_UserName_CN, GETDATE() Chang_Password_Time , 1 Checked , 'system' Check_User , GETDATE() Check_Time , GETDATE() Createtime , GETDATE() Updatetime , 0 AS oprationFlag FROM ehr.TB_INF_EMPLOYEE t1 LEFT JOIN ehr.TB_SYS_USER t2 ON t1.C_OID = t2.C_EMPLOYEEID WHERE t1.C_EMPLOYEESTATUS!=3 "); Dbconn connMDM = new Dbconn("VexSSO"); try { ArrayList tableList = new ArrayList(); connMDM.BeginTransaction(); tableList.Add("MDM_System_User"); connMDM.TableLock(tableList); strEnv_ID = connMDM.GetDataTableFirstValue("SELECT [Env_ID] FROM [MDM_System_Env] WHERE Env_SN='" + strEnv_SN + "'").ToString(); DataTable dtMDM = connMDM.GetDataTable(@" SELECT [App_UserID] ,[Env_ID] ,[VexSSONewID] ,[App_UserName] ,[App_Password] ,[App_PasswordSrc] ,[App_UserName_CN] ,[Chang_Password_Time] ,[Checked] ,[Check_User] ,[Check_Time] ,[Createtime] ,[Updatetime] FROM [dbo].[MDM_System_User] WHERE Env_ID='" + strEnv_ID + @"'"); DataTable dtMDMUpdate = dtMDM.Clone(); DataTable dtMDMInsert = dtMDM.Clone(); DataTable dtMDMDelete = dtMDM.Clone(); for (int i = 0; i < dtMDM.Rows.Count; i++) { string strApp_UserName = dtMDM.Rows[i]["App_UserName"].ToString(); DataRow[] dr = ds.Tables[0].Select("App_UserName='******'"); if (dr.Length > 0) { dtMDM.Rows[i]["App_Password"] = dr[0]["App_Password"]; dtMDM.Rows[i]["App_PasswordSrc"] = dr[0]["App_PasswordSrc"]; dtMDM.Rows[i]["App_UserName_CN"] = dr[0]["App_UserName_CN"]; dtMDMUpdate.ImportRow(dtMDM.Rows[i]); dr[0]["oprationFlag"] = "1"; } else { dtMDMDelete.ImportRow(dtMDM.Rows[i]); } } DataRow[] drInsert = ds.Tables[0].Select("oprationFlag=0"); for (int i = 0; i < drInsert.Length; i++) { DataRow dr = dtMDMInsert.NewRow(); dr["Env_ID"] = strEnv_ID; dr["VexSSONewID"] = drInsert[i]["VexSSONewID"]; dr["App_UserName"] = drInsert[i]["App_UserName"]; dr["App_Password"] = drInsert[i]["App_Password"]; dr["App_PasswordSrc"] = drInsert[i]["App_PasswordSrc"]; dr["App_UserName_CN"] = drInsert[i]["App_UserName_CN"]; dr["Chang_Password_Time"] = drInsert[i]["Chang_Password_Time"]; dr["Checked"] = drInsert[i]["Checked"]; dr["Check_User"] = drInsert[i]["Check_User"]; dr["Check_Time"] = drInsert[i]["Check_Time"]; dr["Createtime"] = drInsert[i]["Createtime"]; dr["Updatetime"] = drInsert[i]["Updatetime"]; dtMDMInsert.Rows.Add(dr); } if (dtMDMDelete.Rows.Count > 0) { for (int i = 0; i < dtMDMDelete.Rows.Count; i++) { string strWhere = "App_UserID='" + dtMDMDelete.Rows[i]["App_UserID"] + "'"; connMDM.Delete("MDM_System_User", strWhere); } } if (dtMDMUpdate.Rows.Count > 0) { ArrayList listKey = new ArrayList(); listKey.Add("App_UserID"); connMDM.Update("MDM_System_User", dtMDMUpdate, listKey); } if (dtMDMInsert.Rows.Count > 0) { dtMDMUpdate.Columns.Remove("App_UserID"); connMDM.InsertBYSQLBC("MDM_System_User", dtMDMInsert); } connMDM.CommitTransaction(); return true; } catch { connMDM.RollbackTransaction(); throw; } }
public bool Execute() { string strEnv_ID = ""; string strEnv_SN = "EP_PLMFZ"; Dbconn conn_PLM_AS = new Dbconn("PLM_AS"); DataSet ds = conn_PLM_AS.GetDataSet( @" SELECT --44 as Env_ID, null as VexSSONewID, username as App_UserName, RIGHT(sys.fn_VarBinToHexStr(hashbytes('MD5', convert(vARCHAR(100),PASSWORD))), 32) as App_Password, PASSWORD as App_PasswordSrc, userNameC as App_UserName_CN, getdate() Chang_Password_Time , 1 Checked , 'system' Check_User , getdate() Check_Time , getdate() Createtime , getdate() Updatetime, 0 as oprationFlag FROM PLMAss.dbo.USERINFO u "); Dbconn connMDM = new Dbconn("VexSSO"); try { ArrayList tableList = new ArrayList(); connMDM.BeginTransaction(); tableList.Add("MDM_System_User"); connMDM.TableLock(tableList); strEnv_ID = connMDM.GetDataTableFirstValue("SELECT [Env_ID] FROM [MDM_System_Env] WHERE Env_SN='" + strEnv_SN + "'").ToString(); DataTable dtMDM = connMDM.GetDataTable(@" SELECT [App_UserID] ,[Env_ID] ,[VexSSONewID] ,[App_UserName] ,[App_Password] ,[App_PasswordSrc] ,[App_UserName_CN] ,[Chang_Password_Time] ,[Checked] ,[Check_User] ,[Check_Time] ,[Createtime] ,[Updatetime] FROM [dbo].[MDM_System_User] WHERE Env_ID='" + strEnv_ID + @"' "); DataTable dtMDMUpdate = dtMDM.Clone(); DataTable dtMDMInsert = dtMDM.Clone(); DataTable dtMDMDelete = dtMDM.Clone(); for (int i = 0; i < dtMDM.Rows.Count; i++) { string strApp_UserName = dtMDM.Rows[i]["App_UserName"].ToString(); DataRow[] dr = ds.Tables[0].Select("App_UserName='******'"); if (dr.Length > 0) { dtMDM.Rows[i]["App_Password"] = dr[0]["App_Password"]; dtMDM.Rows[i]["App_PasswordSrc"] = dr[0]["App_PasswordSrc"]; dtMDM.Rows[i]["App_UserName_CN"] = dr[0]["App_UserName_CN"]; dtMDMUpdate.ImportRow(dtMDM.Rows[i]); dr[0]["oprationFlag"] = "1"; } else { dtMDMDelete.ImportRow(dtMDM.Rows[i]); } } DataRow[] drInsert = ds.Tables[0].Select("oprationFlag=0"); for (int i = 0; i < drInsert.Length; i++) { DataRow dr = dtMDMInsert.NewRow(); dr["Env_ID"] = strEnv_ID; dr["VexSSONewID"] = drInsert[i]["VexSSONewID"]; dr["App_UserName"] = drInsert[i]["App_UserName"]; dr["App_Password"] = drInsert[i]["App_Password"]; dr["App_PasswordSrc"] = drInsert[i]["App_PasswordSrc"]; dr["App_UserName_CN"] = drInsert[i]["App_UserName_CN"]; dr["Chang_Password_Time"] = drInsert[i]["Chang_Password_Time"]; dr["Checked"] = drInsert[i]["Checked"]; dr["Check_User"] = drInsert[i]["Check_User"]; dr["Check_Time"] = drInsert[i]["Check_Time"]; dr["Createtime"] = drInsert[i]["Createtime"]; dr["Updatetime"] = drInsert[i]["Updatetime"]; dtMDMInsert.Rows.Add(dr); } if (dtMDMDelete.Rows.Count > 0) { for (int i = 0; i < dtMDMDelete.Rows.Count; i++) { string strWhere = "App_UserID='" + dtMDMDelete.Rows[i]["App_UserID"] + "'"; connMDM.Delete("MDM_System_User", strWhere); } } if (dtMDMUpdate.Rows.Count > 0) { ArrayList listKey = new ArrayList(); listKey.Add("App_UserID"); connMDM.Update("MDM_System_User", dtMDMUpdate, listKey); } if (dtMDMInsert.Rows.Count > 0) { dtMDMUpdate.Columns.Remove("App_UserID"); connMDM.InsertBYSQLBC("MDM_System_User", dtMDMInsert); } connMDM.CommitTransaction(); return true; } catch { connMDM.RollbackTransaction(); throw; } }
/// <summary> /// 新建或修改日历记录 /// </summary> /// <returns></returns> public DataSet SetCalendar(Dbconn conn, String strType) { DataSet ds_Return = new DataSet(); string strActor = m_request.Tables[0].Rows[0]["actor"].ToString(); string strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); //获取日历主数据 DataSet dsXML = Common.Common.GetDSByExcelXML(strXML); String strOPType = dsXML.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper(); String strID = dsXML.Tables["LIST"].Rows[0]["dail_id"].ToString(); DataTable dt_List = dsXML.Tables["LIST"]; if (strID == "") { throw new Exception("数据异常,缺少主键,请联系管理员!"); } bool bResult = false; if (strType == "New") //新建 { conn.BeginTransaction(); bResult = conn.Insert("[B01_MDM].[DAIL_DailyManage]", dt_List); conn.CommitTransaction(); } else if (strType == "Upd") //修改 { conn.BeginTransaction(); bResult = conn.Update("[B01_MDM].[DAIL_DailyManage]", dt_List, "dail_id='" + strID + "'"); conn.CommitTransaction(); } else if (strType == "Del") //删除 { conn.BeginTransaction(); bResult = conn.Delete("[B01_MDM].[DAIL_DailyManage]", "dail_id='" + strID + "'"); conn.CommitTransaction(); } if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "保存成功!" }); } else { dt_EditResult.Rows.Add(new object[] { false, "保存失败!" }); } ds_Return.Tables.Add(dt_EditResult); return ds_Return; }
public DataSet GetData() { Dbconn conn = new Dbconn("WSRR"); string strWhere = string.Empty; string strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); DataTable dt_EditResult = new dsCommon.dtResultDataTable(); DataSet dsRequest = new DataSet(); DataSet ds_Return = new DataSet(); dsRequest = Common.Common.GetDSByExcelXML(strXML); DataTable dt_OPTYPE = dsRequest.Tables["OPTYPE"]; DataTable dt_LIST = dsRequest.Tables["LIST"]; for (int i = 0; i < dt_OPTYPE.Rows.Count; i++) { //获取权限信息 if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "GET") { string strSQL = @" SELECT [AUZID] ,[AUZName] FROM [WSRR_Manage].[F01_CERT].[AUZ]"; ds_Return = conn.GetDataSetForPageList(strSQL,m_hzyPageInfo); } //新增环境的权限名称 else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT") { //String Env_ID = dt_LIST.Rows[0]["Env_ID"].ToString(); String strAuzName = dt_LIST.Rows[0]["AuzName"].ToString(); string strsql = @" SELECT COUNT(1) AS Cnt FROM [WSRR_Manage].[F01_CERT].[AUZ] WHERE Authorization_Name='" + strAuzName + "'"; DataTable dt = conn.GetDataTable(strsql); if (int.Parse(dt.Rows[0][0].ToString()) > 0) { dt_EditResult.Rows.Add(new object[] { false, "权限:" + strAuzName + "已存在!" }); } else { //dt_LIST.Rows[0]["AuzID"] = Guid.NewGuid().ToString(); conn.BeginTransaction(); bool flag = conn.Insert(" [WSRR_Manage].[F01_CERT].[AUZ]", dt_LIST); conn.CommitTransaction(); if (flag) { dt_EditResult.Rows.Add(new object[] { true, "权限:" + strAuzName + "添加成功!" }); } else { dt_EditResult.Rows.Add(new object[] { true, "权限:" + strAuzName + "添加失败!" }); } } ds_Return.Tables.Add(dt_EditResult); } //修改权限的菜单树 else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "EDIT") { String strAuZID = dt_LIST.Rows[0]["AuzID"].ToString(); strWhere = " AuzID=" + strAuZID; dt_LIST.Columns.Remove("AuzID");//移除属性,标识符列(ID)不能更新 conn.LockTableList.Add("[WSRR_Manage].[F01_CERT].[AUZ]"); conn.BeginTransaction(); bool flag = conn.Update("[WSRR_Manage].[F01_CERT].[AUZ]", dt_LIST, strWhere); conn.CommitTransaction(); if (flag) { dt_EditResult.Rows.Add(new object[] { true, "权限修改成功!" }); } else { dt_EditResult.Rows.Add(new object[] { false, "权限修改失败!" }); } ds_Return.Tables.Add(dt_EditResult); } //删除权限 else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "DELETE") { String strAuZID = dt_LIST.Rows[0]["AuzID"].ToString(); strWhere = " AuzID=" + strAuZID; conn.BeginTransaction(); bool flag = conn.Delete("[WSRR_Manage].[F01_CERT].[AUZ]", strWhere); conn.CommitTransaction(); if (flag) { dt_EditResult.Rows.Add(new object[] { true, "权限删除成功!" }); } else { dt_EditResult.Rows.Add(new object[] { false, "权限删除失败!" }); } ds_Return.Tables.Add(dt_EditResult); } } return ds_Return; }
/// <summary> /// 新建或修改记录 /// </summary> /// <returns></returns> public DataSet SaveRows(Dbconn conn, String strType) { DataSet ds_Return = new DataSet(); string strActor = m_request.Tables[0].Rows[0]["actor"].ToString(); string strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); DataSet dsXML = Common.Common.GetDSByExcelXML(strXML); DataTable dtOptypes = dsXML.Tables["OPTYPE"]; bool bResult = true; conn.BeginTransaction(); for (int i = 0; i < dtOptypes.Rows.Count; i++) { //如果包含rowindex,就循环移除 if (dsXML.Tables[i + 1].Columns.Contains("rowindex")) { dsXML.Tables[i + 1].Columns.Remove("rowindex"); } //如果子表解析出来的XML,类型有insert,做新增 if (dtOptypes.Rows[i][0].ToString().ToUpper() == "INSERT") { DataTable dt_List1 = dsXML.Tables[i + 1]; //如果包含bg3_lmdt,就循环移除 if (dt_List1.Columns.Contains("ct1_lmdt")) { dt_List1.Columns.Remove("ct1_lmdt"); } bResult = conn.Insert("M01_CONF.CT0_CSYTAB", dt_List1); } //如果类型包含,update,解析成表,做update else if (dtOptypes.Rows[i][0].ToString().ToUpper() == "UPDATE") { DataTable dt_List2 = dsXML.Tables[i + 1]; //添加更新主键,按照GUID更新 ArrayList ListKey = new ArrayList(); ListKey.Add("ct1_id"); bResult = conn.Update("M01_CONF.CT0_CSYTAB", dt_List2, ListKey); } //如果类型包含,DELETE,解析成表,做DELETE else if (dtOptypes.Rows[i][0].ToString().ToUpper() == "DELETE") { DataTable dt_List3 = dsXML.Tables[i + 1]; for (int k = 0; k < dt_List3.Rows.Count; k++) { string strID1 = dt_List3.Rows[k]["ct1_id"].ToString(); bResult = conn.Delete("M01_CONF.CT0_CSYTAB", "ct1_id=" + "'" + strID1 + "'"); } } } conn.CommitTransaction(); if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "保存成功!" }); } else { dt_EditResult.Rows.Add(new object[] { false, "保存失败!" }); } ds_Return.Tables.Add(dt_EditResult); return ds_Return; }
public bool Execute() { string strEnv_ID = ""; string strEnv_SN = "HZY_SCM"; Dbconn conn_PLM_AS = new Dbconn("ERP_PROD"); DataSet ds = conn_PLM_AS.GetDataSet( @" SELECT NULL AS VexSSONewID , IDSUNO AS App_UserName , RIGHT(sys.fn_VarBinToHexStr(HASHBYTES('MD5', CONVERT(VARCHAR(100), '123456a'))), 32) AS App_PasswordSrc , RIGHT(sys.fn_VarBinToHexStr(HASHBYTES('MD5', CONVERT(VARCHAR(100), '123456a'))), 32) AS App_Password , IDSUNM AS App_UserName_CN , GETDATE() Chang_Password_Time , 1 Checked , 'system' Check_User , GETDATE() Check_Time , GETDATE() Createtime , GETDATE() Updatetime , 0 AS oprationFlag FROM CIDMAS WHERE IDCONO = 100 AND IDSTAT = 20"); Dbconn connMDM = new Dbconn("VexSSO"); try { ArrayList tableList = new ArrayList(); connMDM.BeginTransaction(); tableList.Add("MDM_System_User"); connMDM.TableLock(tableList); strEnv_ID = connMDM.GetDataTableFirstValue("SELECT [Env_ID] FROM [MDM_System_Env] WHERE Env_SN='" + strEnv_SN + "'").ToString(); DataTable dtMDM = connMDM.GetDataTable(@" SELECT [App_UserID] ,[Env_ID] ,[VexSSONewID] ,[App_UserName] ,[App_Password] ,[App_PasswordSrc] ,[App_UserName_CN] ,[Chang_Password_Time] ,[Checked] ,[Check_User] ,[Check_Time] ,[Createtime] ,[Updatetime] FROM [dbo].[MDM_System_User] WHERE Env_ID='" + strEnv_ID + @"' "); DataTable dtMDMUpdate = dtMDM.Clone(); DataTable dtMDMInsert = dtMDM.Clone(); DataTable dtMDMDelete = dtMDM.Clone(); for (int i = 0; i < dtMDM.Rows.Count; i++) { string strApp_UserName = dtMDM.Rows[i]["App_UserName"].ToString(); DataRow[] dr = ds.Tables[0].Select("App_UserName='******'"); if (dr.Length > 0) { //只修改供应商名称不修改帐号密码 //dtMDM.Rows[i]["App_Password"] = dr[0]["App_Password"]; //dtMDM.Rows[i]["App_PasswordSrc"] = dr[0]["App_PasswordSrc"]; dtMDM.Rows[i]["App_UserName_CN"] = dr[0]["App_UserName_CN"]; dtMDMUpdate.ImportRow(dtMDM.Rows[i]); dr[0]["oprationFlag"] = "1"; } else { dtMDMDelete.ImportRow(dtMDM.Rows[i]); } } DataRow[] drInsert = ds.Tables[0].Select("oprationFlag=0"); for (int i = 0; i < drInsert.Length; i++) { DataRow dr = dtMDMInsert.NewRow(); dr["Env_ID"] = strEnv_ID; dr["VexSSONewID"] = drInsert[i]["VexSSONewID"]; dr["App_UserName"] = drInsert[i]["App_UserName"]; dr["App_Password"] = drInsert[i]["App_Password"]; dr["App_PasswordSrc"] = drInsert[i]["App_PasswordSrc"]; dr["App_UserName_CN"] = drInsert[i]["App_UserName_CN"]; dr["Chang_Password_Time"] = drInsert[i]["Chang_Password_Time"]; dr["Checked"] = drInsert[i]["Checked"]; dr["Check_User"] = drInsert[i]["Check_User"]; dr["Check_Time"] = drInsert[i]["Check_Time"]; dr["Createtime"] = drInsert[i]["Createtime"]; dr["Updatetime"] = drInsert[i]["Updatetime"]; dtMDMInsert.Rows.Add(dr); } if (dtMDMDelete.Rows.Count > 0) { for (int i = 0; i < dtMDMDelete.Rows.Count; i++) { string strWhere = "App_UserID='" + dtMDMDelete.Rows[i]["App_UserID"] + "'"; connMDM.Delete("MDM_System_User", strWhere); } } if (dtMDMUpdate.Rows.Count > 0) { ArrayList listKey = new ArrayList(); listKey.Add("App_UserID"); connMDM.Update("MDM_System_User", dtMDMUpdate, listKey); } if (dtMDMInsert.Rows.Count > 0) { dtMDMUpdate.Columns.Remove("App_UserID"); connMDM.InsertBYSQLBC("MDM_System_User", dtMDMInsert); } connMDM.CommitTransaction(); return true; } catch { connMDM.RollbackTransaction(); throw; } }
/// <summary> /// 新建或修改部门记录 /// </summary> /// <returns></returns> public DataSet SetDeptInfo(Dbconn conn, String strType) { String strCode = ""; DataSet ds_Return = new DataSet(); string strActor = m_request.Tables[0].Rows[0]["actor"].ToString(); string strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); DataSet dsXML = Common.Common.GetDSByExcelXML(strXML); String strOPType = dsXML.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper(); String strID = dsXML.Tables["LIST"].Rows[0]["oz1_id"].ToString(); DataTable dt_List = dsXML.Tables["LIST"]; if (strID == "") { throw new Exception("数据异常,缺少主键,请联系管理员!"); } bool bResult = false; conn.BeginTransaction(); if (strType == "NewDept") //新建部门 { bResult = conn.Insert("[F01_CERT].[OZ1_Organization] ", dt_List); } else if (strType == "UpdDept") //修改部门 { bResult = conn.Update("[F01_CERT].[OZ1_Organization] ", dt_List, "oz1_id='" + strID + "'"); } else if (strType == "UpdDept1") //修改部门 { //添加更新主键,按照GUID更新 ArrayList ListKey = new ArrayList(); ListKey.Add("oz1_id"); bResult = conn.Update("F01_CERT.OZ1_Organization", dt_List, ListKey); } else if (strType == "DelDept") //删除部门 { for (int k = 0; k < dt_List.Rows.Count; k++) { string strID1 = dt_List.Rows[k]["oz1_id"].ToString(); bResult = conn.Delete("F01_CERT.OZ1_Organization", "oz1_id=" + "'" + strID1 + "'"); } } conn.CommitTransaction(); if (bResult) { dt_EditResult.Rows.Add(new object[] { true, strCode }); } else { dt_EditResult.Rows.Add(new object[] { false, "保存失败!" }); } ds_Return.Tables.Add(dt_EditResult); return ds_Return; }
/// <summary> /// 获取WSRR的基本信息 /// </summary> /// <returns></returns> public DataSet GetData() { DataSet ds_Return = new DataSet(); string strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); if (strXML == "") { throw new Exception("XML不能为空"); } DataSet ds = Common.Common.GetDSByExcelXML(strXML); DataTable dt_OPTYPE = ds.Tables["OPTYPE"]; Dbconn conn = new Dbconn("HZY_SDK"); if (dt_OPTYPE.Rows[0][0].ToString().ToUpper() == "GET") { ds_Return = conn.GetDataSet(@" SELECT t1.Envo_ID , t1.Envo_Name , COUNT(t2.ViewCount) AS ViewCount FROM dbo.Envo t1 LEFT JOIN dbo.EnvoTemplates t2 ON t1.Envo_ID = t2.Envo_ID GROUP BY t1.Envo_ID , t1.Envo_Name ORDER BY ViewCount DESC "); } else if (dt_OPTYPE.Rows[0][0].ToString().ToUpper() == "UPDATE") { bool bResult = true; if (ds.Tables["list"].Rows.Count > 0) { string strEnvo_ID = ds.Tables["list"].Rows[0]["Envo_ID"].ToString(); if (strEnvo_ID == "") { throw new Exception("Envo_ID不能为空"); } ds.Tables["list"].Columns.Remove("Envo_ID"); Commom_Ds.SetUpdateInfo(ds.Tables["list"], hzyMessage); conn.BeginTransaction(); if (CheckName(ds.Tables["list"], conn) == false) { conn.RollbackTransaction(); throw new Exception("名称不能重复!"); } bResult = conn.Update("Envo", ds.Tables["list"], "Envo_ID='" + strEnvo_ID + "'"); conn.CommitTransaction(); } if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "修改成功" }); } else { dt_EditResult.Rows.Add(new object[] { false, "修改失败" }); } ds_Return.Tables.Add(dt_EditResult); } else if (dt_OPTYPE.Rows[0][0].ToString().ToUpper() == "INSERT") { bool bResult = true; if (ds.Tables["list"].Rows.Count > 0) { if (ds.Tables["list"].Columns.Contains("Envo_ID")) { ds.Tables["list"].Columns.Remove("Envo_ID"); } Commom_Ds.SetUpdateInfo(ds.Tables["list"], hzyMessage); conn.BeginTransaction(); if (CheckName(ds.Tables["list"], conn) == false) { conn.RollbackTransaction(); throw new Exception("名称不能重复!"); } bResult = conn.Insert("Envo", ds.Tables["list"]); conn.CommitTransaction(); } if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "添加成功" }); } else { dt_EditResult.Rows.Add(new object[] { false, "添加成功" }); } ds_Return.Tables.Add(dt_EditResult); } else if (dt_OPTYPE.Rows[0][0].ToString().ToUpper() == "DELETE") { bool bResult = true; if (ds.Tables["list"].Rows.Count > 0) { string strEnvo_ID = ds.Tables["list"].Rows[0]["Envo_ID"].ToString(); if (strEnvo_ID == "") { throw new Exception("Envo_ID不能为空"); } conn.BeginTransaction(); if (CheckName(ds.Tables["list"], conn) == false) { conn.RollbackTransaction(); throw new Exception("名称不能重复!"); } bResult = conn.Delete("Envo", "Envo_ID='" + strEnvo_ID + "'"); conn.CommitTransaction(); } if (bResult) { dt_EditResult.Rows.Add(new object[] { true, "添加成功" }); } else { dt_EditResult.Rows.Add(new object[] { false, "添加成功" }); } ds_Return.Tables.Add(dt_EditResult); } return ds_Return; }