Ejemplo n.º 1
0
        public static void ReadFile()
        {
            string DeviceName;
            string TableConfig;

            using (System.IO.StreamReader file =
                       new System.IO.StreamReader(@"D:\jinchen\projects\webapi2\source1.txt", true))
            {
                try
                {
                    int    counter = 0;
                    string line;
                    while ((line = file.ReadLine()) != null)
                    {
                        //  System.Console.WriteLine(line);

                        string[] sA = line.Split('\t');

                        int ln = sA.Length;
                        if (ln > 0)
                        {
                            DeviceName = sA[0] as string;
                            DeviceName = DeviceName.Trim();
                            if (DeviceName == "")
                            {
                                continue;
                            }

                            if (ln > 1)
                            {
                                for (int i = 1; i < ln; i++)
                                {
                                    TableConfig = sA[i] as string;
                                    TableConfig = TableConfig.Trim();
                                    if (TableConfig == "")
                                    {
                                        continue;
                                    }
                                    Console.Write(DeviceName + "  ");
                                    GenerateSQLFile(DeviceName, TableConfig);
                                    Console.Write(TableConfig + "  ");
                                    Console.WriteLine("  ");
                                    counter++;
                                }
                            }
                        }
                    }

                    Console.WriteLine(counter);
                }
                catch (System.NullReferenceException e)
                {
                    file.Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void UpdateDevice(object param)
        {
            try
            {
                if (SelectedDevice == null)
                {
                    throw new Exception("Устройство не выбрано");
                }

                if (string.IsNullOrEmpty(DeviceName.Trim()) || string.IsNullOrEmpty(DeviceSerialNumber.Trim()) ||
                    string.IsNullOrEmpty(DeviceIpAddress.Trim()) || PlatformId < 1)
                {
                    throw new Exception("Не заполнены обязательные поля");
                }

                using (var deviceService = _ppsClientViewModel.ServiceProxy.GetPpsChannelFactory <IDeviceService>())
                {
                    var channel = deviceService.CreateChannel();
                    var result  =
                        channel.UpdateDevice(SelectedDevice, new DeviceInfoDataContract
                    {
                        DeviceId           = SelectedDevice.DeviceId,
                        DeviceName         = DeviceName.Trim(),
                        DeviceSerialNumber = DeviceSerialNumber.Trim(),
                        DeviceMacAddress   = DeviceMacAddress.Trim(),
                        DeviceIpAddress    = DeviceIpAddress.Trim(),
                        DevicePlatformId   = PlatformId
                    });

                    if (!result.BoolRes || !string.IsNullOrEmpty(result.ErrorRes))
                    {
                        throw new Exception(result.ErrorRes);
                    }

                    _ppsClientViewModel.GetDeviceCollection();
                    _ppsClientViewModel.AddEvent(EventConstants.EVENT_UPD_DEVICE, SelectedDevice.DeviceSerialNumber);
                }
            }
            catch (Exception ex)
            {
                _ppsClientViewModel.WriteLogMessage("Не удалось изменить устройство - " + ex.Message);
            }
        }
Ejemplo n.º 3
0
            /// <summary>
            /// Finds the LVM id of the volume id where the folder is placed
            /// </summary>
            private void Initialize(string folder)
            {
                //Figure out what logical volume the path is located on
                var output = ExecuteCommand("find-volume.sh", $"\"{folder}\"", 0);

                var rex = new System.Text.RegularExpressions.Regex("device=\"(?<device>[^\"]+)\"");
                var m   = rex.Match(output);

                if (!m.Success)
                {
                    throw new Exception(Strings.LinuxSnapshot.ScriptOutputError("device", output));
                }

                DeviceName = rex.Match(output).Groups["device"].Value;

                if (string.IsNullOrEmpty(DeviceName) || DeviceName.Trim().Length == 0)
                {
                    throw new Exception(Strings.LinuxSnapshot.ScriptOutputError("device", output));
                }

                rex = new System.Text.RegularExpressions.Regex("mountpoint=\"(?<mountpoint>[^\"]+)\"");
                m   = rex.Match(output);

                if (!m.Success)
                {
                    throw new Exception(Strings.LinuxSnapshot.ScriptOutputError("mountpoint", output));
                }

                MountPoint = rex.Match(output).Groups["mountpoint"].Value;

                if (string.IsNullOrEmpty(MountPoint) || MountPoint.Trim().Length == 0)
                {
                    throw new Exception(Strings.LinuxSnapshot.ScriptOutputError("mountpoint", output));
                }

                MountPoint = Util.AppendDirSeparator(MountPoint);
            }