private void SaveRecordChannel() { if (this.IPTextBox.GetIP() != string.Empty && this.IPTextBox.GetIP() != "0.0.0.0") { ResourceProperty TempResourceProper = CurrentConfigObj.ListProperties.FirstOrDefault(p => p.PropertyID == 13); if (TempResourceProper != null) { CurrentConfigObj.ListProperties.FirstOrDefault(p => p.PropertyID == 13).Value = this.IPTextBox.GetIP(); } } if (this.TexChanName.Text != string.Empty) { ResourceProperty TempResourceProper = CurrentConfigObj.ListProperties.FirstOrDefault(p => p.PropertyID == 12); if (TempResourceProper != null) { CurrentConfigObj.ListProperties.FirstOrDefault(p => p.PropertyID == 12).Value = this.TexChanName.Text; } } if (this.CombStartupMode.SelectedIndex != -1) { ResourceProperty TempResourceProper = CurrentConfigObj.ListProperties.FirstOrDefault(p => p.PropertyID == 21); if (TempResourceProper != null) { PropertyValueEnumItem propertyItem = this.CombStartupMode.SelectedItem as PropertyValueEnumItem; CurrentConfigObj.ListProperties.FirstOrDefault(p => p.PropertyID == 21).Value = propertyItem.Value; } } CurrentConfigObj.GetBasicPropertyValues(); bool IsFind = false; //List<ConfigObject> TempList = WizardHelper.ListAllConfigObjects.Where(p => p.ObjectType == 225 && p.ParentID == RecordConfigObj.ObjectID).ToList(); for (int i = 0; i < ListReadyExistChans.Count; i++) { if (ListReadyExistChans[i].ObjectID == CurrentConfigObj.ObjectID) { IsFind = true; } } if (!IsFind) { WizardHelper.ListAllConfigObjects.Add(CurrentConfigObj); //WizardHelper.ListRecords.Add(CurrentConfigObj); ListRecordChannels.Add(CurrentConfigObj); } if (RecordChannelNumber > ListRecordChannels.Count) { ListRecordChannels.Add(CurrentConfigObj); } if (ParentObjectItem != null) { MainPage.CreateNewChannelConfigObjectItem(ParentObjectItem, CurrentConfigObj); //MainPage.RefreshConfigObjectItem(ParentObjectItem); } }
private void SaveScreenChannel() { if (this.TexExtName.Text != string.Empty) { if (CurrentConfigObj.ListProperties.FirstOrDefault(p => p.PropertyID == 12) != null) { CurrentConfigObj.ListProperties.FirstOrDefault(p => p.PropertyID == 12).Value = this.TexExtName.Text; } CurrentConfigObj.GetBasicPropertyValues(); MainPage.CreateNewChannelConfigObjectItem(ParentObjectItem, CurrentConfigObj); } }
private void AddChannels() { try { if (TxtCount.Value == null) { return; } int intCount = (int)TxtCount.Value; string strExtension = TxtExt.Text; int intExtenstion; int.TryParse(strExtension, out intExtenstion); var baseExtension = ComboBaseExt.SelectedItem as ConfigObject; int objType = S1110Consts.RESOURCE_SCREENCHANNEL; if (ListResourceTypeParams == null) { return; } ResourceTypeParam typeParam = ListResourceTypeParams.FirstOrDefault(t => t.TypeID == objType); if (typeParam == null) { return; } if (ListPropertyInfos == null) { return; } List <ObjectPropertyInfo> listPropertyInfos = ListPropertyInfos.Where(p => p.ObjType == objType).OrderBy(p => p.PropertyID).ToList(); if (ListConfigObjects == null) { return; } if (mParentObject == null) { return; } long parentObjID = mParentObject.ObjectID; //逐一添加 for (int i = 0; i < intCount; i++) { //获取当前所有已经存在的通道 List <ConfigObject> channels = ListConfigObjects.Where(o => o.ObjectType == objType) .OrderBy(o => o.ObjectID) .ToList(); //确定ObjID long objID = objType * (long)Math.Pow(10, 16) + 1; for (int k = 0; k < channels.Count; k++) { if (objID == channels[k].ObjectID) { objID++; } } //确定Key,Key就是ObjID的尾数 int key = (int)(objID - (objType * (long)Math.Pow(10, 16) + 1)); //确定ID //获取当前ScreenServer下的所有通道 List <ConfigObject> channelsInScreen = mParentObject.ListChildObjects.Where(o => o.ObjectType == objType) .OrderBy(o => o.ID) .ToList(); int id = 0; for (int k = 0; k < channelsInScreen.Count; k++) { if (id == channelsInScreen[k].ID) { id++; } } foreach (var channel in channelsInScreen) { if (id == channel.ID) { id++; } } //分机号 string strExt = strExtension; if (intExtenstion > 0) { strExt = (intExtenstion + i).ToString(); } ConfigObject configObject = ConfigObject.CreateObject(objType); configObject.CurrentApp = CurrentApp; configObject.ObjectID = objID; configObject.Icon = typeParam.Icon; configObject.TypeParam = typeParam; configObject.ListAllObjects = ListConfigObjects; configObject.ListAllTypeParams = ListResourceTypeParams; configObject.ListAllBasicInfos = ListAllBasicInfos; for (int j = 0; j < listPropertyInfos.Count; j++) { ObjectPropertyInfo info = listPropertyInfos[j]; int propertyID = info.PropertyID; ResourceProperty propertyValue = new ResourceProperty(); propertyValue.ObjID = configObject.ObjectID; propertyValue.ObjType = configObject.ObjectType; propertyValue.PropertyID = info.PropertyID; //先使用默认属性填充 propertyValue.Value = info.DefaultValue; propertyValue.EncryptMode = info.EncryptMode; //拷贝属性 if (baseExtension != null) { ResourceProperty temp = baseExtension.ListProperties.FirstOrDefault(p => p.PropertyID == propertyID); if (temp != null) { propertyValue.Value = temp.Value; } } //特别的属性重新赋值 if (propertyID == S1110Consts.PROPERTYID_KEY) { propertyValue.Value = key.ToString(); } if (propertyID == S1110Consts.PROPERTYID_ID) { propertyValue.Value = id.ToString(); } if (propertyID == S1110Consts.PROPERTYID_PARENTOBJID) { propertyValue.Value = parentObjID.ToString(); } if (propertyID == 12) { propertyValue.Value = strExt; } configObject.ListProperties.Add(propertyValue); if (ListPropertyValues != null) { ListPropertyValues.Add(propertyValue); } } configObject.Name = string.Format("[{0}] {1}", id.ToString("000"), strExt); configObject.Description = string.Format("[{0}] {1}", id.ToString("000"), strExt); configObject.GetBasicPropertyValues(); mParentObject.ListChildObjects.Add(configObject); ListConfigObjects.Add(configObject); if (MainPage != null) { MainPage.CreateNewChannelConfigObjectItem(ParentItem, configObject); } } #region 写操作日志 var optID = string.Format("1110{0}06", objType); string strOptLog = string.Format("{0}:{1}", Utils.FormatOptLogString("1110202"), intCount); CurrentApp.WriteOperationLog(optID, ConstValue.OPT_RESULT_SUCCESS, strOptLog); #endregion if (MainPage != null) { MainPage.CreateChildObjectList(); } var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } } catch (Exception ex) { ShowException(ex.Message); } }