static DynamicWebServiceHelpers() {
        _webServiceHelper = new WebServiceHelper();
        _pluralizerHelper = new PluralizerHelper();
        _simpleXmlHelper = new SimpleXmlHelper();

        Ops.RegisterAttributesInjectorForType(typeof(XmlElement), new XmlElementAttributesInjector(), true);
        Ops.RegisterAttributesInjectorForType(typeof(WebServiceHelper), new WebServiceHelperAttributesInjector(), false);
        Ops.RegisterAttributesInjectorForType(typeof(string), new PluralizerAttributesInjector(), false);
    }
    public static IList<SymbolId> GetMemberNames(WebServiceHelper self)
    {
        List<string> providerNames = DynamicWebServiceHelpers.WebService.GetProviderNames();
        List<SymbolId> attrNames = new List<SymbolId>(providerNames.Count);

        foreach (string providerName in providerNames) {
            attrNames.Add(SymbolTable.StringToId("Load" + providerName));
        }

        return attrNames;
    }
    public static object GetBoundMember(WebServiceHelper self, string name)
    {
        if (name.StartsWith("Load", StringComparison.Ordinal)) {
            name = name.Substring("Load".Length);

            if (DynamicWebServiceHelpers.WebService.IsValidProviderName(name)) {
                return new CallableLoadHelper(name);
            }
        }

        return OperationFailed.Value;
    }
        /// <summary>
        /// Gets the information about all time series supported by the web service as a XML document
        /// in the WaterML format
        /// <param name="fullSiteCode">The full site code in NetworkPrefix:SiteCode format</param>
        /// </summary>
        /// <returns>the downloaded xml file name</returns>
        public string GetSiteInfoXML(string fullSiteCode)
        {
            //generate the file name
            string fileName = "Site-" + fullSiteCode + "-" + GenerateTimeStampString() + ".xml";

            fileName = fileName.Replace(":", "-");
            fileName = Path.Combine(DownloadDirectory, fileName);

            var req = WebServiceHelper.CreateGetSiteInfoRequest(_serviceURL, fullSiteCode);

            req.Timeout = _reqTimeOut * 1000;
            SaveWebResponseToFile(req, fileName);
            return(fileName);
        }
