Example #1
0
 public ActionResult Index(Message msg)
 {
     msg.SellerID = "";
     msg.UserID   = "";
     APIMethods.APIPost <Message>(msg, "Messages");
     return(View(msg));
 }
Example #2
0
        /// <summary>
        /// Query this method with the provided HTTP POST data
        /// </summary>
        /// <typeparam name="T">The subtype to deserialize (the deserialized type being <see cref="APIResult{T}"/>).</typeparam>
        /// <param name="method">The method to query</param>
        /// <param name="postData">The http POST data</param>
        /// <param name="transform">The XSL transform to apply, may be null.</param>
        /// <returns>The deserialized object</returns>
        private APIResult <T> QueryMethod <T>(APIMethods method, HttpPostData postData, XslCompiledTransform transform)
        {
            // Download
            string url    = GetMethodUrl(method);
            var    result = Util.DownloadAPIResult <T>(url, postData, transform);

            // On failure with a custom method, fallback to CCP
            if (ShouldRetryWithCCP(result))
            {
                return(s_ccpProvider.QueryMethod <T>(method, postData, transform));
            }

            // If the result is a character sheet, we store the result
            if (method == APIMethods.CharacterSheet && !result.HasError)
            {
                SerializableAPICharacterSheet sheet = (SerializableAPICharacterSheet)(Object)result.Result;
                LocalXmlCache.Save(sheet.Name, result.XmlDocument);
            }

            // If the result is a conquerable station list, we store the result
            if (method == APIMethods.ConquerableStationList && !result.HasError)
            {
                LocalXmlCache.Save(method.ToString(), result.XmlDocument);
            }

            // Returns
            return(result);
        }
Example #3
0
        /// <summary>
        /// Initializes paths, static objects, check and load datafiles, etc.
        /// </summary>
        /// <remarks>May be called more than once without causing redundant operations to occur.</remarks>
        public static void Initialize()
        {
            if (s_initialized)
            {
                return;
            }

            s_initialized = true;

            Trace("begin");

            // Network monitoring (connection availability changes)
            NetworkMonitor.Initialize();

            // APIMethods collection initialization (always before members instatiation)
            APIMethods.Initialize();

            // Members instantiations
            APIProviders        = new GlobalAPIProviderCollection();
            MonitoredCharacters = new GlobalMonitoredCharacterCollection();
            CharacterIdentities = new GlobalCharacterIdentityCollection();
            Notifications       = new GlobalNotificationCollection();
            Characters          = new GlobalCharacterCollection();
            Datafiles           = new GlobalDatafileCollection();
            APIKeys             = new GlobalAPIKeyCollection();
            EVEServer           = new EveServer();

            Trace("done");
        }
Example #4
0
        // GET: AuctionRoom
        public ActionResult Index(int id)
        {
            if (User.Identity.IsAuthenticated)
            {
                try
                {
                    List <AuctionRegistration> reglys = APIMethods.APIGetALL <List <AuctionRegistration> >("AuctionRegistrations");

                    Property model = APIMethods.APIGet <Property>(id.ToString(), "Properties");


                    foreach (AuctionRegistration reg in reglys)
                    {
                        if (model.PropertyID == reg.PropertyID && reg.BuyerId == User.Identity.GetUserId())
                        {
                            return(View(model));
                        }
                    }
                    return(RedirectToAction("RegisterForAuction", "Buyers", new { id = model.PropertyID }));
                }
                catch (Exception E)
                {
                    return(RedirectToAction("Create", "Buyers", new { id = 0 }));
                }
            }
            else
            {
                return(RedirectToAction("login", "account"));
            }
        }
        public ActionResult CreatePrivate(PrivateSellerData model)
        {
            model.UserID = User.Identity.GetUserId();
            if (ModelState.IsValid)
            {
                try
                {
                    var newData = new PrivateSeller
                    {
                        UserID    = model.UserID,
                        IDNumber  = model.IDNumber,
                        Signiture = model.Signiture,
                    };

                    newData.ProofOfResedence = FileController.PostFile(model.ProofOfResedence, "ProofOfResedence", "ProofOfResedence");

                    //Call Post Method
                    PrivateSeller ob = APIMethods.APIPost <PrivateSeller>(newData, "PrivateSellers");

                    return(RedirectToAction("AddAddress"));
                }
                catch (Exception E)
                {
                    throw new Exception(E.ToString());
                }
            }
            else
            {
                return(View());
            }
        }
