Ejemplo n.º 1
0
        public static void LogAction(BusinessObject obj, String ViewDesc, String Action)
        {
            Guid iID = BusinessObjectHelper.GetIDValue(obj);

            if (iID == Guid.Empty)
            {
                return;
            }

            String strNo        = BusinessObjectHelper.GetNoValue(obj);
            String strRemark    = BusinessObjectHelper.GetRemarkValue(obj);
            String strTableDesc = DataConfigProvider.GetTableCaption(obj.AATableName);

            LogAction(obj.AATableName, iID, strNo, strRemark, strTableDesc, ViewDesc, Action);
        }
Ejemplo n.º 2
0
        public static void CreateNewNotifyFromComment(String strUser, String strTableName, Guid iID)
        {
            if (strUser != ABCUserProvider.CurrentUserName)
            {
                String strTitle      = DataConfigProvider.GetTableCaption(strTableName);
                String strDisplayCol = DataStructureProvider.GetDisplayColumn(strTableName);
                String strIDCol      = DataStructureProvider.GetPrimaryKeyColumn(strTableName);

                object obj = BusinessObjectController.GetData(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}' ", strDisplayCol, strTableName, strIDCol, iID));
                if (obj != null && obj != DBNull.Value)
                {
                    strTitle = strTitle + " : " + obj.ToString();
                }
                CreateNewNotify(strUser, strTitle, "", strTableName, iID, "");
            }
        }
Ejemplo n.º 3
0
        public static void SynchronizeFieldPermission( )
        {
            GEPermissionFieldsController permissionCtrl = new GEPermissionFieldsController();
            String strQuery = String.Format(@"DELETE FROM GEPermissionFields WHERE FK_GEPermissionID NOT IN (SELECT GEPermissionID FROM GEPermissions)");

            BusinessObjectController.RunQuery(strQuery);

            foreach (GEPermissionsInfo permission in new GEPermissionsController().GetListAllObjects())
            {
                #region Field
                Dictionary <String, GEPermissionFieldsInfo> lstFields = new Dictionary <string, GEPermissionFieldsInfo>();

                foreach (GEPermissionFieldsInfo fieldInfo in permissionCtrl.GetListByForeignKey("FK_GEPermissionID", permission.GEPermissionID).Cast <GEPermissionFieldsInfo>().ToList())
                {
                    if (lstFields.ContainsKey(fieldInfo.FieldName) == false)
                    {
                        String strTableCaption = DataConfigProvider.GetTableCaption(fieldInfo.TableName);
                        String strFieldCaption = DataConfigProvider.GetFieldCaption(fieldInfo.TableName, fieldInfo.FieldName);

                        if (DataStructureProvider.IsTableColumn(fieldInfo.TableName, fieldInfo.FieldName) &&
                            strTableCaption != String.Empty && strTableCaption != fieldInfo.TableName &&
                            strFieldCaption != String.Empty && strFieldCaption != fieldInfo.FieldName)
                        {
                            lstFields.Add(fieldInfo.TableName + fieldInfo.FieldName, fieldInfo);
                        }
                        else
                        {
                            permissionCtrl.DeleteObject(fieldInfo);
                        }
                    }
                }


                foreach (String strTableName in DataStructureProvider.DataTablesList.Keys)
                {
                    foreach (String strFieldName in DataStructureProvider.DataTablesList[strTableName].ColumnsList.Keys)
                    {
                        if (DataStructureProvider.IsPrimaryKey(strTableName, strFieldName))
                        {
                            continue;
                        }

                        if (lstFields.ContainsKey(strTableName + strFieldName) == false)
                        {
                            GEPermissionFieldsInfo fieldInfo = new GEPermissionFieldsInfo();
                            fieldInfo.FK_STFieldConfigID = DataConfigProvider.TableConfigList[strTableName].FieldConfigList[strFieldName].ConfigID;
                            fieldInfo.FK_STTableConfigID = DataConfigProvider.TableConfigList[strTableName].ConfigID;
                            fieldInfo.TableName          = strTableName;
                            fieldInfo.FieldName          = strFieldName;
                            fieldInfo.FK_GEPermissionID  = permission.GEPermissionID;
                            fieldInfo.AllowView          = true;
                            fieldInfo.AllowEdit          = true;

                            permissionCtrl.CreateObject(fieldInfo);
                            lstFields.Add(fieldInfo.TableName + fieldInfo.FieldName, fieldInfo);
                        }
                    }
                }
                #endregion
            }
        }
