www.pudn.com > WorkflowDesigner.rar > DO_IMPORT.cs, change:2008-03-26,size:46586b


using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Data; 
using System.Xml; 
using DataAccess; 
namespace Bussiness 
{ 
    public class DO_IMPORT 
    { 
        public DO_IMPORT() 
        {  
         
        } 
        private bool updateModel = false; 
        private XmlDocument _doc = new XmlDocument(); 
         
        public void UpdatePackageInfo(XmlDocument doc) 
        { 
            this._doc = doc; 
            //得到包名 
            XmlNode packageNode = doc.SelectSingleNode("/package"); 
            //得到包的ID 
            String packageId = packageNode.Attributes["id"].Value; 
            //得到包名 
            String packageName = packageNode.Attributes["name"].Value; 
 
            IDataAccess da = DataAccessFactory.CreateDataAccess(); 
            da.Open(); 
            IDbTransaction tran = da.BeginTransaction(); 
            try 
            { 
                DataSet ds = this.GetPackageById(packageId, da); 
                if (ds.Tables != null && ds.Tables.Count > 0) 
                { 
                    if (ds.Tables[0].Rows.Count == 0) 
                    { 
                        //新增包 
                        updateModel = false; 
                        AddPackageInfo(packageId, packageName, da); 
                    } 
                    else 
                    { 
                        //更改旧的包 
                        updateModel = true; 
                    } 
 
                } 
                if (!updateModel) 
                { 
                    //在一个事务内做完 
                    //创建角色 角色用户信息 
                    UpdateRoleInfo(packageId, da); 
                    //创建应用 
                    UpdateAppInfo(packageId, da); 
                    //创建参数 
                    this.UpdateParamInfo(packageId, da); 
                    //创建流程 
                    UpdateProcessInfo(packageId, da); 
                } 
                else 
                { 
 
                    //更新所有的删除(删除的为先删除流程中的内容再删除参数 饮用 角色) 
                    //新增所有元素(角色,应用 参数 流程) 
                    //更新所有更新的信息(角色,应用 参数 流程) 
 
                } 
 
                tran.Commit(); 
            } 
            catch (Exception err) 
            { 
                tran.Rollback(); 
                throw err; 
            } 
            finally 
            { 
                da.Close(); 
            } 
        } 
 
        #region 更新包信息 
         
        #endregion 
 
        #region 更新角色用户信息 
        /// <summary> 
        /// 更新角色信息 
        /// </summary> 
        /// <param name="package"></param> 
        private void UpdateRoleInfo(String PackageId, IDataAccess da) 
        { 
            foreach (XmlElement roleNode in this._doc.SelectNodes("/package/roles/role")) 
            { 
                String roleName = roleNode.Attributes["name"].Value; 
                String roleType = roleNode.Attributes["type"].Value; 
                String roleContent = roleNode.Attributes["checkcontent"].Value; 
                int RoleId = CreateRole(PackageId, roleName,  roleType,  roleContent, da); 
                UpdateRoleUserInfo( RoleId,  roleNode,da); 
            } 
        } 
 
        
        private void UpdateRoleUserInfo(int RoleId, XmlElement roleNode,IDataAccess da) 
        { 
            foreach (XmlElement roleuserNode in roleNode.SelectNodes("users/user")) 
            {  
                String UserId = roleuserNode.Attributes["id"].Value;                  
                String Rank = roleuserNode.Attributes["rank"].Value; 
                CreateRoleUserInfo( UserId, Rank, RoleId, da); 
            } 
        } 
 
        
        #endregion 
 
        #region 通用函数 
        private int GetMaxId(String Table, IDataAccess da) 
        { 
            //String Sql = "select bde_" + Table + ".nextval from dual"; 
            String Sql = "select @@IDENTITY"; 
            Object ob = da.ExecuteScalar(Sql); 
            if (ob == null || ob.ToString() == "") 
            { 
                return 0; 
            } 
            else 
            { 
                return Convert.ToInt32(ob); 
            } 
        } 
 
        private DataSet GetPackageById(String PackageId, IDataAccess da) 
        { 
            String Sql = "select * from wfpackage where id = '" + PackageId + "'"; 
            //IDataAccess da = DataAccessFactory.CreateDataAccess(); 
            return da.ExecuteDataset(Sql); 
        } 
        private int GetMaxPackageVersionByPackageName(String PackageName, IDataAccess da) 
        { 
            String Sql = "select max(version) as max_version from wfpackage where name = '" + PackageName + "'"; 
            Object ob = da.ExecuteScalar(Sql); 
            if (ob == null || ob.ToString() == "") 
            { 
                return 0; 
            } 
            else 
            { 
                return Convert.ToInt32(ob); 
            } 
        } 
 
        private int GetRoleIDByName(String packageId,String RoleName, IDataAccess da) 
        { 
            String Sql = "select Id from wfrole a where a.ref_package_id='" + packageId + "' and a.name='" + RoleName + "'"; 
            Object ob = da.ExecuteScalar(Sql); 
            if (ob == null || ob.ToString() == "") 
            { 
                return -1; 
            } 
            else 
            { 
                return Convert.ToInt32(ob); 
            } 
        } 
        private int GetParamIDByName(String packageId,String ParaName, IDataAccess da) 
        { 
            String Sql = "select Id from wfparam a where a.ref_WFpackage_id='" + packageId + "' and a.name='" + ParaName + "'"; 
            Object ob = da.ExecuteScalar(Sql); 
            if (ob == null || ob.ToString() == "") 
            { 
                return -1; 
            } 
            else 
            { 
                return Convert.ToInt32(ob); 
            } 
        } 
 
        private int GetActivityIDByName(String ProcessId,String ActivName, IDataAccess da) 
        { 
            String Sql = "select Id from wfactivity a where a.ref_process_id=" + ProcessId + " and a.name='" + ActivName + "'"; 
            Object ob = da.ExecuteScalar(Sql); 
            if (ob == null || ob.ToString() == "") 
            { 
                return -1; 
            } 
            else 
            { 
                return Convert.ToInt32(ob); 
            } 
        } 
   