Example #6
0
        public ActionResult <string> GetUser(int id)
        {
            string result = "";

            if (Program.errorStatus == PasswdErrors.PasswdError.NoError)
            {
                result = APIMethods.GetUser(Program.dataSet.Tables["UserTable"], id);
            }

            if (Program.errorStatus != PasswdErrors.PasswdError.NoError)
            {
                JObject jObject = PasswdErrors.errorHandler(Program.errorStatus);
                Response.StatusCode = (int)jObject["StatusCode"];

                result = jObject.ToString();
            }
            else if (result.Length == 0 || result == null)
            {
                Response.StatusCode = 404;
                JObject jObject = new JObject();

                jObject.Add("error", $"User with id {id} not found.");
                jObject.Add("error code", Response.StatusCode);

                result = jObject.ToString();
            }
            return(result);
        }
Example #7
0
        /// <summary>
        /// Initializes paths, static objects, check and load datafiles, etc.
        /// </summary>
        /// <remarks>May be called more than once without causing redundant operations to occur.</remarks>
        public static void Initialize()
        {
            if (s_initialized)
                return;

            s_initialized = true;

            Trace("begin");

            // Network monitoring (connection availability changes)
            NetworkMonitor.Initialize();

            //Set swagger global config
            Configuration.Default = new Configuration
            {
                BasePath = "https://esi.tech.ccp.is/",
                UserAgent = "EveMon - Development",
            };

            // APIMethods collection initialization (always before members instatiation)
            APIMethods.Initialize();

            // Members instantiations
            APIProviders = new GlobalAPIProviderCollection();
            MonitoredCharacters = new GlobalMonitoredCharacterCollection();
            CharacterIdentities = new GlobalCharacterIdentityCollection();
            Notifications = new GlobalNotificationCollection();
            Characters = new GlobalCharacterCollection();
            Datafiles = new GlobalDatafileCollection();
            APIKeys = new GlobalAPIKeyCollection();
            EVEServer = new EveServer();

            Trace("done");
        }
Example #8
0
        public ActionResult AddAddress(Address model)
        {
            if (ModelState.IsValid)
            {
                try
                {  //Call Post Method
                    Address objec = APIMethods.APIPost <Address>(model, "Addresses");

                    SellerAddress sAdd = new SellerAddress
                    {
                        AddressID = objec.AddressID,
                        UserID    = User.Identity.GetUserId()
                    };
                    APIMethods.APIPost <SellerAddress>(sAdd, "SellerAddresses");
                    return(RedirectToAction("Index"));
                }
                catch (Exception E)
                {
                    throw new Exception(E.ToString());
                }
            }
            else
            {
                return(View());
            }
        }
        public ActionResult CreateAuctioneer(AuctioneerView model)
        {
            model.UserID = User.Identity.GetUserId();
            if (ModelState.IsValid)
            {
                try
                {
                    var newData = new Auctioneer
                    {
                        UserID               = model.UserID,
                        CompanyName          = model.CompanyName,
                        Branch               = model.Branch,
                        CompanyContactNumber = model.CompanyContactNumber,
                        CompanyEmail         = model.CompanyEmail,
                        Signature            = model.Signature,
                        CompanyDescriprion   = model.CompanyDescriprion,
                    };

                    newData.CompanyLogo = FileController.PostFile(model.CompanyLogo, "CompanyLogo", "CompanyLogo");

                    //Call Post Method
                    Auctioneer ob = APIMethods.APIPost <Auctioneer>(newData, "Auctioneers");

                    return(RedirectToAction("AddAddress"));
                }
                catch (Exception E)
                {
                    throw new Exception(E.ToString());
                }
            }
            else
            {
                return(View());
            }
        }
