public async Task <JsonResult> Get(string kodekelurahan, string namakelurahan, string kodekecamatan, string namakecamatan, string kodecabang, string namacabang)
        {
            var watch = Stopwatch.StartNew();

            try
            {
                var param = new MasterKelurahanDto()
                {
                    KodeKelurahan = kodekelurahan,
                    NamaKelurahan = namakelurahan,
                    KodeKecamatan = kodekecamatan,
                    NamaKecamatan = namakecamatan,
                    KodeCabang    = kodecabang,
                    NamaCabang    = namacabang,
                };

                AppResponse.ResponseGetData(await kelurahanService.GetAll(param));
            }
            catch (Exception e)
            {
                AppResponse.ResponseErrorGetData(e.InnerException != null ? e.InnerException.Message : e.Message);
            }

            watch.Stop();
            AppResponse._result.execution_time = watch.ElapsedMilliseconds;
            return(new JsonResult(AppResponse._result));
        }
Exemple #2
0
        public async Task Invoke(HttpContext context)
        {
            if (context.Response.Headers["Token-Expired"] == "true")
            {
                context.Response.StatusCode = StatusCodes.Status403Forbidden;
                var resp = AppResponse.UnauthorizedUser("Authorization Rejection - Token-Expired");
                await context.Response.WriteAsync(JsonConvert.SerializeObject(resp, Formatting.Indented));


                // DO NOT CALL NEXT. THIS SHORTCIRCUITS THE PIPELINE
            }
            else if (context.Response.Headers["Token-Invalid"] == "true")
            {
                context.Response.StatusCode = StatusCodes.Status403Forbidden;
                var resp = AppResponse.UnauthorizedUser("Authorization Rejection - Token-Invalid");
                await context.Response.WriteAsync(JsonConvert.SerializeObject(resp, Formatting.Indented));
            }
            else if (context.Response.Headers["Token-Invalid-Signature"] == "true")
            {
                context.Response.StatusCode = StatusCodes.Status403Forbidden;
                var resp = AppResponse.UnauthorizedUser("Authorization Rejection - Token-Invalid-Signature");
                await context.Response.WriteAsync(JsonConvert.SerializeObject(resp, Formatting.Indented));
            }
            else
            {
                await _next(context);
            }
        }
        public AppResponse MantenimientoHistorico(List <IndicadorDetalleHistoricoLogic> listaIndicadorDetalle, List <VariableFormulaHistoricoLogic> listaVariables, string accion)
        {
            try
            {
                DataTable dtIndicadorDetalle = new DataTable();
                DataTable dtVariableFormula  = new DataTable();

                List <IndicadorDetalleHistorico> listaEntidadIndicadorDetalle = listaIndicadorDetalle.Cast <IndicadorDetalleHistorico>().ToList();
                List <VariableFormulaHistorico>  listaEntidadVariableFormula  = listaVariables.Cast <VariableFormulaHistorico>().ToList();
                dtIndicadorDetalle = Util.ConvertListToDatatable(listaEntidadIndicadorDetalle);
                dtVariableFormula  = Util.ConvertListToDatatable(listaEntidadVariableFormula);
                SQLServer.OpenConection();
                SQLServer.CreateCommand("MOV.USP_MANT_INDICADOR_DETALLE_HISTORICO", CommandType.StoredProcedure,
                                        SQLServer.CreateParameter("ACCION", SqlDbType.VarChar, accion),
                                        SQLServer.CreateParameter("VARIABLE_FORMULA_HISTORICO_TYPE", SqlDbType.Structured, dtVariableFormula),
                                        SQLServer.CreateParameter("INDICADOR_DETALLE_HISTORICO_TYPE", SqlDbType.Structured, dtIndicadorDetalle));
                using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection))
                {
                    oResponse = new GenericInstance <AppResponse>().readDataReader(oReader);
                }
            }
            catch (Exception ex)
            {
                oResponse.SetException(string.Format("{ 0}: { 1}.", System.AppDomain.CurrentDomain.FriendlyName, ex.Message));
            }
            return(oResponse);
        }