         private int GetApplicationIDByName(String packageId,String AppName, IDataAccess da) 
        { 
            String Sql = "select Id from Wfapplication a where a.ref_package_id='" + packageId + "' and a.name='" + AppName + "'"; 
            Object ob = da.ExecuteScalar(Sql); 
            if (ob == null || ob.ToString() == "") 
            { 
                return -1; 
            } 
            else 
            { 
                return Convert.ToInt32(ob); 
            } 
        } 
 
        
        #endregion 
 
        #region 更新应用信息 
 
        
        
        private void UpdateAppInfo(String PackageId, IDataAccess da) 
        { 
            foreach (XmlElement AppNode in this._doc.SelectNodes("/package/applications/application")) 
            { 
                String appName = AppNode.Attributes["name"].Value; 
                String appType = AppNode.Attributes["type"].Value; 
                String appParameter = AppNode.Attributes["parameter"].Value; 
                String appGroupId = AppNode.Attributes["groupid"].Value; 
                String appPath = AppNode.Attributes["path"].Value; 
                int AppId = AddAppInfo(PackageId,appName, appType, appParameter, appGroupId, appPath, da); 
                
            } 
        } 
        #endregion 
 
        #region 更新参数 
 
 
         
        
        private void UpdateParamInfo(String PackageId, IDataAccess da) 
        { 
            foreach (XmlElement paramNode in this._doc.SelectNodes("/package/params/param")) 
            { 
                String paramName = paramNode.Attributes["name"].Value; 
                String paramType = paramNode.Attributes["paramtype"].Value; 
                String paramValue = paramNode.Attributes["value"].Value; 
                String paramRemark = paramNode.Attributes["remark"].Value; 
                int ParamId = AddParamInfo(PackageId, paramName, paramType, paramValue, paramRemark, da); 
                 
                 
            } 
        } 
          
        #endregion 
 
        #region 更新流程信息 
        private void UpdateProcessInfo(String packageId, IDataAccess da) 
        { 
            foreach (XmlElement processNode in this._doc.SelectNodes("/package/processes/process")) 
            { 
               // String NAME 
              //      ,String  WORK_DAY,String WARNING_TIME, String REF_ROLE_ID 
 
                String NAME = processNode.Attributes["name"].Value; 
                String WORK_DAY = processNode.Attributes["WORK_DAY"].Value; 
                String WARNING_TIME = processNode.Attributes["WARNING_TIME"].Value; 
                String REF_ROLE_ID = processNode.Attributes["role"].Value; 
                int ProcessId = this.AddProcessInfo( packageId,  NAME,  WORK_DAY, WARNING_TIME,  REF_ROLE_ID, da); 
 
                //创建节点 
                UpdateActiveInfo(packageId,ProcessId, processNode, da); 
                //创建流程线 
                UpdateTransInfo(packageId,ProcessId, processNode, da); 
            } 
        } 
         
        private void UpdateTransInfo(String PackageId, int ProcessId, XmlElement processNode, IDataAccess da) 
        { 
            foreach (XmlElement transitionNode in processNode.SelectNodes("activities/activity/transitions/transition")) 
            { 
                String endActivity = transitionNode.Attributes["forward"].Value; 
 
                String transitionName; 
                if (transitionNode.Attributes["name"] == null) 
                { 
                    transitionName = endActivity; 
                } 
                else 
                { 
                    transitionName = transitionNode.Attributes["name"].Value; 
                } 
                String endActivityId = ""; 
                int value = this.GetActivityIDByName(ProcessId.ToString(), endActivity, da); 
                if (value != -1) 
                    endActivityId = value.ToString(); 
 
                String startActivity = transitionNode.ParentNode.ParentNode.Attributes["name"].Value; 
 
                String type = "0"; 
                if (transitionNode.Attributes["type"] != null) 
                { 
                    type = transitionNode.Attributes["type"].Value; 
                } 
 
                String startActivityId = ""; 
                value = this.GetActivityIDByName(ProcessId.ToString(), startActivity, da); 
                if (value != -1) 
                    startActivityId = value.ToString(); 
 
                String X = transitionNode.Attributes["x"].Value; 
                String Y =transitionNode.Attributes["y"].Value; 
                int transID = this.AddWFTRANSITIONInfo(transitionName, type, Y, X, ProcessId.ToString(), startActivityId, endActivityId, "", da); 
                UpdateTCInfo(PackageId, ProcessId, transID, transitionNode, da); 
                 
 
            } 
        } 
        private void UpdateTCInfo(String PackageId, int ProcessId, int transID, XmlElement transitionNode, IDataAccess da) 
        { 
            foreach (XmlElement tcNode in transitionNode.SelectNodes("transconditions/transcondition")) 
            { 
                String param = tcNode.Attributes["param"].Value; 
                String paramId = ""; 
                int valueTemp = this.GetParamIDByName(PackageId, param, da); 
                if (valueTemp != -1) 
                    paramId = valueTemp.ToString(); 
 
                String oper = tcNode.Attributes["oper"].Value; 
                String value = tcNode.Attributes["value"].Value; 
                this.AddWFTRANSITIONCONDITIONInfo(oper, value, transID.ToString(), paramId, da); 
                 
            } 
        } 
 
