예제 #1
0
        public static void AddSaasDataToDB(SaasData saasData)
        {
            using (var db = new SQLDataAccess())
            {
                db.cmd.CommandText = "INSERT INTO [dbo].[SaasData] " +
                                     "(Name, ProductsCount, PhotosCount, HaveExcel, Have1C, HaveExportFeeds, HavePriceRegulating, HaveBankIntegration, IsWork, PaidTo, LastUpdate) VALUES " +
                                     "(@Name, @ProductsCount, @PhotosCount, @HaveExcel, @Have1C, @HaveExportFeeds, @HavePriceRegulating, @HaveBankIntegration, @IsWork, @PaidTo, GETDATE()) ";
                db.cmd.CommandType = CommandType.Text;
                db.cmd.Parameters.Clear();

                db.cmd.Parameters.AddWithValue("@Name", saasData.Name);
                db.cmd.Parameters.AddWithValue("@ProductsCount", saasData.ProductsCount);
                db.cmd.Parameters.AddWithValue("@PhotosCount ", saasData.PhotosCount);
                db.cmd.Parameters.AddWithValue("@HaveExcel", saasData.HaveExcel);
                db.cmd.Parameters.AddWithValue("@Have1C", saasData.Have1C);
                db.cmd.Parameters.AddWithValue("@HaveExportFeeds", saasData.HaveExportFeeds);
                db.cmd.Parameters.AddWithValue("@HavePriceRegulating", saasData.HavePriceRegulating);
                db.cmd.Parameters.AddWithValue("@HaveBankIntegration", saasData.HaveBankIntegration);
                db.cmd.Parameters.AddWithValue("@IsWork", saasData.IsWork);
                db.cmd.Parameters.AddWithValue("@PaidTo", saasData.PaidTo);

                db.cnOpen();
                db.cmd.ExecuteNonQuery();
                db.cnClose();
            }
        }
예제 #2
0
        public static SaasData GetSaasDataFromDB()
        {
            var saasData = new SaasData()
            {
                LastUpdate = DateTime.Now.AddDays(-2)
            };

            using (var db = new SQLDataAccess())
            {
                db.cmd.CommandText = "SELECT * FROM [dbo].[SaasData]";
                db.cmd.CommandType = CommandType.Text;
                db.cmd.Parameters.Clear();

                db.cnOpen();
                using (var reader = db.cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        saasData = GetSaasDataFromReader(reader);
                    }
                    reader.Close();
                }
                db.cnClose();
            }

            return(saasData);
        }
예제 #3
0
        public static SaasData GetSaasData(bool forceUpdate = false)
        {
            var saasDataDb = GetDbSaasdata();
            var saasData   = new SaasData(saasDataDb);

            SaasData saasDataNew = null;
            DateTime now         = DateTime.Now;

            if ((saasData.LastUpdate <= now) || !saasData.IsWorkingNow || forceUpdate)
            {
                saasDataNew = UpdateSaasDataFromService();
                if (saasDataNew != null)
                {
                    if (IsExistSingle(SaasDataTemplate.LastUpdate))
                    {
                        UpdateSingle(SaasDataTemplate.LastUpdate, now.AddMinutes(5).ToString(CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        AddSingle(SaasDataTemplate.LastUpdate, now.AddMinutes(5).ToString(CultureInfo.InvariantCulture));
                    }
                }
            }
            return(saasDataNew ?? saasData);
        }
예제 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (SaasDataService.IsSaasEnabled && (CustomerSession.CurrentCustomer.IsAdmin || CustomerSession.CurrentCustomer.IsVirtual))
     {
         MySaasData = SaasDataService.CurrentSaasData;
     }
     else
     {
         this.Visible = false;
     }
 }
예제 #5
0
        public static void UpdateSaasDataToDB(SaasData saasData)
        {
            using (var db = new SQLDataAccess())
            {
                db.cmd.CommandText = " UPDATE [dbo].[SaasData] SET Name = @Name, ProductsCount = @ProductsCount, PhotosCount = @PhotosCount, HaveExcel = @HaveExcel, Have1C = @Have1C, HaveExportFeeds = @HaveExportFeeds, HavePriceRegulating = @HavePriceRegulating, HaveBankIntegration = @HaveBankIntegration, IsWork = @IsWork, PaidTo = @PaidTo, LastUpdate = GETDATE()";
                db.cmd.CommandType = CommandType.Text;
                db.cmd.Parameters.Clear();

                db.cmd.Parameters.AddWithValue("@Name", saasData.Name);
                db.cmd.Parameters.AddWithValue("@ProductsCount", saasData.ProductsCount);
                db.cmd.Parameters.AddWithValue("@PhotosCount ", saasData.PhotosCount);
                db.cmd.Parameters.AddWithValue("@HaveExcel", saasData.HaveExcel);
                db.cmd.Parameters.AddWithValue("@Have1C", saasData.Have1C);
                db.cmd.Parameters.AddWithValue("@HaveExportFeeds", saasData.HaveExportFeeds);
                db.cmd.Parameters.AddWithValue("@HavePriceRegulating", saasData.HavePriceRegulating);
                db.cmd.Parameters.AddWithValue("@HaveBankIntegration", saasData.HaveBankIntegration);
                db.cmd.Parameters.AddWithValue("@IsWork", saasData.IsWork);
                db.cmd.Parameters.AddWithValue("@PaidTo", saasData.PaidTo);

                db.cnOpen();
                db.cmd.ExecuteNonQuery();
                db.cnClose();
            }
        }