示例#1
0
        /// <summary>
        /// Changes properties of specified collection.
        /// </summary>
        public AResult<Dictionary<string, object>> ChangeProperties(string collectionName)
        {
            var request = new Request(HttpMethod.PUT, ApiBaseUri.Collection, "/" + collectionName + "/properties");
            var bodyDocument = new Dictionary<string, object>();

            // optional
            Request.TrySetBodyParameter(ParameterName.WaitForSync, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.JournalSize, _parameters, bodyDocument);

            request.Body = JSON.ToJSON(bodyDocument, ASettings.JsonParameters);

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Dictionary<string, object>>();

                    result.Success = (body != null);
                    result.Value = body;
                    break;
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#2
0
        /// <summary>
        /// Retrieves list of registered AQL user functions.
        /// </summary>
        public AResult<List<Dictionary<string, object>>> List()
        {
            var request = new Request(HttpMethod.GET, ApiBaseUri.AqlFunction, "");

            // optional
            request.TrySetQueryStringParameter(ParameterName.Namespace, _parameters);

            var response = _connection.Send(request);
            var result = new AResult<List<Dictionary<string, object>>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    if (response.DataType == DataType.List)
                    {
                        result.Value = ((IEnumerable)response.Data).Cast<Dictionary<string, object>>().ToList();
                        result.Success = (result.Value != null);
                    }
                    break;
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
        public EditResultWindow(AEvent Event, bool newResult = false, bool isDNF = false)
        {
            InitializeComponent();

            if (Event == null)
            {
                throw new ArgumentNullException();
            }

            this.Event = Event;

            if (newResult)
            {
                if (isDNF)
                {
                    // this is a DNF entry
                    this.tbxVest.Text = "";

                    this.tbxDuration.Text      = "";
                    this.tbxDuration.IsEnabled = false;
                    this.tbxRank.IsEnabled     = false;
                    this.tbxRank.Text          = "";

                    this.tbxCompName.Text = "";

                    this.btnSetAsDNF.IsEnabled = false;
                    this.btnPrevious.IsEnabled = false;
                    this.btnNext.IsEnabled     = false;
                    this.btnUnlock.IsEnabled   = false;

                    this.isDNF     = true;
                    this.newResult = true;
                }
                else
                {
                    // we will open a new result at the next available rank
                    this.tbxRank.Text = Event.getNextResultRank().ToString();
                    this.newResult    = true;
                }
            }
            else
            {
                if (Event.Results.Count() == 0)
                {
                    // create first result
                    newResult         = true;
                    this.tbxRank.Text = Event.getNextResultRank().ToString();
                }
                else if (Event.Results.Count() > 0)
                {
                    // select the first result
                    Result       = Event.Results.OrderBy(r => r.Rank).First();
                    tbxRank.Text = Result.Rank.ToString();
                    refreshData();
                    lockEntry();
                }
            }
        }
        private void MoveDown_Click(object sender, RoutedEventArgs e)
        {
            AResult res = (AResult)this.resultsDataGrid.SelectedItem;

            if (res == null)
            {
                return;
            }

            Event.moveResultDown(res);
            refreshData();
        }
示例#5
0
        //--- Constructors ---

        /// <summary>
        /// Create a new Coroutine instance from a delegate.
        /// </summary>
        /// <remarks>
        /// Consider using one of the static Invoke methods instead.
        /// </remarks>
        /// <param name="callee">Delegate to method to be invoked as a coroutine.</param>
        /// <param name="result">Synchronization handle.</param>
        public Coroutine(Delegate callee, AResult result)
        {
            if (callee == null)
            {
                throw new ArgumentNullException("callee");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            _method = callee;
            _result = result;
        }
 /// <summary>
 /// Sets the current coroutine's behavior to catch any exception thrown by a coroutine and log the exception,
 /// but continue with the caller's context.
 /// </summary>
 /// <param name="result">Coroutine synchronization handle.</param>
 /// <param name="log">Logger instance to use for the exception logging.</param>
 /// <param name="message">Additional message to log along with exception</param>
 /// <returns>Iterator used by <see cref="Coroutine"/>.</returns>
 public static IYield CatchAndLog(this AResult result, ILog log, string message)
 {
     if (result == null)
     {
         throw new ArgumentNullException("result");
     }
     if (log == null)
     {
         throw new ArgumentNullException("log");
     }
     Coroutine.Current.Mode = CoroutineExceptionHandlingMode.CatchOnce;
     return(new LogExceptionAndContinue(result, log, message));
 }
示例#7
0
 /// <summary>
 /// Create a new Coroutine instance from a method
 /// </summary>
 /// <param name="method">Info for method to be invoked as a coroutine.</param>
 /// <param name="result">Synchronization handle.</param>
 public Coroutine(MethodInfo method, AResult result)
 {
     if (method == null)
     {
         throw new ArgumentNullException("method");
     }
     if (result == null)
     {
         throw new ArgumentNullException("result");
     }
     _method = method;
     _result = result;
 }
示例#8
0
        private void listBoxItem_Click(object sender, MouseButtonEventArgs e)
        {
            if (listBox.Items.Count > 0 && listBox.SelectedIndex > -1)
            {
                ALibModel lm = listBox.SelectedItem as ALibModel;
                string searchStr = lm.Tag;
                AResult result = new AResult(searchStr);

                Window m = Application.Current.Properties["mainwindow"] as Window;
                Frame main_frame = m.FindName("main_frame") as Frame;
                main_frame.Navigate(result);

            }
        }
        private void EditMenuItem_Click(object sender, RoutedEventArgs e)
        {
            AResult res = (AResult)this.resultsDataGrid.SelectedItem;

            if (res == null)
            {
                return;
            }

            EditResultWindow erw = new EditResultWindow(res);

            erw.ShowDialog();

            refreshData();
        }
        private void PreviousResult_Click(object sender, RoutedEventArgs e)
        {
            int rank;

            ProcessResultForm();
            if (int.TryParse(tbxRank.Text, out rank))
            {
                if (rank == 1)
                {
                    if (Result != null)
                    {
                        if (!Result.isPlaceholder())
                        {
                            --rank;
                        }
                    }
                }

                if (rank > 1)
                {
                    Result = Event.getResult(--rank);
                }


                if (rank < 1)
                {
                    // out of range push results down
                    rank = 1;
                    Event.insertRankSpace(rank);
                    Result = Event.getResult(rank);
                }

                if (Result == null)
                {
                    tbxRank.Text = rank.ToString();
                    prepNewResult();
                }
                else
                {
                    refreshData();
                }
            }
        }
示例#11
0
        public virtual Int32 WriteToParcel(Parcel parcel)
        {
            if (parcel == null)
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteString("NA.CBase")))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteByte(mB)))
            {
                return(AResult.AE_FAIL);
            }

            return(AResult.AS_OK);
        }
        private void NextResult_Click(object sender, RoutedEventArgs e)
        {
            int rank;

            ProcessResultForm();
            if (int.TryParse(tbxRank.Text, out rank))
            {
                Result = Event.getResult(++rank);

                if (Result == null)
                {
                    tbxRank.Text = rank.ToString();
                    prepNewResult();
                }
                else
                {
                    refreshData();
                }
            }
        }
