Exemplo n.º 1
0
        public string GetPlusCodeTerrainDataFull(string plusCode)
        {
            //This function returns 1 line per Cell10 per intersecting element. For an app that needs to know all things in all points.
            PerformanceTracker pt  = new PerformanceTracker("GetPlusCodeTerrainDataFull");
            GeoArea            box = OpenLocationCode.DecodeValid(plusCode);

            if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), box))
            {
                return("");
            }
            var places = GetPlaces(box); //All the places in this Cell8

            places = places.Where(p => p.GameElementName != TagParser.defaultStyle.Name).ToList();

            StringBuilder sb = new StringBuilder();
            //pluscode|name|type|privacyID(named wrong but its the Guid)

            var data = AreaTypeInfo.SearchAreaFull(ref box, ref places);

            foreach (var d in data)
            {
                foreach (var v in d.Value)
                {
                    sb.Append(d.Key).Append("|").Append(v.Name).Append("|").Append(v.areaType).Append("|").Append(v.PrivacyId).Append("\r\n");
                }
            }
            var results = sb.ToString();

            pt.Stop(plusCode);
            return(results);
        }
Exemplo n.º 2
0
        [Route("/[controller]/SlippyAreaData/{styleSet}/{dataKey}/{zoom}/{x}/{y}.png")]                //slippy map conventions.
        public ActionResult DrawSlippyTileCustomPlusCodes(int x, int y, int zoom, string styleSet, string dataKey)
        {
            try
            {
                PerformanceTracker pt      = new PerformanceTracker("DrawSlippyTileCustomPlusCodes");
                string             tileKey = x.ToString() + "|" + y.ToString() + "|" + zoom.ToString();
                var info = new ImageStats(zoom, x, y, IMapTiles.SlippyTileSizeSquare);

                if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), info.area))
                {
                    pt.Stop("OOB");
                    return(StatusCode(500));
                }

                byte[] tileData = getExistingSlippyTile(tileKey, styleSet);
                if (tileData != null)
                {
                    pt.Stop(tileKey + "|" + styleSet);
                    return(File(tileData, "image/png"));
                }

                //Make tile
                var places   = GetPlacesForTile(info, null, styleSet);
                var paintOps = MapTileSupport.GetPaintOpsForCustomDataPlusCodes(dataKey, styleSet, info);
                tileData = FinishSlippyMapTile(info, paintOps, tileKey, styleSet);

                pt.Stop(tileKey + "|" + styleSet + "|" + Configuration.GetValue <string>("MapTilesEngine"));
                return(File(tileData, "image/png"));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex);
                return(StatusCode(500));
            }
        }
        protected void DgUserInitiatedTransactionsItemCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                dgUserInitiatedTransactions.SelectedIndex = e.Item.ItemIndex;

                long id = (DataCheck.IsNumeric(dgUserInitiatedTransactions.DataKeys[e.Item.ItemIndex].ToString())) ? long.Parse(dgUserInitiatedTransactions.DataKeys[e.Item.ItemIndex].ToString()) : 0;

                if (id < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid Record Selection!", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var transaction = ServiceProvider.Instance().GetExpenseTransactionServices().GetExpenseTransaction(id);

                if (transaction == null || transaction.ExpenseTransactionId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid record selection.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                LoadTransactionItems(transaction);
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin. Please try again soon or contact your site Admin.", ConfirmAlertBox.PopupMessageType.Error);
            }
        }
