public Model_Properties(CProperties properties) { Properties = properties; SelfIntersectionCheck = properties.SelfIntersectionCheck; SubjectStrokeWidth = properties.opProperty[0].StrokeWeight; SubjectStrokeColor = (Color)ColorConverter.ConvertFromString(properties.opProperty[0].StrokeColor); SubjectFillColor = (Color)ColorConverter.ConvertFromString(properties.opProperty[0].FillColor); ClipperStrokeWidth = properties.opProperty[1].StrokeWeight; ClipperStrokeColor = (Color)ColorConverter.ConvertFromString(properties.opProperty[1].StrokeColor); ClipperFillColor = (Color)ColorConverter.ConvertFromString(properties.opProperty[1].FillColor); ResultStrokeWidth = properties.opProperty[2].StrokeWeight; ResultStrokeColor = (Color)ColorConverter.ConvertFromString(properties.opProperty[2].StrokeColor); ResultFillColor = (Color)ColorConverter.ConvertFromString(properties.opProperty[2].FillColor); FileLocation = properties.FileLocation; UserLogin = properties.UserLogin; UserPassword = properties.UserPassword; RemoteHostAddress = properties.RemoteHost; RemotePort = properties.RemotePort; LocalHostAddress = properties.LocalHost; LocalPort = properties.LocalPort; RemoteUsed = properties.RemoteUsed; }
public PropertiesService() { properties = new CProperties(); // Задаем свойства "по умолчанию" properties.SelfIntersectionCheck = true; properties.opProperty[(int)OPERATION_OBJECT_TYPE.Subject].StrokeWeight = 2; properties.opProperty[(int)OPERATION_OBJECT_TYPE.Subject].StrokeColor = "#FF000000"; properties.opProperty[(int)OPERATION_OBJECT_TYPE.Subject].FillColor = "#3C000000"; properties.opProperty[(int)OPERATION_OBJECT_TYPE.Clipper].StrokeWeight = 2; properties.opProperty[(int)OPERATION_OBJECT_TYPE.Clipper].StrokeColor = "#FF00BFFF"; properties.opProperty[(int)OPERATION_OBJECT_TYPE.Clipper].FillColor = "#5100BFFF"; properties.opProperty[(int)OPERATION_OBJECT_TYPE.Result].StrokeWeight = 2; properties.opProperty[(int)OPERATION_OBJECT_TYPE.Result].StrokeColor = "#FF3CB371"; properties.opProperty[(int)OPERATION_OBJECT_TYPE.Result].FillColor = "#4700FF00"; properties.FileLocation = Application.StartupPath + @"\File"; properties.UserLogin = "******"; properties.UserPassword = "******"; properties.RemoteUsed = true; properties.RemoteHost = "109.248.33.124"; properties.RemotePort = "37067"; properties.LocalHost = "127.0.0.1";// "mongodb://localhost" properties.LocalPort = "37067"; properties.LocalDataBaseLocation = Application.StartupPath + @"\MongoDB\data"; }
public void UpdateProperties(CProperties new_prop) { properties.SelfIntersectionCheck = new_prop.SelfIntersectionCheck; for (int i = 0; i < 3; i++) { properties.opProperty[i].StrokeWeight = new_prop.opProperty[i].StrokeWeight + 1; properties.opProperty[i].StrokeColor = new_prop.opProperty[i].StrokeColor; properties.opProperty[i].FillColor = new_prop.opProperty[i].FillColor; } properties.FileLocation = new_prop.FileLocation; properties.UserLogin = new_prop.UserLogin; properties.UserPassword = new_prop.UserPassword; properties.RemoteUsed = new_prop.RemoteUsed; properties.RemoteHost = new_prop.RemoteHost; properties.RemotePort = new_prop.RemotePort; properties.LocalHost = new_prop.LocalHost; properties.LocalPort = new_prop.LocalPort; properties.LocalDataBaseLocation = new_prop.LocalDataBaseLocation; SavePropities(); }
public CProperties GetPropertiesClone() { CProperties prop_clone = new CProperties(); prop_clone.SelfIntersectionCheck = properties.SelfIntersectionCheck; for (int i = 0; i < 3; i++) { prop_clone.opProperty[i].StrokeWeight = properties.opProperty[i].StrokeWeight - 1; prop_clone.opProperty[i].StrokeColor = properties.opProperty[i].StrokeColor; prop_clone.opProperty[i].FillColor = properties.opProperty[i].FillColor; } prop_clone.FileLocation = properties.FileLocation; prop_clone.UserLogin = properties.UserLogin; prop_clone.UserPassword = properties.UserPassword; prop_clone.RemoteUsed = properties.RemoteUsed; prop_clone.RemoteHost = properties.RemoteHost; prop_clone.RemotePort = properties.RemotePort; prop_clone.LocalHost = properties.LocalHost; prop_clone.LocalPort = properties.LocalPort; prop_clone.LocalDataBaseLocation = properties.LocalDataBaseLocation; return(prop_clone); }
public Window_Properties(CProperties properties) { InitializeComponent(); data_model = new Model_Properties(properties); this.DataContext = data_model; if (data_model.Properties.RemoteUsed) { RadioButton_RemoteHost.IsChecked = true; } else { RadioButton_LocalHost.IsChecked = true; } if (_PasswordBox.SecurePassword.IsReadOnly()) { MessageBox.Show("Password is read-only!"); } else if (_PasswordBox.SecurePassword == null) { MessageBox.Show("Password is null!"); } else { if (properties.UserPassword != null && properties.UserPassword.Length > 0) { _PasswordBox.Password = properties.UserPassword; _PasswordTextBox.Text = _PasswordBox.Password; PasswordHelper.SetIsUpdating(_PasswordBox, true); PasswordHelper.SetPassword(_PasswordBox, _PasswordBox.Password); PasswordHelper.SetIsUpdating(_PasswordBox, false); } } //this.UpdateLayout(); }
public void InitFromSetupFile() { string setupFullPath = Application.StartupPath + @"\" + setupFileName; JsonFileService jfs = new JsonFileService(); if (File.Exists(setupFullPath)) // Если файл установок существует, то { try { CProperties instance = jfs.LoadInstanceFromFile <CProperties>(setupFullPath); // загружаем его содержимое if (instance != null) { if (((CProperties)instance).SelfIntersectionCheck.GetType().Equals(typeof(bool))) { properties.SelfIntersectionCheck = ((CProperties)instance).SelfIntersectionCheck; } for (int i = 0; i < 3; i++) { if (((CProperties)instance).opProperty[i].StrokeWeight.GetType().Equals(typeof(int))) { properties.opProperty[i].StrokeWeight = ((CProperties)instance).opProperty[i].StrokeWeight; } if (((CProperties)instance).opProperty[i].StrokeColor.GetType().Equals(typeof(string))) { properties.opProperty[i].StrokeColor = ((CProperties)instance).opProperty[i].StrokeColor; } if (((CProperties)instance).opProperty[i].FillColor.GetType().Equals(typeof(string))) { properties.opProperty[i].FillColor = ((CProperties)instance).opProperty[i].FillColor; } } if (((CProperties)instance).FileLocation != null) { if (Directory.Exists(((CProperties)instance).FileLocation)) { properties.FileLocation = ((CProperties)instance).FileLocation; } else { SavePropities(); //MessageBox.Show("The path specified in the files location property is missing, the default path will be used!"); } } else { MessageBox.Show("Could not read property of the shape-files location path, default path will be used!"); } if (!Directory.Exists(properties.FileLocation)) // Если нет дефолтной директории сохранения файлов { Directory.CreateDirectory(properties.FileLocation); // создаем ее } if (((CProperties)instance).UserLogin.GetType().Equals(typeof(string))) { properties.UserLogin = ((CProperties)instance).UserLogin; } if (((CProperties)instance).UserPassword.GetType().Equals(typeof(string))) { properties.UserPassword = ((CProperties)instance).UserPassword; } if (((CProperties)instance).RemoteUsed.GetType().Equals(typeof(bool))) { properties.RemoteUsed = ((CProperties)instance).RemoteUsed; } if (((CProperties)instance).RemoteHost.GetType().Equals(typeof(string))) { properties.RemoteHost = ((CProperties)instance).RemoteHost; } if (((CProperties)instance).RemotePort.GetType().Equals(typeof(string))) { properties.RemotePort = ((CProperties)instance).RemotePort; } if (((CProperties)instance).LocalHost.GetType().Equals(typeof(string))) { properties.LocalHost = ((CProperties)instance).LocalHost; } if (((CProperties)instance).LocalPort.GetType().Equals(typeof(string))) { properties.LocalPort = ((CProperties)instance).LocalPort; } /********** Прописать этот блок если получится сконфигурировать портативный сервер MongoDB *************** * if (((CProperties)instance).LocalDataBaseLocation != null) * { * if (Directory.Exists(((CProperties)instance).LocalDataBaseLocation)) * { * properties.LocalDataBaseLocation = ((CProperties)instance).LocalDataBaseLocation; * } * else * { * MessageBox.Show("The path specified in the files location property is missing, the default path will be used!"); * } * } * else * { * MessageBox.Show("Could not read property of the shape-files location path, default path will be used!"); * } * /*if (!Directory.Exists(properties.LocalDataBaseLocation)) // Если нет дефолтной директории для БД * { * Directory.CreateDirectory(properties.LocalDataBaseLocation); // создаем ее **************** }************************************************************************/ } else { //MessageBox.Show("Could not read Properties from the Setup File, Default Properties will be used!!"); SavePropities(); } } catch (ApplicationException ex) { MessageBox.Show("PropertiesService.InitFromSetupFile()" + ex.Message, "ApplicationException!"); } catch (Exception ex) { MessageBox.Show("PropertiesService.InitFromSetupFile()" + ex.Message, "Exeption!"); } } }
private string userPassword; // Пароль доступа к БД public void OpenDB(CProperties save_property, string _dbName) { BsonClassMap.RegisterClassMap <namedParameter>(cm => { cm.AutoMap(); cm.MapMember(cl => cl.ParamName); cm.MapMember(cl => cl.ParamValue).SetSerializer(new myObjectSerializer()); cm.SetIgnoreExtraElements(true); }); BsonClassMap.RegisterClassMap <ShapeParams>(cm => { cm.AutoMap(); cm.MapMember(cl => cl.ShapeName); cm.MapMember(cl => cl.ShapeType); cm.MapMember(cl => cl.StrokeWeight); cm.MapMember(cl => cl.StrokeColor); cm.MapMember(cl => cl.FillColor); cm.MapMember(cl => cl.GeometricParams); cm.SetIgnoreExtraElements(true); }); BsonClassMap.RegisterClassMap <shapeGroup>(cm => { cm.AutoMap(); cm.MapMember(cl => cl.groupName); cm.MapMember(cl => cl.Shapes); cm.SetIgnoreExtraElements(true); }); BsonClassMap.RegisterClassMap <PolygonOperation>(cm => { cm.AutoMap(); cm.MapMember(cl => cl.OperationName); cm.MapMember(cl => cl.SubjectGeometry); cm.MapMember(cl => cl.ClipperGeometry); cm.MapMember(cl => cl.OperationType).SetSerializer(new EnumSerializer <BooleanOperations>(BsonType.String));; cm.MapMember(cl => cl.ResultGeometry); cm.SetIgnoreExtraElements(true); }); remoteUsed = save_property.RemoteUsed; dbName = _dbName; userLogin = save_property.UserLogin.Trim(); userPassword = save_property.UserPassword.Trim(); selfrun_mongod = false; mongodProcess = null; is_open = false; if (remoteUsed) { host = save_property.RemoteHost.Trim(); port = save_property.RemotePort.Trim(); } else { host = save_property.LocalHost.Trim(); port = save_property.LocalPort.Trim(); } try { if (userLogin.Length > 0) { client = new MongoClient(new MongoClientSettings { Credential = MongoCredential.CreateCredential(dbName, userLogin, userPassword), Server = new MongoServerAddress(host, Convert.ToInt32(port)) }); } else { client = new MongoClient(new MongoClientSettings { Server = new MongoServerAddress(host, Convert.ToInt32(port)) }); } db = client.GetDatabase(dbName); is_open = true; if (!remoteUsed) { bool ret_val = db.RunCommandAsync((Command <BsonDocument>) "{ping:1}").Wait(500); if (!ret_val) { is_open = false; //Пинга к необходимому порту нет } } } catch (Exception ex) { throw new System.ApplicationException(ex.Message); } /*******---- Этот блок доделать, если получится сконфигурировать портативный сервер MongoDB ------------------******* * * Process[] procs = Process.GetProcessesByName("mongod"); * if (procs != null && procs.Count() > 0) // Если процесс с запущенным Сервером БД существует * { * client = new MongoClient("mongodb://"+host+":" + port); // пытаемся подключиться к * db = client.GetDatabase(dbName); * bool ret_val = db.RunCommandAsync((Command<BsonDocument>)"{ping:1}").Wait(500); * if (!ret_val) * { * selfrun_mongod = true; //сервер на необходимый порт не пингуется * } * else * { * is_open = true; //Пинг к необходимому порту есть * } * } * else * selfrun_mongod = true; * * if (selfrun_mongod) * { * //Console.Write("Сервер 'MongoDB' НЕ запущен! Запускаю....\n"); * ProcessStartInfo start = new ProcessStartInfo(); * string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\MongoDB\"; * start.FileName = dir + @"bin\mongod.exe"; * start.Arguments = "--dbpath \"" + dir + "data\" --logpath \"" + dir + "log\\log\" --port "+port; * start.WindowStyle = ProcessWindowStyle.Hidden; * //start.UseShellExecute = false; * try * { * mongodProcess = Process.Start(start); * } * catch (Exception ex) * { * mongodProcess = null; * throw new System.ApplicationException("Запустить сервер 'MongoDB' не удалось.../n" + ex.Message); * } * //else * //Console.Write("Cервер 'MongoDB' загружен.\n\n"); * * client = new MongoClient("mongodb://" + host + ":" + port); * db = client.GetDatabase(dbName); * is_open = true; * } ******---------------------------------------------------------************/ }