Пример #1
0
        /// <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 strTASK_ID = m_request.Tables[0].Rows[0]["task_id"].ToString();  //获取参数Task_ID
                string strParam_Name = m_request.Tables[0].Rows[0]["param_name"].ToString();  //获取参数Param_Name
                string strParam_ID = m_request.Tables[0].Rows[0]["param_id"].ToString();  //获取参数Param_ID

                ArrayList listTable = new ArrayList();
                listTable.Add("WS_SchedulingParam");
                conn.BeginTransaction();    //开启事务
                conn.TableLock(listTable);  //锁表WS_SchedulingParam
                string strWhere = " 1=1 ";

                if (!string.IsNullOrEmpty(strTASK_ID))
                {
                    strWhere += " AND TASK_ID = '" + strTASK_ID + "'";
                }

                if (!string.IsNullOrEmpty(strParam_Name))
                {
                    strWhere += " AND Param_Name = '" + strParam_Name + "'";
                }

                //创建DataTable
                DataTable dt_Add = new DataTable();
                dt_Add.Columns.Add("Param_ID");
                dt_Add.Columns.Add("TASK_ID");
                dt_Add.Columns.Add("Param_Name");
                dt_Add.Columns.Add("Param_Value");

                DataRow dr = dt_Add.NewRow();

                for (int i = 0; i < dt_Add.Columns.Count; i++)
                {
                    dr[i] = m_request.Tables[0].Rows[0][dt_Add.Columns[i].ColumnName].ToString();   //将m_request中的数据逐个赋值
                }
                dt_Add.Rows.Add(dr);



                if (strParam_ID == "") //如果为空,说明是复制数据
                {
                    //判断是否已经存在
                    int nRow = conn.GetDataTableRowCount("SELECT * FROM WS_SchedulingParam WHERE " + strWhere, new string[0]);
                    if (nRow > 0)
                    {
                        throw new Exception(strParam_Name + "已经存在,不能更新");
                    }
                    strParam_ID = Guid.NewGuid().ToString();    //创建GUID

                    dt_Add.Rows[0]["Param_ID"] = strParam_ID;
                    conn.Insert("WS_SchedulingParam", dt_Add);  //插入数据
                }
                else
                {
                    dt_Add.Columns.Remove("Param_ID");  //删除Param_ID,更新不需要
                    dt_Add.Columns.Remove("Task_ID");  //删除Task_ID,更新不需要
                    strWhere = " 1=1 AND Param_ID = '" + strParam_ID + "'"; //重新设置where语句
                    conn.Update("WS_SchedulingParam", dt_Add, 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;
            }
        }
        public bool Execute()
        {

            Dbconn conn = new Dbconn("AM");
            Dbconn connMDM = new Dbconn("VexSSO");

            conn.BeginTransaction();
            connMDM.BeginTransaction();


            try
            {
                DataSet ds = conn.GetDataSet(
                @"    
               DECLARE @maxid  AS BINARY(10);
 
                 SELECT t1.[__$start_lsn] AS LogID,
                        t1.[__$seqval] ,
                        t1.[__$operation] OprationType ,
                        t1.CN_ID ,
                        t1.CN_LOGIN ,
                        t1.CN_USER_NAME ,
                        t1.CN_PASSWORD ,
                        Convert(int,t1.CN_ISDELETE) as CN_ISDELETE ,
                        Convert(int,t1.CN_DISABLED) as CN_DISABLED
						INTO #tmp
                FROM   [cdc].[dbo_TN_SYS_EM_USER_CT] t1 ,
                        [M01_CONF].[S01_Sync] t2
                WHERE  1=1
				AND  t1.[__$start_lsn]> ISNULL(t2.MaxStart_lsn,0x00023FE600000FBF0004)
				AND t2.SyncName='MDM数据获取'
				AND t1.[__$update_mask] !=0x00004000
				AND  t1.[__$update_mask] !=0x00800000 
				AND t1.[__$update_mask] !=0x00804000  
                
                
				SELECT @maxid=MAX(LogID)
				FROM #tmp
                
                if(@maxid is not null)
                begin
				UPDATE [M01_CONF].[S01_Sync] SET MaxStart_lsn=@maxid
				WHERE SyncName='MDM数据获取'
                end

                select * from #tmp
                order by  [LogID] ASC,[__$seqval] ASC ,[OprationType] ASC


	            ");
                string strSQL = "";

                Byte[] strMaxID = null;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    strMaxID = (Byte[])ds.Tables[0].Rows[i]["LogID"];
                    string strCN_LOGIN = ds.Tables[0].Rows[i]["CN_LOGIN"].ToString();
                    string strCN_PASSWORD = ds.Tables[0].Rows[i]["CN_PASSWORD"].ToString();
                    string strCN_ISDELETE = ds.Tables[0].Rows[i]["CN_ISDELETE"].ToString();

                    string strOprationType = ds.Tables[0].Rows[i]["OprationType"].ToString();

                    if (strOprationType == "1" || strOprationType == "4") //添加或者更新
                    {
                        if (connMDM.GetDataTableRowCount("select 1 as a from MDM_Employees where SSO_UserName=@param0", new string[] { strCN_LOGIN }) == 0)
                        {
                            strSQL = @"INSERT INTO MDM_Employees (Name,SSO_UserName,SSO_Password,Leave_Flag,IsActived)
                                    Values(@param0,@param1,@param2,@param3,'1')";
                        }
                        else
                        {
                            strSQL = @"update MDM_Employees 
                                        SET SSO_Password=@param2,Leave_Flag=@param3
                                        WHERE SSO_UserName=@param1
                                    ";
                        }
                        connMDM.ExcuteQuerryByTran(strSQL, new string[] { strCN_LOGIN, strCN_LOGIN, strCN_PASSWORD, strCN_ISDELETE });

                    }
                    else if (strOprationType == "2" || strOprationType == "3") //删除
                    {
                        strSQL = @"update MDM_Employees 
                                        SET Leave_Flag=@param0
                                    WHERE SSO_UserName=@param1";
                        connMDM.ExcuteQuerryByTran(strSQL, new string[] { "1", strCN_LOGIN });

                    }
                }

                if (strMaxID != null)
                {
                    strSQL = "UPDATE M01_CONF.S01_Sync SET MaxStart_lsn=@param0,LastSyncTime=getdate() WHERE SyncName='MDM数据获取'";
                    conn.ExcuteQuerryByTran(strSQL, new object[] { strMaxID });
                }
                conn.CommitTransaction();
                connMDM.CommitTransaction();
                return true;
            }
            catch
            {
                connMDM.RollbackTransaction();
                conn.RollbackTransaction();
                throw;
            }
        }
