Beispiel #1
0
        public void Save(WeUser user)
        {
            if (user == null)
            {
                return;
            }

            DataRow row = NewRow();

            user.AddToDataRow(row);

            SetCommands(AdapterCommand.Insert);
        }
Beispiel #2
0
        public static void ProcessNormalUser(bool subscrible, string openId)
        {
            using (EmptyDbDataSource source = WeDataUtil.CreateSource())
                using (UserResolver resolver = new UserResolver(source))
                    using (SubscribeDataResolver subResolver = new SubscribeDataResolver(source))
                    {
                        subResolver.SetCommands(AdapterCommand.Insert);
                        resolver.SetCommands(AdapterCommand.Insert | AdapterCommand.Update);
                        DateTime current = DateTime.Now;

                        DataRow row = resolver.TrySelectRowWithKeys(openId);
                        if (row == null)
                        {
                            row = resolver.NewRow();
                        }
                        if (subscrible)
                        {
                            WeUser user = WeUser.GetUser(openId);
                            user.AddToDataRow(row);
                        }
                        else
                        {
                            row["Subscribe"] = 0;
                        }

                        DataRow subRow = subResolver.NewRow();
                        subRow.BeginEdit();
                        subRow["Id"]            = subResolver.CreateUniId();
                        subRow["OpenId"]        = openId;
                        subRow["SubscribeDate"] = current;
                        subRow["IsSubscribe"]   = subscrible ? 1 : 0;
                        subRow.EndEdit();

                        UpdateUtil.UpdateTableResolvers(source.Context, null,
                                                        new TableResolver[] { resolver, subResolver });
                    }
        }