        private void UpdateActiveInfo(String PackageId,int ProcessId,XmlElement processNode, IDataAccess da) 
        { 
            foreach (XmlElement activNode in processNode.SelectNodes("activities/activity")) 
            { 
                String Type =activNode.Attributes["type"].Value; 
                String NAME = activNode.Attributes["name"].Value; 
                String X = activNode.Attributes["x"].Value; 
                String Y = activNode.Attributes["y"].Value; 
                switch (Type) 
                {  
                    case "0": 
                    case "1": 
                        //开始//结束 
                        this.AddWFACTIVITYInfo(NAME, Type, "0", "ReceiveStrategyAnd", "DispatchStrategyRandom", "", "", "", "", "", X, Y, ProcessId.ToString(), "", "", "", da); 
                        break; 
                    case "2": 
                        //普通 
                        String work_day = activNode.Attributes["work_day"].Value; 
                        String warning_time = activNode.Attributes["warning_time"].Value; 
                        String issendself = activNode.Attributes["issendself"].Value; 
                         
                        String enablesendback = activNode.Attributes["enablesendback"].Value; 
                        String isselectuser = activNode.Attributes["isselectuser"].Value; 
                        String RoleId = ""; 
                        String before_activId = ""; 
                        if (isselectuser == "0") 
                        { 
                            XmlNode roleNode = activNode.SelectSingleNode("role"); 
                            String RoleName = roleNode.Attributes["ref"].Value; 
                            int value = this.GetRoleIDByName(PackageId, RoleName, da); 
                            if(value!=-1) 
                                RoleId = value.ToString(); 
                        } 
                        else 
                        { 
                            XmlNode beforeactivNode = activNode.SelectSingleNode("before_activ"); 
                            String before_activName = beforeactivNode.Attributes["ref"].Value; 
 
                            int value =this.GetActivityIDByName(ProcessId.ToString(), before_activName, da); 
                            if (value != -1) 
                                before_activId = value.ToString(); 
                             
                        } 
                        int activitid = this.AddWFACTIVITYInfo(NAME, Type, "2", "ReceiveStrategyAnd", "DispatchStrategyRandom", "", enablesendback, issendself, work_day, warning_time 
                        , X, Y, ProcessId.ToString(), RoleId, isselectuser, before_activId, da); 
 
                        //更新应用 
                        UpdateActiveAppInfo(PackageId, ProcessId,activitid, activNode, da); 
                        //更新参数 
                        UpdateActivParamInfo(PackageId, ProcessId, activitid, activNode, da); 
                        //更新事件 
                        UpdateActivEventInfo(PackageId, ProcessId, activitid, activNode, da); 
                        break; 
                    //以后再增加 
                } 
            } 
        } 
 
        private void UpdateActiveAppInfo(String PackageId,int ProcessId,int activitid,XmlElement activNode, IDataAccess da) 
        { 
            foreach (XmlElement appNode in activNode.SelectNodes("applications/application")) 
            { 
                String Name = appNode.Attributes["ref"].Value; 
                String AppId = ""; 
                String rank = appNode.Attributes["rank"].Value; 
                int value = this.GetApplicationIDByName(PackageId, Name, da); 
                if (value != -1) 
                    AppId = value.ToString(); 
 
                this.AddWF_R_APPLICATIONACTIVITYInfo(AppId, activitid.ToString(), rank, da); 
            } 
        } 
 
        
 
        private void UpdateActivParamInfo(String PackageId, int ProcessId, int activitid, XmlElement activNode, IDataAccess da) 
        { 
            foreach (XmlElement paramNode in activNode.SelectNodes("params/param")) 
            { 
                String Name = paramNode.Attributes["ref"].Value; 
                String ParamId = ""; 
                
                int value = this.GetParamIDByName(PackageId, Name, da); 
                if (value != -1) 
                    ParamId = value.ToString(); 
 
                this.AddWFACTIVITYPARAMInfo(ParamId, activitid.ToString(), da); 
            } 
        } 
        private void UpdateActivEventInfo(String PackageId, int ProcessId, int activitid, XmlElement activNode, IDataAccess da) 
        { 
            foreach (XmlElement eventNode in activNode.SelectNodes("events/event")) 
            { 
                String eventtype = eventNode.Attributes["eventtype"].Value; 
                String excutetype = eventNode.Attributes["excutetype"].Value; 
                String content = eventNode.Attributes["content"].Value; 
                this.AddWFNORMALACTIVITYEVENTInfo(eventtype, excutetype, content, "1", activitid.ToString(), da); 
            } 
        } 
        #endregion 
 
        #region 新增信息 
        private int CreateRole(String PackageId, String roleName, String roleType, String roleContent, IDataAccess da) 
        { 
            String Sql = "insert into WFROLE(NAME,TYPE,REF_PACKAGE_ID,CHECKCONTENT) values(@NAME,@TYPE,@REF_PACKAGE_ID,@CHECKCONTENT)"; 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp1 = new QueryParameter("ID", DbType.Int32); 
             
            //qp1.Value = RoleId; 
            //qpc.Add(qp1); 
 
            QueryParameter qp2 = new QueryParameter("NAME", DbType.String); 
            qp2.Value = roleName; 
            qpc.Add(qp2); 
 
            QueryParameter qp3 = new QueryParameter("TYPE", DbType.Int32); 
            qp3.Value = Convert.ToInt32(roleType); 
            qpc.Add(qp3); 
 
            QueryParameter qp4 = new QueryParameter("REF_PACKAGE_ID", DbType.String); 
            qp4.Value = PackageId; 
            qpc.Add(qp4); 
 
 
            QueryParameter qp5 = new QueryParameter("CHECKCONTENT", DbType.String); 
            qp5.Value = roleContent; 
            qpc.Add(qp5); 
 
            da.ExecuteNonQuery(Sql, qpc); 
            int RoleId = this.GetMaxId("WFROLE", da); 
            return RoleId; 
        } 
 