Example #10
0
        /// <summary>
        /// Asynchrnoneously queries this method with the provided HTTP POST data
        /// </summary>
        /// <typeparam name="T">The subtype to deserialize (the deserialized type being <see cref="APIResult{T}"/>).</typeparam>
        /// <param name="method">The method to query</param>
        /// <param name="postData">The http POST data</param>
        /// <param name="callback">The callback to invoke once the query has been completed. It will be done on the data actor (see <see cref="DataObject.CommonActor"/>).</param>
        /// <param name="transform">The XSL transform to apply, may be null.</param>
        private void QueryMethodAsync <T>(APIMethods method, HttpPostData postData, XslCompiledTransform transform, QueryCallback <T> callback)
        {
            // Check callback not null
            if (callback == null)
            {
                throw new ArgumentNullException("The callback cannot be null.", "callback");
            }

            // Lazy download
            string url = GetMethodUrl(method);

            Util.DownloadAPIResultAsync <T>(url, postData, transform, (result) =>
            {
                // On failure with a custom method, fallback to CCP
                if (ShouldRetryWithCCP(result))
                {
                    result = s_ccpProvider.QueryMethod <T>(method, postData, transform);
                }

                // If the result is a character sheet, we store the result
                if (method == APIMethods.CharacterSheet && !result.HasError)
                {
                    SerializableAPICharacter sheet = (SerializableAPICharacter)(Object)result.Result;
                    LocalXmlCache.Save(sheet.Name, result.XmlDocument);
                }

                // Invokes the callback
                callback(result);
            });
        }
        // GET: Buyers
        public ActionResult Index(RegisteredBuyer model)
        {
            if (ModelState.IsValid)
            {
                return(View());
            }
            else
            {
                try
                {
                    RegisteredBuyer buyer = APIMethods.APIGet <RegisteredBuyer>(User.Identity.GetUserId(), "RegisteredBuyers");

                    return(View(buyer));
                }
                catch (Exception E)
                {
                    if (User.Identity.IsAuthenticated)
                    {
                        return(RedirectToAction("Create", "Buyers", new { id = 0 }));
                    }
                    else
                    {
                        return(RedirectToAction("Login", "Account"));
                    }
                }
            }
        }
        public ActionResult AddPhoto(int id, PropertyPhotoView file)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    PropertyPhoto model = new PropertyPhoto();
                    if (file != null)
                    {
                        model.PropertyId        = id;
                        model.Description       = file.Description;
                        model.Title             = file.Title;
                        model.PropertyPhotoPath = FileController.PostFile(file.PropertyPhotoPath, "propertyphotos", "propertyphotos");

                        //Call Post Method
                        APIMethods.APIPost <PropertyPhoto>(model, "PropertyPhotoes");
                        return(View());
                    }
                }
                catch (Exception E)
                {
                    throw new Exception(E.ToString());
                }



                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
        public ActionResult AddPromoVideo(int id, PromoVideoData file)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (file != null)
                    {
                        //Call Post Method
                        APIMethods.APIPost <PropertyPhoto>(file, "PropertyPhotoes");
                        return(RedirectToAction("Index"));
                    }
                }
                catch (Exception E)
                {
                    throw new Exception(E.ToString());
                }



                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
