예제 #1
0
        public IHttpActionResult GetSAPGetRegionsCopy()
        {
            SAPRFC objSAPRFC1 = new SAPRFC();

            try
            {
                return(Json(objSAPRFC1.GetRegions()));
            }
            catch (Exception ex)
            {
                string strErroFilePath = ConfigurationManager.AppSettings["ErrorFilePath"];
                WriteLog(strErroFilePath, ex.Message);
                return(Json(objSAPRFC1.GetRegions()));
            }
        }
예제 #2
0
        public async Task <List <SIISAPRegionDTO> > GetSAPRegions(string sharePointUrl)
        {
            SAPRFC objSAPRFCRegions = new SAPRFC();
            var    results          = new List <SIISAPRegionDTO>();

            try
            {
                var userToken = this.Request.Headers.Authorization.Parameter;
                var newToken  = await GetSharePointAccessToken(sharePointUrl, userToken);

                using (var context = new ClientContext(sharePointUrl))
                {
                    results = objSAPRFCRegions.GetRegions();
                    context.ExecutingWebRequest +=
                        (s, e) => e.WebRequestExecutor.WebRequest.Headers.Add(
                            "Authorization", "Bearer " + newToken);

                    var web  = context.Web;
                    var user = web.CurrentUser;
                    context.Load(user);
                    context.ExecuteQuery();
                }
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.Message);
                string strErroFilePath = ConfigurationManager.AppSettings["ErrorFilePath"];
                WriteLog(strErroFilePath, ex.Message);
            }

            return(results);
        }