Exemplo n.º 4
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
            {
                filterContext.Controller.ViewBag.UserAuthInfo = null;
                base.OnActionExecuting(filterContext);
                return;
            }

            var frmId  = (FormsIdentity)filterContext.HttpContext.User.Identity;
            var usData = frmId.Ticket.UserData;

            if (string.IsNullOrEmpty(usData))
            {
                filterContext.Controller.ViewBag.UserAuthInfo = null;
                base.OnActionExecuting(filterContext);
                return;
            }

            var userDataSplit = usData.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            if (!userDataSplit.Any() || userDataSplit.Length != 3)
            {
                filterContext.Controller.ViewBag.UserAuthInfo = null;
                base.OnActionExecuting(filterContext);
                return;
            }

            if (!DataCheck.IsNumeric(userDataSplit[0].Trim()))
            {
                filterContext.Controller.ViewBag.UserAuthInfo = null;
                base.OnActionExecuting(filterContext);
                return;
            }

            var roles = userDataSplit[2].Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            var identity  = new FormsIdentity(frmId.Ticket);
            var principal = new StcPrincipal(identity, roles);

            var userData = new UserData
            {
                UserId   = long.Parse(userDataSplit[0].Trim()),
                Username = frmId.Name,
                Email    = userDataSplit[1].Trim(),
                Roles    = roles,
            };

            if (!MvcApplication.SetUserData(userData))
            {
                filterContext.Controller.ViewBag.UserAuthInfo = null;
                base.OnActionExecuting(filterContext);
                return;
            }


            filterContext.Controller.ViewBag.UserAuthInfo = userData;
            filterContext.HttpContext.User = principal;
            base.OnActionExecuting(filterContext);
        }
Exemplo n.º 5
0
        public void DeleteTest()
        {
            DataCheck v = new DataCheck();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.LeftTableID  = AddLeftTable();
                v.RightTableID = AddRightTable();
                v.ID           = 21;
                context.Set <DataCheck>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(DataCheckVM));

            DataCheckVM vm = rv.Model as DataCheckVM;

            v         = new DataCheck();
            v.ID      = vm.Entity.ID;
            vm.Entity = v;
            _controller.Delete(v.ID.ToString(), null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <DataCheck>().Count(), 0);
            }
        }
Exemplo n.º 6
0
        public void BatchDeleteTest()
        {
            DataCheck v1 = new DataCheck();
            DataCheck v2 = new DataCheck();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.LeftTableID  = AddLeftTable();
                v1.RightTableID = AddRightTable();
                v1.ID           = 21;
                v2.LeftTableID  = v1.LeftTableID;
                v2.RightTableID = v1.RightTableID;
                context.Set <DataCheck>().Add(v1);
                context.Set <DataCheck>().Add(v2);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() });

            Assert.IsInstanceOfType(rv.Model, typeof(DataCheckBatchVM));

            DataCheckBatchVM vm = rv.Model as DataCheckBatchVM;

            vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() };
            _controller.DoBatchDelete(vm, null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <DataCheck>().Count(), 0);
            }
        }
Exemplo n.º 7
0
        // ##########################################################################################
        //  xxx     x   x   xxxxx   xxxxx    xxx    x   x    xxxx
        //  x  x    x   x     x       x     x   x   xx  x   x
        //  xxxx    x   x     x       x     x   x   x x x    xxx
        //  x   x   x   x     x       x     x   x   x  xx       x
        //  xxxx     xxx      x       x      xxx    x   x   xxxx
        // ##########################################################################################
        private void buttonClient_Click(object sender, EventArgs e)
        {
            Errors    error_code = Errors.NO_ERROR;
            CryptType ctype      = (CryptType)comboBoxMenuCrypt.SelectedIndex;

            if (!DataCheck.CheckLogin(textBoxMenuLogin.Text, out error_code))
            {
                Messages.IncorrectLoginError(error_code);
            }
            if (!DataCheck.CheckIP(textBoxMenuIP.Text, out error_code))
            {
                Messages.IncorrectIPError(error_code);
            }
            if (!DataCheck.CheckPort(textBoxMenuPort.Text, out error_code))
            {
                Messages.IncorrectPortError(error_code);
            }
            int.TryParse(textBoxMenuPort.Text, out int port);

            client                     = new Client(textBoxMenuLogin.Text, textBoxMenuIP.Text, port, ctype);
            client.CliOutput           = rTextBoxClientMessage;
            client.CliList             = listViewClientUsers;
            client.FuncShowMessage     = ClientShowMessage;
            client.FuncDisconnect      = ClientDisableSend;
            client.FuncShutDown        = ClientLogout;
            panelMenu.Visible          = false;
            panelClient.Visible        = true;
            menuClient.Visible         = true;
            textBoxClient.Enabled      = true;
            buttonClientSend.Enabled   = true;
            rTextBoxClientMessage.Text = "";
            bgWorkerMenuTime.WorkerSupportsCancellation = true;
            bgWorkerMenuTime.RunWorkerAsync();
            client.Start();
        }
