Ejemplo n.º 1
0
    public virtual void Shoot(float delta)
    {
        if (timeBetweenShots <= 0)
        {
            if (enemyBulletScene != null)
            {
                var bulletRoot = enemyBulletScene.Instance();
                var bullet     = bulletRoot.GetNode <BulletComponent>("BulletComponent");

                float rotationDegrees = Utlities.LookAtSomething(player.Position, GlobalPosition);
                Utlities.SetNode2DParams(ref bullet, GlobalPosition, rotationDegrees);

                GetTree().CurrentScene.AddChild(bulletRoot);
                timeBetweenShots = startTimeBetweenShots;
            }
            else
            {
                return;
            }
        }
        else
        {
            timeBetweenShots -= delta;
        }
    }
Ejemplo n.º 2
0
    public override void Shoot(float delta)
    {
        List <Node> bullets = new List <Node>();

        if (timeBetweenShots <= 0)
        {
            for (int i = 0; i < maxBullets; i++)
            {
                var bulletRoot = enemyBulletScene.Instance();
                bullets.Add(bulletRoot);

                float rotationDegrees = Utlities.LookAtSomething(player.Position, GlobalPosition) + (45 * i);
                var   bullet          = bullets[i].GetNode <Node2D>("BulletComponent");

                Utlities.SetNode2DParams(ref bullet, GlobalPosition, rotationDegrees);

                GetTree().CurrentScene.AddChild(bullets[i]);
            }

            timeBetweenShots = startTimeBetweenShots;
            bullets.Clear();
        }
        else
        {
            timeBetweenShots -= delta;
        }
    }
Ejemplo n.º 3
0
    public override void Shoot(Vector2 lookDir, float delta)
    {
        List <ShotgunShell> bullets = new List <ShotgunShell>();

        if (timeBetweenShots <= 0)
        {
            if (Input.IsActionPressed("Shoot"))
            {
                for (int i = 0; i < maxBullets; i++)
                {
                    var bulletRoot = bulletScene.Instance() as ShotgunShell;
                    bullets.Add(bulletRoot);
                }

                for (int i = 0; i < bullets.Count; i++)
                {
                    float rotationDegrees = Utlities.LookAtSomething(GetGlobalMousePosition(), GlobalPosition) + (20 * i);
                    var   bullet          = bullets[i].GetNode <BulletComponent>("BulletComponent");

                    Utlities.SetNode2DParams(ref bullet, firepoint.GlobalPosition, rotationDegrees);

                    GetTree().CurrentScene.AddChild(bullets[i]);
                }

                timeBetweenShots = startTimeBetweenShots;
                bullets.Clear();
            }
        }
        else
        {
            timeBetweenShots -= delta;
        }
    }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(int RoomID, DateTime CheckInDate, DateTime CheckOutDate, Guest guest, Payment payment, int Amount)
        {
            int guestid   = GuestDAO.InsertGuest(guest);
            int paymentid = PaymentDAO.InsertPayment(payment);
            int bookingid = BookingDAO.InsertBooking(new Booking()
            {
                RoomID       = RoomID,
                CheckInDate  = CheckInDate.AddHours(14),
                CheckOutDate = CheckOutDate.AddHours(12).AddMinutes(5),
                GuestID      = guestid,
                Amount       = (int)(CheckOutDate - CheckInDate).TotalDays * RoomsDAO.GetRoomModel(RoomID).RoomType.Price,
                PaymentID    = paymentid,
            });

            var    model = BookingDAO.GetBookingModel(bookingid);
            string body  = await Utlities.RenderViewToStringAsync <BookingModel>(this, "~/Areas/Guests/Views/Partial/_ConfirmEmail.cshtml", model);

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("*****@*****.**");
            mail.To.Add(guest.Email);
            mail.Subject    = "Congratulations on your successful booking";
            mail.Body       = body;
            mail.IsBodyHtml = true;

            Utlities.SendEmail(mail);

            return(View());
        }
