Ejemplo n.º 1
0
 private  List<CalendarItem> MergeItems(List<CalendarItem> newItems, List<CalendarItem> fromRepo)
 {
     var result = new List<CalendarItem>();
     var newModels = newItems.Except(fromRepo, new CalendarItemEqualityComparer()).ToList();
     var updatet = fromRepo.Except(newModels,new CalendarItemEqualityComparer()).ToList();
     updatet.ForEach(x =>
     {
         var model = newItems.FirstOrDefault(y => y.Id == x.Id);
         if (model != null)
         {
             model.SyncStatus.CalenadCalendarItemStatus = IsModified(model, x)
                 ? CalendarItemStatus.Updated
                 : CalendarItemStatus.Unmodified;
             result.Add(model);
         }
     });
     var deleted = fromRepo.Where(x => x.Start.Date >= DateTime.Now.Date).Except(newItems).Except(updatet);
     newModels.ForEach(x => x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.New);
     deleted.ForEach(x =>
     {
         x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.Deleted;
         result.Add(x);
     });
     result.AddRange(newModels);
     return result.OrderBy(x => x.Start).ToList();
 }
		public static void CreateKnownProperties(List<Driver> drivers)
		{
			try
			{
				RMHelper.Create(drivers);
				MROHelper.Create(drivers);
				AMP4Helper.Create(drivers);
				MDUHelper.Create(drivers);
				BUZHelper.Create(drivers);
				foreach (var driverType in new List<DriverType>() { DriverType.Pump, DriverType.JokeyPump, DriverType.Compressor, DriverType.DrenazhPump, DriverType.CompensationPump })
				{
					var driver = drivers.FirstOrDefault(x => x.DriverType == driverType);
					BUNHelper.Create(driver);
				}
				MPTHelper.Create(drivers);
				DetectorsHelper.Create(drivers);

				AM_1_Helper.Create(drivers);
				AM1_T_Helper.Create(drivers);
				AM1_O_Helper.Create(drivers);

				ControlCabinetHelper.Create(drivers);
				FanCabinetHelper.Create(drivers);
				MRO2Helper.Create(drivers);
			}
			catch (Exception e)
			{
				Logger.Error(e, "DriverConfigurationParametersHelper.CreateKnownProperties");
			}
		}
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            int totalCount = 3;
            List<Student> listStudent = new List<Student>();
            for (int i = 0; i < 3; i++)
            {
                Student objStudent = new Student();
                Console.Write("Please enter the Student ID: ");
                objStudent.StudentId = Int32.Parse(Console.ReadLine());
                Console.Write("Please enter the Student Name: ");
                objStudent.Name = Console.ReadLine();
                listStudent.Add(objStudent);
            }

            //Query to get by name - only first occurence
            //Student student = listStudent.First(x => x.Name == "Karthik");
            Student student = listStudent.FirstOrDefault(x => x.Name == "Karthik");

            if(student != null)
                Console.WriteLine(string.Format("ID: {0} Name: {1}", student.StudentId, student.Name));

            //Query to get by name - all occurences
            //IEnumerable<Student> stdList = listStudent.Where(x => x.Name == "Karthik");
            IEnumerable<Student> stdList = listStudent.Where(x => x.StudentId >= 20);
            foreach (var student1 in stdList)
            {
                Console.WriteLine(string.Format("ID: {0} Name: {1}", student1.StudentId, student1.Name));
            }

            listStudent.Sort((std1, std2) => std1.Name.CompareTo(std2.Name));
            listStudent.ForEach(x=>Console.WriteLine(x.Name));
        }
Ejemplo n.º 4
0
        public async void LoadData()
        {
            try
            {
                _allNamedays = await NamedayRepository.GetAllNamedaysAsync();
                PerformFiltering();
                LoadingState = LoadingStates.Loaded;
            }
            catch
            {
                LoadingState = LoadingStates.Error;
            }

            var now = DateTime.Now;
            SelectedNameday = _allNamedays.FirstOrDefault(
                d => d.Day == now.Day && d.Month == now.Month);
        }
Ejemplo n.º 5
0
		public static void ResetAllStates()
		{
			try
			{
				var resetItems = new List<ResetItem>();
				foreach (var device in Devices)
				{
					foreach (var deviceDriverState in device.DeviceState.ThreadSafeStates)
					{
						if (deviceDriverState.DriverState.IsManualReset)
						{
							var resetItem = new ResetItem()
							{
								DeviceState = device.DeviceState
							};
							resetItem.States.Add(deviceDriverState);

							var existringResetItem = resetItems.FirstOrDefault(x => x.DeviceState == resetItem.DeviceState);
							if (existringResetItem != null)
							{
								foreach (var driverState in resetItem.States)
								{
									if (existringResetItem.States.Any(x => x.DriverState.Code == driverState.DriverState.Code) == false)
										existringResetItem.States.Add(driverState);
								}
							}
							else
							{
								resetItems.Add(resetItem);
							}
						}
					}
				}

				FiresecManager.ResetStates(resetItems);
			}
			catch (Exception e)
			{
				Logger.Error(e, "FiresecManager.ResetAllStates");
			}
		}
Ejemplo n.º 6
0
		public DeviceControlViewModel(Device device)
		{
			Device = device;
			ConfirmCommand = new RelayCommand(OnConfirm, CanConfirm);

			Blocks = new List<BlockViewModel>();

			foreach (var property in device.Driver.Properties)
			{
				if (property.IsControl)
				{
					var blockViewModel = Blocks.FirstOrDefault(x => x.Name == property.BlockName);
					if (blockViewModel == null)
					{
						blockViewModel = new BlockViewModel()
						{
							Name = property.BlockName
						};
						Blocks.Add(blockViewModel);
					}
					blockViewModel.Commands.Add(property);
				}
			}
		}
Ejemplo n.º 7
0
		void OnResetAll()
		{
			var resetItems = new List<ResetItem>();
			foreach (var alarm in allAlarms)
			{
				var resetItem = alarm.GetResetItem();
				if (resetItem != null)
				{
					var existringResetItem = resetItems.FirstOrDefault(x => x.DeviceState == resetItem.DeviceState);
					if (existringResetItem != null)
					{
						foreach (var driverState in resetItem.States)
						{
							if (existringResetItem.States.Any(x => x.DriverState.Code == driverState.DriverState.Code) == false)
								existringResetItem.States.Add(driverState);
						}
					}
					else
					{
						resetItems.Add(resetItem);
					}
				}
			}

			FiresecManager.ResetStates(resetItems);
			AllAlarmsResetingTimer = new DispatcherTimer();
			AllAlarmsResetingTimer.Interval = TimeSpan.FromSeconds(2);
			AllAlarmsResetingTimer.Tick += new EventHandler(AllAlarmsResetingTimer_Tick);
			AllAlarmsResetingTimer.Start();
			IsAllAlarmsReseting = true;
		}
