Exemple #1
0
        public static void UpdateBillingPeriod(String CustId)
        {
            String couponid = null;
            double discount = 0;
            var    invoices = StripeHelper.GetInvoices(CustId);

            if (invoices != null)
            {
                foreach (var invoice in invoices)
                {
                    var startperiod     = invoice.StripeInvoiceLineItems.Data.First().StripePeriod.Start.Value.ToString();
                    var endperiod       = invoice.StripeInvoiceLineItems.Data.First().StripePeriod.End.Value.ToString();
                    var stripe_discount = invoice.StripeDiscount;
                    if (stripe_discount != null)
                    {
                        couponid = stripe_discount.StripeCoupon.Id;
                    }
                    var amount_off = (double)invoice.AmountDue / 100;
                    var total      = (double)invoice.Total / 100; //after discount
                    var amount     = ((double)invoice.StripeInvoiceLineItems.Data.First().Amount) / 100;
                    discount = Math.Round(amount - total, 2, MidpointRounding.AwayFromZero);
                    var paid = invoice.Paid;
                    ServicesData.UpdatePaymentStatus(CustId, amount, amount_off, couponid, discount, startperiod, endperiod, paid);
                }
            }
        }
        public async Task <IActionResult> Create([Bind("ID,Nombre,Descripcion,icon")] ServicesData servicesData)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(RedirectToAction(nameof(AccountController.Login), "Account"));
                // throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            if (ModelState.IsValid)
            {
                var notification = new Notifications();
                TempData["sms"]      = "Un nuevo servicio se ha publicado correctamente";
                ViewBag.sms          = TempData["sms"];
                notification.Detalle = ViewBag.sms;
                notification.Section = "Servicios";
                notification.Tipo    = "check";
                notification.Time    = DateTime.Now;
                notification         = _empleadosData.AddNotification(notification);
                _context.Add(servicesData);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(servicesData));
        }
        // GET: Services
        public ActionResult Service()
        {
            ServicesData serviceData = new ServicesData();

            serviceData.Services        = db.Services.ToList();
            serviceData.DepartmentsList = db.Departments.ToList();
            return(View(serviceData));
        }
Exemple #4
0
    private void OnApplicationPause(bool pause)
    {
        SaveObject saveObj = SaveManager.GetInstance().LoadPersistentData(SaveManager.SERVICES_PATH);

        if (saveObj != null)
        {
            ServicesData servData = saveObj.GetData <ServicesData>();
            servData.lastAccess = System.DateTime.Now;
            SaveManager.GetInstance().SavePersistentData(servData, SaveManager.SERVICES_PATH);
        }
    }
Exemple #5
0
        //Process once a day services
        public void Process_DailyService()
        {
            DataTable tbl = null;

            tbl = ServicesData.GetAllSellerIds();
            foreach (DataRow row in tbl.Rows)
            {
                String custmid = Convert.ToString(row["stp_custId"]);
                StripeServices.UpdateBillingPeriod(custmid);//when webhooks don't work
            }
            APIData.SetOldReportDatesData();
        }
        public ActionResult Service([Bind(Include = "Id,ServiceName,DepartmentId,CashPrice")] CaresoftHMISDataAccess.Service service)
        {
            service.DateAdded = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Services.Add(service);
                db.SaveChanges();
                return(RedirectToAction("Service"));
            }

            ServicesData serviceData = new ServicesData();

            serviceData.Services        = db.Services.ToList();
            serviceData.Service         = service;
            serviceData.DepartmentsList = db.Departments.ToList();
            return(View(serviceData));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Nombre,Descripcion,icon")] ServicesData servicesData)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(RedirectToAction(nameof(AccountController.Login), "Account"));
                // throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            if (id != servicesData.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(servicesData);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ServicesDataExists(servicesData.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                var notification = new Notifications();
                TempData["sms"]      = "Los cambios han sido guardados correctamente";
                ViewBag.sms          = TempData["sms"];
                notification.Detalle = ViewBag.sms;
                notification.Section = "Servicios";
                notification.Tipo    = "check";

                notification.Time = DateTime.Now;
                notification      = _empleadosData.AddNotification(notification);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(servicesData));
        }
        public async Task <IActionResult> Create([Bind("ID,Nombre,Descripcion,icon")] ServicesData servicesData)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(RedirectToAction(nameof(AccountController.Login), "Account"));
                // throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            if (ModelState.IsValid)
            {
                _context.Add(servicesData);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(servicesData));
        }
        public List <ServicesData> GetServiceData(DataTable excelDatatable, string machineName)
        {
            List <ServicesData> listServices = new List <ServicesData>();
            ServicesData        sd           = new ServicesData();

            for (int col = 2; col < excelDatatable.Columns.Count; col++)
            {
                DataColumn column = excelDatatable.Columns[col];
                if (!Convert.ToBoolean(Enum.Parse(typeof(YesNo), (excelDatatable.Rows[1][col].ToString()))))
                {
                    continue;
                }
                sd = new ServicesData();
                for (int row = 0; row < 2; row++)
                {
                    if (excelDatatable.Rows[row][col].ToString() != "")
                    {
                        sd.Service = column.ColumnName;
                        if (row == 0)
                        {
                            sd.ServiceName = excelDatatable.Rows[row][col].ToString();
                        }
                        if (row == 1)
                        {
                            sd.skipService = !Convert.ToBoolean(Enum.Parse(typeof(YesNo), (excelDatatable.Rows[row][col].ToString())));
                        }
                    }
                }

                int machineRowCounter = 2;
                for (int i = machineRowCounter; i < excelDatatable.Rows.Count; i++)
                {
                    // finding index of row of machine name
                    if (excelDatatable.Rows[i][0].ToString() == machineName)
                    {
                        machineRowCounter = i;
                    }
                }
                sd.ExpectedServiceStatus = excelDatatable.Rows[machineRowCounter][col].ToString();
                sd.MachineIp             = GetIpAddressFromMachineAddress(machineName);
                listServices.Add(sd);
            }
            return(listServices);
        }
