Пример #1
0
        public static ApplicationRelation GetApplicationRelationById(Guid appid)
        {
            ApplicationRelation info  = null;
            IDbConnection       conn  = null;
            IDbCommand          cmd   = null;
            IDbTransaction      trans = null;

            try
            {
                IApplicationRelation dp = DataProvider.DbApplicationRelationDP;
                conn = DbConnOperation.CreateConnection();
                cmd  = conn.CreateCommand();
                conn.Open();
                trans           = conn.BeginTransaction();
                cmd.Transaction = trans;
                info            = dp.GetApplicationRelationById(cmd, appid);
                trans.Commit();
            }
            catch (Exception ex)
            {
                log.Error(string.Format("GetApplicationRelationById()发生错误,错误信息如下:{0}", ex));
                if (trans != null)
                {
                    trans.Rollback();
                }
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(info);
        }
Пример #2
0
        public static bool AddOrUpdateApplicationRelation(ApplicationRelation info, ModifierType mode)
        {
            bool           ret   = false;
            IDbConnection  conn  = null;
            IDbCommand     cmd   = null;
            IDbTransaction trans = null;

            try
            {
                IApplicationRelation dp = DataProvider.DbApplicationRelationDP;
                conn = DbConnOperation.CreateConnection();
                cmd  = conn.CreateCommand();
                conn.Open();
                trans           = conn.BeginTransaction();
                cmd.Transaction = trans;
                ret             = dp.AddOrUpdateApplicationRelation(cmd, info, mode);
                trans.Commit();
            }
            catch (Exception ex)
            {
                log.Error(string.Format("AddOrUpdateApplicationRelation()发生错误,错误信息如下:{0}", ex));
                if (trans != null)
                {
                    trans.Rollback();
                }
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(ret);
        }
        public static List <ApplicationRelation> ConvertToListOfApplicationRelation(List <ProcessApplicationRelation> apps)
        {
            List <ApplicationRelation> relation = new List <ApplicationRelation>();

            foreach (ProcessApplicationRelation app in apps)
            {
                ApplicationRelation relationItem = new ApplicationRelation()
                {
                    ApplicationID   = app.ApplicationID,
                    ApplicationName = app.ApplicationName
                };
                relation.Add(relationItem);
            }
            return(relation);
        }
        public ApplicationRelation GetApplicationRelationById(IDbCommand icmd, Guid appid)
        {
            icmd.Parameters.Clear();
            MySqlCommand cmd = icmd as MySqlCommand;

            cmd.CommandType = CommandType.Text;
            string sql = @"select appId,appName,fatherId,fatherName,childId,childName,createtime from applicationrelation where appId = '{0}'";

            cmd.CommandText = string.Format(sql, appid);
            ApplicationRelation info = null;
            DataTable           dt   = new DataTable();

            dt.Load(cmd.ExecuteReader());
            if (dt.Rows.Count > 0)
            {
                info = new ApplicationRelation();
                info.AllParse(dt.Rows[0]);
            }
            return(info);
        }
        public bool AddOrUpdateApplicationRelation(IDbCommand icmd, ApplicationRelation info, ModifierType mode)
        {
            icmd.Parameters.Clear();
            MySqlCommand cmd = icmd as MySqlCommand;

            cmd.CommandType = CommandType.Text;
            if (mode == ModifierType.Add)
            {
                string sql = @"insert into applicationrelation(appId,appName,fatherId,fatherName,childId,childName,createtime)
                                values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')";
                cmd.CommandText = string.Format(sql, info.appId, info.appName, info.fatherId, info.fatherName, info.childId, info.childName, info.createtime);
            }
            else if (mode == ModifierType.Update)
            {
                string sql = @"update applicationrelation set fatherId = '{0}',fatherName = '{1}',childId = '{2}',childName = '{3}',createtime = '{4}'
                                where appId = '{5}'";
                cmd.CommandText = string.Format(sql, info.fatherId, info.fatherName, info.childId, info.childName, info.appId);
            }
            cmd.ExecuteNonQuery();
            return(true);
        }
 public object AddApplicationInterfaceRelation(string appid, string appname, string interfaceid, string interfacename, string destinappid, string destinappname, string fatherid, string fathername)
 {
     try
     {
         SystemSettingBase settings = SystemSettingBase.CreateInstance();
         if (settings.SysMySqlDB != null)
         {
             ConnString.MySqldb = settings.SysMySqlDB.ConnectionString;
         }
         if (null == ApplicationInterfaceRelationOperation.GetApplicationInterfaceRelation(new Guid(appid), new Guid(interfaceid), new Guid(destinappid)))
         {
             ApplicationInterfaceRelation info = new ApplicationInterfaceRelation()
             {
                 Id            = Guid.NewGuid(),
                 appId         = new Guid(appid),
                 appname       = appname,
                 interfaceId   = new Guid(interfaceid),
                 interfacename = interfacename,
                 destinappid   = new Guid(destinappid),
                 destinappname = destinappname,
                 updatetime    = DateTime.Now
             };
             ApplicationInterfaceRelationOperation.AddOrUpdateApplicationInterfaceRelation(info, ModifierType.Add);
             if (null == ApplicationRelationOperation.GetApplicationRelationById(new Guid(appid)))
             {
                 ApplicationRelation relation = new ApplicationRelation()
                 {
                     appId      = new Guid(appid),
                     appName    = appname,
                     fatherId   = new Guid(fatherid),
                     fatherName = fathername,
                     childId    = new Guid(destinappid),
                     childName  = destinappname
                 };
                 ApplicationRelationOperation.AddOrUpdateApplicationRelation(relation, ModifierType.Add);
             }
             //更新接口配置表接口配置中接口所属系统信息
             InterfaceConfigInfo interfaceConfig = InterfaceConfigInfoOperation.GetInterfaceConfigInfoById(new Guid(interfaceid));
             if (null != interfaceConfig)
             {
                 interfaceConfig.ApplicationName = appname;
                 interfaceConfig.CreateTime      = DateTime.Now;
                 InterfaceConfigInfoOperation.AddOrUpdateInterfaceConfigInfo(interfaceConfig, ModifierType.Update);
             }
             //更新接口实时信息表中接口所属系统信息
             InterfaceRealtimeInfo realtimeInfo = InterfaceRealtimeInfoOperation.GetInterfaceRealtimeInfo(new Guid(interfaceid));
             if (null != realtimeInfo)
             {
                 realtimeInfo.ApplicationName = appname;
                 realtimeInfo.UpdateTime      = DateTime.Now;
                 InterfaceRealtimeInfoOperation.AddOrUpdateInterceRealtimeInfo(realtimeInfo, ModifierType.Update);
             }
             return(string.Format("添加【{0},{1},{2}】关联关系成功!", appname, interfacename, destinappname));
         }
         else
         {
             return(string.Format("系统已存在【{0},{1},{2}】该关联关系!", appname, interfacename, destinappname));
         }
     }
     catch (Exception ex)
     {
         return(string.Format("添加【{0},{1},{2}】关联关系失败!异常信息如下:{3}", appname, interfacename, destinappname, ex.Message));
     }
 }