コード例 #1
0
        /// <summary>
        /// 接口实时状态新增或修改
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="mode"></param>
        public static void AddOrUpdateInterceRealtimeInfo(InterfaceRealtimeInfo entity, ModifierType mode)
        {
            IDbConnection  conn  = null;
            IDbCommand     cmd   = null;
            IDbTransaction trans = null;

            try
            {
                IInterfaceRealtimeInfo dp = DataProvider.DbInterfaceRealtimeDP;
                conn = DbConnOperation.CreateConnection();
                cmd  = conn.CreateCommand();
                conn.Open();
                trans           = conn.BeginTransaction();
                cmd.Transaction = trans;
                dp.AddOrUpdateInterceRealtimeInfo(cmd, entity, mode);
                trans.Commit();
            }
            catch (Exception ex)
            {
                if (null != trans)
                {
                    trans.Rollback();
                }
            }
            finally
            {
                if (null != conn)
                {
                    conn.Close();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 接口实时状态信息新增或修改
        /// </summary>
        /// <param name="icmd"></param>
        /// <param name="entity"></param>
        /// <param name="mode"></param>
        public void AddOrUpdateInterceRealtimeInfo(IDbCommand icmd, InterfaceRealtimeInfo entity, ModifierType mode)
        {
            icmd.Parameters.Clear();
            MySqlCommand cmd = icmd as MySqlCommand;

            cmd.CommandType = CommandType.Text;
            if (mode == ModifierType.Add)
            {
                string sql = @"insert into interfacerealtimeinfo(Id,InterfaceName,ApplicationName,ServerAddress,StateCode,UpdateTime,appid)
                            values('{0}','{1}','{2}','{3}',{4},'{5}','{6}')";
                cmd.CommandText = string.Format(sql, entity.Id, entity.InterfaceName, entity.ApplicationName, entity.ServerAddress, entity.StateCode, entity.UpdateTime, entity.appid);
            }
            else if (mode == ModifierType.Update)
            {
                string sql = @"update interfacerealtimeinfo
                                set InterfaceName = '{0}',
                                ApplicationName = '{1}',
                                ServerAddress = '{2}',
                                StateCode = {3},
                                UpdateTime = '{4}',
                                appid = '{5}'
                                where Id = '{6}'";
                cmd.CommandText = string.Format(sql, entity.InterfaceName, entity.ApplicationName, entity.ServerAddress, entity.StateCode, entity.UpdateTime, entity.appid, entity.Id);
            }
            cmd.ExecuteNonQuery();
        }
コード例 #3
0
        /// <summary>
        /// 根据Id编号获取接口实时状态信息
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns></returns>
        public static InterfaceRealtimeInfo GetInterfaceRealtimeInfo(Guid id)
        {
            IDbConnection         conn  = null;
            IDbCommand            cmd   = null;
            IDbTransaction        trans = null;
            InterfaceRealtimeInfo info  = null;

            try
            {
                IInterfaceRealtimeInfo dp = DataProvider.DbInterfaceRealtimeDP;
                conn = DbConnOperation.CreateConnection();
                cmd  = conn.CreateCommand();
                conn.Open();
                trans           = conn.BeginTransaction();
                cmd.Transaction = trans;
                info            = dp.GetInterfaceRealtimeInfo(cmd, id);
                trans.Commit();
            }
            catch (Exception ex)
            {
                if (null != trans)
                {
                    trans.Rollback();
                }
            }
            finally
            {
                if (null != conn)
                {
                    conn.Close();
                }
            }
            return(info);
        }
コード例 #4
0
        /// <summary>
        /// 接口初始化业务逻辑方法
        /// </summary>
        /// <param name="interfaceName">接口名</param>
        /// <param name="applicationName">应用系统名</param>
        /// <param name="server">服务器地址</param>
        /// <param name="user">用户名</param>
        /// <param name="userPwd">密码</param>
        /// <param name="charger">负责人</param>
        /// <param name="phone">负责人联系号码</param>
        /// <param name="timeout">超时时间</param>
        /// <param name="path">帮助文档存放路径</param>
        /// <param name="descript">描述</param>
        /// <param name="appid">应用编号</param>
        public static void SaveInterfaceInitial(string interfaceName, string user, string userPwd, string charger, string phone, int timeout, string path, string descript, string urlAddress, string exeptionlevel, string affectProduction, string type, string appid, string destAppid)
        {
            //生成接口编号id
            Guid id = Guid.NewGuid();
            ApplicationSysInfo appinfo = ApplicationSysInfoLogical.GetApplicationSysInfoById(new Guid(appid));
            ApplicationSysInfo destapp = ApplicationSysInfoLogical.GetApplicationSysInfoById(new Guid(destAppid));

            //判断接口配置信息是否存在,如果不存在则新增
            if (InterfaceConfigInfoOperation.GetInterfaceConfigInfo(interfaceName, appinfo.name, appinfo.server) == null)
            {
                //接口配置信息
                InterfaceConfigInfo config = new InterfaceConfigInfo();
                config.Id                  = id;
                config.InterfaceName       = interfaceName;
                config.ApplicationName     = appinfo.name;
                config.ServerAddress       = appinfo.server;
                config.ServerUser          = user;
                config.UserPwd             = userPwd;
                config.PersonOfChargeName  = charger;
                config.PersonOfChargePhone = phone;
                config.ConnectedTimeout    = timeout;
                config.DocumentHelpPath    = path;
                config.UrlAddress          = urlAddress;
                config.Description         = descript;
                config.Exeptionlevel       = Int32.Parse(exeptionlevel);
                config.AffectProduction    = Int32.Parse(affectProduction);
                config.Type                = Int32.Parse(type);
                config.appid               = new Guid(appid);
                config.CreateTime          = DateTime.Now;
                //应用系统接口关系
                ApplicationInterfaceRelation relation = new ApplicationInterfaceRelation();
                relation.Id            = Guid.NewGuid();
                relation.appId         = appinfo.Id;
                relation.appname       = appinfo.name;
                relation.interfaceId   = id;
                relation.interfacename = interfaceName;
                relation.destinappid   = destapp.Id;
                relation.destinappname = destapp.name;
                relation.updatetime    = DateTime.Now;
                //接口实时状态信息
                InterfaceRealtimeInfo realtime = new InterfaceRealtimeInfo();
                realtime.Id              = id;
                realtime.InterfaceName   = interfaceName;
                realtime.ApplicationName = appinfo.name;
                realtime.ServerAddress   = appinfo.server;
                realtime.appid           = new Guid(appid);
                realtime.StateCode       = 0;
                realtime.UpdateTime      = DateTime.Now;

                InterfaceConfigInfoOperation.AddOrUpdateInterfaceConfigInfo(config, ModifierType.Add);
                InterfaceRealtimeInfoOperation.AddOrUpdateInterceRealtimeInfo(realtime, ModifierType.Add);
                ApplicationInterfaceRelationOperation.AddOrUpdateApplicationInterfaceRelation(relation, ModifierType.Add);
            }
        }
コード例 #5
0
        /// <summary>
        /// 更新接口实时状态信息业务逻辑
        /// </summary>
        /// <param name="interfaceName">接口名</param>
        /// <param name="applicationName">应用系统名</param>
        /// <param name="server">服务器地址</param>
        /// <param name="stateCode">状态码</param>
        public static void UpdateInterfaceRealtimeInfo(string interfaceName, string applicationName, string server, int stateCode)
        {
            InterfaceRealtimeInfo info = InterfaceRealtimeInfoOperation.GetInterfaceRealtimeInfo(interfaceName, applicationName, server);

            if (null != info)
            {
                info.StateCode  = stateCode;
                info.UpdateTime = DateTime.Now;
                InterfaceRealtimeInfoOperation.AddOrUpdateInterceRealtimeInfo(info, ModifierType.Update);
            }
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: hercat/InterfacesMonitor
        /// <summary>
        /// 接口实时状态添加测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button9_Click(object sender, EventArgs e)
        {
            InterfaceRealtimeInfo entity = new InterfaceRealtimeInfo();

            entity.Id              = new Guid("ad6fb4e4-96c0-4e15-a072-dd921bcac243");
            entity.InterfaceName   = "InterfaceMonitor.Frameworks.Logical.InterfaceConfigInfoOperation";
            entity.ApplicationName = "测试接口";
            entity.ServerAddress   = "192.168.1.100";
            entity.StateCode       = 200;
            entity.UpdateTime      = DateTime.Now;
            InterfaceRealtimeInfoOperation.AddOrUpdateInterceRealtimeInfo(entity, ModifierType.Add);
        }
コード例 #7
0
        /// <summary>
        /// 根据id删除接口配置信息(同时删除对应的实时状态表中信息)
        /// </summary>
        /// <param name="id"></param>
        public static void DeleteInterfaceConfigInfoById(string id)
        {
            InterfaceConfigInfo info = InterfaceConfigInfoOperation.GetInterfaceConfigInfoById(new Guid(id));

            if (null != info)
            {
                InterfaceConfigInfoOperation.DeleteInterfaceConfigInfoById(info.Id);
                InterfaceRealtimeInfo realtime = InterfaceRealtimeInfoOperation.GetInterfaceRealtimeInfo(info.Id);
                if (null != realtime)
                {
                    InterfaceRealtimeInfoOperation.DeleteInterfaceRealtimeInfoById(info.Id);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// 删除接口配置信息(同时删除对应的实时状态表中信息)
        /// </summary>
        /// <param name="interfaceName"></param>
        /// <param name="applicationName"></param>
        /// <param name="server"></param>
        public static void DeleteInterfaceConfigInfo(string interfaceName, string server)
        {
            InterfaceConfigInfo info = InterfaceConfigInfoOperation.GetInterfaceConfigInfo(interfaceName, server);

            if (info != null)
            {
                InterfaceConfigInfoOperation.DeleteInterfaceConfigInfoById(info.Id);
                InterfaceRealtimeInfo realtime = InterfaceRealtimeInfoOperation.GetInterfaceRealtimeInfo(info.Id);
                if (realtime != null)
                {
                    InterfaceRealtimeInfoOperation.DeleteInterfaceRealtimeInfoById(info.Id);
                }
            }
        }
コード例 #9
0
 public object GetInterfaceRealtimeById(string id)
 {
     try
     {
         SystemSettingBase settings = SystemSettingBase.CreateInstance();
         if (settings.SysMySqlDB != null)
         {
             ConnString.MySqldb = settings.SysMySqlDB.ConnectionString;
         }
         InterfaceRealtimeInfo info = InterfaceRealtimeInfoOperation.GetInterfaceRealtimeInfo(new Guid(id));
         return(new JsonResult(info));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #10
0
        /// <summary>
        /// 更新接口实时状态信息、接口异常日志信息业务逻辑
        /// </summary>
        /// <param name="interfaceName">接口名</param>
        /// <param name="applicationName">应用系统名</param>
        /// <param name="server">服务器地址</param>
        /// <param name="stateCode">状态码</param>
        /// <param name="exceptionInfo">接口异常信息内容</param>
        public static void UpdateInterfaceRealtimeInfoWithException(string interfaceName, string applicationName, string server, int stateCode, string exceptionInfo)
        {
            InterfaceRealtimeInfo realtime = InterfaceRealtimeInfoOperation.GetInterfaceRealtimeInfo(interfaceName, applicationName, server);
            InterfaceConfigInfo   config   = InterfaceConfigInfoOperation.GetInterfaceConfigInfo(interfaceName, server);

            if (null != realtime)
            {
                realtime.StateCode  = stateCode;
                realtime.UpdateTime = DateTime.Now;
                InterfaceRealtimeInfoOperation.AddOrUpdateInterceRealtimeInfo(realtime, ModifierType.Update);
            }
            if (!string.IsNullOrEmpty(exceptionInfo))
            {
                InterfaceExceptionlog log = new InterfaceExceptionlog();
                log.ConfigId      = config.Id;
                log.StateCode     = stateCode;
                log.ExceptionInfo = exceptionInfo;
                log.CreateTime    = DateTime.Now;
                InterfaceExceptionlogOperation.AddInterfaceExceptionlogInfo(log);
            }
        }
コード例 #11
0
        /// <summary>
        /// 根据Id获取实时状态信息
        /// </summary>
        /// <param name="icmd"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public InterfaceRealtimeInfo GetInterfaceRealtimeInfo(IDbCommand icmd, Guid id)
        {
            icmd.Parameters.Clear();
            MySqlCommand cmd = icmd as MySqlCommand;

            cmd.CommandType = CommandType.Text;
            string sql = @"select Id,InterfaceName,ApplicationName,ServerAddress,StateCode,UpdateTime,appid
                            from interfacerealtimeinfo
                            where Id = '{0}'";

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

            dt.Load(cmd.ExecuteReader());
            if (dt.Rows.Count > 0)
            {
                info = new InterfaceRealtimeInfo();
                info.AllParse(dt.Rows[0]);
            }
            return(info);
        }
コード例 #12
0
        /// <summary>
        /// 获取实时状态信息列表(带分页)
        /// </summary>
        /// <param name="icmd"></param>
        /// <param name="fields"></param>
        /// <param name="whereCondition"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public List <InterfaceRealtimeInfo> GetInterfaceRealtimeInfoPageList(IDbCommand icmd, string fields, string whereCondition, int pageIndex, int pageSize)
        {
            icmd.Parameters.Clear();
            MySqlCommand cmd = icmd as MySqlCommand;

            cmd.CommandType = CommandType.Text;
            StringBuilder sb         = new StringBuilder();
            int           startIndex = (pageIndex - 1) * pageSize;//计算页面开始下标值

            if (!string.IsNullOrEmpty(fields))
            {
                sb.AppendFormat("select {0} from interfacerealtimeinfo ", fields);
            }
            if (!string.IsNullOrEmpty(whereCondition))
            {
                sb.AppendFormat("{0} ", whereCondition);
            }
            sb.AppendFormat("limit {0},{1}", startIndex, pageSize);
            cmd.CommandText = sb.ToString();
            List <InterfaceRealtimeInfo> list = new List <InterfaceRealtimeInfo>();
            DataTable dt = new DataTable();

            dt.Load(cmd.ExecuteReader());
            if (dt.Rows.Count > 0)
            {
                InterfaceRealtimeInfo obj = null;
                foreach (DataRow dr in dt.Rows)
                {
                    obj = new InterfaceRealtimeInfo();
                    obj.AllParse(dr);
                    if (null != obj)
                    {
                        list.Add(obj);
                    }
                }
            }
            return(list);
        }
コード例 #13
0
ファイル: Form1.cs プロジェクト: hercat/InterfacesMonitor
 /// <summary>
 /// 根据Id获取
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button12_Click(object sender, EventArgs e)
 {
     Guid id = new Guid("ad6fb4e4-96c0-4e15-a072-dd921bcac243");
     InterfaceRealtimeInfo info = InterfaceRealtimeInfoOperation.GetInterfaceRealtimeInfo(id);
 }
コード例 #14
0
 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));
     }
 }