Exemple #4
0
        public async Task <JsonResult> Get(string koderayon, string namarayon, string kodearea, string namaarea, string kodewil, string namawilayah)
        {
            var watch = Stopwatch.StartNew();

            try
            {
                var param = new MasterRayonDto()
                {
                    KodeRayon   = koderayon,
                    NamaRayon   = namarayon,
                    KodeArea    = kodearea,
                    NamaArea    = namaarea,
                    KodeWil     = kodewil,
                    NamaWilayah = namawilayah,
                };

                AppResponse.ResponseGetData(await rayonService.GetAll(param));
            }
            catch (Exception e)
            {
                AppResponse.ResponseErrorGetData(e.InnerException != null ? e.InnerException.Message : e.Message);
            }

            watch.Stop();
            AppResponse._result.execution_time = watch.ElapsedMilliseconds;
            return(new JsonResult(AppResponse._result));
        }
Exemple #5
0
        public async Task <IActionResult> Delete(string rec_id)
        {
            var user = await unitOfWork.Users.DeleteByIdAsync(rec_id);


            return(AppResponse.Success());
        }
        public AppResponse Mantenimiento(List <IndicadorDetalleLogic> lista, List <VariableFormulaLogic> listaFormula, string accion)
        {
            try
            {
                DataTable dt = new DataTable();
                DataTable dtVariableFormula                  = new DataTable();
                List <IndicadorDetalle> listEntidad          = lista.Cast <IndicadorDetalle>().ToList();
                List <VariableFormula>  listaVariableFormula = listaFormula.Cast <VariableFormula>().ToList();
                dt = Util.ConvertListToDatatable(listEntidad);
                dtVariableFormula = Util.ConvertListToDatatable(listaVariableFormula);
                SQLServer.OpenConection();
                SQLServer.CreateCommand("MOV.USP_MANT_INDICADOR_DETALLE", CommandType.StoredProcedure,
                                        SQLServer.CreateParameter("ACCION", SqlDbType.VarChar, accion),
                                        SQLServer.CreateParameter("INDICADOR_DETALLE_TYPE", SqlDbType.Structured, dt),
                                        SQLServer.CreateParameter("VARIABLE_FORMULA_TYPE", SqlDbType.Structured, dtVariableFormula));

                using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection))
                {
                    oResponse = new GenericInstance <AppResponse>().readDataReader(oReader);
                }
            }
            catch (Exception ex)
            {
                oResponse.SetException(string.Format("{ 0}: { 1}.", System.AppDomain.CurrentDomain.FriendlyName, ex.Message));
            }
            return(oResponse);
            //return new AppResponse { Code = "S",Description= "Se registro exitosamente" };
        }
Exemple #7
0
 public VMUpload(int id, string path, string siteName)
 {
     this.id       = id;
     this.path     = path;
     this.response = null;
     this.siteName = siteName;
 }
Exemple #8
0
        public async Task <ActionResult <PaymentDetails> > GetPayment(string payID)
        {
            int merchantID = Authenticate();

            if (merchantID == -3)
            {
                return(new ObjectResult(HttpStatusCode.ExpectationFailed));
            }
            if (merchantID < 0)
            {
                return(new ObjectResult(HttpStatusCode.Unauthorized));
            }
            PaymentDetails paymentDetails;

            try
            {
                paymentDetails = unitOfWork.Payment.getPaymentDetails(merchantID, payID);
                return(AppResponse.Success(paymentDetails));
                // paymentDetails = await _paymentService.getPaymentDetails(merchantID, payID);
                // return Ok(paymentDetails);
            }
            catch (Exception ex)
            {
                return(Unauthorized(ex.Message));
            }
        }
        public AppResponse <SftpFile> getRemoteFileInfo(string remoteDir, string remoteFileName)
        {
            AppResponse <SftpFile> resp = new AppResponse <SftpFile>();

            try
            {
                sftp.ConnectionInfo.Timeout = TimeSpan.FromMinutes(30);
                sftp.Connect();
                SftpFile remoteFile = sftp.ListDirectory(remoteDir).Where(x => x.Name == remoteFileName).FirstOrDefault();
                if (remoteFile != null)
                {
                    resp.SetSuccess();
                    resp.setData(remoteFile);
                }
                else
                {
                    resp.SetFailure("File not found");
                    resp.responseCode = AppResponse <SftpFile> .NOT_FOUND;
                }
            }
            catch (Exception ex)
            {
                resp.SetFailure(ex.Message);
            }
            finally
            {
                sftp.Disconnect();
            }
            return(resp);
        }
