Пример #1
0
        protected override List <BaseIntegrationObject> ReadPack()
        {
            var pack = new List <BaseIntegrationObject>();

            lock (_lock)
            {
                using (var provider = new DBConnectionProvider())
                {
                    using (var reader = provider.Execute(_selectQuery, packSize))
                    {
                        while (reader != null && reader.Read())
                        {
                            pack.Add(new SMS()
                            {
                                ContactId     = reader.GetValue("ContactId", String.Empty),
                                ContactPhone  = reader.GetValue("ContactPhone", String.Empty),
                                MessageStatus = reader.GetValue("MessageStatus", String.Empty),
                                SentDate      = reader.GetValue("SentDate", String.Empty),
                                ERPId         = reader.GetValue("ERPId", String.Empty),
                                Text          = reader.GetValue("Text", String.Empty),
                                Id            = Guid.NewGuid(),
                            });
                        }
                    }
                }

                if (pack.Count > 0)
                {
                    DBConnectionProvider.ExecuteNonQuery(String.Format("Update {1} Set Status = 3 Where ERPId in ({0})", String.Join(",", pack.Select(p => String.Format("'{0}'", p.CorrectERPId))), _tableName));
                }
            }

            return(pack);
        }
Пример #2
0
        protected void ProceedPrimaryResults(PrimaryIntegratePackResponse results)
        {
            try
            {
                var query = new StringBuilder();
                foreach (var result in results.PrimaryIntegratePackResult)
                {
                    if (result.IsSuccess)
                    {
                        query.AppendLine(String.Format("Update {1} Set Status = 1 Where ERPId = '{0}';", result.GetCorrectId(), _tableName));
                    }
                    else
                    {
                        var errorMessage = String.IsNullOrEmpty(result.ErrorMessage) ? String.Empty : result.ErrorMessage.Replace("'", "''").Replace("{", "").Replace("}", "");
                        if (errorMessage.Length > 250)
                        {
                            errorMessage = errorMessage.Substring(0, 250);
                        }
                        query.AppendLine(String.Format("Update {2} Set Status = {3}, ErrorMessage = '{1}' Where ERPId = '{0}';", result.GetCorrectId(), errorMessage, _tableName, result.IsTimeout ? "4" : "2"));
                    }
                }

                var sql = query.ToString();
                if (!string.IsNullOrEmpty(sql))
                {
                    DBConnectionProvider.ExecuteNonQuery(sql);
                }
            }
            catch (Exception e)
            {
                Logger.LogError(JsonConvert.SerializeObject(results), e);
            }
        }
Пример #3
0
        protected override List <BaseIntegrationObject> ReadPack()
        {
            var pack = new List <BaseIntegrationObject>();

            lock (_lock)
            {
                using (var provider = new DBConnectionProvider())
                {
                    using (var reader = provider.Execute(_selectQuery, packSize))
                    {
                        while (reader != null && reader.Read())
                        {
                            pack.Add(new ProductCategory()
                            {
                                Name      = reader.GetValue("name", String.Empty),
                                ERPId     = reader.GetValue("ERPId", String.Empty),
                                Direction = reader.GetValue("Direction", String.Empty),
                                Id        = Guid.NewGuid(),
                            });
                        }
                    }
                }

                if (pack.Count > 0)
                {
                    DBConnectionProvider.ExecuteNonQuery(String.Format("Update {1} Set Status = 3 Where ERPId in ({0})", String.Join(",", pack.Select(p => String.Format("'{0}'", p.CorrectERPId))), _tableName));
                }
            }

            return(pack);
        }
Пример #4
0
        private void SetProcessingErrors(List <BaseIntegrationObject> pack, string responseStr, bool isTimeout)
        {
            var errorMessage = String.IsNullOrEmpty(responseStr) ? String.Empty : responseStr.Replace("'", "''").Replace("{", "").Replace("}", "");

            if (errorMessage.Length > 250)
            {
                errorMessage = errorMessage.Substring(0, 250);
            }
            DBConnectionProvider.ExecuteNonQuery(String.Format("Update {1} Set Status = {3}, ErrorMessage = '{2}' Where ERPId in ({0})", String.Join(",", pack.Select(p => String.Format("'{0}'", p.CorrectERPId))), _tableName, errorMessage, isTimeout ? "4" : "2"));
        }
