示例#1
0
        public static void Get()
        {
            LogWriteLock.EnterReadLock();

            try
            {
                if (File.Exists(filePath))
                {
                    var contents = File.ReadAllLines(filePath);

                    foreach (var item in contents)
                    {
                        if (!string.IsNullOrEmpty(item))
                        {
                            var arr = item.Split('|');
                            if (arr.Length == 6)
                            {
                                if (layoutRs.ContainsKey(arr[5].ToString()))
                                {
                                    layoutRs.Remove(arr[5].ToString());
                                }
                                var set = new LayoutRandomSet();
                                set.IsOpen = arr[0].ToInt() == 0 ? false : true;
                                set.Pass   = arr[1].ToInt();
                                if (float.TryParse(arr[2].ToString(), out float result))
                                {
                                    set.RPercent = result;
                                }

                                set.ValidCount = arr[3].ToInt();
                                set.ValidDays  = arr[4].ToInt();
                                set.Channel    = arr[5].ToString();
                                layoutRs.Add(arr[5].ToString(), set);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                LogWriteLock.ExitReadLock();
            }
        }
示例#2
0
        public Resp_Binary LayoutRandom_Save(Layout_Random_Set set)
        {
            if (set.IsOpen && set.Percent <= 0)
            {
                return new Resp_Binary {
                           message = "随机取样百分比应大于0"
                }
            }
            ;

            var lset = new LayoutRandomSet {
                IsOpen     = set.IsOpen,
                Pass       = set.Pass,
                RPercent   = set.Percent,
                ValidCount = set.ValidCount,
                ValidDays  = set.ValidDays,
                Channel    = set.Channel
            };

            if (LayoutRandomSetLock.layoutRs.ContainsKey(set.Channel))
            {
                LayoutRandomSetLock.layoutRs[set.Channel] = lset;
            }
            else
            {
                LayoutRandomSetLock.layoutRs.Add(set.Channel, lset);
            }


            LayoutRandomSetLock.Set();


            return(Resp_Binary.Modify_Sucess);
            //var ply = set.IsOpen + "|" + set.Pass + "|" + set.Percent;

            //Application
        }