Overrides some of the functionality of the API_BASE to make compatible with serving from the web project Speciffically, skips HTTP Basic auth, and assumes that the website has delt with authorization. Takes a username in the constructor, in order to check permissions for later operations
Inheritance: vwar.service.host._3DRAPI_Imp
        public async void Notify(CoinProfit coinProfit, OrderN order)
        {
            foreach (var userId in userIdList.Where(u => u.Value))
            {
                string message = null;
                if (coinProfit.IsProfit == true)
                {
                    if (order != null && coinProfit.CoinName == "Deeponion")
                    {
                        var limit = APIWrapper.OrderSetLimit(order.location, order.algo, order.id, 100);
                        message = $"Мустафа, увеличили лимит. Рубим бабло. Монета {coinProfit.CoinName}, ProfitCountPercent={coinProfit.ProfitCountPercent:P2}, ProfitCountC1Percent={coinProfit.ProfitCountC1Percent:P2}";
                    }
                    else
                    {
                        message = $"Соломон, пора открывать ордер. Рубим бабло. Монета {coinProfit.CoinName}, ProfitCountPercent={coinProfit.ProfitCountPercent:P2}, ProfitCountC1Percent={coinProfit.ProfitCountC1Percent:P2}";
                    }
                }
                else if (coinProfit.OrderId > 0 && order != null)
                {
                    var limit = APIWrapper.OrderSetLimit(order.location, order.algo, order.id, 0.01);
                    message = $"Виталик, уменьшили лимит. Монета {coinProfit.CoinName}, ProfitCountPercent={coinProfit.ProfitCountPercent:P2}, ProfitCountC1Percent={coinProfit.ProfitCountC1Percent:P2}";
                }
                else
                {
                    message = $"Ахмед, ордера нет и профита тоже. Имей в виду. Монета {coinProfit.CoinName}, ProfitCountPercent={coinProfit.ProfitCountPercent:P2}, ProfitCountC1Percent={coinProfit.ProfitCountC1Percent:P2}";
                }

                if (_botNotify && !string.IsNullOrEmpty(message))
                {
                    await _bot.SendTextMessageAsync(userId.Key, message);
                }
            }
        }
Ejemplo n.º 2
0
    private void StartLogin()
    {
        if (username.text != "" && address.text != "" && password.text != "")
        {
            // Debug.LogFormat("Username: {0}\nAddress: {1}\nPassword: {2}", username.text, address.text, password.text);

            StartCoroutine(APIWrapper.getPlayer(username.text, (existingPlayerQuery) => {
                if (existingPlayerQuery == null)
                {
                    // Debug.LogFormat("Create new player");

                    StartCoroutine(APIWrapper.geocodeAddress(address.text, (geocodeResponse) => {
                        // If address was successfully geocoded as GPS coordinates.
                        if (geocodeResponse != null && geocodeResponse["message"] == null && geocodeResponse["features"].Count > 0)
                        {
                            // Debug.LogFormat("Geocoding: {0}", geocodeResponse.ToString());
                            double lat = geocodeResponse["features"][0]["center"][1];
                            double lon = geocodeResponse["features"][0]["center"][0];
                            StartCoroutine(APIWrapper.createPlayer(username.text, password.text, lat, lon, (createPlayerQuery) => {
                                if (createPlayerQuery != null)
                                {
                                    SavePlayerPrefsAndLoadOverworld();
                                }
                            }));
                        }
                    }));
                }
                else
                {
                    SavePlayerPrefsAndLoadOverworld();
                }
            }));
        }
    }
Ejemplo n.º 3
0
        public Config GetConfig(uint hash, ConfigType cfgType)
        {
            CheckValidity();
            IntPtr ptr = APIWrapper.Level_GetConfig(NativeInstance, (uint)cfgType, hash);

            return(RegisterChild(FromNative <Config>(ptr)));
        }
Ejemplo n.º 4
0
    public static bool UpdateScreenshot(string pid, string newfilename)
    {
        APIWrapper api = null;

        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
        {
            api = new APIWrapper(Membership.GetUser().UserName, null);
        }
        else
        {
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);
        }

        bool response = false;

        try
        {
            using (FileStream stream = new FileStream(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename)), FileMode.Open))
            {
                byte[] data = new byte[stream.Length];
                stream.Read(data, 0, (int)stream.Length);
                string result = api.UploadScreenShot(data, pid, newfilename, "00-00-00");
                if (result == "Ok")
                {
                    response = true;
                }
            }
            File.Delete(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename)));
        }
        catch (System.IO.FileNotFoundException t)
        {
        }
        return(response);
    }