Example #14
0
        private void ConfigAndSetStartDateToRetrieve(ConnectionStringSettings configCS, int daysResend, out Stopwatch timerTokenRefresh, out APIMethods api, out GetLastResult _lastExportDate)
        {
            _config = new JobConfig
            {
                FarmaticConnectionString = configCS.ConnectionString,
                ProviderConnectionString = configCS.ProviderName,
                APIEndpoint           = ConfigurationManager.AppSettings["APIEndpoint"],
                APIUser               = ConfigurationManager.AppSettings["APIUser"],
                APIPwd                = ConfigurationManager.AppSettings["APIPwd"],
                JWTAuthRoute          = ConfigurationManager.AppSettings["APITokenEndpoint"],
                APIGetVentaData       = ConfigurationManager.AppSettings["APIGetVentaData"],
                APIPostVentaData      = ConfigurationManager.AppSettings["APIPostVentaData"],
                APIPostVentaDataRange = ConfigurationManager.AppSettings["APIPostVentaDataRange"],
                APICodUsuario         = ConfigurationManager.AppSettings["APICodUsuario"],
                DaysToResend          = daysResend,
                UseAPIRangeMethod     = bool.Parse(ConfigurationManager.AppSettings["UseAPIRangeMethod"])
            };

            // try webApi retrieve lastrecord to limit request
            timerTokenRefresh = new Stopwatch();
            timerTokenRefresh.Start();
            api = new APIMethods(_config);
            api.SetToken();
            if (api.TokenData == null)
            {
                throw new System.Exception($"Could not obtain token from WebAPI, endpoint root was {_config.APIEndpoint}");
            }

            // 2. Get 'last export date' (if I can add column: ExportDate, if not fallback to use FechaVenta) data from webAPI
            _lastExportDate = api.GetLastExportInfo();
            DateTime searchFrom = DateTime.Now;
        }
        public ActionResult AddPropertyStyled(Property model)
        {
            model.SellerID = User.Identity.GetUserId();

            bool   m     = ModelState.IsValid;
            string adddd = model.Address;

            if (ModelState.IsValid)
            {
                Property ob = APIMethods.APIPost <Property>(model, "Properties");

                try
                {
                    //Call Post Method
                    return(RedirectToAction("Index"));
                }
                catch (Exception E)
                {
                    throw new Exception(E.ToString());
                }
            }
            else
            {
                return(View());
            }
        }
Example #16
0
        private int PrepareLocalDbCommand(int daysResend, APIMethods api)
        {
            // 2. Get 'last export date' (if I can add column: ExportDate, if not fallback to use FechaVenta) data from webAPI
            var      _lastExportDate = api.GetLastExportInfo();
            DateTime searchFrom      = DateTime.Now;

            // 3. Get all records from a day before 'last export date' to now with SQL in pages of 20 records each
            if (_lastExportDate.Status == System.Net.HttpStatusCode.OK)
            {
                // searchFrom = searchFrom.AddDays(-1);
                var result = Math.Ceiling(DateTime.Now.Subtract(_lastExportDate.DateLastVenta).TotalDays);
                if (Config.DaysToResend < result)
                {
                    daysResend = int.Parse(Math.Ceiling(result).ToString());
                    Log($"Getting from {daysResend} days ago: {DateTime.Now.AddDays(daysResend * -1).ToString("yyyy-MM-dd")}.");
                }
                else
                {
                    Log($"Getting from {Config.DaysToResend} days ago: {DateTime.Now.AddDays(Config.DaysToResend * -1).ToString("yyyy-MM-dd")}.");
                }
            }
            else if (_lastExportDate.Status == System.Net.HttpStatusCode.NotFound)
            {
                // no hay registros, configurar para que envie todo (5 años)
                var dOld   = DateTime.Now.AddYears(-5);
                var result = DateTime.Now.Subtract(dOld);
                Log($"Getting all currrent records from {dOld.ToString("yyyy-MM-dd")}");
                daysResend = int.Parse(Math.Ceiling(result.TotalDays).ToString());
            }

            return(daysResend);
        }
