示例#1
0
        public async Task <ActionResult <LogSingleton> > PostLogSingleton(LogSingleton logSingleton)
        {
            _context.LogSingleton.Add(logSingleton);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLogSingleton", new { id = logSingleton.LogId }, logSingleton));
        }
示例#2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            AppModel model = new AppModel();
            IConfigurationSection configurationSection = Configuration.GetSection(typeof(AppModel).Name);

            services.Configure <AppModel>(configurationSection);
            configurationSection.Bind(model);

            services.AddTransient <ILogSingleton, LogSingleton>(t => LogSingleton.GetLog(model.Path));

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
示例#3
0
        public HttpResponseMessage Dropbox(string challenge)
        //public ActionResult Dropbox(string challenge)
        {
            LogSingleton.Info(challenge);

            var resp = new HttpResponseMessage(HttpStatusCode.OK);

            resp.Content = new StringContent(challenge, System.Text.Encoding.UTF8, "text/plain");
            return(resp);

            //return Content(challenge);
            //  return challenge;
        }
示例#4
0
        public void _runActionId(ActionId nActionId)
        {
            uint id_ = nActionId._getId();

            if (mActions.ContainsKey(id_))
            {
                mActions[id_]._runActionId(nActionId);
            }
            else
            {
                LogSingleton logSingleton_ = __singleton <LogSingleton> ._instance();

                logSingleton_._logError(@"ActionMgr _runActionId ContainsKey");
                throw new Exception();
            }
        }
示例#5
0
        // public async Task<ActionResult> Dropbox()
        public HttpResponseMessage Dropbox()
        {
            LogSingleton.Info("dropbox start");

            // Get the request signature
            var signatureHeader = Request.Headers.GetValues("X-Dropbox-Signature");

            if (signatureHeader == null || !signatureHeader.Any())
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            // Get the signature value
            string signature = signatureHeader.FirstOrDefault();

            // Extract the raw body of the request
            string body = null;

            body = Request.Content.ReadAsStringAsync().Result;

            //using (StreamReader reader = new StreamReader(Request.InputStream))
            //{
            //    body = await reader.ReadToEndAsync();
            //}

            // Check that the signature is good
            string appSecret = ConfigurationManager.AppSettings["Dropbox_AppSecret"];

            using (HMACSHA256 hmac = new HMACSHA256(Encoding.UTF8.GetBytes(appSecret)))
            {
                if (!VerifySha256Hash(hmac, body, signature))
                {
                    //     return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                    return(this.Request.CreateResponse(HttpStatusCode.BadRequest));
                }
            }

            LogSingleton.Info(body);

            // Do your thing here... e.g. store it in a queue to process later
            // ...

            // Return A-OK :)
            //          return new HttpStatusCodeResult(HttpStatusCode.OK);
            return(this.Request.CreateResponse(HttpStatusCode.OK));
        }
示例#6
0
        public HttpResponseMessage GetFormWebhook()
        {
            string body = Request.Content.ReadAsStringAsync().Result;

            LogSingleton.Info(body);

            var platoformparser = new PlatoformParser();

            try
            {
                PlatoformsWebHookResponse response = JsonConvert.DeserializeObject <PlatoformsWebHookResponse>(body);

                using (var context = new ApplicationDbContext())
                {
                    platoformparser.AddToDB(context, 1, "id", response.PFProperty[0].id);
                    platoformparser.AddToDB(context, 1, "submit_date", response.PFProperty[0].submit_date);
                    platoformparser.AddToDB(context, 1, "submit_revision", response.PFProperty[0].submit_revision);
                    platoformparser.AddToDB(context, 1, "published_form_revision", response.PFProperty[0].published_form_revision);
                    platoformparser.AddToDB(context, 1, "submit_form_sharing_creator_url", response.PFProperty[0].submit_form_sharing_creator_url);
                    platoformparser.AddToDB(context, 1, "submit_form_url", response.PFProperty[0].submit_form_url);
                    platoformparser.AddToDB(context, 1, "form.id", response.PFProperty[0].form.id);
                    platoformparser.AddToDB(context, 1, "form.name", response.PFProperty[0].form.name);
                    platoformparser.AddToDB(context, 1, "workflow_id", response.PFProperty[0].workflow_id);
                    platoformparser.AddToDB(context, 1, "workflow_step_id", response.PFProperty[0].workflow_step_id);
                    platoformparser.AddToDB(context, 1, "workflow_next_step_url", response.PFProperty[0].workflow_next_step_url);
                    platoformparser.AddToDB(context, 1, "workflow_next_step_api_url", response.PFProperty[0].workflow_next_step_api_url);
                    platoformparser.AddToDB(context, 1, "pdf.id", response.PFProperty[0].pdf[0]?.id);
                    platoformparser.AddToDB(context, 1, "pdf.template_id", response.PFProperty[0].pdf[0]?.template_id);
                    platoformparser.AddToDB(context, 1, "pdf.display_name", response.PFProperty[0].pdf[0]?.display_name);
                    platoformparser.AddToDB(context, 1, "pdf.name", response.PFProperty[0].pdf[0]?.name);
                    platoformparser.AddToDB(context, 1, "pdf.url", response.PFProperty[0].pdf[0]?.url);

                    foreach (var data in response.PFProperty[0].submit_data)
                    {
                        platoformparser.AddToDB(context, 1, data.id, data.value);
                    }
                }
            }
            catch (Exception)
            {
                LogSingleton.Error($"Platoforms body didn't deserialize..... {body}");
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
示例#7
0
        bool _isActionId(ActionId nActionId)
        {
            bool result_ = false;
            uint id_     = nActionId._getId();

            if (mActions.ContainsKey(id_))
            {
                result_ = mActions[id_]._isActionId(nActionId);
            }
            else
            {
                LogSingleton logSingleton_ = __singleton <LogSingleton> ._instance();

                logSingleton_._logError(@"ActionMgr _isActionId ContainsKey");
                throw new Exception();
            }
            return(result_);
        }
示例#8
0
        public void Configuration(IAppBuilder app)
        {
            LogSingleton.Info("starting up");

            app.MapSignalR();
            // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=316888

            app.UseCors(CorsOptions.AllowAll);

            OAuthAuthorizationServerOptions option = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath         = new PathString("/token"),
                Provider                  = new ApplicationOAuthProvider(),
                AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(60),
                AllowInsecureHttp         = true
            };

            app.UseOAuthAuthorizationServer(option);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
        }
        public async Task <ActionResult <Sale> > PostSale(Sale sale)
        {
            sale.Product = _context.Product.Where(p => p.ProductId == sale.ProductId).SingleOrDefault();
            sale.User    = _context.Users.Where(u => u.UserId == sale.UserId).SingleOrDefault();

            _context.Sale.Add(sale);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (SaleExists(sale.SaleId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            LogSingleton            log           = new LogSingleton();
            LogSingletonsController logController = new LogSingletonsController(_context);

            log.LogDate   = DateTime.Now;
            log.LogType   = "Sale Completed";
            log.Product   = sale.Product;
            log.ProductId = sale.ProductId;
            log.Quantity  = sale.Quantity;
            log.User      = sale.User;
            log.UserId    = sale.UserId;

            await logController.PostLogSingleton(log);

            return(CreatedAtAction("GetSale", new { id = sale.SaleId }, sale));
        }
示例#10
0
 public Log4NetExceptionFilter()
 {
     _logger = LogSingleton.GetInstance().logError;
 }