Beispiel #1
0
        public ExcuteMessage AddRevisionPublish(SvnRevisionPublishModel model)
        {
            var message        = new ExcuteMessage();
            var jenkinsOptions = _repository.Query($"select JobName from Svn_Jenkins where ID='{model.JenkinsID}'").FirstOrDefault();

            if (jenkinsOptions == null)
            {
                message.Success = false;
                message.Message = "不存在Job";
            }
            else
            {
                using (HttpClient http = new HttpClient())
                {
                    try
                    {
                        var response = http.PostAsync($"{_jenkinsUrl}/job/{jenkinsOptions.JobName}/build", null);
                        var result   = response.Result.Content.ReadAsStringAsync().Result;
                        var query    = $"insert into SVN_RevisionPublish(SystemAccountID,LogID,JenkinsID,Description) values('{model.SystemAccountID}','{model.LogID}','{model.JenkinsID}','{model.Description}')";
                        _repository.Excute(query);
                    }
                    catch (Exception e)
                    {
                        message.Success = false;
                        message.Message = e.ToString();
                    }
                }
            }
            return(message);
        }
Beispiel #2
0
        /// <summary>
        /// 功能描述:修改数据(如果实体启用记录修改字段功能,则修改主键可用,否则请重新该函数并使用dal的UpdateEx函数进行处理)
        /// </summary>
        /// <param name="strJson">strJson</param>
        /// <returns>返回值</returns>
        public virtual string Update(string strJson)
        {
            TEntity entity = strJson.ToJsonObject <TEntity>();

            try
            {
                Type type = entity.GetType();
                //取的LstModifyFields
                PropertyInfo pi = type.GetProperty("LstModifyFields");
                Dictionary <string, object> LstModifyFields = null;
                if (pi != null)
                {
                    LstModifyFields = pi.GetValue(entity, null) as Dictionary <string, object>;
                }

                //是否修改内容包含主键
                bool blnIsHas  = false;
                bool blnUpdate = false;
                if (LstModifyFields != null && LstModifyFields.Count > 0)
                {
                    List <string> lst = LstModifyFields.Keys.ToList();
                    MethodInfo    miIsHasPrimaryKey = type.GetMethod("IsHasPrimaryKey", new Type[] { lst.GetType() });
                    blnIsHas = (bool)miIsHasPrimaryKey.Invoke(entity, new object[] { lst });
                }

                if (blnIsHas)
                {
                    //处理包含主键的修改
                    MethodInfo miCreateWhereDictWithModifyFields = type.GetMethod("CreateWhereDictWithModifyFields", new Type[] { });
                    Dictionary <string, object> lstDicWhere      = (Dictionary <string, object>)miCreateWhereDictWithModifyFields.Invoke(entity, null);
                    blnUpdate = dal.UpdateEx(entity, LstModifyFields.Keys.ToList(), lstDicWhere);
                }
                else
                {
                    //普通修改
                    blnUpdate = dal.Update(entity, LstModifyFields == null ? null : LstModifyFields.Keys.ToList(), null);
                }

                if (pi != null)
                {
                    MethodInfo mi = entity.GetType().GetMethod("ClearRecord");
                    if (mi != null)
                    {
                        mi.Invoke(entity, null);
                    }
                }
                if (blnUpdate)
                {
                    return(ExcuteMessage.Sucess(entity));
                }
                else
                {
                    return(ExcuteMessage.Error("更新失败。"));
                }
            }
            catch (Exception ex)
            {
                return(ExcuteMessage.ErrorOfException(ex));
            }
        }
Beispiel #3
0
 /// <summary>
 /// 功能描述:查询一条单表数据
 /// </summary>
 /// <param name="strID">ID</param>
 /// <returns>数据对象</returns>
 public virtual string Select(string strID)
 {
     try
     {
         var entity = dal.QueryByID(strID);
         return(ExcuteMessage.Sucess(entity));
     }
     catch (Exception ex)
     {
         return(ExcuteMessage.ErrorOfException(ex));
     }
 }
Beispiel #4
0
 /// <summary>
 /// 功能描述:数据条数
 /// </summary>
 /// <param name="strWhere">strWhere</param>
 /// <returns>返回值</returns>
 public string SelectCount(string strWhere)
 {
     try
     {
         int intCount = dal.SelectCount(strWhere);
         return(ExcuteMessage.Sucess(intCount));
     }
     catch (Exception ex)
     {
         return(ExcuteMessage.ErrorOfException(ex));
     }
 }