Ejemplo n.º 5
0
        public string AttackRequst(FormCollection collection)
        {
            string id = Request.Form["PlayerId"];
            PlayerForDataBase thisPlayerData = dataBase.PlayerinDataBase.Find(id);
            thisPlayerData.UpdatePropertyByTime();
            if(0 < thisPlayerData.remaningTimeToNextAttack)
            {
                return false.ToString();
            }

            string enemyId = new PlayerListManager().NextIdForAtack(id);
            if (enemyId != null)
            {
                //Theif2dDataDBContext dataBase = new Theif2dDataDBContext();
                PlayerForDataBase PlayerData = dataBase.PlayerinDataBase.Find(enemyId);
                if(PlayerData != null)
                {
                    PlayerForSerialize playerDataForSerialize = new Utlities().ConvertBuildingDataBaseToSerialize(PlayerData);
                    LogSystem.AddPlayerLog(id, "player" + id.ToString() + " attacked " + PlayerData.ID + " ID");
                    string uu = new JavaScriptSerializer().Serialize(playerDataForSerialize);
                    return uu;
                }
                return false.ToString();
            }
            else
            {
                return false.ToString();
            }
        }
Ejemplo n.º 6
0
        public string LoadPlayerData2(FormCollection collection)
        {
            string id                  = Request.Form["PlayerId"];
            string Shipname            = Request.Form["Shipname"];
            string Password            = Request.Form["Password"];
            string PasswordForCreation = "11111";
            string PasswordForEdit     = "11111";

            new Theif2dDataDBContext().LoadForFisttimeIfNessecary();
            if (Shipname == "PlayerShip")
            {
                ShipForDataBase findedShip = dataBase.AllShips.Find(id);
                if (findedShip == null)
                {
                    AddNew.WaitOne();
                    findedShip = new Utlities().returnDefultShip();
                    //AllShips.buildingCode = dataBase.ShipBaseDataBase.Find(1).BaseString;
                    string ss    = new Random().NextDouble().ToString();
                    int    index = dataBase.PlayerinDataBase.Count <PlayerForDataBase>() + 1;
                    findedShip.OwnerID = index.ToString() + ss;
                    dataBase.AllShips.Add(findedShip);
                    dataBase.SaveChanges();
                    AddNew.ReleaseMutex();
                    // new PlayerListManager().AddPlayerInfo(PlayerData);
                }
                else
                {
                    findedShip.UpdatePropertyByTime();
                    dataBase.Entry(findedShip).State = EntityState.Modified;
                    dataBase.SaveChanges();
                    // new PlayerListManager().UpdatePlayerInfo(PlayerData);
                }
                LogSystem.AddPlayerLog(findedShip.OwnerID, "Ship" + findedShip.OwnerID.ToString() + " added ");
                ShipForSerialize fors = new ShipForSerialize();
                fors.SetAccordingTodataBAse(findedShip);
                string uu = new JavaScriptSerializer().Serialize(fors);
                return(uu);
            }
            else
            {
                string          code       = Shipname + Password;
                ShipForDataBase findedShip = dataBase.AllShips.Find(code);
                if (findedShip == null)
                {
                    if (Password == PasswordForCreation)
                    {
                        return("UnderConstuction");
                    }
                    else
                    {
                        return("shipNotFinded  & CreationPaswordIsWrong");
                    }
                }
                else
                {
                    return("UnderConstuction");
                }
            }
        }
Ejemplo n.º 7
0
    public override void UnEquip()
    {
        inventory.RemoveItemFromInventory(this);
        var shotgun = weaponScene.Instance() as Shotgun;

        shotgun.Position        = GetTree().CurrentScene.GetNode <Player>("Player").Position;
        shotgun.RotationDegrees = Utlities.LookAtMouse(GetGlobalMousePosition(), shotgun.Position);

        GetTree().CurrentScene.AddChild(shotgun);
    }
Ejemplo n.º 8
0
    public override void UnEquip()
    {
        inventory.RemoveItemFromInventory(this);
        var rocketLauncher = weaponScene.Instance() as RocketLauncher;

        rocketLauncher.Position        = GetTree().CurrentScene.GetNode <Player>("Player").Position;
        rocketLauncher.RotationDegrees = Utlities.LookAtMouse(GetGlobalMousePosition(), rocketLauncher.Position);

        GetTree().CurrentScene.AddChild(rocketLauncher);
    }