Ejemplo n.º 8
0
		bool FindDevicesOnShleif(GKDevice kauDevice, int shleifNo, GKProgressCallback progressCallback, Guid clientUID)
		{
			var shleifDevice = kauDevice.Children.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif && x.IntAddress == shleifNo + 1);
			progressCallback.Title = "Автопоиск на АЛС " + (shleifNo + 1) + " устройства " + kauDevice.PresentationName;
			progressCallback.CurrentStep = 0;
			progressCallback.StepCount = 256;
			using (var gkLifecycleManager = new GKLifecycleManager(kauDevice, "Автопоиск на АЛС " + (shleifNo + 1)))
			{
				var deviceGroups = new List<DeviceGroup>();
				var devices = new List<GKDevice>();
				for (int address = 1; address <= 255; address++)
				{
					gkLifecycleManager.Progress(address, 255);
					GKProcessorManager.DoProgress("Поиск устройства с адресом " + address, progressCallback, clientUID);
					if (progressCallback.IsCanceled)
					{
						Error = "Операция отменена";
						return false;
					}
					var bytes = new List<byte>();
					bytes.Add(0);
					bytes.Add((byte)address);
					bytes.Add((byte)shleifNo);
					var result2 = new SendResult("");
					for (int i = 0; i < 3; i++)
					{
						if (progressCallback.IsCanceled)
						{
							Error = "Операция отменена";
							return false;
						}
						result2 = SendManager.Send(kauDevice, 3, 0x86, 6, bytes, true, false, 3000);
						if (!result2.HasError)
							break;
					}
					if (!result2.HasError)
					{
						if (result2.Bytes.Count == 6)
						{
							var driverTypeNo = result2.Bytes[1];
							var serialNo = BytesHelper.SubstructInt(result2.Bytes, 2);
							var driver = GKManager.Drivers.FirstOrDefault(x => x.DriverTypeNo == (ushort)driverTypeNo);
							if (driver != null)
							{
								var device = new GKDevice();
								device.Driver = driver;
								device.DriverUID = driver.UID;
								device.IntAddress = (byte)address;
								devices.Add(device);

								var deviceGroup = deviceGroups.FirstOrDefault(x => x.SerialNo == serialNo);
								if (deviceGroup == null || (serialNo == 0 || serialNo == -1) || (driver.DriverType != GKDriverType.RSR2_AM_1 && driver.DriverType != GKDriverType.RSR2_MAP4
									&& driver.DriverType != GKDriverType.RSR2_MVK8 && driver.DriverType != GKDriverType.RSR2_RM_1 && driver.DriverType != GKDriverType.RSR2_OPKZ))
								{
									deviceGroup = new DeviceGroup();
									deviceGroup.SerialNo = serialNo;
									deviceGroups.Add(deviceGroup);
								}
								deviceGroup.Devices.Add(device);
							}
						}
					}
					else
					{
						break;
					}
				}

				foreach (var deviceGroup in deviceGroups)
				{
					var firstDeviceInGroup = deviceGroup.Devices.FirstOrDefault();
					if (deviceGroup.Devices.Count > 1 && firstDeviceInGroup != null)
					{
						GKDriver groupDriver = null;
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_AM_1)
						{
							if (deviceGroup.Devices.Count == 2)
								groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_AM_2);
							else
								groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_AM_4);
						}
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_MAP4)
						{
							groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_MAP4_Group);
						}
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_MVK8)
						{
							groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_MVK8_Group);
						}
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_RM_1)
						{
							if (deviceGroup.Devices.Count == 2)
								groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_RM_2);
							else
								groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_RM_4);
						}
						if (firstDeviceInGroup.Driver.DriverType == GKDriverType.RSR2_OPKS)
						{
							groupDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_OPSZ);
						}

						var groupDevice = new GKDevice();
						groupDevice.Driver = groupDriver;
						if (groupDriver != null)
							groupDevice.DriverUID = groupDriver.UID;
						groupDevice.IntAddress = firstDeviceInGroup.IntAddress;
						foreach (var deviceInGroup in deviceGroup.Devices)
						{
							groupDevice.Children.Add(deviceInGroup);
						}
						if (shleifDevice != null)
							shleifDevice.Children.Add(groupDevice);
					}
					else
					{
						if (shleifDevice != null)
							shleifDevice.Children.Add(firstDeviceInGroup);
					}
				}
			}
			return true;
		}
Ejemplo n.º 9
0
		ExportPassJournalItem Translate(PassJournal tableItem, List<Employee> employees)
		{
			var employee = employees.FirstOrDefault(x => x.UID == tableItem.EmployeeUID);
			var zone = GKManager.SKDZones.FirstOrDefault(x => x.UID == tableItem.ZoneUID);
			return new ExportPassJournalItem
			{
				UID = tableItem.UID,
				EmployeeUID = tableItem.EmployeeUID != null ? tableItem.EmployeeUID.Value : Guid.Empty,
				EmployeeFIO = employee != null ? employee.LastName + " " + employee.FirstName + " " + employee.SecondName : "",
				EnterDateTime = tableItem.EnterTime,
				ExitDateTime = tableItem.ExitTime != null ? tableItem.ExitTime.Value : new DateTime(),
				ZoneUID = tableItem.ZoneUID,
				ZoneNo = zone != null ? zone.No : -1
			};
		}
Ejemplo n.º 10
0
        void SetListView()
        {
            lvMacStatus.Items.Clear();

            if (this.m_AllStatusMonitoring.Count == 0)
            {
                return;
            }
            int tmp = 0;
            if (this.m_AllStatusMonitoring.Count - m_iNowPage * this.m_iMaxCount > 0)
            {
                tmp = this.m_iMaxCount;
            }
            else
            {
                tmp = this.m_AllStatusMonitoring.Count - (m_iNowPage - 1) * this.m_iMaxCount;
            }

            ListViewItem lvitem;

            List<ComboboxDataInfo> cdList = new List<ComboboxDataInfo>();

            cdList.Add(new ComboboxDataInfo("待生產", CustEnum.ProjectStatus.SCHEDULE.ToString()));
            cdList.Add(new ComboboxDataInfo("準備中", CustEnum.ProjectStatus.PREPARE.ToString()));
            cdList.Add(new ComboboxDataInfo("準備超時", CustEnum.ProjectStatus.PREPARE_OT.ToString()));
            cdList.Add(new ComboboxDataInfo("生產中", CustEnum.ProjectStatus.PROD_IN.ToString()));
            cdList.Add(new ComboboxDataInfo("生產中停機", CustEnum.ProjectStatus.PROD_STOP.ToString()));
            cdList.Add(new ComboboxDataInfo("生產中停機超時", CustEnum.ProjectStatus.PROD_STOP_OT.ToString()));
            cdList.Add(new ComboboxDataInfo("完成", CustEnum.ProjectStatus.FINISH.ToString()));
            cdList.Add(new ComboboxDataInfo("抽起", CustEnum.ProjectStatus.STOP.ToString()));

            for (int i = (m_iNowPage - 1) * this.m_iMaxCount; i < (m_iNowPage - 1) * this.m_iMaxCount + tmp; i++)
            {
                lvitem = new ListViewItem();
                lvitem.SubItems[0].Text = this.m_AllStatusMonitoring[i].MachineID;
                lvitem.SubItems.Add(this.m_AllStatusMonitoring[i].ProjectNO);
                lvitem.SubItems.Add(this.m_AllStatusMonitoring[i].SONO);

                ComboboxDataInfo macStatc = cdList.FirstOrDefault(t => t.ValueMember == this.m_AllStatusMonitoring[i].MacStatus.Replace("狀態:", ""));

                if (macStatc != null)
                {
                    lvitem.SubItems.Add(macStatc.DisplayMember);

                    lvitem.ImageIndex = GetMacchineBMP(macStatc.ValueMember);
                }
                else
                {
                    lvitem.SubItems.Add(this.m_AllStatusMonitoring[i].MacStatus);

                    lvitem.ImageIndex = GetMacchineBMP(this.m_AllStatusMonitoring[i].MacStatus);
                }

                lvitem.SubItems.Add(this.m_AllStatusMonitoring[i].MachineCaption);

                lvitem.SubItems.Add(this.m_AllStatusMonitoring[i].choldTime.Replace("00:00:00", "未知"));

                //lvitem.SubItems.Add(this.m_AllStatusMonitoring[i].ProdSpeed);
                // lvitem.ImageIndex = GetImgIndex(this.m_AllStatusMonitoring[i].MacStatus);

                lvMacStatus.Items.Add(lvitem);
            }
        }
