Beispiel #1
0
        public static GroupSchemas GetSchemas(
            string xml,
            string localeid)
        {
            XmlDocument doc = null;

            if (!string.IsNullOrEmpty(xml))
            {
                doc = new XmlDocument();
                doc.LoadXml(xml);
            }
            return(GroupSchemas.GetSchemas(doc, localeid));
        }
Beispiel #2
0
        public static void InitializeCross(
            Report report,
            XmlDocument schemaXmlDoc,
            string localeid)
        {
            report.CrossSchemas = GroupSchemas.GetSchemas(schemaXmlDoc, localeid, true);

            // 设置当前分组ID
            if (report.CurrentCrossSchema == null)
            {
                report.CurrentCrossID = report.CrossSchemas[0].ID;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 产生分组对象
        /// </summary>
        /// <param name="report">报表结构对象</param>
        /// <param name="schemaXmlDoc">存储报表结构对象信息的XmlDocument</param>
        /// <param name="detailtype">对应的报表区域</param>
        /// <param name="localeid">当前的语言区域</param>
        public static void Initialize(
            Report report,
            XmlDocument schemaXmlDoc,
            SectionType detailtype,
            string localeid)
        {
            report.GroupSchemas = GroupSchemas.GetSchemas(schemaXmlDoc, localeid);

            // 设置当前分组ID
            if (report.CurrentSchema == null)
            {
                report.CurrentSchemaID = report.GroupSchemas[0].ID;
            }
        }
        public string SaveCrossSchemasWithLock(U8LoginInfor login, string viewID, string crossSchemas, string actionType)
        {
            //1开一个新的连接,并开事务
            SqlConnection cnn = new SqlConnection(login.UfMetaCnnString);

            cnn.Open();
            SqlTransaction tran   = cnn.BeginTransaction();
            string         result = string.Empty;

            try
            {
                //21 首先获取当前数据库的groupSchemas,并构造要保存的groupSchemas
                XmlDocument  doc = this.GetCrossSchemasWithXLock(viewID, tran); //tran
                GroupSchemas haveSaveCrossSchemas = GroupSchemas.GetSchemas(doc, "");
                GroupSchemas toSaveCrossSchemas   = GroupSchemas.GetSchemasNoSetDefaultSchema(crossSchemas, "");
                //3然后每一个groupSchema做对比
                if (toSaveCrossSchemas.Count <= 0)
                {
                    return(toSaveCrossSchemas.ToXml().InnerXml);
                }
                GroupSchema cs = toSaveCrossSchemas[0];//要更新的
                foreach (GroupSchema group in toSaveCrossSchemas)
                {
                    if (group.ID != NOGROUPID)
                    {
                        cs = group;
                    }
                }
                GroupSchema oldGs = GetGroupSchemaById(haveSaveCrossSchemas, cs.ID);//数据库中已经有的
                switch (actionType.ToLower().Trim())
                {
                case "delete":
                    if (oldGs == null)
                    {
                        throw new ResourceReportException(String4Report.GetString("U8.UAP.Services.ReportData.ReportDataFacade.Delete.Ex", login.LocaleID));    //"没有权限"
                        //throw new Exception(String4Report.GetString("操作失败,别人已经删除"));
                    }
                    haveSaveCrossSchemas.Remove(oldGs);
                    break;

                case "add":
                    if (HaveSameName(haveSaveCrossSchemas, cs))
                    {
                        throw new ResourceReportException(String4Report.GetString("U8.UAP.Services.ReportData.ReportDataFacade.Add.Ex", login.LocaleID));
                        //throw new Exception(String4Report.GetString("存在重名的分组/交叉,请再次打开报表后更改"));
                    }
                    cs.GuidVersion = Guid.NewGuid().ToString();
                    haveSaveCrossSchemas.Add(cs);
                    SetOtherSchemaBDefault(haveSaveCrossSchemas, cs);
                    break;

                case "modify":
                    if (oldGs == null)
                    {
                        throw new ResourceReportException(String4Report.GetString("U8.UAP.Services.ReportData.ReportDataFacade.Delete.Ex", login.LocaleID));    //"没有权限"
                        //throw new Exception(String4Report.GetString("操作失败,别人已经删除"));
                    }
                    //表明同一个用户在操作,不校验并发
                    if (string.IsNullOrEmpty(oldGs.LastUserGuid) || oldGs.LastUserGuid == cs.LastUserGuid)
                    {
                        if (HaveSameName(haveSaveCrossSchemas, cs))
                        {
                            throw new ResourceReportException(String4Report.GetString("U8.UAP.Services.ReportData.ReportDataFacade.Modify.Ex2", login.LocaleID));
                            //throw new Exception(String4Report.GetString("存在重名的分组/交叉,请再次打开报表后更改"));
                        }
                        haveSaveCrossSchemas.Remove(oldGs);
                        cs.GuidVersion = Guid.NewGuid().ToString();
                        haveSaveCrossSchemas.Add(cs);
                        SetOtherSchemaBDefault(haveSaveCrossSchemas, cs);
                    }
                    //表明同一个用户在操作,不校验并发
                    else
                    {
                        if (oldGs.GuidVersion == cs.GuidVersion)
                        {
                            if (HaveSameName(haveSaveCrossSchemas, cs))
                            {
                                throw new ResourceReportException(String4Report.GetString("U8.UAP.Services.ReportData.ReportDataFacade.Modify.Ex2", login.LocaleID));
                                //throw new Exception(String4Report.GetString("存在重名的分组/交叉,请再次打开报表后更改"));
                            }
                            haveSaveCrossSchemas.Remove(oldGs);
                            cs.GuidVersion = Guid.NewGuid().ToString();
                            haveSaveCrossSchemas.Add(cs);
                            SetOtherSchemaBDefault(haveSaveCrossSchemas, cs);
                        }
                        else
                        {
                            throw new ResourceReportException(String4Report.GetString("U8.UAP.Services.ReportData.ReportDataFacade.Modify.Ex3", login.LocaleID));
                            //throw new Exception(String4Report.GetString("操作失败,别人已经修改"));
                        }
                    }
                    break;

                default:
                    break;
                }
                result = haveSaveCrossSchemas.ToXml().InnerXml;
                string     sql     = "UPDATE UAP_ReportView SET PreservedField = @CrossSchemas WHERE ID=@ViewID";
                SqlCommand command = new SqlCommand(sql, cnn);
                command.Parameters.Add(new SqlParameter("CrossSchemas", result));
                command.Parameters.Add(new SqlParameter("ViewID", viewID));

                SqlHelper.ExecuteNonQuery(tran, command);
                tran.Commit();
            }
            catch (Exception e)
            {
                tran.Rollback();
                throw e;
            }
            finally
            {
                if (cnn.State == ConnectionState.Open)
                {
                    cnn.Close();
                }
            }
            return(result);
        }