示例#1
0
        public OrderReservation(OrderReservationRequestFrontEnd request, string sessionInfo, ProjectConfigData configData)
        {
            response = new OrderReservationResponseBackEnd();
            if (String.IsNullOrEmpty(request.requestId))
            {
                response.requestId = Guid.NewGuid().ToString();
            }
            else
            {
                response.requestId = request.requestId;
            }

            try
            {
                if (request.photoProcessId != null && request.photoProcessId.Count > 0)
                {
                    int photoCounter = request.photoProcessId.Count;

                    float amountValue = 0;
                    if (photoCounter > configData.billCosts.Length - 1)
                    {
                        amountValue = (float)Math.Round(configData.billCosts[configData.billCosts.Length - 1], 2);
                    }
                    else
                    {
                        amountValue = (float)Math.Round(configData.billCosts[photoCounter]);
                    }

                    if (amountValue > 0)
                    {
                        response.amount = String.Format("{0} {1}", amountValue, configData.billCurrency);

                        double delta = TimeSpan.FromTicks(DateTime.UtcNow.Ticks - 636710112000000000).TotalSeconds;
                        response.orderNumber = String.Format("{0}{1}", configData.billOrderPrefix, (((UInt64)(delta)).ToString("X") + ((byte)(delta % 1 * 16)).ToString("X")).Replace("0", "G").Replace("A", "S").Replace("B", "V").Replace("C", "R").Replace("E", "Z"));

                        if (photoCounter == 1 || photoCounter == 21 || photoCounter == 31 || photoCounter == 41 || photoCounter == 51 || photoCounter == 61 || photoCounter == 71 || photoCounter == 81 || photoCounter == 91 || photoCounter == 101)
                        {
                            response.description = String.Format("Покупка {0} фотографии.", photoCounter);
                        }
                        else
                        {
                            response.description = String.Format("Покупка {0} фотографий.", photoCounter);
                        }

                        MsSqlDbExplorer mySqlDbExplorer = new MsSqlDbExplorer();
                        mySqlDbExplorer.Orders_AddNewRecord(response.orderNumber, DateTime.Now, request.photoProcessId, (int)(amountValue * 100), 933, response.description, "user", request.sessionId);
                    }
                    else
                    {
                        response.description = "Нет фотографий для приобретения.";
                    }
                }
                else
                {
                    response.description = "Нет фотографий для приобретения.";
                }
            }
            catch (Exception exc) { }
        }
示例#2
0
 private void btn_UpdateOrdersDelivery_Click(object sender, EventArgs e)
 {
     MsSqlDbExplorer dbExplorer = new MsSqlDbExplorer();
     var             result     = dbExplorer.Orders_UpdateDeliveryResult
                                  (
         "lebyzhiy_1234567890",
         DateTime.Now,
         true
                                  );
 }
示例#3
0
        private void btn_TableRowCount_Click(object sender, EventArgs e)
        {
            MsSqlDbExplorer dbExplorer               = new MsSqlDbExplorer();
            int             result_Content           = dbExplorer.SelectCountFrom(MsSqlDbExplorer.Table.Content);
            int             result_SearchFaces       = dbExplorer.SelectCountFrom(MsSqlDbExplorer.Table.SearchFaces);
            int             result_SearchPhotos      = dbExplorer.SelectCountFrom(MsSqlDbExplorer.Table.SearchPhotos);
            int             result_OrderReservations = dbExplorer.SelectCountFrom(MsSqlDbExplorer.Table.OrderReservations);
            int             result_OrderPayments     = dbExplorer.SelectCountFrom(MsSqlDbExplorer.Table.OrderPayments);

            dbExplorer = null;
        }
示例#4
0
        private void btn_DropAllTables_Click(object sender, EventArgs e)
        {
            MsSqlDbExplorer dbExplorer = new MsSqlDbExplorer();

            int result_Orders = dbExplorer.DropTable(MsSqlDbExplorer.Table.Orders);

            int result_Content           = dbExplorer.DropTable(MsSqlDbExplorer.Table.Content);
            int result_SearchFaces       = dbExplorer.DropTable(MsSqlDbExplorer.Table.SearchFaces);
            int result_SearchPhotos      = dbExplorer.DropTable(MsSqlDbExplorer.Table.SearchPhotos);
            int result_OrderReservations = dbExplorer.DropTable(MsSqlDbExplorer.Table.OrderReservations);
            int result_OrderPayments     = dbExplorer.DropTable(MsSqlDbExplorer.Table.OrderPayments);

            dbExplorer = null;
        }