Ejemplo n.º 4
0
        public static void CreateNewNotifyFromComment(String strTableName, Guid iID)
        {
            if (DataStructureProvider.IsExistedTable(strTableName) == false)
            {
                return;
            }

            String strIDCol = DataStructureProvider.GetPrimaryKeyColumn(strTableName);

            #region Get Users
            List <String> lstUsers = new List <string>();
            DataSet       ds       = BusinessObjectController.RunQuery(String.Format(@"SELECT CreateUser FROM GEComments WHERE TableName ='{0}' AND ID = '{1}' GROUP BY CreateUser", strTableName, iID));
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (lstUsers.Contains(dr[0].ToString()) == false)
                    {
                        lstUsers.Add(dr[0].ToString());
                    }
                }
            }
            ds = BusinessObjectController.RunQuery(String.Format(@"SELECT TagString FROM GEComments WHERE TableName ='{0}' AND ID = '{1}'  AND TagString IS NOT NULL AND TagString NOT LIKE '' GROUP BY TagString", strTableName, iID));
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr[0] != null && dr[0] != DBNull.Value && String.IsNullOrWhiteSpace(dr[0].ToString()) == false)
                    {
                        string[] arr = { "::" };
                        arr = dr[0].ToString().Split(arr, StringSplitOptions.None);
                        for (int i = 0; i < arr.Length; i++)
                        {
                            if (lstUsers.Contains(arr[i]) == false)
                            {
                                lstUsers.Add(arr[i]);
                            }
                        }
                    }
                }
            }



            if (DataStructureProvider.IsTableColumn(strTableName, ABCCommon.ABCConstString.colCreateUser))
            {
                ds = BusinessObjectController.RunQuery(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}'", ABCCommon.ABCConstString.colCreateUser, strTableName, strIDCol, iID));
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    object objCreateUser = ds.Tables[0].Rows[0][0];
                    if (objCreateUser != null && objCreateUser != DBNull.Value && lstUsers.Contains(objCreateUser.ToString()) == false)
                    {
                        lstUsers.Add(objCreateUser.ToString());
                    }
                }
            }
            if (DataStructureProvider.IsTableColumn(strTableName, ABCCommon.ABCConstString.colUpdateUser))
            {
                ds = BusinessObjectController.RunQuery(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}'", ABCCommon.ABCConstString.colUpdateUser, strTableName, strIDCol, iID));
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    object objUpdateUser = ds.Tables[0].Rows[0][0];
                    if (objUpdateUser != null && objUpdateUser != DBNull.Value && lstUsers.Contains(objUpdateUser.ToString()) == false)
                    {
                        lstUsers.Add(objUpdateUser.ToString());
                    }
                }
            }

            #endregion

            String strTitle      = DataConfigProvider.GetTableCaption(strTableName);
            String strDisplayCol = DataStructureProvider.GetDisplayColumn(strTableName);

            object obj = BusinessObjectController.GetData(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}' ", strDisplayCol, strTableName, strIDCol, iID));
            if (obj != null && obj != DBNull.Value)
            {
                strTitle = strTitle + " : " + obj.ToString();
            }

            foreach (String strUser in lstUsers)
            {
                if (strUser != ABCUserProvider.CurrentUserName)
                {
                    CreateNewNotify(strUser, strTitle, "", strTableName, iID, "");
                }
            }
        }