Exemplo n.º 8
0
        // ------------------------------------------------------------------------------------------
        private void buttonServer_Click(object sender, EventArgs e)
        {
            Errors error_code = Errors.NO_ERROR;

            if (!DataCheck.CheckLogin(textBoxMenuLogin.Text, out error_code))
            {
                Messages.IncorrectLoginError(error_code);
            }
            if (!DataCheck.CheckIP(textBoxMenuIP.Text, out error_code))
            {
                Messages.IncorrectIPError(error_code);
            }
            if (!DataCheck.CheckPort(textBoxMenuPort.Text, out error_code))
            {
                Messages.IncorrectPortError(error_code);
            }
            int.TryParse(textBoxMenuPort.Text, out int port);

            server                    = new Server(textBoxMenuLogin.Text, textBoxMenuIP.Text, port);
            server.SrvOutput          = textBoxServerConsole;
            server.FuncShutDown       = ServerLogout;
            panelMenu.Visible         = false;
            panelServer.Visible       = true;
            menuServer.Visible        = true;
            textBoxServerConsole.Text = "";
            bgWorkerMenuTime.WorkerSupportsCancellation = true;
            bgWorkerMenuTime.RunWorkerAsync();
            server.Start();
        }
        protected void lnkLeftPanelSectionNew_Click(object sender, EventArgs e)
        {
            // Get the full path of the current session's report definition file.
            string fileName = HttpContext.Current.Session["ReportDefinition"].ToString();

            // Create a new report definition by the file.
            ReportDefinition reportDefinition = new ReportDefinition(
                Global.Core,
                fileName,
                Global.HierarchyFilters[fileName]
                );

            // Clear the report definition.
            reportDefinition.Clear();

            // Clear the data check entries.
            DataCheck dataCheck = new DataCheck(fileName);

            dataCheck.Clear();

            // Self redirect to display clear crosstable.
            Response.Redirect(
                Request.Url.ToString()
                );
        }
Exemplo n.º 10
0
        private void tbbah_Validating(object sender, CancelEventArgs e)
        {
            char      bi;
            DataCheck dc = new DataCheck();

            if (this.tbbah.Text.Trim() == "")
            {
                this.dxErrorProvider.SetError(tbbah, "【备案号(VIN)】不能为空!");
            }
            else if (!dc.CheckCLSBDH(this.tbbah.Text.Trim().ToUpper(), out bi))
            {
                if (bi == '-')
                {
                    this.dxErrorProvider.SetError(tbbah, "请核对【备案号(VIN)】为17位字母或者数字!");
                }
                else
                {
                    this.dxErrorProvider.SetError(tbbah, "【备案号(VIN)】校验失败!第9位应为:'" + bi + "'");
                }
            }
            else
            {
                this.dxErrorProvider.SetError(tbbah, "");
            }
        }
Exemplo n.º 11
0
 private bool ValidateControls()
 {
     try
     {
         if (string.IsNullOrEmpty(txtTransactionType.Text.Trim()))
         {
             ConfirmAlertBox1.ShowMessage("Please supply an Expense Type.", ConfirmAlertBox.PopupMessageType.Error);
             txtTransactionType.Focus();
             mpeProcessTypesOfExpensesPopup.Show();
             return(false);
         }
         if (DataCheck.IsNumeric(txtTransactionType.Text.Trim()))
         {
             ConfirmAlertBox1.ShowMessage("Invalid entry!", ConfirmAlertBox.PopupMessageType.Error);
             txtTransactionType.Focus();
             mpeProcessTypesOfExpensesPopup.Show();
             return(false);
         }
         return(true);
     }
     catch
     {
         ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
         return(false);
     }
 }
        protected void DgPortalUsersEditCommand(Object source, DataGridCommandEventArgs e)
        {
            if (!(Page.User.IsInRole("PortalAdmin") || Page.User.IsInRole("SiteAdmin")))
            {
                ErrorDisplay1.ShowError("Sorry: You do not have access to this module!");
                return;
            }
            ErrorDisplay1.ClearError();
            dgPortalUsers.SelectedIndex = e.Item.ItemIndex;
            var userId = (DataCheck.IsNumeric(dgPortalUsers.DataKeys[e.Item.ItemIndex].ToString())) ? long.Parse(dgPortalUsers.DataKeys[e.Item.ItemIndex].ToString()) : 0;

            if (userId < 1)
            {
                ErrorDisplay1.ShowError("Invalid Selection");
                return;
            }

            Session["_selectedUser"] = null;
            if (!BindUSer(userId))
            {
                return;
            }

            btnSubmit.CommandArgument = "2";     // Update Item
            btnSubmit.Text            = "Update User";
            mpeDisplayJobDetails.Show();
        }
