Exemplo n.º 1
0
        public IEnumerable <AdVM> GetBooks()
        {
            var booksIDs = (from b in db.Seller_Approved_book
                            where b.Approved == "Yes"
                            select b).OrderByDescending(x => x.Book.Date_Uploaded);
            List <AdVM> adsList = new List <AdVM>();

            foreach (var item in booksIDs)
            {
                //AdVM adVM = new AdVM();
                //adVM.BookID = item.Book_Id;
                //adVM.UserID = item.Seller_Id;
                //var book = (from b in db.Books
                //            where b.Id == item.Book_Id
                //            select b).FirstOrDefault();
                //var images = (from i in db.Images
                //              where i.Book_Id == item.Book_Id
                //              select i).FirstOrDefault();
                //adVM.Img_Url = images.Img_URL;
                //adVM.Name = book.Name;
                //adVM.Points = book.Points;
                //adVM.Date_Uploaded = book.Date_Uploaded;
                //adsList.Add(adVM);
                var OpDone = db.Seller_Buyer_Book.Where(op => op.BuyerConfirm == "Yes" && op.SellerConfirm == "Yes" && op.Book_Id == item.Book_Id).FirstOrDefault();
                if (OpDone == null)
                {
                    adsList.Add(ConvertClass.ApprovedToAdsVm(item));
                }
            }
            return(adsList);
        }
        public void StringToAsciiTest()
        {
            string strOperatString = "313131313131";
            string strResult       = ConvertClass.StringToAscii(strOperatString);

            Assert.AreEqual(strResult, "1");
        }
Exemplo n.º 3
0
        public IEnumerable <AdVM> GetByCity(string cityName)
        {
            var books =
                (from b in db.Books
                 where b.City.Name == cityName
                 select b).ToList();

            var appBook =
                (from appB in db.Seller_Approved_book
                 where appB.Approved == "Yes"
                 select appB).OrderByDescending(x => x.Book.Date_Uploaded).ToList();
            List <Seller_Approved_book> appBookList = new List <API_Server.Seller_Approved_book>();

            foreach (var approved in appBook)
            {
                foreach (var book in books)
                {
                    if (book.Id == approved.Book_Id)
                    {
                        appBookList.Add(approved);
                    }
                }
            }

            List <AdVM> bookvmList3 = new List <AdVM>();

            foreach (var item in appBookList)
            {
                bookvmList3.Add(ConvertClass.ApprovedToAdsVm(item));
            }
            return(bookvmList3);
        }
        public void GetWeekOfYearTest1()
        {
            DateTime tim          = DateTime.Now;
            int      intWeekValue = ConvertClass.GetWeekOfYear(tim);

            Assert.AreEqual(intWeekValue, 1);
        }
        public void Special_BytesToStrHexTest()
        {
            byte[] byts     = new byte[] { 0X01, 0X02, 0X03, 0XFF };
            string strValue = ConvertClass.Special_BytesToStrHex(byts);

            Assert.AreEqual(strValue, 1);
        }
        public void GetWeekofDateTimeValueTest()
        {
            DateTime tim     = DateTime.Now.AddDays(-6);
            int      intWeek = ConvertClass.GetWeekofDateTimeValue(tim.DayOfWeek);

            Assert.AreEqual(intWeek, 1);
        }
        public void GetWeekNumInMonthTest()
        {
            DateTime tim          = DateTime.Now;
            int      intWeekValue = ConvertClass.GetWeekNumInMonth(tim);

            Assert.AreEqual(intWeekValue, 1);
        }
Exemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            //DateTime timStart = DateTime.Now.AddSeconds(-3000);
            //DateTime timEnd = DateTime.Now.AddSeconds(-2700);
            DateTime timStart = DateTime.Parse("2019-09-06 12:33:00");
            DateTime timEnd   = DateTime.Parse("2019-09-06 12:35:01");
            //DateTime timStart = DateTime.Now.AddSeconds(-3000);
            //DateTime timEnd = DateTime.Now.AddSeconds(-2700);
            long start_time = ConvertClass.DateTimeToUnixTimestamp(timStart);
            long stop_time  = ConvertClass.DateTimeToUnixTimestamp(timEnd);

            //long start_time = ConvertClass.DateTimeToUnixTimestamp(DateTime.Parse("2019-06-05 17:01:38"));
            //long stop_time = ConvertClass.DateTimeToUnixTimestamp(DateTime.Parse("2019-06-05 17:03:34"));
            //long start_time = ConvertClass.DateTimeToUnixTimestamp(DateTime.Parse("2019-06-05 15:04:13"));
            //long stop_time = ConvertClass.DateTimeToUnixTimestamp(DateTime.Parse("2019-06-05 15:50:03"));
            //long start_time = 1559802091;
            //long stop_time = 1559802199;
            int intCount = 0;

            while (SDK_SKVideoSDK.p_sdkc_get_online() == 0 && intCount < 10)
            {
                Common.Delay_Second(1);
                intCount++;
            }
            //string Temp_strDownPath = @"C:\SHIKE_Video\0138\DownloadTest\" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".H264";

            Temp_strName = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss");
            //string Temp_strDownPath = @"C:\SHIKE_Video\0138\DownloadTest";
            string Temp_strDownPath = Path + "\\" + Temp_strName + "_Temp.h264";
            int    intResult        = SDK_SKVideoSDK.p_sdkc_request_download_video("72-00F51F0150E8-35B7", 0, (int)start_time, (int)stop_time, Temp_strDownPath);

            intCount         = 0;
            timDownLoadStart = DateTime.Now;
        }