Пример #5
0
        protected override List <BaseIntegrationObject> ReadPack()
        {
            var pack = new List <BaseIntegrationObject>();

            lock (_lock)
            {
                using (var provider = new DBConnectionProvider())
                {
                    using (var reader = provider.Execute(_selectContact, packSize))
                    {
                        while (reader != null && reader.Read())
                        {
                            pack.Add(new Contact()
                            {
                                Address          = reader.GetValue("address", String.Empty),
                                City             = reader.GetValue("City", String.Empty),
                                Country          = reader.GetValue("Country", String.Empty),
                                ContactStatus    = reader.GetValue("contactStatus", String.Empty),
                                Email            = reader.GetValue("email", String.Empty),
                                ErrorMessage     = reader.GetValue("errorMessage", String.Empty),
                                FirstName        = reader.GetValue("FirstName", String.Empty),
                                MiddleName       = reader.GetValue("MiddleName", String.Empty),
                                Phone            = reader.GetValue("Phone", String.Empty),
                                RegistrationDate = reader.GetValue("RegistrationDate", String.Empty),
                                CreatedOn        = reader.GetValue("CreatedOn", String.Empty),
                                BirthDay         = reader.GetValue("birthday", String.Empty),
                                ERPId            = reader.GetValue("ERPId", String.Empty),
                                Id       = Guid.NewGuid(),
                                Surname  = reader.GetValue("Surname", String.Empty),
                                ShopCode = reader.GetValue("ShopCode", String.Empty),
                                SmrNearestMetroStation = reader.GetValue("SmrNearestMetroStation", String.Empty),
                                BonusBalance           = reader.GetValue("bonusBalance", 0m),
                                IsMan = reader.GetValue("gender", false),
                                PersDataProcAgreement = reader.GetValue("PersDataProcAgreement", false),
                                RequiresCorrection    = reader.GetValue("RequiresCorrection", false),
                                ThereAreEmptyFields   = reader.GetValue("ThereAreEmptyFields", String.Empty),
                                Type = reader.GetValue("type", -1),
                            });
                        }
                    }
                }

                if (pack.Count > 0)
                {
                    DBConnectionProvider.ExecuteNonQuery(String.Format("Update ContactGate Set Status = 3 Where ERPId in ({0})", String.Join(",", pack.Select(p => String.Format("'{0}'", p.CorrectERPId)))));
                }
            }

            return(pack);
        }
Пример #6
0
        public ActionResult ExportBalance([FromBody] List <ContactBalance> balances)
        {
            foreach (var balance in balances)
            {
                DBConnectionProvider.ExecuteNonQuery(
                    string.Format(
                        @"IF NOT EXISTS(select top 1 1 from ContactBalanceGate where ERPId = '{0}' and bonusType = '{2}')
                        BEGIN
                            Insert into ContactBalanceGate(ERPId, uploadedOn, bonusBalance, bonusType) VALUES('{0}', GETUTCDATE(), {1}, '{2}')
                        END
                        ELSE BEGIN
                            update ContactBalanceGate set bonusBalance = {1}, uploadedOn = GETUTCDATE() where ERPId = '{0}'
                        END
                        ",
                        balance.ERPId, balance.Balance.ToString().Replace(",", "."), balance.BonusType));
            }

            return(Ok());
        }
Пример #7
0
        protected override List <BaseIntegrationObject> ReadPack()
        {
            var pack = new List <BaseIntegrationObject>();

            lock (_lock)
            {
                using (var provider = new DBConnectionProvider())
                {
                    using (var reader = provider.Execute(_selectQuery, packSize))
                    {
                        while (reader != null && reader.Read())
                        {
                            pack.Add(new Product()
                            {
                                Name                   = reader.GetValue("name", String.Empty),
                                ERPId                  = reader.GetValue("ERPId", String.Empty),
                                Category               = reader.GetValue("category", String.Empty),
                                Brand                  = reader.GetValue("Brand", String.Empty),
                                BrandType              = reader.GetValue("BrandType", String.Empty),
                                Code                   = reader.GetValue("Code", String.Empty),
                                Direction              = reader.GetValue("Direction", String.Empty),
                                Group                  = reader.GetValue("Group", String.Empty),
                                Provider               = reader.GetValue("Provider", String.Empty),
                                Size                   = reader.GetValue("Size", String.Empty),
                                SubCategory            = reader.GetValue("SubCategory", String.Empty),
                                IsArchived             = reader.GetValue("IsArchived", false),
                                RecommendedRetailPrice = reader.GetValue("RecommendedRetailPrice", 0m),
                                Id = Guid.NewGuid(),
                            });
                        }
                    }
                }

                if (pack.Count > 0)
                {
                    DBConnectionProvider.ExecuteNonQuery(String.Format("Update {1} Set Status = 3 Where ERPId in ({0})", String.Join(",", pack.Select(p => String.Format("'{0}'", p.CorrectERPId))), _tableName));
                }
            }

            return(pack);
        }