Beispiel #5
0
 /// <summary>
 /// 功能描述:根据条件删除
 /// </summary>
 /// <param name="strWhere">strJson</param>
 /// <returns>返回值</returns>
 public virtual string DeleteByWhere(string strWhere)
 {
     try
     {
         dal.Delete(strWhere);
         return(ExcuteMessage.Sucess(true));
     }
     catch (Exception ex)
     {
         return(ExcuteMessage.ErrorOfException(ex));
     }
 }
Beispiel #6
0
 /// <summary>
 /// 功能描述:根据条件查询一条数据
 /// </summary>
 /// <param name="strWhere">条件</param>
 /// <returns>返回值</returns>
 public virtual string SelectByWhere(string strWhere)
 {
     try
     {
         var entity = dal.QueryEntity(strWhere);
         return(ExcuteMessage.Sucess(entity));
     }
     catch (Exception ex)
     {
         return(ExcuteMessage.ErrorOfException(ex));
     }
 }
Beispiel #7
0
 /// <summary>
 /// 功能描述:查询数据
 /// </summary>
 /// <param name="strSqlwhere">strSqlwhere</param>
 /// <returns>返回值</returns>
 public virtual string Search(string strSqlwhere)
 {
     try
     {
         List <TEntity> list = dal.QueryList(strSqlwhere);
         return(ExcuteMessage.Sucess(list));
     }
     catch (Exception ex)
     {
         return(ExcuteMessage.ErrorOfException(ex));
     }
 }
Beispiel #8
0
        /// <summary>
        /// 功能描述:删除数据
        /// </summary>
        /// <param name="strJson">strJson</param>
        /// <returns>返回值</returns>
        public virtual string Delete(string strJson)
        {
            TEntity entity = strJson.ToJsonObject <TEntity>();

            try
            {
                dal.Delete(entity);
                return(ExcuteMessage.Sucess(entity));
            }
            catch (Exception ex)
            {
                return(ExcuteMessage.ErrorOfException(ex));
            }
        }
Beispiel #9
0
        /// <summary>
        /// 功能描述:获取缓存数据
        /// </summary>
        /// <param name="strJson">strJson</param>
        /// <returns>返回值</returns>
        public string GetCacheSource(string strJson)
        {
            if (string.IsNullOrEmpty(strJson))
            {
                return(ExcuteMessage.Error("参数为空。"));
            }

            Dictionary <string, object> lstParas = strJson.ToJsonObject <Dictionary <string, object> >();
            string strProperty  = lstParas["Property"].ToString();
            string strTableName = lstParas["table"].ToString();
            string strWhere     = lstParas["where"].ToString();

            Type         type = Assembly.Load("JZ.Cache").GetType("JZ.Cache.CacheHelper");
            PropertyInfo pi   = type.GetProperty(strProperty);

            if (pi == null)
            {
                if (string.IsNullOrWhiteSpace(strTableName))
                {
                    return(ExcuteMessage.Sucess(new DataTable()));
                }
                //不存在缓存对象
                PublicRepository dal = new PublicRepository();
                DataTable        dt  = dal.GetTableByName(strTableName, strWhere);
                return(ExcuteMessage.Sucess(dt));
            }
            else if (pi.GetValue(null, null) == null)
            {
                if (string.IsNullOrWhiteSpace(strTableName))
                {
                    return(ExcuteMessage.Sucess(new DataTable()));
                }
                //缓存无值
                PublicRepository dal = new PublicRepository();
                DataTable        dt  = dal.GetTableByName(strTableName, strWhere);
                pi.SetValue(null, dt.ToJsonHasNull().ToJsonObject(pi.PropertyType), null);
                return(ExcuteMessage.Sucess(dt));
            }
            else
            {
                //返回缓存内容
                return(ExcuteMessage.Sucess(pi.GetValue(null, null)));
            }
        }
Beispiel #10
0
        public virtual string UpdateLst(string strJson)
        {
            List <TEntity> entity = strJson.ToJsonObject <List <TEntity> >();

            try
            {
                if (dal.Update(entity.ToArray()) > 0)
                {
                    return(ExcuteMessage.Sucess("更新成功"));
                }
                else
                {
                    return(ExcuteMessage.Error("更新失败。"));
                }
            }
            catch (Exception ex)
            {
                return(ExcuteMessage.ErrorOfException(ex));
            }
        }
Beispiel #11
0
        /// <summary>
        /// 功能描述:批量插入
        /// </summary>
        /// <param name="strJson">strJson</param>
        /// <returns>返回值</returns>
        public virtual string InsertLst(string strJson)
        {
            List <TEntity> entity = strJson.ToJsonObject <List <TEntity> >();

            try
            {
                if (dal.Insert(entity.ToArray()))
                {
                    return(ExcuteMessage.Sucess("新增成功"));
                }
                else
                {
                    return(ExcuteMessage.Error("新增失败。"));
                }
            }
            catch (Exception ex)
            {
                return(ExcuteMessage.ErrorOfException(ex));
            }
        }