Exemplo n.º 9
0
        private void FrmSKVideoSDKTest_Load(object sender, EventArgs e)
        {
            CurrentVideoInfo = TestDataSource.TestDataSource.GetSKDVSData3();

            p_msg_demo_callback = new CallBack(callback);
            SDK_SKVideoSDK.p_sdkc_reg_msg_callback(p_msg_demo_callback);

            SDK_SKVideoSDK.p_sdkc_init_client("Admin", "192.168.2.19", 47624, 47724, 47824, @"d:\");
            while (SDK_SKVideoSDK.p_sdkc_get_online() == 0)
            {
                Common.Delay_Second(1);
            }
            DateTime timStart     = DateTime.Now.AddSeconds(-3000);
            DateTime timEnd       = DateTime.Now.AddSeconds(-2700);
            long     intStartTime = ConvertClass.DateTimeToUnixTimestamp(timStart);
            long     intEndTimt   = ConvertClass.DateTimeToUnixTimestamp(timEnd);

            //SDK_SKVideoSDK.p_sdkc_start_playback_av(CurrentVideoInfo.DVSAddress, 0, Convert.ToUInt32(intStartTime), pictureBox1.Handle);

            p_vsdk_reg_dl_video_data_callback = new p_dl_video_data_callback(callback_download);
            SDK_SKVideoSDK.p_vsdk_reg_dl_video_data_callback(p_vsdk_reg_dl_video_data_callback);
            //string Temp_strDownPath = @"C:\SHIKE_Video\0138\DownloadTest\" + timStart.ToString("yyyy_MM_dd_HH_mm_ss") + ".H264";
            //string Temp_strDownPath = @"C:\SHIKE_Video\0138\DownloadTest";
            //int intResult = SDK_SKVideoSDK.p_sdkc_request_download_video(CurrentVideoInfo.DVSAddress, 0, (int)intStartTime, (int)intEndTimt, Temp_strDownPath);
        }
        public IHttpActionResult Postcat(CategoryVM cat)
        {
            bool catFlag = isAddedBefor(cat.Name);

            if (catFlag)
            {
                ModelState.AddModelError("cat", "Categoryl already exists");
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Category newcat = new API_Server.Category();

            newcat = ConvertClass.VMToCategory(cat);
            db.Categories.Add(newcat);
            db.SaveChanges();


            var catId =
                (from c in db.Categories
                 where c.Name == cat.Name
                 select c.Id).FirstOrDefault();

            return(Ok(catId));
        }
Exemplo n.º 11
0
        public async Task <JsonResult> DatabaseGetByGardenerID()
        {
            var str = new List <DatabaseStead>();
            //происходит запрос с id, в базе данных ищутся все строки с id садовода == id, который пришел в запросе
            string sqlExpression = $"SELECT * FROM Steads WHERE GardenerID = {User.Identity.Name}";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand    command = new SqlCommand(sqlExpression, connection);
                SqlDataReader reader  = command.ExecuteReader();
                if (reader.HasRows) // если есть данные
                {
                    //в этом месте присвоения можно создавать экземпляры классов с десериализацией или же просто доставать строку, затем добавлять в какой-то IEnumerable и возвращать его
                    while (reader.Read()) // построчно считываем данные
                    {
                        var stead = new ConvertClass();
                        stead.Id         = (int)reader.GetValue(0);
                        stead.Stead      = (string)reader.GetValue(1);
                        stead.GardenerID = (int)reader.GetValue(2);
                        var convertedStead = new DatabaseStead();
                        convertedStead.Id         = stead.Id;
                        convertedStead.Stead      = JsonConvert.DeserializeObject <Stead>(stead.Stead);
                        convertedStead.GardenerID = stead.GardenerID;
                        str.Add(convertedStead);
                    }
                }
            }
            return(Json(str));
            //var l = JsonConvert.SerializeObject(str);
            //var k = l.Substring(1, l.Length);
            //return new JsonResult(JsonConvert.SerializeObject(str));
        }
Exemplo n.º 12
0
 protected void OnButton1Clicked(object sender, EventArgs e)
 {
     if (this.num1.Text == null || this.num1.Text == "")
     {
         textview4.Buffer.Text += "ERRO: Nenhum numero digitado.\n";
     }
     else if (this.combobox1.Active == 0)
     {
         textview4.Buffer.Text += "ERRO: Base de origen nao foi selecionada.\n";
     }
     else if (this.combobox2.Active == 0)
     {
         textview4.Buffer.Text += "ERRO: Base final nao foi selecionada.\n";
     }
     else
     {
         try{
             textview4.Buffer.Text = ConvertClass.conver(this.num1.Text, this.combobox1.Active, this.combobox2.Active);
         }
         catch (Exception ex) {
             MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, "Error: Tentativa de conversao de numero maior que 64 bits. \n" + ex.ToString());
             md.Run();
             md.Destroy();
         }
     }
     textview4.ScrollToIter(textview4.Buffer.EndIter, 0, true, 0, 0);
 }