Пример #3
0
        public static void UpdateFullText(string pstrWSID, Dbconn pconn)
        {
            string strSQL = @"
                        DECLARE @cols NVARCHAR(MAX)
                        SET @cols = ''
                        SELECT  @cols = @cols + 'convert(varchar(1000),isnull(' + name
                                + ',''''),21)+'' ''+'
                        FROM    syscolumns
                        WHERE   ( id = ( SELECT id
                                         FROM   sysobjects
                                         WHERE  ( name = 'WS0E_WSExtDoc' )
                                       ) )

                        SELECT  @cols as A

                ";

            string strInfoColumns = pconn.GetDataTableFirstValue(strSQL).ToString();
            strSQL = strInfoColumns.Substring(0, strInfoColumns.Length - 1);
            strSQL = "SELECT " + strSQL + "  FROM [B01_MDM].[WS0E_WSExtDoc] WHERE WSID=@Param0";
            string strValue = pconn.GetDataTableFirstValue(strSQL, new string[] { pstrWSID }).ToString();

            strSQL = @"
                        DECLARE @cols NVARCHAR(MAX)
                        SET @cols = ''
                        SELECT  @cols = @cols + 'convert(varchar(1000),isnull(' + name
                                + ',''''),21)+'' ''+'
                        FROM    syscolumns
                        WHERE   ( id = ( SELECT id
                                         FROM   sysobjects
                                         WHERE  ( name = 'WS0M_WSMethodDoc' )
                                       ) )

                        SELECT  @cols as A

                ";


            string strFunctionColumns = pconn.GetDataTableFirstValue(strSQL).ToString();

            strSQL = "SELECT " + strFunctionColumns.Substring(0, strFunctionColumns.Length - 1) + " AS A  FROM [B01_MDM].[WS0M_WSMethodDoc] WHERE WSID=@Param0";


            DataTable dt = pconn.GetDataTable(strSQL, new string[] { pstrWSID });
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strValue += " " + dt.Rows[i]["A"].ToString();
            }

            strSQL = " SELECT 1 AS A FROM [B05_RPT].[WS0V_WSMethodView] WHERE WSID=@Param0";
            if (pconn.GetDataTableRowCount(strSQL, new string[] { pstrWSID }) == 1)
            {
                pconn.ExcuteQuerryByTran("UPDATE [B05_RPT].[WS0V_WSMethodView] SET fulltext=@Param0 WHERE WSID=@PARAM1", new string[] { strValue, pstrWSID });
            }
            else
            {
                pconn.ExcuteQuerryByTran("INSERT INTO [B05_RPT].[WS0V_WSMethodView](fulltext,WSID)Values(@Param0,@PARAM1)", new string[] { strValue, pstrWSID });
            }
        }