Example #17
0
        private void SendVentaPage2API(Stopwatch timerTokenRefresh, APIMethods api, VentaDTOBatch ventaListJson)
        {
            string ventaToPostJson = JsonConvert.SerializeObject(ventaListJson);

            Debug.WriteLine($"Sending page of records: {ventaToPostJson}");

            var done = api.PostVentaPage(ventaListJson, out ListProcessResult result);

            if (!done)
            {
                var msg = $"ERROR enviando ventas en paginas.";
                Debug.WriteLine(msg);
                throw new Exception(msg);
            }
            else
            {
                Debug.WriteLine($"Send result info - Creates: {result.Creations}; Updates: {result.Updates}");
            }

            if (timerTokenRefresh.Elapsed.TotalMinutes > 4)
            {
                //refresh token
                Debug.WriteLine("Refreshing api token");
                api.SetToken();
                if (api.TokenData == null)
                {
                    throw new System.Exception($"Could not refresh token from WebAPI, endpoint root was {_config.APIEndpoint}");
                }
                else
                {
                    timerTokenRefresh.Restart();
                }
            }
        }
Example #18
0
        /// <summary>
        /// Query a method with the provided arguments for a character messages.
        /// </summary>
        /// <param name="userID">The account's ID</param>
        /// <param name="apiKey">The account's API key</param>
        /// <param name="messageID">The message ID.</param>
        /// <returns></returns>
        public void QueryMethodAsync <T>(APIMethods method, long userID, string apiKey, long characterID, long messageID, QueryCallback <T> callback)
        {
            HttpPostData postData = new HttpPostData(String.Format(
                                                         "userID={0}&apiKey={1}&characterID={2}&ids={3}", userID, apiKey, characterID, messageID));

            QueryMethodAsync <T>(method, postData, RowsetsTransform, callback);
        }
        public ActionResult AddBankGuarintee(int id, GuarinteeViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Guarintee newModel = new Guarintee
                    {
                        AuctionRegistrationID = id,
                        DateOfSubmition       = DateTime.Now
                    };
                    newModel.GuarinteePath = FileController.PostFile(model.GuarinteePath, "Guarintees", "guarintees");

                    //Call Post Method
                    APIMethods.APIPost <Guarintee>(newModel, "Guarintees");

                    int propID = APIMethods.APIGet <AuctionRegistration>(id.ToString(), "AuctionRegistrations").PropertyID;

                    return(RedirectToAction("Detailss", "home", new { id = propID }));
                }
                catch (Exception E)
                {
                    throw new Exception("Something went wrong. Please try again" + E.Message);
                }
            }
            else
            {
                return(View(model));
            }
        }
        // GET: Buyers/Create

        public ActionResult CreateAddress(int?id, Address model)
        {
            if (ModelState.IsValid)
            {
                try
                {  //Call Post Method
                    Address objec = APIMethods.APIPost <Address>(model, "Addresses");

                    BuyerAddress bAdd = new BuyerAddress();
                    bAdd.AddressID = objec.AddressID;
                    bAdd.UserID    = User.Identity.GetUserId();
                    APIMethods.APIPost <BuyerAddress>(bAdd, "BuyerAddresses");

                    if (id != 0)
                    {
                        return(RedirectToAction("Detailss", "home", new { id = id }));
                    }
                    return(RedirectToAction("Index"));
                }
                catch (Exception E)
                {
                    throw new Exception("Something went wrong. Please try again");
                }
            }
            else
            {
                return(View());
            }
        }
        public ActionResult AdPreApproval(int id, BankApprovalView model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    BankApproval newModel = new BankApproval
                    {
                        AuctionRegistrationID = id,
                        DateOfSubmision       = DateTime.Now
                    };
                    newModel.ApprovalPath = FileController.PostFile(model.ApprovalPath, "bankapprovals", "bankapprovals");

                    //Call Post Method
                    APIMethods.APIPost <BankApproval>(newModel, "BankApprovals");

                    int propID = APIMethods.APIGet <AuctionRegistration>(id.ToString(), "AuctionRegistrations").PropertyID;


                    return(RedirectToAction("Detailss", "home", new { id = propID }));
                }
                catch (Exception E)
                {
                    throw new Exception("Something went wrong. Please try again" + E.Message);
                }
            }
            else
            {
                return(View(model));
            }
        }
