Пример #1
0
        public ScrapperReportViewModel SendAsync(WebTelegramReporter cls)
        {
            try
            {
                var msg = "";
                if (cls == null)
                {
                    return(null);
                }

                if (cls.Source == ENSource.Scrapper)
                {
                    msg = SendScrapperErrorToTelegramAsync(cls);
                }
                else if (cls.Source == ENSource.Building)
                {
                    msg = SendToTelegramAsync(cls);
                }

                WebTelegramMessage.GetReporter_bot().Send(msg);
                return(null);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                return(null);
            }
        }
Пример #2
0
        private void SendToTelegramAsync(ErrorLog err, Customers cust)
        {
            try
            {
                var message = $"Source:✨ #{err.Source.GetDisplay()} ✨ \r\n" +
                              $"Version:✏ {err.Version} ✏ \r\n" +
                              $"=========================== \r\n" +
                              $"ClassName: #{err.ClassName.Replace(" ", "_")} \r\n" +
                              $"FunctionName: #{err.FuncName.Replace(" ", "_")} \r\n" +
                              $"Type: {err.ExceptionType.Replace(" ", "_")} \r\n" +
                              $"Message: {err.ExceptionMessage} \r\n" +
                              $"Description: {err.Description}\r\n" +
                              $"=========================== \r\n" +
                              $"HardSerial: {err.HardSerial} \r\n" +
                              $"Customer:😉 #{(cust?.Name ?? "").Replace(" ", "_")} 😉 \r\n" +
                              $"Company:🏫 #{(cust?.CompanyName ?? "").Replace(" ", "_")} 🏫 \r\n" +
                              $"Tell1:📱 {cust?.Tell1 ?? ""} 📱 \r\n" +
                              $"Tell2:📱 {cust?.Tell2 ?? ""} 📱 \r\n" +
                              $"IP:🌐 {err.Ip} 🌐 \r\n" +
                              $"Date: {Calendar.MiladiToShamsi(err.Date)} \r\n" +
                              $"Time:🕟 {err.Time} 🕟 \r\n" +
                              $"https://aarad.ir/Arad-Manager/Home/Details/{err.Guid}";

                WebTelegramMessage.GetErrorLog_bot().Send(message);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Пример #3
0
        public async Task <ReturnedSaveFuncInfo> SendAsync(WebTelegramBuilding cls)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var tel = new WebTelegramMessage()
                {
                    ChatID      = cls.Channel,
                    ApiKey      = cls.BotApi,
                    ContactType = EnTelegramType.Channel
                };
                _ = Task.Run(() => tel.SendAsync(cls.Content));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Пример #4
0
        private void SendServerErrorToTelegramAsync(ErrorLog err)
        {
            try
            {
                var message = $"Source:✨ #{err.Source.GetDisplay()} ✨ \r\n" +
                              $"=========================== \r\n" +
                              $"ClassName: #{err.ClassName.Replace(" ", "_")} \r\n" +
                              $"FunctionName: #{err.FuncName.Replace(" ", "_")} \r\n" +
                              $"Type: {err.ExceptionType.Replace(" ", "_")} \r\n" +
                              $"Message: {err.ExceptionMessage} \r\n" +
                              $"Description: {err.Description}\r\n" +
                              $"=========================== \r\n" +
                              $"Date: {Calendar.MiladiToShamsi(err.Date)} \r\n" +
                              $"Time:🕟 {err.Time} 🕟 \r\n" +
                              $"https://aarad.ir/Arad-Manager/Home/Details/{err.Guid}";

                WebTelegramMessage.GetErrorLog_bot().Send(message);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Пример #5
0
        public async Task <UploadFiles> Post()
        {
            try
            {
                var       uploadPath = HttpContext.Current.Server.MapPath("~/BackUpFiles");
                Customers cus        = null;
                if (Request.Content.IsMimeMultipartContent())
                {
                    var hddSerial = Request.Headers.GetValues("hddSerial").FirstOrDefault();
                    if (!string.IsNullOrEmpty(hddSerial))
                    {
                        cus = db.Customers.FirstOrDefault(q => q.HardSerial == hddSerial);
                        if (cus == null)
                        {
                            return(null);
                        }
                        if (cus.isBlock || cus.isWebServiceBlock)
                        {
                            return(null);
                        }
                    }
                }

                var multipartFormDataStreamProvider = new UploadFileMultiparProvider(uploadPath);

                await Request.Content.ReadAsMultipartAsync(multipartFormDataStreamProvider);

                var localFileName = multipartFormDataStreamProvider
                                    .FileData.Select(multiPartData => multiPartData.LocalFileName).FirstOrDefault();

                var x = new UploadFiles
                {
                    FilePath   = localFileName,
                    FileName   = Path.GetFileName(localFileName),
                    FileLength = new FileInfo(localFileName).Length
                };
                var url = $"https://aarad.ir/BackUpFiles/{x.FileName}";
                db.BackUpLog.Add(new BackUpLog()
                {
                    Guid         = Guid.NewGuid(),
                    CustomerGuid = cus?.Guid ?? Guid.Empty,
                    CreateDate   = DateTime.Now,
                    FileName     = x.FileName,
                    FileLength   = (double)x.FileLength / 1000000,
                    URL          = url
                });
                db.SaveChanges();

                var msg = $"Customer:😉 #{(cus?.Name ?? "").Replace(" ", "_")} 😉 \r\n" +
                          $"Company:🏫 #{(cus?.CompanyName ?? "").Replace(" ", "_")} 🏫 \r\n" +
                          $"HardSerial: {cus?.HardSerial} \r\n" +
                          $"Tell1:📱 {cus?.Tell1 ?? ""} 📱 \r\n" +
                          $"Tell2:📱 {cus?.Tell2 ?? ""} 📱 \r\n" +
                          $"=========================== \r\n" +
                          $"FileName:✏ {x.FileName} ✏ \r\n" +
                          $"FileLength:✨ #{(double)x.FileLength / 1000000} MB ✨ \r\n" +
                          $"URL: {url}";
                WebTelegramMessage.GetBackUpLog_bot().Send(msg);
                return(x);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                return(null);
            }
        }