Ejemplo n.º 5
0
        private async Task SetOvSpeedAsync()
        {
            FormPleaseWait pleaseWait = new FormPleaseWait();

            try
            {
                pleaseWait.StartPosition = FormStartPosition.CenterScreen;
                pleaseWait.Show();
            }
            catch (Exception ex) { Console.WriteLine(ex); }

            bool needDelay = false;

            OrderContainer[] Orders = OrderContainer.GetAll();
            for (int i = Orders.Length - 1; i >= 0; i--)
            {
                if (Orders[i].Algorithm == AlgorithmComboBox.SelectedIndex)
                {
                    if (Orders[i].OrderStats != null)
                    {
                        if (needDelay)
                        {
                            await Task.Delay(2000);
                        }
                        OrderContainer.SetLimit(i, Convert.ToDouble(OvSpeedTextBox.Text));
                        APIWrapper.OrderSetLimit(Orders[i].ServiceLocation, Orders[i].Algorithm, Orders[i].ID, Convert.ToDouble(OvSpeedTextBox.Text));
                        needDelay = true;
                    }
                }
            }
            try { pleaseWait.Close(); }
            catch (Exception ex) { Console.WriteLine(ex); }

            Refresh();
        }
Ejemplo n.º 6
0
    public static UpdateDetailsResponse UpdateDetails(string polys, string textures, string format, string pid)
    {
        APIWrapper api = null;

        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
        {
            api = new APIWrapper(Membership.GetUser().UserName, null);
        }
        else
        {
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);
        }


        vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00");

        md.NumPolygons = polys;
        md.NumTextures = textures;
        md.Format      = format;

        string result = api.UpdateMetadata(md, pid, "00-00-00");
        UpdateDetailsResponse response = new UpdateDetailsResponse(result == "Ok");

        response.polys    = md.NumPolygons;
        response.textures = md.NumTextures;
        response.format   = md.Format;

        return(response);
    }
Ejemplo n.º 7
0
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormSettings FS = new FormSettings(SettingsContainer.Settings.APIID, SettingsContainer.Settings.APIKey, SettingsContainer.Settings.TwoFactorSecret);

            if (FS.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SettingsContainer.Settings.APIID           = FS.ID;
                SettingsContainer.Settings.APIKey          = FS.Key;
                SettingsContainer.Settings.TwoFactorSecret = FS.TwoFASecret;
                SettingsContainer.Commit();

                if (SettingsContainer.Settings.TwoFactorSecret.Length > 0)
                {
                    APIWrapper.TwoFASecret = SettingsContainer.Settings.TwoFactorSecret;
                }
                else
                {
                    APIWrapper.TwoFASecret = null;
                }

                if (APIWrapper.Initialize(SettingsContainer.Settings.APIID.ToString(), SettingsContainer.Settings.APIKey))
                {
                    BalanceRefresh_Tick(sender, e);
                }
            }
        }
Ejemplo n.º 8
0
 public void ShutDownApplication()
 {
     GeneralTimer.GeneralTimerInstance.StopGeneralTimer();
     APIWrapper.DisconnectFromBroker();
     Logger.InfoFormat("ShutDown Application! ");
     //TOADO add another shutdown actions:
 }
Ejemplo n.º 9
0
        public Config FindConfig(ConfigType type, uint nameHash = 0)
        {
            CheckValidity();
            IntPtr ptr = APIWrapper.Container_GetConfig(NativeInstance, (uint)type, nameHash);

            return(RegisterChild(FromNative <Config>(ptr)));
        }