Ejemplo n.º 11
0
        private void MapQuestions(EditQuizModel source, Quiz destination)
        {
            var existingQuestions = new List<Question>(destination.Questions);
            destination.Questions.Clear();

            foreach (var question in source.Questions)
            {
                var existingQuestion = existingQuestions.FirstOrDefault(q => q.Id == question.Id);
                if (existingQuestion == null)
                {
                    destination.Questions.Add(this.Mapper.Map<Question>(question));
                }
                else
                {
                    destination.Questions.Add(existingQuestion);

                    this.Mapper.Map(question, existingQuestion);
                    var existingAnswers = new List<Answer>(existingQuestion.Answers);
                    existingQuestion.Answers.Clear();

                    foreach (var answer in question.Answers)
                    {
                        var existingAnswer = existingAnswers.FirstOrDefault(a => a.Id == answer.Id);
                        if (existingAnswer == null)
                        {
                            existingQuestion.Answers.Add(this.Mapper.Map<Answer>(answer));
                        }
                        else
                        {
                            this.Mapper.Map(answer, existingAnswer);
                            existingQuestion.Answers.Add(existingAnswer);
                        }
                    }

                    this.Mapper.Map(question, existingQuestion);
                }
            }
        }
Ejemplo n.º 12
0
        private void LlenaForm(DataRowView FilaSeleccionada)
        {
            List<PRODUCTO> listaProd = new List<PRODUCTO>();
            listaProd = cPRODUCTO.ObtenerActivos().Where(x => x.PRO_ID == Convert.ToInt32(FilaSeleccionada["PRO_ID"])).ToList();

            PRODUCTO oPRODUCTO = listaProd.FirstOrDefault();

            cmbProducto.DataSource = listaProd;
            cmbProducto.DisplayMember = "PRO_DESCRIPCION";
            cmbProducto.ValueMember = "PRO_ID";
            cmbProducto.SelectedIndex = 0;

            txtCodigoBarra.Text = oPRODUCTO.PRO_BARRAS;
            numCostoSinIva.Value = Convert.ToDecimal(FilaSeleccionada["PRECIOCOSTO_SINIVA"]);
            numCostoConIva.Value = Convert.ToDecimal(FilaSeleccionada["PRECIOCOSTO_CONIVA"]);
            cmbTipoIva.SelectedValue = (int)FilaSeleccionada["TIVA_ID"];
            numCantidad.Value = Convert.ToDecimal(FilaSeleccionada["CANTIDAD"]);
            numCantidadTotal.Value = Convert.ToDecimal(FilaSeleccionada["CANTIDAD_TOTAL"]);

            txtPorcGanReal.Text = (FilaSeleccionada["PRO_MARGENGANANCIAREAL"]).ToString();
            numPorcGanEstimada.Value = Convert.ToDecimal(FilaSeleccionada["PRO_MARGENGANACIAESTIMADA"]);
            numPrecioVenta.Value = Convert.ToDecimal(FilaSeleccionada["PRECIO_VENTA"]);
            numDescuento.Value = Convert.ToDecimal(FilaSeleccionada["PORCENTAJEDESCUENTO"]);
            chkModificaPrecioVenta.Checked = (bool)FilaSeleccionada["MODIFICA_PRECIO_VENTA"];
            chkBulto.Checked = (bool)FilaSeleccionada["ES_BULTO"];

            numBulto.Value = Convert.ToDecimal(FilaSeleccionada["CANTIDAD_BULTO"]);
            numBultoSinIva.Value = Convert.ToDecimal(FilaSeleccionada["PRECIOBULTO_SINIVA"]);
            numBultoConIva.Value = Convert.ToDecimal(FilaSeleccionada["PRECIOBULTO_CONIVA"]);
            numImpuesto.Value = Convert.ToDecimal(FilaSeleccionada["IMPUESTO"]);

            txtCodigoBarra.Enabled = false;
            cmbProducto.Enabled = false;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 初始化選項列表控件
        /// </summary>
        void loadButtonList(List<ProjectBaseItemModel> listPrepareItems)
        {
            try
            {
                this._projectPrepareWorkBase.ButtonListPrepareItems.DataSource = listPrepareItems;
                this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonEnabled = true;
                this._projectPrepareWorkBase.ButtonListPrepareItems.DisplayMember = "Description";
                this._projectPrepareWorkBase.ButtonListPrepareItems.ValueMember = "Code";
                this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonSelectedColor = GlobalVar.Color_select;
                this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonDefaultBackColor = GlobalVar.Color_notSelect;
                this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonClick -= btnClick;
                this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonClick += btnClick;

                switch (ScreenSizeFactory.ScreenSize)
                {
                    case ScreenSizeType.Size1024X768:
                        this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonHeight = 80;
                        this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonWidth = 150;
                        this._projectPrepareWorkBase.ButtonListPrepareItems.PageSize = 16;
                        break;
                    case ScreenSizeType.Size800X600:
                        this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonHeight = 65;
                        this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonWidth = 120;
                        this._projectPrepareWorkBase.ButtonListPrepareItems.PageSize = 12;
                        break;
                    default:
                        this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonHeight = 65;
                        this._projectPrepareWorkBase.ButtonListPrepareItems.ButtonWidth = 120;
                        this._projectPrepareWorkBase.ButtonListPrepareItems.PageSize = 12;
                        break;
                }

                if (listPrepareItems != null)
                {
                    this._projectPrepareWorkBase.ButtonListPrepareItems.ShowButtonList();

                    if (this.m_Controller.ProjectProductionInfo != null && this.m_Controller.ProjectProductionInfo.PrepareJobItems != null)
                    {
                        IList<object> selectedItems = new List<object>();
                        foreach (var item in this.m_Controller.ProjectProductionInfo.PrepareJobItems)
                        {
                            var ppm = listPrepareItems.FirstOrDefault(d => d.Code.Trim() == item.ppji_PPMID.ToString().Trim());
                            if (ppm != null)
                            {
                                selectedItems.Add(ppm);
                            }
                        }

                        this._projectPrepareWorkBase.ButtonListPrepareItems.SelectedItems = selectedItems;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 14
0
		static OperationResult<List<GKProperty>> GetDeviceParameters(CommonDatabase commonDatabase, BaseDescriptor descriptor)
		{
			var properties = new List<GKProperty>();

			var no = descriptor.GetDescriptorNo();
			var sendResult = SendManager.Send(commonDatabase.RootDevice, 2, 9, ushort.MaxValue, BytesHelper.ShortToBytes(no));
			if (sendResult.HasError)
			{
				return OperationResult<List<GKProperty>>.FromError(sendResult.Error);
			}

			var binProperties = new List<BinProperty>();
			for (int i = 0; i < sendResult.Bytes.Count / 4; i++)
			{
				byte paramNo = sendResult.Bytes[i * 4];
				ushort paramValue = BytesHelper.SubstructShort(sendResult.Bytes, i * 4 + 1);
				var binProperty = new BinProperty()
				{
					No = paramNo,
					Value = paramValue
				};
				binProperties.Add(binProperty);
			}

			var device = descriptor.GKBase as GKDevice;
			if (device != null)
			{
				foreach (var driverProperty in device.Driver.Properties)
				{
					if (!driverProperty.IsAUParameter)
						continue;

					var binProperty = binProperties.FirstOrDefault(x => x.No == driverProperty.No);
					if (binProperty != null)
					{
						var paramValue = binProperty.Value;
						if (driverProperty.IsLowByte)
						{
							paramValue = (ushort)(paramValue << 8);
							paramValue = (ushort)(paramValue >> 8);
						}
						if (driverProperty.IsHieghByte)
						{
							paramValue = (ushort)(paramValue / 256);
						}
						if (driverProperty.Mask != 0)
						{
							paramValue = (byte)(paramValue & driverProperty.Mask);
						}
						var property = device.DeviceProperties.FirstOrDefault(x => x.Name == driverProperty.Name);
						if (property == null)
						{
							var systemProperty = device.Properties.FirstOrDefault(x => x.Name == driverProperty.Name);
							property = new GKProperty()
							{
								DriverProperty = systemProperty.DriverProperty,
								Name = systemProperty.Name,
								Value = paramValue,
							};
							device.DeviceProperties.Add(property);
						}
						if (property != null)
						{
							property.Value = paramValue;
							property.DriverProperty = driverProperty;
							if (property.DriverProperty.DriverPropertyType == GKDriverPropertyTypeEnum.BoolType)
								property.Value = (ushort)(property.Value > 0 ? 1 : 0);

							properties.Add(property);
						}
					}
					else
						return OperationResult<List<GKProperty>>.FromError("Неизвестный номер параметра");
				}
			}
			if ((descriptor.DescriptorType == DescriptorType.Direction || descriptor.DescriptorType == DescriptorType.Delay
				|| descriptor.DescriptorType == DescriptorType.GuardZone || descriptor.DescriptorType == DescriptorType.PumpStation) && binProperties.Count >= 3)
			{
				properties.Add(new GKProperty() { Value = binProperties[0].Value });
				properties.Add(new GKProperty() { Value = binProperties[1].Value });
				properties.Add(new GKProperty() { Value = binProperties[2].Value });
			}
			if ((descriptor.DescriptorType == DescriptorType.Code || descriptor.DescriptorType == DescriptorType.Door) && binProperties.Count >= 2)
			{
				properties.Add(new GKProperty() { Value = binProperties[0].Value });
				properties.Add(new GKProperty() { Value = binProperties[1].Value });
			}
			return new OperationResult<List<GKProperty>>(properties);
		}
        /// <summary>
        /// Maps the visitor information.
        /// </summary>
        /// <param name="visitors">The visitors.</param>
        /// <param name="personsStatusHistory">The persons status history.</param>
        /// <param name="personStatusList">The person status list.</param>
        private static void MapVisitorInformation(VisitorCollection visitors, ListResult<PersonStatusHistory> personsStatusHistory, List<PersonStatus> personStatusList)
        {
            foreach (var visitor in visitors)
            {
                var item = personStatusList.FirstOrDefault(a => a.PersonId.ToString(CultureInfo.CurrentCulture).Equals(visitor.VisitorId));
                var personStatusHistory = new PersonStatusHistory();
                personStatusHistory.PersonId = visitor.VisitorId;
                personStatusHistory.FirstName = visitor.PersonalDetail.FirstName;
                personStatusHistory.MiddleName = visitor.PersonalDetail.MiddleName;
                personStatusHistory.LastName = visitor.PersonalDetail.LastName;
                personStatusHistory.Gender = visitor.PersonalDetail.Gender;
                personStatusHistory.Age = visitor.PersonalDetail.Age ?? 0;
                personStatusHistory.LastEvent = item != null ? item.Status : visitor.LastEvent;
                ////personStatusHistory.LastDateTime = item != null ? item.StatusChangedDate : visitor.LastDateTime;
                personStatusHistory.PersonTypeId = CommonConstants.VisitorTypeId;

                personsStatusHistory.Items.Add(personStatusHistory);
            }
        }
        /// <summary>
        /// Maps the guest information.
        /// </summary>
        /// <param name="guests">The guests.</param>
        /// <param name="personsStatusHistory">The persons status history.</param>
        /// <param name="personStatusList">The person status list.</param>
        private static void MapGuestInformation(GuestCollection guests, ListResult<PersonStatusHistory> personsStatusHistory, List<PersonStatus> personStatusList)
        {
            foreach (var guest in guests)
            {
                var item = personStatusList.FirstOrDefault(a => a.PersonId.ToString(CultureInfo.CurrentCulture).Equals(guest.GuestId));
                var personStatusHistory = new PersonStatusHistory();
                personStatusHistory.PersonId = guest.GuestId;
                personStatusHistory.FirstName = guest.PersonalDetail.FirstName;
                personStatusHistory.MiddleName = guest.PersonalDetail.MiddleName;
                personStatusHistory.LastName = guest.PersonalDetail.LastName;
                personStatusHistory.Gender = guest.PersonalDetail.Gender;
                personStatusHistory.Age = guest.PersonalDetail.Age ?? 0;
                personStatusHistory.LastEvent = item != null ? item.Status : guest.LastEvent;
                personStatusHistory.LastDateTime = item != null ? item.StatusChangedDate : guest.LastDateTime;
                personStatusHistory.PersonTypeId = CommonConstants.GuestTypeId;
                personStatusHistory.ReservationNumber = guest.CruiseDetail.ReservationNumber;
                personStatusHistory.Stateroom = guest.CruiseDetail.Stateroom;

                personsStatusHistory.Items.Add(personStatusHistory);
            }
        }
        /// <summary>
        /// Gets a new <c>EntityReference</c> object that represents an instance of an entity within the target system.
        /// </summary>
        /// <param name="field">The field that is currently being set to a <c>EntityReference</c>.</param>
        /// <param name="mappedLookupObject">The <c>Dictionary</c> that contains the data for populating the returned <c>EntityReference</c>.</param>
        /// <returns>A new instance of a <c>EntityReference</c> object initialized with the proper values from the target system or null
        /// if the dynamics_integrationkey in the supplied <c>Dictionary</c> is null or empty.</returns> 
        protected EntityReference MapEntityReference(FieldDefinition field, Dictionary<string, object> mappedLookupObject)
        {
            if (field == null)
            {
                throw new AdapterException(string.Format(CultureInfo.CurrentCulture, Resources.ArgumentNullExceptionMessage), new ArgumentNullException("field")) { ExceptionId = AdapterException.SystemExceptionGuid };
            }

            if (mappedLookupObject == null)
            {
                throw new AdapterException(string.Format(CultureInfo.CurrentCulture, Resources.ArgumentNullExceptionMessage), new ArgumentNullException("mappedLookupObject")) { ExceptionId = AdapterException.SystemExceptionGuid };
            }

            CRM2011AdapterUtilities.ValidateDictionary(mappedLookupObject);
            EntityReference reference = this.GetReferenceInstanceType(field);

            var lookupField = field.AdditionalAttributes.FirstOrDefault(x => x.Name == "LookupField");
            var lookupEntity = field.AdditionalAttributes.FirstOrDefault(x => x.Name == "LookupType");

            var typeSplit = lookupEntity.Value.Split(',');
            var fieldSplit = lookupField.Value.Split(',');
            var typeFieldList = new List<KeyValuePair<string, string>>();

            if (typeSplit.Count() > 1 && fieldSplit.Count() > 1)
            {
                for (int i = 0; i < typeSplit.Count(); i++)
                {
                    typeFieldList.Add(new KeyValuePair<string, string>(typeSplit[i], fieldSplit[i]));
                }

                lookupEntity.Value = mappedLookupObject["LogicalName"].ToString();
                lookupField.Value = typeFieldList.FirstOrDefault(x => x.Key == lookupEntity.Value).Value;
            }

            if (lookupField != null && lookupEntity != null)
            {
                var entityCollection = this.RetrieveEntityReferenceValue(field, lookupEntity, lookupField, mappedLookupObject);
                if (entityCollection != null)
                {
                    if (entityCollection.Entities.Count != 0)
                    {
                        var integrationKeyValue = entityCollection.Entities.First().Id;

                        if (integrationKeyValue != Guid.Empty && integrationKeyValue != null)
                        {
                            return new EntityReference(lookupEntity.Value, integrationKeyValue);
                        }
                    }
                }
            }
            else
            {
                CRM2011AdapterUtilities.SetRelationshipValuesFromDictionary(mappedLookupObject, reference);
            }

            if (reference.Id == Guid.Empty)
            {
                if (field.Name.Contains("pricelevelid"))
                {
                    reference = new EntityReference("pricelevel", (Guid)this.GetBaseCurrencyPriceLevel()["pricelevelid"]);
                    return reference;
                }

                if (field.Name == "transactioncurrencyid")
                {
                    reference = new EntityReference("transactioncurrency", this.CrmAdapter.BaseCurrencyId);
                    return reference;
                }

                return null;
            }

            if (reference.Id == Guid.Empty)
            {
                return null;
            }

            return reference;
        }
        /// <summary>
        /// Gets a <c>Dictionary</c> that represents a <c>DynamicEntity</c>.
        /// </summary>
        /// <param name="entity">The CRM <c>Entity</c> to return as a <c>Dictioanry</c>.</param>
        /// <param name="adapter">An instance of a <c>CRMAdapter</c> to use when getting dynamics_integrationkey data for a <c>Lookup</c> type.</param>
        /// <param name="fieldDefinitions">The <C>List</C> of <see cref="FieldDefinition"/>s to use when populating the <C>Dictionary</C>.</param>
        /// <returns>A <c>Dictionary</c> that has Keys that are the property names of the <c>DynamicEntity</c> supplied and 
        /// Values that are the values of those properties on the <c>DynamicEntity</c>.</returns>
        internal static Dictionary<string, object> GetDictionary(Entity entity, DynamicCrmAdapter adapter, List<FieldDefinition> fieldDefinitions)
        {
            Dictionary<string, object> dictionary = new Dictionary<string, object>();

            // This dictionary is for holding a complexType that might be the type for the current property on the entity
            Dictionary<string, object> holdingDictionary;
            foreach (KeyValuePair<string, object> property in entity.Attributes)
            {
                // CrmMoney needs the dictionary to be converted but it also starts with the same prefix as the property types that do not,so handle it separately
                // else if the property is not one of the Built-in types and is also not of the StringProperty type, use the holding dictionary
                Type propertyType = property.Value.GetType();
                holdingDictionary = new Dictionary<string, object>();
                if (propertyType == typeof(Money))
                {
                    PopulateDictionary(entity, holdingDictionary, property);
                }
                else if (propertyType == typeof(OptionSetValue))
                {
                    PopulateOptionSetValueDictionary(entity, holdingDictionary, property, adapter);
                }
                else if (propertyType == typeof(EntityReference))
                {
                    FieldDefinition definition = fieldDefinitions.FirstOrDefault(x => x.Name == property.Key);
                    PopulateDictionary(entity, holdingDictionary, property, adapter, definition);
                }
                else if (propertyType == typeof(EntityCollection))
                {
                    FieldDefinition definition = fieldDefinitions.FirstOrDefault(x => x.Name == property.Key);
                    PopulatePartyList(entity, holdingDictionary, property, adapter, definition);
                }

                // The property is of a ComplexType and the holding dictionary was populated
                // else if the property is one of the Built-in CRM types just convert it
                // else if the property was a string property, just use its value
                if (holdingDictionary.Count > 0)
                {
                    dictionary.Add(property.Key, holdingDictionary);
                }
                else
                {
                    dictionary.Add(property.Key, property.Value);
                }
            }

            if (fieldDefinitions.Any(x => x.Name == "overriddencreatedon"))
            {
                dictionary.Add("overriddencreatedon", null);
            }

            return dictionary;
        }
        /// <summary>
        /// Populates a <c>Dictionary</c> with the values contained in a <c>DynamicEntity</c>.
        /// </summary>
        /// <param name="dynamicEntity">The <c>DynamicEntity</c> to get the properties and data from.</param>
        /// <param name="complexTypeDictionary">The <c>Dictionary</c> to be populated.</param>
        /// <param name="property">The property on the <c>DynamicEntity</c> to populate the supplied <c>Dictionary</c> for.</param>
        /// <param name="adapter">An instance of a <c>CRMAdapter</c> to use when getting dynamics_integrationkey data for a <c>Lookup</c> type.</param>
        /// <param name="definition">The <see cref="FieldDefinition"/> for the referenced entity.</param>
        private static void PopulateDictionary(Entity dynamicEntity, Dictionary<string, object> complexTypeDictionary, KeyValuePair<string, object> property, DynamicCrmAdapter adapter, FieldDefinition definition)
        {
            PopulateDictionary(dynamicEntity, complexTypeDictionary, property);

            if (complexTypeDictionary.ContainsKey("Id") && complexTypeDictionary.ContainsKey("LogicalName"))
            {
                if (complexTypeDictionary["LogicalName"].ToString() != "attachment" && complexTypeDictionary["LogicalName"].ToString() != "activitymimeattachment")
                {
                    ColumnSet cols = new ColumnSet(true);
                    if (!CRM2011AdapterUtilities.GetIntegratedEntities().Contains(complexTypeDictionary["LogicalName"].ToString()))
                    {
                        cols = new ColumnSet(true);
                    }

                    RetrieveRequest request = new RetrieveRequest() { ColumnSet = cols, Target = new EntityReference(complexTypeDictionary["LogicalName"].ToString(), new Guid(complexTypeDictionary["Id"].ToString())) };
                    RetrieveResponse response = adapter.OrganizationService.Execute(request) as RetrieveResponse;
                    Entity entity = response.Entity;

                    var lookupType = definition.AdditionalAttributes.FirstOrDefault(x => x.Name == "LookupType");
                    var lookupField = definition.AdditionalAttributes.FirstOrDefault(x => x.Name == "LookupField");

                    var typeSplit = lookupType.Value.Split(',');
                    var fieldSplit = lookupField.Value.Split(',');

                    var keyValueLookup = new List<KeyValuePair<string, string>>();

                    if (typeSplit.Count() > 1 && fieldSplit.Count() > 1)
                    {
                        for (int i = 0; i < typeSplit.Count(); i++)
                        {
                            keyValueLookup.Add(new KeyValuePair<string, string>(typeSplit[i], fieldSplit[i]));
                        }

                        lookupField.Value = keyValueLookup.FirstOrDefault(x => x.Key == entity.LogicalName).Value;
                    }

                    if (lookupField != null)
                    {
                        if (lookupField.Value == "domainname" || entity.LogicalName == "systemuser")
                        {
                            lookupField.Value = "fullname";
                        }
                        else if (entity.LogicalName == "activitypointer")
                        {
                            lookupField.Value = "activityid";
                        }

                        complexTypeDictionary.Add(lookupField.Value, entity[lookupField.Value]);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        protected void CreateOrUpdateHook(string owner, string repository, Site website)
        {
            string baseUri = website.GetProperty("repositoryuri");
            string publishingUsername = website.GetProperty("publishingusername");
            string publishingPassword = website.GetProperty("publishingpassword");
            UriBuilder newUri = new UriBuilder(baseUri);
            newUri.UserName = publishingUsername;
            newUri.Password = publishingPassword;
            newUri.Path = "/deploy";

            string deployUri = newUri.ToString();

            List<GithubRepositoryHook> repositoryHooks = new List<GithubRepositoryHook>();
            InvokeInGithubOperationContext(() => { repositoryHooks = PSCmdlet.GithubChannel.GetRepositoryHooks(owner, repository); });

            var existingHook = repositoryHooks.FirstOrDefault(h => h.Name.Equals("web") && new Uri(h.Config.Url).Host.Equals(new Uri(deployUri).Host));
            if (existingHook != null)
            {
                if (!existingHook.Config.Url.Equals(newUri.ToString(), StringComparison.InvariantCultureIgnoreCase))
                {
                    existingHook.Config.Url = deployUri;
                    InvokeInGithubOperationContext(() => PSCmdlet.GithubChannel.UpdateRepositoryHook(owner, repository, existingHook.Id, existingHook));
                    InvokeInGithubOperationContext(() => PSCmdlet.GithubChannel.TestRepositoryHook(owner, repository, existingHook.Id));
                }
                else
                {
                    throw new Exception(Resources.LinkAlreadyEstablished);
                }
            }
            else
            {
                GithubRepositoryHook githubRepositoryHook = new GithubRepositoryHook()
                {
                    Name = "web",
                    Active = true,
                    Events = new List<string> { "push" },
                    Config = new GithubRepositoryHookConfig
                    {
                        Url = deployUri,
                        InsecureSsl = "1",
                        ContentType = "form"
                    }
                };

                InvokeInGithubOperationContext(() => { githubRepositoryHook = PSCmdlet.GithubChannel.CreateRepositoryHook(owner, repository, githubRepositoryHook); });
                InvokeInGithubOperationContext(() => PSCmdlet.GithubChannel.TestRepositoryHook(owner, repository, githubRepositoryHook.Id));
            }  
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Retrieves the guest.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="personData">The person data.</param>
        /// <param name="workStation">The work station.</param>
        /// <param name="eventType">Type of the event.</param>
        /// <param name="personTypeList">The person type list.</param>
        /// <param name="personList">The person list.</param>
        /// <returns>
        /// The person
        /// </returns>
        private static Person RetrievePerson(NotificationEvent message, Person personData, Workstation workStation, NotificationEventType eventType, List<PersonType> personTypeList, IList<PersonBase> personList)
        {
            var person = personList.Where(p => p.PersonId == message.PersonId).FirstOrDefault();
            var task = Task.Run(async () => await PersonsService.RetrievePersonsBySearchText(workStation.Ship.ShipId, null, personTypeList, SearchType.PersonId, personId: message.PersonId, folioNumber: null));
            task.Wait();
            if (!task.IsCanceled && !task.IsFaulted)
            {
                personData = task.Result;

                PersonBase retrievedPerson = null;

                if (personTypeList.FirstOrDefault() == PersonType.Guest)
                {
                    retrievedPerson = personData.Guests.FirstOrDefault().MapToPersonBase();
                }
                else if (personTypeList.FirstOrDefault() == PersonType.Crewmember)
                {
                    retrievedPerson = personData.Crewmembers.FirstOrDefault().MapToPersonBase();
                }
                else if (personTypeList.FirstOrDefault() == PersonType.Visitor)
                {
                    retrievedPerson = personData.Visitors.FirstOrDefault().MapToPersonBase();
                }

                if (personData != null)
                {
                    MapPersonData(person, retrievedPerson, eventType);

                    if (person != null)
                    {
                        RetrievePhoto(person);
                    }
                }
            }

            return personData;
        }
Ejemplo n.º 22
0
        private void CheckedNode(TreeNode node, List<Sys_UserPurview_usp_Info> rightList)
        {
            if (rightList != null)
            {
                Sys_UserPurview_usp_Info info = rightList.FirstOrDefault(t => t.usp_iFormID == Convert.ToInt32(node.Name));

                if (info != null)
                {
                    node.Checked = true;
                }
                else
                {
                    node.Checked = false;
                }

                if (node.Nodes != null && node.Nodes.Count > 0)
                {
                    foreach (TreeNode item in node.Nodes)
                    {
                        CheckedNode(item, rightList);
                    }
                }
            }
            else
            {

                node.Checked = false;

                CheckedNode(node, new List<Sys_UserPurview_usp_Info>());
            }
        }
Ejemplo n.º 23
0
 public OAuthOption GetAuthOption(AuthProvider provider)
 {
     return(_oauthOptions
            ?.FirstOrDefault(x => x.Provider == provider));
 }
        /// <summary>
        /// Maps the crew information.
        /// </summary>
        /// <param name="crews">The crews.</param>
        /// <param name="personsStatusHistory">The persons status history.</param>
        /// <param name="personStatusList">The person status list.</param>
        private static void MapCrewInformation(CrewmemberCollection crews, ListResult<PersonStatusHistory> personsStatusHistory, List<PersonStatus> personStatusList)
        {
            foreach (var crew in crews)
            {
                var item = personStatusList.FirstOrDefault(a => a.PersonId.ToString(CultureInfo.CurrentCulture).Equals(crew.CrewmemberId));
                var personStatusHistory = new PersonStatusHistory();
                personStatusHistory.PersonId = crew.CrewmemberId;
                personStatusHistory.FirstName = crew.PersonalDetail.FirstName;
                personStatusHistory.MiddleName = crew.PersonalDetail.MiddleName;
                personStatusHistory.LastName = crew.PersonalDetail.LastName;
                personStatusHistory.Gender = crew.PersonalDetail.Gender;
                personStatusHistory.Age = crew.PersonalDetail.Age ?? 0;
                personStatusHistory.LastEvent = item != null ? item.Status : crew.LastEvent;
                personStatusHistory.LastDateTime = item != null ? item.StatusChangedDate : crew.LastDateTime;
                personStatusHistory.PersonTypeId = CommonConstants.CrewmemberTypeId;
                personStatusHistory.Stateroom = crew.Stateroom;

                personsStatusHistory.Items.Add(personStatusHistory);
            }
        }
Ejemplo n.º 25
0
		public static List<RviDevice> GetRviDevices(string url, string login, string password, List<Camera> existingCameras, out bool isNotConnected)
		{
			var devices = GetDevices(url, login, password, out isNotConnected);
			var rviDevices = new List<RviDevice>();
			var newCameras = new List<Camera>();
			foreach (var device in devices)
			{
				var rviDevice = new RviDevice { Uid = device.Guid, Ip = device.Ip, Name = device.Name, Status = ConvertToRviStatus(device.Status) };
				rviDevices.Add(rviDevice);
				foreach (var channel in device.Channels)
				{
					var camera = new Camera
					{
						UID = channel.Guid,
						Name = channel.Name,
						RviServerUrl = url,
						RviDeviceName = device.Name,
						RviDeviceUID = device.Guid,
						Ip = device.Ip,
						Number = channel.Number,
						Vendor = channel.Vendor,
						CountPresets = channel.CountPresets,
						CountTemplateBypass = channel.CountTemplateBypass,
						CountTemplatesAutoscan = channel.CountTemplatesAutoscan,
						Status = ConvertToRviStatus(device.Status),
						IsRecordOnline = channel.IsRecordOnline,
						IsOnGuard = channel.IsOnGuard
					};
					foreach (var stream in channel.Streams)
					{
						var rviStream = new RviStream { Number = stream.Number, RviDeviceUid = device.Guid, RviChannelNumber = channel.Number };
						camera.RviStreams.Add(rviStream);
					}
					camera.SelectedRviStreamNumber = camera.RviStreams.Count > 0 ? camera.RviStreams.First().Number : 0;
					rviDevice.Cameras.Add(camera);
					newCameras.Add(camera);
				}
			}
			if (existingCameras != null)
			{
				foreach (var existingCamera in existingCameras)
				{
					var camera = newCameras.FirstOrDefault(newCamera => newCamera.UID == existingCamera.UID);
					if (camera != null)
					{
						camera.ShowDetailsHeight = existingCamera.ShowDetailsHeight;
						camera.ShowDetailsWidth = existingCamera.ShowDetailsWidth;
						camera.ShowDetailsMarginLeft = existingCamera.ShowDetailsMarginLeft;
						camera.ShowDetailsMarginTop = existingCamera.ShowDetailsMarginTop;
						camera.PlanElementUIDs = existingCamera.PlanElementUIDs;
					}
				}
			}
			return rviDevices;
		}
Ejemplo n.º 26
0
 /// <summary>
 /// Function to updates the selected person.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="personData">The person data.</param>
 /// <param name="personTypeList">The person type list.</param>
 /// <param name="personsPartyManager">The persons party manager.</param>
 /// <param name="eventType">Type of the event.</param>
 private static void UpdateSelectedPerson(NotificationEvent message, Person personData, List<PersonType> personTypeList, PersonsPartyManager personsPartyManager, NotificationEventType eventType)
 {
     if (personTypeList.FirstOrDefault() == PersonType.Guest && personsPartyManager.CurrentParty.IsPartyCreated)
     {
         var guest = personsPartyManager.CurrentParty.Guests.FirstOrDefault(g => g.GuestId.Equals(message.PersonId, StringComparison.OrdinalIgnoreCase));
         MapGuestData(guest, personData.Guests.FirstOrDefault(), eventType);
         RetrieveGuestPhoto(guest);
     }
     else if (personTypeList.FirstOrDefault() == PersonType.Crewmember && personsPartyManager.CurrentParty.IsPartyCreated)
     {
         var crewMember = personsPartyManager.CurrentParty.Crew.FirstOrDefault(c => c.CrewmemberId.Equals(message.PersonId, StringComparison.OrdinalIgnoreCase));
         MapCrewMemberData(crewMember, personData, eventType);
         RetrieveCrewmemberPhoto(crewMember);
     }
     else if (personTypeList.FirstOrDefault() == PersonType.Visitor && personsPartyManager.CurrentParty.IsPartyCreated)
     {
         var visitor = personsPartyManager.CurrentParty.Visitors.FirstOrDefault(v => v.VisitorId.Equals(message.PersonId, StringComparison.OrdinalIgnoreCase));
         MapVisitorData(visitor, personData, eventType);
         RetrieveVisitorPhoto(visitor);
     }
 }
Ejemplo n.º 27
0
		public void InitializeArguments(List<Variable> variables, List<Argument> arguments, List<Variable> callingProcedureVariables)
		{
			int i = 0;
			foreach (var variable in variables)
			{
				var list = new List<object>();
				if (arguments.Count <= i)
					break;
				var argument = arguments[i];
				if (argument == null)
					break;
				if (argument.VariableScope == VariableScope.ExplicitValue)
				{
					variable.Value = argument.Value;
				}
				else
				{
					var argumentVariable = callingProcedureVariables.FirstOrDefault(x => x.Uid == argument.VariableUid);
					if (argumentVariable == null)
						continue;
					if (argumentVariable.IsReference)
						variable.Value = argumentVariable.Value;
					else
						variable.Value = argumentVariable.Value;
				}
				i++;
			}
		}
		void UpdateDeviceStateDetalisation(Device device)
		{
			try
			{
				var additionalParameters = new List<Parameter>();

				var deviceTable = MetadataHelper.GetMetadataDeviceTable(device);
				if (deviceTable != null && deviceTable.detalization != null)
				{
					foreach (var metadataDetalization in deviceTable.detalization)
					{
						var stateType = (StateType)Int32.Parse(metadataDetalization.@class);
						string parameterName = null;
						switch (stateType)
						{
							case StateType.Norm:
								parameterName = "OtherMessage";
								break;

							case StateType.Failure:
								parameterName = "FailureType";
								break;

							case StateType.Fire:
								parameterName = "AlarmReason";
								break;
						}
						if (parameterName != null)
						{
							if (device.DeviceState.StateType == stateType)
							{
								var rawParameterValue = 0;
								var rawParameterIndex = -1;
								if (metadataDetalization.source == null)
								{
									if (metadataDetalization.stateByte != null)
									{
										switch (metadataDetalization.stateByte)
										{
											case "high":
												rawParameterIndex = 0;
												//if (device.StateWordBytes.Count > 0)
												//    rawParameterValue = device.StateWordBytes[0];
												break;
										}
									}
									else
									{
										rawParameterIndex = 1;
									}
								}
								else
								{
									var splittedSources = metadataDetalization.source.Split('_');
									var source = splittedSources.Last();
									rawParameterIndex = GetRawParameterIndex(source);
								}
								if (rawParameterIndex != -1)
								{
									if (device.RawParametersBytes != null && device.RawParametersBytes.Count > rawParameterIndex)
									{
										rawParameterValue = device.RawParametersBytes[rawParameterIndex];
									}
								}

								var statusBytesArray = new byte[] { (byte)rawParameterValue };
								var bitArray = new BitArray(statusBytesArray);

								var metadataDictionary = MetadataHelper.Metadata.dictionary.FirstOrDefault(x => x.name == metadataDetalization.dictionary);
								if (metadataDictionary != null)
								{
									foreach (var matadataBit in metadataDictionary.bit)
									{
										var isMatch = false;
										if (matadataBit.no.Contains("-"))
										{
											var stringBits = matadataBit.no.Split('-');
											if (stringBits.Count() == 2)
											{
												var startBit = Int32.Parse(stringBits[0]);
												var endBit = Int32.Parse(stringBits[1]);
												var maskedParameterValue = rawParameterValue & ((1 << startBit) + (1 << endBit));
												if (maskedParameterValue == Int32.Parse(matadataBit.val))
												{
													isMatch = true;
												}
											}
										}
										else
										{
											var bitNo = Int32.Parse(matadataBit.no);
											if (bitArray[bitNo])
											{
												isMatch = true;
											}
										}
										if (isMatch)
										{
											var additionalParameter = additionalParameters.FirstOrDefault(x => x.Name == parameterName);
											if (additionalParameter == null)
											{
												additionalParameter = new Parameter()
												{
													Name = parameterName,
													Value = matadataBit.value,
													Visible = true,
												};
												var driverParameter = device.Driver.Parameters.FirstOrDefault(x => x.Name == parameterName);
												if (driverParameter != null)
												{
													additionalParameter.Caption = driverParameter.Caption;
												}
												additionalParameters.Add(additionalParameter);
											}
											else
											{
												additionalParameter.Value += ", " + matadataBit.value;
											}
										}
									}
								}
							}
						}
					}
				}

				foreach (var parameter in device.DeviceState.Parameters)
				{
					if (parameter.Name == "OtherMessage" || parameter.Name == "FailureType" || parameter.Name == "AlarmReason")
					{
						var additionalparameter = additionalParameters.FirstOrDefault(x => x.Value == parameter.Value);
						if (additionalparameter != null)
						{
							if (parameter.Value != additionalparameter.Value)
							{
								parameter.Value = additionalparameter.Value;
								HasChanges = true;
							}
						}
						else
						{
							parameter.IsDeleting = true;
							HasChanges = true;
						}
					}
				}
				foreach (var additionalparameter in additionalParameters)
				{
					var parameter = device.DeviceState.Parameters.FirstOrDefault(x => x.Value == additionalparameter.Value);
					if (parameter == null)
					{
						device.DeviceState.Parameters.Add(additionalparameter);
						HasChanges = true;
					}
				}
				device.DeviceState.Parameters.RemoveAll(x => x.IsDeleting);
			}
			catch (Exception e)
			{
				Logger.Error(e, "DeviceStatesManager.UpdateExtraDeviceState");
			}
		}
		List<propType> AddProperties(Device device)
		{
			var propertyList = new List<propType>();
			if (device.Driver.DriverType != DriverType.Computer && device.Properties.IsNotNullOrEmpty())
			{
				foreach (var deviceProperty in device.Properties)
				{
					var property = device.Driver.Properties.FirstOrDefault(x => x.Name == deviceProperty.Name);
					if (property != null && property.IsAUParameter)
					{
						continue;
					}

					if (string.IsNullOrEmpty(deviceProperty.Name) == false &&
						string.IsNullOrEmpty(deviceProperty.Value) == false)
					{
						propertyList.Add(new propType()
						{
							name = deviceProperty.Name,
							value = deviceProperty.Value
						});
					}
				}
			}

			if (device.IsRmAlarmDevice)
			{
				var isRmAlarmDeviceProperty = propertyList.FirstOrDefault(x => x.name == "IsAlarmDevice");
				if (isRmAlarmDeviceProperty == null)
				{
					propertyList.Add(new propType() { name = "IsAlarmDevice", value = "1" });
				}
			}

			if (device.IsNotUsed)
			{
				var isNotUsedProperty = propertyList.FirstOrDefault(x => x.name == "NotUsed");
				if (isNotUsedProperty == null)
				{
					propertyList.Add(new propType() { name = "NotUsed", value = "1" });
				}
			}

			if (device.ZoneLogic != null)
			{
				if (device.ZoneLogic.Clauses.Count > 0)
				{
					var zoneLogicProperty = propertyList.FirstOrDefault(x => x.name == "ExtendedZoneLogic");
					if (zoneLogicProperty == null)
					{
						zoneLogicProperty = new propType();
						propertyList.Add(zoneLogicProperty);
					}

					zoneLogicProperty.name = "ExtendedZoneLogic";
					var zoneLogic = ZoneLogicConverter.ConvertBack(device.ZoneLogic);
					zoneLogicProperty.value = SerializerHelper.SetZoneLogic(zoneLogic);
				}
			}

            if ((device.Driver.DriverType == DriverType.Indicator) && (device.IndicatorLogic != null))
			{
				var indicatorLogicProperty = propertyList.FirstOrDefault(x => x.name == "C4D7C1BE-02A3-4849-9717-7A3C01C23A24");
				if (indicatorLogicProperty == null)
				{
					indicatorLogicProperty = new propType();
					propertyList.Add(indicatorLogicProperty);
				}

				indicatorLogicProperty.name = "C4D7C1BE-02A3-4849-9717-7A3C01C23A24";
				var indicatorLogic = IndicatorLogicConverter.ConvertBack(device.IndicatorLogic);
				indicatorLogicProperty.value = SerializerHelper.SetIndicatorLogic(indicatorLogic);
			}

			if ((device.Driver.DriverType == DriverType.PDUDirection) || (device.Driver.DriverType == DriverType.PDU_PTDirection))
			{
				var pduGroupLogicProperty = propertyList.FirstOrDefault(x => x.name == "E98669E4-F602-4E15-8A64-DF9B6203AFC5");
				if (pduGroupLogicProperty == null)
				{
					pduGroupLogicProperty = new propType();
					propertyList.Add(pduGroupLogicProperty);
				}

				pduGroupLogicProperty.name = "E98669E4-F602-4E15-8A64-DF9B6203AFC5";
				var pDUGroupLogic = PDUGroupLogicConverter.ConvertBack(device.PDUGroupLogic);
				pduGroupLogicProperty.value = SerializerHelper.SeGroupProperty(pDUGroupLogic);
			}

			return propertyList;
		}