Ejemplo n.º 9
0
    public override void _Ready()
    {
        player = GetTree().CurrentScene.GetNode <Player>("Player");
        sprite = GetNode <Sprite>("EnemySprite");

        GlobalPosition   = Utlities.RandPosition(new Vector2(320f, 180f), GetTree());
        timeBetweenShots = startTimeBetweenShots;

        Connect("SEnemyDied", GetTree().CurrentScene, "OnEnemyDied");
        Connect("SSpawnPoints", GetTree().CurrentScene, "SpawnPoints");
    }
Ejemplo n.º 10
0
        public static string AddSubscribersToTracking(int cid, string userID)
        {
            subIDs = M_Campaigns.GetSubscribersForCampaign(cid);
            string id = Guid.NewGuid().ToString();

            if (subIDs.Count != 0)
            {
                using (dbcontext = new ApplicationDbContext())
                {
                    try
                    {
                        foreach (var item in subIDs)
                        {
                            track                      = new M_Tracking();
                            track.CampId               = cid;
                            track.SubsciberId          = item;
                            track.IsOpened             = false;
                            track.IdentifierSubscriber = Guid.NewGuid().ToString();
                            track.IdentifierCampaign   = id;
                            track.MailStatus           = false;
                            track.UserID               = userID;
                            dbcontext.M_Trackings.Add(track);
                            dbcontext.SaveChanges();
                        }
                    }
                    catch (SqlException ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber);
                        obj.LogException();
                        throw obj;
                    }
                    catch (InvalidOperationException ex) {
                        obj = new M_CustomException((int)ErorrTypes.InvalidOperation, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                        obj.LogException();
                        throw obj;
                    }
                    catch (ArgumentNullException ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.ArgumentNullExceptions, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                        obj.LogException();
                        throw obj;
                    }
                    catch (Exception ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                        obj.LogException();
                        throw obj;
                    }
                }
            }
            return(track.IdentifierCampaign);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Update list to database
 /// </summary>
 /// <returns>true or false</returns>
 public bool UpdateList()
 {
     this.LastUpdated = DateTime.Now;
     using (dbcontext = new ApplicationDbContext())
     {
         try
         {
             dbcontext.Entry(this).State = System.Data.Entity.EntityState.Modified;
             dbcontext.SaveChanges();
         }
         catch (SqlException ex)
         {
             obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber);
             obj.LogException();
             throw obj;
         }
         catch (Exception ex)
         {
             obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
             obj.LogException();
             throw obj;
         }
     }
     return(true);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Gets list information to be edited
 /// </summary>
 /// <param name="listID"></param>
 /// <returns>List obejct</returns>
 public M_List EditList(int?listID)
 {
     newList = new M_List();
     using (dbcontext = new ApplicationDbContext())
     {
         try
         {
             newList = dbcontext.M_Lists.Find(listID);
         }
         catch (SqlException ex)
         {
             obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber);
             obj.LogException();
             throw obj;
         }
         catch (Exception ex)
         {
             obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
             obj.LogException();
             throw obj;
         }
     }
     return(newList);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Get lists to display for user
        /// </summary>
        /// <param name="userID"></param>
        /// <returns>return list view model which contains list information and count of its subcribers and unsubscribers</returns>
        public ListViewModel ViewList(string userID)
        {
            // NewList lst = null;
            //listIds = new List<int?>();
            // listIds = GetListIds(userID);
            using (dbcontext = new ApplicationDbContext())
            {
                try
                {
                    LVmodel.lists = (from list in dbcontext.M_Lists
                                     join users in dbcontext.UsersList
                                     on list.ListID equals users.ListID
                                     where users.UsersID == userID
                                     select list).ToList();

                    foreach (var i in LVmodel.lists)
                    {
                        //int cnt = (from list in LVmodel.lists
                        //           join sub in dbcontext.Subscribers
                        //           on list.ListID equals sub.ListID
                        //           where sub.ListID == i.ListID
                        //           select sub).Count();
                        int cnt = (from list in LVmodel.lists
                                   join sub in dbcontext.ListSusbscribers
                                   on list.ListID equals sub.ListID
                                   where sub.ListID == i.ListID
                                   select list).Count();
                        LVmodel.NoOfSubscribers.Add(cnt);
                    }

                    //foreach (var item in listIds)
                    //{
                    //    lst = new NewList();
                    //    lst = dbcontext.NewLists.Where(u => u.ListID == item).FirstOrDefault();
                    //    LVmodel.lists.Add(lst);
                    //    var cnt = dbcontext.Subscribers.Where(l => l.ListID == item && l.Unsubscribe == false).Count();
                    //    LVmodel.NoOfSubscribers.Add(cnt);
                    //}
                }
                catch (SqlException ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber);
                    obj.LogException();
                    throw obj;
                }
                catch (Exception ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                    obj.LogException();
                    throw obj;
                }
            }
            return(LVmodel);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Get subscriber to be edited
        /// </summary>
        /// <param name="sid"></param>
        /// <returns></returns>
        public M_Subscriber Edit(int?sid)
        {
            if (sid != null)
            {
                using (dbcontext = new ApplicationDbContext())
                {
                    try
                    {
                        subscriber = dbcontext.M_Subscribers.Find(sid);
                    }
                    catch (SqlException ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.SqlExceptions, "Problem in saving data", ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                        obj.LogException();
                        throw obj;
                    }
                    catch (Exception ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.others, "Some problem occured while processing request", ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                        obj.LogException();
                        throw obj;
                    }
                }
            }
            return(subscriber);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// collection of emailaddress for peticular list
        /// </summary>
        /// <param name="userID">collection of list ids for perticular user</param>
        /// <returns></returns>
        public List <string> getSubscribers(string userID)
        {
            subscriberEmail = new List <string>();
            listIds         = new List <int?>();
            listIds         = M_List.GetListIds(userID);
            using (dbcontext = new ApplicationDbContext())
            {
                foreach (var item in listIds)
                {
                    try
                    {
                        subscriberEmail.Add(dbcontext.M_Subscribers.Where(l => l.ListID == item).Select(s => s.EmailAddress).FirstOrDefault());
                    }
                    catch (SqlException ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.SqlExceptions, ex.Message, ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                        obj.LogException();
                        throw obj;
                    }
                    catch (Exception ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                        obj.LogException();
                        throw obj;
                    }
                }
            }
            return(subscriberEmail);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Save the subscriber with thier status , so that the Windows service can send mail to user
 /// </summary>
 /// <param name="usrId"></param>
 /// <param name="campId"></param>
 /// <param name="listId"></param>
 /// <param name="subId"></param>
 public void settingMail(string usrId, int campId, int listId, int subId)
 {
     dbContext         = new ApplicationDbContext();
     this.UserId       = usrId;
     this.CampId       = campId;
     this.ListId       = listId;
     this.StatusId     = 4;
     this.SubscriberId = subId;
     try
     {
         dbContext.M_MailStatus.Add(this);
         dbContext.SaveChanges();
     }
     catch (SqlException ex)
     {
         obj = new M_CustomException((int)ErorrTypes.SqlExceptions, "Problem in saving data", ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), UserId, Utlities.GetURL(), ex.LineNumber);
         obj.LogException();
         throw obj;
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Save subscriber to database
        /// </summary>
        /// <param name="listID">list from which subscriber belogs</param>
        /// <param name="userID"></param>
        public void saveSubscriber(string userID)
        {
            ListSusbscriber lSub = new ListSusbscriber();

            if (isSubscriberExist(this.EmailAddress, this.ListID, userID) == false)
            {
                lSub.ListID = this.ListID;
                // this.StatusID = 3;
                this.AddedDate = DateTime.Now;
                using (dbcontext = new ApplicationDbContext())
                {
                    using (var trans = dbcontext.Database.BeginTransaction())
                    {
                        //Subscriber not present in list
                        try
                        {
                            dbcontext.M_Subscribers.Add(this);
                            dbcontext.SaveChanges();
                            lSub.SubscribersID = this.SubscriberID;
                            dbcontext.ListSusbscribers.Add(lSub);
                            dbcontext.SaveChanges();
                            trans.Commit();
                        }
                        catch (SqlException ex)
                        {
                            //failed to save in subscriber or listsubscriber,clear model ans add model error
                            trans.Rollback();
                            obj = new M_CustomException((int)ErorrTypes.SqlExceptions, "Problem in saving data", ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                            obj.LogException();
                            throw obj;
                        }
                        catch (Exception ex)
                        {
                            trans.Rollback();
                            obj = new M_CustomException((int)ErorrTypes.others, "Some problem occured while processing request", ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                            obj.LogException();
                            throw obj;
                        }
                    }
                }
            }
            else
            {
                //Subscriber already present in list,clear model ans add model error
            }
        }
Ejemplo n.º 18
0
        public static bool Unsub(string subid)
        {
            using (dbcontext = new ApplicationDbContext())
            {
                subscriber = new M_Subscriber();
                int?id;
                if (subid != null)
                {
                    try
                    {
                        id                     = dbcontext.M_Trackings.Where(t => t.IdentifierSubscriber == subid).Select(t => t.SubsciberId).FirstOrDefault();
                        subscriber             = dbcontext.M_Subscribers.Find(id);
                        subscriber.Unsubscribe = true;
                        dbcontext.M_Subscribers.Attach(subscriber);
                        dbcontext.Entry(subscriber).Property(p => p.Unsubscribe).IsModified = true;
                        dbcontext.SaveChanges();
                        return(true);
                    }
                    catch (SqlException ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.SqlExceptions, ex.Message, ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                        obj.LogException();
                        throw obj;
                    }
                    catch (Exception ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                        obj.LogException();
                        throw obj;
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
Ejemplo n.º 19
0
        public List <M_Subscriber> Unsubscriber(int?lid)
        {
            // listIds = list.GetListIds(userID);
            if (lid != null)
            {
                using (dbcontext = new ApplicationDbContext())
                {
                    try
                    {
                        subscribersList = new List <M_Subscriber>();
                        subscribersList = dbcontext.M_Subscribers.Where(l => l.ListID == lid && l.Unsubscribe == true).ToList();
                    }
                    catch (SqlException ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.SqlExceptions, ex.Message, ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                        obj.LogException();
                        throw obj;
                    }
                    catch (Exception ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                        obj.LogException();
                        throw obj;
                    }
                }
            }
            return(subscribersList);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Delete perticular subscriber from database
        /// </summary>
        /// <param name="sid"></param>
        public void Delete(int?sid)
        {
            if (sid != null)
            {
                using (dbcontext = new ApplicationDbContext())
                {
                    var ls = dbcontext.ListSusbscribers.SingleOrDefault(l => l.SubscribersID == sid);
                    subscriber = dbcontext.M_Subscribers.Find(sid);
                    int?lid = subscriber.ListID;
                    if (ls != null)
                    {
                        try
                        {
                            dbcontext.ListSusbscribers.Remove(ls);
                        }
                        catch (SqlException ex)
                        {
                            obj = new M_CustomException((int)ErorrTypes.SqlExceptions, "Problem in saving data", ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                            obj.LogException();
                            throw obj;
                        }
                        catch (Exception ex)
                        {
                            obj = new M_CustomException((int)ErorrTypes.others, "Some problem occured while processing request", ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                            obj.LogException();
                            throw obj;
                        }
                    }
                    try
                    {
                        dbcontext.M_Subscribers.Remove(subscriber);
                        dbcontext.SaveChanges();
                    }
                    catch (SqlException ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.SqlExceptions, "Problem in saving data", ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                        obj.LogException();
                        throw obj;
                    }
                    catch (Exception ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.others, "Some problem occured while processing request", ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                        obj.LogException();
                        throw obj;
                    }
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// update subscribers information to database
        /// </summary>
        public void Update()
        {
            using (dbcontext = new ApplicationDbContext())
            {
                try
                {
                    dbcontext.Entry(this).State = System.Data.Entity.EntityState.Modified;
                    dbcontext.SaveChanges();
                }
                catch (SqlException ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.SqlExceptions, "Problem in saving data", ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                    obj.LogException();
                    throw obj;
                }
                catch (Exception ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.others, "Some problem occured while processing request", ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                    obj.LogException();
                    throw obj;
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// get collection of subscribers for perticular list
        /// </summary>
        /// <param name="listId">if listid is null display all subscribers for user and if listid is not null display subscriber
        /// for perticular list</param>
        /// <param name="userID"></param>
        /// <returns></returns>
        public List <M_Subscriber> GetsubscribersToList(int?listId, string userID)
        {
            if (listId != null)
            {
                using (dbcontext = new ApplicationDbContext())
                {
                    try
                    {
                        subscribersList = dbcontext.M_Lists.Find(listId).Subscribers.Where(s => s.Unsubscribe == false).ToList();
                    }
                    catch (SqlException ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.SqlExceptions, ex.InnerException.Message, ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                        obj.LogException();
                        throw obj;
                    }
                    catch (Exception ex)
                    {
                        obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                        obj.LogException();
                        throw obj;
                    }
                }
                return(subscribersList);
            }
            return(subscribersList);
            //else {
            //    subscribersList = GetAllSubscribers(userID);
            //    return subscribersList;
            //}
        }
        public ActionResult editCampaign(int?id)
        {
            userID = GetUser();
            UpdateCampModel campaign = new UpdateCampModel();

            try
            {
                // campaign.Campaigns = dbContext.M_Campaigns.Find(id);
                campaign.Campaigns = M_Campaigns.FindCampaign(id);
                //campaign.Subscribers = dbContext.NewLists.Find(campaign.Campaigns.ListId).Subscribers.ToList();
                campaign.Subscribers = M_Campaigns.subscribersToCampaign(campaign.Campaigns.ListId);
                //WebUtility.HtmlDecode(campaign.Campaigns.EmailContent);
                ViewBag.campTypes        = new SelectList(S_CampaignTypes.GetCampTypes(), "CTId", "Name");
                ViewBag.List             = new SelectList(M_List.GetLists(userID), "ListID", "ListName");
                TempData["emailContent"] = campaign.Campaigns.EmailContent;
                return(View("UpdateCamp", campaign));
            }
            catch (M_CustomException ex)
            {
                if (ex.ErrorCode == 100)
                {
                    ModelState.AddModelError("error", ex.message);
                    return(RedirectToAction("Campaign"));
                }
                else if (ex.ErrorCode == 101)
                {
                    ModelState.AddModelError("Error", "logical exception");
                    return(RedirectToAction("Campaign"));
                }
            }
            catch (InvalidOperationException ex)
            {
                M_CustomException obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                obj.LogException();
                ModelState.AddModelError("Error", "Invalid operation");
                return(RedirectToAction("Campaign"));
            }

            return(RedirectToAction("Campaign"));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// if listid is not null get subscribers by listid
        /// </summary>
        /// <param name="listID">is not null</param>
        /// <returns></returns>
        public List <M_Subscriber> GetSubscribersbyListID(int?listID)
        {
            using (dbcontext = new ApplicationDbContext())
            {
                try
                {
                    subscribersList = dbcontext.M_Lists.Find(listID).Subscribers.Where(s => s.Unsubscribe == false).ToList();
                }
                catch (SqlException ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.SqlExceptions, ex.Message, ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), Utlities.GetURL(), ex.LineNumber);

                    obj.LogException();
                    throw obj;
                }
                catch (Exception ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                    obj.LogException();
                    throw obj;
                }
            }
            return(subscribersList);
        }
Ejemplo n.º 25
0
        /// <summary>
        ///     Function to save New List object,and add list id into userslist table
        /// </summary>
        /// <param name="obj">New List type object</param>
        /// <param name="userID">User for which list is created</param>
        /// <returns></returns>
        public string SaveList(string userID)
        {
            if (CheckListExist(this.ListName, userID) == false)
            {
                user.UsersID = userID;
                try
                {
                    using (dbcontext = new ApplicationDbContext())
                    {
                        //begin transaction
                        using (var trans = dbcontext.Database.BeginTransaction())
                        {
                            try
                            {
                                this.CreatedDate = DateTime.Now;
                                dbcontext.M_Lists.Add(this);
                                dbcontext.SaveChanges();

                                user.ListID = this.ListID;
                                dbcontext.UsersList.Add(user);
                                dbcontext.SaveChanges();
                                trans.Commit();
                            }
                            catch (SqlException ex)
                            {
                                trans.Rollback();
                                obj = new M_CustomException((int)ErorrTypes.SqlExceptions, ex.Message, ex.StackTrace, ErorrTypes.SqlExceptions.ToString(), userID, Utlities.GetURL(), ex.LineNumber);

                                obj.LogException();
                                throw obj;
                            }
                            catch (Exception ex)
                            {
                                trans.Rollback();
                                obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), userID, Utlities.GetURL());

                                obj.LogException();
                                throw obj;
                            }
                        }
                    }
                    return("Saved");
                }
                catch (Exception ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), userID, Utlities.GetURL());
                    obj.LogException();
                    throw obj;
                }
            }
            //if listname already exist
            else
            {
                return("List name already exist");
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Function to check if list name is already exist
        /// </summary>
        /// <param name="listName">user want to create list by this name</param>
        /// <param name="UserID">User for which list is created</param>
        /// <returns>true if listname is already exist and false if listname does not exist</returns>
        public bool CheckListExist(string listName, string userID)
        {
            listIds = new List <int?>();
            //  listIds = GetListIds(userID);
            bool res = false;

            using (dbcontext = new ApplicationDbContext())
            {
                try
                {
                    var listdata = from list in dbcontext.M_Lists
                                   join users in dbcontext.UsersList
                                   on list.ListID equals users.ListID
                                   where users.UsersID == userID
                                   select new { list.ListName };
                    //foreach (var item in listIds)
                    //{
                    //    ListNames.Add(dbcontext.NewLists.Where(l => l.ListID == item).Select(l => l.ListName).FirstOrDefault());
                    //}
                    if (listdata != null)
                    {
                        res = listdata.Any(l => l.ListName == listName);
                    }
                }
                catch (SqlException ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber);
                    obj.LogException();
                    throw obj;
                }
                catch (Exception ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                    obj.LogException();
                    throw obj;
                }
            }
            // return ListNames.Any(l => l == listName);
            return(res);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Get list ids collection for perticular user
 /// </summary>
 /// <param name="userID"></param>
 /// <returns>listids collection</returns>
 public static List <int?> GetListIds(string userID)
 {
     using (dbcontext = new ApplicationDbContext())
     {
         try
         {
             listIds = new List <int?>();
             listIds = dbcontext.UsersList.Where(u => u.UsersID == userID).Select(l => l.ListID).ToList();
             return(listIds);
         }
         catch (SqlException ex)
         {
             obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber);
             obj.LogException();
             throw obj;
         }
         catch (Exception ex)
         {
             obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
             obj.LogException();
             throw obj;
         }
     }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Imports CSV data and saves to database
        /// </summary>
        /// <param name="UploadFile"></param>
        /// <param name="model"></param>
        public void ImportCSV(HttpPostedFileBase UploadFile, SubscribersViewModel model)
        {
            subscriber = new M_Subscriber();
            string filename = System.IO.Path.GetFileNameWithoutExtension(UploadFile.FileName);

            if (UploadFile.FileName.EndsWith(".csv"))
            {
                using (dbcontext = new ApplicationDbContext())
                {
                    Stream stream   = UploadFile.InputStream;
                    string thisFile = filename + "_" + model.ListID + ".csv";
                    // var path = System.IO.Path.Combine(Server.MapPath("~/CSVFiles"), thisFile);
                    DataTable csvTable = new DataTable();
                    using (CsvReader csvReader = new CsvReader(new StreamReader(stream), true))
                    {
                        csvTable.Load(csvReader);
                    }
                    model.dataTable = csvTable;
                    //read column headers
                    var columnHeaders = (from DataColumn dc in model.dataTable.Columns select dc.ColumnName).ToArray();
                    //save list to database
                    if (model.dataTable.Rows.Count > 0)
                    {
                        //UploadFile.SaveAs(path);
                        for (int i = 0; i < model.dataTable.Rows.Count; i++)
                        {
                            try
                            {
                                List <string> sub = new List <string>();
                                sub = dbcontext.M_Subscribers.Where(l => l.ListID == model.ListID).Select(m => m.EmailAddress).ToList();
                                bool ispresent = false;
                                try
                                {
                                    ispresent = sub.Any(s => s == model.dataTable.Rows[i]["EmailAddress"].ToString());
                                }
                                catch (ArgumentException ex)
                                {
                                    //ModelState.AddModelError("Fileerr", "Please see sample file format");
                                    //return View();
                                }
                                if (ispresent == false)
                                {
                                    ListSusbscriber lSub = new ListSusbscriber();
                                    lSub.ListID = model.ListID;
                                    using (var trans = dbcontext.Database.BeginTransaction())
                                    {
                                        // ObjectParameter objParam = new ObjectParameter("ID", typeof(int));
                                        try
                                        {
                                            subscriber.ListID                = Convert.ToInt32(model.ListID);
                                            subscriber.FirstName             = model.dataTable.Rows[i]["FirstName"].ToString();
                                            subscriber.LastName              = model.dataTable.Rows[i]["LastName"].ToString();
                                            subscriber.EmailAddress          = model.dataTable.Rows[i]["EmailAddress"].ToString();
                                            subscriber.AlternateEmailAddress = model.dataTable.Rows[i]["AlternateEmailAddress"].ToString();
                                            subscriber.Address               = model.dataTable.Rows[i]["Address"].ToString();
                                            subscriber.Country               = model.dataTable.Rows[i]["Country"].ToString();
                                            subscriber.City      = model.dataTable.Rows[i]["City"].ToString();
                                            subscriber.AddedDate = DateTime.Now;
                                            // subscriber.StatusID = 3;
                                            dbcontext.M_Subscribers.Add(subscriber);
                                            dbcontext.SaveChanges();
                                            //dbcontext.ImportSubscribers(Convert.ToInt32(model.ListID), model.dataTable.Rows[i]["FirstName"].ToString(),
                                            //      model.dataTable.Rows[i]["LastName"].ToString(), model.dataTable.Rows[i]["EmailAddress"].ToString(), model.dataTable.Rows[i]["AlternateEmailAddress"].ToString(),
                                            //      model.dataTable.Rows[i]["Address"].ToString(), model.dataTable.Rows[i]["Country"].ToString(), model.dataTable.Rows[i]["City"].ToString(),
                                            //      DateTime.Now.ToString(), objParam);

                                            //lSub.SubscribersID = Convert.ToInt32(objParam.Value);
                                            // lSub.SubscribersID = (int?)((SqlParameter)param[9]).Value;
                                            lSub.SubscribersID = subscriber.SubscriberID;
                                            dbcontext.ListSusbscribers.Add(lSub);
                                            dbcontext.SaveChanges();
                                            trans.Commit();
                                        }
                                        catch (SqlException)
                                        {
                                            trans.Rollback();
                                        }
                                        catch (Exception ex)
                                        {
                                            obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                                            obj.LogException();
                                            throw obj;
                                        }
                                    }
                                }
                                else
                                {
                                    //   ModelState.AddModelError("present", "Some subscribers already present");
                                }
                            }
                            catch (ArgumentException ex)
                            {
                                //ModelState.AddModelError("Fileerr", "Please see sample file format");
                                //return View();
                            }
                            catch (Exception ex)
                            {
                                obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                                obj.LogException();
                                throw obj;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 29
0
 public override void _Process(float delta)
 {
     lookDir         = GetGlobalMousePosition() - GlobalPosition;
     RotationDegrees = Utlities.LookAtMouse(GetGlobalMousePosition(), GlobalPosition);
     Shoot(lookDir, delta);
 }
Ejemplo n.º 30
0
        /// <summary>
        /// gets all lists
        /// </summary>
        /// <returns></returns>
        public static List <M_List> GetLists()
        {
            List <M_List> lists1 = new List <M_List>();

            using (dbcontext = new ApplicationDbContext())
            {
                try
                {
                    lists1 = dbcontext.M_Lists.ToList();
                }
                catch (SqlException ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber);
                    obj.LogException();
                    throw obj;
                }
                catch (Exception ex)
                {
                    obj = new M_CustomException((int)ErorrTypes.others, ex.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL());
                    obj.LogException();
                    throw obj;
                }
            }
            return(lists1);
        }