Exemplo n.º 13
0
        [Route("/[controller]/AreaPlaceData/{code}/{styleSet}/{dataKey}")] //Draw an area using place data.
        public ActionResult DrawPlusCodeCustomElements(string code, string styleSet, string dataKey)
        {
            try
            {
                PerformanceTracker pt = new PerformanceTracker("DrawTilePlace");
                MapTileSupport.GetPlusCodeImagePixelSize(code, out var imgX, out var imgY);
                var info = new ImageStats(OpenLocationCode.DecodeValid(code), imgX, imgY);

                if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), info.area))
                {
                    pt.Stop("OOB");
                    return(StatusCode(500));
                }

                byte[] tileData = getExistingSlippyTile(code, styleSet);
                if (tileData != null)
                {
                    pt.Stop(code + "|" + styleSet);
                    return(File(tileData, "image/png"));
                }

                //Make tile
                var places   = GetPlacesForTile(info, null, styleSet, false);
                var paintOps = MapTileSupport.GetPaintOpsForCustomDataElements(dataKey, styleSet, info);
                tileData = FinishMapTile(info, paintOps, code, styleSet);

                pt.Stop(code + "|" + styleSet + "|" + Configuration.GetValue <string>("MapTilesEngine"));
                return(File(tileData, "image/png"));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex);
                return(StatusCode(500));
            }
        }
Exemplo n.º 14
0
        public void IncrementPlusCodeData(string plusCode, string key, double changeAmount, double?expirationTimer = null)
        {
            if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), OpenLocationCode.DecodeValid(plusCode)))
            {
                return;
            }

            PerformanceTracker pt      = new PerformanceTracker("IncrementPlusCodeData");
            string             lockKey = plusCode + key;

            locks.TryAdd(lockKey, new ReaderWriterLockSlim());
            var thisLock = locks[lockKey];

            thisLock.EnterWriteLock();
            var    data = GenericData.GetAreaData(plusCode, key);
            double val  = 0;

            Double.TryParse(data.ToString(), out val);
            val += changeAmount;
            GenericData.SetAreaData(plusCode, key, val.ToString(), expirationTimer);
            thisLock.ExitWriteLock();

            if (thisLock.WaitingWriteCount == 0)
            {
                locks.TryRemove(lockKey, out thisLock);
            }

            pt.Stop();
        }
Exemplo n.º 15
0
        private bool ValidateControls()
        {
            ErrorDisplayProcessExpenseCategory.ClearError();
            if (string.IsNullOrEmpty(txtTitle.Text.Trim()))
            {
                ErrorDisplayProcessExpenseCategory.ShowError("Please supply an Expense Category.");
                txtTitle.Focus();
                mpeProcessExpenseCategory.Show();
                return(false);
            }

            if (string.IsNullOrEmpty(txtCode.Text.Trim()))
            {
                ErrorDisplayProcessExpenseCategory.ShowError("Please supply a code for the category.");
                txtCode.Focus();
                mpeProcessExpenseCategory.Show();
                return(false);
            }

            if (!DataCheck.IsNumeric(txtCode.Text.Trim()))
            {
                ErrorDisplayProcessExpenseCategory.ShowError("Invalid entry!");
                txtCode.Focus();
                mpeProcessExpenseCategory.Show();
                return(false);
            }

            return(true);
        }
