示例#1
0
        private static readonly String queryfailed_error_code = "602"; //query failed error code
        #endregion

        /*
         * /// <summary>
         * /// this function will retrieve the the details for a society based on a CUI
         * /// </summary>
         * /// <param name="cui">the CUI passed as a parameter</param>
         * /// <returns>the state of the connection</returns>
         * private static String AnafGetCui(String cui)
         * {
         *  //we check if we were pasted a cui and if it is valid
         *  if (String.IsNullOrEmpty(cui) || !ElementCheck.VerifyCIF(cui))
         *  {
         *      //if it isn't we retrurn the error code
         *      return input_error_code + ",input_empty_cui";
         *  }
         *  //if not we initialize a new client over the the web service
         *  RestClient client = new RestClient(anaf_ws);
         *  //with the client we also need to initialize a new request over the parameter and the post
         *  RestRequest request = new RestRequest(anaf_ws_platitor_tva, Method.POST);
         *  //we set the request format to JSON
         *  request.RequestFormat = DataFormat.Json;
         *  //and preset the date
         *  String date = DateTime.Now.ToString("yyyy-MM-dd");
         *  //finally we create the request parameters
         *  //the parameter needs to be a JSON value containing the date of the request and the CUI
         *  String req = "";
         *  req += String.Format(@"{{'cui': {1}, 'data':'{0}'}}", date, cui);
         *  //we repair the string value
         *  req = req.Replace("'", "\"");
         *  //and finally we finish the format
         *  req = "[" + req + "]";
         *  //before placing them to the request
         *  request.AddParameter("application/json", req, ParameterType.RequestBody);
         *  //we retrieve the API response
         *  IRestResponse data = client.Execute(request);
         *  //and return the JSON content of the response
         *  return data.Content;
         * }
         */

        public static String AnafGetCui(String cui, DateTime dateTime)
        {
            //we check if we were pasted a cui and if it is valid
            if (String.IsNullOrEmpty(cui) || !ElementCheck.VerifyCIF(cui))
            {
                return(String.Empty);
            }
            //if not we initialize a new client over the the web service
            RestClient client = new RestClient(anaf_ws);
            //with the client we also need to initialize a new request over the parameter and the post
            RestRequest request = new RestRequest(anaf_ws_platitor_tva[0], Method.POST)
            {
                //we set the request format to JSON
                RequestFormat = DataFormat.Json
            };
            //and preset the date format
            String date = dateTime.ToString("yyyy-MM-dd");
            //finally we create the request parameters
            //the parameter needs to be a JSON value containing the date of the request and the CUI
            String req = "";

            req += String.Format(@"{{'cui': {1}, 'data':'{0}'}}", date, cui);
            //we repair the string value
            req = req.Replace("'", "\"");
            //and finally we finish the format
            req = "[" + req + "]";
            //before placing them to the request
            request.AddParameter("application/json", req, ParameterType.RequestBody);
            //we retrieve the API response
            IRestResponse data = client.Execute(request);

            //and return the JSON content of the response
            return(data.Content);
        }
示例#2
0
        public void LoadFromList(IList source, ElementCheck isChecked)
        {
            Collection = source;

            lbxCollection.Items.Clear();
            foreach (object obj in Collection)
            {
                lbxCollection.Items.Add(obj.ToString(), isChecked(obj));
            }

            lbxCollection.SelectedIndex = 0;
        }