Exemple #10
0
        public async Task <List <ServicesData> > GetDataServices()
        {
            var res = new List <ServicesData>();

            try
            {
                conn.ConnectionString = General.Configuration.ToString();
                using (var connection = conn)
                {
                    connection.Open();
                    string sql = "exec SP_GetDataServices";
                    using (var command = new SqlCommand(sql, connection))
                    {
                        command.CommandTimeout = 0;
                        using (var reader = await command.ExecuteReaderAsync())
                        {
                            while (reader.Read())
                            {
                                var            d     = new ServicesData();
                                Type           type  = d.GetType();
                                PropertyInfo[] props = type.GetProperties();
                                foreach (var p in props)
                                {
                                    if (null != p && p.CanWrite)
                                    {
                                        if (p.PropertyType.Name.ToString() != "IFormFile" && p.Name != "Result")
                                        {
                                            p.SetValue(d, reader[p.Name].ToString(), null);
                                        }
                                    }
                                }
                                res.Add(d);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(res);
        }
        public void FillServicesData(WorkerStatistic someWorkerStatistic)
        {
            // someWorkerStatistic.ServiceData = new List<WorkerStatistic.ServicesData>();

            IEnumerable <ServiceType> providedServiceTypes = db.ServiceTypes.Where(m => m.ProvidedServices.Where(n => n.ValueSet.HasValue).Where(n => n.WorkerId == someWorkerStatistic.Worker.Id).Any()).OrderBy(m => m.Id);

            foreach (ServiceType item in providedServiceTypes)
            {
                ServicesData someServiceData = new ServicesData(item);

                someServiceData.ServicesToClients = item.ProvidedServices.Where(n => n.ValueSet.HasValue).Where(n => n.WorkerId == someWorkerStatistic.Worker.Id).ToList();

                /*
                 * OneServiceData someOneServiceDate = new OneServiceData();
                 *
                 * someOneServiceDate.PositiveServices = db.ServiceToClients.Where(m => m.WorkerId == someWorkerStatistic.Worker.Id).Where(m => m.ServiceTypeId == item.Id).Where(m => m.Value == 1);
                 * someOneServiceDate.NegativeServices = db.ServiceToClients.Where(m => m.WorkerId == someWorkerStatistic.Worker.Id).Where(m => m.ServiceTypeId == item.Id).Where(m => m.Value == -1);
                 * someOneServiceDate.UnknownServices = db.ServiceToClients.Where(m => m.WorkerId == someWorkerStatistic.Worker.Id).Where(m => m.ServiceTypeId == item.Id).Where(m => m.ValueSet == null);
                 *
                 */
                someWorkerStatistic.ServiceData.Add(someServiceData);
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Nombre,Descripcion,icon")] ServicesData servicesData)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(RedirectToAction(nameof(AccountController.Login), "Account"));
                // throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            if (id != servicesData.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(servicesData);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ServicesDataExists(servicesData.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(servicesData));
        }
Exemple #13
0
        //All Services
        public void Process_AllServices()
        {
            DataTable dtbl = null, dtbl1 = null, dtbl2 = null;
            DataSet   ds    = null;
            var       sdata = new SellerData();

            dtbl = sdata.GetUserStatus();
            if (dtbl.Rows.Count > 0)
            {
                foreach (DataRow rw in dtbl.Rows)
                {
                    bool   subscription = false;
                    int    UserId       = Convert.ToInt32(rw["MppUserID"]);
                    String CustmID      = Convert.ToString(rw["stp_custId"]);
                    if (!String.IsNullOrWhiteSpace(CustmID))
                    {
                        subscription = StripeHelper.UnSubscribe(CustmID);    //unsubscribe the users either whose status is 2 or active with no card
                    }
                    if (subscription)
                    {
                        ServicesData.UpdatePlanData(UserId, 0);
                    }
                }
            }

            ds    = sdata.GetUserEmails();
            dtbl1 = ds.Tables[0];
            dtbl2 = ds.Tables[1];

            if (dtbl1.Rows.Count > 0)
            {
                DataTable tbl = new DataTable();
                tbl.Columns.AddRange(new DataColumn[2] {
                    new DataColumn("MppUserId", typeof(Int32)),
                    new DataColumn("Limit", typeof(Int32))
                });

                //Using Parallel Multi-Threading to send multiple bulk email.
                Parallel.ForEach(dtbl1.AsEnumerable(), row =>
                {
                    String msg = "";

                    Int32 Limit  = Convert.ToInt32(row["accesslimit"]);
                    Int32 UserID = Convert.ToInt32(row["MppUserID"]);
                    msg          = alert.SendNewUserAccessAlert(row["Email"].ToString(), row["FirstName"].ToString(), row["LastName"].ToString());
                    if (msg == "")
                    {
                        tbl.Rows.Add();
                        tbl.Rows[tbl.Rows.Count - 1][0] = UserID;
                        switch (Limit)
                        {
                        case 1:
                            Limit = 2;
                            break;

                        case 2:
                            Limit = 3;
                            break;

                        default:
                            Limit = 0;
                            break;
                        }
                        tbl.Rows[tbl.Rows.Count - 1][1] = Limit;
                    }
                });
                if (tbl.Rows.Count > 0)
                {
                    sdata.UpdateUserAccessLimit(tbl);
                }
            }

            if (dtbl2.Rows.Count > 0)
            {
                DataTable tbl1 = new DataTable();
                DataTable tbl2 = new DataTable();
                tbl1.Columns.AddRange(new DataColumn[2] {
                    new DataColumn("UserID", typeof(Int32)),
                    new DataColumn("Status", typeof(Int32))
                });
                tbl2.Columns.AddRange(new DataColumn[2] {
                    new DataColumn("UserID", typeof(Int32)),
                    new DataColumn("Status", typeof(Int32))
                });

                //Using Parallel Multi-Threading to send multiple bulk email.
                Parallel.ForEach(dtbl2.AsEnumerable(), row =>
                {
                    String msg            = "";
                    Int32 UserID          = Convert.ToInt32(row["MppUserID"]);
                    String FirstName      = Convert.ToString(row["FirstName"]);
                    String LastName       = Convert.ToString(row["LastName"]);
                    String Email          = Convert.ToString(row["Email"]);
                    DateTime TrialEndDate = Convert.ToDateTime(row["TrailEndDate"]);
                    msg = alert.SendTrialExpiresAlert(Email, TrialEndDate, FirstName, LastName);
                    if (msg == "")
                    {
                        if (TrialEndDate < DateTime.Now)
                        {
                            tbl2.Rows.Add();
                            tbl2.Rows[tbl2.Rows.Count - 1][0] = UserID;
                            tbl2.Rows[tbl2.Rows.Count - 1][1] = 1;
                        }
                        else
                        {
                            tbl1.Rows.Add();
                            tbl1.Rows[tbl1.Rows.Count - 1][0] = UserID;
                            tbl1.Rows[tbl1.Rows.Count - 1][1] = 1;
                        }
                    }
                });
                if (tbl1.Rows.Count > 0)
                {
                    sdata.UpdateSevenTrialEmailStatus(tbl1);
                }
                if (tbl2.Rows.Count > 0)
                {
                    sdata.UpdateTrialEndEmailStatus(tbl2);
                }
            }

            StripeServices.RenewPlan();
        }
Exemple #14
0
        public static void RenewPlan()
        {
            int UserId = 0;

            try
            {
                var subs = ServicesData.GetSubscribers();
                int plan;
                if (subs.Rows.Count > 0)
                {
                    foreach (DataRow row in subs.Rows)
                    {
                        String msg        = "";
                        String CustomerId = row["stp_custId"].ToString();
                        String CardId     = row["stp_cardId"].ToString();
                        UserId = Convert.ToInt32(row["MppUserID"]);

                        if (!String.IsNullOrWhiteSpace(CustomerId) && !String.IsNullOrWhiteSpace(CardId))
                        {
                            var profile = APIData.GetUserProfileForSkuData(UserId);

                            if (profile.Rows.Count > 0)
                            {
                                DataRow  dr            = profile.Rows[0];
                                String   ProfileId     = Convert.ToString(dr["ProfileId"]);
                                DateTime LastUpdatedOn = Convert.ToDateTime(dr["AccessTokenUpdatedOn"]);

                                var Auth = new AuthorizationModel()
                                {
                                    access_token  = Convert.ToString(dr["AccessToken"]),
                                    refresh_token = Convert.ToString(dr["RefreshToken"]),
                                    token_type    = Convert.ToString(dr["TokenType"]),
                                    expires_in    = Convert.ToInt32(dr["TokenExpiresIn"])
                                };
                                var reportApi = new ReportsAPI();
                                var skuCount  = AccountData.UserSkuCount(UserId);
                                if (String.IsNullOrWhiteSpace(msg))
                                {
                                    if (skuCount > 250)
                                    {
                                        plan = GetCustomPlan(skuCount);
                                    }
                                    else
                                    {
                                        plan = GetPlanBySku(skuCount);
                                    }
                                    var subsPlan   = new StripeSubscription();
                                    var subService = StripeHelper.GetSubscription(CustomerId);
                                    if (subService != null)
                                    {
                                        subsPlan = StripeHelper.UpdateSubscription(CustomerId, subService.Id, new Stripe.StripeSubscriptionUpdateOptions {
                                            PlanId = plan.ToString(), Prorate = false
                                        }, out msg);
                                    }
                                    else
                                    {
                                        subsPlan = StripeHelper.Subscription(CustomerId, new Stripe.StripeSubscriptionCreateOptions {
                                            PlanId = plan.ToString()
                                        }, out msg);
                                    }
                                    if (String.IsNullOrWhiteSpace(msg))
                                    {
                                        UpdateUserInfo userInfo = new UpdateUserInfo
                                        {
                                            Amount        = ((double)(subsPlan.StripePlan.Amount) / 100).ToString(),
                                            CardId        = CardId,
                                            CustId        = CustomerId,
                                            UserId        = UserId,
                                            PlanId        = plan,
                                            EndedAt       = subsPlan.CurrentPeriodEnd.ToString(),
                                            PlanStartDate = subsPlan.CurrentPeriodStart.ToString(),
                                            PlanEndDate   = subsPlan.CurrentPeriodEnd.ToString(),
                                            TrialEndDate  = row["TrailEndDate"].ToString()
                                        };
                                        ServicesData.UpdateStripeData(userInfo);
                                    }
                                    else
                                    {
                                        LogAPI.WriteLog("RenewPlan - " + msg, UserId.ToString());
                                    }
                                }
                                else
                                {
                                    LogAPI.WriteLog("RenewPlan - " + msg, UserId.ToString());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogAPI.WriteLog("RenewPlan - " + ex.Message, UserId.ToString());
            }
        }
Exemple #15
0
    private void InitializeData()
    {
        SaveObject objectData;

        //SETTINGS DATA
        objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.SETTINGS_PATH);
        if (objectData == null)
        {
            settingsData = SaveManager.GetInstance().SavePersistentData(new SettingsData(), SaveManager.SETTINGS_PATH).GetData <SettingsData>();
        }
        else
        {
            settingsData = objectData.GetData <SettingsData>();
        }
        SharedUtilities.GetInstance().SetQualitySettings(settingsData.qualityLevel);


        //PLAYER DATA
        objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.PLAYER_DATA);
        if (objectData == null)
        {
            objectData = SaveManager.GetInstance().SavePersistentData(new PlayerData(), SaveManager.PLAYER_DATA);
        }
        PlayerData playerData = objectData.GetData <PlayerData>();

        playerData.InitializeMissingData();
        levelText.text      = playerData.playerLevel.ToString("0");
        currentExpText.text = playerData.currentExp.ToString("0");
        int expNeeded = playerData.GetLevelExpNeeded();

        expNeededText.text  = expNeeded.ToString("0");
        levelBar.fillAmount = playerData.currentExp / (float)expNeeded;
        GameObject eff = GetLevelEffect(playerData.playerLevel);

        if (eff != null)
        {
            instantiatedEff = Instantiate(eff, playerLevelTransform);
            instantiatedEff.transform.localScale    = new Vector3(1, 1, 1);
            instantiatedEff.transform.localPosition = new Vector3(0, 40, 0);
        }
        SaveManager.GetInstance().SavePersistentData(playerData, SaveManager.PLAYER_DATA);


        //SKILLS DATA
        objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.SKILLSDATA_PATH);
        if (objectData == null)
        {
            objectData = SaveManager.GetInstance().SavePersistentData(new PlayerSkillsData(), SaveManager.SKILLSDATA_PATH);
        }
        PlayerSkillsData skillData = objectData.GetData <PlayerSkillsData>();

        skillData.InitializeMissingData();
        SaveManager.GetInstance().SavePersistentData(skillData, SaveManager.SKILLSDATA_PATH);


        //ACHIEVEMENTS
        objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.ACHIEVMENTS_PATH);
        if (objectData == null)
        {
            SaveManager.GetInstance().SavePersistentData(new PlayerAchievementsData(), SaveManager.ACHIEVMENTS_PATH);
        }


        //LEVELS DATA
        objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.LEVELSDATA_PATH);
        if (objectData == null)
        {
            objectData = SaveManager.GetInstance().SavePersistentData <LevelsData>(new LevelsData(), SaveManager.LEVELSDATA_PATH);
        }
        LevelsData data = objectData.GetData <LevelsData>();

        data.InitializeMissingData();
        SaveManager.GetInstance().SavePersistentData(data, SaveManager.LEVELSDATA_PATH);
        highScoreText.text = data.GetLevelHighScore(LevelsData.ENDLESS_ID).ToString();


        //CURRENCY DATA
        SaveObject currencyObj = SaveManager.GetInstance().LoadPersistentData(SaveManager.CURRENCY_PATH);

        if (currencyObj == null)
        {
            currencyObj = SaveManager.GetInstance().SavePersistentData <CurrencyData>(new CurrencyData(), SaveManager.CURRENCY_PATH);
        }
        currencyData = currencyObj.GetData <CurrencyData>();
        currencyData.InitializeMissingData();

        int currentGP = 0;

        objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.GRAVITYPOINTS_PATH);
        if (objectData != null)
        {
            currentGP = objectData.GetData <int>();
            currencyData.gravityPoints = currentGP;
        }
        SaveManager.GetInstance().SavePersistentData <CurrencyData>(currencyData, SaveManager.CURRENCY_PATH);
        SaveManager.GetInstance().DeleteData(SaveManager.GRAVITYPOINTS_PATH);
        gravityPointsText.text = currencyData.gravityPoints.ToString();
        gravitonsText.text     = currencyData.gravitons.ToString();

        //ASPECT DATA
        objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.ASPECTDATA_PATH);
        if (objectData == null)
        {
            objectData = SaveManager.GetInstance().SavePersistentData(new PlayerAspectData(), SaveManager.ASPECTDATA_PATH);
        }
        aspectData = objectData.GetData <PlayerAspectData>();
        aspectData.InitializeMissingData();
        SaveManager.GetInstance().SavePersistentData(aspectData, SaveManager.ASPECTDATA_PATH);

        //SERVICES DATA
        objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.SERVICES_PATH);
        if (objectData == null)
        {
            objectData = SaveManager.GetInstance().SavePersistentData(new ServicesData(), SaveManager.SERVICES_PATH);
        }
        servData = objectData.GetData <ServicesData>();
        servData.InitializeMissingData();
        SaveManager.GetInstance().SavePersistentData(servData, SaveManager.SERVICES_PATH);
    }