Exemplo n.º 16
0
        protected void DgAllTransactionPaymentsCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                dgAllTransactionPayments.SelectedIndex = e.Item.ItemIndex;

                long id = (DataCheck.IsNumeric(dgAllTransactionPayments.DataKeys[e.Item.ItemIndex].ToString())) ? long.Parse(dgAllTransactionPayments.DataKeys[e.Item.ItemIndex].ToString()) : 0;

                if (id < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid Record Selection!", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var expenseTransactionPayment = ServiceProvider.Instance().GetExpenseTransactionPaymentServices().GetExpenseTransactionPayment(id);

                if (expenseTransactionPayment == null || expenseTransactionPayment.ExpenseTransactionId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid record selection.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                LoadTransactionPaymentHistory(expenseTransactionPayment.ExpenseTransactionId);
                //dvTransactionPayments.Visible = false;
                //dvTransactionPaymentHistory.Visible = true;
                dvView.Visible       = true;
                dvAllContent.Visible = false;
            }

            catch
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
            }
        }
Exemplo n.º 17
0
        public string GetPlusCodeTerrainData(string plusCode)
        {
            //This function returns 1 line per Cell10, the smallest (and therefore highest priority) item intersecting that cell10.
            PerformanceTracker pt  = new PerformanceTracker("GetPlusCodeTerrainData");
            GeoArea            box = OpenLocationCode.DecodeValid(plusCode);

            if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), box))
            {
                return("");
            }
            var places = GetPlaces(box);

            places = places.Where(p => p.GameElementName != TagParser.defaultStyle.Name).ToList();

            StringBuilder sb = new StringBuilder();
            //pluscode|name|type|PrivacyID

            var data = AreaTypeInfo.SearchArea(ref box, ref places);

            foreach (var d in data)
            {
                sb.Append(d.Key).Append("|").Append(d.Value.Name).Append("|").Append(d.Value.areaType).Append("|").Append(d.Value.PrivacyId).Append("\r\n");
            }
            var results = sb.ToString();

            pt.Stop(plusCode);
            return(results);
        }
        private void LoadTransactionsFooter()
        {
            try
            {
                if (dgExpenseItem.Items.Count > 0)
                {
                    //int subTotalQuantity = 0;
                    //int subTotalApprovedQuantity = 0;
                    double subTotalUnitPrice     = 0;
                    double subTotalApprovedPrice = 0;

                    for (var i = 0; i < dgExpenseItem.Items.Count; i++)
                    {
                        //subTotalQuantity += DataCheck.IsNumeric(((Label)dgExpenseItem.Items[i].FindControl("lblQuantity")).Text)
                        //              ? int.Parse(((Label)dgExpenseItem.Items[i].FindControl("lblQuantity")).Text) : 0;
                        //subTotalApprovedQuantity += DataCheck.IsNumeric(((Label)dgExpenseItem.Items[i].FindControl("lblApprovedQuantity")).Text)
                        //              ? int.Parse(((Label)dgExpenseItem.Items[i].FindControl("lblApprovedQuantity")).Text) : 0;
                        subTotalUnitPrice += DataCheck.IsNumeric(((Label)dgExpenseItem.Items[i].FindControl("lblUnitPrice")).Text)
                                      ? float.Parse(((Label)dgExpenseItem.Items[i].FindControl("lblUnitPrice")).Text) : 0;
                        subTotalApprovedPrice += DataCheck.IsNumeric(((Label)dgExpenseItem.Items[i].FindControl("lblApprovedUnitPrice")).Text)
                                      ? float.Parse(((Label)dgExpenseItem.Items[i].FindControl("lblApprovedUnitPrice")).Text) : 0;
                    }

                    foreach (var item in dgExpenseItem.Controls[0].Controls)
                    {
                        if (item.GetType() == typeof(DataGridItem))
                        {
                            var itmType = ((DataGridItem)item).ItemType;
                            if (itmType == ListItemType.Footer)
                            {
                                //if (((DataGridItem)item).FindControl("lblTotalQuantity") != null)
                                //{
                                //    ((Label)((DataGridItem)item).FindControl("lblTotalQuantity")).Text = subTotalQuantity.ToString(CultureInfo.InvariantCulture);
                                //}

                                //if (((DataGridItem)item).FindControl("lblTotalApprovedQuantity") != null)
                                //{
                                //    ((Label)((DataGridItem)item).FindControl("lblTotalApprovedQuantity")).Text = subTotalApprovedQuantity.ToString(CultureInfo.InvariantCulture);
                                //}

                                if (((DataGridItem)item).FindControl("lblTotalUnitPrice") != null)
                                {
                                    ((Label)((DataGridItem)item).FindControl("lblTotalUnitPrice")).Text = "N" + NumberMap.GroupToDigits(subTotalUnitPrice.ToString(CultureInfo.InvariantCulture));
                                }

                                if (((DataGridItem)item).FindControl("lblTotalApprovedUnitPrice") != null)
                                {
                                    ((Label)((DataGridItem)item).FindControl("lblTotalApprovedUnitPrice")).Text = "N" + NumberMap.GroupToDigits(subTotalApprovedPrice.ToString(CultureInfo.InvariantCulture));
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
            }
        }
Exemplo n.º 19
0
 public bool SetPlusCodeData(string plusCode, string key, string value, double?expiresIn = null)
 {
     if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), OpenLocationCode.DecodeValid(plusCode)))
     {
         return(false);
     }
     return(GenericData.SetAreaData(plusCode, key, value, expiresIn));
 }
Exemplo n.º 20
0
 /// <summary>
 /// 链表添加
 /// </summary>
 /// <param name="input"></param>
 public void AddNum(string input)
 {
     input = DataCheck.RepLanguage(input);
     string[] str = input.Split(';');
     double[] arr = Sort.BubbleSort(Utils.GetStrToDoubleArr(str[0]));
     double[] num = Utils.GetStrToDoubleArr(str[1]);
     ResWrite(LinkListAdd(arr, num).ToString(" , "));
 }
Exemplo n.º 21
0
            private DataCheck check;            // Checking class

            /// <summary>
            /// Initialize an order with fieldDesc class injection
            /// </summary>
            /// <param name="_logger"></param>
            /// <param name="_fieldDesc"></param>
            public Order(ref Logger _logger)
            {
                logger = _logger;
                check  = new DataCheck(ref logger);

                // Load fields
                InitializefieldDesc();
            }
Exemplo n.º 22
0
 public void checkPolynomInput()
 {
     Assert.AreEqual(DataCheck.polynomCheck("3x^2+2x+1"), true);
     Assert.AreEqual(DataCheck.polynomCheck("2+3x^5+x^4+x"), true);
     Assert.AreEqual(DataCheck.polynomCheck("7x"), true);
     Assert.AreEqual(DataCheck.polynomCheck("2x+y"), false);
     Assert.AreEqual(DataCheck.polynomCheck("33xa^2+6"), false);
     Assert.AreEqual(DataCheck.polynomCheck(""), false);
 }
Exemplo n.º 23
0
 public void checkArgumentInput()
 {
     Assert.AreEqual(DataCheck.argumentCheck("32"), true);
     Assert.AreEqual(DataCheck.argumentCheck("4"), true);
     Assert.AreEqual(DataCheck.argumentCheck("5"), true);
     Assert.AreEqual(DataCheck.argumentCheck("sa"), false);
     Assert.AreEqual(DataCheck.argumentCheck("8d"), false);
     Assert.AreEqual(DataCheck.argumentCheck(""), false);
 }
Exemplo n.º 24
0
        protected void DgPaymentHistoryCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                if (Session["_paymentHistoryList"] == null)
                {
                    ErrorDisplay1.ShowError("Transaction Payment History is empty or session has expired.");
                    return;
                }

                var expenseTransactionPaymentHistoryList = Session["_paymentHistoryList"] as List <StaffExpenseTransactionPaymentHistory>;

                if (expenseTransactionPaymentHistoryList == null || !expenseTransactionPaymentHistoryList.Any())
                {
                    ErrorDisplay1.ShowError("Transaction Payment History is empty or session has expired.");
                    return;
                }

                dgPaymentHistory.SelectedIndex = e.Item.ItemIndex;

                long id = (DataCheck.IsNumeric(dgPaymentHistory.DataKeys[e.Item.ItemIndex].ToString())) ? long.Parse(dgPaymentHistory.DataKeys[e.Item.ItemIndex].ToString()) : 0;

                if (id < 1)
                {
                    ErrorDisplay1.ShowError("Invalid Record Selection!");
                    return;
                }

                var transactionHistory =
                    expenseTransactionPaymentHistoryList.Find(m => m.StaffExpenseTransactionPaymentHistoryId == id);

                if (transactionHistory == null || transactionHistory.StaffExpenseTransactionPaymentHistoryId < 1)
                {
                    ErrorDisplay1.ShowError("Invalid selection");
                    return;
                }

                if (transactionHistory.Comment == null)
                {
                    ErrorDisplay1.ShowError("There is no comment for the selected transaction");
                }

                else
                {
                    lgTransactionTitle.InnerHtml           = transactionHistory.StaffExpenseTransaction.ExpenseTitle;
                    txtHistoryComment.Text                 = transactionHistory.Comment;
                    mpePaymentCommentPopup.PopupControlID  = dvTransactionComment.ID;
                    mpePaymentCommentPopup.CancelControlID = btnCloseComment.ID;
                    mpePaymentCommentPopup.Show();
                }
            }
            catch
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
            }
        }
