Exemplo n.º 1
0
        public bool UpdLoadLog(UploadClause logIds)
        {
            try
            {
                return Dal.UpLoadLog(logIds);
            }
            catch (Exception e)
            {

                LogManager.Instance.Log.Info(e.ToString());
            }
            return false;
        }
Exemplo n.º 2
0
 public bool UpLoadLog(UploadClause logIds)
 {
     return Bll.UpdLoadLog(logIds);
 }
Exemplo n.º 3
0
        private bool UpLoadLogFile(UploadClause clause)
        {
            if (clause.LogIds.Count == 0)
            {
                LogManager.Instance.Log.Info("没有符合条件的log!");
                return false;
            }
            LogManager.Instance.Log.Info("开始上传log!");
            string sql =
                string.Format(
                    "select t.auid,t.node_id,t.log_path,t.province_id from log_file_info t where t.auid in ({0})",
                    string.Join(",", clause.LogIds.Select(d => d.Value)));

            var logs = HelperDal.ExecuteAndGetInstanceList(sql, null, dr =>
            {
                return new LogEntity
                {
                    LogId = Convert.ToInt32(dr["auid"]),
                    NodeId = Convert.ToInt32(dr["node_id"]),
                    ProvinceId = Convert.ToInt32(dr["province_id"]),
                    UpLoadPath = dr["log_path"].ToString()
                };
            },ConfigureManager.Logsever.DbConnection);
            if (logs.Count == 0)
            {
                LogManager.Instance.Log.Info("log表里没有相关log");
                return false;
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();

            GetLogContent(logs);
            try
            {
                MoveFile(logs);
            }
            catch (Exception e)
            {
                LogManager.Instance.Log.Info(e.ToString());
                return false;
            }
            LogManager.Instance.Log.Info("上传成功!");
            return true;
        }
Exemplo n.º 4
0
        private bool ProcessDb(UploadClause clause)
        {
            #region

            string logIds = string.Join(",", clause.LogIds);

            string update =
                string.Format(
                    "update  {0}.work_sub_items t set t.is_upload=1 where t.ITEMS_ID in (select d.items_id from log_file_info d where d.auid in ({1}))",
                    GetSchem(), logIds);
            HelperDal.ExcecuteNoQureyWithoutTrans(update);
            string clientId = Guid.NewGuid().ToString();
            using (var con = HelperDal.GetConnection(clientId))
            {
                HelperDal.BeginTrans(clientId);
                try
                {
                    // HelperDal.ExcecuteNoQurey(del, con);

                    string checkSubItem =
                        string.Format(
                            "select count(t.log_id)  from {2}.work_sub_items t where t.work_id={0} and t.sub_group_id ={1} and t.is_upload=0",
                            clause.WorkId, clause.SubGroupId, GetSchem());
                    if (Convert.ToInt32(HelperDal.ExcecuteSalar(checkSubItem)) == 0)
                    {
                        DeleteReleatedWorkItems(clause.WorkId, clause.SubGroupId, clientId);
                    }
                    else
                    {
                        var delLog = string.Format(@"delete from work_report_log d where d.floors_code in
            (select distinct(t.floors_code) from work_report_log t where t.log_id in ({0}) )", logIds);
                        // var delLog = string.Format("delete   from work_report_log t where t.log_id in ({0}) ", logIds);

                        var deLogKpi =
                            string.Format(
                                "delete from work_report_log_kpi t where t.log_id in ({0})", logIds
                                );

                        HelperDal.ExcecuteNoQurey(delLog, con);
                        HelperDal.ExcecuteNoQurey(deLogKpi, con);
                    }
                    HelperDal.CommitTrans(clientId);
                }
                catch (Exception e)
                {
                    LogHelper.GetInstance().Error("清除数据出错", e);
                    HelperDal.RollBackTrans(clientId);
                }
                finally
                {
                    con.Close();
                }
            }
            return true;

            #endregion
        }
Exemplo n.º 5
0
        private bool AutoUpLoadLog(UploadClause clause)
        {
            if (!UpLoadLogFile(clause))
            {
                return false;
            }

            if (!ProcessDb(clause))
            {
                return false;
            }

            return true;
        }
Exemplo n.º 6
0
        public bool UpLoadLog(UploadClause clause)
        {
            LogManager.Instance.Log.Info("开始手动上传log");
            if (!UpLoadLogFile(clause))
            {
                LogManager.Instance.Log.Info("手动上传log失败");
                return false;
            }
            LogManager.Instance.Log.Info("手动上传log成功");

            ProcessDb(clause);

            return true;
        }