        /// <summary> 
        /// 新增包信息 
        /// </summary> 
        /// <param name="Id"></param> 
        /// <param name="Name"></param> 
        /// <param name="da"></param> 
        private void AddPackageInfo(String Id, String Name, IDataAccess da) 
        { 
            String sql = "insert into wfpackage(ID,NAME,version,Createtime) values(@ID,@NAME,@version,@Createtime)"; 
 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            QueryParameter qpID = new QueryParameter("ID", DbType.String); 
            qpID.Value = Id; 
            qpc.Add(qpID); 
 
            QueryParameter qpName = new QueryParameter("NAME", DbType.String); 
            qpName.Value = Name; 
            qpc.Add(qpName); 
 
            int MaxVersion = this.GetMaxPackageVersionByPackageName(Name, da); 
            MaxVersion++; 
            //得到版本 
            QueryParameter qpVersion = new QueryParameter("version", DbType.Int32); 
            qpVersion.Value = MaxVersion; 
            qpc.Add(qpVersion); 
            //得到创建日期 
            QueryParameter qpNow = new QueryParameter("Createtime", DbType.DateTime); 
            qpNow.Value = System.DateTime.Now; 
            qpc.Add(qpNow); 
            da.ExecuteNonQuery(sql, qpc); 
 
        } 
 
 
        private void CreateRoleUserInfo(String UserId, String Rank, int RoleId, IDataAccess da) 
        { 
            String Sql = "insert into WF_R_ROLEUSER(\"USER\",RANK,REF_ROLE_ID) values(@UR,@RANK,@REF_ROLE_ID)"; 
 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp1 = new QueryParameter("ID", DbType.Int32); 
             
            //qp1.Value = RoleUserId; 
            //qpc.Add(qp1); 
 
            QueryParameter qp2 = new QueryParameter("UR", DbType.String); 
            qp2.Value = UserId; 
            qpc.Add(qp2); 
 
            QueryParameter qp3 = new QueryParameter("RANK", DbType.String); 
            qp3.Value = Rank; 
            qpc.Add(qp3); 
 
            QueryParameter qp4 = new QueryParameter("REF_ROLE_ID", DbType.Int32); 
            qp4.Value = RoleId; 
            qpc.Add(qp4); 
            da.ExecuteNonQuery(Sql, qpc); 
        } 
 
        private int AddAppInfo(String PackageId, String appName, String appType, String appParameter, String appGroupId, String appPath, IDataAccess da) 
        { 
            String sql = "insert into WFAPPLICATION(NAME,TYPE,PARAMETER,PATH,GROUPID,REF_PACKAGE_ID) values(@NAME,@TYPE,@PARAMETER,@PATH,@GROUPID,@REF_PACKAGE_ID)"; 
 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp1 = new QueryParameter("ID", DbType.Int32); 
             
            //qp1.Value = AppId; 
            //qpc.Add(qp1); 
 
 
 
            QueryParameter qp2 = new QueryParameter("NAME", DbType.String); 
            qp2.Value = appName; 
            qpc.Add(qp2); 
 
            QueryParameter qp3 = new QueryParameter("TYPE", DbType.Int32); 
            qp3.Value = Convert.ToInt32(appType); 
            qpc.Add(qp3); 
 
            QueryParameter qp4 = new QueryParameter("PARAMETER", DbType.String); 
            qp4.Value = appParameter; 
            qpc.Add(qp4); 
 
            QueryParameter qp5 = new QueryParameter("PATH", DbType.String); 
            qp5.Value = appPath; 
            qpc.Add(qp5); 
 
            QueryParameter qp6 = new QueryParameter("GROUPID", DbType.Int32); 
            qp6.Value = Convert.ToInt32(appGroupId); 
            qpc.Add(qp6); 
 
 
            QueryParameter qp7 = new QueryParameter("REF_PACKAGE_ID", DbType.String); 
            qp7.Value = PackageId; 
            qpc.Add(qp7); 
 
            da.ExecuteNonQuery(sql, qpc); 
            int AppId = this.GetMaxId("WFAPPLICATION", da); 
            return AppId; 
 
        } 
        private int AddParamInfo(String PackageId, String paramName, String paramType, String paramValue, String paramRemark, IDataAccess da) 
        { 
            String sql = "insert into wfparam(PARAMTYPE,\"NAME\",REMARK,REF_WFPACKAGE_ID,\"VALUE\")values(@PARTYPE,@NAME,@REMA,@REF_WFPACKAGE_ID,@VAL)"; 
 
 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp1 = new QueryParameter("ID", DbType.Int32); 
             
            //qp1.Value = ParamId; 
            //qpc.Add(qp1); 
 
            QueryParameter qp2 = new QueryParameter("PARTYPE", DbType.Int32); 
            qp2.Value = Convert.ToInt32(paramType); 
            qpc.Add(qp2); 
 
            QueryParameter qp3 = new QueryParameter("NAME", DbType.String); 
            qp3.Value = paramName; 
            qpc.Add(qp3); 
 
            QueryParameter qp4 = new QueryParameter("REMA", DbType.String); 
            qp4.Value = paramRemark; 
            qpc.Add(qp4); 
 
            QueryParameter qp5 = new QueryParameter("REF_WFPACKAGE_ID", DbType.String); 
            qp5.Value = PackageId; 
            qpc.Add(qp5); 
 
            QueryParameter qp6 = new QueryParameter("VAL", DbType.String); 
            qp6.Value = paramValue; 
            qpc.Add(qp6); 
 
            da.ExecuteNonQuery(sql, qpc); 
            int ParamId = this.GetMaxId("WFPARAM", da); 
            return ParamId; 
 
        } 
        private int AddProcessInfo(String packageId, String NAME, String WORK_DAY, String WARNING_TIME, String REF_ROLE_ID, IDataAccess da) 
        { 
            String sql = "insert into WFPROCESS(NAME,WORK_DAY,WARNING_TIME,REF_ROLE_ID,REF_PACKAGE_ID) values(@NAME,@WORK_DAY,@WARNING_TIME,@REF_ROLE_ID,@REF_PACKAGE_ID)"; 
             
 
 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
           // QueryParameter qp1 = new QueryParameter("ID", DbType.Int32); 
 
           // qp1.Value = ProcessId; 
           // qpc.Add(qp1); 
 
            QueryParameter qp2 = new QueryParameter("NAME", DbType.String); 
            qp2.Value = NAME; 
            qpc.Add(qp2); 
 
            QueryParameter qp3 = new QueryParameter("WORK_DAY", DbType.Double); 
            qp3.Value = Convert.ToDouble(WORK_DAY); 
            qpc.Add(qp3); 
 
            QueryParameter qp4 = new QueryParameter("WARNING_TIME", DbType.Double); 
            qp4.Value = Convert.ToDouble(WARNING_TIME); 
            qpc.Add(qp4); 
 
            QueryParameter qp5 = new QueryParameter("REF_PACKAGE_ID", DbType.String); 
            qp5.Value = packageId; 
            qpc.Add(qp5); 
            //更具name和packageId查询roleID 
 
            QueryParameter qp6 = new QueryParameter("REF_ROLE_ID", DbType.Int32); 
            int roleid = this.GetRoleIDByName(packageId, REF_ROLE_ID, da); 
            if (roleid == -1) 
                throw new Exception("不存在" + NAME + "流程创建角色!"); 
            if (REF_ROLE_ID != "") 
                qp6.Value = roleid; 
            else 
                qp6.Value = DBNull.Value; 
            qpc.Add(qp6); 
 
            da.ExecuteNonQuery(sql, qpc); 
 
            int ProcessId = this.GetMaxId("WFPROCESS", da); 
            return ProcessId; 
        } 
 
