Ejemplo n.º 1
0
        private CRMResponse OnlineTest(JObject entityObj)
        {
            if (!ValidateInput(entityObj))
            {
                return(OutputHelper.InvalidResponse(entityObj));
            }
            try
            {
                ServiceSetting setting = new ServiceSetting();
                setting.CRMVersion = "online";
                setting.MicrosoftAccountEnabled = true;
                setting.CrmResourceURL          = "https://mpctest.crm.dynamics.com/";
                setting.User     = "******";
                setting.Password = "******";

                setting.CacheAccountId = WebApiApplication.accountId;
                var crmRepositry = RepositryBase.CreateRepositry(setting);
                //crmRepositry.AssociateAccountId = WebApiApplication.accountId;

                crmRepositry.Execute(entityObj);
                WebApiApplication.accountId = crmRepositry.AssociateAccountId;

                return(OutputHelper.SuccessResponse(entityObj));
            }
            catch (Exception ex)
            {
                return(OutputHelper.FailedResponse(entityObj, ex));
            }
        }
Ejemplo n.º 2
0
        private CRMResponse OnpremTest(JObject entityObj)
        {
            if (!ValidateInput(entityObj))
            {
                return(OutputHelper.InvalidResponse(entityObj));
            }
            try
            {
                ServiceSetting setting = new ServiceSetting();
                setting.CRMVersion = "onprem";
                setting.MicrosoftAccountEnabled = false;
                setting.CrmResourceURL          = "https://azcrmuextwb01.partners.extranet.microsoft.com/OnePayrollUAT041115";
                setting.User     = "******";
                setting.Password = "******";

                var crmRepositry = RepositryBase.CreateRepositry(setting);

                crmRepositry.Execute(entityObj);

                return(OutputHelper.SuccessResponse(entityObj));
            }
            catch (Exception ex)
            {
                return(OutputHelper.FailedResponse(entityObj, ex));
            }
        }
Ejemplo n.º 3
0
        public CRMResponse Post([FromBody] object input)
        {
            ILog log = LogManager.GetLogger(typeof(ApiController));

            log.Info(string.Format("[Information]: Receive request. {0}", DateTime.Now.ToString()));
            var entityObj = input as JObject;

            if (!ValidateInput(entityObj))
            {
                return(OutputHelper.InvalidResponse(entityObj));
            }
            log.Info("[Information]: Validation complete.");

            try
            {
                ServiceSetting setting = new ServiceSetting();
                if (setting.MicrosoftAccountEnabled)
                {
                    setting.CacheAccountId = WebApiApplication.accountId;
                }
                var crmRepositry = RepositryBase.CreateRepositry(setting);
                //crmRepositry.AssociateAccountId = WebApiApplication.accountId;

                log.Info(string.Format("[Information]: Start processing to CRM. {0}", DateTime.Now.ToString()));
                crmRepositry.Execute(entityObj);
                if (setting.MicrosoftAccountEnabled)
                {
                    WebApiApplication.accountId = crmRepositry.AssociateAccountId;
                }

                log.Info(string.Format("[Information]: Finish processing to CRM. {0}", DateTime.Now.ToString()));
                return(OutputHelper.SuccessResponse(entityObj));
            }
            catch (Exception ex)
            {
                log.Info(string.Format("[Information]: Original Data. {0}", entityObj.ToString()));
                log = LogManager.GetLogger(ex.GetType());
                log.Error("[Exception]:", ex);

                return(OutputHelper.FailedResponse(entityObj, ex));
            }
        }