Esempio n. 1
0
 static GlobalConfig()
 {
     CacheType   = AppSettingHelper.Get <string>("CacheType", "cache").ToUpper();
     CacheTime   = AppSettingHelper.Get <int>("CacheTime", 120);
     SessionType = AppSettingHelper.Get <string>("SessionType", "cache").ToUpper();
     RedisPath   = AppSettingHelper.Get <string>("RedisPath");
 }
Esempio n. 2
0
 private IocContainer()
 {
     this.DBType  = AppSettingHelper.Get("DBType");
     this.Builder = new ContainerBuilder();
     this.Register(this.Builder);
     this.Container = this.Builder.Build();
 }
        public HttpResponseMessage GetZookeeperHost()
        {
            var host = AppSettingHelper.Get <string>("ZookeeperHost");

            return(new HttpResponseMessage {
                Content = new StringContent(host, Encoding.GetEncoding("UTF-8"), "text/plain")
            });
        }
Esempio n. 4
0
        public ResponseWrapper <ZooKeeperResponse> GetZookeeperHost()
        {
            var response = new ResponseWrapper <ZooKeeperResponse>();

            response.Result = new ZooKeeperResponse
            {
                Host = AppSettingHelper.Get <string>("ZookeeperHost")
            };
            return(response);
        }
Esempio n. 5
0
        /// <summary>
        /// 你猜
        /// </summary>
        /// <returns></returns>
        public static bool DBExists()
        {
            bool result = false;

            try
            {
                var path = AppSettingHelper.Get("SQLite");
            }
            catch (Exception ex)
            {
                Helper.NLogHelper.log.Error(ex.Message);
            }
            return(result);
        }
Esempio n. 6
0
        string GetTemplateUrl(DataFeedTemplate template, string fileName)
        {
            string path = Path.Combine(
                AppDomain.CurrentDomain.SetupInformation.ApplicationBase
                , AppSettingHelper.Get("DataFeedFilesTemplatePath")
                );

            template.LoadWorkbook(path);
            template.InitWorkbook();

            byte[] buf = template.GetBytes();

            return(FileUploadManager.UploadFileAndGetUrl(fileName, buf));
        }
Esempio n. 7
0
        public async Task <ActionResult> DownloadZip(string version)
        {
            var condition = new TemplateCondition
            {
                AppId   = AppId,
                EnvId   = EnvId,
                Type    = (int)ConfigType.File,
                Version = version
            };
            await _templateService.BatchCreateFile(condition);

            var fileName = DateTime.Now.ToString("yyMMddHHmmssff");

            string[] files = Directory.GetFiles(AppSettingHelper.Get <string>("FilePath")); //返回指定目录下的文件名
            Zip(files, fileName);
            return(File(AppSettingHelper.Get <string>("ZipPath") + fileName + ".zip", "application/zip", fileName + ".zip"));
        }
Esempio n. 8
0
 /// <summary>
 /// 压缩zip
 /// </summary>
 /// <param name="fileToZips">文件路径集合</param>
 /// <param name="zipedFile">想要压成zip的文件名</param>
 public void Zip(string[] fileToZips, string zipedFile)
 {
     using (ZipFile zip = new ZipFile(AppSettingHelper.Get <string>("ZipPath") + zipedFile + ".zip", Encoding.Default))
     {
         foreach (string fileToZip in fileToZips)
         {
             using (FileStream fs = new FileStream(fileToZip, FileMode.Open, FileAccess.ReadWrite))
             {
                 byte[] buffer = new byte[fs.Length];
                 fs.Read(buffer, 0, buffer.Length);
                 string fileName = fileToZip.Substring(fileToZip.LastIndexOf("\\") + 1);
                 zip.AddEntry(fileName, buffer);
             }
         }
         zip.Save();
     }
 }
Esempio n. 9
0
        /// <summary>
        /// 创建User
        /// </summary>
        /// <param name="entity">请求体</param>
        /// <returns>创建后的实体</returns>
        public VendorUser Create(VendorUser entity)
        {
            if (entity == null ||
                string.IsNullOrEmpty(entity.UserID)
                )
            {
                BizExceptionHelper.Throw("ExternalSYS_VendorUser_LoginError");
            }
            if (string.IsNullOrEmpty(entity.UserName))
            {
                BizExceptionHelper.Throw("ExternalSYS_VendorUser_LoginNameError");
            }
            if (!entity.VendorSysNo.HasValue)
            {
                BizExceptionHelper.Throw("ExternalSYS_VendorUser_SelectVendorError");
            }
            if (m_da.CountUserID(entity.UserID, 0) > 0)
            {
                BizExceptionHelper.Throw("ExternalSYS_VendorUser_ExistUserError");
            }
            if (string.IsNullOrEmpty(entity.APIKey) && entity.APIStatus == ECCentral.BizEntity.ExternalSYS.ValidStatus.Active)
            {
                entity.APIKey = RandomString(32);
            }

            entity.Pwd = Hash_MD5.GetMD5(AppSettingHelper.Get("VendorUserInitPassword"));

            entity.UserNum = m_da.CountVendorNum(entity.VendorSysNo.Value) + 1;
            entity         = m_da.InsertVendorUser(entity);
            if (entity.ManufacturerSysNoList != null && entity.ManufacturerSysNoList.Count > 0)
            {
                foreach (var ManufacturerSysNo in entity.ManufacturerSysNoList)
                {
                    m_da.InsertVendorUserVendorEx(new VendorUserMapping()
                    {
                        UserSysNo         = entity.SysNo,
                        ManufacturerSysNo = ManufacturerSysNo,
                        IsAuto            = 1,
                        VendorSysNo       = entity.VendorSysNo.Value
                    });
                }
            }
            return(entity);
        }