Exemplo n.º 25
0
        private void cbDataCheckType_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataWidth = 8;

            if (_DataBytes == null)
            {
                return;
            }

            gbCRCParam.Enabled = false;

            int index = cbDataCheckType.SelectedIndex;

            if (index == 0)
            {
                dataWidth = 16;
            }
            else if (index == 1)
            {
                dataWidth = 8;
            }
            else if (index == 2)
            {
                dataWidth = 8;
            }
            else
            {
                gbCRCParam.Enabled = true;
                CRCType crcType = (CRCType)(index - 3);
                CRCInfo crcInfo = DataCheck.GetCRCInfo(crcType);

                chkRefIn.Checked  = crcInfo.RefIn;
                chkRefOut.Checked = crcInfo.RefOut;
                chkXorOut.Checked = crcInfo.XorOut == 0 ? false : true;

                if (crcType >= CRCType.CRC16_IBM && crcType <= CRCType.CRC16_DNP)
                {
                    txtPoly.Text = string.Format("{0:X4}", crcInfo.Poly);
                    txtInit.Text = string.Format("{0:X4}", crcInfo.Init);

                    dataWidth = 16;
                }
                else if (crcType >= CRCType.CRC32 && crcType <= CRCType.CRC32_MPEG2)
                {
                    txtPoly.Text = string.Format("{0:X8}", crcInfo.Poly);
                    txtInit.Text = string.Format("{0:X8}", crcInfo.Init);

                    dataWidth = 32;
                }
            }


            CalCheckData();
        }