示例#5
0
 private void btn_UpdateOrdersAddress_Click(object sender, EventArgs e)
 {
     MsSqlDbExplorer dbExplorer = new MsSqlDbExplorer();
     var             result     = dbExplorer.Orders_UpdateAddressAndOrderId
                                  (
         "lebyzhiy_1234567890",
         DateTime.Now,
         "*****@*****.**",
         "*****@*****.**",
         "+375297776177",
         7,
         Guid.NewGuid().ToString()
                                  );
 }
示例#6
0
        private void btn_SelectContent_Click(object sender, EventArgs e)
        {
            string        connectionString = "Data Source=mssql.by1880.hb.by;Initial Catalog=photocore;Persist Security Info=True;User ID=photocoreuser;Password=!Q@WAZSX3e4rdcfv;Pooling=True";
            SqlConnection connection       = new SqlConnection(connectionString);
            int           counter          = 0;

            try
            { // https://www.sqlservertutorial.net/sql-server-basics/sql-server-drop-table/
                connection.Open();
                SqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = "SELECT amazon_id FROM Content;";
                var reader = cmd.ExecuteReader();

                List <Guid> guids = new List <Guid>();

                if (reader.HasRows)       // если есть данные
                {
                    while (reader.Read()) // построчно считываем данные
                    {
                        Guid amazon_id = (Guid)reader.GetValue(0);
                        if (guids.Count < 3)
                        {
                            guids.Add(amazon_id);                  ///////////////////////////////////////////////////////////////////////////////////////
                        }
                        counter++;
                    }
                }
                reader.Close();

                List <string> dateMasks = new List <string>();
                dateMasks.Add("20200322");
                dateMasks.Add("20200323");
                dateMasks.Add("20200324");
                List <Guid>[] facesGuids = new List <Guid> [guids.Count];
                for (int i = 0; i < guids.Count; i++)
                {
                    facesGuids[i] = guids;
                }

                MsSqlDbExplorer dbExplorer = new MsSqlDbExplorer();

                DateTime dt1    = DateTime.Now;
                var      result = dbExplorer.SelectFromContent(facesGuids, "12345", dateMasks);
                DateTime dt2    = DateTime.Now;
            }
            catch (Exception exc)
            {
                // Invalid object name 'Content'.
            }
        }
示例#7
0
 private void btn_UpdateOrdersPaymentNotSucc_Click(object sender, EventArgs e)
 {
     MsSqlDbExplorer dbExplorer = new MsSqlDbExplorer();
     var             result     = dbExplorer.Orders_UpdatePaymentResult
                                  (
         "lebyzhiy_1234567890",
         DateTime.Now,
         3,
         "Просто норма",
         1,
         "123456 ** 7890",
         "022022",
         "VITALI SUHAK",
         "123456",
         "2",
         "192.168.1.1"
                                  );
 }
示例#8
0
        private void btn_Register_Click(object sender, EventArgs e)
        {
            MsSqlDbExplorer msSqlDbExplorer = new MsSqlDbExplorer();


            // 2. Зарезервировать в банке заказ

            BillingBGPB billingBGPB = new BillingBGPB();

            billingBGPB.Register("Lebjazhiy_12345", "Тестовая покупка", 101, new ProjectConfigData());

            var registerResponse = JsonConvert.DeserializeObject <OrderPayment.RegisterResult>(billingBGPB.Answer);


            string mdOrder = null;

            int beg = billingBGPB.Answer.IndexOf("mdOrder=");

            if (beg > -1)
            {
                beg = beg + 8;
                int end = billingBGPB.Answer.IndexOf("\"", beg);
                if (end > -1)
                {
                    mdOrder = billingBGPB.Answer.Substring(beg, end - beg);
                }
            }
            //response.orderId = request.orderNumber;
            //if (mdOrder != null)
            //{
            //    // обновляем базу данными куда доставлять и банковскими данными

            //    if (msSqlDbExplorer.Orders_UpdateAddressAndOrderId(request.orderNumber, DateTime.Now, request.mainEmail, request.backupEmail, request.phone, request.messangers, mdOrder))
            //    {
            //        response.errorCode = 0;
            //        response.formUrl = configData.billReturnUrl;



            //    }
            //}
            //else response.errorCode = 1;
        }