Ejemplo n.º 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void _watchers_IssueFound(object sender, PrinterIssueEventArgs e)
 {
     LogHelper.LogDebug();
     try
     {
         if (e != null)
         {
             PrinterTrouble pt = e.Issue;
             LogHelper.LogDebug(pt.Issue());
             if (pt != PrinterTrouble.None)
             {
                 APIWrapper.PrinterIssue(e.PrinterName, pt);
                 Notifier.Error(string.Format("Document can't be printed because of printer issue : {1}.{0}Administration has been notified about this issue.", Environment.NewLine, pt.Issue()));
             }
             else
             {
                 if (!string.IsNullOrWhiteSpace(e.Status))
                 {
                     //Notifier.Error(string.Format("Document can't be printed because of printer issue : {1}", Environment.NewLine, e.Status));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Notifier.Error(ex);
     }
 }
Ejemplo n.º 11
0
        public uint[] GetBoneCRCs()
        {
            CheckValidity();
            IntPtr crcs = APIWrapper.AnimationBank_GetBoneCRCs(NativeInstance, out int numAnims);

            return(MemUtils.IntPtrToArray <uint>(crcs, numAnims));
        }
Ejemplo n.º 12
0
    public bool AddHighScoreEntry(int score, string name)
    {
        var gameMode       = (int)GameConfig.Instance.GetGameMode();
        var gameDifficulty = 0;

        if (gameMode == (int)GameModeEnum.Casual)
        {
            gameDifficulty = (int)GameConfig.Instance.GetDifficulty();
        }
        else if (gameMode == (int)GameModeEnum.Competitive)
        {
            gameDifficulty = (int)GameConfig.Instance.GetTimeLimit();
        }
        else
        {
            return(false);
        }

        RequestModel request = new RequestModel()
        {
            username   = name,
            score      = score,
            game_mode  = gameMode,
            difficulty = gameDifficulty
        };

        var wrapper = new APIWrapper();
        var result  = Task.Run(() => wrapper.submitScore(request)).Result;

        return(result);
    }
Ejemplo n.º 13
0
        public Field[] GetFields(uint hash = 0)
        {
            CheckValidity();
            IntPtr fields = APIWrapper.ConfigScope_GetFields(NativeInstance, hash, true, out uint count);

            return(RegisterChildren(MemUtils.IntPtrToWrapperArray <Field>(fields, (int)count)));
        }
        /// timerAllowedToPrint
        #region timerAllowedToPrint

        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void timerAllowedToPrint_Tick(object sender, EventArgs e)
        {
            timerAllowedToPrint.Stop();

            if (!ConfigData.Config_DontCheckUserBalance)
            {
                AllowedToPrintResponse res = APIWrapper.CheckIfCanPrint(Environment.MachineName, Environment.UserName, PrintWithColor, NumberOfPrints, ChosenPrinter.Name);
                if (res == null)
                {
                    WPFNotifier.Warning(string.Format("No response from server but still printing."));
                    Print(PDFFileName, PostScriptMetaData.Title, ChosenPrinter.Settings, PostScriptMetaData);
                }
                else
                {
                    if (res.AllowedToPrint)
                    {
                        Print(PDFFileName, PostScriptMetaData.Title, ChosenPrinter.Settings, PostScriptMetaData);
                    }
                    else
                    {
                        timerAllowedToPrint.Start();
                    }
                }
            }

            timerAllowedToPrint.Start();
        }
Ejemplo n.º 15
0
        private void UpdateOrdersNew()
        {
            Task t = new Task(() =>
            {
                APIBalance balance   = APIWrapper.GetBalance();
                tbBalance.Text       = balance.Confirmed.ToString();
                var values           = Enum.GetValues(typeof(AlgorithmEnum)).OfType <AlgorithmEnum>().Select(a => (int)a).ToList();
                List <OrderN> result = new List <OrderN>();
                values.ForEach(value =>
                {
                    result.AddRange(HttpHelper.GetOrderListByLocation(_apiId, _apiKey, 0, value).Result);
                    result.AddRange(HttpHelper.GetOrderListByLocation(_apiId, _apiKey, 1, value).Result);
                });
                orderList = new SortableBindingList <OrderN>(result);
                if (dgvOrders.InvokeRequired)
                {
                    dgvOrders.Invoke(new Action(() =>
                    {
                        orderNBindingSource.DataSource = orderList;
                    }));
                }
                else
                {
                    orderNBindingSource.DataSource = orderList;
                }
            });

            t.Start();
        }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            APIWrapper apiWrapper = new APIWrapper();

            Entities.DataSheet sheet = apiWrapper.GetDataSheet(Request.QueryString["TagNumber"]);
            BindData(sheet);
        }
Ejemplo n.º 17
0
        private void FindOrdersButton_Click(object sender, EventArgs e)
        {
            DesyncController.Delete();

            List <Order> orders = new List <Order>();

            foreach (Order order in APIWrapper.GetMyOrders(0, AlgorithmComboBox.SelectedIndex))
            {
                orders.Add(order);
            }
            foreach (Order order in APIWrapper.GetMyOrders(1, AlgorithmComboBox.SelectedIndex))
            {
                orders.Add(order);
            }

            OrderContainer[] localOrders = OrderContainer.GetAll();
            foreach (Order order in orders)
            {
                bool exists = false;
                foreach (OrderContainer orderContainer in localOrders)
                {
                    if (orderContainer.ID == order.ID)
                    {
                        exists = true;
                    }
                }
                if (!exists)
                {
                    OrderContainer.Add(order.ServiceLocation, order.Algorithm, order.Price, order.SpeedLimit, new Pool(), order.ID, 0.001, 0.005, "");
                }
            }

            Refresh();
        }
Ejemplo n.º 18
0
        public override string Refund(Commerce.Common.Order order)
        {
            APIWrapper wrapper = new APIWrapper(_apiUserName, _apiPassword, _signature,
                                                _defaultCurrencyCode, _isLive);

            //the PayPal transactionID is stored in the auth code
            string transactionID = order.Transactions[0].AuthorizationCode;

            string sResponse = wrapper.RefundTransaction(transactionID, true);

            if (sResponse != "Success")
            {
                string sMessage    = "PayPal has returned an error message for this refund: " + sResponse;
                string encResponse = System.Web.HttpContext.Current.Server.UrlEncode(sResponse);
                if (sMessage.ToLower(System.Globalization.CultureInfo.InvariantCulture).IndexOf("you can not refund this type of transaction (10009)") >= 0)
                {
                    sMessage = "PayPal has rejected the refund of this order for one or more reasons (they don't give exact " +
                               "reasons). If this is a DirectPay (Credit Card) transaction, PayPal will not refund an order if the card for that order is expired. If this is not a DirectPay order, " +
                               "the order is likely too old (greater than 30 days) to be refunded.<br><br>" +
                               "<a href='http://paypal.forums.liveworld.com/search!execute.jspa?q=" + encResponse + "' target=_blank>Find out more</a>";
                }

                throw new Exception(sMessage);
            }
            else
            {
                //PayPal, for some reason, will not return the transactionID
                //this is sort of ridiculous
                //so return a value that means something
                sResponse = order.OrderNumber + "PayPal_REFUND";
            }

            return(sResponse);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// This method called by the General timer every 1 sec.
        /// </summary>
        public void AddOrUpdateDataToPosition()
        {
            var contractList = new List <OptionContract>();

            foreach (var positionData in PositionDataDic.Values)
            {
                var key = ((OptionContract)(positionData.GetContract())).OptionKey;
                if (GetOptionData(positionData, key) == false)
                {
                    contractList.Add((OptionContract)PositionDataDic[key].GetContract());
                }
                //used for UIDataBroker
                UNLManager.Distributer.Enqueue(positionData, false);
            }

            CalculateUnlTradingData();
            UNLManager.Distributer.Enqueue(UnlTradingData, false);
            if (contractList.Count < 1)
            {
                return;
            }

            //Request option data
            APIWrapper.RequestContinousContractData(contractList.Select(oc => (ContractBase)oc).ToList());
            Logger.InfoFormat("{0}.PDB send {1} contracts for not found options.", Symbol, contractList.Count);
        }
Ejemplo n.º 20
0
    void SetExpressOrder()
    {
        //use the API to get the SetCheckout response.
        //Then, redirect to PayPal
        int currencyDecimals = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits;
        //get the wrapper
        APIWrapper wrapper = GetPPWrapper();

        string sEmail = "";

        if (Profile.LastShippingAddress != null)
        {
            if (Profile.LastShippingAddress.Email != string.Empty)
            {
                sEmail = Profile.LastShippingAddress.Email;
            }
            else
            {
                sEmail = "*****@*****.**";
            }
        }

        //send them back here for all occassions
        string successURL = Utility.GetSiteRoot() + "/checkout.aspx";
        string failURL    = Utility.GetSiteRoot() + "/default.aspx";


        if (currentOrder.Items.Count > 0)
        {
            string ppToken = wrapper.SetExpressCheckout(sEmail, currentOrder.CalculateSubTotal(),
                                                        successURL, failURL, true, addShipping.SelectedAddress);
            if (ppToken.ToLower().Contains("error"))
            {
                //lblPPErr.Text="PayPal has returned an error message: "+ppToken;
            }
            else
            {
                string sUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;

                if (!SiteConfig.PayPalAPIIsLive)
                {
                    sUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;
                }

                try {
                    Response.Redirect(sUrl, false);
                }
                catch (Exception x)
                {
                    LovRubLogger.LogException(x); // 04/10/08 KPL added
                    ResultMessage1.ShowFail(x.Message);
                }
            }
        }
        else
        {
            Response.Redirect("CCBasket.aspx", false);
        }
    }
Ejemplo n.º 21
0
 /// <summary>
 /// will return all encounters. will also recursively search base classes, if existent
 /// </summary>
 public bool GetProperty(string propName, out string[] propValues)
 {
     CheckValidity();
     if (APIWrapper.Instance_GetPropertiesFromName(NativeInstance, propName, out IntPtr res, out uint count))
     {
         propValues = MemUtils.IntPtrToStringList(res, (int)count).ToArray();
         return(true);
     }
Ejemplo n.º 22
0
 internal override void SetPtr(IntPtr ptr)
 {
     base.SetPtr(ptr);
     if (APIWrapper.Config_FetchSimpleFields(ptr, out uint name))
     {
         Name = name;
     }
 }
Ejemplo n.º 23
0
    APIWrapper GetPPWrapper()
    {
        APIWrapper wrapper =
            new APIWrapper(SiteConfig.PayPalAPIUserName, SiteConfig.PayPalAPIPassword,
                           SiteConfig.PayPalAPISignature, SiteConfig.CurrencyCode, SiteConfig.PayPalAPIIsLive);

        return(wrapper);
    }
Ejemplo n.º 24
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ShellViewModel()
        {
            IsHomeActive = true;

            APIWrapper.ShellViewModel = this;

            APIWrapper.RunCommand("echo Hello World");
        }
Ejemplo n.º 25
0
 internal override void SetPtr(IntPtr ptr)
 {
     base.SetPtr(ptr);
     APIWrapper.Bone_FetchAllFields(ptr, out IntPtr namePtr, out IntPtr parentNamePtr, out IntPtr loc, out IntPtr rot);
     Name       = Marshal.PtrToStringAnsi(namePtr);
     ParentName = Marshal.PtrToStringAnsi(parentNamePtr);
     Rotation   = new Vector4(rot);
     Location   = new Vector3(loc);
 }
        private void CreateOrder(double limitPrice)
        {
            OrderData = new OrderData()
            {
                OrderType = DefaultOrderType, OrderAction = OrderAction, LimitPrice = limitPrice, Quantity = Quantity, Contract = OptionData.OptionContract
            };

            OrderData.OrderId = APIWrapper.CreateOrder(OrderData);
        }
Ejemplo n.º 27
0
 internal override void SetPtr(IntPtr ptr)
 {
     base.SetPtr(ptr);
     if (APIWrapper.Field_FetchAllFields(ptr, out IntPtr scopePtr, out uint name))
     {
         Name  = name;
         Scope = FromNative <Scope>(scopePtr);
     }
 }
Ejemplo n.º 28
0
 internal override void SetPtr(IntPtr ptr)
 {
     base.SetPtr(ptr);
     APIWrapper.EntityClass_FetchAllFields(ptr, out IntPtr name, out byte classType, out IntPtr baseClass, out IntPtr baseClassName);
     Name          = Marshal.PtrToStringAnsi(name);
     ClassType     = (EEntityClassType)classType;
     BaseClass     = FromNative <EntityClass>(baseClass);
     BaseClassName = Marshal.PtrToStringAnsi(baseClassName);
 }
Ejemplo n.º 29
0
    APIWrapper GetPPWrapper()
    {
        //string certPath = Server.MapPath("~/App_Data/" + SiteConfig.PayPalAPICertificate);
        APIWrapper wrapper =
            new APIWrapper(SiteConfig.PayPalAPIUserName, SiteConfig.PayPalAPIPassword,
                           SiteConfig.PayPalAPISignature, SiteConfig.CurrencyCode, SiteConfig.PayPalAPIIsLive);

        return(wrapper);
    }
Ejemplo n.º 30
0
 public T Get <T>(string name) where T : NativeWrapper, new()
 {
     CheckValidity();
     if (WrapperTypeMapping.ContainsKey(typeof(T)))
     {
         IntPtr ptr = APIWrapper.Level_GetWrapper(NativeInstance, WrapperTypeMapping[typeof(T)], name);
         return(RegisterChild(FromNative <T>(ptr)));
     }
     return(null);
 }
Ejemplo n.º 31
0
    public string UpdateThumbnailCache(string pid)
    {
        vwarDAL.IDataRepository dal = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy();

        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        foreach (vwarDAL.ContentObject co in allpids)
        {
            if (co.PID == pid)
                try
                {
                    System.IO.Stream screenshotdata = api.GetScreenshot(co.PID, "00-00-00");
                    if (screenshotdata != null)
                    {
                        int length = (int)screenshotdata.Length;

                        if (length != 0)
                        {
                            byte[] data = new byte[screenshotdata.Length];
                            screenshotdata.Seek(0,SeekOrigin.Begin);
                            screenshotdata.Read(data,0,length);
                            api.UploadScreenShot(data, co.PID, co.ScreenShot, "00-00-00");
                        }
                        else
                        {
                            dal.Dispose();
                            return "No screenshot data";
                        }
                    }
                    else
                    {
                        dal.Dispose();
                        return "No screenshot data";
                    }
                }
                catch (System.Exception ex)
                {
                    return ex.Message;
                }
        }
        dal.Dispose();
        return "OK";
    }
Ejemplo n.º 32
0
    public static GetSupportingFilesResponse GetSupportingFiles(string pid)
    {
        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00");
        if (md == null)
        {
            return new GetSupportingFilesResponse(false);
        }

        PermissionsManager prm = new PermissionsManager();

        MembershipUser user = Membership.GetUser();

        ModelPermissionLevel Permission = prm.GetPermissionLevel(user != null ? user.UserName:vwarDAL.DefaultUsers.Anonymous[0], pid);
        prm.Dispose();

        GetSupportingFilesResponse response = new GetSupportingFilesResponse(true);
        response.DownloadAllowed = Permission >= ModelPermissionLevel.Fetchable;
        response.EditAllowed = Permission >= ModelPermissionLevel.Editable;
        response.files = new vwarDAL.SupportingFile[md.SupportingFiles.Count];
        for(int i=0; i<md.SupportingFiles.Count; i++)
        {
            response.files[i] = new vwarDAL.SupportingFile(md.SupportingFiles[i].Filename, md.SupportingFiles[i].Description, "");
        }
        return response;
    }
Ejemplo n.º 33
0
    public static UpdateAssetDataResponse UpdateAssetData(string Title, string Description, string Keywords, string License, string pid)
    {
        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00");

        if(md == null)
            return new UpdateAssetDataResponse(false);

            UpdateAssetDataResponse response = new UpdateAssetDataResponse(true);
            response.Keywords = md.Keywords.Split(new char[] { ',', '|' });
            for (int i = 0; i < response.Keywords.Length; i++)
                response.Keywords[i] = response.Keywords[i].ToLower().Trim();

            switch (License.ToLower().Trim())
            {
                case "by-nc-sa":
                    response.LicenseURL = "http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode";
                    response.LicenseImage = "../styles/images/by-nc-sa.png";
                    response.LicenseTitle = "by-nc-sa";
                    break;

                case "by-nc-nd":
                response.LicenseURL =  "http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode";
                response.LicenseImage = "../styles/images/by-nc-nd.png";
                    response.LicenseTitle = "by-nc-nd";
                    break;

                case "by-nc":
                response.LicenseURL =  "http://creativecommons.org/licenses/by-nc/3.0/legalcode";
                response.LicenseImage = "../styles/images/by-nc.png";
                    response.LicenseTitle = "by-nc";
                    break;

                case "by-nd":
                response.LicenseURL =  "http://creativecommons.org/licenses/by-nd/3.0/legalcode";
                response.LicenseImage = "../styles/images/by-nd.png";
                    response.LicenseTitle = "by-nd";
                    break;

                case "by-sa":
                response.LicenseURL =  "http://creativecommons.org/licenses/by-sa/3.0/legalcode";
                response.LicenseImage = "../styles/images/by-sa.png";
                    response.LicenseTitle = "by-sa";
                    break;

                case "publicdomain":
                response.LicenseURL =  "http://creativecommons.org/publicdomain/mark/1.0/";
                response.LicenseImage = "../styles/images/publicdomain.png";
                    response.LicenseTitle = "Public Domain";
                    break;

                case "by":
                    response.LicenseURL = "http://creativecommons.org/licenses/by/3.0/legalcode";
                    response.LicenseImage = "../styles/images/by.png";
                    response.LicenseTitle = "by";
                    break;
            }

            md.Title = Title;
            md.Description = Description;
            md.Keywords = Keywords;
            md.License = response.LicenseURL;

            response.Title = md.Title;
            response.Description = md.Description;

            string result = api.UpdateMetadata(md, pid, "00-00-00");
            if(result != "Ok")
                return new UpdateAssetDataResponse(false);
            return response;
    }
Ejemplo n.º 34
0
    public static bool DeleteSupportingFile(string Filename, string pid)
    {
        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        bool result = api.DeleteSupportingFile(pid, Filename);
        return result;
    }
Ejemplo n.º 35
0
    public static UpdateDetailsResponse UpdateDetails(string polys,string textures,string format, string pid)
    {
        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00");

        md.NumPolygons = polys;
        md.NumTextures = textures;
        md.Format = format;

        string result = api.UpdateMetadata(md, pid, "00-00-00");
        UpdateDetailsResponse response = new UpdateDetailsResponse(result == "Ok");
        response.polys = md.NumPolygons;
        response.textures = md.NumTextures;
        response.format = md.Format;

        return response;
    }
Ejemplo n.º 36
0
    public static UpdateDistributionInfoResponse UpdateDistributionInfo( string Class,string DeterminationDate,string Office,string Regulation,string Reason, string pid)
    {
        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00");
        if (md == null)
            return new UpdateDistributionInfoResponse(false);

        UpdateDistributionInfoResponse response = new UpdateDistributionInfoResponse(false);

        md.Distribution_Grade = Class;
        md.Distribution_Reason = Reason;
        md.Distribution_Regulation = Regulation;
        md.Distribution_Determination_Date = DeterminationDate;
        md.Distribution_Contolling_Office = Office;

        string result = api.UpdateMetadata(md, pid, "00-00-00");
        if (result == "Ok")
        {
            response = new UpdateDistributionInfoResponse(true);
            response.Class = md.Distribution_Grade; ;
            response.DeterminationDate = DeterminationDate;
            response.Office = Office;
            response.Reason = Reason;
            response.Regulation = Regulation;
            response.FullText = GetDistributionText(md);
        }

        return response;
    }
Ejemplo n.º 37
0
    public static bool UpdateScreenshot(string pid, string newfilename)
    {
        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        bool response = false;
        try
        {
            using (FileStream stream = new FileStream(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename)), FileMode.Open))
            {
                byte[] data = new byte[stream.Length];
                stream.Read(data, 0, (int)stream.Length);
                string result = api.UploadScreenShot(data, pid, newfilename, "00-00-00");
                if (result == "Ok")
                {
                    response = true;
                }

            }
            File.Delete(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename)));
        }
        catch (System.IO.FileNotFoundException t)
        {

        }
        return response;
    }