Пример #8
0
        public virtual void ProceedResult(PackResult result, List <BaseIntegrationObject> pack)
        {
            lock (_lockRes)
            {
                try
                {
                    var query = new StringBuilder();

                    if (result.IsSuccess)
                    {
                        foreach (var obj in pack)
                        {
                            query.AppendLine(String.Format("Update {1} Set Status = 1 Where ERPId = '{0}';", obj.CorrectERPId, _tableName));
                        }
                    }
                    else
                    {
                        var errorMessage = String.IsNullOrEmpty(result.ErrorMessage) ? String.Empty : result.ErrorMessage.Replace("'", "").Replace("{", "").Replace("}", "");
                        if (errorMessage.Length > 250)
                        {
                            errorMessage = errorMessage.Substring(0, 250);
                        }
                        foreach (var obj in pack)
                        {
                            query.AppendLine(String.Format("Update {2} Set Status = {3}, ErrorMessage = '{1}' Where ERPId = '{0}';", obj.CorrectERPId, errorMessage, _tableName, result.IsTimeout ? "4" : "2"));
                        }
                    }

                    var sql = query.ToString();
                    if (!string.IsNullOrEmpty(sql))
                    {
                        DBConnectionProvider.ExecuteNonQuery(sql);
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError(String.Format("Ошибка обновления состояний в ШТ {0} для первичного импорта", _tableName), e);
                }
            }
        }
Пример #9
0
        protected override List <BaseIntegrationObject> ReadPack()
        {
            var pack = new List <BaseIntegrationObject>();

            lock (_lock)
            {
                using (var provider = new DBConnectionProvider())
                {
                    using (var reader = provider.Execute(_selectQuery, packSize))
                    {
                        while (reader != null && reader.Read())
                        {
                            pack.Add(new Purchase()
                            {
                                Number       = reader.GetValue("Number", String.Empty),
                                ERPId        = reader.GetValue("ERPId", String.Empty),
                                CardNumber   = reader.GetValue("CardNumber", String.Empty),
                                Amount       = reader.GetValue("Amount", 0m),
                                CashDeskCode = reader.GetValue("CashDeskCode", String.Empty),
                                ContactId    = reader.GetValue("ContactId", String.Empty),
                                CreatedOn    = reader.GetValue("CreatedOn", String.Empty),
                                PaymentForm  = reader.GetValue("PaymentForm", String.Empty),
                                Phone        = reader.GetValue("Phone", String.Empty),
                                PurchaseDate = reader.GetValue("purchaseDateStr", String.Empty),
                                PDate        = reader.GetValue("purchaseDate", DateTime.MinValue),
                                ShopCode     = reader.GetValue("ShopCode", String.Empty),
                                Id           = Guid.NewGuid(),
                            });
                        }
                    }
                }

                if (pack.Count > 0)
                {
                    DBConnectionProvider.ExecuteNonQuery(String.Format("Update {1} Set Status = 3 Where ERPId in ({0})", String.Join(",", pack.Select(p => String.Format("'{0}'", p.CorrectERPId))), _tableName));
                }
            }

            return(pack);
        }
Пример #10
0
        protected override List <BaseIntegrationObject> ReadPack()
        {
            var pack = new List <BaseIntegrationObject>();

            lock (_lock)
            {
                using (var provider = new DBConnectionProvider())
                {
                    using (var reader = provider.Execute(_selectContact, packSize))
                    {
                        while (reader != null && reader.Read())
                        {
                            pack.Add(new Card()
                            {
                                ActivationDate = reader.GetValue("activationDate", String.Empty),
                                BlockedOn      = reader.GetValue("blockedOn", String.Empty),
                                BlockingReason = reader.GetValue("blockingReason", String.Empty),
                                CardStatus     = reader.GetValue("cardStatus", String.Empty),
                                ContactId      = reader.GetValue("contactId", String.Empty),
                                ErrorMessage   = reader.GetValue("errorMessage", String.Empty),
                                IsMain         = reader.GetValue("isMain", false),
                                Number         = reader.GetValue("number", String.Empty),
                                CreatedOn      = reader.GetValue("CreatedOn", String.Empty),
                                ERPId          = reader.GetValue("ERPId", String.Empty),
                                Id             = Guid.NewGuid()
                            });
                        }
                    }
                }

                if (pack.Count > 0)
                {
                    DBConnectionProvider.ExecuteNonQuery(String.Format("Update {1} Set Status = 3 Where ERPId in ({0})", String.Join(",", pack.Select(p => String.Format("'{0}'", p.CorrectERPId))), _tableName));
                }
            }

            return(pack);
        }