        private int AddWFACTIVITYInfo( String NAME, String TYPE, String POSTSTRATEGY, String RECEIVESTRATEGY, String DISPATCHSTRATEGY, String TERM, String ENABLESENDBACK, String ISSENDSELF, String WORK_DAY, String WARNING_TIME, String POSITION_X, String POSITION_Y, String REF_PROCESS_ID, String REF_ROLE_ID, String ISSELECTUSER, String BEFOR_ACTIV_ID, IDataAccess da) 
        { 
            
            String sql = "insert into WFACTIVITY(NAME,TYPE,POSTSTRATEGY,RECEIVESTRATEGY,DISPATCHSTRATEGY,TERM,ENABLESENDBACK,ISSENDSELF,WORK_DAY,WARNING_TIME,POSITION_X,POSITION_Y,REF_PROCESS_ID,REF_ROLE_ID,ISSELECTUSER,BEFOR_ACTIV_ID)values(@NAME,@TYPE,@POSTSTRATEGY,@RECEIVESTRATEGY,@DISPATCHSTRATEGY,@TERM,@ENABLESENDBACK,@ISSENDSELF,@WORK_DAY,@WARNING_TIME,@POSITION_X,@POSITION_Y,@REF_PROCESS_ID,@REF_ROLE_ID,@ISSELECTUSER,@BEFOR_ACTIV_ID)"; 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp0 = new QueryParameter("ID", DbType.Decimal); 
            //qp0.Value = Convert.ToDecimal(WFACTIVITYId); 
           // qpc.Add(qp0); 
            QueryParameter qp1 = new QueryParameter("NAME", DbType.String); 
            if (NAME == "") 
            { 
                qp1.Value = DBNull.Value; 
            } 
            else 
            { 
                qp1.Value = Convert.ToString(NAME); 
            } 
            qpc.Add(qp1); 
            QueryParameter qp2 = new QueryParameter("TYPE", DbType.Decimal); 
            if (TYPE == "") 
            { 
                qp2.Value = DBNull.Value; 
            } 
            else 
            { 
                qp2.Value = Convert.ToDecimal(TYPE); 
            } 
            qpc.Add(qp2); 
            QueryParameter qp3 = new QueryParameter("POSTSTRATEGY", DbType.Decimal); 
            if (POSTSTRATEGY == "") 
            { 
                qp3.Value = DBNull.Value; 
            } 
            else 
            { 
                qp3.Value = Convert.ToDecimal(POSTSTRATEGY); 
            } 
            qpc.Add(qp3); 
            QueryParameter qp4 = new QueryParameter("RECEIVESTRATEGY", DbType.String); 
            if (RECEIVESTRATEGY == "") 
            { 
                qp4.Value = DBNull.Value; 
            } 
            else 
            { 
                qp4.Value = Convert.ToString(RECEIVESTRATEGY); 
            } 
            qpc.Add(qp4); 
            QueryParameter qp5 = new QueryParameter("DISPATCHSTRATEGY", DbType.String); 
            if (DISPATCHSTRATEGY == "") 
            { 
                qp5.Value = DBNull.Value; 
            } 
            else 
            { 
                qp5.Value = Convert.ToString(DISPATCHSTRATEGY); 
            } 
            qpc.Add(qp5); 
            QueryParameter qp6 = new QueryParameter("TERM", DbType.Decimal); 
            if (TERM == "") 
            { 
                qp6.Value = DBNull.Value; 
            } 
            else 
            { 
                qp6.Value = Convert.ToDecimal(TERM); 
            } 
            qpc.Add(qp6); 
            QueryParameter qp7 = new QueryParameter("ENABLESENDBACK", DbType.Decimal); 
            if (ENABLESENDBACK == "") 
            { 
                qp7.Value = DBNull.Value; 
            } 
            else 
            { 
                qp7.Value = Convert.ToDecimal(ENABLESENDBACK); 
            } 
            qpc.Add(qp7); 
            QueryParameter qp8 = new QueryParameter("ISSENDSELF", DbType.Decimal); 
            if (ISSENDSELF == "") 
            { 
                qp8.Value = DBNull.Value; 
            } 
            else 
            { 
                qp8.Value = Convert.ToDecimal(ISSENDSELF); 
            } 
            qpc.Add(qp8); 
            QueryParameter qp9 = new QueryParameter("WORK_DAY", DbType.Decimal); 
            if (WORK_DAY == "") 
            { 
                qp9.Value = DBNull.Value; 
            } 
            else 
            { 
                qp9.Value = Convert.ToDecimal(WORK_DAY); 
            } 
            qpc.Add(qp9); 
            QueryParameter qp10 = new QueryParameter("WARNING_TIME", DbType.Decimal); 
            if (WARNING_TIME == "") 
            { 
                qp10.Value = DBNull.Value; 
            } 
            else 
            { 
                qp10.Value = Convert.ToDecimal(WARNING_TIME); 
            } 
            qpc.Add(qp10); 
            QueryParameter qp11 = new QueryParameter("POSITION_X", DbType.Decimal); 
            if (POSITION_X == "") 
            { 
                qp11.Value = DBNull.Value; 
            } 
            else 
            { 
                qp11.Value = Convert.ToDecimal(POSITION_X); 
            } 
            qpc.Add(qp11); 
            QueryParameter qp12 = new QueryParameter("POSITION_Y", DbType.Decimal); 
            if (POSITION_Y == "") 
            { 
                qp12.Value = DBNull.Value; 
            } 
            else 
            { 
                qp12.Value = Convert.ToDecimal(POSITION_Y); 
            } 
            qpc.Add(qp12); 
            QueryParameter qp13 = new QueryParameter("REF_PROCESS_ID", DbType.Decimal); 
            if (REF_PROCESS_ID == "") 
            { 
                qp13.Value = DBNull.Value; 
            } 
            else 
            { 
                qp13.Value = Convert.ToDecimal(REF_PROCESS_ID); 
            } 
            qpc.Add(qp13); 
            QueryParameter qp14 = new QueryParameter("REF_ROLE_ID", DbType.Decimal); 
            if (REF_ROLE_ID == "") 
            { 
                qp14.Value = DBNull.Value; 
            } 
            else 
            { 
                qp14.Value = Convert.ToDecimal(REF_ROLE_ID); 
            } 
            qpc.Add(qp14); 
            QueryParameter qp15 = new QueryParameter("ISSELECTUSER", DbType.Decimal); 
            if (ISSELECTUSER == "") 
            { 
                qp15.Value = DBNull.Value; 
            } 
            else 
            { 
                qp15.Value = Convert.ToDecimal(ISSELECTUSER); 
            } 
            qpc.Add(qp15); 
            QueryParameter qp16 = new QueryParameter("BEFOR_ACTIV_ID", DbType.Decimal); 
            if (BEFOR_ACTIV_ID == "") 
            { 
                qp16.Value = DBNull.Value; 
            } 
            else 
            { 
                qp16.Value = Convert.ToDecimal(BEFOR_ACTIV_ID); 
            } 
            qpc.Add(qp16); 
            da.ExecuteNonQuery(sql, qpc); 
            int WFACTIVITYId = this.GetMaxId("WFACTIVITY", da); 
            return WFACTIVITYId; 
        } 
 
