コード例 #1
0
ファイル: Daily.aspx.cs プロジェクト: menasbeshay/ivalley-svn
        private void SendFollowAdminBotMessages()
        {
            BLL.Member bllBotMember = BLL.Member.GetSiteMember("بوت متابعة الإدارة");

            BLL.RoomBot bllRoomBot = new BLL.RoomBot();
            List<Info.RoomBot> lstBots = bllRoomBot.GetByBotID(Helper.Enums.Bot.FollowAdmin);
            Info.FollowAdmin infoSettings;
            string mailURL = "/RoomHistory.aspx?rid=";
            bool send = false;
            foreach (Info.RoomBot roomBot in lstBots)
            {
                mailURL += roomBot.RoomID.ToString();
                infoSettings = (Info.FollowAdmin)roomBot.Settings;
                if (infoSettings.FollowSchedule==Convert.ToString((int)Helper.Enums.FollowAdminBotSchedule.Daily))
                {
                    send = true;
                    mailURL += "&sid=" + Convert.ToString((int)Helper.Enums.FollowAdminBotSchedule.Daily);
                }
                else if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday &&
                    infoSettings.FollowSchedule==Convert.ToString((int)Helper.Enums.FollowAdminBotSchedule.Week))
                {
                    send = true;
                    mailURL += "&sid=" + Convert.ToString((int)Helper.Enums.FollowAdminBotSchedule.Daily);
                }
                else if (DateTime.Now.Day == 1 &&
                    infoSettings.FollowSchedule==Convert.ToString((int) Helper.Enums.FollowAdminBotSchedule.Month))
                {
                    send = true;
                    mailURL += "&sid=" + Convert.ToString((int)Helper.Enums.FollowAdminBotSchedule.Daily);
                }
                if (send)
                {
                    mailURL += "&l=" + String.Join(",", infoSettings.FollowMemberLevels);
                    mailURL = Request.Url.OriginalString.ToLower().Replace("/jobs/daily.aspx", "") + mailURL;

                    SendBotMsg(mailURL, roomBot,bllBotMember.MemberID);
                }
            }
        }
コード例 #2
0
ファイル: RoomBot.cs プロジェクト: menasbeshay/ivalley-svn
        public void Save(List<Info.RoomBot> lst)
        {
            MyGeneration.dOOdads.TransactionMgr tx = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
            try
            {
                BLL.RoomBot bllRoomBot = new BLL.RoomBot();

                tx.BeginTransaction();
                foreach (Info.RoomBot bot in lst)
                {
                    if (bot.ID == 0)//new bot
                    {
                        bllRoomBot.AddNew();
                        bllRoomBot.RoomID = bot.RoomID;
                        bllRoomBot.BotID = bot.Bot.ID;
                        bllRoomBot.IsEnabled = bot.IsEnabled;
                        bllRoomBot.StartDate = DateTime.Now;
                        bllRoomBot.TimeStamp = DateTime.Now;
                        bllRoomBot.ShortcutKey = bot.ShortcutKey;
                        bllRoomBot.SettingString = Helper.JsonConverter.Serialize(bot.Settings);
                        bllRoomBot.Save();
                        bot.ID = bllRoomBot.ID;
                        //update member points
                        BLL.Member currentMember = BLL.Member.CurrentMember;
                        if (currentMember.Credit_Point < bot.Bot.Points)
                            throw new Exception("رصيد النقاط غير كافى");
                        currentMember.Credit_Point -= bot.Bot.Points;
                        currentMember.Save();
                    }
                    else
                    {
                        if (bllRoomBot.LoadByPrimaryKey(bot.ID))
                        {
                            bllRoomBot.IsEnabled = bot.IsEnabled;
                            bllRoomBot.ShortcutKey = bot.ShortcutKey;
                            bllRoomBot.SettingString = Helper.JsonConverter.Serialize(bot.Settings);
                            bllRoomBot.Save();
                        }
                    }
                }
                tx.CommitTransaction();
            }
            catch (Exception ex)
            {
                tx.RollbackTransaction();
                throw;
            }
        }
