예제 #1
0
        public ToolsDocumentSource()
        {
            OrderBy      = "ORDER BY DOC_ORGIN_DATE DESC";
            SortQuery    = true;
            Context      = DbContextUtil.CreateDbContext("Tools");
            MainResolver = new TaxDocumentResolver(this);
            Operators    = new ListOperators();

            using (var idSource = new EmptyDbDataSource())
            {
                SqlSelector.Select(idSource.Context, idSource.DataSet, "Document",
                                   "SELECT DISTINCT DOC_SOURCE_ID FROM CS_DOCUMENT WHERE DOC_SOURCE_ID IS NOT NULL");
                DataTable table = idSource.DataSet.Tables["Document"];
                if (table == null || table.Rows.Count == 0)
                {
                    FilterSql = new MarcoConfigItem(false, false, "DOC_VERIFY_FLAG > 0");
                }
                else
                {
                    var ids = from row in table.AsEnumerable()
                              select row["DOC_SOURCE_ID"].ToString();
                    string sql = string.Format(ObjectUtil.SysCulture,
                                               "DOC_VERIFY_FLAG > 0 AND DOC_DOC_ID NOT IN ({0})", string.Join(",", ids));
                    FilterSql = new MarcoConfigItem(false, false, sql);
                }
            }
        }
예제 #2
0
        protected override void OnUpdatingRow(UpdatingEventArgs e)
        {
            base.OnUpdatingRow(e);

            TaxDocumentResolver resolver;
            DataRow             docRow;

            switch (e.Status)
            {
            case UpdateKind.Update:
                int flag = e.Row["SendFlag"].Value <int>();
                if (flag == 0)
                {
                    resolver = new TaxDocumentResolver(Source);
                    NonUIResolvers.NonUIResolvers.Add(resolver);
                    docRow             = resolver.SelectRowWithKeys(e.Row["DocId"]);
                    docRow["MassFlag"] = 1;
                    resolver.SetCommands(AdapterCommand.Update);
                    e.Row["SendFlag"] = 1;
                }
                break;

            case UpdateKind.Delete:
                resolver = new TaxDocumentResolver(Source);
                NonUIResolvers.NonUIResolvers.Add(resolver);
                docRow = resolver.SelectRowWithKeys(e.Row["DocId"]);
                docRow.BeginEdit();
                docRow["MassFlag"] = 0;
                docRow["MassId"]   = DBNull.Value;
                docRow.EndEdit();
                resolver.SetCommands(AdapterCommand.Update);
                break;
            }
        }
예제 #3
0
        public override OutputData DoAction(IInputData input)
        {
            using (WeixinMassResolver massResolver = new WeixinMassResolver(this))
                using (TaxDocumentResolver docResolver = new TaxDocumentResolver(this))
                {
                    string  docId  = input.QueryString["DocId"];
                    DataRow docRow = docResolver.SelectRowWithKeys(docId);
                    string  massId = docRow["MassId"].ToString();
                    if (string.IsNullOrEmpty(massId))
                    {
                        docResolver.SetCommands(AdapterCommand.Update);
                        massId = massResolver.NewRow(docId);
                        docRow.BeginEdit();
                        docRow["MassId"]   = massId;
                        docRow["MassFlag"] = 0;
                        docRow.EndEdit();
                        UpdateUtil.UpdateTableResolvers(null, docResolver, massResolver);
                    }

                    string retUrl = input.QueryString["RetUrl"];
                    if (!string.IsNullOrEmpty(retUrl))
                    {
                        retUrl = "&RetUrl=" + HttpUtility.UrlEncode(retUrl);
                    }
                    string url = string.Format("~/Library/WebUpdateXmlPage.tkx?Source=CXCS/WeixinMass&MassId={0}{1}", massId, retUrl);
                    return(OutputData.Create(url));
                }
        }