示例#13
0
        public virtual Int32 ReadFromParcel(Parcel parcel)
        {
            if (parcel == null)
            {
                return(AResult.AE_FAIL);
            }

            String description = null;

            if (AResult.AFAILED(parcel.ReadString(ref description)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.ReadByte(ref mB)))
            {
                return(AResult.AE_FAIL);
            }

            return(AResult.AS_OK);
        }
        public void SetValue(int eventid, int rank, string value)
        {
            Championship championship = getCurrentChampionship();
            IScriptEvent Event        = championship.getEvent(eventid);

            AResult result = ((AEvent)Event).getResult(rank);

            if (result == null)
            {
                return;
            }

            ResultValue rv = AEvent.MakeNewResultsValue((AEvent)Event);

            rv.setResultString(System.Web.HttpUtility.UrlDecode(value));


            result.Value = rv;
            result.Save( );
            //!**!
            //saveChangesToDatabase();
        }
        // 按节点查询最新信息
        public ActionResult ShowLatestByMac(string mac)
        {
            AResult result = new AResult();
            var     rs     = result.showlatestByMac(mac);

            if (rs != null)
            {
                return(Content(JsonConvert.SerializeObject(new
                {
                    code = 1,
                    des = "查询成功",
                    data = rs,
                })));
            }
            else
            {
                return(Content(JsonConvert.SerializeObject(new
                {
                    code = 0,
                    des = "查询失败",
                })));
            }
        }
示例#16
0
        /// <summary>
        /// Retrieves first result value as single generic object.
        /// </summary>
        public async Task <AResult <T> > ToObject <T>()
        {
            var listResult = await Post <T>();

            var result = new AResult <T>()
            {
                StatusCode = listResult.StatusCode,
                Success    = listResult.Success
            };

            if (listResult.Success)
            {
                if (listResult.Value.Result.Count > 0)
                {
                    result.Value = listResult.Value.Result[0];
                }
                else
                {
                    result.Value = default;
                }
            }

            return(result);
        }
 //--- Constructors ---
 public LogExceptionAndContinue(AResult result, ILog log, string message)
 {
     _result  = result;
     _log     = log;
     _message = message ?? "unhandled exception occurred in coroutine";
 }
