Esempio n. 1
0
        /// <summary>
        /// Register information on the current mapping cycle
        /// </summary>
        /// <param name="description"></param>
        /// <param name="fileName"></param>
        public static void Information(string description, [CallerFilePath] string fileName = null)
        {
            if (string.IsNullOrEmpty(description))
            {
                throw new Exception("description cannot be null or empty");
            }

            try
            {
                var stackFrame = new StackFrame(1);

                var details = new Details()
                {
                    RadarType    = RadarType.Information.ToString(),
                    Description  = description,
                    VariableType = string.Empty,
                    Value        = string.Empty,
                    FileName     = fileName,
                    Method       = stackFrame.GetMethod().Name,
                    Environment  = Environment.MachineName
                };

                FireBase.InsertData(details);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 2
0
        private async void simpleButton1_Click(object sender, EventArgs e)
        {
            if (Sounding?.InnerList?.Count == 0)
            {
                XtraMessageBox.Show(_localization.LoadText(1061), _localization.LoadText(1037), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            Sounding.UpdateData(true, true, false, 5);
            var    serializedJson = JsonConvert.SerializeObject(Sounding.InnerList);
            string fileName       = Path.Combine(Path.GetTempFileName());

            using (StreamWriter myWriter = File.CreateText(fileName))
            {
                myWriter.WriteLine(serializedJson);
            }
            if (File.Exists(fileName))
            {
                SplashScreenManager.ShowForm(this, typeof(ProgressControl), true, true);
                SplashScreenManager.Default.SetWaitFormCaption(_localization.LoadText(3700));
                FireBase.SetProgress += (s, arg) => SplashScreenManager.Default.SetWaitFormDescription(_localization.LoadText(1062) + ": " + arg + "% " + _localization.LoadText(1063));
                await FireBase.AddFlight(fileName, StationId, Sounding.StartTime, Temp100FileName, TempEndFileName);

                SplashScreenManager.CloseForm(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Register information about the variable on the current map cycle
        /// </summary>
        /// <param name="variable"></param>
        /// <param name="description"></param>
        /// <param name="fileName"></param>
        public static void Track(this object variable, string description = "", [CallerFilePath] string fileName = null)
        {
            try
            {
                var stackFrame    = new StackFrame(1);
                var variableValue = variable.ToString();

                if (variable.GetType().IsGenericType)
                {
                    variableValue = JsonConvert.SerializeObject(variable);
                }

                var details = new Details()
                {
                    RadarType    = RadarType.Track.ToString(),
                    Description  = description,
                    VariableType = variable.GetType().Name,
                    Value        = variableValue,
                    FileName     = fileName,
                    Method       = stackFrame.GetMethod().Name,
                    Environment  = Environment.MachineName
                };

                FireBase.InsertData(details);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 4
0
        public async Task GetStation()
        {
            if (StationSetting != null)
            {
                SplashScreenManager.ShowDefaultWaitForm(_localization.LoadText(3700), _localization.LoadText(1055));
                StationObject = await FireBase.GetStation(StationSetting?.Id ?? 0);

                SplashScreenManager.CloseDefaultWaitForm();
                await UpdateUi();
            }
        }
Esempio n. 5
0
 private void Awake()
 {
     Instance = this;
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Instance = null;
     }
     // Set this before calling into the realtime database.
     FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://farming-in-purria.firebaseio.com/");
 }
Esempio n. 6
0
        /// <summary>
        /// Start the current map of execution steps ,
        /// don't need to pass the fileName !
        /// </summary>
        /// <param name="authKey"></param>
        /// <param name="baseUrl"></param>
        /// <param name="jsonPath"></param>
        /// <param name="description"></param>
        /// <param name="fileName"></param>
        public static void StartRadar(string authKey, string baseUrl, string jsonPath, string description, [CallerFilePath] string fileName = null)
        {
            if (string.IsNullOrEmpty(authKey))
            {
                throw new Exception("authKey cannot be null");
            }

            if (string.IsNullOrEmpty(baseUrl))
            {
                throw new Exception("baseUrl cannot be null");
            }

            if (string.IsNullOrEmpty(jsonPath))
            {
                throw new Exception("jsonPath cannot be null");
            }

            if (!jsonPath.ToLower().Contains(".json"))
            {
                throw new Exception("jsonPath need specify the extension");
            }

            try
            {
                var stackFrame = new StackFrame(1);

                FireBase.AuthKey  = authKey;
                FireBase.BaseUrl  = baseUrl;
                FireBase.JsonPath = jsonPath;

                var details = new Details()
                {
                    RadarType    = RadarType.StartRadar.ToString(),
                    Description  = description,
                    VariableType = string.Empty,
                    Value        = string.Empty,
                    FileName     = fileName,
                    Method       = stackFrame.GetMethod().Name,
                    Environment  = Environment.MachineName
                };

                FireBase.InsertData(details);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 7
0
        public void InsertData_WithOut_StartRadar()
        {
            //Arrange
            var details = new Details()
            {
                RadarType    = "TestType",
                Description  = "TestDescription",
                VariableType = "TestVariableType",
                Value        = "TestValue",
                FileName     = "FileNameTest",
                Method       = "MethodTest",
                Environment  = Environment.MachineName
            };

            //Act & Assert
            Assert.ThrowsException <UriFormatException>(() => FireBase.InsertData(details));
        }
Esempio n. 8
0
        public async Task <IActionResult> Send(string Id, string text, bool save)
        {
            List <string> Ids    = new List <string>();
            List <Device> device = unit.Device.GetByUserId(Guid.Parse(Id));

            device.ForEach(p => Ids.Add(p.PushId));

            FireBase.SendNotification(text, Ids);
            //if (save)
            //{
            //    unit.Notification.Add(new Notification { RegisterDate = Utility.Utility.UnixTimeNow(), Text = text });
            //    unit.Complete();
            //}
            dynamic temp = new { ok = "Ok" };

            return(new OkObjectResult(temp));
        }
Esempio n. 9
0
    override protected void Start()
    {
        base.Start();

        FireBase fireBase = UseForceToFire ? gameObject.GetOrAddComponent <FireWithForce>() : (FireBase)gameObject.GetOrAddComponent <FireWithoutForce>();

        fireBase.Player = Player;
        fireBase.Init();

        _fire = () =>
        {
            if (DateTime.Now.Subtract(_lastFire).TotalMilliseconds > MinTimeBetweenContinuesFire)
            {
                _lastFire = DateTime.Now;
                fireBase.Fire(FireSpeed);
            }
        };
    }
Esempio n. 10
0
        public Response ApproveAppRequest(Int64 AppId, Int64 UserId)
        {
            Response r = new Response();

            try
            {
                FireBase           fb          = new FireBase();
                WebConfig          wc          = new WebConfig();
                string             FirebaseKey = wc.AppSettings("AirViewStore");
                Sec_UserSettingsDL usd         = new Sec_UserSettingsDL();
                bool Result = usd.Manage("Set_IsRequestApproved", UserId, AppId, AppId.ToString(), null);

                if (Result)
                {
                    var dt = usd.GetDataTable("Get_UserAppToken", UserId.ToString(), AppId.ToString());
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        dynamic result = fb.SendNotification(FirebaseKey, dt.Rows[0]["Token"].ToString(), "{ \"EmailPIN\": \"" + dt.Rows[0]["EmailPIN"].ToString() + "\", \"MobilePIN\": \"" + dt.Rows[0]["MobilePIN"].ToString() + "\"}");

                        r.Status  = "success";
                        r.Message = "success";
                        r.Value   = result;
                    }
                    else
                    {
                        r.Status  = "error";
                        r.Message = "Device not found.";
                    }
                }
                else
                {
                    r.Status  = "error";
                    r.Message = "Request not fund.";
                }
            }
            catch (Exception ex)
            {
                r.Status  = "error";
                r.Message = ex.Message;
            }

            return(r);
        }
Esempio n. 11
0
        /// <summary>
        /// Map Exception information
        /// </summary>
        /// <param name="exception"></param>
        /// <param name="description"></param>
        /// <param name="fileName"></param>
        public static void Error(this Exception exception, string description = "", [CallerFilePath] string fileName = null)
        {
            try
            {
                var stackFrame = new StackFrame(1);

                var details = new Details()
                {
                    RadarType    = RadarType.Error.ToString(),
                    Description  = description,
                    VariableType = exception.GetType().Name,
                    Value        = exception.Message,
                    FileName     = fileName,
                    Method       = stackFrame.GetMethod().Name,
                    Environment  = Environment.MachineName
                };

                FireBase.InsertData(details);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 12
0
 public void InsertData_Throws()
 {
     //Arrange & Act & Assert
     Assert.ThrowsException <Exception>(() => FireBase.InsertData(null));
 }
Esempio n. 13
0
 void Start()
 {
     firingScript = GetComponent <FireBase>();
 }
        private async Task <Tuple <bool, bool, bool> > RunHeadGestureOnImageFrame(string filePath)
        {
            var  headGestureResult = "";
            bool runStepOne        = true;
            bool runStepTwo        = true;
            bool runStepThree      = true;
            bool stepOneComplete   = false;
            bool stepTwoComplete   = false;
            bool stepThreeComplete = false;

            var buffPitch = new List <double>();
            var buffYaw   = new List <double>();
            var buffRoll  = new List <double>();

            var files = Directory.GetFiles(filePath);

            foreach (var item in files)
            {
                if (item.EndsWith("mp4"))
                {
                    continue;
                }
                var fileName  = item.Split('\\').Last();
                var imageName = fileName.Split('.').First();

                //UPLOAD IMAGE TO FIREBASE
                // var baseString = GetBaseStringFromImagePath(item);
                byte[] imageArray      = System.IO.File.ReadAllBytes(item);
                var    uploadedContent = await FireBase.UploadDocumentAsync(fileName, imageName, item);

                // Submit image to API.
                var attrs = new List <FaceAttributeType> {
                    FaceAttributeType.HeadPose
                };

                //TODO: USE IMAGE URL OF NETWORK
                var faces = await client.Face.DetectWithUrlWithHttpMessagesAsync(uploadedContent, returnFaceId : false, returnFaceAttributes : attrs);

                if (faces.Body.Count <= 0)
                {
                    continue;
                }
                var headPose = faces.Body.First().FaceAttributes?.HeadPose;

                var pitch = headPose.Pitch;
                var roll  = headPose.Roll;
                var yaw   = headPose.Yaw;


                if (runStepOne)
                {
                    headGestureResult = StepOne(buffPitch, pitch);
                    if (!string.IsNullOrEmpty(headGestureResult))
                    {
                        runStepOne      = false;
                        stepOneComplete = true;
                    }
                }

                if (runStepTwo)
                {
                    headGestureResult = StepTwo(buffYaw, yaw);
                    if (!string.IsNullOrEmpty(headGestureResult))
                    {
                        runStepTwo      = false;
                        stepTwoComplete = true;
                    }
                }

                if (runStepThree)
                {
                    headGestureResult = StepThree(buffRoll, roll);
                    if (!string.IsNullOrEmpty(headGestureResult))
                    {
                        runStepThree      = false;
                        stepThreeComplete = true;
                    }
                }
            }
            return(new Tuple <bool, bool, bool>(stepOneComplete, stepTwoComplete, stepThreeComplete));
        }
Esempio n. 15
0
        private async void simpleButton1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textEdit1.Text) || string.IsNullOrEmpty(textEdit2.Text) ||
                string.IsNullOrEmpty(textEdit3.Text) || string.IsNullOrEmpty(textEdit4.Text) ||
                string.IsNullOrEmpty(textEdit5.Text) || string.IsNullOrEmpty(textEdit6.Text) ||
                string.IsNullOrEmpty(textEdit7.Text))
            {
                XtraMessageBox.Show(_localization.LoadText(1036), _localization.LoadText(1037), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            var station = new Station()
            {
                Id        = textEdit1.Text.ToInteger(),
                Name      = textEdit2.Text,
                City      = textEdit3.Text,
                Country   = textEdit4.Text,
                Latitude  = textEdit5.Text,
                Longitude = textEdit6.Text,
                Altitude  = textEdit7.Text,
                IsPublic  = checkEdit1.Checked
            };

            var fileName = $"{station.Id}_{station.Name}.png";

            //if (!string.IsNullOrEmpty(StationObject.Object.ImageName) && !string.Equals(fileName, StationObject.Object.ImageName))
            //{
            //    await FireBase.AddImage(StationObject.Object.ImageName);
            //}

            if (!FormulaLib.IsNumeric(station.Id))
            {
                XtraMessageBox.Show(_localization.LoadText(1060),
                                    _localization.LoadText(3738), MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                if (_imageChanged)
                {
                    pictureEdit1.Image.Save(fileName, ImageFormat.Png);

                    var pictureUrl = await FireBase.AddImage(fileName);

                    File.Delete(fileName);
                    if (!string.IsNullOrEmpty(pictureUrl))
                    {
                        station.ImageName = fileName;
                        station.ImageUrl  = pictureUrl;
                    }
                }
                else
                {
                    station.ImageName = StationObject.Object.ImageName;
                    station.ImageUrl  = StationObject.Object.ImageUrl;
                }

                if (StationObject != null && StationObject.Object.Id.Equals(station.Id))
                {
                    SplashScreenManager.ShowDefaultWaitForm(_localization.LoadText(3700), _localization.LoadText(1056));
                    var r = await FireBase.ChangeStation(station, StationObject.Key);

                    SplashScreenManager.CloseDefaultWaitForm();
                }
                else
                {
                    SplashScreenManager.ShowDefaultWaitForm(_localization.LoadText(3700), _localization.LoadText(1057));
                    var result = await FireBase.AddStation(station);

                    SplashScreenManager.CloseDefaultWaitForm();
                    if (!result)
                    {
                        XtraMessageBox.Show(_localization.LoadText(1046) + " " + FireBase.ErrorText, _localization.LoadText(1037), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                }
                SplashScreenManager.ShowDefaultWaitForm(_localization.LoadText(3700), _localization.LoadText(1058));
                var s = await FireBase.GetStation(station.Id);

                SplashScreenManager.CloseDefaultWaitForm();
                if (s != null)
                {
                    XtraMessageBox.Show(_localization.LoadText(1561) + " " + s.Object.Name + " " + _localization.LoadText(1059), _localization.LoadText(3841), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }