Example #1
0
        bool ICommon <OrganizationInfo> .Insert(OrganizationInfo organizationInfo)
        {
            Contract.Requires <ArgumentNullException>(organizationInfo != null, "参数organizationInfo:不能为空!");
            Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(organizationInfo.OrgID), "参数organizationInfo.OrgID:不能为空!");
            bool          result   = false;
            string        message1 = string.Empty;
            string        message2 = string.Empty;
            string        message  = string.Empty;
            List <string> sqls     = new List <string>();

            sqls.Add(DBService.InsertSql(organizationInfo, out message1));
            DimOrganizationInfo dimOrg = new DimOrganizationInfo()
            {
                AreaCityID       = organizationInfo.AreaCityID,
                AreaCityName     = organizationInfo.AreaCityName,
                AreaCountryID    = organizationInfo.AreaCountryID,
                AreaCountryName  = organizationInfo.AreaCountryName,
                AreaProvinceID   = organizationInfo.AreaProvinceID,
                AreaProvinceName = organizationInfo.AreaProvinceName,
                BeginTime        = DateTime.Now,
                TradeID          = organizationInfo.TradeID,                //@Majichao 添加大行业维度 2016-07-15
                TradeName        = organizationInfo.TradeName,
                TradeSubID       = organizationInfo.TradeSubID,             //@Majichao 添加小行业维度 2016-07-15
                TradeSubName     = organizationInfo.TradeSubName,
                RegisterTypeID   = organizationInfo.RegisterTypeID,
                RegisterTypeName = organizationInfo.RegisterTypeName,
                ScaleTypeID      = organizationInfo.ScaleTypeID,
                ScaleTypeName    = organizationInfo.ScaleTypeName,
                OrgID            = organizationInfo.OrgID,
                ShareTypeID      = organizationInfo.ShareTypeID,
                ShareTypeName    = organizationInfo.ShareTypeName,
                Valid            = ((int)MiicValidTypeSetting.Valid).ToString(),
            };

            sqls.Add(DBService.InsertSql(dimOrg, out message2));
            try
            {
                result = dbService.excuteSqls(sqls, out message);
            }
            catch (Exception ex)
            {
                Config.IlogicLogService.Write(new LogicLog()
                {
                    AppName       = Config.AppName,
                    ClassName     = ClassName,
                    NamespaceName = NamespaceName,
                    MethodName    = MethodBase.GetCurrentMethod().Name,
                    Message       = ex.Message,
                    Oper          = Config.Oper
                });
            }
            if (result == true)
            {
                if (this.IsCached == true)
                {
                    InsertCache(organizationInfo);
                }
            }
            return(result);
        }
