コード例 #1
0
        public ActionResult AllEmployees()
        {
            var obj   = new DBComponent();
            var model = obj.GetAllEmployees();

            return(View(model));
        }
コード例 #2
0
    private void SendMSG(Object sender, mCore.NewMessageReceivedEventArgs e)
    {
        string smsMsg = DBComponent.userSession(e.TextMessage.Trim(), e.Phone);

        sendSMS(e.Phone, smsMsg);
        //Send the message
    }
コード例 #3
0
 protected void btnReg_Click(object sender, EventArgs e)
 {
     if (this.IsValid)
     {
         bool b;
         long vcd;
         vcd = DBComponent.GenerateVerification();
         b   = DBComponent.userSignup(txtunm.Text.Trim(), txtMbno.Text.Trim(), vcd.ToString());
         if (b)
         {
             lblMsg.Text = "Registered Successfully, Verification code Sent To Your Mobile";
             this.Session["username"] = txtunm.Text.Trim();
             this.Session["mbno"]     = txtMbno.Text.Trim();
             SMS sobj = (SMS)Application["SmsObject"];
             sobj.sendSMS(txtMbno.Text.Trim(), "Your Verification Code is " + vcd.ToString() + "  oPas - A User Verification Protocol");
             BtnNext.Enabled = true;
             btnReg.Enabled  = false;
         }
         else
         {
             lblMsg.Text = "Failed to Register,Try After Some Time";
         }
     }
     else
     {
         lblMsg.Text = "Please Correct The Errors";
     }
 }
コード例 #4
0
        public ActionResult Edit(EmpTable emp)
        {
            var obj = new DBComponent();

            obj.UpdateEmployee(emp);
            return(RedirectToAction("AllEmployees"));//Moves the code to the Action AllEmployees...
        }
コード例 #5
0
    private void checkpss(Object sender, mCore.NewMessageReceivedEventArgs e)
    {
        bool b, c;

        number = e.Phone;
        string name = this.Session["unm"].ToString();

        c = DBComponent.chkmbno(e.Phone.Trim());
        if (c)
        {
            b = DBComponent.changenum(e.TextMessage, name, e.Phone);
            if (b)
            {
                s = 1;
            }
            else
            {
                s = 1;
                r = 2;
            }
        }
        else
        {
            s = 1;
            r = 1;
        }
    }
