예제 #1
0
        public static void ProcessCorpUser(bool subscribe, string logonName)
        {
            using (EmptyDbDataSource source = WeDataUtil.CreateSource())
            using (InternalCorpUserResolver resolver = new InternalCorpUserResolver(source))
            {
                DataRow row = resolver.TrySelectRowWithParam("UserLogonName", logonName);
                if (row != null)
                {
                    resolver.SetCommands(AdapterCommand.Update);
                    row.BeginEdit();
                    DateTime current = DateTime.Now;
                    if (subscribe)
                    {
                        row["AttentionFlag"] = 1;
                        row["AttentionDate"] = current;
                        row["UnAttentionDate"] = DBNull.Value;
                    }
                    else
                    {
                        row["AttentionFlag"] = 0;
                        row["UnAttentionDate"] = current;
                    }
                    row["UpdateDate"] = current;
                    row.EndEdit();
                }

                resolver.UpdateDatabase();
            }
        }
예제 #2
0
        protected override OutputData DoPost(IInputData input)
        {
            Tk5TableResolver getResovler = new Tk5TableResolver(@"Weixin\CorpTagDept.xml", this);

            using (getResovler)
            {
                DataSet postDataSet = input.PostObject.Convert <DataSet>();
                getResovler.PrepareDataSet(postDataSet);

                FieldErrorInfoCollection errors = new FieldErrorInfoCollection();
                getResovler.CheckFirstConstraints(input, errors);
                getResovler.CheckLaterConstraints(input, errors);
                errors.CheckError();

                QuoteStringList postList  = new QuoteStringList();
                DataTable       postTable = postDataSet.Tables[getResovler.TableName];
                if (postTable != null)
                {
                    foreach (DataRow postRow in postTable.Rows)
                    {
                        postList.Add(postRow["DeparmentId"].ToString());
                    }
                }
                string tagId = input.QueryString["TagId"];

                InternalCorpUserResolver userResolver = new InternalCorpUserResolver(this);
                using (userResolver)
                {
                    DataRow  row  = userResolver.SelectRowWithKeys(input.QueryString["UserId"]);
                    CorpUser user = new CorpUser();
                    user.ReadFromDataRow(row, WeCorpConst.USER_MODE);
                    user.DepartmentList = postList;
                    row["Department"]   = postList;
                    userResolver.SetCommands(AdapterCommand.Update);
                    user.Update();

                    userResolver.UpdateDatabase();
                    return(OutputData.CreateToolkitObject(userResolver.CreateKeyData()));
                }
            }
        }
        protected override OutputData DoPost(IInputData input)
        {
            Tk5TableResolver getResovler = new Tk5TableResolver(@"Weixin\CorpTagDept.xml", this);
            using (getResovler)
            {
                DataSet postDataSet = input.PostObject.Convert<DataSet>();
                getResovler.PrepareDataSet(postDataSet);

                FieldErrorInfoCollection errors = new FieldErrorInfoCollection();
                getResovler.CheckFirstConstraints(input, errors);
                getResovler.CheckLaterConstraints(input, errors);
                errors.CheckError();

                QuoteStringList postList = new QuoteStringList();
                DataTable postTable = postDataSet.Tables[getResovler.TableName];
                if (postTable != null)
                {
                    foreach (DataRow postRow in postTable.Rows)
                        postList.Add(postRow["DeparmentId"].ToString());
                }
                string tagId = input.QueryString["TagId"];

                InternalCorpUserResolver userResolver = new InternalCorpUserResolver(this);
                using (userResolver)
                {
                    DataRow row = userResolver.SelectRowWithKeys(input.QueryString["UserId"]);
                    CorpUser user = new CorpUser();
                    user.ReadFromDataRow(row, WeCorpConst.USER_MODE);
                    user.DepartmentList = postList;
                    row["Department"] = postList;
                    userResolver.SetCommands(AdapterCommand.Update);
                    user.Update();

                    userResolver.UpdateDatabase();
                    return OutputData.CreateToolkitObject(userResolver.CreateKeyData());
                }
            }
        }