Exemple #10
0
 public VMUpload()
 {
     this.id       = -1;
     this.path     = "";
     this.response = null;
     this.siteName = "";
 }
Exemple #11
0
        public IActionResult Guncelle(Kullanici param)
        {
            //if (!param.IsValid(true))
            //    return Content(AppResponse.Return(400));

            return(Content(AppResponse.Return(Kullanici.Guncelle(param))));
        }
        public async Task <IHttpActionResult> CreateApp([FromBody] AppInfo info, CancellationToken token)
        {
            CustomTrace.TraceInformation("[CreateApp] AppId={0}", info.AppId);

            var app = await this.Database.Apps.GetSingleAsync(info.AppId, token);

            if (app == null)
            {
                // todo: currently, app name equals app id.
                app = new AppEntity
                {
                    Id        = info.AppId,
                    Name      = info.AppId,
                    AppSecret = info.AppSecret,
                };

                await this.Database.Apps.InsertAsync(app, token);
            }

            var response = new AppResponse
            {
                AppId     = info.AppId,
                AppSecret = info.AppSecret
            };

            return(this.CreateSuccessResult(response));
        }
Exemple #13
0
        public async Task <IHttpActionResult> Create([FromBody] AppInfo info)
        {
            Logger.Info("App.Create AppId={0}", info.AppId);

            var app = await this.DatabaseContext.Bucket.GetByEntityIdSlimAsync <AppEntity>(info.AppId, false);

            if (app == null)
            {
                var appEntity = new AppEntity
                {
                    Id        = info.AppId,
                    AppSecret = info.AppSecret
                };

                await this.DatabaseContext.Bucket.InsertSlimAsync(appEntity);
            }

            var response = new AppResponse
            {
                AppId     = info.AppId,
                AppSecret = info.AppSecret
            };

            return(CreateSuccessResult(response));
        }
Exemple #14
0
        public override void Execute()
        {
            AppMapMarkers appMapMarkers = Pool.Get <AppMapMarkers>();

            appMapMarkers.markers = Pool.GetList <AppMarker>();
            RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(base.UserId);
            if (playerTeam != null)
            {
                foreach (ulong member in playerTeam.members)
                {
                    BasePlayer basePlayer = RelationshipManager.FindByID(member);
                    if (!(basePlayer == null))
                    {
                        appMapMarkers.markers.Add(GetPlayerMarker(basePlayer));
                    }
                }
            }
            else if (base.Player != null)
            {
                appMapMarkers.markers.Add(GetPlayerMarker(base.Player));
            }
            foreach (MapMarker serverMapMarker in MapMarker.serverMapMarkers)
            {
                if (serverMapMarker.appType != 0)
                {
                    appMapMarkers.markers.Add(serverMapMarker.GetAppMarkerData());
                }
            }
            AppResponse appResponse = Pool.Get <AppResponse>();

            appResponse.mapMarkers = appMapMarkers;
            Send(appResponse);
        }