Ejemplo n.º 38
0
    public static UpdateSponsorInfoResponse UpdateSponsorInfo(string SponsorName, string pid, string newfilename)
    {
        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00");
        UpdateSponsorInfoResponse response = new UpdateSponsorInfoResponse(false);

        if (md.SponsorName != SponsorName)
        {
            md.SponsorName = SponsorName;
            string result = api.UpdateMetadata(md, pid, "00-00-00");
            if (result == "Ok")
            {
                response = new UpdateSponsorInfoResponse(true);
                response.SponsorName = md.SponsorName;
            }
        }
        try
        {
            using (FileStream stream = new FileStream(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename)), FileMode.Open))
            {
                byte[] data = new byte[stream.Length];
                stream.Read(data, 0, (int)stream.Length);
                api.UploadSponsorLogo(data,pid,newfilename,"00-00-00");

            }
            File.Delete(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename)));
        }
        catch (Exception e)
        {

        }

        return response;
    }
Ejemplo n.º 39
0
    public static UploadSupportingFileResponse UploadSupportingFileHandler(string filename, string description, string pid, string newfilename)
    {
        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        UploadSupportingFileResponse response = new UploadSupportingFileResponse(false);
        try
        {
            using (FileStream stream = new FileStream(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename)), FileMode.Open))
            {
                byte[] data = new byte[stream.Length];
                stream.Read(data, 0, (int)stream.Length);
                string result = api.UploadSupportingFile(data, pid, filename, description, "00-00-00");
                if (result == "Ok")
                {
                    response = new UploadSupportingFileResponse(true);
                    response.Description = description;
                    response.Filename = filename;
                }

            }
            File.Delete(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename)));
        }
        catch (System.IO.FileNotFoundException t)
        {

        }
        return response;
    }