示例#18
0
        /// <summary>
        /// Creates new or replaces existing AQL user function with specified name and code.
        /// </summary>
        public AResult<bool> Register(string name, string code)
        {
            var request = new Request(HttpMethod.POST, ApiBaseUri.AqlFunction, "");
            var bodyDocument = new Dictionary<string, object>();

            // required
            bodyDocument.String(ParameterName.Name, name);
            // required
            bodyDocument.String(ParameterName.Code, code);
            // optional
            Request.TrySetBodyParameter(ParameterName.IsDeterministic, _parameters, bodyDocument);

            request.Body = JSON.ToJSON(bodyDocument, ASettings.JsonParameters);

            var response = _connection.Send(request);
            var result = new AResult<bool>(response);

            switch (response.StatusCode)
            {
                case 200:
                case 201:
                    if (response.DataType == DataType.Document)
                    {
                        result.Success = true;
                        result.Value = true;
                    }
                    break;
                case 400:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
 /// <summary>
 /// Sets the current coroutine's behavior to catch any exception thrown by a coroutine and log the exception,
 /// but continue with the caller's context.
 /// </summary>
 /// <param name="result">Coroutine synchronization handle.</param>
 /// <param name="log">Logger instance to use for the exception logging.</param>
 /// <returns>Iterator used by <see cref="Coroutine"/>.</returns>
 public static IYield CatchAndLog(this AResult result, ILog log)
 {
     return(CatchAndLog(result, log, null));
 }
示例#20
0
        /// <summary>
        /// Unregisters specified AQL user function.
        /// </summary>
        public AResult<bool> Unregister(string name)
        {
            var request = new Request(HttpMethod.DELETE, ApiBaseUri.AqlFunction, "/" + name);

            // optional
            request.TrySetQueryStringParameter(ParameterName.Group, _parameters);

            var response = _connection.Send(request);
            var result = new AResult<bool>(response);

            switch (response.StatusCode)
            {
                case 200:
                    if (response.DataType == DataType.Document)
                    {
                        result.Success = true;
                        result.Value = true;
                    }
                    break;
                case 400:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#21
0
        private void search_textBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Down)
            {
                int li = comViewModel.Selectedindex + 1;
                comViewModel.Selectedindex = li > comList.Count
                    ? comList.Count : li;

            }
            if (e.Key == Key.Up)
            {
                int li = comViewModel.Selectedindex - 1;
                comViewModel.Selectedindex = li < 0
                    ? 0 : li;

            }
            if (e.Key == Key.Enter)
            {
                if (comList.Count > 0 && comViewModel.Selectedindex != -1)
                {
                    search_textBox.Text = comList[comViewModel.Selectedindex].Tag;

                    comList.Clear();

                    AResult result = new AResult(search_textBox.Text);
                    NavigationService.Navigate(result);

                }

                search_textBox.Focus();
                search_textBox.SelectAll();

                //textBlock.Text = "search selected.";
            }
            if (e.Key == Key.Escape)
            {
                clearbutton_Click(null, null);

            }
        }
示例#22
0
        /// <summary>
        /// Retrieves list of edges in specified collection.
        /// </summary>
        public AResult<List<string>> GetAllEdges(string collectionName)
        {
            var request = new Request(HttpMethod.GET, ApiBaseUri.Edge, "");

            // required
            request.QueryString.Add(ParameterName.Collection, collectionName);
            // optional
            request.TrySetQueryStringParameter(ParameterName.Type, _parameters);

            var response = _connection.Send(request);
            var result = new AResult<List<string>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    if (response.DataType == DataType.Document)
                    {
                        result.Value = (response.Data as Dictionary<string, object>).List<string>("documents");
                        result.Success = (result.Value != null);
                    }
                    break;
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#23
0
        /// <summary>
        /// Retrieves information about currently connected database.
        /// </summary>
        public AResult<Dictionary<string, object>> GetCurrent()
        {
            var request = new Request(HttpMethod.GET, ApiBaseUri.Database, "/current");

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Body<Dictionary<string, object>>>();

                    result.Success = (body != null);
                    result.Value = body.Result;
                    break;
                case 400:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#24
0
 /// <summary>
 /// Creates index within specified collection in current database context.
 /// </summary>
 public AResult<Dictionary<string, object>> Create(string collectionName)
 {
     var request = new Request(HttpMethod.POST, ApiBaseUri.Index, "");
     var bodyDocument = new Dictionary<string, object>();
     
     // required
     request.QueryString.Add(ParameterName.Collection, collectionName);
     
     // required
     bodyDocument.String(ParameterName.Type, _parameters.String(ParameterName.Type));
     
     switch (_parameters.Enum<AIndexType>(ParameterName.Type))
     {
         case AIndexType.Cap:
             Request.TrySetBodyParameter(ParameterName.ByteSize, _parameters, bodyDocument);
             Request.TrySetBodyParameter(ParameterName.Size, _parameters, bodyDocument);
             break;
         case AIndexType.Fulltext:
             Request.TrySetBodyParameter(ParameterName.Fields, _parameters, bodyDocument);
             Request.TrySetBodyParameter(ParameterName.MinLength, _parameters, bodyDocument);
             break;
         case AIndexType.Geo:
             Request.TrySetBodyParameter(ParameterName.Fields, _parameters, bodyDocument);
             Request.TrySetBodyParameter(ParameterName.GeoJson, _parameters, bodyDocument);
             break;
         case AIndexType.Hash:
             Request.TrySetBodyParameter(ParameterName.Fields, _parameters, bodyDocument);
             Request.TrySetBodyParameter(ParameterName.Sparse, _parameters, bodyDocument);
             Request.TrySetBodyParameter(ParameterName.Unique, _parameters, bodyDocument);
             break;
         case AIndexType.Skiplist:
             Request.TrySetBodyParameter(ParameterName.Fields, _parameters, bodyDocument);
             Request.TrySetBodyParameter(ParameterName.Sparse, _parameters, bodyDocument);
             Request.TrySetBodyParameter(ParameterName.Unique, _parameters, bodyDocument);
             break;
         default:
             break;
     }
     
     request.Body = JSON.ToJSON(bodyDocument, ASettings.JsonParameters);
     
     var response = _connection.Send(request);
     var result = new AResult<Dictionary<string, object>>(response);
     
     switch (response.StatusCode)
     {
         case 200:
         case 201:
             if (response.DataType == DataType.Document)
             {
                 result.Value = (response.Data as Dictionary<string, object>);
                 result.Success = (result.Value != null);
             }
             break;
         case 400:
         case 404:
         default:
             // Arango error
             break;
     }
     
     _parameters.Clear();
     
     return result;
 }
示例#25
0
        /// <summary>
        /// Creates new collection in current database context.
        /// </summary>
        public AResult<Dictionary<string, object>> Create(string collectionName)
        {
            var request = new Request(HttpMethod.POST, ApiBaseUri.Collection, "");
            var bodyDocument = new Dictionary<string, object>();

            // required
            bodyDocument.String(ParameterName.Name, collectionName);
            // optional
            Request.TrySetBodyParameter(ParameterName.Type, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.WaitForSync, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.JournalSize, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.DoCompact, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.IsSystem, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.IsVolatile, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.KeyOptionsType, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.KeyOptionsAllowUserKeys, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.KeyOptionsIncrement, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.KeyOptionsOffset, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.NumberOfShards, _parameters, bodyDocument);
            // optional
            Request.TrySetBodyParameter(ParameterName.ShardKeys, _parameters, bodyDocument);

            request.Body = JSON.ToJSON(bodyDocument, ASettings.JsonParameters);

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Dictionary<string, object>>();

                    result.Success = (body != null);
                    result.Value = body;
                    break;
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#26
0
        /// <summary>
        /// Retrieves information about currently connected database.
        /// </summary>
        public AResult<Dictionary<string, object>> GetCurrent()
        {
            var request = new Request(HttpMethod.GET, ApiBaseUri.Database, "/current");

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    if (response.DataType == DataType.Document)
                    {
                        result.Value = (response.Data as Dictionary<string, object>).Document("result");
                        result.Success = (result.Value != null);
                    }
                    break;
                case 400:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#27
0
        /// <summary>
        /// Renames specified collection.
        /// </summary>
        public AResult<Dictionary<string, object>> Rename(string collectionName, string newCollectionName)
        {
            var request = new Request(HttpMethod.PUT, ApiBaseUri.Collection, "/" + collectionName + "/rename");
            var bodyDocument = new Dictionary<string, object>()
                .String(ParameterName.Name, newCollectionName);

            request.Body = JSON.ToJSON(bodyDocument, ASettings.JsonParameters);

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Dictionary<string, object>>();

                    result.Success = (body != null);
                    result.Value = body;
                    break;
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#28
0
        /// <summary>
        /// Unloads specified collection from memory.
        /// </summary>
        public AResult<Dictionary<string, object>> Unload(string collectionName)
        {
            var request = new Request(HttpMethod.PUT, ApiBaseUri.Collection, "/" + collectionName + "/unload");

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    if (response.DataType == DataType.Document)
                    {
                        result.Value = (response.Data as Dictionary<string, object>);
                        result.Success = (result.Value != null);
                    }
                    break;
                case 400:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#29
0
        /// <summary>
        /// Retrieves list of indexes in specified collection.
        /// </summary>
        public AResult<Dictionary<string, object>> GetAllIndexes(string collectionName)
        {
            var request = new Request(HttpMethod.GET, ApiBaseUri.Index, "");

            // required
            request.QueryString.Add(ParameterName.Collection, collectionName);

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Dictionary<string, object>>();

                    result.Success = (body != null);
                    result.Value = body;
                    break;
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
 protected bool Equals(AResult other)
 {
     return(Id == other.Id);
 }
示例#31
0
 /// <summary>
 /// Deletes specified index.
 /// </summary>
 /// <exception cref="ArgumentException">Specified id value has invalid format.</exception>
 public AResult<Dictionary<string, object>> Delete(string id)
 {
     if (!ADocument.IsID(id))
     {
         throw new ArgumentException("Specified id value (" + id + ") has invalid format.");
     }
     
     var request = new Request(HttpMethod.DELETE, ApiBaseUri.Index, "/" + id);
     
     var response = _connection.Send(request);
     var result = new AResult<Dictionary<string, object>>(response);
     
     switch (response.StatusCode)
     {
         case 200:
             if (response.DataType == DataType.Document)
             {
                 result.Value = (response.Data as Dictionary<string, object>);
                 result.Success = (result.Value != null);
             }
             break;
         case 400:
         case 404:
         default:
             // Arango error
             break;
     }
     
     _parameters.Clear();
     
     return result;
 }
示例#32
0
        public override Int32 ReadFromParcel(Parcel parcel)
        {
            if (parcel == null)
            {
                return(AResult.AE_FAIL);
            }

            String description = null;

            if (AResult.AFAILED(parcel.ReadString(ref description)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(base.ReadFromParcel(parcel)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.ReadInt8(ref a)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.ReadInt16(ref b)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.ReadInt64(ref c)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.ReadDouble(ref e)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.ReadBoolean(ref bee)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.ReadNullableInt8(ref f)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.ReadNullableInt64(ref g)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.ReadString(ref m)))
            {
                return(AResult.AE_FAIL);
            }

            {
                lstring = new List <String>();
                if (lstring == null)
                {
                    return(AResult.AE_FAIL);
                }

                Byte[] type = null;
                if (AResult.AFAILED(parcel.Read(ref type, 1)))
                {
                    return(AResult.AE_FAIL);
                }

                String typeStr = System.Text.Encoding.ASCII.GetString(type);
                if (typeStr != "L")
                {
                    return(AResult.AE_FAIL);
                }

                Byte[] lengthArray = null;
                if (AResult.AFAILED(parcel.Read(ref lengthArray, 4)))
                {
                    return(AResult.AE_FAIL);
                }

                Int32 length = System.BitConverter.ToInt32(lengthArray, 0);
                for (Int32 i = 0; i < length; i++)
                {
                    String obj = null;
                    if (AResult.AFAILED(parcel.ReadString(ref obj)))
                    {
                        return(AResult.AE_FAIL);
                    }

                    lstring.Add(obj);
                }
            }

            {
                list64 = new List <Int64?>();
                if (list64 == null)
                {
                    return(AResult.AE_FAIL);
                }

                Byte[] type = null;
                if (AResult.AFAILED(parcel.Read(ref type, 1)))
                {
                    return(AResult.AE_FAIL);
                }

                String typeStr = System.Text.Encoding.ASCII.GetString(type);
                if (typeStr != "L")
                {
                    return(AResult.AE_FAIL);
                }

                Byte[] lengthArray = null;
                if (AResult.AFAILED(parcel.Read(ref lengthArray, 4)))
                {
                    return(AResult.AE_FAIL);
                }

                Int32 length = System.BitConverter.ToInt32(lengthArray, 0);
                for (Int32 i = 0; i < length; i++)
                {
                    Int64?obj = null;
                    if (AResult.AFAILED(parcel.ReadNullableInt64(ref obj)))
                    {
                        return(AResult.AE_FAIL);
                    }

                    list64.Add(obj);
                }
            }

            {
                listDouble = new List <Double?>();
                if (listDouble == null)
                {
                    return(AResult.AE_FAIL);
                }

                Byte[] type = null;
                if (AResult.AFAILED(parcel.Read(ref type, 1)))
                {
                    return(AResult.AE_FAIL);
                }

                String typeStr = System.Text.Encoding.ASCII.GetString(type);
                if (typeStr != "L")
                {
                    return(AResult.AE_FAIL);
                }

                Byte[] lengthArray = null;
                if (AResult.AFAILED(parcel.Read(ref lengthArray, 4)))
                {
                    return(AResult.AE_FAIL);
                }

                Int32 length = System.BitConverter.ToInt32(lengthArray, 0);
                for (Int32 i = 0; i < length; i++)
                {
                    Double?obj = null;
                    if (AResult.AFAILED(parcel.ReadNullableDouble(ref obj)))
                    {
                        return(AResult.AE_FAIL);
                    }

                    listDouble.Add(obj);
                }
            }

            return(AResult.AS_OK);
        }
        private void ProcessResultForm()
        {
            int rank;

            if (!locked)
            {
                try
                {
                    if (int.TryParse(tbxRank.Text, out rank))
                    {
                        if (Event.isRankAvailable(rank))
                        {
                            if (Competitor == null)
                            {
                                ResultValue rv = AEvent.MakeNewResultsValue(Event);

                                if (rv.setResultString(tbxDuration.Text))
                                {
                                    Result = Event.AddResult(rank, rv);
                                }
                                else
                                {
                                    Result = Event.AddPlaceholderResult(rank);
                                }
                            }
                            else
                            {
                                // Competitive, CompetativeTimed or Competitive DNF
                                if (isDNF)
                                {
                                    Result = Event.AddDNF(Competitor); //new ResultCompetiveDNF();
                                }
                                else
                                {
                                    // Competitive or CompetativeTimed
                                    if (string.IsNullOrWhiteSpace(tbxDuration.Text))
                                    {
                                        Result = Event.AddResult(rank, Competitor); //new Result();
                                    }
                                    else
                                    {
                                        ResultValue rv = AEvent.MakeNewResultsValue(Event);

                                        if (rv.setResultString(tbxDuration.Text))
                                        {
                                            Result = Event.AddResult(rank, Competitor, rv);
                                        }
                                        else
                                        {
                                            MessageBox.Show("Failed To phrase Duration");
                                            return;
                                        }
                                    }
                                }
                            }

                            lockEntry();
                        }
                        else // rank is not available
                        {
                            if (MessageBox.Show("This rank has already been used, do you want to use the next available rank for this event?", "Rank not recognized", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                            {
                                this.tbxRank.Text = Event.getNextResultRank().ToString();
                                ProcessResultForm();
                            }
                            else
                            {
                                return;
                            }
                        }
                    }// no rank
                    else
                    {
                        if (isDNF)
                        {
                            if (Competitor != null)
                            {
                                Result = Event.AddDNF(Competitor); //new ResultCompetiveDNF();
                            }
                            else
                            {
                                MessageBox.Show("That vest number was not entered into this event");
                            }
                        }
                        else
                        {
                            if (MessageBox.Show("Rank has not been set/recognized, do you want to use the next available rank for this event?", "Rank not recognized", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                            {
                                this.tbxRank.Text = Event.getNextResultRank().ToString();
                                ProcessResultForm();
                            }
                            else
                            {
                                return;
                            }
                        }
                    } // if rank
                }     // try
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else //entry form is locked - do nothing
            {
            }
        }
示例#34
0
        public override Int32 WriteToParcel(Parcel parcel)
        {
            if (parcel == null)
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteString("NA.CList")))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(base.WriteToParcel(parcel)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteInt8(a)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteInt16(b)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteInt64(c)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteDouble(e)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteBoolean(bee)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteNullableInt8(f)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteNullableInt64(g)))
            {
                return(AResult.AE_FAIL);
            }

            if (AResult.AFAILED(parcel.WriteString(m)))
            {
                return(AResult.AE_FAIL);
            }

            {
                Int32 length = 0;
                if (lstring == null)
                {
                    length = 0;
                }
                else
                {
                    length = lstring.Count;
                }

                string typeStr = "L";
                Byte[] type    = System.Text.Encoding.ASCII.GetBytes(typeStr);
                if (AResult.AFAILED(parcel.Write(type)))
                {
                    return(AResult.AE_FAIL);
                }

                Byte[] lengthArray = System.BitConverter.GetBytes(length);
                if (AResult.AFAILED(parcel.Write(lengthArray)))
                {
                    return(AResult.AE_FAIL);
                }

                if (lstring != null)
                {
                    foreach (String obj in lstring)
                    {
                        if (obj == null)
                        {
                            return(AResult.AE_FAIL);
                        }

                        if (AResult.AFAILED(parcel.WriteString(obj)))
                        {
                            return(AResult.AE_FAIL);
                        }
                    }
                }
            }

            {
                Int32 length = 0;
                if (list64 == null)
                {
                    length = 0;
                }
                else
                {
                    length = list64.Count;
                }

                string typeStr = "L";
                Byte[] type    = System.Text.Encoding.ASCII.GetBytes(typeStr);
                if (AResult.AFAILED(parcel.Write(type)))
                {
                    return(AResult.AE_FAIL);
                }

                Byte[] lengthArray = System.BitConverter.GetBytes(length);
                if (AResult.AFAILED(parcel.Write(lengthArray)))
                {
                    return(AResult.AE_FAIL);
                }

                if (list64 != null)
                {
                    foreach (Int64?obj in list64)
                    {
                        if (obj == null)
                        {
                            return(AResult.AE_FAIL);
                        }

                        if (AResult.AFAILED(parcel.WriteNullableInt64(obj)))
                        {
                            return(AResult.AE_FAIL);
                        }
                    }
                }
            }

            {
                Int32 length = 0;
                if (listDouble == null)
                {
                    length = 0;
                }
                else
                {
                    length = listDouble.Count;
                }

                string typeStr = "L";
                Byte[] type    = System.Text.Encoding.ASCII.GetBytes(typeStr);
                if (AResult.AFAILED(parcel.Write(type)))
                {
                    return(AResult.AE_FAIL);
                }

                Byte[] lengthArray = System.BitConverter.GetBytes(length);
                if (AResult.AFAILED(parcel.Write(lengthArray)))
                {
                    return(AResult.AE_FAIL);
                }

                if (listDouble != null)
                {
                    foreach (Double?obj in listDouble)
                    {
                        if (obj == null)
                        {
                            return(AResult.AE_FAIL);
                        }

                        if (AResult.AFAILED(parcel.WriteNullableDouble(obj)))
                        {
                            return(AResult.AE_FAIL);
                        }
                    }
                }
            }

            return(AResult.AS_OK);
        }
示例#35
0
 /// <summary>
 /// Retrieves specified index.
 /// </summary>
 /// <exception cref="ArgumentException">Specified id value has invalid format.</exception>
 public AResult<Dictionary<string, object>> Get(string id)
 {
     if (!ADocument.IsID(id))
     {
         throw new ArgumentException("Specified id value (" + id + ") has invalid format.");
     }
     
     var request = new Request(HttpMethod.GET, ApiBaseUri.Index, "/" + id);
     
     var response = _connection.Send(request);
     var result = new AResult<Dictionary<string, object>>(response);
     
     switch (response.StatusCode)
     {
         case 200:
             var body = response.ParseBody<Dictionary<string, object>>();
             
             result.Success = (body != null);
             result.Value = body;
             break;
         case 404:
         default:
             // Arango error
             break;
     }
     
     _parameters.Clear();
     
     return result;
 }
示例#36
0
        /// <summary>
        /// Retrieves basic information, revision ID and checksum of specified collection.
        /// </summary>
        public AResult<Dictionary<string, object>> GetChecksum(string collectionName)
        {
            var request = new Request(HttpMethod.GET, ApiBaseUri.Collection, "/" + collectionName + "/checksum");

            // optional
            request.TrySetQueryStringParameter(ParameterName.WithRevisions, _parameters);
            // optional
            request.TrySetQueryStringParameter(ParameterName.WithData, _parameters);

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Dictionary<string, object>>();

                    result.Success = (body != null);
                    result.Value = body;
                    break;
                case 400:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#37
0
        /// <summary>
        /// Creates new database with given name and user list.
        /// </summary>
        public AResult<bool> Create(string databaseName, List<AUser> users)
        {
            var request = new Request(HttpMethod.POST, ApiBaseUri.Database, "");
            var bodyDocument = new Dictionary<string, object>();

            // required: database name
            bodyDocument.String("name", databaseName);

            // optional: list of users
            if ((users != null) && (users.Count > 0))
            {
                var userList = new List<Dictionary<string, object>>();

                foreach (var user in users)
                {
                    var userItem = new Dictionary<string, object>();

                    if (!string.IsNullOrEmpty(user.Username))
                    {
                        userItem.String("username", user.Username);
                    }

                    if (!string.IsNullOrEmpty(user.Password))
                    {
                        userItem.String("passwd", user.Password);
                    }

                    userItem.Bool("active", user.Active);

                    if (user.Extra != null)
                    {
                        userItem.Document("extra", user.Extra);
                    }

                    userList.Add(userItem);
                }

                bodyDocument.List("users", userList);
            }

            request.Body = JSON.ToJSON(bodyDocument, ASettings.JsonParameters);

            var response = _connection.Send(request);
            var result = new AResult<bool>(response);

            switch (response.StatusCode)
            {
                case 201:
                    var body = response.ParseBody<Body<bool>>();

                    result.Success = (body != null);
                    result.Value = body.Result;
                    break;
                case 400:
                case 403:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#38
0
        /// <summary>
        /// Loads specified collection into memory.
        /// </summary>
        public AResult<Dictionary<string, object>> Load(string collectionName)
        {
            var request = new Request(HttpMethod.PUT, ApiBaseUri.Collection, "/" + collectionName + "/load");

            if (_parameters.Has(ParameterName.Count))
            {
                var bodyDocument = new Dictionary<string, object>();

                // optional
                Request.TrySetBodyParameter(ParameterName.Count, _parameters, bodyDocument);

                request.Body = JSON.ToJSON(bodyDocument, ASettings.JsonParameters);
            }

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Dictionary<string, object>>();

                    result.Success = (body != null);
                    result.Value = body;
                    break;
                case 400:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#39
0
        /// <summary>
        /// Deletes specified database.
        /// </summary>
        public AResult<bool> Drop(string databaseName)
        {
            var request = new Request(HttpMethod.DELETE, ApiBaseUri.Database, "/" + databaseName);

            var response = _connection.Send(request);
            var result = new AResult<bool>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Body<bool>>();

                    result.Success = (body != null);
                    result.Value = body.Result;
                    break;
                case 400:
                case 403:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#40
0
        /// <summary>
        /// Unloads specified collection from memory.
        /// </summary>
        public AResult<Dictionary<string, object>> Unload(string collectionName)
        {
            var request = new Request(HttpMethod.PUT, ApiBaseUri.Collection, "/" + collectionName + "/unload");

            var response = _connection.Send(request);
            var result = new AResult<Dictionary<string, object>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Dictionary<string, object>>();

                    result.Success = (body != null);
                    result.Value = body;
                    break;
                case 400:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#41
0
        /// <summary>
        /// Retrieves information about collections in current database connection.
        /// </summary>
        public AResult<List<Dictionary<string, object>>> GetAllCollections()
        {
            var request = new Request(HttpMethod.GET, ApiBaseUri.Collection, "");

            // optional
            request.TrySetQueryStringParameter(ParameterName.ExcludeSystem, _parameters);

            var response = _connection.Send(request);
            var result = new AResult<List<Dictionary<string, object>>>(response);

            switch (response.StatusCode)
            {
                case 200:
                    var body = response.ParseBody<Dictionary<string, object>>();

                    result.Success = (body != null);
                    result.Value = body.List<Dictionary<string, object>>("collections");
                    break;
                case 400:
                case 403:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }
示例#42
0
        //--- Constructors ---
        public DekiScriptNativeInvocationTarget(object subject, MethodInfo method, Parameter[] parameters)
        {
            this.Method = method;

            // check if method is a coroutine
            Type            nativeReturnType;
            ConstructorInfo resultTypeConstructor = null;

            ParameterInfo[] methodParams = method.GetParameters();
            bool            isCoroutine  = (method.ReturnType == typeof(IEnumerator <IYield>));

            if (isCoroutine)
            {
                // check if enough parameters are present
                if (methodParams.Length == 0)
                {
                    throw new ArgumentException("handler is missing Result<T> parameter");
                }

                // check that the last parameter is of type Result<T>
                Type lastParam = methodParams[methodParams.Length - 1].ParameterType;
                if (!lastParam.IsGenericType || (lastParam.GetGenericTypeDefinition() != typeof(Result <>)))
                {
                    throw new ArgumentException(string.Format("handler last parameter must be generic type Result<T>, but is {0}", lastParam.FullName));
                }
                resultTypeConstructor = lastParam.GetConstructor(Type.EmptyTypes);
                nativeReturnType      = lastParam.GetGenericArguments()[0];

                // remove last parameter from array since it represents the return type
                methodParams = ArrayUtil.Resize(methodParams, methodParams.Length - 1);
            }
            else
            {
                nativeReturnType = method.ReturnType;
            }
            ReturnType = DekiScriptLiteral.AsScriptType(nativeReturnType);

            // check if first parameter is a DekiScriptRuntime
            bool usesRuntime = false;

            if ((methodParams.Length > 0) && (methodParams[methodParams.Length - 1].ParameterType.IsA <DekiScriptRuntime>()))
            {
                usesRuntime  = true;
                methodParams = ArrayUtil.Resize(methodParams, methodParams.Length - 1);
            }

            // retrieve method parameters and their attributes
            Parameters = new DekiScriptParameter[methodParams.Length];
            for (int i = 0; i < methodParams.Length; ++i)
            {
                ParameterInfo param   = methodParams[i];
                Parameter     details = parameters[i] ?? Parameter.Default;

                // add hint parameter
                Parameters[i] = new DekiScriptParameter(param.Name, DekiScriptLiteral.AsScriptType(param.ParameterType), details.Optional, details.Hint, param.ParameterType, DekiScriptNil.Value);
            }

            // determine access rights
            if (method.IsPrivate || method.IsFamily)
            {
                this.Access = DreamAccess.Private;
            }
            else if (method.IsAssembly)
            {
                this.Access = DreamAccess.Internal;
            }
            else
            {
                this.Access = DreamAccess.Public;
            }

            // create invocation callback
            if (resultTypeConstructor != null)
            {
                if (usesRuntime)
                {
                    // invoke coroutine with runtime
                    _invoke = (runtime, args) => {
                        var     arguments = new object[args.Length + 2];
                        AResult result    = (AResult)resultTypeConstructor.Invoke(null);
                        arguments[arguments.Length - 1] = result;
                        arguments[arguments.Length - 2] = runtime;
                        Array.Copy(args, arguments, args.Length);
                        new Coroutine(method, result).Invoke(() => (IEnumerator <IYield>)method.InvokeWithRethrow(subject, arguments));
                        result.Block();
                        return(result.UntypedValue);
                    };
                }
                else
                {
                    // invoke coroutine without runtime
                    _invoke = (runtime, args) => {
                        var     arguments = new object[args.Length + 1];
                        AResult result    = (AResult)resultTypeConstructor.Invoke(null);
                        arguments[arguments.Length - 1] = result;
                        Array.Copy(args, arguments, args.Length);
                        new Coroutine(method, result).Invoke(() => (IEnumerator <IYield>)method.InvokeWithRethrow(subject, arguments));
                        result.Block();
                        return(result.UntypedValue);
                    };
                }
            }
            else
            {
                if (usesRuntime)
                {
                    // invoke method with runtime
                    _invoke = (runtime, args) => {
                        var arguments = new object[args.Length + 1];
                        arguments[arguments.Length - 1] = runtime;
                        Array.Copy(args, arguments, args.Length);
                        return(method.InvokeWithRethrow(subject, arguments));
                    };
                }
                else
                {
                    // invoke method without runtime
                    _invoke = (runtime, args) => method.InvokeWithRethrow(subject, args);
                }
            }
        }
示例#43
0
        /// <summary>
        /// Deletes specified database.
        /// </summary>
        public AResult<bool> Drop(string databaseName)
        {
            var request = new Request(HttpMethod.DELETE, ApiBaseUri.Database, "/" + databaseName);

            var response = _connection.Send(request);
            var result = new AResult<bool>(response);

            switch (response.StatusCode)
            {
                case 200:
                    if (response.DataType == DataType.Document)
                    {
                        result.Value = (response.Data as Dictionary<string, object>).Bool("result");
                        result.Success = result.Value;
                    }
                    break;
                case 400:
                case 403:
                case 404:
                default:
                    // Arango error
                    break;
            }

            _parameters.Clear();

            return result;
        }