        private int AddWFACTIVITYPARAMInfo(String REF_WFPARAM_ID, String REF_WFACTIVITY_ID, IDataAccess da) 
        { 
             
            String sql = "insert into WFACTIVITYPARAM(REF_WFPARAM_ID,REF_WFACTIVITY_ID)values(@REF_WFPARAM_ID,@REF_WFACTIVITY_ID)"; 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
           // QueryParameter qp0 = new QueryParameter("ID", DbType.Decimal); 
            //qp0.Value = Convert.ToDecimal(WFACTIVITYPARAMId); 
           // qpc.Add(qp0); 
            QueryParameter qp1 = new QueryParameter("REF_WFPARAM_ID", DbType.Decimal); 
            if (REF_WFPARAM_ID == "") 
            { 
                qp1.Value = DBNull.Value; 
            } 
            else 
            { 
                qp1.Value = Convert.ToDecimal(REF_WFPARAM_ID); 
            } 
            qpc.Add(qp1); 
            QueryParameter qp2 = new QueryParameter("REF_WFACTIVITY_ID", DbType.Decimal); 
            if (REF_WFACTIVITY_ID == "") 
            { 
                qp2.Value = DBNull.Value; 
            } 
            else 
            { 
                qp2.Value = Convert.ToDecimal(REF_WFACTIVITY_ID); 
            } 
            qpc.Add(qp2); 
            da.ExecuteNonQuery(sql, qpc); 
            int WFACTIVITYPARAMId = this.GetMaxId("WFACTIVITYPARAM", da); 
            return WFACTIVITYPARAMId; 
        } 
        private int AddWFCONVERGEACTIVITYInfo( String TYPE, String CONDITION, String REF_WFACTIVITY_ID, IDataAccess da) 
        { 
             
            String sql = "insert into WFCONVERGEACTIVITY(TYPE,CONDITION,REF_WFACTIVITY_ID)values(@TYPE,@CONDITION,@REF_WFACTIVITY_ID)"; 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp0 = new QueryParameter("ID", DbType.Decimal); 
           //qp0.Value = Convert.ToDecimal(WFCONVERGEACTIVITYId); 
           // qpc.Add(qp0); 
            QueryParameter qp1 = new QueryParameter("TYPE", DbType.Decimal); 
            if (TYPE == "") 
            { 
                qp1.Value = DBNull.Value; 
            } 
            else 
            { 
                qp1.Value = Convert.ToDecimal(TYPE); 
            } 
            qpc.Add(qp1); 
            QueryParameter qp2 = new QueryParameter("CONDITION", DbType.String); 
            if (CONDITION == "") 
            { 
                qp2.Value = DBNull.Value; 
            } 
            else 
            { 
                qp2.Value = Convert.ToString(CONDITION); 
            } 
            qpc.Add(qp2); 
            QueryParameter qp3 = new QueryParameter("REF_WFACTIVITY_ID", DbType.Decimal); 
            if (REF_WFACTIVITY_ID == "") 
            { 
                qp3.Value = DBNull.Value; 
            } 
            else 
            { 
                qp3.Value = Convert.ToDecimal(REF_WFACTIVITY_ID); 
            } 
            qpc.Add(qp3); 
            da.ExecuteNonQuery(sql, qpc); 
            int WFCONVERGEACTIVITYId = this.GetMaxId("WFCONVERGEACTIVITY", da); 
            return WFCONVERGEACTIVITYId; 
        } 
 