Exemplo n.º 13
0
        //为草图缩略图加上时间段
        public static void AddTextBoxTime(MyButton myButton)
        {
            List <string> hmsStart    = ConvertClass.getInstance().MsToHMS(myButton.TimeStart);
            List <string> hmsEnd      = ConvertClass.getInstance().MsToHMS(myButton.TimeEnd);
            string        TimeString  = hmsStart[0] + ":" + hmsStart[1] + ":" + hmsStart[2] + "-" + hmsEnd[0] + ":" + hmsEnd[1] + ":" + hmsEnd[2];
            TextBox       textBoxTime = new TextBox();

            textBoxTime.Margin          = new System.Windows.Thickness(myButton.Left, myButton.Top - 15, 0, 0);
            textBoxTime.Width           = 110;
            textBoxTime.FontSize        = 10;
            textBoxTime.Height          = 15;
            textBoxTime.Background      = null;
            textBoxTime.Text            = TimeString;
            textBoxTime.BorderThickness = new System.Windows.Thickness(0);

            if (myButton.TextBoxTime != null)
            {
                textBoxTime.RenderTransform = myButton.TextBoxTime.RenderTransform;
                if (myButton.TextBoxTime.Background != null)
                {
                    textBoxTime.Background = myButton.TextBoxTime.Background;
                }
            }
            myButton.TextBoxTime = textBoxTime;
        }
Exemplo n.º 14
0
        public ChatRoomViewModel(MainViewModel mainVM, string ip, int remotePort, Server server)
        {
            this.mainVM = mainVM;
            this.server = server;
            uniqueID    = (int)(GetHashCode() & 0xFFFFFFFC);

            myModel = new UserModel(uniqueID, mainVM.Name);
            client  = new Client(ip, remotePort, uniqueID, this);
            client.SendData(ConvertClass.ObjectToByteArray(myModel), 0, uniqueID + 0);
            users            = new List <UserModel>();
            webcam           = new Webcam((new FilterInfoCollection(FilterCategory.VideoInputDevice))[0]);
            webcam.NewFrame += (sender, e) =>
            {
                if (myModel.IsScreenDemonstration != true)
                {
                    client.SendData(ConvertClass.ConvertBitmapToByte((Bitmap)e.Frame.Clone()), 0, uniqueID + 1);
                }
            };
            audioRecord = new AudioRecord(0);
            audioRecord.DataAvailable += (sender, e) =>
            {
                client.SendData(e.Buffer, 0, uniqueID + 2);
            };
            demonstration           = new ScreenDemonstration();
            demonstration.NewFrame += (sender, e) =>
            {
                client.SendData(ConvertClass.ConvertBitmapToByte((Bitmap)e.Frame.Clone()), 0, uniqueID + 1);
            };
        }
Exemplo n.º 15
0
        public void GetDataToDayTest()
        {
            DateTime tim       = DateTime.Now;
            DateTime timResult = ConvertClass.GetDataTimeToDay(tim);

            Assert.AreEqual(timResult, "123");
        }