예제 #4
0
        protected override void OnUpdatingRow(UpdatingEventArgs e)
        {
            base.OnUpdatingRow(e);

            TaxDocumentResolver resolver;
            DataRow docRow;
            switch (e.Status)
            {
                case UpdateKind.Update:
                    int flag = e.Row["SendFlag"].Value<int>();
                    if (flag == 0)
                    {
                        resolver = new TaxDocumentResolver(Source);
                        NonUIResolvers.NonUIResolvers.Add(resolver);
                        docRow = resolver.SelectRowWithKeys(e.Row["DocId"]);
                        docRow["MassFlag"] = 1;
                        resolver.SetCommands(AdapterCommand.Update);
                        e.Row["SendFlag"] = 1;
                    }
                    break;
                case UpdateKind.Delete:
                    resolver = new TaxDocumentResolver(Source);
                    NonUIResolvers.NonUIResolvers.Add(resolver);
                    docRow = resolver.SelectRowWithKeys(e.Row["DocId"]);
                    docRow.BeginEdit();
                    docRow["MassFlag"] = 0;
                    docRow["MassId"] = DBNull.Value;
                    docRow.EndEdit();
                    resolver.SetCommands(AdapterCommand.Update);
                    break;
            }
        }
예제 #5
0
        public override OutputData DoAction(IInputData input)
        {
            using (WeixinMassResolver massResolver = new WeixinMassResolver(this))
            using (TaxDocumentResolver docResolver = new TaxDocumentResolver(this))
            {

                string docId = input.QueryString["DocId"];
                DataRow docRow = docResolver.SelectRowWithKeys(docId);
                string massId = docRow["MassId"].ToString();
                if (string.IsNullOrEmpty(massId))
                {
                    docResolver.SetCommands(AdapterCommand.Update);
                    massId = massResolver.NewRow(docId);
                    docRow.BeginEdit();
                    docRow["MassId"] = massId;
                    docRow["MassFlag"] = 0;
                    docRow.EndEdit();
                    UpdateUtil.UpdateTableResolvers(null, docResolver, massResolver);
                }

                string retUrl = input.QueryString["RetUrl"];
                if (!string.IsNullOrEmpty(retUrl))
                    retUrl = "&RetUrl=" + HttpUtility.UrlEncode(retUrl);
                string url = string.Format("~/Library/WebUpdateXmlPage.tkx?Source=CXCS/WeixinMass&MassId={0}{1}", massId, retUrl);
                return OutputData.Create(url);
            }
        }