Example #22
0
        static void Main(string[] args)
        {
            Constants.ApiKey    = "";
            Constants.SecretKey = "";


            #region PublicAPI

            //Get Markets test
            List <Market> listOfMarkets = APIMethods.GetMarkets();

            //Get all supported currencies
            List <MarketCurrency> listOfCurrencies = APIMethods.GetCurrencies();

            //Get the current tick value for the specified market
            Ticker tick = APIMethods.GetTicker("BTC-LTC");

            //Gets the summary of all markets
            List <MarketSummary> listOfMarketSummaries = APIMethods.GetMarketSummaries();

            //Gets the summary of a specificed market
            MarketSummary marketSummary = APIMethods.GetMarketSummary("BTC-LTC");

            //Gets the Order book for the specified market
            OrderBook book = APIMethods.GetOrderBook("BTC-LTC", Order.Type.both);

            List <MarketHistory> marketHistory = APIMethods.GetMarketHistory("BTC-LTC");

            #endregion


            #region MarketAPI

            //APIMethods.PlaceBuyLimitOrder("BTC-LTC", 5, 0.17);

            // APIMethods.PlaceSellLimitOrder("BTC-LTC", 5, 0.17);

            APIMethods.CancelOrder("328bd88e-537e-4979-9d8b-d2e827d1a49e");

            // List<OpenOrder> orders = APIMethods.GetOpenOrders("BTC-GRS");

            #endregion

            #region AccountAPI

            //  List<Balance> balanceList = APIMethods.GetBalances();

            Balance balance = APIMethods.GetBalance("GRS");

            //APIMethods.Withdraw("GRS", 20.23222, "Address to withdraw GRS to");

            AccountOrder accountOrder = APIMethods.GetOrder("uuid here");

            List <HistoryOrder> listOfOrderHistory = APIMethods.GetOrderHistory();

            List <HistoryOrder> listOfSpecificOrderHistory = APIMethods.GetOrderHistory("BTC-LTC");


            #endregion
        }
        public override IList CreateArgumnets(APIMethods type)
        {
            creator = new ArgumentCreator();

            //to do

            return(creator.CreateArguments(type));
        }
Example #24
0
 /// <summary>
 /// Creates a set of API methods with their default urls.
 /// </summary>
 /// <returns></returns>
 public static IEnumerable <APIMethod> CreateDefaultSet()
 {
     foreach (string methodName in Enum.GetNames(typeof(APIMethods)))
     {
         APIMethods methodEnum = (APIMethods)Enum.Parse(typeof(APIMethods), methodName);
         string     methodURL  = NetworkConstants.ResourceManager.GetString("API" + methodName);
         yield return(new APIMethod(methodEnum, methodURL));
     }
 }
 public ActionResult Details(int id, Property model)
 {
     if (ModelState.IsValid)
     {
         return(View());
     }
     else
     {
         return(View(APIMethods.APIGet <Property>(id.ToString(), "Properties")));
     }
 }
Example #26
0
        /// <summary>
        /// Captures an Oculus Mirror screenshot.
        /// </summary>
        private void CaptureScreenshot()
        {
            Process[] processes = Process.GetProcessesByName("GalGun2-Win64-Shipping");
            Process   proc      = null;

            if (processes.Length > 0)
            {
                proc = processes[0];
            }
            else
            {
                return;
            }
            var rect = new WindowRect();

            APIMethods.GetClientRect(proc.MainWindowHandle, ref rect);

            int width  = rect.Right - rect.Left;
            int height = rect.Bottom - rect.Top;

            Bitmap   bmp       = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            Graphics graphics  = Graphics.FromImage(bmp);
            IntPtr   hdcBitmap = graphics.GetHdc();

            APIMethods.PrintWindow(proc.MainWindowHandle, hdcBitmap, 1);

            graphics.ReleaseHdc();
            graphics.Dispose();

            string picFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

            try
            {
                string targetFolder = picFolder + @"\GG2VR";
                if (!Directory.Exists(targetFolder))
                {
                    Directory.CreateDirectory(targetFolder);
                }

                DateTime dt   = DateTime.Now;
                string   fn   = dt.ToString("yyyy-MM-dd_HH-mm-ss", CultureInfo.InvariantCulture);
                int      add  = 1;
                string   addS = "";
                while (File.Exists(targetFolder + "\\" + fn + addS + ".png"))
                {
                    add++;
                    addS = add.ToString();
                }
                bmp.Save(targetFolder + "\\" + fn + addS + ".png", ImageFormat.Png);
            } catch (Exception ex)
            {
                //Apparently I'm not allowed to write the library. Ah well.
            }
        }
