示例#1
0
        public void TestMethodFile()
        {
            ContentLog con = new ContentLog(true, false, false);

            con.ContText  = "Prueba Mensaje";
            con.IdContent = 1;
            JobLogger job       = new JobLogger();
            bool      resultado = job.GenerateLog(con, true, false, false);
        }
示例#2
0
        /// <summary>
        /// 记录普通日志到数据库
        /// </summary>
        /// <param name="title"></param>
        /// <param name="log"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public BllResult <int?> LogContent(LogTitle logTitle, string log, string userCode, LogLevel flag)
        {
            ContentLog contentLog = new ContentLog();

            contentLog.Title     = logTitle.ToString();
            contentLog.Content   = log;
            contentLog.Flag      = flag.ToString();
            contentLog.Created   = DateTime.Now;
            contentLog.CreatedBy = userCode.ToString();
            return(AppSession.Dal.InsertCommonModel <ContentLog>(contentLog));
        }
示例#3
0
        public static async Task <string> SaveContentLog(List <SpContentLogModel> logs, long eventSettingId)
        {
            string result = "success";

            if (logs != null && logs.Count > 0)
            {
                List <ContentLog> contentLogs = new List <ContentLog>();
                Type source      = typeof(SpContentLogModel);
                Type destination = typeof(ContentLog);
                foreach (var item in logs)
                {
                    ContentLog obj = new ContentLog();
                    CopyHelper.Copy(source, item, destination, obj);
                    obj.ModifiedBy = obj.CreatedBy;
                    obj.ModifiedOn = DateTime.Now.ToUniversalTime();
                    contentLogs.Add(obj);
                }
                int count = await ColligoO365RMOManager <ContentLog> .SaveAsync(contentLogs);

                if (count > 0)
                {
                    //update settings with last execution date
                    result = await EventSettingManager.UpdateEventSetting(eventSettingId, logs[0].CreatedBy, logs[0].ExecutionTime, true);

                    //filter data for ADG process
                    List <ADGAgent> agent       = new List <ADGAgent>();
                    Type            agentsource = typeof(ADGAgent);
                    foreach (var item in contentLogs)
                    {
                        if (!string.IsNullOrEmpty(item.ComplianceTag) && item.EventColumnValue != null)
                        {
                            ADGAgent obj = new ADGAgent();
                            CopyHelper.Copy(destination, item, agentsource, obj);
                            obj.EventColumnValue = item.EventColumnValue.Value;
                            obj.IsProcessed      = false;
                            agent.Add(obj);
                            //agent.Add(new ADGAgent()
                            //{
                            //    ContentLogId = item.ContentLogId,
                            //     ComplainceAssetId=item.ComplainceAssetId,
                            //      ComplianceTag=item.ComplianceTag,
                            //       ContentType=item.ContentType
                            //});
                        }
                    }
                    if (agent.Count > 0)
                    {
                        count = await ColligoO365RMOManager <ADGAgent> .SaveAsync(agent);
                    }
                }
            }
            return(result);
        }
        public HttpResponseMessage Open(string path)
        {
            Log4Log.Info(Request.ToString());
            ContentLog.WriteLine(Request.ToString());

            var httpResponseMessage = Request.Response(path);

            Log4Log.Info(httpResponseMessage.ToString());
            ContentLog.WriteLine(httpResponseMessage.ToString());

            return(httpResponseMessage);
        }
示例#5
0
        /// <summary>
        /// 插入数据
        /// </summary>
        internal void InsertClickLog(ContentLog _entity)
        {
            string        sql = string.Format("insert into click_logs values (null,@time,@key,@title,@website);");
            SQLiteCommand cmd = new SQLiteCommand(sql, m_dbConnection);

            cmd.Parameters.Add(new SQLiteParameter("@time", _entity.ch_Time));
            cmd.Parameters.Add(new SQLiteParameter("@key", _entity.ch_Key));
            cmd.Parameters.Add(new SQLiteParameter("@title", _entity.ch_Title));
            cmd.Parameters.Add(new SQLiteParameter("@website", _entity.ch_Website));

            cmd.ExecuteNonQuery();
        }
        public HttpResponseMessage Index()
        {
            var path = Application.StartupPath;

            Log4Log.Info(Request.ToString());
            ContentLog.WriteLine(Request.ToString());

            var httpResponseMessage = Request.Response(path);

            Log4Log.Info(httpResponseMessage.ToString());
            ContentLog.WriteLine(httpResponseMessage.ToString());

            return(httpResponseMessage);
        }