Exemplo n.º 26
0
        protected void DgExpenseTransactionEditCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                if (Session["_transactionItems"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var transactionItems = Session["_transactionItems"] as List <TransactionItem>;

                if (transactionItems == null || !transactionItems.Any())
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                dgExpenseItem.SelectedIndex = e.Item.ItemIndex;

                var id = (DataCheck.IsNumeric(dgExpenseItem.DataKeys[e.Item.ItemIndex].ToString())) ? int.Parse(dgExpenseItem.DataKeys[e.Item.ItemIndex].ToString()) : 0;

                if (id < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid Record Selection!", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var transactionItem = transactionItems.Find(m => m.TransactionItemId == id);

                if (transactionItem == null || transactionItem.TransactionItemId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid selection.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                textApprouvedQuantity.Value   = string.Empty;
                textApprovedUnitPrice.Value   = string.Empty;
                btnUpdateTransactionItem.Text = "Update";
                ddlExpenseItem.SelectedValue  = transactionItem.ExpenseItem.ExpenseItemId.ToString(CultureInfo.InvariantCulture);
                ddlExpenseType.SelectedValue  = transactionItem.ExpenseTypeId.ToString(CultureInfo.InvariantCulture);
                txtQuantity.Text              = transactionItem.RequestedQuantity.ToString(CultureInfo.InvariantCulture);
                txtUnitPrice.Text             = transactionItem.RequestedUnitPrice.ToString(CultureInfo.InvariantCulture);
                txtTotalRequestedPrice.Value  = transactionItem.TotalPrice.ToString(CultureInfo.InvariantCulture);
                btnUpdateTransactionItem.Text = "Update";
                mpeExpenseItemsPopup.Show();
                Session["_transactionItem"] = transactionItem;
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("The Edit process could not be initiated. Please try again.", ConfirmAlertBox.PopupMessageType.Error);
            }
        }
Exemplo n.º 27
0
 internal static bool shouldClearCache(string itemName)
 {
     try
     {
         var status = ConfigurationManager.AppSettings.Get(itemName);
         return(!string.IsNullOrEmpty(status) && DataCheck.IsNumeric(status) && int.Parse(status) == 1);
     }
     catch (Exception)
     {
         return(true);
     }
 }
Exemplo n.º 28
0
        public void GetSecurePlusCodeData(string plusCode, string key, string password)
        {
            if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), OpenLocationCode.DecodeValid(plusCode)))
            {
                return;
            }

            byte[] rawData = GenericData.GetSecureAreaData(plusCode, key, password);
            Response.BodyWriter.Write(rawData);
            Response.CompleteAsync();
            return;
        }