예제 #6
0
        public override OutputData DoAction(IInputData input)
        {
            using (TaxDocumentResolver docResolver = new TaxDocumentResolver(this))
                using (WeixinMassResolver massResolver = new WeixinMassResolver(this))
                    using (WeixinMassDetailResolver detailResolver = new WeixinMassDetailResolver(this))
                    {
                        DataRow row = massResolver.Query(input.QueryString);
                        if (row["SendFlag"].Value <int>() == 4) // 已发送的不在发送
                        {
                            return(OutputData.Create("-2"));
                        }

                        massResolver.SetCommands(AdapterCommand.Update);
                        docResolver.SetCommands(AdapterCommand.Update);

                        DateTime current = DateTime.Now;
                        row.BeginEdit();
                        row["SendFlag"] = 4;
                        row["SendDate"] = row["UpdateDate"] = current;
                        row["SendId"]   = row["UpdateId"] = BaseGlobalVariable.UserId;
                        row.EndEdit();

                        MpNewsMassMessage msg      = new MpNewsMassMessage();
                        string            basePath = Path.Combine(BaseAppSetting.Current.AppPath, @"..\pic\sys\");
                        string            path     = Path.Combine(basePath, "hzwtitle.jpg");
                        //MediaId mId = WeUtil.UploadFile(MediaType.Image, path);
                        string  mediaId = WeDataUtil.GetMediaId(MediaType.Image, path);
                        DataRow docRow  = UpdateDocRow(docResolver, row, current, 4);
                        msg.AddArticle(CreateArticle(docRow, mediaId));

                        detailResolver.SelectWithParam(string.Empty, "ORDER BY WMD_ORDER_NUM",
                                                       "MassId", input.QueryString["MassId"]);
                        DataTable childTable = detailResolver.HostTable;
                        if (childTable != null)
                        {
                            foreach (DataRow childRow in childTable.Rows)
                            {
                                docRow  = UpdateDocRow(docResolver, childRow, current, 2);
                                path    = Path.Combine(basePath, string.Format("A{0}.jpg", docRow["Catelog"]));
                                mediaId = WeDataUtil.GetMediaId(MediaType.Image, path);
                                msg.AddArticle(CreateArticle(docRow, mediaId));
                            }
                        }

                        UpdateUtil.UpdateTableResolvers(null, docResolver, massResolver);

                        var media_Id = msg.UploadMessage();
                        var users    = WeFanContainter.GetAllUsers();

                        var result = msg.Send(users);
                        if (result > 0)
                        {
                            return(OutputData.Create("0"));
                        }

                        return(OutputData.Create("-1"));
                    }
        }
        public override OutputData DoAction(IInputData input)
        {
            using (TaxDocumentResolver docResolver = new TaxDocumentResolver(this))
            using (WeixinMassResolver massResolver = new WeixinMassResolver(this))
            using (WeixinMassDetailResolver detailResolver = new WeixinMassDetailResolver(this))
            {
                DataRow row = massResolver.Query(input.QueryString);
                if (row["SendFlag"].Value<int>() == 4) // 已发送的不在发送
                    return OutputData.Create("-2");

                massResolver.SetCommands(AdapterCommand.Update);
                docResolver.SetCommands(AdapterCommand.Update);

                DateTime current = DateTime.Now;
                row.BeginEdit();
                row["SendFlag"] = 4;
                row["SendDate"] = row["UpdateDate"] = current;
                row["SendId"] = row["UpdateId"] = BaseGlobalVariable.UserId;
                row.EndEdit();

                MpNewsMassMessage msg = new MpNewsMassMessage();
                string basePath = Path.Combine(BaseAppSetting.Current.AppPath, @"..\pic\sys\");
                string path = Path.Combine(basePath, "hzwtitle.jpg");
                //MediaId mId = WeUtil.UploadFile(MediaType.Image, path);
                string mediaId = WeDataUtil.GetMediaId(MediaType.Image, path);
                DataRow docRow = UpdateDocRow(docResolver, row, current, 4);
                msg.AddArticle(CreateArticle(docRow, mediaId));

                detailResolver.SelectWithParam(string.Empty, "ORDER BY WMD_ORDER_NUM",
                    "MassId", input.QueryString["MassId"]);
                DataTable childTable = detailResolver.HostTable;
                if (childTable != null)
                {
                    foreach (DataRow childRow in childTable.Rows)
                    {
                        docRow = UpdateDocRow(docResolver, childRow, current, 2);
                        path = Path.Combine(basePath, string.Format("A{0}.jpg", docRow["Catelog"]));
                        mediaId = WeDataUtil.GetMediaId(MediaType.Image, path);
                        msg.AddArticle(CreateArticle(docRow, mediaId));
                    }
                }

                UpdateUtil.UpdateTableResolvers(null, docResolver, massResolver);

                var media_Id = msg.UploadMessage();
                var users = WeFanContainter.GetAllUsers();

                var result = msg.Send(users);
                if (result > 0)
                    return OutputData.Create("0");

                return OutputData.Create("-1");
            }
        }
 private static DataRow UpdateDocRow(TaxDocumentResolver docResolver, DataRow row, DateTime current, int flag)
 {
     DataRow docRow = docResolver.SelectRowWithKeys(row["DocId"]);
     docRow.BeginEdit();
     if (flag == 4)
         docRow["MassFlag"] = flag;
     else
     {
         int oldFlag = docRow["MassFlag"].Value<int>();
         if (oldFlag < flag)
             docRow["MassFlag"] = flag;
     }
     docRow["MassDate"] = current;
     docRow.EndEdit();
     return docRow;
 }
예제 #9
0
        private static DataRow UpdateDocRow(TaxDocumentResolver docResolver, DataRow row, DateTime current, int flag)
        {
            DataRow docRow = docResolver.SelectRowWithKeys(row["DocId"]);

            docRow.BeginEdit();
            if (flag == 4)
            {
                docRow["MassFlag"] = flag;
            }
            else
            {
                int oldFlag = docRow["MassFlag"].Value <int>();
                if (oldFlag < flag)
                {
                    docRow["MassFlag"] = flag;
                }
            }
            docRow["MassDate"] = current;
            docRow.EndEdit();
            return(docRow);
        }
예제 #10
0
        public override OutputData DoAction(IInputData input)
        {
            try
            {
                string docId = input.QueryString["DocId"];
                using (TaxDocumentResolver destResolver = new TaxDocumentResolver(this))
                {
                    DataRow row = destResolver.TrySelectRowWithParam("SourceId", docId);
                    if (row != null)
                    {
                        throw new WebPostException("已经复制过该文档!");
                    }

                    var toolSource = new EmptyDbDataSource()
                    {
                        Context = DbContextUtil.CreateDbContext("Tools")
                    };
                    using (toolSource)
                        using (var srcResolver = new TaxDocumentResolver(toolSource))
                            using (var srcAttachResolver = new DocAttachmentResolver(toolSource))
                                using (var destAttachResolver = new DocAttachmentResolver(this))
                                {
                                    srcResolver.SelectWithKeys(docId);
                                    srcAttachResolver.SelectWithParam("DocId", docId);

                                    DataSetUtil.CopyDataTable(srcResolver.HostTable, destResolver.HostTable);
                                    destResolver.SetCommands(AdapterCommand.Insert);
                                    string id       = null;
                                    string keyField = destResolver.KeyField;
                                    foreach (DataRow destRow in destResolver.HostTable.Rows)
                                    {
                                        id = destResolver.CreateUniId();
                                        destRow.BeginEdit();
                                        destRow["SourceId"] = destRow[keyField];
                                        destRow[keyField]   = id;
                                        destRow.EndEdit();
                                    }

                                    DataTable attachTable = srcAttachResolver.HostTable;
                                    if (attachTable == null)
                                    {
                                        UpdateUtil.UpdateTableResolvers(null, destResolver);
                                    }
                                    else
                                    {
                                        DataTable destAttachTable = destAttachResolver.SelectTableStructure();
                                        DataSetUtil.CopyDataTable(attachTable, destAttachTable);
                                        foreach (DataRow attachRow in destAttachTable.Rows)
                                        {
                                            attachRow.BeginEdit();
                                            attachRow["AttId"] = destAttachResolver.CreateUniId();
                                            attachRow["DocId"] = id;
                                            attachRow.EndEdit();
                                        }
                                        destAttachResolver.SetCommands(AdapterCommand.Insert);
                                        UpdateUtil.UpdateTableResolvers(null, destResolver, destAttachResolver);
                                    }
                                    return(OutputData.CreateToolkitObject(destResolver.CreateKeyData()));
                                }
                }
            }
            catch (WebPostException ex)
            {
                return(OutputData.CreateToolkitObject(ex.CreateErrorResult()));
            }
        }
예제 #11
0
        public override OutputData DoAction(IInputData input)
        {
            try
            {
                string docId = input.QueryString["DocId"];
                using (TaxDocumentResolver destResolver = new TaxDocumentResolver(this))
                {
                    DataRow row = destResolver.TrySelectRowWithParam("SourceId", docId);
                    if (row != null)
                        throw new WebPostException("已经复制过该文档!");

                    var toolSource = new EmptyDbDataSource()
                    {
                        Context = DbContextUtil.CreateDbContext("Tools")
                    };
                    using (toolSource)
                    using (var srcResolver = new TaxDocumentResolver(toolSource))
                    using (var srcAttachResolver = new DocAttachmentResolver(toolSource))
                    using (var destAttachResolver = new DocAttachmentResolver(this))
                    {
                        srcResolver.SelectWithKeys(docId);
                        srcAttachResolver.SelectWithParam("DocId", docId);

                        DataSetUtil.CopyDataTable(srcResolver.HostTable, destResolver.HostTable);
                        destResolver.SetCommands(AdapterCommand.Insert);
                        string id = null;
                        string keyField = destResolver.KeyField;
                        foreach (DataRow destRow in destResolver.HostTable.Rows)
                        {
                            id = destResolver.CreateUniId();
                            destRow.BeginEdit();
                            destRow["SourceId"] = destRow[keyField];
                            destRow[keyField] = id;
                            destRow.EndEdit();
                        }

                        DataTable attachTable = srcAttachResolver.HostTable;
                        if (attachTable == null)
                        {
                            UpdateUtil.UpdateTableResolvers(null, destResolver);
                        }
                        else
                        {
                            DataTable destAttachTable = destAttachResolver.SelectTableStructure();
                            DataSetUtil.CopyDataTable(attachTable, destAttachTable);
                            foreach (DataRow attachRow in destAttachTable.Rows)
                            {
                                attachRow.BeginEdit();
                                attachRow["AttId"] = destAttachResolver.CreateUniId();
                                attachRow["DocId"] = id;
                                attachRow.EndEdit();
                            }
                            destAttachResolver.SetCommands(AdapterCommand.Insert);
                            UpdateUtil.UpdateTableResolvers(null, destResolver, destAttachResolver);
                        }
                        return OutputData.CreateToolkitObject(destResolver.CreateKeyData());
                    }
                }
            }
            catch (WebPostException ex)
            {
                return OutputData.CreateToolkitObject(ex.CreateErrorResult());
            }
        }