Пример #1
0
        public void RunIndexingOn(string uuid)
        {
            try
            {
                SetNorwegianIndexCores();
                RemoveIndexDocument(uuid);

                SetEnglishIndexCores();
                RemoveIndexDocument(uuid);

                MD_Metadata_Type metadata = _geoNorge.GetRecordByUuid(uuid);

                if (metadata != null)
                {
                    SetNorwegianIndexCores();
                    MetadataIndexDoc metadataIndexDoc = _indexDocumentCreator.CreateIndexDoc(new SimpleMetadata(metadata), _geoNorge, Culture.NorwegianCode);
                    RunIndex(metadataIndexDoc, Culture.NorwegianCode);

                    SetEnglishIndexCores();
                    metadataIndexDoc = _indexDocumentCreator.CreateIndexDoc(new SimpleMetadata(metadata), _geoNorge, Culture.EnglishCode);
                    RunIndex(metadataIndexDoc, Culture.EnglishCode);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error in UUID: " + uuid + "", exception);
                _errorService.AddError(uuid, exception);
            }
        }
Пример #2
0
        public IHttpActionResult ArticleUpdated(ArticleStatus article)
        {
            HttpStatusCode statusCode;

            string Id     = article.Id;
            string status = article.Status;

            try
            {
                Log.Info("Received notification of updated article: Id=" + Id + ", status: " + status);

                if (!string.IsNullOrWhiteSpace(Id))
                {
                    Log.Info("Running single indexing of article with Id=" + Id);

                    _indexer.RunIndexingOn(Id);

                    statusCode = HttpStatusCode.OK;
                }
                else
                {
                    Log.Warn("Not indexing article - id was empty");
                    statusCode = HttpStatusCode.BadRequest;
                }
            }
            catch (Exception e)
            {
                Log.Error("Exception while indexing single article.", e);
                _errorService.AddError(Id, e);
                statusCode = HttpStatusCode.BadRequest;
            }
            return(StatusCode(statusCode));
        }
Пример #3
0
        public IHttpActionResult MetadataUpdated(FormDataCollection metadata)
        {
            HttpStatusCode statusCode;

            string action  = metadata.Get("action");
            string uuid    = metadata.Get("uuid");
            string XMLFile = metadata.Get("XMLFile");

            try
            {
                Log.Info("Received notification of updated metadata: " + action + ", uuid=" + uuid);

                if (!string.IsNullOrWhiteSpace(uuid))
                {
                    Log.Info("Running single indexing of metadata with uuid=" + uuid);

                    _indexer.RunIndexingOn(uuid);

                    statusCode = HttpStatusCode.OK;
                }
                else
                {
                    Log.Warn("Not indexing metadata - uuid was empty");
                    statusCode = HttpStatusCode.BadRequest;
                }
            }
            catch (Exception e)
            {
                Log.Error("Exception while indexing single metadata.", e);
                _errorService.AddError(uuid, e);
                statusCode = HttpStatusCode.BadRequest;
            }
            return(StatusCode(statusCode));
        }
        public void RunIndexingOn(string uuid)
        {
            try
            {
                SetNorwegianIndexCores();
                RemoveIndexDocument(uuid);

                var article = _articleFether.FetchArticleDocumentAsync(uuid, Culture.NorwegianCode).Result;

                if (article != null)
                {
                    ArticleIndexDoc articleIndexDoc = _indexDocumentCreator.CreateIndexDoc(article);
                    RunIndex(articleIndexDoc);
                }

                SetEnglishIndexCores();
                RemoveIndexDocument(uuid);

                article = _articleFether.FetchArticleDocumentAsync(uuid, Culture.EnglishCode).Result;

                if (article != null)
                {
                    ArticleIndexDoc articleIndexDoc = _indexDocumentCreator.CreateIndexDoc(article);
                    RunIndex(articleIndexDoc);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error in UUID: " + uuid + "", exception);
                _errorService.AddError(uuid, exception);
            }
        }
Пример #5
0
        // ReSharper disable once UnusedMember.Global
        public async Task EnterInRoom(string roomName, string password, string username)
        {
            roomName = NormalizeRoomName(roomName);
            username = ValidateString(username);
            var httpContext = Context.GetHttpContext();
            await _apiHealper.DoStandartSomething(async() =>
            {
                if (string.IsNullOrWhiteSpace(password))
                {
                    password = null;
                }
                else
                {
                    password = _hasher.GetHash(password);
                }


                if (string.IsNullOrEmpty(roomName))
                {
                    _errorService.AddError(_errorContainer.TryGetError(Consts.PlanitPokerErrorConsts.RoomNameIsEmpty));
                    await _apiHealper.NotifyFromErrorService();
                    await Clients.Caller.SendAsync(Consts.PlanitPokerHubEndpoints.ConnectedToRoomError);
                }

                var room = await _planitPokerService.TryGetRoom(roomName, password);
                if (room == null)
                {
                    throw new SomeCustomException(Consts.PlanitPokerErrorConsts.RoomNotFound);
                }

                UserInfo userInfo = null;
                var expired       = false;
                try
                {
                    (expired, userInfo) =
                        _apiHealper.GetUserInfoWithExpired(Context.GetHttpContext().Request, _jwtService, false);
                }
                catch
                {
                }

                if (expired && userInfo != null)
                {
                    //не прерываем процесс подключения, но сообщаем о том что нужен рефреш
                    await Clients.Caller.SendAsync(Consts.PlanitPokerHubEndpoints.NeedRefreshTokens);
                }

                var user = new PlanitUser()
                {
                    MainAppUserId    = userInfo?.UserId,
                    PlaningAppUserId = GenerateUniqueUserId(),
                    UserConnectionId = GetConnectionId(),
                    Name             = username,
                    Role             = GetDefaultRoles(),
                };

                _ = await EnterInRoom(room, user);
            }, httpContext.Response, _logger);
        }
Пример #6
0
        //public async Task DoStandartSomethingWithOutErrorResponse(Func<Task> action, HttpResponse response, ILogger logger)
        //{

        //}

        public virtual async Task DoStandartSomething(Func <Task> action, HttpResponse response, ILogger logger)
        {
            try
            {
                await action();

                return;
            }
            catch (SomeCustomException e)
            {
                ErrorFromCustomException(e);
            }
            catch (StopException)
            {
            }
            catch (NotAuthException)
            {
                var error = _errorContainer.TryGetError(ErrorConsts.NotAuthorized);
                if (error != null)
                {
                    _errorService.AddError(error);
                }

                await WriteResponseAsync(response, new ErrorObjectReturnFactory().GetObjectReturn(_errorService.GetErrorsObject()), 401);//TODO 401

                return;
            }
            catch (Exception e)
            {
                _errorService.AddError(_errorContainer.TryGetError(ErrorConsts.SomeError));
                logger?.LogError(e, ErrorConsts.SomeError);
            }

            await WriteResponseAsync(response, new ErrorObjectReturnFactory().GetObjectReturn(_errorService.GetErrorsObject()));
        }
Пример #7
0
        /// <summary>
        /// 根据uid 获取发型师别名信息
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public HariStyleList GetHariStyleListInfo(Guid uid)
        {
            var info = new List <HariStyleList>();

            try
            {
                info = _db.t_salinhairstylist.Where(a => a.shs_h_uid == uid)
                       .Select(a => new HariStyleList()
                {
                    Huid      = a.shs_h_uid,
                    Name      = a.shs_name,
                    Hairprice = a.shs_hairprice,
                    Exp       = a.shs_exp,
                    Cell      = a.shs_cell,
                    Uid       = a.shs_s_uid,
                    Logo      = a.shs_logo,
                    status    = a.shs_status
                }).ToList();
            }
            catch (Exception ex)
            {
                _err.AddError("GetHariStyleListInfo", ex.Message);
            }
            return(info.FirstOrDefault());
        }
Пример #8
0
        public int UpdateImageInfo(int id, string imagePath)
        {
            var info  = _db.t_salonimageinfo.Find(id);
            var count = 0;

            try
            {
                if (info != null)
                {
                    info.si_photo         = imagePath;
                    _db.Entry(info).State = EntityState.Modified;
                    count = _db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                _db.Entry(info).Reload();
                _err.AddError("", ex.Message);
            }
            return(count);
        }
Пример #9
0
        /// <summary>
        /// 获取订单表
        /// </summary>
        /// <returns></returns>
        public List <Order> GetOrderList(int pageindex, int pagesize, out int cou, out int pagcou)
        {
            var list = new PageOfItems <Order>()
            {
                PageNumber = pageindex, PageSize = pagesize
            };

            list.TotalItemCount = _db.t_order
                                  .OrderByDescending(a => a.o_date).Count();
            cou    = list.TotalItemCount;
            pagcou = list.TotalPageCount;
            var beginnum = (pageindex - 1) * pagesize;

            var info = new List <Order>();

            try
            {
                info = _db.t_order
                       .OrderByDescending(a => a.o_date)
                       .Skip(beginnum)
                       .Take(pagesize)
                       .Select(a => new Order()
                {
                    Id      = a.o_id,
                    Date    = a.o_date,
                    Money   = a.o_money,
                    Name    = a.o_name,
                    Orid    = a.o_orid,
                    Paydate = a.o_paydate,
                    Status  = a.o_status,
                    Suid    = a.o_s_uid
                }).ToList();
            }
            catch (Exception ex)
            {
                _err.AddError("GetOrderList", ex.Message);
            }
            return(info);
        }
Пример #10
0
 public Result <AgreementModel> GetAgreementModel(string uniqueId)
 {
     try {
         var agreementModel = _agreementRepository.GetAgreement(uniqueId);
         if (agreementModel == null)
         {
             Result <AgreementModel> result = new NotFoundResult <AgreementModel>("Agreement not found!");
             if (_errorService.AddError(uniqueId, result.ResultType, result.Errors, "Get") == false)
             {
                 Console.WriteLine("Error service failed");
             }
             return(result);
         }
         return(new SuccessResult <AgreementModel>(agreementModel));
     }
     catch (Exception e)
     {
         return(new UnexpectedResult <AgreementModel>());
     }
 }
Пример #11
0
        /// <summary>
        /// 添加 沙龙
        /// </summary>
        /// <param name="mod"></param>
        /// <returns></returns>
        public int AddSalon(SalonSimple mod)
        {
            int count = 0;
            var model = new t_salon()
            {
                s_cell         = mod.Cell,
                s_date         = mod.Date,
                s_email        = mod.Email,
                s_kind         = mod.Kind,
                s_logo         = mod.Logo,
                s_nickname     = mod.Nickname,
                s_pwd          = mod.Pwd,
                s_status       = mod.Status,
                s_uid          = mod.Uid,
                s_address      = mod.Address,
                s_linkname     = mod.LinkName,
                s_summary      = mod.Summary,
                s_lat          = mod.Lat,
                s_lon          = mod.Lon,
                s_price        = mod.Price,
                s_wxname       = mod.Wxname,
                s_businessdate = mod.Businessdate,
                s_recommend    = mod.Recommend
            };

            try
            {
                _db.t_salon.Add(model);
                return(_db.SaveChanges());
            }
            catch (Exception ex)
            {
                _db.t_salon.Remove(model);
                _err.AddError("AddSalon", ex.Message);
            }
            return(count);
        }
Пример #12
0
 public void LogException(ErrorDto error)
 {
     _errorService.AddError(error);
 }