コード例 #6
0
        protected async ETVoid RunAsync(Session session, DBSaveRequest message, Action <DBSaveResponse> reply)
        {
            DBSaveResponse response = new DBSaveResponse();

            try
            {
                DBComponent dbComponent = Game.Scene.GetComponent <DBComponent>();
                if (string.IsNullOrEmpty(message.CollectionName))
                {
                    // myDebugInfo(session, message);//[MyAppend]
                    if (message.Component != null) //[MyAppend]
                    {                              //[MyAppend]
                        message.CollectionName = message.Component.GetType().Name;
                    }//[MyAppend]
                }

                await dbComponent.Add(message.Component, message.CollectionName);

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #7
0
        public ActionResult AddNew(EmpTable emp)
        {
            var obj = new DBComponent();

            obj.AddNewEmployee(emp);
            return(RedirectToAction("AllEmployees"));
        }
コード例 #8
0
        public ActionResult AddNew(Employee emp)
        {
            var com = new DBComponent();

            com.AddEmployee(emp);
            return(RedirectToAction("AllEmployees"));
        }
コード例 #9
0
        public ActionResult Delete(int id)
        {
            var com = new DBComponent();

            com.DeleteEmployee(id);
            return(RedirectToAction("AllEmployees"));
        }
コード例 #10
0
        [HttpPost]//As there are 2 methods, we should differ them by the HTTP Method....
        public ActionResult Edit(Employee emp)
        {
            var com = new DBComponent();

            com.UpdateEmployee(emp);
            return(RedirectToAction("AllEmployees"));//Redirecting to the Table View...
        }
コード例 #11
0
        protected override async ETTask Run(Session session, DBQueryBatchRequest request, DBQueryBatchResponse response, Action reply)
        {
            DBComponent dbComponent = Game.Scene.GetComponent <DBComponent>();

            response.Components = await dbComponent.GetBatch(request.CollectionName, request.IdList);

            reply();
        }
コード例 #12
0
        public ActionResult Edit(string id)
        {
            var com   = new DBComponent();
            int empId = int.Parse(id);
            var model = com.FindEmployee(empId);

            return(View(model));
        }
コード例 #13
0
        public static async ETTask <Gamer> GetGamerFromDB(Entity domain, DBComponent db, long gamerid)
        {
            Gamer gamer = await db.Query <Gamer>(gamerid);

            gamer.Domain = domain;

            return(gamer);
        }
コード例 #14
0
        public static async Task <long> QueryJsonCount <T>(this DBProxyComponent self, string json)
        {
            DBComponent dbComponent = Game.Scene.GetComponent <DBComponent>();
            FilterDefinition <ComponentWithId> filterDefinition = new JsonFilterDefinition <ComponentWithId>(json);
            long count = await dbComponent.GetCollection(typeof(T).Name).CountAsync(filterDefinition);

            return(count);
        }
コード例 #15
0
ファイル: MongoDBExtensions.cs プロジェクト: fotocj007/ETBomb
        public static async ETTask <long> GetIncrementId <T>(this DBComponent self)
        {
            var collection        = self.GetCollection <CollectionIdentity>();
            CollectionIdentity id = await collection.FindOneAndUpdateAsync(Builders <CollectionIdentity> .Filter.Eq(f => f.Id, typeof(T).Name),
                                                                           Builders <CollectionIdentity> .Update.Inc(f => f.Value, 1), options);

            return(id.Value);
        }
コード例 #16
0
        public static async ETTask <long> Remove <T>(this DBComponent self, long taskId, long id, string collection = null) where T : Entity
        {
            using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
            {
                DeleteResult result = await self.GetCollection <T>(collection).DeleteOneAsync(d => d.Id == id);

                return(result.DeletedCount);
            }
        }
コード例 #17
0
        public static async ETTask <long> Remove <T>(this DBComponent self, Expression <Func <T, bool> > filter, string collection = null) where T : Entity
        {
            using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.DB, RandomHelper.RandInt64() % DBComponent.TaskCount))
            {
                DeleteResult result = await self.GetCollection <T>(collection).DeleteManyAsync(filter);

                return(result.DeletedCount);
            }
        }
コード例 #18
0
ファイル: DBProxyComponentSystem.cs プロジェクト: kok5/ET
 /// <summary>
 /// 根据表达式删除
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="self"></param>
 /// <param name="exp"></param>
 /// <returns></returns>
 public static async ETTask DeleteAll <T>(this DBProxyComponent self, Expression <Func <T, bool> > exp)
 {
     DBComponent dbComponent = Game.Scene.GetComponent <DBComponent>();
     ExpressionFilterDefinition <T> filter             = new ExpressionFilterDefinition <T>(exp);
     IBsonSerializerRegistry        serializerRegistry = BsonSerializer.SerializerRegistry;
     IBsonSerializer <T>            documentSerializer = serializerRegistry.GetSerializer <T>();
     string json = filter.Render(documentSerializer, serializerRegistry).ToJson();
     await dbComponent.GetCollection(typeof(T).Name).FindOneAndDeleteAsync(json);
 }
コード例 #19
0
        public static async ETTask <T> Query <T>(this DBComponent self, long id, string collection = null) where T : Entity
        {
            using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.DB, id % DBComponent.TaskCount))
            {
                IAsyncCursor <T> cursor = await self.GetCollection <T>(collection).FindAsync(d => d.Id == id);

                return(await cursor.FirstOrDefaultAsync());
            }
        }
コード例 #20
0
        public static void Update <T>(this DBProxyComponent self, string fieldname, string fieldvalue, string aaa)
        {
            //第一个参数是需要更改的在数据库中的对象  第二个是要更改的对象的值  第三个是更改后的对象的值 对象也可以改 多传点参数就行
            DBComponent dbComponent = Game.Scene.GetComponent <DBComponent>();
            var         filter1     = Builders <ComponentWithId> .Filter.Eq(fieldname, fieldvalue);

            var updata1 = Builders <ComponentWithId> .Update.Set(fieldname, aaa);

            dbComponent.GetCollection(typeof(T).Name).UpdateOne(filter1, updata1);
        }
