示例#1
0
        private void LoadAd(string fileName)
        {
            if (_Value.ContainsKey(fileName))
            {
                return;
            }

            var configPath = string.Format("{0}.config", fileName);

            if (!File.Exists(configPath))
            {
                return;
            }

            Notifi adNotifi = new Notifi();

            adNotifi.Content = File.ReadAllText(fileName);
            PublicFileJson <NotifiSettings> notifiSettings = new PublicFileJson <NotifiSettings>(configPath);

            adNotifi.Settings = notifiSettings.Read();
            if (adNotifi.Settings == null)
            {
                return;
            }

            _Value.Add(fileName, adNotifi);
        }
示例#2
0
        //LockFunc _ClientList
        public bool InviteUser(WCFUser user, string inviteLogin, string msg)
        {
            lock (_ClientList)
            {
                //проверка подключена ли система оповещения пользователя
                var client = _ClientList.SingleOrDefault(p => p.Login == inviteLogin);
                if (client == null)
                {
                    return(false);
                }

                //загрузка настроект окна приглошения
                PublicFileJson <NotifiSettings> notifiSettings = new PublicFileJson <NotifiSettings>(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "configs\\invite.config"));
                notifiSettings.Read();
                if (notifiSettings.Value == null)
                {
                    if (!tmpMethod(notifiSettings))
                    {
                        return(false);
                    }
                }

                client.NotifiList.Add(new Notifi()
                {
                    Content = string.Format("dynamic_message*{0}", msg), User = user.Login, Settings = notifiSettings.Value
                });
            }

            return(true);
        }
示例#3
0
        //LockFunc _ClientList
        public void AddUserNotifi(WCFUser user, string message)
        {
            //TODO можно загружать при старте хоста
            PublicFileJson <NotifiSettings> notifiSettings = new PublicFileJson <NotifiSettings>(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "configs\\user.config"));

            notifiSettings.Read();
            if (notifiSettings.Value == null)
            {
                if (!tmpMethod(notifiSettings))
                {
                    return;
                }
            }

            foreach (var login in user.SignerUsers)
            {
                lock (_ClientList)
                {
                    var client = _ClientList.SingleOrDefault(p => p.Login == login);
                    if (client == null)
                    {
                        continue;
                    }

                    client.NotifiList.Add(new Notifi()
                    {
                        Content = message, User = user.Login, Settings = notifiSettings.Value
                    });
                }
            }
        }
示例#4
0
 public void Save(string filename)
 {
     PublicFileJson <NeuroWeb> data = new PublicFileJson <NeuroWeb>(filename)
     {
         Value = this
     };
     bool res = data.Write();
 }
示例#5
0
        public void Load(string filename)
        {
            PublicFileJson <NeuroWeb> data = new PublicFileJson <NeuroWeb>(filename);

            data.Read();
            InputPerceptrons  = data.Value?.InputPerceptrons;
            OutputPerceptrons = data.Value?.OutputPerceptrons;
            OutputPerceptrons?.ForEach(o => o.Synaptics.ForEach(s => s.Perceptron = InputPerceptrons.SingleOrDefault(i => i.Id == s.PerceptronId)));
        }
示例#6
0
        public App()
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                TaskFactory = new TaskFactory(new LimitedConcurrencyLevelTaskScheduler(1));
                ChannelFactory <IService> _CF = new ChannelFactory <IService>("AGOT2");
                Service = _CF.CreateChannel();

                ClientVersion = Crypto.Md5Hex(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Agot2Client.exe"));
                string mac = NetworkInterface.GetAllNetworkInterfaces().First(p => p.OperationalStatus == OperationalStatus.Up).GetPhysicalAddress().ToString();
                ClientId = string.Format("{0}\\{1}\\{2} {3} {4} {5}", Environment.MachineName, Environment.UserDomainName, Environment.UserName, Environment.OSVersion.VersionString, Environment.Version, mac);

#if !DEBUG
                Settings = new CryptoFileJson <AppSettings>("AppSettings", "W@NtUz81");
#endif
#if DEBUG
                Settings = new PublicFileJson <AppSettings>("AppSettings");
#endif
                if (Settings.Read() == null)
                {
                    Settings.Value = new AppSettings();
                }

                if (Settings.Value.Vols == null || Settings.Value.Vols.Count < 5 || string.IsNullOrEmpty(Settings.Value.Lang))
                {
                    Settings.Value.SetDefault();
                }

                CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(Settings.Value.Lang);
            }
            catch (Exception exp)
            {
                //Удаление файла настроек
                if (File.Exists("AppSettings"))
                {
                    File.Delete("AppSettings");
                }

                WriteException(exp);
            }
        }
示例#7
0
 private static bool tmpMethod(PublicFileJson <NotifiSettings> settings)
 {
     settings.Value = new NotifiSettings();
     return(settings.Write());
 }