Exemplo n.º 29
0
        private void LoadTransactionPaymentFooter()
        {
            try
            {
                if (dgAllTransactionPayments.Items.Count > 0)
                {
                    double expAmountPayableTotal = 0;
                    double expAmountPaidTotal    = 0;
                    double totalBalance          = 0;
                    for (var i = 0; i < dgAllTransactionPayments.Items.Count; i++)
                    {
                        expAmountPayableTotal += DataCheck.IsNumeric(((Label)dgAllTransactionPayments.Items[i].FindControl("lblTotalAmountPaid")).Text)
                                      ? double.Parse(((Label)dgAllTransactionPayments.Items[i].FindControl("lblTotalAmountPaid")).Text)
                                      : 0;
                        expAmountPaidTotal += DataCheck.IsNumeric(((Label)dgAllTransactionPayments.Items[i].FindControl("lblAmountPaid")).Text)
                                     ? double.Parse(((Label)dgAllTransactionPayments.Items[i].FindControl("lblAmountPaid")).Text)
                                     : 0;
                        totalBalance += DataCheck.IsNumeric(((Label)dgAllTransactionPayments.Items[i].FindControl("lblBalance")).Text)
                                     ? double.Parse(((Label)dgAllTransactionPayments.Items[i].FindControl("lblBalance")).Text)
                                     : 0;
                    }

                    foreach (var item in dgAllTransactionPayments.Controls[0].Controls)
                    {
                        if (item.GetType() == typeof(DataGridItem))
                        {
                            var itmType = ((DataGridItem)item).ItemType;
                            if (itmType == ListItemType.Footer)
                            {
                                if (((DataGridItem)item).FindControl("lblTotalAmountPaidFooter") != null)
                                {
                                    ((Label)((DataGridItem)item).FindControl("lblTotalAmountPaidFooter")).Text = "N" + NumberMap.GroupToDigits(expAmountPayableTotal.ToString(CultureInfo.InvariantCulture));
                                }
                                if (((DataGridItem)item).FindControl("lblAmountPaidFooter") != null)
                                {
                                    ((Label)((DataGridItem)item).FindControl("lblAmountPaidFooter")).Text = "N" + NumberMap.GroupToDigits(expAmountPaidTotal.ToString(CultureInfo.InvariantCulture));
                                }
                                if (((DataGridItem)item).FindControl("lblBalanceFooter") != null)
                                {
                                    ((Label)((DataGridItem)item).FindControl("lblBalanceFooter")).Text = "N" + NumberMap.GroupToDigits(totalBalance.ToString(CultureInfo.InvariantCulture));
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
            }
        }
Exemplo n.º 30
0
        public void GetPlusCodeData(string plusCode, string key)
        {
            if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), OpenLocationCode.DecodeValid(plusCode)))
            {
                return;
            }

            var data = GenericData.GetAreaData(plusCode, key); //TODO: this requires writing bytes directly to Response.BodyWriter for all other, similar functions.

            Response.BodyWriter.WriteAsync(data);
            Response.CompleteAsync();
            return;
        }