Пример #4
0
        private bool CheckName(DataTable dt, Dbconn conn)
        {
            bool bResult = true;

            if (dt.Columns.Contains("Template_Name"))
            {
                string strTemplate_ID = "";
                string strEnvo_ID = "";
                if (dt.Columns.Contains("Template_ID"))
                {
                    strTemplate_ID = dt.Rows[0]["Template_ID"].ToString();
                }

                if (dt.Columns.Contains("Envo_ID"))
                {
                    strEnvo_ID = dt.Rows[0]["Envo_ID"].ToString();
                }
                string strEnvo_Name = dt.Rows[0]["Template_Name"].ToString();

                if (conn.GetDataTableRowCount("select Template_ID from [EnvoTemplates] where Template_ID!=@param0 and [Template_Name]=@param1 and Envo_id=@param2", new string[3] { strTemplate_ID, strEnvo_Name,strEnvo_ID }) > 0)
                {
                    bResult = false;
                }
            }


            return bResult;
        }
Пример #5
0
        /// <summary>
        /// 对审核步骤进行审核
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                //DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();


                Dbconn conn = new Dbconn("HZY_ITSM");

                string strXML = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();

                DataSet ds = Common.Common.GetDSByExcelXML(strXML);

                string strCheck_ID = "";
                string strCheck_User = "";
                string strCheck_Result = "";
                string strCheck_RemarK = "";
                string strKey_Value = "";
                string strKeyColumn = "";
                string strRequestTableName = "";

                strCheck_ID = ds.Tables["LIST"].Rows[0]["ID"].ToString();
                if (strCheck_ID == "")
                {
                    ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "1:您的请求有误!" });

                    return ds_Return;

                }

                DataTable dt = conn.GetDataTable(@"
                            SELECT  t1.ID ,
                                    t1.Key_ID ,
                                    t1.Seq_Index ,
                                    t1.Seq_Name ,
                                    t1.Check_User ,
                                    t1.Check_Type,
                                    t1.Check_Type_Table_Name,
                                    t1.Check_Type_Key_Column,
                                    t1.Check_Date ,
                                    t1.Check_Result ,
                                    t1.Remark ,
                                    t2.Table_Templete
                            FROM    dbo.Check_List t1
                                    LEFT JOIN dbo.check_Table_Type t2 ON t1.Check_Type = t2.Check_Type
                            WHERE   t1.id = @Param0

                    ", new string[1] { strCheck_ID });

                if (dt.Rows.Count == 0)
                {
                    ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "2:您的请求有误!" });

                    return ds_Return;
                }

                strKey_Value = dt.Rows[0]["Key_ID"].ToString();
                strKeyColumn = dt.Rows[0]["Check_Type_Key_Column"].ToString();
                strRequestTableName = dt.Rows[0]["Check_Type_Table_Name"].ToString();

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                {

                    ITSM_Server_Request_EditByXML itsm_SR = new ITSM_Server_Request_EditByXML();

                    strXML = @"<ROOT><OPTYPE>GET</OPTYPE>
                                        <LIST>
                                        <ROW>    
                                        <condition>" + strKeyColumn + @"='" + strKey_Value + @"'</condition>
                                        </ROW>
                                        </LIST>
                                        </ROOT>";
                    DataSet ds_ITSMSR_Request = Common.Common.GetRequestDataSet(new string[1] { "XML" }, new string[1] { strXML});
                    itsm_SR.Request = ds_ITSMSR_Request;
                    DataSet ds_ITSMSR_Response = itsm_SR.GetData();
                    if (ds_ITSMSR_Response.Tables.Count == 0 || ds_ITSMSR_Response.Tables[0].Rows.Count == 0)
                    {
                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "3:获取原始单据有误!" });
                        return ds_Return;
                    }

                    string strTableTemplete = dt.Rows[0]["Table_Templete"].ToString();
                    for (int i = 0; i < ds_ITSMSR_Response.Tables[0].Columns.Count; i++)
                    {
                        string strTemp = ds_ITSMSR_Response.Tables[0].Rows[0][i].ToString().Replace("\n", "<p>");
                        if(strTemp == "")
                        {
                            strTemp = "&nbsp;";
                        }
                        strTableTemplete = strTableTemplete.Replace("[@@" + ds_ITSMSR_Response.Tables[0].Columns[i].ColumnName + "]", strTemp);
                    }
                    dt.Rows[0]["Table_Templete"] = Microsoft.JScript.GlobalObject.escape(strTableTemplete);

                    dt.Columns.Add("timestamps");
                    dt.Rows[0]["timestamps"] = ds_ITSMSR_Response.Tables[0].Rows[0]["timestamps"];

                    ds_Return.Tables.Add(dt.Copy());
                   

                }
                else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                {

                    strCheck_ID = ds.Tables["LIST"].Rows[0]["ID"].ToString();
                    strCheck_User = ds.Tables["LIST"].Rows[0]["Check_User"].ToString();
                    strCheck_Result = ds.Tables["LIST"].Rows[0]["Check_Result"].ToString();
                    strCheck_RemarK = ds.Tables["LIST"].Rows[0]["Check_Remark"].ToString();

                    DataTable dtCheckList = conn.GetDataTable("SELECT * FROM Check_List WHERE ID='" + strCheck_ID + "'");

                    if (dt.Rows.Count == 0)
                    {
                        throw new Exception("该审核单已不存在,请联系管理员");
                    }

                    int nSeq_ID = Convert.ToInt32(dt.Rows[0]["Seq_Index"]);

                    //判断是否已经进行后续的审批
                    string strSql = "SELECT '1' as A from Check_List WHERE Check_Type='" + dt.Rows[0]["Check_Type"].ToString() + @"'
                                AND Key_ID='" + dt.Rows[0]["Key_ID"].ToString() + @"'
                                AND Check_Result is not null
                                AND Seq_Index>" + nSeq_ID.ToString() + "";

                    if (conn.GetDataTableRowCount(strSql) > 0)
                    {
                        throw new Exception("下一道的流程已经审批,本次审批不能再做修改!");
                    }


                    dtCheckList.Rows[0]["Check_User"] = strCheck_User;
                    dtCheckList.Rows[0]["Check_Date"] = DateTime.Now;
                    dtCheckList.Rows[0]["Check_Result"] = strCheck_Result;
                    dtCheckList.Rows[0]["Remark"] = strCheck_RemarK;
                    dtCheckList.Rows[0]["updateTime"] = DateTime.Now;

                    ArrayList listTable = new ArrayList();
                    listTable.Add("Check_List");

                    try
                    {
                        conn.BeginTransaction();
                        conn.TableLock(listTable);

                        //判断数据是否为最新数据
                        strSql = "SELECT timestamps+0 as timestamps from " + strRequestTableName
                            + " WHERE Deleted=0 AND " + strKeyColumn + "='" + strKey_Value + "'";

                        string strTimestamps = conn.GetDataTableFirstValue(strSql).ToString();
                        if (strTimestamps != ds.Tables["LIST"].Rows[0]["timestamps"].ToString())
                        {
                            throw new Exception("原申请单数据已被修改,请刷新后重试!");
                        }
                        //dt.Columns.Remove("timestamps");
                        conn.Update("Check_List", dtCheckList, "ID='" + strCheck_ID + "'");


                        string[] strColumn = new string[3];
                        string[] strValue = new string[3];
                        strColumn[0] = "Check_Type";
                        strColumn[1] = "Seq_Name";
                        strColumn[2] = "Key_ID";

                        strValue[0] = dt.Rows[0]["Check_Type"].ToString();
                        strValue[1] = dt.Rows[0]["Seq_Name"].ToString();
                        strValue[2] = dt.Rows[0]["Key_ID"].ToString();

                        DataSet requestDs = Common.Common.GetRequestDataSet(strColumn, strValue);

                        ITSM_Check_List_Edit checkListEdit = new ITSM_Check_List_Edit();
                        checkListEdit.Conn = conn;
                        checkListEdit.ListAMSendList = listAMSendList;
                        checkListEdit.Request = requestDs;
                        checkListEdit.Execute();

                        if (strCheck_Result != "同意")
                        {
                            //更新原表的状态为已驳回
                            strSql = "UPDATE " + strRequestTableName + " SET State='已驳回' WHERE Deleted=0 AND " + strKeyColumn + "='" + strKey_Value + "'";
                            conn.ExcuteQuerryByTran(strSql);
                        }
                        else
                        {
                            //判断是否有已驳回的状态
                            strSql = "SELECT '1' as A from Check_List WHERE Check_Type='" + dt.Rows[0]["Check_Type"].ToString() + @"'
                                AND Key_ID='" + strKey_Value + @"'
                                AND (Seq_index = " + nSeq_ID.ToString() + @" 
                                AND Check_Result='已驳回')";

                            //没有已驳回的记录
                            if (conn.GetDataTableRowCount(strSql) == 0)
                            {
                                //判断是否还有后续的流程
                                strSql = "SELECT '1' as A from Check_List WHERE Check_Type='" + dt.Rows[0]["Check_Type"].ToString() + @"'
                                AND Key_ID='" + strKey_Value + @"'
                                AND (Seq_Index>" + nSeq_ID.ToString() + @"
                                OR (Seq_Index=" + nSeq_ID.ToString() + @"
                                AND Must_Check=1
                                AND Check_Date IS NULL
                                ))";

                                if (conn.GetDataTableRowCount(strSql) == 0)
                                {
                                    //更新原表的状态为已审核
                                    strSql = "UPDATE " + strRequestTableName + " SET State='已审核' WHERE Deleted=0 AND " + strKeyColumn + "='" + strKey_Value + "'";
                                    conn.ExcuteQuerryByTran(strSql);

                                    ITSM_Common.SendAMMessage("", "马卫清", "有服务器申请表需要操作", "您有有服务器申请表需要操作,请进入EXCEL操作");
                                }
                                else
                                {
                                    //更新原表的状态为审核中
                                    strSql = "UPDATE " + strRequestTableName + " SET State='审核中' WHERE Deleted=0 AND " + strKeyColumn + "='" + strKey_Value + "'";
                                    conn.ExcuteQuerryByTran(strSql);
                                }
                            }
                        }

                        conn.CommitTransaction();

                        for (int i = 0; i < listAMSendList.Count; i++)
                        {
                            string[] strList = (string[])(listAMSendList[i]);
                            ITSM_Common.SendAMMessage(strList[0], strList[1], strList[2]);
                        }

                    }
                    catch (Exception)
                    {
                        conn.RollbackTransaction();
                        throw;
                    }

                    ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
        /// <summary>
        /// 编辑成本中心信息
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            Dbconn conn = new Dbconn("MDM_Master2");
            Dbconn MDM_Market2_conn = new Dbconn("MDM_Market2");

            try
            {
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                string strXML = "";

                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();

                if (strXML == "")
                {
                    throw new Exception("提交的XML为空!");
                }


                DataSet dsXML = Common.Common.GetDSByExcelXML(strXML);
                DataTable dt_OPTYPE = dsXML.Tables["OPTYPE"];
                string strMDM_Class = "0025";

                conn.LockTableList.Add("MDM_0025_B");
                conn.LockTableList.Add("MDM_0025_E");
                conn.BeginTransaction();

                //获取所有属性
                MDM2_GetEntityPropertyList cls = new MDM2_GetEntityPropertyList();
                cls.hzyMessage = this.hzyMessage;
                cls.MainEntity = strMDM_Class;

                DataTable dtPorperty = cls.GetData().Tables[0];

                for (int i = 0; i < dt_OPTYPE.Rows.Count; i++)
                {
                    DataTable dt_List = dsXML.Tables[Common.Common.GetListTableName(i)];


                    string CheckEnvName = dt_List.Rows[0]["系统编号"].ToString();
                    string CheckBodyId = dt_List.Rows[0]["Body_ID"].ToString();
                    if (CheckBodyId == "")
                    {
                        if (MDM_Market2_conn.GetDataTableRowCount("SELECT * FROM MKT_0025 WHERE 系统编号='" + CheckEnvName + "'") > 0)
                        {
                            throw new Exception("系统编号:" + CheckEnvName + "已存在!");
                        }
                    }
                    else
                    {
                        if (MDM_Market2_conn.GetDataTableRowCount("SELECT * FROM MKT_0025 WHERE Body_ID !='" + CheckBodyId + "' AND 系统编号='" + CheckEnvName + "'") > 0)
                        {
                            throw new Exception("系统编号:" + CheckEnvName + "已存在!");
                        }
                    }

                    if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "UPDATE"
                       || dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT"
                       )
                    {

                        //插入BODY表

                        for (int j = 0; j < dt_List.Rows.Count; j++)
                        {
                            string strBody_id = "";

                            strBody_id = dt_List.Rows[j]["body_ID"].ToString();

                            if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT")
                            {
                                MDM2_EntityCreatedBodyID_Edit clsBody = new MDM2_EntityCreatedBodyID_Edit();
                                clsBody.Conn = conn;
                                clsBody.hzyMessage = hzyMessage;
                                clsBody.MDMClass = strMDM_Class;
                                clsBody.Execute();
                                strBody_id = clsBody.BodyID;

                                if (strBody_id == "")
                                {
                                    throw new Exception("BodyID创建失败!");
                                }
                            }
                            else if (strBody_id == "")
                            {
                                throw new Exception("传入的参数有误,如果反复出现,请重新登录!");
                            }

                            for (int k = 0; k < dt_List.Columns.Count; k++)
                            {
                                string strColumnName = dt_List.Columns[k].ColumnName;
                                if (dtPorperty.Select("Property_Name='" + strColumnName + "'").Length == 0)
                                {
                                    continue;
                                }

                                MDM2_EntityPropertyValue_Edit clsProperty = new MDM2_EntityPropertyValue_Edit();
                                clsProperty.Conn = conn;
                                clsProperty.hzyMessage = hzyMessage;
                                clsProperty.MDMClass = strMDM_Class;
                                clsProperty.ExpressionName = "CN";
                                clsProperty.PropertyName = strColumnName;
                                clsProperty.BodyID = strBody_id;
                                clsProperty.PropertyValue = dt_List.Rows[j][k].ToString();
                                if (clsProperty.Execute() == false)
                                {
                                    throw new Exception("修改失败," + clsProperty.Message);
                                }
                            }
                        }
                    }
                    else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "DELETE")
                    {
                        for (int rowIndex = 0; rowIndex < dt_List.Rows.Count; rowIndex++)
                        {
                            string strBody_ID = dt_List.Rows[i]["body_id"].ToString();
                            MDM2_EntityDeleteBodyID_Edit clsDelete = new MDM2_EntityDeleteBodyID_Edit();
                            clsDelete.Conn = conn;
                            clsDelete.hzyMessage = hzyMessage;

                            clsDelete.MDMClass = strMDM_Class;
                            clsDelete.BodyID = strBody_ID;

                            if (clsDelete.Execute() == false)
                            {
                                throw new Exception("删除失败。");
                            }
                        }

                    }
                    else
                    {
                        throw new Exception("提交了错误的操作类型");
                    }
                }

                dt_EditResult.Rows.Add(new object[] { true, "操作成功" });
                ds_Return.Tables.Add(dt_EditResult);
                conn.CommitTransaction();

                return ds_Return;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;

            }


        }
