Exemple #1
0
        /// <summary>
        /// 填充对于指定功能模块数据的同步到其他站点的历史记录
        /// </summary>
        /// <param name="userHandle"></param>
        /// <param name="dt"></param>
        /// <param name="progId"></param>
        /// <param name="internalId">内码</param>
        public static void FillSyncDataHistory(LibHandle userHandle, DataTable dt, string progId, string internalId)
        {
            if (userHandle == null || dt == null || string.IsNullOrEmpty(progId) || ExistAxpSyncDataInfo == false || ExistLinkSiteTable == false)
            {
                return;
            }
            try
            {
                if (string.IsNullOrEmpty(internalId) == false)
                {
                    string sql = string.Format("select A.*,C.PERSONNAME,D.SHORTNAME from AXPSYNCDATAHISTORY A " +
                                               " left join AXPUSER B on A.USERID = B.USERID " +
                                               " left join COMPERSON C on B.PERSONID = C.PERSONID " +
                                               " left join AXPLINKSITE D on A.SITEID = D.SITEID " +
                                               " where A.PROGID = {0} and A.INTERNALID = {1} " +
                                               " order by A.SYNCTIME desc",// 时间降序
                                               LibStringBuilder.GetQuotString(progId), LibStringBuilder.GetQuotString(internalId));
                    LibDataAccess dataAccess = new LibDataAccess();
                    dataAccess.ExecuteDataTable(sql, dt, true, 200);//取前200条
                }

                dt.AcceptChanges();
            }
            catch (Exception exp)
            {
                LibCommUtils.AddOutput(@"Error\CrossSiteCall", string.Format("error:{0}\r\nStacktrace:{1}", exp.Message, exp.StackTrace));
            }
        }
Exemple #2
0
        private void GetQueryData(LibQueryCondition condition)
        {
            string conditionStr = string.Empty;

            if (condition != null && condition.QueryFields.Count != 0)
            {
                conditionStr = LibQueryConditionParser.GetQueryData(this.ProgId, condition);
            }
            //else
            //{  //当用户不选择查询条件的时候,使用默认的过滤条件
            //    conditionStr = GetFilterCondition();
            //}
            string powerStr = LibPermissionControl.Default.GetShowCondition(this.Handle, this.ProgId, this.Handle.PersonId);

            if (!string.IsNullOrEmpty(powerStr))
            {
                conditionStr = LibStringBuilder.JoinStringList(new List <string> {
                    conditionStr, powerStr
                }, "and");
            }
            if (string.IsNullOrEmpty(conditionStr))
            {
                if (condition != null)
                {
                    DataSetManager.GetDataSet(this.DataSet, this.DataAccess, this.ProgId);
                }
            }
            else
            {
                SqlBuilder    sqlBuilder = new SqlBuilder(this.ProgId);
                List <string> sqlList    = new List <string>();
                LibDataAccess dataAccess = new LibDataAccess();
                for (int i = 0; i < this.DataSet.Tables.Count; i++)
                {
                    string sql = sqlBuilder.GetQuerySql(0, string.Format("{0}.*", (char)(i + (int)'A')), conditionStr);
                    dataAccess.ExecuteDataTable(sql, this.DataSet.Tables[i]);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 填充指定用户对于指定功能模块数据的同步到其他站点的配置,如果没有则构造配置
        /// </summary>
        /// <param name="userHandle"></param>
        /// <param name="dt"></param>
        /// <param name="progId"></param>
        public static void FillSyncDataSetting(LibHandle userHandle, DataTable dt, string progId)
        {
            if (userHandle == null || dt == null || string.IsNullOrEmpty(progId) || ExistAxpSyncDataInfo == false || ExistLinkSiteTable == false)
            {
                return;
            }
            //构建当前用户对所有站点的同步选项
            Dictionary <string, LinkSiteInfo> linkSites = GetLinkSites(null, true);

            if (linkSites == null || linkSites.Count == 0)
            {
                return;
            }
            string siteIdStrs = string.Empty;

            foreach (string key in linkSites.Keys)
            {
                siteIdStrs += LibStringBuilder.GetQuotString(key) + ",";
            }
            siteIdStrs = siteIdStrs.Substring(0, siteIdStrs.Length - 1);
            try
            {
                string sql = string.Format("select A.*,C.PERSONNAME,D.SHORTNAME from AXPSYNCDATASETTING A " +
                                           " left join AXPUSER B on A.USERID = B.USERID " +
                                           " left join COMPERSON C on B.PERSONID = C.PERSONID " +
                                           " left join AXPLINKSITE D on A.SITEID = D.SITEID " +
                                           " where A.PROGID = {0} and A.USERID = {1} and A.SITEID in ({2})" +
                                           " order by A.SITEID asc",// 站点代码升序
                                           LibStringBuilder.GetQuotString(progId), LibStringBuilder.GetQuotString(userHandle.UserId), siteIdStrs);
                LibDataAccess dataAccess = new LibDataAccess();
                dataAccess.ExecuteDataTable(sql, dt);
                DataRow[] rows = null;
                if (dt.Rows.Count < linkSites.Count)
                {
                    if (linkSites != null && linkSites.Count > 0)
                    {
                        dt.BeginLoadData();
                        try
                        {
                            DataRow newRow = null;
                            foreach (string key in linkSites.Keys)
                            {
                                rows = dt.Select(string.Format("SITEID = {0}", LibStringBuilder.GetQuotString(key)));
                                if (rows == null || rows.Length == 0)
                                {
                                    //对于没有配置的站点,增加默认配置 并保存到数据库
                                    newRow = dt.NewRow();
                                    newRow.BeginEdit();
                                    Guid guid = Guid.NewGuid();
                                    newRow["SETTINGID"] = guid.ToString();
                                    newRow["PROGID"]    = progId;
                                    newRow["USERID"]    = userHandle.UserId;
                                    newRow["ISSYNCTO"]  = linkSites[key].IsSlave ? 1 : 0;//默认仅向子站点同步
                                    newRow["SITEID"]    = key;
                                    newRow["SHORTNAME"] = linkSites[key].ShortName;
                                    newRow.EndEdit();
                                    dt.Rows.Add(newRow);

                                    string insertSql = string.Format("insert into AXPSYNCDATASETTING(SETTINGID,PROGID,USERID,ISSYNCTO,SITEID) "
                                                                     + "values({0},{1},{2},{3},{4})",
                                                                     LibStringBuilder.GetQuotString(guid.ToString()),
                                                                     LibStringBuilder.GetQuotString(progId),
                                                                     LibStringBuilder.GetQuotString(userHandle.UserId),
                                                                     linkSites[key].IsSlave ? 1 : 0,//默认仅向子站点同步
                                                                     LibStringBuilder.GetQuotString(key)
                                                                     );
                                    dataAccess.ExecuteNonQuery(insertSql);
                                }
                            }
                        }
                        finally
                        {
                            dt.EndLoadData();
                        }
                    }
                }

                dt.AcceptChanges();
            }
            catch (Exception exp)
            {
                LibCommUtils.AddOutput(@"Error\CrossSiteCall", string.Format("error:{0}\r\nStacktrace:{1}", exp.Message, exp.StackTrace));
            }
        }