Exemplo n.º 16
0
        public IEnumerable <AdVM> GetUserAds(int userID)
        {
            var booksIDs = (from b in db.Seller_Approved_book
                            where b.Seller_Id == userID
                            select b).OrderByDescending(x => x.Book.Date_Uploaded);

            if (booksIDs == null)
            {
                return(null);
            }
            List <AdVM> adsList = new List <AdVM>();

            foreach (var item in booksIDs)
            {
                //AdVM adVM = new AdVM();
                //adVM.BookID = item.Book_Id;
                //adVM.UserID = item.Seller_Id;
                //var book = (from b in db.Books
                //            where b.Id == item.Book_Id
                //            select b).FirstOrDefault();
                //var images = (from i in db.Images
                //              where i.Book_Id == item.Book_Id
                //              select i).FirstOrDefault();
                //adVM.Img_Url = images.Img_URL;
                //adVM.Name = book.Name;
                //adVM.Description = book.Discription;
                //adVM.Points = book.Points;
                //adVM.Date_Uploaded = book.Date_Uploaded;
                //adsList.Add(adVM);
                adsList.Add(ConvertClass.ApprovedToAdsVm(item));
            }
            return(adsList);
        }
Exemplo n.º 17
0
        public void GetMonthDateTimeTest()
        {
            DateTime tim1   = DateTime.Today;
            DateTime result = ConvertClass.GetMonthDateTime(tim1);

            Assert.AreEqual(result, DateTime.Now);
        }
        public object Convert(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture)
        {
            var x = ConvertClass.ToDouble(rpValue);
            var y = ConvertClass.ToDouble(rpParameter);

            return((int)(x * y));
        }
Exemplo n.º 19
0
        public void LinuxToTimeTest()
        {
            //long l = 1526886082;
            long     l         = 1569218833000;
            DateTime timResult = ConvertClass.UnixTimestampToDateTime(l);

            Assert.AreEqual(timResult, DateTime.Now);
        }
Exemplo n.º 20
0
        public void BytesToStrTest()
        {
            //Byte[] bytsValue = new byte[] { 0X31, 0X31, 0X31, 0X31, 0X31, 0X31 };
            //Byte[] bytsValue = new byte[] { 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF };
            Byte[] bytsValue = new byte[] { 0X00, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF };
            string strResult = ConvertClass.BytesToCharStr(bytsValue);

            Assert.AreEqual(strResult, "1");
        }
Exemplo n.º 21
0
        public void DataProcessing(int userID, byte operation, byte[] data)
        {
            UserModel user = Users.Find(obj => obj.ID == (int)(userID & 0xFFFFFFFC));

            switch (userID & 3)
            {
            case 0:
                switch (operation)
                {
                case 0:
                    UserModel newUser = ConvertClass.ByteArrayToObject(data) as UserModel;
                    newUser.VoiceFrame = new AudioOutput();
                    Users = CollectionConversion.ConcatList <UserModel>(users, new List <UserModel>()
                    {
                        newUser
                    });
                    break;

                case 1:
                    Users = CollectionConversion.ConcatList <UserModel>(users, ConvertClass.ByteArrayToObject(data) as List <UserModel>);
                    foreach (var value in Users)
                    {
                        value.VoiceFrame = new AudioOutput();
                    }
                    break;

                case 2:
                    PropertyInfo property = ConvertClass.ByteArrayToObject(data) as PropertyInfo;
                    property.SetValue(user, !(bool)property.GetValue(user));
                    break;

                case 3:
                    mainVM.CurrentViewModel = new MenuViewModel(mainVM);
                    break;

                case 4:
                    Users = (ConvertClass.ByteArrayToObject(data) as List <UserModel>).FindAll(obj => obj.ID != uniqueID);
                    break;
                }
                break;

            case 1:
                if (user.IsWebcam != false || user.IsScreenDemonstration != false)
                {
                    user.CurrentFrame = new Bitmap(new MemoryStream(data));
                }
                break;

            case 2:
                if (MyModel.IsSpeaker)
                {
                    user.VoiceFrame.AddData(data);
                }
                break;
            }
        }
Exemplo n.º 22
0
        public int CountByUserIDWait(int userID, string monthYear)
        {
            ConvertClass cv = new ConvertClass();

            string[] yM  = monthYear.Split('-');
            string   sql = "SELECT COUNT(*) C FROM REPAIR WHERE REP_STATUS_ID=1 AND USER_NO=" + userID + " AND (DATEPART(year, REPAIR_REG)=" + yM[0] + " AND  DATEPART(month, REPAIR_REG)=" + yM[1] + ")";
            Dictionary <string, object> listData = db.querySingle(sql);

            return(Int32.Parse(listData["C"].ToString()));
        }