示例#9
0
        private void btn_InsertOrders_Click_1(object sender, EventArgs e)
        {
            List <string> contentIdList = new List <string>();

            contentIdList.Add(Guid.NewGuid().ToString());
            contentIdList.Add(Guid.NewGuid().ToString());
            contentIdList.Add(Guid.NewGuid().ToString());

            MsSqlDbExplorer dbExplorer = new MsSqlDbExplorer();
            var             result     = dbExplorer.Orders_AddNewRecord
                                         (
                "lebyzhiy_1234567890",
                DateTime.Now,
                contentIdList,
                111,
                931,
                "Тестовый заказ",
                "user id in system",
                "user session data with ip and browser"
                                         );
        }
示例#10
0
        private void btn_InsertContent_Click(object sender, EventArgs e)
        {
            List <MsSqlDbExplorer.ContentData> data = new List <MsSqlDbExplorer.ContentData>();

            for (int i = 0; i < 10; i++) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            {
                MsSqlDbExplorer.ContentData cd = new MsSqlDbExplorer.ContentData()
                {
                    amazon_id         = Guid.NewGuid(),
                    location_id       = 12345,
                    partner_id        = 32000,
                    order_id          = Guid.NewGuid(),
                    shooting_datetime = DateTime.Now.AddMinutes(-10),
                    ready_datetime    = DateTime.Now,
                    expiration_date   = DateTime.Now.AddDays(10),
                    locked            = false,
                    x = 0.1F,
                    y = 0.2F,
                    w = 0.3F,
                    h = 0.4F,
                    a = 12,
                    //width = 6000, heigth = 4000, size = 2000000,
                    face_cloud_id        = Guid.NewGuid().ToString(),
                    thumbnail_cloud_id   = Guid.NewGuid().ToString(),
                    photo_cloud_id       = Guid.NewGuid().ToString(),
                    face_local_path      = "face_local_path_face_local_path_face_local_path_face_local_path_face_local_path",
                    thumbnail_local_path = "thumbnail_local_path_thumbnail_local_path_thumbnail_local_path_thumbnail_local_path_thumbnail_local_path",
                    photo_local_path     = "photo_local_path_photo_local_path_photo_local_path_photo_local_path_photo_local_path",
                };
                data.Add(cd);
            }

            MsSqlDbExplorer dbExplorer = new MsSqlDbExplorer();

            DateTime dt1  = DateTime.Now;
            var      lost = dbExplorer.InsertIntoContent(data);
            DateTime dt2  = DateTime.Now;
        }