Beispiel #12
0
        /// <summary>
        /// 功能描述:新增数据
        /// </summary>
        /// <param name="strJson">strJson</param>
        /// <returns>返回值</returns>
        public virtual string Insert(string strJson)
        {
            TEntity entity = strJson.ToJsonObject <TEntity>();

            try
            {
                if (dal.Insert(entity))
                {
                    return(ExcuteMessage.Sucess(entity));
                }
                else
                {
                    return(ExcuteMessage.Error("新增失败。"));
                }
            }
            catch (Exception ex)
            {
                return(ExcuteMessage.ErrorOfException(ex));
            }
        }
Beispiel #13
0
        public string PostSource(string strJson)
        {
            try
            {
                if (string.IsNullOrEmpty(strJson))
                {
                    return("传入参数为空!");
                }

                PostSourceEntity entity = strJson.ToJsonObject <PostSourceEntity>();
                string           str    = string.Empty;

                str = JZ.Server.PublicServer.CallFunction(entity);

                return(str);
            }
            catch (Exception ex)
            {
                return(ExcuteMessage.ErrorOfException(ex));
            }
        }
Beispiel #14
0
        private static void Rec(SocketHelper.Sockets sks)
        {
            if (sks.ex != null)
            {
                //string.Format("客户端出现异常:{0}.!", sks.ex.Message);
            }
            else
            {
                if (sks.NewClientFlag)
                {
                    //string.Format("新客户端:{0}连接成功.!", sks.Ip)
                }
                else
                {
                    byte[] buffer = new byte[sks.Offset];
                    Array.Copy(sks.RecBuffer, buffer, sks.Offset);
                    string str = string.Empty;
                    if (sks.Offset == 0)
                    {
                        str = "客户端下线";
                    }
                    else
                    {
                        str = Encoding.UTF8.GetString(buffer);
                        if (string.IsNullOrEmpty(str))
                        {
                            server.SendToClient(sks.Ip, ExcuteMessage.Error("传入参数为空!"));
                            return;
                        }

                        PostSourceEntity entity = str.ToJsonObject <PostSourceEntity>();
                        str = JZ.Server.PublicServer.CallFunction(entity);
                        server.SendToClient(sks.Ip, str);
                    }
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// 功能描述:反射调用方法
        /// </summary>
        /// <param name="source">source</param>
        /// <param name="action">推送广播</param>
        /// <returns>返回值</returns>
        public static string CallFunction(PostSourceEntity source)
        {
            try
            {
                Type type;
                if (string.IsNullOrEmpty(source.ClassTName))
                {
                    type = Assembly.Load("JZ.Server").GetType(string.Format("{0}.{1}", source.NameSpace, source.ClassName));
                }
                else
                {
                    type = Assembly.Load("JZ.Server").GetType(string.Format("{0}.{1}`1", source.NameSpace, source.ClassName));
                    Type typeArgument = Assembly.Load(source.TAssemblyName).GetType(source.ClassTName);

                    // MakeGenericType is badly named
                    type = type.MakeGenericType(typeArgument);
                }
                object obj = Activator.CreateInstance(type);
                if (obj == null)
                {
                    return(ExcuteMessage.Error("没有找到指定的逻辑对象。"));
                }

                object[]   parameters = null;
                MethodInfo method     = null;

                if (source.Parameters != null)
                {
                    method     = type.GetMethod(source.FunctionName, new Type[] { typeof(string) });
                    parameters = new object[] { source.Parameters };
                }
                else
                {
                    method = type.GetMethod(source.FunctionName, new Type[] { });
                }
                if (method == null)
                {
                    return(ExcuteMessage.Error("没有找到指定的函数。"));
                }
                if (string.IsNullOrEmpty(source.MethodTName))
                {
                    object objReturn = method.Invoke(obj, parameters);
                    if (objReturn != null)
                    {
                        return(objReturn.ToString());
                    }
                }
                else
                {
                    object objReturn = method.MakeGenericMethod(new Type[] { Assembly.Load(source.TAssemblyName).GetType(source.ClassTName) }).Invoke(obj, parameters);
                    if (objReturn != null)
                    {
                        return(objReturn.ToString());
                    }
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ExcuteMessage.ErrorOfException(ex));
            }
        }
Beispiel #16
0
 public string Test()
 {
     return(ExcuteMessage.Error("测试消息"));
 }
Beispiel #17
0
        /// <summary>
        /// 功能描述:数据库当前时间
        /// </summary>
        /// <returns>数据库当前时间</returns>
        public string GetDBTime()
        {
            DateTime dt = dal.GetDBTime();

            return(ExcuteMessage.Sucess(dt));
        }