Example #5
0
        private async void ShowDiscussCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ViewSpot param = e.Parameter as ViewSpot;

            ViewComment.DetailShowItem = param;
            CurrentGrid = CurrentPanel.Comment;
            ViewMaster.DataItemListView.SelectedIndex = -1;

            if (ViewComment.DetailShowItem == null)
            {
                return;
            }

            string requestString = AppSettings["WEB_API_GET_COMMENT_INFO_BY_VIEW"] + "?viewid=" + ViewComment.DetailShowItem.id;

            //API返回内容
            string jsonString = string.Empty;

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(requestString, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["CommentInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(ObservableCollection <CommentInfo>));
                    ViewComment.CommentList = (ObservableCollection <CommentInfo>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            //检查数据
            for (int i = 0; i < ViewComment.CommentList.Count; i++)
            {
                ViewComment.CommentList[i].Spot = ViewComment.DetailShowItem;
                ViewComment.CommentList[i].CheckData();
            }
        }
        /// <summary>
        /// Creates a new instance of a WaterOneFlow web service client
        /// which communicates with the specified web service.
        /// </summary>
        /// <param name="serviceInfo">The object with web service information</param>
        /// <param name="reqTimeOut">Request timeout, in seconds</param>
        /// <param name="valuesPerReq">Number of values per request</param>
        /// <param name="allInOneRequest">All values in one request</param>
        /// <remarks>Throws an exception if the web service is not a valid
        /// WaterOneFlow service</remarks>
        public WaterOneFlowClient(DataServiceInfo serviceInfo, int reqTimeOut = 100, int valuesPerReq = 10000,
                                  bool allInOneRequest = false)
        {
            _serviceURL = serviceInfo.EndpointURL;

            _valuesPerReq        = valuesPerReq;
            _allInOneRequest     = allInOneRequest;
            _serviceInfo         = serviceInfo;
            _reqTimeOut          = reqTimeOut;
            _serviceInfo.Version = WebServiceHelper.GetWaterOneFlowVersion(_serviceURL);
            _parser = ParserFactory.GetParser(ServiceInfo);

            SaveXmlFiles = true; // for backward-compatibility
        }
Example #7
0
    public void InsertIndex(int queueId, string tag)
    {
        RequestData data = new RequestData();

        data.ServiceName = "InsertIndex";
        data.DocName     = tag;
        data.Sequence    = queueId;

        WebServiceHelper queueHelper = new WebServiceHelper();

        queueHelper.GoIntoQueueOld(data);

        log.DebugFormat("Invoke InsertIndex API by {0} - {1}", queueId, tag);
    }
    public static object GetBoundMember(WebServiceHelper self, string name)
    {
        if (name.StartsWith("Load", StringComparison.Ordinal))
        {
            name = name.Substring("Load".Length);

            if (DynamicWebServiceHelpers.WebService.IsValidProviderName(name))
            {
                return(new CallableLoadHelper(name));
            }
        }

        return(OperationFailed.Value);
    }
        public bool Publish(out List <string> publishDetails, BackgroundWorker bw = null)
        {
            publishDetails = new List <string>();
            string apiKey = Settings.GetApiKey();

            if (!string.IsNullOrEmpty(apiKey))
            {
                var priceLevelRepo  = new PriceLevelRepository(Settings.ConnectionString);
                var levelsToImport  = priceLevelRepo.GetAll().ToList();
                var existingLevels  = WebServiceHelper.GetExistingPricingLevels();
                var importCounter   = 0;
                var existingCounter = 0;

                foreach (var level in levelsToImport)
                {
                    if (existingLevels.Any(lvl => lvl.Name == level.Name))
                    {
                        existingCounter++;
                        continue;
                    }

                    var effectiveDate = level.EffectiveDate ?? DateTime.Now.ToUniversalTime();
                    if (level.EndDate < effectiveDate)
                    {
                        level.EndDate = null;
                    }
                    var request = new PricingLevelRequest
                    {
                        Name = level.Name,
                        ExternalReference = level.ExternalReference,
                        InventoryItems    = new List <PricingLevelItemRequest>(),
                        EffectiveDate     = effectiveDate,
                        EndDate           = level.EndDate
                    };

                    WebServiceHelper.PushPricingLevel(request);
                    importCounter++;
                }

                publishDetails.Insert(0,
                                      $"{existingCounter} price levels already existing in LinkGreen and were not pushed.");
                publishDetails.Insert(0, $"{importCounter} price levels have been pushed to LinkGreen");

                return(true);
            }

            Logger.Instance.Warning("No Api Key set while executing price level publish.");
            return(false);
        }
 public List <DeezerUserVM> GetRelatedArtist(string Id)
 {
     try
     {
         var request  = new RestRequest("/artist/" + Id + "/related", Method.GET);
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         var result = deserial.Deserialize <DeezerArtistSearch>(response);
         return(result.data);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public WebResponseContentModel <bool> DeleteEventMeeting(int eventMeetingID, int eventID)
        {
            WebResponseContentModel <bool> model = new WebResponseContentModel <bool>();

            try
            {
                model = GetResponseFromWebRequest <WebResponseContentModel <bool> >(WebServiceHelper.DeleteEventMeeting(eventMeetingID, eventID), "get");
            }
            catch (Exception ex)
            {
                model.ValidationErrorAppSide = ConcatenateExceptionMessage(ex);
            }

            return(model);
        }
 public List <DeezerTrack> GetPlaylistTrack(string Id)
 {
     try
     {
         var request  = new RestRequest("/playlist/" + Id + "/tracks", Method.GET);
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         var result = deserial.Deserialize <DeezerTrackSearch>(response);
         return(result.data);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public DeezerPlaylistVM GetPlaylist(string Id)
 {
     try
     {
         var request  = new RestRequest("/playlist/" + Id, Method.GET);
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         var result = deserial.Deserialize <DeezerPlaylistVM>(response);
         return(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public async Task <string> CreateProject(long userid, string name, string description)
        {
            string functionName = "create-project";
            string entityName   = "project";

            addtionalPath = @"request-json";

            string url = Broker.Server + "/" + pathToApi + entityName + "/" + functionName + "/" + addtionalPath + "/";

            string json = "{\"userid\":" + userid + ",\"name\":\"" + name + "\",\"description\":\"" + description + "\"}";

            string encodedParameters = WebServiceHelper.Encode(json);

            return(await BasicWebService.Call(url, Broker.UserName, Broker.Password, encodedParameters));
        }
        public WebResponseContentModel <bool> DeleteEmployee(int employeeID)
        {
            WebResponseContentModel <bool> model = new WebResponseContentModel <bool>();

            try
            {
                model = GetResponseFromWebRequest <WebResponseContentModel <bool> >(WebServiceHelper.DeleteSelectedEmployee(employeeID), "get");
            }
            catch (Exception ex)
            {
                model.ValidationErrorAppSide = ConcatenateExceptionMessage(ex);
            }

            return(model);
        }
Example #16
0
        public ActionResult WellList()
        {
            //通过webService获取活动井列表
            try
            {
                object result = WebServiceHelper.InvokeWebService("http://192.168.1.123/wds/WitsmlService.asmx", "GetActiveWellInfo", null);
                ViewBag.WellList = result as string[][];
            }
            catch (Exception ex)
            {
                throw new Exception("数据接口异常,原因:" + ex.Message);
            }

            return(View());
        }
Example #17
0
    public void InsertLineBreak(int queueId, string tag, int line)
    {
        RequestData data = new RequestData();

        data.ServiceName = "InsertLineBreak";
        data.DocName     = tag;
        data.Sequence    = queueId;
        data.IntParam    = line;

        WebServiceHelper queueHelper = new WebServiceHelper();

        queueHelper.GoIntoQueueOld(data);

        log.DebugFormat("Invoke InsertLineBreak API by {0} - {1}", queueId, tag);
    }
        public WebResponseContentModel <bool> ClientEmployeeExist(int clientID, int employeeID)
        {
            WebResponseContentModel <bool> model = new WebResponseContentModel <bool>();

            try
            {
                model = GetResponseFromWebRequest <WebResponseContentModel <bool> >(WebServiceHelper.ClientEmployeeExist(clientID, employeeID), "get");
            }
            catch (Exception ex)
            {
                model.ValidationErrorAppSide = ConcatenateExceptionMessage(ex);
            }

            return(model);
        }
Example #19
0
    public void InsertContent(int queueId, string tag, string text)
    {
        RequestData data = new RequestData();

        data.ServiceName = "InsertContent";
        data.Sequence    = queueId;
        data.DocName     = tag;
        data.StringParam = text;

        WebServiceHelper queueHelper = new WebServiceHelper();

        queueHelper.GoIntoQueueOld(data);

        log.DebugFormat("Invoke InsertContent API by {0} - {1}", queueId, tag);
    }
Example #20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string action       = "getticketlist";
         string companycode  = "GX1126";
         string key          = "eade9048bb984549b284c1a422335c20";
         string startairport = "SHA";
         string endairport   = "HKG";
         string startdate    = "2017-12-15";
         string sign         = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(action + companycode + key + startairport + endairport + startdate, "MD5").ToLower();
         string curl         = "http://api.trip258.com/jrinterticket.ashx?param={\"action\":\"" + action + "\",\"companycode\":\"" + companycode + "\",\"key\":\"" + key + "\",\"sign\":\"" + sign + "\",\"startairport\":\"" + startairport + "\",\"endairport\":\"" + endairport + "\",\"startdate\":\"" + startdate + "\",\"startcity\":\"\",\"endcity\":\"\",\"backdate\":\"\",\"cabin\":\"\",\"aircompany\":\"\",\"seatnum\":\"\",\"passtype\":\"\"}";
         string apiContent   = WebServiceHelper.SendPostRequest(curl, "");
     }
 }
 /// <summary>
 /// get current user's profile
 /// </summary>
 /// <param name="token"></param>
 /// <returns></returns>
 public DeezerUserVM GetCurrentUserprofile(AccessDetails token)
 {
     try
     {
         var request = new RestRequest("/user/me", Method.GET);
         request.AddParameter("access_token", token.AccessToken);
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         var result = deserial.Deserialize <DeezerUserVM>(response);
         return(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #22
0
        /// <summary>
        /// Gets the user's current location and
        /// </summary>
        private void GetLocationUpdate()
        {
            try
            {
                //Retrieve the device's current location
                location_manager = (LocationManager)GetSystemService(LocationService);
                location_helper  = new LocationHelper(location_manager);

                //Retrieve the single-day forcast for the current location
                web_helper = new WebServiceHelper(location_helper.Latitude, location_helper.Longitude);
            }
            catch (System.Exception ex)
            {
                error_logger.LogError("GetLocationUpdate", ex.GetType().ToString(), ex.Message, "Failure within web helper class", 001);
            }
        }
Example #23
0
    public void InsertObject(int queueId, string tag, string filename, byte[] s)
    {
        RequestData data = new RequestData();

        data.ServiceName = "InsertObject";
        data.DocName     = tag;
        data.Sequence    = queueId;
        data.StringParam = filename;
        // data.ObjectParam = s;

        WebServiceHelper queueHelper = new WebServiceHelper();

        queueHelper.GoIntoQueueOld(data);

        log.DebugFormat("Invoke InsertObject API by {0} - {1}", queueId, tag);
    }
Example #24
0
        /// <summary>
        /// Method to get OAuth token for authenticate user
        /// </summary>
        /// <param name="Code"></param>
        /// <returns></returns>
        public OAuthTokens GetTokensOAuth(string Code)
        {
            var request = new RestRequest("api/token", Method.POST);

            request.AddHeader("Content-Type", "application/json");
            request.AddParameter("client_id", consumerKey);
            request.AddParameter("client_secret", consumerSecret);
            request.AddParameter("grant_type", "authorization_code");
            request.AddParameter("code", Code);
            request.AddParameter("redirect_uri", RedirectURL);
            var response = WebServiceHelper.WebRequest(request, AccountApiURL);
            JsonDeserializer deserial = new JsonDeserializer();
            var result = deserial.Deserialize <OAuthTokens>(response);

            return(result);
        }
Example #25
0
        public string LBSRequest(LBSRequest lbr)
        {
            string response = "";

            try
            {
                string request = JSON.ObjectToJson(lbr);
                response = WebServiceHelper.InvokeWebService(SysParameters.LBSUrl, "RequestLocation", new object[] { request }).ToString();
                LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Info, "定位请求返回,response:" + response, new LogUtility.RunningPlace("BSSServerMsgHandler", "LBSRequest"), "业务运行信息");
            }
            catch (Exception ex)
            {
                LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Info, ex.Message, new LogUtility.RunningPlace("BSSServerMsgHandler", "LBSRequest"), "业务异常");
            }
            return(response);
        }
Example #26
0
    public byte[] ReceiveMDSMessage(byte[] bytesOfMessage)
    {
        var message = WebServiceHelper.DeserializeMessage(bytesOfMessage);

        try
        {
            var response = ProcessMDSMessage(message);
            return(WebServiceHelper.SerializeMessage(response));
        }
        catch (Exception ex)
        {
            var response = message.CreateResponseMessage();
            response.Result.Success    = false;
            response.Result.ResultText = "Error in ProcessMDSMessage method: " + ex.Message;
            return(WebServiceHelper.SerializeMessage(response));
        }
    }
Example #27
0
 public List <SpotifyArtist> GetArtistRelatedArtist(int socialId, string spotifyArtistId, AccessDetails token)
 {
     try
     {
         var Token   = TokenValidate(socialId, token);
         var request = new RestRequest("v1/artists/" + spotifyArtistId + "/related-artists", Method.GET);
         request.AddHeader("Authorization", "Bearer " + Token.AccessToken);
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         var result = deserial.Deserialize <SpotifyRelatedArtist>(response);
         return(result.artists);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #28
0
 public SpotifyUserPlaylists GetUserPlaylists(int socialId, string userId, AccessDetails token)
 {
     try
     {
         var Token   = TokenValidate(socialId, token);
         var request = new RestRequest("v1/users/" + userId + "/playlists", Method.GET);
         request.AddHeader("Authorization", "Bearer " + Token.AccessToken);
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         var result = deserial.Deserialize <SpotifyUserPlaylists>(response);
         return(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public List <DeezerPlaylistVM> UsersPlaylists(string query)
 {
     try
     {
         var request = new RestRequest("/user/me/playlists", Method.GET);
         //request.AddParameter("q", query);
         //request.AddParameter("limit", "12");
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         var result = deserial.Deserialize <DeezerPlaylistSearch>(response);
         return(result.data);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #30
0
 public SpotifyCategory GetCategory(int socialId, string categoryId, AccessDetails token)
 {
     try
     {
         var Token   = TokenValidate(socialId, token);
         var request = new RestRequest("v1/browse/categories/" + categoryId, Method.GET);
         request.AddHeader("Authorization", "Bearer " + Token.AccessToken);
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         var result = deserial.Deserialize <SpotifyCategory>(response);
         return(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
 /// <summary>
 /// Method to get user profile using access token and userId
 /// </summary>
 /// <param name="Token"></param>
 /// <param name="userId"></param>
 /// <returns></returns>
 public InstaUserList GetUserprofile(AccessDetails Token, string userId)
 {
     try
     {
         var request = new RestRequest("/v1/users/" + userId + "", Method.GET);
         request.AddParameter("format", "json");
         request.AddParameter("access_token", Token.AccessToken);
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         InstaUserProfile result   = deserial.Deserialize <InstaUserProfile>(response);
         return(result.data);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public static string GetAccessToken()
        {
            string  apiUrl = "https://oapi.dingtalk.com/gettoken?corpid=ding08a708c5272bc85d35c2f4657eb6378f&corpsecret=o4Ivoh4T7MfhOGf2wlIZmzrUih03dDw2OcvekuZOGUohFj-CvlyOej2DZHRx_-By";
            string  result = WebServiceHelper.HttpGet(apiUrl, null);
            JObject jObj   = JObject.Parse(result);
            //返回码
            string errcode = jObj["errcode"].ToString();
            //accessToken
            string accessToken = string.Empty;

            //获取成功
            if (errcode == "0")
            {
                accessToken = jObj["access_token"].ToString();
            }
            return(accessToken);
        }
 /// <summary>
 /// Method to get own follower list of instagram user
 /// </summary>
 /// <param name="SMId"></param>
 /// <param name="Token"></param>
 /// <returns></returns>
 public List <InstaUserList> GetUserFollower(long SMId, AccessDetails Token)
 {
     try
     {
         var request = new RestRequest("v1/users/self/follows", Method.GET);
         request.AddParameter("format", "json");
         request.AddParameter("access_token", Token.AccessToken);
         var response = WebServiceHelper.WebRequest(request, ApiURL);
         JsonDeserializer deserial = new JsonDeserializer();
         InstaUserFollow  result   = deserial.Deserialize <InstaUserFollow>(response);
         return(result.data);
     }
     catch (Exception)
     {
         throw;
     }
 }
 static DynamicWebServiceHelpers()
 {
     _webServiceHelper = new WebServiceHelper();
     _pluralizerHelper = new PluralizerHelper();
     _simpleXmlHelper = new SimpleXmlHelper();
 }