        private int AddWFNORMALACTIVITYEVENTInfo(String EVENTTYPE, String EXECUTETYPE, String CONTENT, String RANK, String REF_WFACTIVITY_ID, IDataAccess da) 
        { 
             
            String sql = "insert into WFNORMALACTIVITYEVENT(EVENTTYPE,EXECUTETYPE,CONTENT,RANK,REF_WFACTIVITY_ID)values(@EVENTTYPE,@EXECUTETYPE,@CONTENT,@RANK,@REF_WFACTIVITY_ID)"; 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
           // QueryParameter qp0 = new QueryParameter("ID", DbType.Decimal); 
           // qp0.Value = Convert.ToDecimal(WFNORMALACTIVITYEVENTId); 
           // qpc.Add(qp0); 
            QueryParameter qp1 = new QueryParameter("EVENTTYPE", DbType.Decimal); 
            if (EVENTTYPE == "") 
            { 
                qp1.Value = DBNull.Value; 
            } 
            else 
            { 
                qp1.Value = Convert.ToDecimal(EVENTTYPE); 
            } 
            qpc.Add(qp1); 
            QueryParameter qp2 = new QueryParameter("EXECUTETYPE", DbType.Decimal); 
            if (EXECUTETYPE == "") 
            { 
                qp2.Value = DBNull.Value; 
            } 
            else 
            { 
                qp2.Value = Convert.ToDecimal(EXECUTETYPE); 
            } 
            qpc.Add(qp2); 
            QueryParameter qp3 = new QueryParameter("CONTENT", DbType.String); 
            if (CONTENT == "") 
            { 
                qp3.Value = DBNull.Value; 
            } 
            else 
            { 
                qp3.Value = Convert.ToString(CONTENT); 
            } 
            qpc.Add(qp3); 
            QueryParameter qp4 = new QueryParameter("RANK", DbType.String); 
            if (RANK == "") 
            { 
                qp4.Value = DBNull.Value; 
            } 
            else 
            { 
                qp4.Value = Convert.ToString(RANK); 
            } 
            qpc.Add(qp4); 
            QueryParameter qp5 = new QueryParameter("REF_WFACTIVITY_ID", DbType.Decimal); 
            if (REF_WFACTIVITY_ID == "") 
            { 
                qp5.Value = DBNull.Value; 
            } 
            else 
            { 
                qp5.Value = Convert.ToDecimal(REF_WFACTIVITY_ID); 
            } 
            qpc.Add(qp5); 
            da.ExecuteNonQuery(sql, qpc); 
            int WFNORMALACTIVITYEVENTId = this.GetMaxId("WFNORMALACTIVITYEVENT", da); 
            return WFNORMALACTIVITYEVENTId; 
        } 
        private int AddWFRAMUSACTIVITYInfo( String TYPE, String REF_WFACTIVITY_ID, IDataAccess da) 
        { 
             
            String sql = "insert into WFRAMUSACTIVITY(TYPE,REF_WFACTIVITY_ID)values(@TYPE,@REF_WFACTIVITY_ID)"; 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp0 = new QueryParameter("ID", DbType.Decimal); 
            //qp0.Value = Convert.ToDecimal(WFRAMUSACTIVITYId); 
            //qpc.Add(qp0); 
            QueryParameter qp1 = new QueryParameter("TYPE", DbType.Decimal); 
            if (TYPE == "") 
            { 
                qp1.Value = DBNull.Value; 
            } 
            else 
            { 
                qp1.Value = Convert.ToDecimal(TYPE); 
            } 
            qpc.Add(qp1); 
            QueryParameter qp2 = new QueryParameter("REF_WFACTIVITY_ID", DbType.Decimal); 
            if (REF_WFACTIVITY_ID == "") 
            { 
                qp2.Value = DBNull.Value; 
            } 
            else 
            { 
                qp2.Value = Convert.ToDecimal(REF_WFACTIVITY_ID); 
            } 
            qpc.Add(qp2); 
            da.ExecuteNonQuery(sql, qpc); 
            int WFRAMUSACTIVITYId = this.GetMaxId("WFRAMUSACTIVITY", da); 
            return WFRAMUSACTIVITYId; 
        } 
 