コード例 #21
0
        public static async ETTask <List <T> > QueryJson <T>(this DBComponent self, long taskId, string json, string collection = null) where T : Entity
        {
            using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.DB, RandomHelper.RandInt64() % DBComponent.TaskCount))
            {
                FilterDefinition <T> filterDefinition = new JsonFilterDefinition <T>(json);
                IAsyncCursor <T>     cursor           = await self.GetCollection <T>(collection).FindAsync(filterDefinition);

                return(await cursor.ToListAsync());
            }
        }
コード例 #22
0
        public static async Task <List <T> > QueryJsonDBInfos <T>(this DBProxyComponent self, string time, long uid)
        {
            DBComponent          dbComponent      = Game.Scene.GetComponent <DBComponent>();
            FilterDefinition <T> filterDefinition = new JsonFilterDefinition <T>($"{{CreateTime:/^{time}/,Uid:{uid}}}");
            IAsyncCursor <T>     cursor           = await dbComponent.GetDBDataCollection <T>(typeof(T).Name).FindAsync(filterDefinition);

            List <T> components = await cursor.ToListAsync();

            return(components);
        }
コード例 #23
0
        static void Main(string[] args)
        {
            var       com   = new DBComponent();
            DataTable table = com.GetAllEmployees();

            foreach (DataRow row in table.Rows)
            {
                Console.WriteLine(row["EmpName"]);
            }
        }
コード例 #24
0
        public static async ETTask <List <T> > Query <T>(this DBComponent self, long taskId, Expression <Func <T, bool> > filter, string collection = null)
            where T : Entity
        {
            using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
            {
                IAsyncCursor <T> cursor = await self.GetCollection <T>(collection).FindAsync(filter);

                return(await cursor.ToListAsync());
            }
        }
コード例 #25
0
        public static async Task <List <T> > QueryJsonDB <T>(this DBProxyComponent self, string json) where T : ComponentWithId
        {
            DBComponent          dbComponent      = Game.Scene.GetComponent <DBComponent>();
            FilterDefinition <T> filterDefinition = new JsonFilterDefinition <T>(json);
            IAsyncCursor <T>     cursor           = await dbComponent.GetDBDataCollection <T>(typeof(T).Name).FindAsync(filterDefinition);

            List <T> components = await cursor.ToListAsync();

            return(components);
        }
コード例 #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string    name = this.Session["unm"].ToString();
        DataTable dt   = DBComponent.getUser(name);

        if (dt != null)
        {
            txtque.Text = dt.Rows[0]["Secque"].ToString();
            ans         = dt.Rows[0]["Secans"].ToString();
        }
    }
コード例 #27
0
        public ActionResult AddNew()
        {
            var obj   = new DBComponent();
            var depts = obj.GetAllDepts().Select(e => new SelectListItem {
                Text = e.DeptName, Value = e.DeptId.ToString()
            }).ToList();

            //Get all Depts from the source and convert it to List<SelectListItem> to use it inside DropDownList....
            ViewBag.Depts = depts;//Add it to ViewBag object to display in the view...
            return(View(new EmpTable()));
        }
コード例 #28
0
        public static async ETVoid SaveNotWait <T>(this DBComponent self, T entity, long taskId = 0, string collection = null) where T : Entity
        {
            if (taskId == 0)
            {
                await self.Save(entity, collection);

                return;
            }

            await self.Save(taskId, entity, collection);
        }
コード例 #29
0
 protected void btnReg_Click(object sender, EventArgs e)
 {
     if (DBComponent.authenticateUser(txtunm.Text.Trim()))
     {
         this.Session["unm"] = txtunm.Text;
         Response.Redirect("~/Menu.aspx");
     }
     else
     {
         lblMsg.Text = "SMS Your Password";
     }
 }
コード例 #30
0
        public static async ETTask InsertBatch <T>(this DBComponent self, IEnumerable <T> list, string collection = null) where T : Entity
        {
            if (collection == null)
            {
                collection = typeof(T).Name;
            }

            using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.DB, RandomHelper.RandInt64() % DBComponent.TaskCount))
            {
                await self.GetCollection(collection).InsertManyAsync(list);
            }
        }