Ejemplo n.º 1
0
        public void CallBack([FromBody] WebHookInfo webHookInfo)
        {
            try
            {
                //using (var context = new CreditAppContext())
                //{
                //    var creditDataEntity = context.CreditData.SingleOrDefault(x =>
                //        x.AdobeSignAgreementId == webHookInfo.agreement.id);
                //    if (creditDataEntity != null)
                //    {
                //        creditDataEntity.Status = webHookInfo.agreement.status;
                //        context.SaveChanges();
                //    }
                //}
                //log

                repository.AddAdobeSignLog(null, "UpdateCreditApplicationStatus", $"AgreementId={webHookInfo.agreement.id}", webHookInfo);
                ////repository.AddAdobeSignLog(null, "UpdateCreditApplicationStatus",null , webHookInfo);
                UpdateAllAgreementsStatuses();
            }
            catch (Exception e)
            {
                repository.AddAdobeSignLog(null, "UpdateCreditApplicationStatus", $"AgreementId={webHookInfo.agreement.id}", e);
                throw;
            }
        }
Ejemplo n.º 2
0
        public Task <bool> UpdateCreditApplicationStatus([FromBody] WebHookInfo webHookInfo)
        {
            using (var context = new CreditAppContext())
            {
                var creditDataEntity = context.CreditData.SingleOrDefault(x =>
                                                                          x.AdobeSignAgreementId == webHookInfo.agreement.id);
                if (creditDataEntity != null)
                {
                    creditDataEntity.Status = webHookInfo.Event;

                    context.Update(creditDataEntity);
                    context.SaveChanges();
                }
            }
            //log
            repository.AddAdobeSignLog("UpdateCreditApplicationStatus", $"AgreementId={webHookInfo.agreement.id}", webHookInfo.ToJson());

            return(Task.FromResult(true));
        }
Ejemplo n.º 3
0
        public void Initialize(IPluginService pluginService)
        {
            foreach (var plugin in pluginService.Plugins)
            {
                foreach (var assembly in plugin.Assemblies)
                {
                    if (plugin.Assemblies.Any(x => x.FullName == assembly.FullName))
                    {
                        foreach (Type type in assembly.GetTypes())
                        {
                            try
                            {
                                var methods = from method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly)
                                              where method.IsDefined(typeof(WebHookAttribute))
                                              select method;

                                foreach (MethodInfo method in methods)
                                {
                                    var arrtibutes = Attribute.GetCustomAttributes(method, false).Where(a => a is WebHookAttribute);
                                    foreach (WebHookAttribute attr in arrtibutes)
                                    {
                                        WebHookInfo whi = new WebHookInfo();
                                        whi.Instance   = new DynamicObjectCreater(type).CreateInstance();
                                        whi.Method     = method;
                                        whi.EntityName = attr.EntityName.ToLowerInvariant();
                                        whi.Name       = attr.Name.ToLowerInvariant();
                                        whi.Priority   = attr.Priority;

                                        Dictionary <string, List <WebHookInfo> > entityHooks;
                                        if (hooks.TryGetValue(whi.EntityName, out entityHooks))
                                        {
                                            List <WebHookInfo> hooksList;
                                            if (entityHooks.TryGetValue(whi.Name, out hooksList))
                                            {
                                                hooksList.Add(whi);
                                            }
                                            else
                                            {
                                                hooksList = new List <WebHookInfo>();
                                                hooksList.Add(whi);
                                                entityHooks.Add(whi.Name, hooksList);
                                            }
                                        }
                                        else
                                        {
                                            entityHooks = new Dictionary <string, List <WebHookInfo> >();
                                            List <WebHookInfo> hooksList = new List <WebHookInfo>();
                                            hooksList.Add(whi);
                                            entityHooks.Add(whi.Name, hooksList);
                                            hooks.Add(whi.EntityName, entityHooks);
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                throw new Exception("An exception is thrown while register web hooks for plugin : '" +
                                                    assembly.FullName + ";" + type.Namespace + "." + type.Name + "'", ex);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void AgreementNotificationPost(WebHookInfo webHookInfo)
 {
 }
Ejemplo n.º 5
0
        public void Initialize(IPluginService pluginService)
        {
            foreach (var plugin in pluginService.Plugins)
            {
                foreach (var assembly in plugin.Assemblies)
                {
                    if (plugin.Assemblies.Any(x => x.FullName == assembly.FullName))
                    {
                        foreach (Type type in assembly.GetTypes())
                        {
                            try
                            {
                                var methods = from method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly)
                                              where method.IsDefined(typeof(WebHookAttribute))
                                              select method;

                                foreach (MethodInfo method in methods)
                                {
                                    var arrtibutes = Attribute.GetCustomAttributes(method, false).Where(a => a is WebHookAttribute);
                                    foreach (WebHookAttribute attr in arrtibutes)
                                    {
                                        WebHookInfo whi = new WebHookInfo();
                                        whi.Instance = new DynamicObjectCreater(type).CreateInstance();
                                        whi.Method = method;
                                        whi.EntityName = attr.EntityName.ToLowerInvariant();
                                        whi.Name = attr.Name.ToLowerInvariant();
                                        whi.Priority = attr.Priority;

                                        Dictionary<string, List<WebHookInfo>> entityHooks;
                                        if (hooks.TryGetValue(whi.EntityName, out entityHooks))
                                        {
                                            List<WebHookInfo> hooksList;
                                            if (entityHooks.TryGetValue(whi.Name, out hooksList))
                                                hooksList.Add(whi);
                                            else
                                            {
                                                hooksList = new List<WebHookInfo>();
                                                hooksList.Add(whi);
                                                entityHooks.Add(whi.Name, hooksList);
                                            }
                                        }
                                        else
                                        {
                                            entityHooks = new Dictionary<string, List<WebHookInfo>>();
                                            List<WebHookInfo> hooksList = new List<WebHookInfo>();
                                            hooksList.Add(whi);
                                            entityHooks.Add(whi.Name, hooksList);
                                            hooks.Add(whi.EntityName, entityHooks);
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                throw new Exception("An exception is thrown while register web hooks for plugin : '" +
                                    assembly.FullName + ";" + type.Namespace + "." + type.Name + "'", ex);
                            }
                        }
                    }
                }
            }
        }