        private int AddWF_R_APPLICATIONACTIVITYInfo(String REF_APPLICATION_ID, String REF_ACTIVITY_ID, String RANK, IDataAccess da) 
        { 
             
            String sql = "insert into WF_R_APPLICATIONACTIVITY(REF_APPLICATION_ID,REF_ACTIVITY_ID,RANK)values(@REF_APPLICATION_ID,@REF_ACTIVITY_ID,@RANK)"; 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp0 = new QueryParameter("ID", DbType.Decimal); 
            //qp0.Value = Convert.ToDecimal(WF_R_APPLICATIONACTIVITYId); 
            //qpc.Add(qp0); 
            QueryParameter qp1 = new QueryParameter("REF_APPLICATION_ID", DbType.Decimal); 
            if (REF_APPLICATION_ID == "") 
            { 
                qp1.Value = DBNull.Value; 
            } 
            else 
            { 
                qp1.Value = Convert.ToDecimal(REF_APPLICATION_ID); 
            } 
            qpc.Add(qp1); 
            QueryParameter qp2 = new QueryParameter("REF_ACTIVITY_ID", DbType.Decimal); 
            if (REF_ACTIVITY_ID == "") 
            { 
                qp2.Value = DBNull.Value; 
            } 
            else 
            { 
                qp2.Value = Convert.ToDecimal(REF_ACTIVITY_ID); 
            } 
            qpc.Add(qp2); 
            QueryParameter qp3 = new QueryParameter("RANK", DbType.Decimal); 
            if (RANK == "") 
            { 
                qp3.Value = DBNull.Value; 
            } 
            else 
            { 
                qp3.Value = Convert.ToDecimal(RANK); 
            } 
            qpc.Add(qp3); 
            da.ExecuteNonQuery(sql, qpc); 
            int WF_R_APPLICATIONACTIVITYId = this.GetMaxId("WF_R_APPLICATIONACTIVITY", da); 
            return WF_R_APPLICATIONACTIVITYId; 
        } 
        private int AddWFTRANSITIONInfo(String NAME, String TYPE, String POSITION_Y, String POSITION_X, String REF_PROCESS_ID, String REF_STARTACTIVITY_ID, String REF_ENDACTIVITY_ID, String CONDITION, IDataAccess da) 
        { 
            
            String sql = "insert into WFTRANSITION(NAME,TYPE,POSITION_Y,POSITION_X,REF_PROCESS_ID,REF_STARTACTIVITY_ID,REF_ENDACTIVITY_ID,CONDITION)values(@NAME,@TYPE,@POSITION_Y,@POSITION_X,@REF_PROCESS_ID,@REF_STARTACTIVITY_ID,@REF_ENDACTIVITY_ID,@CONDITION)"; 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp0 = new QueryParameter("ID", DbType.Decimal); 
            //qp0.Value = Convert.ToDecimal(WFTRANSITIONId); 
            //qpc.Add(qp0); 
            QueryParameter qp1 = new QueryParameter("NAME", DbType.String); 
            if (NAME == "") 
            { 
                qp1.Value = DBNull.Value; 
            } 
            else 
            { 
                qp1.Value = Convert.ToString(NAME); 
            } 
            qpc.Add(qp1); 
            QueryParameter qp2 = new QueryParameter("TYPE", DbType.Decimal); 
            if (TYPE == "") 
            { 
                qp2.Value = DBNull.Value; 
            } 
            else 
            { 
                qp2.Value = Convert.ToDecimal(TYPE); 
            } 
            qpc.Add(qp2); 
            QueryParameter qp3 = new QueryParameter("POSITION_Y", DbType.Decimal); 
            if (POSITION_Y == "") 
            { 
                qp3.Value = DBNull.Value; 
            } 
            else 
            { 
                qp3.Value = Convert.ToDecimal(POSITION_Y); 
            } 
            qpc.Add(qp3); 
            QueryParameter qp4 = new QueryParameter("POSITION_X", DbType.Decimal); 
            if (POSITION_X == "") 
            { 
                qp4.Value = DBNull.Value; 
            } 
            else 
            { 
                qp4.Value = Convert.ToDecimal(POSITION_X); 
            } 
            qpc.Add(qp4); 
            QueryParameter qp5 = new QueryParameter("REF_PROCESS_ID", DbType.Decimal); 
            if (REF_PROCESS_ID == "") 
            { 
                qp5.Value = DBNull.Value; 
            } 
            else 
            { 
                qp5.Value = Convert.ToDecimal(REF_PROCESS_ID); 
            } 
            qpc.Add(qp5); 
            QueryParameter qp6 = new QueryParameter("REF_STARTACTIVITY_ID", DbType.Decimal); 
            if (REF_STARTACTIVITY_ID == "") 
            { 
                qp6.Value = DBNull.Value; 
            } 
            else 
            { 
                qp6.Value = Convert.ToDecimal(REF_STARTACTIVITY_ID); 
            } 
            qpc.Add(qp6); 
            QueryParameter qp7 = new QueryParameter("REF_ENDACTIVITY_ID", DbType.Decimal); 
            if (REF_ENDACTIVITY_ID == "") 
            { 
                qp7.Value = DBNull.Value; 
            } 
            else 
            { 
                qp7.Value = Convert.ToDecimal(REF_ENDACTIVITY_ID); 
            } 
            qpc.Add(qp7); 
            QueryParameter qp8 = new QueryParameter("CONDITION", DbType.String); 
            if (CONDITION == "") 
            { 
                qp8.Value = DBNull.Value; 
            } 
            else 
            { 
                qp8.Value = Convert.ToString(CONDITION); 
            } 
            qpc.Add(qp8); 
            da.ExecuteNonQuery(sql, qpc); 
            int WFTRANSITIONId = this.GetMaxId("WFTRANSITION", da); 
            return WFTRANSITIONId; 
        } 
        private int AddWFTRANSITIONCONDITIONInfo(String TYPE, String VALUE, String REF_WFTRANSITION_ID, String REF_PARAM_ID, IDataAccess da) 
        { 
             
            String sql = "insert into WFTRANSITIONCONDITION(TYPE,VALUE,REF_WFTRANSITION_ID,REF_PARAM_ID)values(@TYPE,@VALUE,@REF_WFTRANSITION_ID,@REF_PARAM_ID)"; 
            QueryParameterCollection qpc = new QueryParameterCollection(); 
            //QueryParameter qp0 = new QueryParameter("ID", DbType.Decimal); 
            //qp0.Value = Convert.ToDecimal(WFTRANSITIONCONDITIONId); 
            //qpc.Add(qp0); 
            QueryParameter qp1 = new QueryParameter("TYPE", DbType.String); 
            if (TYPE == "") 
            { 
                qp1.Value = DBNull.Value; 
            } 
            else 
            { 
                qp1.Value = Convert.ToString(TYPE); 
            } 
            qpc.Add(qp1); 
            QueryParameter qp2 = new QueryParameter("VALUE", DbType.String); 
            if (VALUE == "") 
            { 
                qp2.Value = DBNull.Value; 
            } 
            else 
            { 
                qp2.Value = Convert.ToString(VALUE); 
            } 
            qpc.Add(qp2); 
            QueryParameter qp3 = new QueryParameter("REF_WFTRANSITION_ID", DbType.Decimal); 
            if (REF_WFTRANSITION_ID == "") 
            { 
                qp3.Value = DBNull.Value; 
            } 
            else 
            { 
                qp3.Value = Convert.ToDecimal(REF_WFTRANSITION_ID); 
            } 
            qpc.Add(qp3); 
            QueryParameter qp4 = new QueryParameter("REF_PARAM_ID", DbType.Decimal); 
            if (REF_PARAM_ID == "") 
            { 
                qp4.Value = DBNull.Value; 
            } 
            else 
            { 
                qp4.Value = Convert.ToDecimal(REF_PARAM_ID); 
            } 
            qpc.Add(qp4); 
            da.ExecuteNonQuery(sql, qpc); 
            int WFTRANSITIONCONDITIONId = this.GetMaxId("WFTRANSITIONCONDITION", da); 
            return WFTRANSITIONCONDITIONId; 
        } 
        #endregion 
 
    } 
}