示例#7
0
        /// <summary>
        /// 加载列表
        /// </summary>
        /// <param name="strData"></param>
        private void AfterSearchSimClick(string strData)
        {
            Monitor.Enter(CommonParameter.LokerObj);
            var  _dataList = JsonConvert.DeserializeObject <List <ListContent> >(strData);
            bool _is_click = false;

            foreach (ListContent singleContent in _dataList)
            {
                // 模拟点击
                if (singleContent.is_ad == ConstParameter.CLICK_AD)
                {
                    var sim = new InputSimulator();
                    sim.Mouse
                    .VerticalScroll(20)
                    .Sleep(CommonParameter.ConfigParam.simulate_speed.mouse_scroll.ToRandom());     // 先到最顶层  1 = 100px;

                    CommonFunction.SimMoveAndLefClick(singleContent.left, singleContent.top, true);

                    // 记录日志
                    var _tmpLog = new ContentLog();
                    _tmpLog.ch_Key     = CommonParameter.ConfigParam.key_match_list[_currentIndex].Key;
                    _tmpLog.ch_Website = singleContent.target;
                    _tmpLog.ch_Title   = singleContent.title;
                    OnWriteLog(_tmpLog, null);
                    _is_click = true;
                    break; // 一次搜索,只点击一次
                }
            }

            _currentIndex++;
            if (_is_click)
            {
                Monitor.Wait(CommonParameter.LokerObj); // 点击成功需要等待
                MyNextSearch(null, null);
            }

            Thread.Sleep(CommonParameter.ConfigParam.sleep_seconds.baidu_search.ToRandom());
            Cef.GetGlobalCookieManager().DeleteCookiesAsync(string.Empty, string.Empty);
            Monitor.Exit(CommonParameter.LokerObj);
            browser.Load(ConstParameter.SEARCH_ENGINES);
        }
        public HttpResponseMessage Download(string filePath)
        {
            Log4Log.Info(Request.ToString());
            ContentLog.WriteLine(Request.ToString());

            if (File.Exists(filePath) == false)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "文件未找到"));
            }
            var response = new HttpResponseMessage(HttpStatusCode.OK);
            var fileName = Path.GetFileName(filePath);

            try
            {
                var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                {
                    response.Content = new StreamContent(fileStream);
                    response.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/octet-stream");
                    response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                    {
                        FileName = fileName
                    };
                }

                Log4Log.Info(response.ToString());
                ContentLog.WriteLine(response.ToString());


                return(response);
            }
            catch (Exception exception)
            {
                var httpResponseMessage = Request.CreateErrorResponse(HttpStatusCode.NotFound, exception.Message);

                Log4Log.Info(httpResponseMessage.ToString());
                ContentLog.WriteLine(httpResponseMessage.ToString());

                return(httpResponseMessage);
            }
        }
示例#9
0
        public HttpResponseMessage Play(HttpRequestMessage request, string filePath)
        {
            Log4Log.Info(Request.ToString());
            ContentLog.WriteLine(Request.ToString());

            try
            {
                var assembly       = Assembly.GetExecutingAssembly();
                var resourceStream = assembly.GetManifestResourceStream("YYX.FileFinder.video.html");
                if (resourceStream == null)
                {
                    throw new Exception("页面异常");
                }
                var response = request.CreateResponse(HttpStatusCode.OK);
                using (var stream = new StreamReader(resourceStream))
                {
                    var html = stream.ReadToEnd();
                    var urlEncodeFilePath = HttpUtility.UrlEncode(filePath);
                    var videoLink         = $"/File/Download?filePath={urlEncodeFilePath}";
                    html = html.Replace("{videoLink}", videoLink);

                    response.Content = new StringContent(html, Encoding.UTF8);
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
                }

                Log4Log.Info(response.ToString());
                ContentLog.WriteLine(response.ToString());

                return(response);
            }
            catch (Exception exception)
            {
                var httpResponseMessage = Request.CreateErrorResponse(HttpStatusCode.NotFound, exception.Message);

                Log4Log.Info(httpResponseMessage.ToString());
                ContentLog.WriteLine(httpResponseMessage.ToString());

                return(httpResponseMessage);
            }
        }
示例#10
0
 internal void AddNewLog(ContentLog _newLog)
 {
     _newLog.ch_Time = DateTime.Now;
     _sqlite.InsertClickLog(_newLog);
     this.RefreshTable();
 }