Exemplo n.º 23
0
        public void DateTimeToUnixTimestampTest()
        {
            //long l = 1526886082;
            long     l         = 1569218833000;
            DateTime timResult = ConvertClass.UnixTimestampToDateTime(l);
            long     lResult   = ConvertClass.DateTimeToUnixTimestamp(timResult);

            Assert.AreEqual(l, lResult);
            //ch01_00000000001041800
        }
Exemplo n.º 24
0
        public void GetWeekOfDataTimeTest()
        {
            //DateTime tim = DateTime.Now;
            //DateTime tim = DateTime.Parse("2018-12-30 11:11:11");

            DateTime tim     = DateTime.Now.AddDays(-1);
            int      intWeek = ConvertClass.GetWeekOfDataTime(tim);

            Assert.AreEqual(intWeek, 1);
        }
 public object Convert(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture)
 {
     if (rpValue is double)
     {
         return((double)rpValue == .0 ? EnumUtil.GetBoxed(Visibility.Collapsed) : EnumUtil.GetBoxed(Visibility.Visible));
     }
     else
     {
         return(ConvertClass.ToInt32(rpValue) == 0 ? EnumUtil.GetBoxed(Visibility.Collapsed) : EnumUtil.GetBoxed(Visibility.Visible));
     }
 }
Exemplo n.º 26
0
        public static IntPtr ResolvePtrOffset(IntPtr offset32Ptr, IntPtr nextInstructionPtr)
        {
            uint jmpOffset = offset32Ptr.AsUInt();
            uint valueUInt = new ConvertClass()
            {
                valueULong = (ulong)nextInstructionPtr.ToInt64()
            }.valueUInt;
            long delta     = nextInstructionPtr.ToInt64() - valueUInt;
            uint newPtrInt = unchecked (valueUInt + jmpOffset);

            return(new IntPtr(newPtrInt + delta));
        }
Exemplo n.º 27
0
        public IEnumerable <AdVM> GetByGovId(int id)
        {
            var cities =
                (from c in db.Cities
                 where c.Governate_Id == id
                 select c.Id).ToList();

            List <Book> booklist  = new List <Book>();
            List <Book> booklist2 = new List <Book>();

            foreach (var item in cities)
            {
                booklist =
                    (from b in db.Books
                     where b.City_Id == item
                     select b).ToList();

                foreach (var item2 in booklist)
                {
                    booklist2.Add(item2);
                }
            }

            var approved =
                (from b in db.Seller_Approved_book
                 where b.Approved == "Yes"
                 select b).OrderByDescending(x => x.Book.Date_Uploaded).ToList();

            List <Seller_Approved_book> appBookList = new List <API_Server.Seller_Approved_book>();

            foreach (var appBook in approved)
            {
                foreach (var book in booklist2)
                {
                    if (book.Id == appBook.Book_Id)
                    {
                        appBookList.Add(appBook);
                    }
                }
            }

            List <AdVM> adVm = new List <AdVM>();

            foreach (var appBook in appBookList)
            {
                var OpDone = db.Seller_Buyer_Book.Where(op => op.BuyerConfirm == "Yes" && op.SellerConfirm == "Yes" && op.Book_Id == appBook.Book_Id).FirstOrDefault();
                if (OpDone == null)
                {
                    adVm.Add(ConvertClass.ApprovedToAdsVm(appBook));
                }
            }
            return(adVm);
        }
Exemplo n.º 28
0
        public IHttpActionResult GetRequest(int userID, int bookID)
        {
            var request = db.Requests.Where(x => x.Requester_Id == userID && x.Book_Id == bookID).FirstOrDefault();

            if (request == null)
            {
                return(NotFound());
            }
            RequestVM requestVM = ConvertClass.RequestToVM(request);

            return(Ok(requestVM));
        }
Exemplo n.º 29
0
        public IEnumerable <RequestVM> GetRequests(int userID, int bookID)
        {
            var requests = db.Requests.Where(x => x.Seller_Id == userID && x.Book_Id == bookID && (x.Acctepted == "Yes" || x.Acctepted == "No")).Select(x => x).OrderByDescending(x => x.Date);
            List <RequestVM> requestList = new List <RequestVM>();

            foreach (var item in requests)
            {
                RequestVM requestVM = ConvertClass.RequestToVM(item);
                requestList.Add(requestVM);
            }
            return(requestList);
        }
Exemplo n.º 30
0
        public IHttpActionResult AcceptedRequest(int BookID)
        {
            var req = db.Requests.Where(r => r.Book_Id == BookID && r.Acctepted == "Yes").FirstOrDefault();

            if (req == null)
            {
                return(Ok(req));
            }
            RequestVM reqVM = ConvertClass.RequestToVM(req);

            return(Ok(reqVM));
        }