Example #27
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="method"></param>
        internal QueryMonitor(APIMethods method)
        {
            m_lastUpdate      = DateTime.MinValue;
            m_isFullKeyNeeded = method.HasAttribute <FullKeyAttribute>();
            m_methodHeader    = method.GetHeader();
            m_forceUpdate     = true;
            m_method          = method;
            m_enabled         = true;

            NetworkMonitor.Register(this);
        }
Example #28
0
        /// <summary>
        /// Disconnect from application.
        /// </summary>
        public void Disconnect()
        {
            if (!IsConnected())
            {
                return;
            }

            APIMethods.CloseHandle(this._handle);
            this._mainModuleAddress = 0;
            this._gcProcessHandle.Free();
            this._handle = IntPtr.Zero;
        }
Example #29
0
        /// <summary>
        /// Returns the request method
        /// </summary>
        /// <param name="requestMethod">An APIMethods enumeration member specfying the method for which the URL is required.</param>
        public APIMethod GetMethod(APIMethods requestMethod)
        {
            foreach (APIMethod method in m_methods)
            {
                if (method.Method == requestMethod)
                {
                    return(method);
                }
            }

            throw new InvalidOperationException();
        }
Example #30
0
        private IList <IDataScheme> SetFilter(IList <IDataScheme> schemes, APIMethods type)
        {
            IList <IDataScheme> filteredSchemes = new List <IDataScheme>();

            foreach (IDataScheme scheme in schemes)
            {
                if ((scheme.GetAssignment()).Contains(type))
                {
                    filteredSchemes.Add(scheme);
                }
            }
            return(filteredSchemes);
        }
Example #31
0
        /// <summary>
        /// Checks whether we should notify an error.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        internal bool ShouldNotifyError(IAPIResult result, APIMethods method)
        {
            // Notify an error occurred
            if (result.HasError)
            {
                // Checks if EVE Backend Database is temporarily disabled
                if (result.EVEBackendDatabaseDisabled)
                    return false;

                if (m_errorNotifiedMethod != APIMethods.None)
                    return false;

                m_errorNotifiedMethod = method;
                return true;
            }

            // Removes the previous error notification
            if (m_errorNotifiedMethod == method)
            {
                EveClient.Notifications.InvalidateCharacterAPIError(this);
                m_errorNotifiedMethod = APIMethods.None;
            }
            return false;
        }
Example #32
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="method"></param>
 /// <param name="path"></param>
 public APIMethod(APIMethods method, string path)
 {
     m_method = method;
     m_path = path;
 }
        /// <summary>
        /// Gets the available update periods for the given method.
        /// </summary>
        /// <param name="method"></param>
        /// <returns></returns>
        private List<UpdatePeriod> GetUpdatePeriods(APIMethods method)
        {
            List<UpdatePeriod> periods = new List<UpdatePeriod>();
            periods.Add(UpdatePeriod.Never);

            var updateAttribute = method.GetAttribute<UpdateAttribute>();
            int min = (int)updateAttribute.Minimum;
            int max = (int)updateAttribute.Maximum;

            foreach (UpdatePeriod period in Enum.GetValues(typeof(UpdatePeriod)))
            {
                if (period != UpdatePeriod.Never)
                {
                    int index = (int)period;
                    if (index >= min && index <= max)
                        periods.Add(period);
                }
            }

            return periods;
        }