Exemple #15
0
// ReSharper disable PossibleMultipleEnumeration
        public async Task RunAsync(IRestContext context)
        {
            ISystemApi systemApi = context.Factory.CreateSystemApi();

            // Read
            SqlQuery query = new SqlQuery {
                fields = "*", related = "services,roles",
            };
            IEnumerable <AppResponse> apps = await systemApi.GetAppsAsync(query);

            Console.WriteLine("Apps: {0}", apps.Select(x => x.api_name).ToStringList());

            // Cloning
            AppResponse todoApp        = apps.Single(x => x.api_name == "todoangular");
            AppRequest  todoAppRequest = todoApp.Convert <AppResponse, AppRequest>();

            todoAppRequest.name     = todoApp.name + "clone";
            todoAppRequest.api_name = todoApp.api_name + "clone";

            // Creating a clone
            apps = await systemApi.CreateAppsAsync(new SqlQuery(), todoAppRequest);

            AppResponse todoAppClone = apps.Single(x => x.api_name == "todoangularclone");

            Console.WriteLine("Created a clone app={0}", todoAppClone.api_name);

            // Deleting the clone
            Debug.Assert(todoAppClone.id.HasValue);
            await systemApi.DeleteAppsAsync(true, todoAppClone.id.Value);

            Console.WriteLine("Created clone has been deleted");
        }
Exemple #16
0
        public async Task <ActionResult <AppResponse <string> > > ScrapeAndSave()
        {
            AppResponse <string> appResponse = null;

            try
            {
                string msg = "Products are already exist in the database."; string result = "";
                if (!(await dbRepo.DataExists <Product>()))
                {
                    Product[] products = await scraping.GetData();

                    await dbRepo.AddRange(products);

                    await dbRepo.SaveChanges();

                    msg = ""; result = "ok";
                }
                appResponse = new AppResponse <string> {
                    Result = result, ErrorMessage = msg
                };
            }
            catch (Exception e)
            {
                appResponse = new AppResponse <string> {
                    ErrorMessage = e.Message
                };
            }
            return(appResponse);
        }
Exemple #17
0
        public async Task <ActionResult <AppResponse <Product[]> > > All()
        {
            if (!sc.IsAuthed(this))
            {
                return(Unauthorized());
            }

            AppResponse <Product[]> appResponse = null;

            try
            {
                Product[] products = await dbRepo.GetAll <Product>();

                string msg = products != null ? "" : "Products are not found";
                appResponse = new AppResponse <Product[]> {
                    Result = products, ErrorMessage = msg
                };
            }
            catch (Exception e)
            {
                appResponse = new AppResponse <Product[]> {
                    ErrorMessage = e.Message
                };
            }

            return(appResponse);
        }
Exemple #18
0
        public async Task <IActionResult> Authenticate([FromBody] LoginDto model)
        {
            if (string.IsNullOrEmpty(model.username) ||
                string.IsNullOrEmpty(model.password))
            {
                return(AppResponse.BadRequest("All fields are required"));
            }


            ModelValidator.Validate(model);
            string ipaddress    = Helper.getIPAddress(this.Request);
            var    authResponse = await authService.Authenticate(model, ipaddress);

            if (authResponse == null || authResponse.Token == null)
            {
                return(AppResponse.Unauthorized("Invalid Token"));
            }

            if (string.IsNullOrEmpty(authResponse.Token.AccessToken) || string.IsNullOrEmpty(authResponse.Token.RefreshToken))
            {
                return(AppResponse.Unauthorized("Invalid Token"));
            }

            setTokenCookie(authResponse.Token.RefreshToken);
            return(AppResponse.Success(authResponse));
        }
Exemple #19
0
        public AppServerApiController(UCenterDatabaseContext database)
            : base(database)
        {
            this.appConfigurationCacheProvider = new CacheProvider <AppConfigurationResponse>(
                TimeSpan.FromMinutes(5),
                async(key, token) =>
            {
                var appConfiguration = await this.Database.AppConfigurations.GetSingleAsync(key, token);

                var response = new AppConfigurationResponse
                {
                    AppId         = key,
                    Configuration = appConfiguration == null ? string.Empty : appConfiguration.Configuration
                };

                return(response);
            });
            this.appCacheProvider = new CacheProvider <AppResponse>(
                TimeSpan.FromMinutes(5),
                async(key, token) =>
            {
                var app      = await this.Database.Apps.GetSingleAsync(key, token);
                var response = new AppResponse
                {
                    AppId     = key,
                    AppSecret = app == null ? string.Empty : app.AppSecret
                };

                return(response);
            });
        }
