public void RaiseTestCase1()
        {
            var helperClass = new HelperClass();
            var eventArgs = new SampleEventArgs( RandomValueEx.GetRandomString() );
            helperClass.RaiseGenericEvent( eventArgs );

            SampleEventArgs actual = null;
            helperClass.MyGenericEvent += ( sender, e ) => actual = e;
            helperClass.RaiseGenericEvent( eventArgs );
            Assert.AreSame( eventArgs, actual );
        }
 public static void Save()
 {
     try
     {
         using (FileStream stream = new FileStream(SettingsPath, FileMode.Create))
         {
             BinaryFormatter bin = new BinaryFormatter();
             HelperClass hc = new HelperClass();
             bin.Serialize(stream, hc);
         }
     }
     catch (Exception ex) { MessageBox.Show("Couldn´t write Settings!" + Environment.NewLine + ex.Message, Gtk.MessageType.Error, Gtk.ButtonsType.Ok); }
 }
        public ForLoopCounterCondition()
        {
            int k, j = 3;
            for (int i = 0; i < 10; i++)
            {

            }
            for (P = 0; P < 10; P++)
            {

            }

            for (int a = 0, b = 5; a + b < 10; a++, b += a)
            {
                //do some stuff
            }

            for (int i = 0; i < 5; )
            {

            }

            for (int i = 0; i < 10; j++) //Noncompliant {{This loop's stop condition tests "i" but the incrementer updates "j".}}
//                          ^^^^^^
            {

            }
            for (int i = 0; ; i++) //Noncompliant {{This loop's stop incrementer updates "i" but the stop condition doesn't test any variables.}}
            {

            }

            var o = new HelperClass();
            for (k = 0; someMethod(o) < 10; P++, j++, o.Property--, someMethod(o)) //Compliant
            {
                o.Property = P;
            }

            for (k = 0; k < 10; o.Property--) //Noncompliant
            {
                o.Property = P;
            }

            for (k = 0; someMethod(o) < 10; o.Property--)
            {
                o.Property = P;
            }
        }
        public ForLoopCounterCondition()
        {
            int k, j = 3;
            for (int i = 0; i < 10; i++)
            {

            }
            for (P = 0; P < 10; P++)
            {

            }

            for (int a = 0, b = 5; a + b < 10; a++, b += a)
            {
                //do some stuff
            }

            for (int i = 0; i < 5; )
            {

            }

            for (int i = 0; i < 10; j++) //Noncompliant
            {

            }
            for (int i = 0; ; i++) //Noncompliant
            {

            }

            var o = new HelperClass();
            for (k = 0; someMethod(o) < 10; P++, j++, o.Property--, someMethod(o)) //Compliant
            {
                o.Property = P;
            }

            for (k = 0; k < 10; o.Property--) //Noncompliant
            {
                o.Property = P;
            }

            for (k = 0; someMethod(o) < 10; o.Property--)
            {
                o.Property = P;
            }
        }
示例#5
0
 private void TextBox_KeyDown(object sender, KeyEventArgs e)
 {
     HelperClass.GoToNextControl(e);
 }
 private void writeBlock(int cbShanQu, int kuai, string value)
 {
     int p = RFIDClass.WriterCardAndReturnStatus(this.lblNum.Text, CurrentUser.Current.PassWordKey, cbShanQu, kuai, HelperClass.EncryptByString(value));
 }
示例#7
0
        bool validInput()
        {
            if (AvaliablHotelsDropdown.SelectedItem == null || AvaliableWebsitesDropdown.SelectedItem == null || PriceTextbox.Text == "" || !HelperClass.IsDigitsOnly(PriceTextbox.Text))
            {
                return(false);
            }
            if (TypeCheckBox.Checked == true && AvaliableRoomsTypeDropdown.SelectedItem == null)
            {
                return(false);
            }
            if (TypeCheckBox.Checked == false && RoomsOfHotelDropdown.SelectedItem == null)
            {
                return(false);
            }

            return(true);
        }
示例#8
0
        public void DoSomething(HelperClass helper)
        {
            int SomeInteger;

            SomeInteger = helper.SomeProperty;
        }
示例#9
0
        public static Image Resize120(this Image image)
        {
            var sz = new Size(120, 120);

            return(HelperClass.ResizeIntern(image, sz));
        }
示例#10
0
 private void TextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     HelperClass.GoToNextControl(e);
 }
示例#11
0
        private void PicOpen_Click(object sender, EventArgs e)
        {
            int        heightaux = 0;
            PictureBox parent    = (PictureBox)sender;
            //Panel panel = (Panel)parent.Parent;
            FlowLayoutPanel painel = (FlowLayoutPanel)parent.Parent.Parent.Parent;

            painel.AutoSize = false;
            Image testeimage = picOpen.Image;

            if (picOpen.Tag.ToString() == "arrowClosed")
            {
                testeimage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                picOpen.Image = testeimage;
                picOpen.Tag   = "arrowOpen";
                if (painel.Name == "ExpandTipo")
                {
                    //panel "EXAME"

                    foreach (Control item in painel.Parent.Controls)
                    {
                        try
                        {
                            var testeexame = (Exame)item;
                            if (testeexame.picOpen.Tag.ToString() == "arrowOpen")
                            {
                                heightaux += testeexame.Parent.Parent.Size.Height;
                            }
                        }
                        catch
                        {
                        }
                    }
                    painel.MaximumSize = new Size(painel.Width, painel.Controls.Count * 36 + heightaux);
                    painel.Size        = new Size(painel.Width, painel.Controls.Count * 36 + heightaux);
                }
                else if (painel.Name == "ExameExpandChild1")
                {
                    int heightAux = 0;
                    //panwl HCV


                    painel.MaximumSize        = new Size(painel.Width, painel.Controls.Count * 36);
                    painel.Size               = new Size(painel.Width, painel.Controls.Count * 36);
                    painel.Parent.MaximumSize = new Size(painel.Parent.Width, painel.Parent.Size.Height + painel.Size.Height - 36);
                    painel.Parent.Size        = new Size(painel.Parent.Width, painel.Parent.Size.Height + painel.Size.Height - 36);
                }
            }
            else if (picOpen.Tag.ToString() == "arrowOpen")
            {
                testeimage.RotateFlip(RotateFlipType.Rotate270FlipNone);
                picOpen.Image = testeimage;
                picOpen.Tag   = "arrowClosed";
                if (painel.Name == "ExpandTipo")
                {
                    //panel "EXAME"

                    for (int i = 0; i < painel.Controls.Count; i++)
                    {
                        var closeopen = (PictureBox)HelperClass.FindTag(painel.Controls, "arrowOpen");
                        if (closeopen != null)
                        {
                            var examViewer = (Exame)closeopen.Parent.Parent;
                            examViewer.PicOpen_Click(examViewer.picOpen, new EventArgs());
                        }
                    }
                    painel.MaximumSize = new Size(painel.Width, 36);
                    painel.Size        = new Size(painel.Width, 36);
                }
                else if (painel.Name == "ExameExpandChild1")
                {
                    int heightaux2 = 0;
                    painel.MaximumSize = new Size(painel.Width, 34);
                    painel.Size        = new Size(painel.Width, 34);
                    foreach (Control item in painel.Parent.Controls)
                    {
                        heightaux2 += item.Size.Height + 4;
                    }
                    painel.Parent.MaximumSize = new Size(painel.Parent.Width, heightaux2);
                    painel.Parent.Size        = new Size(painel.Parent.Width, heightaux2);

                    //painel.Parent.MaximumSize = new Size(painel.Parent.Width, painel.Parent.Controls.Count * 36);
                    //painel.Parent.Size = new Size(painel.Parent.Width, painel.Parent.Controls.Count * 36);
                }



                //picOpen.Image = testeimage;
                //picOpen.Tag = "arrowClosed";
                //FlowLayoutPanel testeAux = painel;
                //FlowLayoutPanel teste = null;
                //if (testeAux.Controls.Count > 1)
                //{
                //    teste = (FlowLayoutPanel)painel.Controls[1];
                //    if (painel.Name == "ExpandGeral")
                //    {
                //        painel.AutoSize = true;
                //        painel.AutoSizeMode = AutoSizeMode.GrowOnly;
                //        teste.AutoSize = true;
                //        teste.AutoSizeMode = AutoSizeMode.GrowOnly;
                //        //teste.MaximumSize = new Size(teste.Size.Width, 32);
                //        //teste.Size = new Size(teste.Size.Width, 32);

                //        //painel.MaximumSize = new Size(painel.Size.Width, 35);
                //        //painel.Size = new Size(painel.Size.Width, 35);

                //    }
                //    else if (painel.Name == "ExpandTipo")
                //    {
                //        FlowLayoutPanel teste2 = (FlowLayoutPanel)painel.Parent;
                //        //teste2.MaximumSize = new Size(teste2.Size.Width, painel.Controls.Count * 32 + 30);
                //        //teste2.Size = new Size(teste2.Size.Width, painel.Controls.Count * 32 + 30);
                //        painel.AutoSize = true;
                //        painel.AutoSizeMode = AutoSizeMode.GrowOnly;
                //        teste2.AutoSize = true;
                //        teste2.AutoSizeMode = AutoSizeMode.GrowOnly;

                //        //FlowLayoutPanel teste33 = (FlowLayoutPanel)parent.Parent.Parent.Parent;
                //        //FlowLayoutPanel teste = (FlowLayoutPanel)painel.Controls[1];
                //        //teste.MaximumSize = new Size(teste.Size.Width, 26);
                //        //teste.Size = new Size(teste.Size.Width, 26);
                //    }
                //}
            }



            var hashoriginal = picOpen.Image;
            //picOpen.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
        }