示例#11
0
        public OrderPayment(OrderPaymentRequestFrontEnd request, string sessionInfo, ProjectConfigData configData)
        {
            response = new OrderPaymentResponseBackEnd();
            if (String.IsNullOrEmpty(request.requestId))
            {
                response.requestId = Guid.NewGuid().ToString();
            }
            else
            {
                response.requestId = request.requestId;
            }

            try
            {
                if (!String.IsNullOrEmpty(request.orderNumber) && !String.IsNullOrEmpty(request.mainEmail))
                {
                    string pattern     = @"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
                    Regex  r           = new Regex(pattern, RegexOptions.IgnoreCase);
                    bool   mainMatched = r.Match(request.mainEmail).Success; // true в случае подтверждения совпадения

                    bool backupMatched = false;
                    if (!String.IsNullOrEmpty(request.backupEmail))
                    {
                        backupMatched = r.Match(request.backupEmail).Success; // true в случае подтверждения совпадения
                    }
                    if (mainMatched || backupMatched)
                    {
                        // 1. Вычитать данные по заказу и извлечь его параметры
                        int    amount;
                        Int16  currency;
                        string description;

                        MsSqlDbExplorer msSqlDbExplorer = new MsSqlDbExplorer();

                        // извлекаем данные по заказу для формирования запроса в банк
                        if (msSqlDbExplorer.Orders_GetReservedOrderInfo(request.orderNumber, out amount, out currency, out description) && amount > 0 && currency > 0 && String.IsNullOrEmpty(description))
                        {
                            // 2. Зарезервировать в банке заказ

                            BillingBGPB billingBGPB = new BillingBGPB();
                            billingBGPB.Register(request.orderNumber, description, amount, new ProjectConfigData());

                            var registerResponse = JsonConvert.DeserializeObject <RegisterResult>(billingBGPB.Answer);

                            if (registerResponse.errorCode == 0) // заказ на оплату принят
                            {
                                if (msSqlDbExplorer.Orders_UpdateAddressAndOrderId(request.orderNumber, DateTime.Now, request.mainEmail, request.backupEmail, request.phone, request.messangers, registerResponse.orderId))
                                {
                                    response.errorCode = 0;
                                    response.formUrl   = registerResponse.formUrl;
                                    response.orderId   = registerResponse.orderId;
                                }
                                else
                                {
                                    response.errorCode = 7;
                                }
                            }
                            else
                            {
                                if (msSqlDbExplorer.Orders_UpdateAddressAndOrderId(request.orderNumber, DateTime.Now, request.mainEmail, request.backupEmail, request.phone, request.messangers, registerResponse.orderId))
                                {
                                    response.errorCode = (byte)registerResponse.errorCode; ///////////////////////////////////////////////////////
                                    response.formUrl   = registerResponse.formUrl;
                                    response.orderId   = registerResponse.orderId;
                                }
                                else
                                {
                                    response.errorCode = 7;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
            }
        }
示例#12
0
        // POST /payment/rest/register.do?amount=1964&currency=933&language=en&orderNumber=a2023b42ac9044b88968ccfa7d6c4cd9&returnUrl=finish.html&userName=Testing&password=Testing123&failUrl=error.html&description=testovaya pokupka HTTP/1.1
        // GET /payment/rest/getOrderStatus.do?userName=Testing&password=Testing123&orderId=2dc52a7f-247f-47bd-a9c1-b93bc981a494&language=en HTTP/1.1
        // {"depositAmount":0,"currency":"933","authCode":2,"params":{},"ErrorCode":"0","ErrorMessage":"Success","OrderStatus":0,"OrderNumber":"a2023b42ac9044b88968ccfa7d6c4cd9","Amount":1964}


        #region ОПЕРАЦИИ С ТАБЛИЦЕЙ CONTENT
        private void btn_CreateContent_Click(object sender, EventArgs e)
        {
            MsSqlDbExplorer dbExplorer = new MsSqlDbExplorer();
            var             result     = dbExplorer.CreateTable(MsSqlDbExplorer.Table.Content);
        }
示例#13
0
 private void btn_DeleteOrders_Click(object sender, EventArgs e)
 {
     var result = new MsSqlDbExplorer().DropTable(MsSqlDbExplorer.Table.Orders);
 }
示例#14
0
 private void btn_TotalRecordsContent_Click(object sender, EventArgs e)
 {
     int result = new MsSqlDbExplorer().SelectCountFrom(MsSqlDbExplorer.Table.Content);
 }
示例#15
0
        public SearchPhotos(SearchPhotosRequestFrontEnd request, string sessionInfo, string faceDir, ProjectConfigData configData)
        {
            response = new SearchPhotosResponseBackEnd();

            List <Guid>[] searchedFaceIds = null;

            this.awsAccessKeyId        = configData.awsAccessKeyId;
            this.awsSecretAccessKey    = configData.awsSecretAccessKey;
            this.awsRegionEndpoint     = Amazon.RegionEndpoint.GetBySystemName(configData.awsEndpoint);//("eu-west-1");
            this.awsCollectionId       = configData.awsCollectionId;
            this.awsFaceMatchThreshold = configData.awsFaceMatchThreshold;

            if (request != null)
            {
                if (request.requestId == null)
                {
                    response.requestId = Guid.NewGuid().ToString();
                }
                else
                {
                    response.requestId = request.requestId;
                }

                if (request.faces == null || request.faces.Count == 0)
                {
                    if (sessionInfo != null)
                    {
                        log.Debug(String.Format("SearchPhotos. Request. Id={0}. Null faces. Session info: {1}.", response.requestId, sessionInfo.Replace("\n", "; ")));
                    }
                    else
                    {
                        log.Debug(String.Format("SearchPhotos. Request. Id={0}. Null faces. Session info: NULL.", response.requestId));
                    }
                    response.photos = null;
                    log.Debug(String.Format("SearchPhotos. Response. Id={0}. Null result. Reason = \"No faces\".", response.requestId));
                }
                else if (request.searchDates == null || request.searchDates.Count == 0) // пустой список дат
                {
                    if (sessionInfo != null)
                    {
                        log.Debug(String.Format("SearchPhotos. Request. Id={0}. Null dates. Session info: {1}.", response.requestId, sessionInfo.Replace("\n", "; ")));
                    }
                    else
                    {
                        log.Debug(String.Format("SearchPhotos. Request. Id={0}. Null dates. Session info: NULL.", response.requestId));
                    }
                    response.photos = null;
                    log.Debug(String.Format("SearchPhotos. Response. Id={0}. Null result. Reason = \"No dates\".", response.requestId));
                }
                else
                {
                    dates = new List <string>();
                    for (int i = 0; i < request.searchDates.Count; i++)
                    {
                        if (request.searchDates[i] != null && request.searchDates[i].Length == 8)
                        {
                            bool isCorrect = true;
                            for (int c = 0; c < 8; c++)
                            {
                                if (request.searchDates[i][c] < 0x30 || request.searchDates[i][c] > 0x39)
                                {
                                    isCorrect = false; break;
                                }
                            }
                            if (isCorrect)
                            {
                                dates.Add(request.searchDates[i]);
                            }
                        }
                    }
                    if (dates.Count == 0)
                    {
                        if (sessionInfo != null)
                        {
                            log.Debug(String.Format("SearchPhotos. Request. Id={0}. Null dates. Session info: {1}.", response.requestId, sessionInfo.Replace("\n", "; ")));
                        }
                        else
                        {
                            log.Debug(String.Format("SearchPhotos. Request. Id={0}. Null dates. Session info: NULL.", response.requestId));
                        }
                        response.photos = null;
                        log.Debug(String.Format("SearchPhotos. Response. Id={0}. Null result. Reason = \"No dates\".", response.requestId));
                    }
                    else
                    {
                        response.photos = null;
                        List <string> faceFileNames = new List <string>();
                        for (int i = 0; i < request.faces.Count; i++)
                        {
                            string faceFile = String.Format("{0}{1}.jpg", faceDir, request.faces[i]);
                            if (System.IO.File.Exists(faceFile))
                            {
                                faceFileNames.Add(faceFile);
                            }
                        }

                        if (faceFileNames != null && faceFileNames.Count > 0 && dates != null && dates.Count > 0)
                        {
                            if (sessionInfo != null)
                            {
                                log.Debug(String.Format("SearchPhotos. Request. Id={0}. Total faces={1}. Total dates={2}. Session info: {3}.", response.requestId, sessionInfo.Replace("\n", "; "), faceFileNames.Count, dates.Count));
                            }
                            else
                            {
                                log.Debug(String.Format("SearchPhotos. Request. Id={0}. Total faces={1}. Total dates={2}. Session info: NULL.", response.requestId, faceFileNames.Count, dates.Count));
                            }
                            response.photos = null;
                            AmazonSearcher amazonSearcher = new AmazonSearcher(faceFileNames, dates, configData);
                            searchedFaceIds = amazonSearcher.SearchedFaceIds;
                            amazonSearcher  = null;

                            if (searchedFaceIds != null && searchedFaceIds.Length > 0)
                            {
                                MsSqlDbExplorer mySqlDbExplorer = new MsSqlDbExplorer(new ProjectConfigData());
                                response.photos = mySqlDbExplorer.SelectFromContent(searchedFaceIds, request.locationId, dates);

                                //log.Debug(String.Format("SearchPhotos. Response. Id={0}. Null result. Reason = \"No dates\".", response.requestId));
                            }
                            else
                            {
                            }
                        }
                        else
                        {
                            // дописать логирование
                        }
                    }
                }
            }
            else
            {
                log.Debug("SearchPhotos. Null request.");
                response.requestId = Guid.NewGuid().ToString();
                response.photos    = null;
            }
        }