Exemple #20
0
        public override void Execute()
        {
            RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(base.UserId);
            if (playerTeam == null)
            {
                SendError("no_team");
                return;
            }
            AppResponse appResponse = Pool.Get <AppResponse>();

            appResponse.teamChat          = Pool.Get <AppTeamChat>();
            appResponse.teamChat.messages = Pool.GetList <AppChatMessage>();
            IReadOnlyList <ChatLog.Entry> history = Server.TeamChat.GetHistory(playerTeam.teamID);

            if (history != null)
            {
                foreach (ChatLog.Entry item in history)
                {
                    AppChatMessage appChatMessage = Pool.Get <AppChatMessage>();
                    appChatMessage.steamId = item.SteamId;
                    appChatMessage.name    = item.Name;
                    appChatMessage.message = item.Message;
                    appChatMessage.color   = item.Color;
                    appChatMessage.time    = item.Time;
                    appResponse.teamChat.messages.Add(appChatMessage);
                }
            }
            Send(appResponse);
        }
Exemple #21
0
        public override void Execute()
        {
            if (_imageData == null)
            {
                SendError("no_map");
                return;
            }
            AppMap appMap = Pool.Get <AppMap>();

            appMap.width       = (uint)_width;
            appMap.height      = (uint)_height;
            appMap.oceanMargin = 500;
            appMap.jpgImage    = _imageData;
            appMap.background  = _background;
            appMap.monuments   = Pool.GetList <AppMap.Monument>();
            if (TerrainMeta.Path != null && TerrainMeta.Path.Landmarks != null)
            {
                foreach (LandmarkInfo landmark in TerrainMeta.Path.Landmarks)
                {
                    if (landmark.shouldDisplayOnMap)
                    {
                        Vector2         vector   = Util.WorldToMap(landmark.transform.position);
                        AppMap.Monument monument = Pool.Get <AppMap.Monument>();
                        monument.token = (landmark.displayPhrase.IsValid() ? landmark.displayPhrase.token : landmark.transform.root.name);
                        monument.x     = vector.x;
                        monument.y     = vector.y;
                        appMap.monuments.Add(monument);
                    }
                }
            }
            AppResponse appResponse = Pool.Get <AppResponse>();

            appResponse.map = appMap;
            Send(appResponse);
        }
        private Task HandleExceptionAsync(HttpContext context, Exception exception)
        {
            bool allowTraceDev = env.IsDevelopment();

            allowTraceDev = false;
            var message = ((allowTraceDev) ? exception.StackTrace : exception.Message);

            var statuscode = GetStatusCode(exception);

            if (exception.InnerException != null)
            {
                logger.LogError(exception, "Inner Exception : " + exception.InnerException.Message);
                message = message + (allowTraceDev ? exception.InnerException.StackTrace : exception.InnerException.Message);
            }

            if (exception is SqlException)
            {
                //resp = AppResponse.BadRequest("Server Error");
                logger.LogError(exception, "Sql Exception : " + exception.Message);
            }
            else if (exception is AppException)
            {
                statuscode = 400;
                logger.LogError(exception, "AppException : " + exception.Message);
            }
            else
            {
                logger.LogError(exception, "Unknown Exception : " + exception.Message);
            }
            context.Response.ContentType = "application/json";
            context.Response.StatusCode  = statuscode;
            var resp = AppResponse.SystemError(message);

            return(context.Response.WriteAsync(JsonConvert.SerializeObject(resp, Formatting.Indented)));
        }