Пример #7
0
        /// <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 strWS_ID = m_request.Tables[0].Rows[0]["WS_ID"].ToString();
                string strWS_Name = m_request.Tables[0].Rows[0]["WS_Name"].ToString();

                ArrayList listTable = new ArrayList();
                listTable.Add("WS");
                conn.BeginTransaction();
                conn.TableLock(listTable);
                string strWhere = " WS_Name='" + strWS_Name + "'";

                if (strWS_ID != "")
                {
                    strWhere += " AND WS_ID != '"+strWS_ID+"'";
                }

                //判断是否已经存在
                int nRow = conn.GetDataTableRowCount("SELECT 'A' as A FROM WS WHERE " + strWhere, new string[0]);
                if (nRow > 0)
                {
                    throw new Exception(strWS_Name + "已经存在,不能更新");
                }

                DSWSRR.WSDataTable dt_Add = new DSWSRR.WSDataTable();
                dt_Add.PrimaryKey = null;
                dt_Add.Columns["WS_ID"].DataType = typeof(string);

                string strWS_IDSrc = "";
                if (m_request.Tables[0].Columns.Contains("WS_IDSrc"))
                {
                    strWS_IDSrc = m_request.Tables[0].Rows[0]["WS_IDSrc"].ToString();
                }

                DataRow dr = dt_Add.NewRow();
                
                for (int i = 0; i < dt_Add.Columns.Count-4; i++)
                {
                    if (dt_Add.Columns[i].ColumnName == "WS_Host")
                    {
                        string strENV = ConfigurationManager.AppSettings["WSRR_ENV"];
                        if (strENV.ToLower() == "prod")
                        {
                            dr[i] = m_request.Tables[0].Rows[0]["WS_Host_Prod"].ToString();
                        }
                        else
                        {
                            dr[i] = m_request.Tables[0].Rows[0]["WS_Host_Test"].ToString();

                        }
                    }
                    else
                    {
                        dr[i] = m_request.Tables[0].Rows[0][dt_Add.Columns[i].ColumnName].ToString();
                    }
                }
                dt_Add.Rows.Add(dr);



                if (strWS_ID == "") //如果为空,说明是复制数据
                {
                    dt_Add.Columns.Remove("Update_User");
                    dt_Add.Columns.Remove("Update_Time");

                    strWS_ID = conn.GetDataTableFirstValue("SELECT NEWID() as ID").ToString();

                    dt_Add.Rows[0]["WS_ID"] = strWS_ID;
                    conn.Insert("WS", dt_Add);


                    //添加参数表的信息
                    DataTable dtParam = conn.GetDataTable("SELECT * FROM WS_Param WHERE WS_ID='" + strWS_IDSrc + "'");
                    
                    
                    //更新WSID
                    for (int i = 0; i < dtParam.Rows.Count; i++)
                    {
                        dtParam.Rows[i]["WS_ID"] = strWS_ID;
                    }

                    dtParam.Columns.Remove("Param_ID");
                    conn.Insert("WS_Param", dtParam);

                }
                else
                {
                    dt_Add.Columns.Remove("Create_User");
                    dt_Add.Columns.Remove("Create_Time");
                    dt_Add.Rows[0]["Update_Time"] = DateTime.Now;

                    strWhere = " WS_ID = '" + strWS_ID + "'";
                    conn.Update("WS", dt_Add, strWhere);
                }
                
                conn.CommitTransaction();
                return true;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;
            }



        }