コード例 #3
0
ファイル: Bots.aspx.cs プロジェクト: menasbeshay/ivalley-svn
        protected void btnSaveBots_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(lstRooms.SelectedValue))
            {
                dvError.Visible = true;
                lblError.Text = "يرجى إختيار الغرفة";
                return;
            }

            List<BLL.Log.AddRoomBot> lstLogs=new List<BLL.Log.AddRoomBot>();
            BLL.MemberLog bllLog = new BLL.MemberLog();

            int totalPoint = 0;
            int roomID = Convert.ToInt32(lstRooms.SelectedValue);
            BLL.RoomBot bllRoomBot = new BLL.RoomBot();
            foreach (RepeaterItem bot in repBots.Items)
            {
                CheckBox chkBot = (CheckBox)bot.FindControl("chkSelect");
                HiddenField hdnBotID = (HiddenField)bot.FindControl("hdnBotID");
                HiddenField hdnBotPoints = (HiddenField)bot.FindControl("hdnBotPoints");
                if (chkBot.Checked)
                {
                    int botID = Helper.TypeConverter.ToInt32(hdnBotID.Value);
                    int points = Helper.TypeConverter.ToInt32(hdnBotPoints.Value);
                    totalPoint += points;
                    bllRoomBot.AddNew();
                    bllRoomBot.BotID = botID;
                    bllRoomBot.RoomID = roomID;
                    bllRoomBot.CreatedByMemberID = BLL.Member.CurrentMemberID;
                    bllRoomBot.StartDate = DateTime.Now;
                    bllRoomBot.EndDate = DateTime.Now.AddMonths(1);

                    lstLogs.Add(new BLL.Log.AddRoomBot(){RoomID=roomID,RoomName=lstRooms.SelectedItem.Text,BotID=botID,BotPoints=points});
                }
            }

            if (totalPoint < BLL.Member.CurrentMember.Credit_Point || totalPoint == 0)
            {
                MyGeneration.dOOdads.TransactionMgr tx = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {
                    tx.BeginTransaction();
                    BLL.Member.CurrentMember.Credit_Point -= totalPoint;
                    BLL.Member.CurrentMember.Save();

                    bllRoomBot.Save();

                    foreach(var log in lstLogs)
                    {
                        bllLog.AddNew(BLL.Member.CurrentMemberID, log, null, roomID);
                    }
                    tx.CommitTransaction();
                    //notify rooms
                    List<int> newBots = bllRoomBot.DefaultView.Table.AsEnumerable().Select(r => Helper.TypeConverter.ToInt32(r[BLL.RoomBot.ColumnNames.ID])).ToList();
                    services.Services.AddRoomBots(roomID, newBots);

                    Response.Redirect("Bots.aspx");
                }
                catch(Exception ex)
                {
                    tx.RollbackTransaction();
                    dvError.Visible = true;
                    lblError.Text = "عفوا حدث حطأ يرجى المحاولة لاحقا";
                }
            }
            else
            {
                dvError.Visible = true;
                lblError.Text = "رصيد نقاطك غير كافى";
            }
        }
コード例 #4
0
ファイル: Bots.aspx.cs プロジェクト: menasbeshay/ivalley-svn
 private void BindRoomsBots()
 {
     BLL.RoomBot bllRoomBot = new BLL.RoomBot();
     _dicRoomsBots = new List<object>();
     if (bllRoomBot.GetRoomsBotsByCreatorID(BLL.Member.CurrentMemberID))
     {
         _dicRoomsBots = bllRoomBot.DefaultView.Table.AsEnumerable().Select(m => new { RoomID = m[BLL.RoomBot.ColumnNames.RoomID], BotID = m[BLL.RoomBot.ColumnNames.BotID] }).ToList();
     }
 }
コード例 #5
0
        protected void uiGridViewRoom_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int roomid = Convert.ToInt32(e.CommandArgument.ToString());
            if (e.CommandName == "DeleteRoom")
            {

                BLL.Room room = new BLL.Room();

                room.LoadByPrimaryKey(roomid);
                room.MarkAsDeleted();

                room.Save();
                BindRooms();
            }
            else if (e.CommandName == "DeleteBots")
            {
                BLL.RoomBot bots = new BLL.RoomBot();

                bots.Where.RoomID.Value = roomid;
                bots.Where.RoomID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                bots.Query.Load();

                for (int i = 0; i < bots.RowCount; i++)
                {
                    bots.MarkAsDeleted();
                    bots.MoveNext();
                }

                bots.Save();

            }
            else if (e.CommandName == "DeleteMembers")
            {
                BLL.RoomMember members = new BLL.RoomMember();

                members.Where.RoomID.Value = roomid;
                members.Where.RoomID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                members.Query.Load();

                for (int i = 0; i < members.RowCount; i++)
                {
                    members.MarkAsDeleted();
                    members.MoveNext();
                }
                members.Save();

            }

            else if (e.CommandName == "DeleteMessages")
            {
                BLL.RoomMessages msgs = new BLL.RoomMessages();

                msgs.Where.RoomID.Value = roomid;
                msgs.Where.RoomID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                msgs.Query.Load();

                for (int i = 0; i < msgs.RowCount; i++)
                {
                    msgs.MarkAsDeleted();
                    msgs.MoveNext();
                }
                msgs.Save();

            }
            else if (e.CommandName == "DeleteBannedmembers")
            {
                BLL.RoomMemberBanning bans = new BLL.RoomMemberBanning();
                bans.Where.RoomID.Value = roomid;
                bans.Where.RoomID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                bans.Query.Load();

                for (int i = 0; i < bans.RowCount; i++)
                {
                    bans.MarkAsDeleted();
                    bans.MoveNext();
                }
                bans.Save();
            }

            else if (e.CommandName == "DeleteTypes")
            {
                BLL.RoomType type = new BLL.RoomType();
                type.Where.RoomID.Value = roomid;
                type.Where.RoomID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                type.Query.Load();

                for (int i = 0; i < type.RowCount; i++)
                {
                    type.MarkAsDeleted();
                    type.MoveNext();
                }
                type.Save();
            }
        }