Exemple #23
0
        public async Task <IActionResult> GetAll()
        {
            logger.LogInformation("called ProductController");
            var data = await unitOfWork.Products.GetAllAsync();

            return(AppResponse.Success(data));
        }
Exemple #24
0
        public async Task <IActionResult> Delete(int id)
        {
            await Task.Delay(3000);

            //await unitOfWork.Products.DeleteByIdAsync(id);
            return(AppResponse.Success());
        }
Exemple #25
0
        public async Task <AppResponse> ForecastByLocationIdAsync(int locationId)
        {
            var output = new AppResponse();

            try
            {
                var response = await _httpClient.GetStreamAsync(string.Format(_appSettings.WeatherForecast.Forecast, locationId));

                var weatherForecast = await JsonSerializer.DeserializeAsync <MetaWeatherForecast>(response);

                output.Status  = true;
                output.Message = "Forecast loaded!";
                output.Type    = ResponseType.Success;
                output.Data    = weatherForecast;
            }
            catch (Exception ex)
            {
                output.Status  = false;
                output.Type    = ResponseType.Error;
                output.Message = ex.Message;
                output.Data    = ex;
                output.Trace   = ex.StackTrace;
            }

            return(output);
        }
        public JsonResult Guardar(VMParametro formMantenimiento)
        {
            if (base.ModelState.IsValid)
            {
                formMantenimiento.parametro.UsuarioCreacion = formMantenimiento.parametro.UsuarioModificacion = Login.Obtener.Usuario.Login();
                formMantenimiento.parametro.Funcional       = false;

                if (formMantenimiento.parametro.InfoMovs.ACCION == Enums.Action.New)
                {
                    appResponse = _parametroAppService.MantenimientoNuevo(new List <ParametroLogic> {
                        formMantenimiento.parametro
                    });
                }
                else
                {
                    appResponse = _parametroAppService.MantenimientoEditar(new List <ParametroLogic> {
                        formMantenimiento.parametro
                    });
                }
            }
            else
            {
                appResponse = GetModelStateErrors();
            }
            return(Json(appResponse));
        }
Exemple #27
0
        private static async Task <string> GetResponseAsync(Func <Task <object> > getLogicData)
        {
            var logicResult = new AppResponse();

            try
            {
                logicResult.Data = await getLogicData?.Invoke();
            }
            catch (Exception ex)
            {
                //Log.Logger.Error(ex, "");

                logicResult.Flag    = 1;
                logicResult.Message = ex.Message;
                if (ex is AppException)
                {
                    logicResult.Code = (ex as AppException).Code.Id;
                }
                else
                {
                    logicResult.Code = ExceptionCode.UnknownError.Id;
                }
            }

            return(JsonConvert.SerializeObject(logicResult));
        }
        public async Task <JsonResult> Get(string kodegol, int?periodemulaiberlaku, string namagolongan, bool?status)
        {
            var watch = Stopwatch.StartNew();

            try
            {
                var param = new MasterGolonganDto()
                {
                    KodeGol             = kodegol,
                    NamaGolongan        = namagolongan,
                    PeriodeMulaiBerlaku = periodemulaiberlaku,
                    Status = status
                };

                AppResponse.ResponseGetData(await GolonganService.GetAll(param));
            }
            catch (Exception e)
            {
                AppResponse.ResponseErrorGetData(e.InnerException != null ? e.InnerException.Message : e.Message);
            }

            watch.Stop();
            AppResponse._result.execution_time = watch.ElapsedMilliseconds;
            return(new JsonResult(AppResponse._result));
        }
 public IActionResult Kaydet(GorevEvent param)
 {
     if (!param.IsValid(false))
     {
         return(Content(AppResponse.Return(400)));
     }
     return(Content(AppResponse.Return(GorevEvent.Olustur(param))));
 }
 public async Task <IActionResult> deleteProfileId(int?id)
 {
     if (id.HasValue)
     {
         var user = await unitOfWork.Users.DeleteByIdAsync(id.Value);
     }
     return(AppResponse.Success());
 }