Пример #1
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());
                }
            }
        }
Пример #3
0
        protected override OutputData DoPost(IInputData input)
        {
            string oper             = input.QueryString["Operation"];
            string dataXml          = null;
            string tagFieldName     = null;
            string dataXmlFieldName = null;

            switch (oper)
            {
            case "User":
                dataXml          = @"Weixin\CorpTagUser.xml";
                tagFieldName     = "UserList";
                dataXmlFieldName = "UserId";
                break;

            case "Dept":
                dataXml          = @"Weixin\CorpTagDept.xml";
                tagFieldName     = "DepartmentList";
                dataXmlFieldName = "DeparmentId";
                break;

            default:
                TkDebug.ThrowImpossibleCode(this);
                break;
            }
            Tk5TableResolver getResovler = new Tk5TableResolver(dataXml, 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[dataXmlFieldName].ToString());
                    }
                }
                string tagId = input.QueryString["TagId"];

                CorpTagList tagList;
                CorpTag     tag = CorpTagEditObjectSource.FindTag(tagId, out tagList);

                DataRow row = fResolver.TrySelectRowWithKeys(tagId);
                if (row == null)
                {
                    fResolver.SetCommands(AdapterCommand.Insert);
                    row = fResolver.NewRow();
                    row.BeginEdit();
                    row["TagId"]      = tagId;
                    row["Name"]       = tag.Name;
                    row[tagFieldName] = postList.ToString();
                    row.EndEdit();
                    switch (oper)
                    {
                    case "User":
                        AddUserMembers(tag, postList, null);
                        break;

                    case "Dept":
                        AddDeptMembers(tag, postList, null);
                        break;
                    }

                    fResolver.UpdateDatabase();
                }
                else
                {
                    fResolver.SetCommands(AdapterCommand.Update);
                    QuoteStringList sourceList = row[tagFieldName].Value <QuoteStringList>();
                    row[tagFieldName] = postList.ToString();

                    switch (oper)
                    {
                    case "User":
                        AddUserMembers(tag, postList, sourceList);
                        break;

                    case "Dept":
                        AddDeptMembers(tag, postList, sourceList);
                        break;
                    }

                    fResolver.UpdateDatabase();
                }

                return(OutputData.CreateToolkitObject(fResolver.CreateKeyData()));
            }
        }