Example #2
0
        bool ICommon <OrganizationInfo> .Update(OrganizationInfo organizationInfo)
        {
            Contract.Requires <ArgumentNullException>(organizationInfo != null, "参数organizationInfo:不能为空!");
            Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(organizationInfo.OrgID), "参数organizationInfo.OrgID:不能为空,因为是主键");
            string           message = string.Empty;
            bool             result  = false;
            List <string>    sqls    = new List <string>();
            OrganizationInfo old     = ((ICommon <OrganizationInfo>) this).GetInformation(organizationInfo.OrgID);

            if ((organizationInfo.TradeID != null && organizationInfo.TradeName != old.TradeName) ||           //@Majichao IndustryCode => TradeID 2016-7-15
                (organizationInfo.TradeSubID != null && organizationInfo.TradeSubName != old.TradeSubName) ||
                (organizationInfo.RegisterTypeID != null && organizationInfo.RegisterTypeID != old.RegisterTypeID) ||
                (organizationInfo.ShareTypeID != null && organizationInfo.ShareTypeID != old.ShareTypeID) ||
                (organizationInfo.ScaleTypeID != null && organizationInfo.ScaleTypeID != old.ScaleTypeID) ||
                (organizationInfo.AreaProvinceID != null && organizationInfo.AreaProvinceID != old.AreaProvinceID) ||
                (organizationInfo.AreaCityID != null && organizationInfo.AreaCityID != old.AreaCityID) ||
                (organizationInfo.AreaCountryID != null && organizationInfo.AreaCountryID != old.AreaCountryID)
                )
            {
                string message1 = string.Empty;
                string message2 = string.Empty;
                string message3 = string.Empty;
                sqls.Add(DBService.UpdateSql(organizationInfo, out message1));
                MiicConditionCollections condition      = new MiicConditionCollections(MiicDBLogicSetting.No);
                MiicCondition            orgIDCondition = new MiicCondition(Config.Attribute.GetSqlColumnNameByPropertyName <DimOrganizationInfo, string>(o => o.OrgID),
                                                                            organizationInfo.OrgID,
                                                                            DbType.String,
                                                                            MiicDBOperatorSetting.Equal);
                condition.Add(new MiicConditionLeaf(MiicDBLogicSetting.No, orgIDCondition));
                MiicCondition validCondition = new MiicCondition(Config.Attribute.GetSqlColumnNameByPropertyName <DimOrganizationInfo, string>(o => o.Valid),
                                                                 ((int)MiicValidTypeSetting.Valid).ToString(),
                                                                 DbType.String,
                                                                 MiicDBOperatorSetting.Equal);
                condition.Add(new MiicConditionLeaf(validCondition));
                sqls.Add(DBService.UpdateConditionsSql <DimOrganizationInfo>(new DimOrganizationInfo()
                {
                    EndTime = DateTime.Now,
                    Valid   = ((int)MiicValidTypeSetting.InValid).ToString()
                }, condition, out message3));
                DimOrganizationInfo dimOrg = new DimOrganizationInfo()
                {
                    AreaCityID       = organizationInfo.AreaCityID,
                    AreaCityName     = organizationInfo.AreaCityName,
                    AreaCountryID    = organizationInfo.AreaCountryID,
                    AreaCountryName  = organizationInfo.AreaCountryName,
                    AreaProvinceID   = organizationInfo.AreaProvinceID,
                    AreaProvinceName = organizationInfo.AreaProvinceName,
                    BeginTime        = DateTime.Now,
                    TradeID          = organizationInfo.TradeID,                //@Majichao 添加大行业维度 2016-07-15
                    TradeName        = organizationInfo.TradeName,
                    TradeSubID       = organizationInfo.TradeSubID,             //@Majichao 添加小行业维度 2016-07-15
                    TradeSubName     = organizationInfo.TradeSubName,
                    RegisterTypeID   = organizationInfo.RegisterTypeID,
                    RegisterTypeName = organizationInfo.RegisterTypeName,
                    ScaleTypeID      = organizationInfo.ScaleTypeID,
                    ScaleTypeName    = organizationInfo.ScaleTypeName,
                    OrgID            = organizationInfo.OrgID,
                    ShareTypeID      = organizationInfo.ShareTypeID,
                    ShareTypeName    = organizationInfo.ShareTypeName,
                    Valid            = ((int)MiicValidTypeSetting.Valid).ToString()
                };
                sqls.Add(DBService.InsertSql(dimOrg, out message2));
            }
            else
            {
                string message1 = string.Empty;
                sqls.Add(DBService.UpdateSql(organizationInfo, out message1));
            }
            try
            {
                result = dbService.excuteSqls(sqls, out message);
            }
            catch (Exception ex)
            {
                Config.IlogicLogService.Write(new LogicLog()
                {
                    AppName       = Config.AppName,
                    ClassName     = ClassName,
                    NamespaceName = NamespaceName,
                    MethodName    = MethodBase.GetCurrentMethod().Name,
                    Message       = ex.Message,
                    Oper          = Config.Oper
                });
            }
            if (result == true)
            {
                if (this.IsCached == true)
                {
                    DeleteCache(o => o.OrgID == organizationInfo.OrgID);
                }
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// 新增企业信息
        /// </summary>
        /// <param name="organizationInfo">企业信息</param>
        /// <param name="orgProductInfos">企业产品附件</param>
        /// <returns>Yes/No</returns>
        public bool Insert(OrganizationInfo organizationInfo, List <OrgProductInfo> orgProductInfos)
        {
            Contract.Requires <ArgumentNullException>(organizationInfo != null, "参数organizationInfo:不能为空");
            bool          result   = false;
            List <string> sqls     = new List <string>();
            string        message  = string.Empty;
            string        message1 = string.Empty;
            string        message2 = string.Empty;
            string        message3 = string.Empty;

            sqls.Add(DBService.InsertSql(organizationInfo, out message1));
            DimOrganizationInfo dimOrg = new DimOrganizationInfo()
            {
                AreaCityID       = organizationInfo.AreaCityID,
                AreaCityName     = organizationInfo.AreaCityName,
                AreaCountryID    = organizationInfo.AreaCountryID,
                AreaCountryName  = organizationInfo.AreaCountryName,
                AreaProvinceID   = organizationInfo.AreaProvinceID,
                AreaProvinceName = organizationInfo.AreaProvinceName,
                BeginTime        = DateTime.Now,
                TradeID          = organizationInfo.TradeID,                //@Majichao 添加大行业维度 2016-07-15
                TradeName        = organizationInfo.TradeName,
                TradeSubID       = organizationInfo.TradeSubID,             //@Majichao 添加小行业维度 2016-07-15
                TradeSubName     = organizationInfo.TradeSubName,
                RegisterTypeID   = organizationInfo.RegisterTypeID,
                RegisterTypeName = organizationInfo.RegisterTypeName,
                ScaleTypeID      = organizationInfo.ScaleTypeID,
                ScaleTypeName    = organizationInfo.ScaleTypeName,
                OrgID            = organizationInfo.OrgID,
                ShareTypeID      = organizationInfo.ShareTypeID,
                ShareTypeName    = organizationInfo.ShareTypeName,
                Valid            = ((int)MiicValidTypeSetting.Valid).ToString(),
            };

            sqls.Add(DBService.InsertSql(dimOrg, out message2));
            if (orgProductInfos != null && orgProductInfos.Count != 0)
            {
                sqls.Add(DBService.InsertsSql(orgProductInfos, out message3));
            }

            bool fileResult = false;

            try
            {
                try
                {
                    if (orgProductInfos != null && orgProductInfos.Count != 0)
                    {
                        foreach (var item in orgProductInfos)
                        {
                            string dest   = HttpContext.Current.Server.MapPath(item.FilePath);
                            string source = HttpContext.Current.Server.MapPath("/file/temp/OrgProduct/" + Path.GetFileName(dest));
                            File.Copy(source, dest, true);
                        }
                    }
                    fileResult = true;
                }
                catch (Exception ex)
                {
                    Config.IlogicLogService.Write(new LogicLog()
                    {
                        AppName       = Config.AppName,
                        ClassName     = ClassName,
                        NamespaceName = NamespaceName,
                        MethodName    = MethodBase.GetCurrentMethod().Name,
                        Message       = ex.Message,
                        Oper          = Config.Oper
                    });
                }

                if (fileResult == true)
                {
                    result = dbService.excuteSqls(sqls, out message);
                }
            }
            catch (Exception ex)
            {
                Config.IlogicLogService.Write(new LogicLog()
                {
                    AppName       = Config.AppName,
                    ClassName     = ClassName,
                    NamespaceName = NamespaceName,
                    MethodName    = MethodBase.GetCurrentMethod().Name,
                    Message       = ex.Message,
                    Oper          = Config.Oper
                });
            }
            if (result == true)
            {
                if (IsCached == true)
                {
                    InsertCache(organizationInfo);
                }
            }
            return(result);
        }