Пример #8
0
        /// <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;
                }

                ArrayList listTable = new ArrayList();
                listTable.Add("WS_Param");
                conn.BeginTransaction();
                conn.TableLock(listTable);

                for (int row = 0; row < m_request.Tables[0].Rows.Count; row++)
                {
                    string strParam_ID = m_request.Tables[0].Rows[row]["Param_ID"].ToString();
                    string strParam_Index = m_request.Tables[0].Rows[row]["Param_Index"].ToString();
                    string strWS_ID = m_request.Tables[0].Rows[row]["WS_ID"].ToString();
                   
                    string strWhere = " Param_Index='" + strParam_Index + "' AND WS_ID='" + strWS_ID + "'";

                    if (strParam_ID != "")
                    {
                        strWhere += " AND Param_ID != '" + strParam_ID + "'";
                    }

                    //判断是否已经存在
                    int nRow = conn.GetDataTableRowCount("SELECT 'A' as A FROM WS_Param WHERE " + strWhere, new string[0]);
                    if (nRow > 0)
                    {
                        throw new Exception("序号" + strParam_Index + "已经存在,不能更新");
                    }

                    DSWSRR.WS_ParamDataTable dt_Add = new DSWSRR.WS_ParamDataTable();
                    dt_Add.PrimaryKey = null;
                    dt_Add.Columns.Remove("Param_ID");

                    DataRow dr = dt_Add.NewRow();

                    for (int i = 0; i < dt_Add.Columns.Count - 1; i++)
                    {
                        dr[i] = m_request.Tables[0].Rows[row][dt_Add.Columns[i].ColumnName].ToString();

                    }
                    dt_Add.Rows.Add(dr);

                    if (strParam_ID == "")
                    {

                        conn.Insert("WS_Param", dt_Add);
                    }
                    else
                    {
                        strWhere = "  Param_ID = '" + strParam_ID + "'";

                        conn.Update("WS_Param", dt_Add, strWhere);
                    }
                }
                
                
                conn.CommitTransaction();
                return true;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;
            }



        }
Пример #9
0
        private bool CheckName(DataTable dt, Dbconn conn)
        {
            bool bResult = true;

            if (dt.Columns.Contains("Envo_Name"))
            {
                string strEnvo_ID = "";
                if (dt.Columns.Contains("Envo_ID"))
                {
                    strEnvo_ID = dt.Rows[0]["Envo_ID"].ToString();
                }
                string strEnvo_Name = dt.Rows[0]["Envo_Name"].ToString();

                if (conn.GetDataTableRowCount("select Envo_ID from [Envo] where Envo_ID!=@param0 and [Envo_Name]=@param1", new string[2] { strEnvo_ID, strEnvo_Name }) > 0)
                {
                    bResult = false;
                }
            }


            return bResult;
        }