Ejemplo n.º 5
0
        public static String GenerateNo(BusinessObject obj)
        {
            if (obj.GetID() == Guid.Empty)
            {
                obj.SetNoValue(String.Empty);
                return(String.Empty);
            }

            String strNoValue = String.Empty;

            Numbering numbering = GetNumberingConfig(obj);

            if (numbering != null)
            {
                if (!numbering.IsUsePattern)
                {
                    #region Not UsePattern
                    if (numbering.MiddleConfigs.Count > 0)
                    {
                        #region Have Parts
                        List <String> lstParts = new List <string>();
                        foreach (NumberingType numberType in numbering.MiddleConfigs)
                        {
                            #region Others
                            if (numberType.IsByUser)
                            {
                            }
                            if (numberType.IsByUserGroup)
                            {
                            }
                            if (numberType.IsByEmployee)
                            {
                            }
                            if (numberType.IsByCompanyUnit)
                            {
                            }
                            #endregion

                            if ((numberType.IsYYMMCount || numberType.IsYYMMDDCount || numberType.IsMMDDCount))
                            {
                                String strDateCol = String.Empty;
                                if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateTime))
                                {
                                    strDateCol = ABCCommon.ABCConstString.colCreateTime;
                                }
                                if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colDocumentDate))
                                {
                                    strDateCol = ABCCommon.ABCConstString.colDocumentDate;
                                }

                                if (!String.IsNullOrWhiteSpace(strDateCol))
                                {
                                    object objValue = ABCDynamicInvoker.GetValue(obj, strDateCol);
                                    if (objValue != null && (objValue is DateTime || (objValue is Nullable <DateTime> && (objValue as Nullable <DateTime>).HasValue)))
                                    {
                                        #region With DateTime
                                        DateTime createTime = DateTime.MinValue;
                                        if (objValue is Nullable <DateTime> )
                                        {
                                            createTime = (objValue as Nullable <DateTime>).Value;
                                        }
                                        else
                                        {
                                            createTime = Convert.ToDateTime(objValue);
                                        }

                                        if (numberType.IsYYMMCount)
                                        {
                                            String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false);
                                            strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND {0} < {3}", strDateCol, createTime.Year, createTime.Month, TimeProvider.GenDateTimeString(createTime)));
                                            int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery));
                                            if (iCount <= 0)
                                            {
                                                iCount = 0;
                                            }
                                            iCount++;


                                            int iCountSpace = numberType.CountingSpace;
                                            if (iCountSpace < iCount.ToString().Length)
                                            {
                                                iCountSpace = iCount.ToString().Length + 2;
                                            }

                                            String strTemp = createTime.ToString("yyMM") + String.Format("{0:D" + iCountSpace + "}", iCount);
                                            lstParts.Add(strTemp);
                                        }
                                        if (numberType.IsYYMMDDCount)
                                        {
                                            String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false);
                                            strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND DAY({0}) = {3} AND {0} < {4}", strDateCol, createTime.Year, createTime.Month, createTime.Day, TimeProvider.GenDateTimeString(createTime)));
                                            int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery));
                                            if (iCount <= 0)
                                            {
                                                iCount = 0;
                                            }
                                            iCount++;

                                            int iCountSpace = numberType.CountingSpace;
                                            if (iCountSpace < iCount.ToString().Length)
                                            {
                                                iCountSpace = iCount.ToString().Length + 2;
                                            }

                                            String strTemp = createTime.ToString("yyMMdd") + String.Format("{0:D" + iCountSpace + "}", iCount);
                                            lstParts.Add(strTemp);
                                        }
                                        if (numberType.IsMMDDCount)
                                        {
                                            String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false);
                                            strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND DAY({0}) = {3} AND {0} < {4}", strDateCol, createTime.Year, createTime.Month, createTime.Day, TimeProvider.GenDateTimeString(createTime)));
                                            int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery));
                                            if (iCount <= 0)
                                            {
                                                iCount = 0;
                                            }
                                            iCount++;

                                            int iCountSpace = numberType.CountingSpace;
                                            if (iCountSpace < iCount.ToString().Length)
                                            {
                                                iCountSpace = iCount.ToString().Length + 2;
                                            }

                                            String strTemp = createTime.ToString("MMdd") + String.Format("{0:D" + iCountSpace + "}", iCount);
                                            lstParts.Add(strTemp);
                                        }
                                        #endregion
                                    }
                                }
                            }

                            #region By Field
                            if (numberType.IsByField && !String.IsNullOrWhiteSpace(numberType.FieldName))
                            {
                                if (DataStructureProvider.IsTableColumn(obj.AATableName, numberType.FieldName))
                                {
                                    object objValue = ABCDynamicInvoker.GetValue(obj, numberType.FieldName);
                                    if (objValue != null)
                                    {
                                        if (DataStructureProvider.IsForeignKey(obj.AATableName, numberType.FieldName))
                                        {
                                            String strFieldName = numberType.FieldName + ":" + DataStructureProvider.GetDisplayColumn(obj.AATableName);
                                            objValue = DataCachingProvider.GetCachingObjectAccrossTable(obj, ABCHelper.DataConverter.ConvertToGuid(objValue), strFieldName);
                                        }

                                        lstParts.Add(objValue.ToString());
                                    }
                                }
                            }
                            #endregion
                        }

                        strNoValue = numbering.Prefix + String.Join(numbering.SeperateChar, lstParts) + numbering.Suffix;

                        #endregion
                    }
                    else
                    {
                        String strDateCol = String.Empty;
                        if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateTime))
                        {
                            strDateCol = ABCCommon.ABCConstString.colCreateTime;
                        }
                        if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colDocumentDate))
                        {
                            strDateCol = ABCCommon.ABCConstString.colDocumentDate;
                        }

                        if (!String.IsNullOrWhiteSpace(strDateCol))
                        {
                            object objValue = ABCDynamicInvoker.GetValue(obj, strDateCol);
                            if (objValue != null && (objValue is DateTime || (objValue is Nullable <DateTime> && (objValue as Nullable <DateTime>).HasValue)))
                            {
                                #region With DateTime
                                DateTime createTime = DateTime.MinValue;
                                if (objValue is Nullable <DateTime> )
                                {
                                    createTime = (objValue as Nullable <DateTime>).Value;
                                }
                                else
                                {
                                    createTime = Convert.ToDateTime(objValue);
                                }

                                String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false);
                                strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND {0} < {3}", strDateCol, createTime.Year, createTime.Month, TimeProvider.GenDateTimeString(createTime)));
                                int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery));
                                if (iCount <= 0)
                                {
                                    iCount = 0;
                                }
                                iCount++;

                                int iCountSpace = 3;
                                if (iCountSpace < iCount.ToString().Length)
                                {
                                    iCountSpace = iCount.ToString().Length + 2;
                                }

                                strNoValue = numbering.Prefix + createTime.ToString("yyMM") + String.Format("{0:D" + iCountSpace + "}", iCount) + numbering.Suffix;

                                #endregion
                            }
                        }
                        else if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colNoIndex))
                        {
                            int iNoIndex    = Convert.ToInt32(ABCDynamicInvoker.GetValue(obj, ABCCommon.ABCConstString.colNoIndex));
                            int iCountSpace = 4;
                            if (iNoIndex >= 10000)
                            {
                                iCountSpace = iNoIndex.ToString().Length + 2;
                            }
                            strNoValue = numbering.Prefix + String.Format("{0:D" + iCountSpace + "}", iNoIndex) + numbering.Suffix;
                        }
                    }
                    #endregion
                }
                else
                {
                    #region UsePattern

                    #endregion
                }
            }
            else
            {
                #region Have No Config
                if (!String.IsNullOrWhiteSpace(DataConfigProvider.TableConfigList[obj.AATableName].PrefixNo))
                {
                    strNoValue = DataConfigProvider.TableConfigList[obj.AATableName].PrefixNo;
                }
                else
                {
                    strNoValue = new Regex("[^A-Z]+").Replace(DataConfigProvider.GetTableCaption(obj.AATableName), "");
                }


                String strDateCol = String.Empty;
                if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateTime))
                {
                    strDateCol = ABCCommon.ABCConstString.colCreateTime;
                }
                if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colDocumentDate))
                {
                    strDateCol = ABCCommon.ABCConstString.colDocumentDate;
                }

                if (!String.IsNullOrWhiteSpace(strDateCol))
                {
                    object objValue = ABCDynamicInvoker.GetValue(obj, strDateCol);
                    if (objValue != null && (objValue is DateTime || (objValue is Nullable <DateTime> && (objValue as Nullable <DateTime>).HasValue)))
                    {
                        #region With DateTime
                        DateTime createTime = DateTime.MinValue;
                        if (objValue is Nullable <DateTime> )
                        {
                            createTime = (objValue as Nullable <DateTime>).Value;
                        }
                        else
                        {
                            createTime = Convert.ToDateTime(objValue);
                        }

                        String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false);
                        strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND {0} < {3}", strDateCol, createTime.Year, createTime.Month, TimeProvider.GenDateTimeString(createTime)));
                        int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery));
                        if (iCount <= 0)
                        {
                            iCount = 0;
                        }
                        iCount++;

                        int iCountSpace = 3;
                        if (iCountSpace < iCount.ToString().Length)
                        {
                            iCountSpace = iCount.ToString().Length + 2;
                        }

                        strNoValue += createTime.ToString("yyMM") + String.Format("{0:D" + iCountSpace + "}", iCount);

                        #endregion
                    }
                }
                else if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colNoIndex))
                {
                    int iNoIndex    = Convert.ToInt32(ABCDynamicInvoker.GetValue(obj, ABCCommon.ABCConstString.colNoIndex));
                    int iCountSpace = 4;
                    if (iNoIndex >= 10000)
                    {
                        iCountSpace = iNoIndex.ToString().Length + 2;
                    }
                    strNoValue += String.Format("{0:D" + iCountSpace + "}", iNoIndex);
                }

                #endregion
            }

            obj.SetNoValue(strNoValue);
            return(strNoValue);
        }