Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        public static IDBServer FromConnectionString(string connectionString)
        {
            var connProvider = new DBConnectionProvider(connectionString, () => new SQLiteConnection(connectionString));
            var dbAccess     = new SQLiteDatabaseAccess(connProvider);
            var version      =
                connProvider.PerformFunc(conn => conn.ExecuteScalar <string>("SELECT sqlite_version();"));

            return(new DBServer(dbAccess, version));
        }
Exemplo n.º 5
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"));
        }
Exemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            IConfigurationSection configSection = Configuration.GetSection("ServiceConfig");

            ServiceConfigInfo.Init(configSection["consul"], configSection["configKey"], configSection["ip"], Convert.ToInt32(configSection["httpPort"]));

            services.AddGalaxyAuth("ShopInfoManage");
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddCors(options =>
            {
                options.AddPolicy("any", builder =>
                {
                    builder
                    .WithOrigins("*")
                    .AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader();
                });
            });

            services.Configure <MvcOptions>(options =>
            {
                options.Filters.Add(new CorsAuthorizationFilterFactory("any"));
            });

            new AutoMapperInit().Init();

            DBConnectionProvider.Config(ServiceConfigInfo.Single.DBConfig.Server,
                                        ServiceConfigInfo.Single.DBConfig.Port,
                                        ServiceConfigInfo.Single.DBConfig.DBName,
                                        ServiceConfigInfo.Single.DBConfig.User,
                                        ServiceConfigInfo.Single.DBConfig.Password);
            CSRedisInitHelper.Init(ServiceConfigInfo.Single.RedisConfig.Server, System.Convert.ToInt32(ServiceConfigInfo.Single.RedisConfig.Port));

            //注册Swagger生成器,定义一个和多个Swagger 文档
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "ShopInfoServiceAPI", Version = "v1"
                });
                c.SwaggerDoc("v2", new Info {
                    Title = "ShopInfoServiceAPI_2", Version = "v2"
                });
                c.IncludeXmlComments(AppDomain.CurrentDomain.BaseDirectory + "/Galaxy.Taurus.ShopInfoAPI.xml");
            });

            DependencyRegister dependencyRegister = new DependencyRegister();

            ApplicationContainer = dependencyRegister.RegisterWeb(services);
            return(new AutofacServiceProvider(ApplicationContainer));//第三方IOC接管 core内置DI容器
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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());
        }
Exemplo n.º 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 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);
        }
Exemplo n.º 10
0
        private List <PaymentInPurchase> ReadPayments(string erpId)
        {
            var res = new List <PaymentInPurchase>();

            using (var provider = new DBConnectionProvider())
            {
                using (var reader = provider.Execute(@"Select Type, Amount from PaymentsInPurchaseGate WITH(NOLOCK) Where PurchaseId = '{0}'", erpId))
                {
                    while (reader != null && reader.Read())
                    {
                        res.Add(new PaymentInPurchase()
                        {
                            Amount = reader.GetValue("Amount", 0m),
                            Type   = reader.GetValue("Type", String.Empty),
                        });
                    }
                }
            }

            return(res);
        }
Exemplo n.º 11
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);
                }
            }
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        private List <ProductInPurchase> ReadProducts(string erpId)
        {
            var res = new List <ProductInPurchase>();

            using (var provider = new DBConnectionProvider())
            {
                using (var reader = provider.Execute(@"Select ProductCode, Price, Quantity, Amount from ProductsInPurchaseGate WITH(NOLOCK) Where PurchaseId = '{0}'", erpId))
                {
                    while (reader != null && reader.Read())
                    {
                        res.Add(new ProductInPurchase()
                        {
                            Amount      = reader.GetValue("Amount", 0m),
                            Price       = reader.GetValue("Price", 0m),
                            Quantity    = reader.GetValue("Quantity", 0),
                            ProductCode = reader.GetValue("ProductCode", String.Empty),
                        });
                    }
                }
            }

            return(res);
        }