示例#12
0
        private void btninsert_Click(object sender, EventArgs e)
        {
            if (txtmembername.Text == "")
            {
                MessageBox.Show("provide Member Name");
            }
            else if (txtmemberaddress.Text == "")
            {
                MessageBox.Show("Provide Member Address");
            }
            else if (txtemail.Text == "")
            {
                MessageBox.Show("Provide Email address");
            }

            else if (txtcontact.Text == "")
            {
                MessageBox.Show("Provide Contact Number");
            }
            else if (txtdescription.Text == "")
            {
                MessageBox.Show("Provide Description");
            }
            else if (cmbgender.Text == "")
            {
                MessageBox.Show("Provide gender");
            }
            else
            {
                try
                {
                    bool x = blc.ManageMembers(0, txtmembername.Text, txtmemberaddress.Text, txtcontact.Text, txtemail.Text, cmbgender.Text, Convert.ToDateTime(dtpdateofbirth.Text), Convert.ToDateTime(dtpdateofjoin.Text), txtdescription.Text, HelperClass.imageConverter(pbprofilepicture), 1);
                    if (x == true)
                    {
                        MessageBox.Show("NEW MEMBER HAS SUCCESSFULLY CREATED");
                        dgvmanagemember.DataSource = get.getAllMembers();
                        HelperClass.MakeFieldBlank(panel1);
                        pbprofilepicture.Image = null;
                    }
                    else
                    {
                        MessageBox.Show("Error on creating New Member");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
 static HelperClass()
 {
     Instance = new HelperClass();
 }
示例#14
0
 public PhotoInspector()
 {
     this.PhotoQualityInspector = new HelperClass(Constants.TempDirectory);
 }
示例#15
0
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            xStart           = HelperClass.ConvertToDouble(xStartTextBlock.Text);
            yStart           = HelperClass.ConvertToDouble(yStartTextBlock.Text);
            hitsDistanceX    = HelperClass.ConvertToDouble(hitsDistanceXTextBlock.Text);
            numberOfPunchesX = HelperClass.ConvertToInt(numberOfPunchesXTextBlock.Text);
            hitsDistanceY    = HelperClass.ConvertToDouble(hitsDistanceYTextBlock.Text);
            numberOfPunchesY = HelperClass.ConvertToInt(numberOfPunchesYTextBlock.Text);
            toolSize         = new Size(HelperClass.ConvertToDouble(toolWidthTextBox.Text), HelperClass.ConvertToDouble(toolHeightTextBox.Text));
            tool             = HelperClass.GetToolFromComboBox(cmbTool, toolSize);

            gridX = new GridX(xStart, yStart, hitsDistanceX, numberOfPunchesX, hitsDistanceY, numberOfPunchesY, tool, false);

            this.Close();
        }
示例#16
0
 public void Create(Post post)
 {
     post.Creator = HelperClass.GetCurrentUser();
     _context.Posts.Add(post);
     _context.SaveChanges();
 }
        async private void downloadCSVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var cells = dataGridView1.SelectedCells;

            Console.WriteLine("Number of cells: " + dataGridView1.SelectedCells.Count);

            List <int> indexes = new List <int>();

            if (dataGridView1.SelectedCells.Count < 0) // Check if nothing is selected
            {
                return;
            }
            // ------------- FIND FIRST AND LAST (SELECTED) INDEX IN DATAGRID
            foreach (DataGridViewTextBoxCell item in cells)
            {
                int temp = item.RowIndex * 96 + item.ColumnIndex - 1; // Convert to data array index
                if (temp < 0)                                         // Check if header is selected
                {
                    return;
                }
                indexes.Add(temp);
            }

            // Find min and max indexes
            int indexMin = indexes.First();
            int indexMax = indexes.First();

            foreach (var item in indexes)
            {
                if (indexMin > item)
                {
                    indexMin = item;
                }
            }

            foreach (var item in indexes)
            {
                if (indexMax < item)
                {
                    indexMax = item;
                }
            }

            // ---------- INDEXES FOUND

            //DEBUG
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            // debug

            // Now select time period based on min-max
            var startDate = dataPtr.data[indexMin].date;
            var endDate   = dataPtr.data[indexMax].date;

            // Get username and password from textboxes
            string username = textBoxUsername.Text;
            string password = textBoxPassword.Text;


            // Create array of date pairs if xml data needs to be fragmented
            List <CustomXmlDatePair> datePeriodsList = CustomXmlDatePair.FragmentDate(startDate, endDate);

            // ----- Instantiate ntpm object
            string ip;

            try
            {
                // Get IP and Port from database
                ip = GetIPAndPort();
            }
            catch (Exception)
            {
                MessageBox.Show("Couldn't get IP and Port from database");
                return; // abort
            }

            // ----------------------------------- Get and parse report.xml
            string    reportRes;
            XDocument reportDoc;

            try
            {
                reportRes = await NTPMControllerClass.GetReport(ip); // Get xml report from NTPM

                reportDoc = XDocument.Parse(reportRes);
            }
            catch (Exception)
            {
                MessageBox.Show("Couldn't get or parse report.xml");
                return; // abort
            }

            // Create header dates
            string headerStartTime = HelperClass.ConvertToNtpmCustomXmlTime(startDate);
            string headerEndTime   = HelperClass.ConvertToNtpmCustomXmlTime(endDate);
            string csvHeader       = NTPMControllerClass.CreateCSVHeader(headerStartTime, headerEndTime, reportDoc);

            FormCustomConsole.WriteLine("StartTime: " + headerStartTime);
            FormCustomConsole.WriteLine("EndTime: " + headerEndTime);


            // now we only need to fill values with each row

            // --------------------------------Get and parse measurement.xml

            List <XDocument> measurementDoc  = new List <XDocument>();
            List <string>    measurementRows = new List <string>();

            foreach (var datePeriod in datePeriodsList)
            {
                Console.WriteLine("Parsing period: " + datePeriod.startHeader + "---" + datePeriod.endHeader);
                await HelperRetryClass.DoWithRetryAsync(async() =>
                {
                    FormCustomConsole.WriteLine("Loading: " + datePeriod.startHeader + "---" + datePeriod.endHeader);
                    List <KeyValuePair <string, string> > pairs = NTPMControllerClass.GetPairsForCustomXmlPostMethod(datePeriod.startHeader, datePeriod.endHeader, username, password);
                    string measurementRes = await HTTPClientClass.PostRequest("http://" + ip + "/custom.xml", pairs);
                    XDocument tempMeasure = XDocument.Parse(measurementRes);
                    NTPMControllerClass.CheckErrorTag(tempMeasure);
                    string measureRow = NTPMControllerClass.CreateCSVMeasurementRow(tempMeasure);
                    // At this point, download and parsing is ok
                    measurementRows.Add(measureRow);
                    measurementDoc.Add(tempMeasure);
                },
                                                        TimeSpan.FromSeconds(1));
            }

            // now form whole string (HEADER + TAGS + MEASUREMENT ROWS)
            StringBuilder sFinal = new StringBuilder();

            sFinal.Append(csvHeader);
            foreach (var item in measurementRows)
            {
                sFinal.Append(item);
                sFinal.Append("\r\n");
            }
            sFinal.Remove(sFinal.Length - 2, 2); // Remove last new line


            // Write elapsed time
            stopWatch.Stop();
            FormCustomConsole.WriteLine("XML fetching operation finished in: " + (stopWatch.ElapsedMilliseconds / 1000).ToString() + "seconds");


            // --------------------------------------- Finaly save file
            string fileName = XmlHelper.FindFirstDescendant("hostname", reportDoc).Trim();
            string fileMac  = XmlHelper.FindFirstDescendant("mac", reportDoc).Replace(':', '-');
            string fileType = "by_15min";

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Excel File|*.csv";
            // Create file name (based on downloaded data)
            sfd.FileName = fileName + "_" + fileMac + "_" + headerStartTime + "_" + headerEndTime + "_" + fileType;
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string       path = sfd.FileName;
                StreamWriter sw   = new StreamWriter(File.Create(path));
                sw.Write(sFinal.ToString());
                sw.Dispose();
            }
        }
示例#18
0
 public void AssistantMethod(int item)
 {
   // Just let exceptions go on by to my caller.
   HelperClass hc = new HelperClass();
   hc.TopMethod(item);
 }
 private int someMethod(HelperClass o)
 {
     return o.Property;
 }
示例#20
0
        protected override async void OnResume()
        {
            base.OnResume();
            try
            {
                if (IsPurchaseRequired())
                {
                    //show alert and end activity
                    Toast.MakeText(this, string.Format("You need to pay ${0} to view vehile details", _amountToPay),
                                   ToastLength.Short).Show();
                    Finish(); //end this activity
                }
                else
                {
                    var resp = await PopulateFields();

                    bool firstImageLoaded = false;
                    //lets loop through the images list to see if we have any data
                    if (resp)
                    {
                        if (_images != null)
                        {
                            foreach (var image in _images)
                            {
                                var imageUrl  = image.AbsoluteUri;
                                var itemIndex = _images.IndexOf(image);
                                //var bitmap = HelperClass.GetImageBitmapFromUrl(absoluteUri);
                                var imageView = new ImageView(this)
                                {
                                    Id = itemIndex
                                };
                                //imageView.SetPadding(2, 2, 2, 2);
                                imageView.SetPadding(5, 5, 5, 5);
                                //imageView.SetImageBitmap(bitmap);

                                #region Imageloader

                                //ImageSize targetSize = new ImageSize(640,480);
                                _imageLoader.LoadImage(
                                    imageUrl,
                                    //targetSize,
                                    HelperClass.ImageDownloaderOptions,
                                    new ImageLoadingListener(
                                        loadingStarted: delegate
                                {
                                },
                                        loadingComplete: (imageUri, view, loadedImage) =>
                                {
                                    if (loadedImage != null)
                                    {
                                        //check if we have a main image in imageview
                                        if (!firstImageLoaded)
                                        {
                                            SetMainImageView(imageUrl);
                                            firstImageLoaded = true;
                                        }
                                        var resizedImage = HelperClass.ResizeImage(loadedImage, 60);
                                        imageView.SetImageBitmap(resizedImage);
                                        loadedImage.Recycle();         //clear from memory
                                        //Console.WriteLine($"Image dimensions width {loadedImage.Width} height {loadedImage.Height}");
                                    }
                                },
                                        loadingFailed: (imageUri, view, failReason) =>
                                {
                                    string message = "Unable to load image";
                                    if (failReason.Type == FailReason.FailType.IoError)
                                    {
                                        message = "Input/Output error";
                                    }
                                    else if (failReason.Type == FailReason.FailType.DecodingError)
                                    {
                                        message = "Image can't be decoded";
                                    }
                                    else if (failReason.Type == FailReason.FailType.NetworkDenied)
                                    {
                                        message = "Downloads are denied";
                                    }
                                    else if (failReason.Type == FailReason.FailType.OutOfMemory)
                                    {
                                        message = "Out Of Memory error";
                                    }
                                    else
                                    {
                                        message = "Unknown error";
                                    }
                                    Toast.MakeText(view.Context, message, ToastLength.Short).Show();
                                }));

                                #endregion ImageLoader

                                imageView.SetScaleType(ImageView.ScaleType.Center);


                                //lets add it to the layout now
                                _linearLayout.AddView(imageView);

                                //add click events
                                imageView.Click += ImageViewOnClick;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MetricsManager.TrackEvent("Error loading vehicle profile" + ex.StackTrace + ex.Message);
            }
        }
        private async void buttonConfirm_Click(object sender, EventArgs e)
        {
            HelperClass hc = new HelperClass();

            //Преобразование списка продуктов в строку
            string listString = JsonConvert.SerializeObject(list);

            closed = true;

            string connectToRecipies = @"Data Source = DESKTOP-NLAJBQI; Initial Catalog = Kass; Integrated Security = True";
            string sqlCommand        = "INSERT INTO Recipes(Id, Datetime, ProductList, Price, PaymentType, TakeAway, Comment, Cashier)" +
                                       " VALUES(@Id, @Datetime, @ProductList, @Price, @PaymentType, @TakeAway, @Comment, @Cashier)";

            using (SqlConnection connection = new SqlConnection(connectToRecipies))
            {
                await connection.OpenAsync();

                SqlCommand command = new SqlCommand("SELECT * FROM dbo.Recipes", connection);

                var reader = await command.ExecuteReaderAsync();

                if (reader.HasRows)
                {
                    reader.Close();
                    command.CommandText = "SELECT MAX(Id) FROM dbo.Recipes";
                    id = Convert.ToInt32(await command.ExecuteScalarAsync());
                    id++;
                }
                else
                {
                    id = 0;
                }
                reader.Close();

                command.CommandText = sqlCommand;
                command.Parameters.AddWithValue("@Id", id);
                command.Parameters.AddWithValue("@Datetime", datetime);
                command.Parameters.AddWithValue("@ProductList", listString);
                command.Parameters.AddWithValue("@Price", price);
                command.Parameters.AddWithValue("@PaymentType", paymentType);
                command.Parameters.AddWithValue("@TakeAway", takeAway);
                command.Parameters.AddWithValue("@Comment", Comment);
                command.Parameters.AddWithValue("@Cashier", cashier);

                await command.ExecuteNonQueryAsync();
            }


            foreach (var i in listBoxFinal.Items)
            {
                listBoxFinalStrings.Add(i.ToString());
            }

            //печать чека
            hc.PrintRecipie(datetime, price, paymentType, takeAway, listBoxFinalStrings, cashier);
            hc.SendRecipieToPrinter();


            CreateNewRecipie cr = (CreateNewRecipie)this.Owner;

            cr.Enabled = true;
            this.Hide();
            success = true;
        }
示例#22
0
 private void btnupdate_Click(object sender, EventArgs e)
 {
     try
     {
         bool x = blc.ManageMembers(id, txtmembername.Text, txtmemberaddress.Text, txtcontact.Text, txtemail.Text, cmbgender.Text, Convert.ToDateTime(dtpdateofbirth.Text), Convert.ToDateTime(dtpdateofjoin.Text), txtdescription.Text, HelperClass.imageConverter(pbprofilepicture), 2);
         if (x == true)
         {
             MessageBox.Show("MEMBER was SUCCESSFULLY updated");
             dgvmanagemember.DataSource = get.getAllMembers();
             HelperClass.MakeFieldBlank(panel1);
             pbprofilepicture.Image = null;
         }
         else
         {
             MessageBox.Show("Error on creating New Member");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#23
0
    public string Default()
    {
        var link = HelperClass.GenerateLink(Request);

        return(link);
    }
示例#24
0
 private int someMethod(HelperClass o)
 {
     return(o.Property);
 }
示例#25
0
 public ItemsContent()
 {
     HelperClass.FixupDataContext(this);
     Loaded += ItemsContent_Loaded;
 }
示例#26
0
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            xStart          = HelperClass.ConvertToDouble(xStartTextBlock.Text);
            yStart          = HelperClass.ConvertToDouble(yStartTextBlock.Text);
            hitsDistance    = HelperClass.ConvertToDouble(hitsDistanceTextBlock.Text);
            angle           = HelperClass.ConvertToDouble(angleTextBlock.Text);
            numberOfPunches = HelperClass.ConvertToInt(numberOfPunchesTextBlock.Text);
            toolSize        = new Size(HelperClass.ConvertToDouble(toolWidthTextBox.Text), HelperClass.ConvertToDouble(toolHeightTextBox.Text));
            tool            = HelperClass.GetToolFromComboBox(cmbTool, toolSize);

            lineAtAngle = new LineAtAngle(xStart, yStart, hitsDistance, angle, numberOfPunches, tool, false);

            this.Close();
        }
示例#27
0
 /// <summary>
 /// Maps the EDDLOBCD query to data model.
 /// </summary>
 /// <param name="vm">The vm.</param>
 /// <param name="dataModel">The data model.</param>
 internal static void MapEDDLOBCDQueryToDataModel(EDDViewModel vm, LogDataModel dataModel)
 {
     dataModel.SqlQuery = vm.SqlQuery;
     dataModel.SqlQuery = HelperClass.ReplaceKey(dataModel.SqlQuery, "Region", dataModel.Region);
     dataModel.SqlQuery = HelperClass.ReplaceKey(dataModel.SqlQuery, "PolicyId", dataModel.PolicyId);
 }
 public GasOnlyJourneySteps(HelperClass helper)
 {
     _helperClass = helper;
 }
示例#29
0
 internal static void MapTopTenErrorCodeQueryToDataModel(HalErrorDetailViewModel vm, LogDataModel dataModel)
 {
     dataModel.SqlQuery = vm.DetailSqlQuery;
     dataModel.Region   = vm.ExceedRegion.CurrentRegion;
     dataModel.SqlQuery = HelperClass.ReplaceKey(dataModel.SqlQuery, "Region", dataModel.Region);
     dataModel.SqlQuery = HelperClass.ReplaceKey(dataModel.SqlQuery, "MinFailTs", HelperClass.convertToUKFormat(DateTime.Now.AddMonths(-5).Year, DateTime.Now.AddMonths(-5).Month));
 }
示例#30
0
        public async Task <IActionResult> Index(LoginViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            try
            {
                if (ModelState.IsValid)
                {
                    ModelState.Remove("FirstName");
                    ModelState.Remove("LastName");

                    using (var context = _context)
                    {
                        // Query for all blogs with names starting with B
                        var UserCheck = context.m_UserMaster.Where(b => b.UserName == model.Username && b.UserPassword == HelperClass.EncodePassword(model.Password, "P@ssw0rd") && b.Status != "I").Count();
                        if (UserCheck == 0)
                        {
                            ViewBag.UserLoginFailed = "Login Failed.Please enter correct credentials";
                            return(View(model));
                        }
                        else
                        {
                            var identity = (ClaimsIdentity)User.Identity;

                            string lastChanged;
                            lastChanged = (from c in identity.Claims
                                           where c.Type == "ContactName"
                                           select c.Value).FirstOrDefault();


                            //CheckTransacTion(model.Username);

                            //var claims = new List<Claim> { new Claim("ContactName", model.Username ?? "") };
                            //ClaimsIdentity userIdentity = new ClaimsIdentity(claims, "login");
                            //ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity);

                            //await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, user);

                            if (string.IsNullOrEmpty(lastChanged))
                            {
                                // return RedirectToAction("Index", "Login");
                            }
                            else
                            {
                                return(RedirectToAction("Index", "Home"));
                            }


                            // HttpContext.Session.SetString("Username", model.Username);

                            //DbFunctions dfunc = null;
                            if (_context.UserTransaction.Any(x => x.UserName == model.Username))
                            {
                                //         var model1 = _context.UserTransaction.Where(x => SqlServerDbFunctionsExtensions
                                //.DateDiffMinute(dfunc, Convert.ToDateTime(x.DateExprie), Convert.ToDateTime(DateTime.Now)) <= 10 && x.UserName == model.Username).FirstOrDefault();
                                var model1 = _context.UserTransaction.Where(x => x.UserName == model.Username).FirstOrDefault();

                                double Minute = (DateTime.Now - (DateTime)model1.DateExprie).TotalMinutes;

                                if (Minute <= 10)
                                {
                                    ViewBag.UserLoginFailed = "Login Failed.Please enter correct credentials";
                                    return(View());
                                }
                                else
                                {
                                    ClaimsPrincipal user = new ClaimsPrincipal(new ClaimsIdentity(new[]
                                                                                                  { new Claim("ContactName", model.Username ?? "") }, CookieAuthenticationDefaults.AuthenticationScheme));

                                    await HttpContext.SignInAsync(
                                        CookieAuthenticationDefaults.AuthenticationScheme,
                                        new ClaimsPrincipal(user),
                                        new AuthenticationProperties
                                    {
                                        //CookiePath = new PathString("/Login/Logout"),
                                        IsPersistent = true,
                                        ExpiresUtc   = DateTime.UtcNow.AddMinutes(10)
                                    });

                                    var model_1 = _context.UserTransaction.FirstOrDefault(x => x.UserName == model.Username);
                                    _context.UserTransaction.Remove(model_1);
                                    _context.SaveChanges();

                                    DeleteDataRefresh(model.Username);

                                    TempData["UserName"] = model.Username;
                                    var ToKen = Guid.NewGuid();

                                    var Model_Tran = new UserTransaction
                                    {
                                        UserName   = model.Username,
                                        Token      = ToKen.ToString(),
                                        SessionKey = "",
                                        DateExprie = DateTime.Now
                                    };
                                    _context.UserTransaction.AddRange(Model_Tran);
                                    _context.SaveChanges();
                                }
                            }
                            else
                            {
                                var ToKen = Guid.NewGuid();

                                TempData["UserName"] = model.Username;

                                var Model_Tran = new UserTransaction
                                {
                                    UserName   = model.Username,
                                    Token      = ToKen.ToString(),
                                    SessionKey = "",
                                    DateExprie = DateTime.Now
                                };
                                _context.UserTransaction.AddRange(Model_Tran);
                                _context.SaveChanges();


                                ClaimsPrincipal user = new ClaimsPrincipal(new ClaimsIdentity(new[]
                                                                                              { new Claim("ContactName", model.Username ?? "") }, CookieAuthenticationDefaults.AuthenticationScheme));

                                await HttpContext.SignInAsync(
                                    CookieAuthenticationDefaults.AuthenticationScheme,
                                    new ClaimsPrincipal(user),
                                    new AuthenticationProperties
                                {
                                    //CookiePath = new PathString("/Login/Logout"),
                                    IsPersistent = true,
                                    ExpiresUtc   = DateTime.UtcNow.AddMinutes(10)
                                });
                            }


                            // await HttpContext.SignInAsync(principal);

                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                }
                else
                {
                    return(View(model));
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                return(View(model));
            }
        }
示例#31
0
        public string StoreData()
        {
            Connect();

            List <TVQ>        tvqsList        = new List <TVQ>();
            List <Property>   propertiesList  = new List <Property>();
            List <Annotation> annotationsList = new List <Annotation>();

            // create data to store
            DateTime now       = DateTime.Now;
            string   sessionId = GetSessionId();
            Dictionary <string, int> tagIds = GetTagIds();

            foreach (KeyValuePair <string, int> pair in tagIds)
            {
                string tagName = pair.Key;
                int    id      = pair.Value;

                // add tvq data
                for (int i = 0; i < 500; i++)
                {
                    TVQ tvq = new TVQ();
                    tvq.id        = id;
                    tvq.timestamp = now.AddTicks(i);
                    tvq.value     = i % 100;
                    tvq.quality   = StandardQualities.Good;
                    tvqsList.Add(tvq);
                }

                // add property data
                Property highScale = new Property();
                highScale.id          = id;
                highScale.description = null;
                highScale.timestamp   = now;
                highScale.name        = StandardPropertyNames.ScaleHigh;
                highScale.value       = 100;
                highScale.quality     = StandardQualities.Good;
                propertiesList.Add(highScale);

                // add property data
                Property lowScale = new Property();
                lowScale.id          = id;
                lowScale.description = null;
                lowScale.timestamp   = now;
                lowScale.name        = StandardPropertyNames.ScaleLow;
                lowScale.value       = 0;
                lowScale.quality     = StandardQualities.Good;
                propertiesList.Add(lowScale);

                // add property data
                Property sampleInterval = new Property();
                sampleInterval.id          = id;
                sampleInterval.description = null;
                sampleInterval.timestamp   = now;
                sampleInterval.name        = StandardPropertyNames.SampleInterval;
                sampleInterval.value       = TimeSpan.FromSeconds(1);
                sampleInterval.quality     = StandardQualities.Good;
                propertiesList.Add(sampleInterval);

                // add annotation
                Annotation annotation = new Annotation();
                annotation.id        = id;
                annotation.timestamp = now;
                //annotation.createdAt = now; // only necessary if creation time differs from annotation timestamp
                annotation.user  = "******";
                annotation.value = "Example Annotation";
                annotationsList.Add(annotation);
            }

            int tvqsStored;
            int propertiesStored;
            int annotationsStored;

            TVQ[]        tvqs        = tvqsList.ToArray();
            Property[]   properties  = propertiesList.ToArray();
            Annotation[] annotations = annotationsList.ToArray();

            // send only tvqs in this call
            //string result = SAF_HelperClass.StoreData(client, sessionId, tvqs, out tvqsStored);

            // send only properties in this call
            //string result = SAF_HelperClass.StoreData(client, sessionId, properties, out propertiesStored);

            // send only annotations in this call
            //string result = SAF_HelperClass.StoreData(client, sessionId, annotations, out annotationsStored);

            // send tvqs, properties, and annotations in this call
            string result = HelperClass.StoreData(_client, sessionId, tvqs, properties, annotations, out tvqsStored, out propertiesStored, out annotationsStored);

            return(result);
        }
示例#32
0
 public void DoSomethingElse(HelperClass helper)
 {
     helper.SomeProperty = 3;
 }
示例#33
0
        public bool IsLocalhost()
        {
            bool result = HelperClass.IsLocalhost(_historian);

            return(result);
        }
示例#34
0
 public override string ToString()
 {
     return(HelperClass.ToStringByBrand("AUDI", Model, CompulsoryParts, OptionallyParts));
 }
示例#35
0
        public string ExportCustomerVehicleFilter(CustomerVehicleModel objCustomerVehicleModel)
        {
            var      filename    = "Vehicle_" + DateTime.Now.ToString(Constants.dateTimeFormat24HForFileName) + ".csv";
            FileInfo file        = new FileInfo(Server.MapPath("~/Attachment/ExportFiles/" + filename));
            Int16    IsDataFound = 0;

            try
            {
                string strQuery = " WHERE 1=1";
                if (objCustomerVehicleModel.SearchEnable)
                {
                    #region Filter Query
                    if (objCustomerVehicleModel.AccountId > 0)
                    {
                        strQuery += " AND CA.ACCOUNT_ID LIKE '%" + objCustomerVehicleModel.AccountId + "%' ";
                    }
                    if (!string.IsNullOrEmpty(objCustomerVehicleModel.ResidentId))
                    {
                        strQuery += " AND CA.RESIDENT_ID LIKE '%" + objCustomerVehicleModel.ResidentId.ToLower() + "%'";
                    }
                    if (!string.IsNullOrEmpty(objCustomerVehicleModel.MobileNo))
                    {
                        strQuery += " AND CA.MOB_NUMBER LIKE '%" + objCustomerVehicleModel.MobileNo.ToLower() + "%' ";
                    }
                    if (!string.IsNullOrEmpty(objCustomerVehicleModel.EmailId))
                    {
                        strQuery += " AND LOWER(CA.EMAIL_ID) LIKE '%" + objCustomerVehicleModel.EmailId.ToLower() + "%' ";
                    }
                    if (!string.IsNullOrEmpty(objCustomerVehicleModel.FirstName))
                    {
                        strQuery += " AND LOWER(CA.FIRST_NAME) LIKE '%" + objCustomerVehicleModel.FirstName.ToLower() + "%' ";
                    }
                    if (!string.IsNullOrEmpty(objCustomerVehicleModel.VehRegNo))
                    {
                        strQuery += " AND LOWER(CV.VEH_REG_NO) LIKE '%" + objCustomerVehicleModel.VehRegNo.ToLower() + "%' ";
                    }
                    if (!string.IsNullOrEmpty(objCustomerVehicleModel.VehicleRCNumber))
                    {
                        strQuery += " AND LOWER(CV.VEHICLE_RC_NO) LIKE '%" + objCustomerVehicleModel.VehicleRCNumber.ToLower() + "%'";
                    }
                    if (objCustomerVehicleModel.VehicleClassId > 0)
                    {
                        strQuery += " AND CV.VEHICLE_CLASS_ID = " + objCustomerVehicleModel.VehicleClassId + "";
                    }
                    if (objCustomerVehicleModel.QueueStatus > 0)
                    {
                        strQuery += " AND CV.QUEUE_STATUS = " + objCustomerVehicleModel.QueueStatus + "";
                    }
                    if (objCustomerVehicleModel.ExceptionFlag > 0)
                    {
                        strQuery += " AND CV.EXCEPTION_FLAG = " + objCustomerVehicleModel.ExceptionFlag + "";
                    }
                    IsDataFound = CSVUtility.CreateCsvWithTitleFilter(file.FullName, CustomerVehicleBLL.GetFilterCSV(strQuery), "Vehicle", objCustomerVehicleModel);
                    #endregion
                }
                else
                {
                    IsDataFound = CSVUtility.CreateCsvWithTitle(file.FullName, CustomerVehicleBLL.GetFilterCSV(strQuery), "Vehicle");
                }
                if (IsDataFound == 0)
                {
                    filename = "No Data to Export.";
                }
            }
            catch (Exception ex)
            {
                HelperClass.LogMessage("Failed Export Customer CSV " + ex);
            }
            string Det = JsonConvert.SerializeObject(filename, Formatting.Indented);
            return(Det.Replace("\r", "").Replace("\n", ""));
        }
        /// <summary>
        /// 初始化写卡数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbnWriteCard_Click(object sender, EventArgs e)
        {
            string d        = Guid.NewGuid().ToString("N");
            string password = CurrentUser.Current.PassWordKey;

            try
            {
                bool     flag  = false;
                string[] mary1 = StringUtil.readBlock(RFIDClass.ReadCardAndReturnStatus(password, Convert.ToInt32(1)));
                if (mary1[4] == "11" || mary1[4] == "12")
                {
                    flag     = true;
                    password = SystemConstant.StringEmpty;
                    mary1    = StringUtil.readBlock(RFIDClass.ReadCardAndReturnStatus(password, Convert.ToInt32(1)));
                }
                if (mary1[4] != "0")
                {
                    throw new Exception(RFIDClass.ConvertMeassByStatus(Convert.ToInt32(mary1[4])));
                }

                string cardStatus = string.IsNullOrEmpty(mary1[2])?"":mary1[2];
                //判断如果长度是16
                if (cardStatus.Length >= 16)
                {
                    cardStatus = HelperClass.getCardStatus(cardStatus.Substring(13, 1));
                }
                else
                {
                    cardStatus = Bouwa.ITSP2V31.Model.CardTypeInfo.CardTypeInfoDefaultCardStatus.空白卡.ToString("D");
                }
                //如果是从重新初始化的按钮进入,则跳过下面判断
                if (!(Bouwa.ITSP2V31.Model.CardTypeInfo.CardTypeInfoDefaultCardStatus.空白卡.ToString("D").Equals(cardStatus) ||
                      (cardStatus.Equals(CardTypeInfo.CardTypeInfoDefaultCardStatus.已充值.ToString("D")) && string.IsNullOrEmpty(HelperClass.DecryptByString(mary1[3] == null ? "" : mary1[3].ToString()))) ||
                      flag))
                {
                    this.lblNum.Text = string.Empty;
                    MessageBoxForm.Show("此卡非空卡,请更换卡!", MessageBoxButtons.OK);
                    return;
                }
                if (!mary1[0].Equals(this.lblNum.Text))
                {
                    //MessageBoxForm.Show(_objSystemMessage.GetInfoByCode("ReadNoSameCard"), MessageBoxButtons.OK);
                    MessageBoxForm.Show("读取停车卡和待写入卡不是同一张卡,不能被写入!", MessageBoxButtons.OK);
                    return;
                }
                if (string.IsNullOrEmpty(this.lblNum.Text))
                {
                    this.lblNum.Text = string.Empty;
                    MessageBoxForm.Show("未读取到卡内编号,请重试!", MessageBoxButtons.OK);
                    return;
                }
                if (string.IsNullOrEmpty(this.tbxCardNum.Text))
                {
                    MessageBoxForm.Show("卡面编号不能为空,请重新输入!", MessageBoxButtons.OK);
                    return;
                }


                //判断卡面编号输入是否合法
                Regex rx = new Regex("^[\u4E00-\u9FA5]+$");
                if (rx.IsMatch(this.tbxCardNum.Text.Trim()))
                {
                    MessageBoxForm.Show("卡面编号必须是数字或者字母,请重新输入!", MessageBoxButtons.OK);
                    return;
                }
                //判断输入的值是否超过预定的最大值
                string      maxValue        = "0";
                Hashtable   table           = new Hashtable();
                CardTypeBLL _objCardTypeBLL = new CardTypeBLL();
                table.Add("tcit_system", (int)CurrentUser.Current.PARKING_SYSTEM);
                table.Add("tcit_type", (int)CurrentUser.Current.PARK_BACKSTAGE);
                //判断上限分钟是否大于预设值
                if (this.lblCostType.Text.Equals(Bouwa.ITSP2V31.Model.CardInfo.CardTypeInfoCostType.限时卡.ToString("D")))
                {
                    table.Add("tcit_code", CurrentUser.Current.MaxTime);

                    maxValue = _objCardTypeBLL.GetRegisterType(table, null);
                    int   max   = 0;
                    Regex regex = new Regex("[^0-9]");
                    if (string.IsNullOrEmpty(this.tbxOverPlus.Text))
                    {
                        MessageBoxForm.Show("剩余时间不能为空!", MessageBoxButtons.OK);
                        return;
                    }
                    if (regex.IsMatch(maxValue))
                    {
                        MessageBoxForm.Show("限时预设值格式不正确,无法继续充值,请联系管理员!", MessageBoxButtons.OK);
                        return;
                    }
                    if (regex.IsMatch(this.tbxOverPlus.Text))
                    {
                        MessageBoxForm.Show("剩余时间必须为数字,请重新输入!", MessageBoxButtons.OK);
                        return;
                    }
                    max = Convert.ToInt32(this.tbxOverPlus.Text);
                    if (Convert.ToInt32(this.tbxOverPlus.Text) > Convert.ToInt32(this.tbxMax.Text))
                    {
                        MessageBoxForm.Show("剩余时间不能大于上限时间!", MessageBoxButtons.OK);
                        return;
                    }
                    if (Convert.ToInt32(this.tbxOverPlus.Text) > max)
                    {
                        MessageBoxForm.Show("剩余时间不能大于预设最大" + maxValue + "分!", MessageBoxButtons.OK);
                        return;
                    }
                }
                //判断剩余次数是否大于预设值
                else if (this.lblCostType.Text.Equals(Bouwa.ITSP2V31.Model.CardInfo.CardTypeInfoCostType.限次卡.ToString("D")))
                {
                    table.Add("tcit_code", CurrentUser.Current.MaxDegree);

                    maxValue = _objCardTypeBLL.GetRegisterType(table, null);
                    int   max   = 0;
                    Regex regex = new Regex("[^0-9]");
                    if (string.IsNullOrEmpty(this.tbxOverPlus.Text))
                    {
                        MessageBoxForm.Show("剩余次数不能为空!", MessageBoxButtons.OK);
                        return;
                    }
                    if (regex.IsMatch(maxValue))
                    {
                        MessageBoxForm.Show("次数预设值格式不正确,无法继续初始化,请联系管理员!", MessageBoxButtons.OK);
                        return;
                    }
                    if (regex.IsMatch(this.tbxOverPlus.Text))
                    {
                        MessageBoxForm.Show("剩余次数必须为数字,请重新输入!", MessageBoxButtons.OK);
                        return;
                    }
                    max = Int32.Parse(this.tbxOverPlus.Text);
                    if (Convert.ToInt32(this.tbxOverPlus.Text) > Convert.ToInt32(this.tbxMax.Text))
                    {
                        MessageBoxForm.Show("剩余次数不能大于上限次数!", MessageBoxButtons.OK);
                        return;
                    }
                    if (Convert.ToInt32(this.tbxOverPlus.Text) > Convert.ToInt32(maxValue))
                    {
                        MessageBoxForm.Show("剩余次数不能大于预设最大" + maxValue + "次!", MessageBoxButtons.OK);
                        return;
                    }
                }
                //判断剩余金额是否大于预设值
                else if (this.lblCostType.Text.Equals(Bouwa.ITSP2V31.Model.CardInfo.CardTypeInfoCostType.金额卡.ToString("D")))
                {
                    table.Add("tcit_code", CurrentUser.Current.MaxMoney);

                    maxValue = _objCardTypeBLL.GetRegisterType(table, null);
                    decimal max            = new Decimal(0.00);
                    Regex   RegDecimalSign = new Regex("^[+-]?[0-9]+[.]?[0-9]+$");
                    if (string.IsNullOrEmpty(this.tbxOverPlus.Text))
                    {
                        MessageBoxForm.Show("剩余次数不能为空!", MessageBoxButtons.OK);
                        return;
                    }
                    if (!RegDecimalSign.IsMatch(maxValue))
                    {
                        MessageBoxForm.Show("次数预设值格式不正确,无法继续初始化,请联系管理员!", MessageBoxButtons.OK);
                        return;
                    }
                    if (!RegDecimalSign.IsMatch(this.tbxOverPlus.Text))
                    {
                        MessageBoxForm.Show("剩余次数必须为数字,请重新输入!", MessageBoxButtons.OK);
                        return;
                    }
                    max = Convert.ToDecimal(this.tbxOverPlus.Text);
                    if (Convert.ToDecimal(this.tbxOverPlus.Text) > Convert.ToDecimal(this.tbxMax.Text))
                    {
                        MessageBoxForm.Show("剩余金额不能大于上限金额!", MessageBoxButtons.OK);
                        return;
                    }
                    if (Convert.ToDecimal(this.tbxOverPlus.Text) > max)
                    {
                        MessageBoxForm.Show("剩余金额不能大于上限金额" + maxValue + "元!", MessageBoxButtons.OK);
                        return;
                    }
                }
                StringBuilder sb = new StringBuilder();
                //初始化写入密码
                RFIDClass.UpdateCardPassWordAndReturnStatus(this.lblNum.Text, 1, SystemConstant.StringEmpty, CurrentUser.Current.PassWordKey);

                //写入扩展的SAASID
                if (!"0".Equals(SystemConstant.saas_type.SAAS_TYPE.ToString("D")))
                {
                    sb.Append(StringUtil.formatDataString(Convert.ToInt32(lblExtSaasId.Text), 3));
                }
                //写入系统编号
                sb.Append(SystemConstant.system_type.CS_SYSTEM.ToString("D"));
                //写入剩余金额及剩余次数及剩余时间,限期卡为5个0,限时卡前面是小时数,最后一位是分钟数数
                if (this.lblCostType.Text.Equals(Bouwa.ITSP2V31.Model.CardInfo.CardTypeInfoCostType.限期卡.ToString("D")))
                {
                    sb.Append(StringUtil.formatDataString(0, 5));
                }
                else if (this.lblCostType.Text.Equals(Bouwa.ITSP2V31.Model.CardInfo.CardTypeInfoCostType.限时卡.ToString("D")))
                {
                    string hours   = Convert.ToString(Convert.ToInt32(this.tbxOverPlus.Text) / 60);      //根据输入分钟数,输入数字除60取余计算出小时数
                    string minutes = Convert.ToString(Convert.ToInt32(this.tbxOverPlus.Text) % 60 / 10); //根据输入数字除60取模,然后再除以10,得到分钟数,1代表10分钟,2代表20分钟,依次类推

                    sb.Append(StringUtil.formatDataString(Convert.ToInt32(hours + minutes), 5));
                }
                else if (this.lblCostType.Text.Equals(Bouwa.ITSP2V31.Model.CardInfo.CardTypeInfoCostType.金额卡.ToString("D")))
                {
                    //格式化金额的存储,前4位保存整数,后1位保存小数点后面第一位
                    string money = Convert.ToDecimal(this.tbxOverPlus.Text).ToString("0.0");
                    sb.Append(StringUtil.formatDataString(Convert.ToInt32(money.Replace(".", "")), 5));
                }
                else
                {
                    sb.Append(StringUtil.formatDataString(Convert.ToInt32(this.tbxOverPlus.Text), 5));
                }
                //写入卡面编号
                sb.Append(StringUtil.formatDataString(this.tbxCardNum.Text, 7));
                //写入第一扇区的第零块
                writeBlock(1, 0, sb.ToString());
                sb = new StringBuilder();
                //写入生效日期
                sb.Append(DateTime.Parse(this.lblEffectDate.Text).ToString("yyMMdd"));
                //写入最晚日期
                sb.Append(DateTime.Parse(this.lblOutDate.Text).ToString("yyMMdd"));
                //写入扣费类型
                sb.Append(this.lblCostType.Text.ToString());
                //写入停车卡状态
                sb.Append(Bouwa.ITSP2V31.Model.CardTypeInfo.CardTypeInfoDefaultCardStatus.已充值.ToString("D"));
                //写入卡类型
                sb.Append(StringUtil.formatDataString(this.lblExtCardTypeId.Text.ToString(), 2));
                //写入第一扇区的第一块
                writeBlock(1, 1, sb.ToString());
                //把最后操作时间写入第一扇区的第二块
                sb = new StringBuilder();
                sb.Append(DateTime.Now.ToString("yyyyMMddHHmmss"));
                writeBlock(1, 2, sb.ToString());

                RFIDClass.IssueSound(50); //发出声音代表完成
                //将该卡信息写入后台数据库
                Hashtable cardInfo = new Hashtable();
                //插入初始化记录
                Hashtable htCardInfo = new Hashtable();
                //主键
                cardInfo.Add("id", Guid.NewGuid());
                htCardInfo.Add("id", Guid.NewGuid().ToString());
                //saasId
                if (!string.IsNullOrEmpty(this.lblSaasId.Text))
                {
                    cardInfo.Add("saas_id", new Guid(this.lblSaasId.Text));
                    htCardInfo.Add("saas_id", this.lblSaasId.Text);
                }
                //卡内编号
                if (!string.IsNullOrEmpty(this.lblNum.Text))
                {
                    cardInfo.Add("card_id", this.lblNum.Text);
                    htCardInfo.Add("card_id", Guid.Empty.ToString());
                }
                else
                {
                    MessageBoxForm.Show("未读取到卡内编号,请重试!", MessageBoxButtons.OK);
                    return;
                }
                //卡面编号
                if (!string.IsNullOrEmpty(this.tbxCardNum.Text.Trim()))
                {
                    cardInfo.Add("no", StringUtil.formatDataString(this.tbxCardNum.Text, 7));
                    htCardInfo.Add("no", StringUtil.formatDataString(this.tbxCardNum.Text, 7));
                }
                else
                {
                    MessageBoxForm.Show("卡面编号不能为空,请重新输入!", MessageBoxButtons.OK);
                    return;
                }
                //批次
                if (!string.IsNullOrEmpty(this.tbxLotNum.Text))
                {
                    cardInfo.Add("batch", this.tbxLotNum.Text);
                }
                //停车卡类型
                if (!string.IsNullOrEmpty(this.lblCardTypeId.Text))
                {
                    cardInfo.Add("card_type", _objId.ToString());
                }
                cardInfo.Add("status", Bouwa.ITSP2V31.Model.CardTypeInfo.CardTypeInfoDefaultCardStatus.已充值.ToString("D"));
                //生效日期
                if (!string.IsNullOrEmpty(this.lblEffectDate.Text))
                {
                    cardInfo.Add("efffect_date", Convert.ToDateTime(this.lblEffectDate.Text));
                }
                //最晚到期
                if (!string.IsNullOrEmpty(this.lblOutDate.Text))
                {
                    cardInfo.Add("end_date", Convert.ToDateTime(this.lblOutDate.Text));
                }

                //停车卡用途
                if (!string.IsNullOrEmpty(this.lblPurpose.Text))
                {
                    cardInfo.Add("purpose", Convert.ToInt32(this.lblPurpose.Text));
                    //cardInfo.purpose = 0;
                }
                //注册类型
                if (!string.IsNullOrEmpty(this.lblSubmitType.Text))
                {
                    cardInfo.Add("submit_type", Convert.ToInt32(this.lblSubmitType.Text));
                }
                //扣费类型
                if (!string.IsNullOrEmpty(this.lblCostType.Text))
                {
                    cardInfo.Add("cost_type", Convert.ToInt32(this.lblCostType.Text));
                    htCardInfo.Add("cost_type", Convert.ToInt32(this.lblCostType.Text));
                }
                //初始化操作日志,仅对非空白卡进行写数据

                string message = SystemConstant.StringEmpty;
                //剩余操作次数
                if (this.lblCostType.Text.Equals(CardTypeInfo.CardTypeInfoCostType.限次卡.ToString("D")))
                {
                    cardInfo.Add("times", Convert.ToInt32(this.tbxOverPlus.Text));
                    //备注信息
                    cardInfo.Add("memo", this.tbxCardNum.Text + "初始化成功!");
                    htCardInfo.Add("volume", Convert.ToInt32(this.tbxOverPlus.Text));
                    //htCardInfo.Add("operation_memo", String.Format(_objSystemMessage.GetInfoByCode("InitMemo").Content, this.tbxCardNum.Text, String.Format(_objSystemMessage.GetInfoByCode("InitTime").Content, this.tbxOverPlus.Text)));
                    message = "InitTime";
                }
                else
                {
                    cardInfo.Add("times", 0);
                }
                //剩余操作金额
                if (this.lblCostType.Text.Equals(CardTypeInfo.CardTypeInfoCostType.金额卡.ToString("D")))
                {
                    cardInfo.Add("money", Convert.ToDecimal(this.tbxOverPlus.Text));
                    //备注信息
                    cardInfo.Add("memo", this.tbxCardNum.Text + "初始化成功!");
                    htCardInfo.Add("volume", Convert.ToDecimal(this.tbxOverPlus.Text));
                    // htCardInfo.Add("operation_memo", String.Format(_objSystemMessage.GetInfoByCode("InitMemo").Content, this.tbxCardNum.Text, String.Format(_objSystemMessage.GetInfoByCode("InitMoney").Content, this.tbxOverPlus.Text)));
                    message = "InitMoney";
                }
                else
                {
                    cardInfo.Add("money", 0);
                }
                //剩余计费时间
                if (this.lblCostType.Text.Equals(CardTypeInfo.CardTypeInfoCostType.限时卡.ToString("D")))
                {
                    cardInfo.Add("charges_date", Convert.ToInt32(this.tbxOverPlus.Text));
                    //备注信息
                    cardInfo.Add("memo", this.tbxCardNum.Text + "初始化成功!");
                    htCardInfo.Add("volume", Convert.ToInt32(this.tbxOverPlus.Text));
                    //htCardInfo.Add("operation_memo", String.Format(_objSystemMessage.GetInfoByCode("InitMemo").Content, this.tbxCardNum.Text, String.Format(_objSystemMessage.GetInfoByCode("InitDegree").Content, this.tbxOverPlus.Text)));
                    message = "InitDegree";
                }
                else
                {
                    cardInfo.Add("charges_date", 0);
                }
                //剩余计费时间
                if (this.lblCostType.Text.Equals(CardTypeInfo.CardTypeInfoCostType.限期卡.ToString("D")))
                {
                    //备注信息
                    cardInfo.Add("memo", this.tbxCardNum.Text + "初始化成功!");
                    htCardInfo.Add("volume", Convert.ToDateTime(this.lblOutDate.Text).ToString("yyyyMMdd"));
                    //htCardInfo.Add("operation_memo", "初始化成功!");
                    message = "InitDate";
                }
                htCardInfo.Add("operation_memo_init", _objSystemMessage.GetInfoByCode("InitMemo").Content);
                htCardInfo.Add("operation_type_init", 1);

                if (this.ddlStatus.Text == CardTypeInfo.CardTypeInfoDefaultCardStatus.已充值.ToString())
                {
                    htCardInfo.Add("operation_type_payment", 5);
                    htCardInfo.Add("operation_memo_payment", string.Format(_objSystemMessage.GetInfoByCode(message).Content, this.tbxOverPlus.Text));
                }


                //初始化人员ID
                cardInfo.Add("create_user", CurrentUser.Current.UserId);
                htCardInfo.Add("operation_user", CurrentUser.Current.UserId);
                //初始化时间
                cardInfo.Add("create_time", DateTime.Now);
                htCardInfo.Add("operation_time", DateTime.Now.ToString());
                htCardInfo.Add("modity_user", CurrentUser.Current.UserId);
                htCardInfo.Add("modity_time", DateTime.Now.ToString());
                // htCardInfo.Add("operation_type","1");
                htCardInfo.Add("address_type", "1");
                htCardInfo.Add("network_id", CurrentUser.Current.NetWorkID);
                string mes = _objCardInfoBLL.ChangeCardInitAndBack(cardInfo, htCardInfo, null, ref _objSystemMessageInfo);

                if ("换卡操作成功!".Equals(mes))
                {
                    MessageBoxForm.Show("停车卡[" + this.tbxCardNum.Text + "]换卡成功!", MessageBoxButtons.OK);
                    this.Close();
                }
                else if ("换卡操作失败!".Equals(mes))
                {
                    //写入停车卡状态
                    RFIDClass.UpdateCardPassWordAndReturnStatus(this.lblNum.Text, 1, password, SystemConstant.StringEmpty);
                    writeBlock(1, 0, "");
                    writeBlock(1, 1, "");
                    writeBlock(1, 2, "");
                    MessageBoxForm.Show("停车卡[" + this.tbxCardNum.Text + "]换卡失败!", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                //写入停车卡状态
                RFIDClass.UpdateCardPassWordAndReturnStatus(this.lblNum.Text, 1, password, SystemConstant.StringEmpty);
                writeBlock(1, 0, "");
                writeBlock(1, 1, "");
                writeBlock(1, 2, "");
                MessageBoxForm.Show(ex.Message, MessageBoxButtons.OK);
            }
        }
示例#37
0
        public string ExportCSVTranscations(ViewTransactionCBE transaction)
        {
            Int16    IsDataFound = 0;
            var      filename    = "Transaction_Details_Registered_" + DateTime.Now.ToString(Constants.dateTimeFormat24HForFileName) + ".csv";
            var      filename1   = "Transaction_Details_UnRegistered_" + DateTime.Now.ToString(Constants.dateTimeFormat24HForFileName) + ".csv";
            FileInfo file        = new FileInfo(Server.MapPath("~/Attachment/ExportFiles/" + filename));
            FileInfo file1       = new FileInfo(Server.MapPath("~/Attachment/ExportFiles/" + filename1));

            try
            {
                string strstarttime = Convert.ToDateTime(transaction.StartDate).ToString("dd/MM/yyyy HH:mm:ss");
                string strendtime   = Convert.ToDateTime(transaction.EndDate).ToString("dd/MM/yyyy HH:mm:ss");
                string strQuery     = " WHERE 1=1 ";
                if (strstarttime != null && strendtime != null)
                {
                    strQuery += " AND  TRANSACTION_DATETIME BETWEEN TO_DATE('" + strstarttime + "','DD/MM/YYYY HH24:MI:SS') AND  TO_DATE('" + strendtime + "','DD/MM/YYYY HH24:MI:SS')";
                }
                else if (strstarttime != null)
                {
                    strQuery += " AND  TRANSACTION_DATETIME >= TO_DATE('" + strstarttime + "','DD/MM/YYYY HH24:MI:SS')";
                }
                else if (strendtime != null)
                {
                    strQuery += " AND  TRANSACTION_DATETIME <= TO_DATE('" + strendtime + "','DD/MM/YYYY HH24:MI:SS')";
                }
                DataTable dt      = TransactionBLL.TransDeatils(strQuery);
                DataView  dv      = new DataView(dt);
                DataTable Charged = dt.AsEnumerable()
                                    .Where(r => r.Field <decimal>("IS_REGISTERED") == 1)
                                    .CopyToDataTable();
                //DataTable Charged = (DataTable)(dv.RowFilter = "IS_BALANCE_UPDATED=1").;
                if (Charged.Rows.Count > 0)
                {
                    IsDataFound = CSVUtility.CreateCsv(file.FullName, Charged);
                    if (IsDataFound == 0)
                    {
                        filename = string.Empty;
                    }
                }
                DataTable UnCharged = dt.AsEnumerable()
                                      .Where(r => r.Field <decimal>("IS_REGISTERED") != 1)
                                      .CopyToDataTable();
                if (UnCharged.Rows.Count > 0)
                {
                    IsDataFound = CSVUtility.CreateCsv(file1.FullName, UnCharged);
                    if (IsDataFound == 0)
                    {
                        if (string.IsNullOrEmpty(filename))
                        {
                            filename = "No Data to Export.";
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(filename))
                        {
                            filename = "No Data to Export.";
                        }
                        else
                        {
                            filename = filename + ";" + filename1;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                filename = "No Data to Export. :" + ex.Message;
                HelperClass.LogMessage("Failed Export Transaction Details_ CSV " + ex);
            }
            string Det = JsonConvert.SerializeObject(filename, Formatting.Indented);

            return(Det.Replace("\r", "").Replace("\n", ""));
        }