Esempio n. 10
0
        private RedisClientManager_Old()
        {
            try
            {
                _config = new RedisConfig()
                {
                    Host     = AppSettingHelper.Get <string>("RedisHost"),
                    Port     = AppSettingHelper.Get <int>("RedisPort"),
                    Password = AppSettingHelper.Get <string>("RedisPassword"),
                };

                RedisConfig = _config;

                //CacheClient = AppHostBase.Resolve<IRedisClientsManager>().GetClient();
            }
            catch (Exception)
            {
                this.TryGetClientFromConfig();
            }
        }
Esempio n. 11
0
        public async Task <bool> BatchCreateFile(TemplateCondition condition)
        {
            var list = await GetTemplateList(condition);

            FormatFolder(AppSettingHelper.Get <string>("FilePath"));
            FormatFolder(AppSettingHelper.Get <string>("ZipPath"));
            foreach (var item in list)
            {
                FileStream   myFs = new FileStream(AppSettingHelper.Get <string>("FilePath") + item.Name, FileMode.Create);
                StreamWriter mySw = new StreamWriter(myFs);
                if (string.IsNullOrWhiteSpace(item.ConfigValue))
                {
                    mySw.Write(item.DefaultValue);
                }
                else
                {
                    mySw.Write(item.ConfigValue);
                }
                mySw.Close();
                myFs.Close();
            }
            return(true);
        }
Esempio n. 12
0
        DataFeedTemplate BulidTemplate(int c3SysNo, string c3Name)
        {
            string configPath = Path.Combine(
                AppDomain.CurrentDomain.SetupInformation.ApplicationBase
                , AppSettingHelper.Get("DataFeedFilesConfigPath")
                );

            m_dataFeed = SerializationUtility.LoadFromXml <DataFeedFileMapping>(configPath).Mappings[0];
            DataFeedTemplate template = new DataFeedTemplate();

            template.C3Name     = c3Name;
            template.C3SysNo    = c3SysNo;
            template.C3RowIndex = int.Parse(m_dataFeed.C3RowIndex);
            //填充列分组信息
            template.HeaderGroups = new List <HeaderGroup>();
            foreach (var item in m_dataFeed.HeaderGroups)
            {
                template.HeaderGroups.Add(item);
            }
            template.BasicColumns = BuildBasicColumns(c3SysNo);
            var list = ExternalDomainBroker.GetCategoryPropertyByCategorySysNo(c3SysNo);

            if (list != null)
            {
                template.Properties = new List <DataFeedColumn>();
                var activeList = list.Where(p => p.Property.Status == PropertyStatus.Active);
                if (activeList.Count() > 0)
                {
                    var propertySysNoList = activeList.Select(p => p.Property.SysNo.Value).ToList();
                    var propertyValues    = ExternalDomainBroker.GetPropertyValueInfoByPropertySysNoList(propertySysNoList);
                    foreach (var item in activeList)
                    {
                        DataFeedColumn column = new DataFeedColumn();
                        column.Number = item.Property.SysNo.Value;
                        // item.PropertyType == "D"? 没有这个属性?
                        if (item.PropertyType == PropertyType.Grouping)
                        {
                            column.Name = string.Format("{0}_列表", item.Property.PropertyName.Content);
                        }
                        else
                        {
                            column.Name = item.Property.PropertyName.Content;
                        }
                        column.Type  = DataType.LIST;
                        column.Width = column.Name.Length;

                        if (item.IsMustInput == CategoryPropertyStatus.Yes)
                        {
                            column.IsMustInput = true;
                        }
                        else
                        {
                            column.IsMustInput = false;
                        }

                        if (item.IsInAdvSearch == CategoryPropertyStatus.Yes)
                        {
                            column.IsInAdvSearch = true;
                        }

                        column.List = new List <string>();
                        var propertyList = propertyValues.FirstOrDefault(p => p.Key == item.Property.SysNo.Value).Value;
                        if (propertyList != null)
                        {
                            foreach (var value in propertyList.Where(p => p.PropertyInfo.Status == PropertyStatus.Active))
                            {
                                column.List.Add(value.ValueDescription.Content);
                            }
                        }

                        template.Properties.Add(column);

                        //分组属性需要多加一列
                        // item.PropertyType == "D"? 没有这个属性?
                        if (item.PropertyType == PropertyType.Grouping)
                        {
                            column       = new DataFeedColumn();
                            column.Name  = string.Format("{0}_自定义", item.Property.PropertyName.Content);
                            column.Width = column.Name.Length;
                            column.Type  = DataType.TEXT_LENGTH;

                            template.Properties.Add(column);
                        }

                        //HACK:Bob.H.Li 如果Item.Type==G,那么添加一列“是否分组属性”
                        if (item.PropertyType == PropertyType.Grouping)
                        {
                            column = new DataFeedColumn();

                            column.Number = template.Properties.Count;

                            column.Name  = DataFeedConstString.EXCEL_ADDSELECTGROUPSTRING;
                            column.Width = column.Name.Length;
                            column.Type  = DataType.LIST;

                            column.List = new List <string>()
                            {
                                GroupPropertyType.OnlyGroupText,
                                GroupPropertyType.OnlyGroupPicture,
                                GroupPropertyType.GroupAggregationText,
                                GroupPropertyType.GroupAggregationPicture
                            };
                            template.Properties.Add(column);
                        }
                    }
                }
            }

            return(template);
        }
Esempio n. 13
0
 public static string GetDbType()
 {
     return(AppSettingHelper.Get(Key_DbType));
 }