private List <MeterInfo> Dt2listmeter(DataTable DT) { List <MeterInfo> result = new List <MeterInfo>(); for (int i = 0; i < DT.Rows.Count; i++) { MeterInfo temp = (MeterInfo)Activator.CreateInstance(typeof(MeterInfo)); PropertyInfo[] pi = temp.GetType().GetProperties(); foreach (PropertyInfo p in pi) { for (int j = 0; j < DT.Columns.Count; j++) { if (p.Name.Equals(DT.Columns[j].ColumnName)) { if (DT.Rows[i][j] != DBNull.Value) { p.SetValue(temp, DT.Rows[i][j], null); } else { p.SetValue(temp, null, null); } break; } } } result.Add(temp); } return(result); }
public async Task <bool> MeterHasContract(int meterID) { meter = new MeterSoapClient(basicHttpBinding, basicendpoint); MeterInfo meterInfo = await meter.GetMeterAsync(meterID); return(await Task.FromResult(meterInfo.CostTariffID != 0)); }
public async Task <double> GetCorrectionFactor(int meterID) { meter = new MeterSoapClient(basicHttpBinding, basicendpoint); MeterInfo meterInfo = await meter.GetMeterAsync(meterID); return(await Task.FromResult(meterInfo.CorrectionFactor > 0?meterInfo.CorrectionFactor : 1)); }
public override void SetData(CLDC_DataCore.Model.DnbModel.DnbGroupInfo MeterGroup, bool allowedit) { Dgw_Data.Rows.Clear(); for (int i = 0; i < MeterGroup._Bws; i++) { if (MeterGroup.MeterGroup[i].YaoJianYn == false) { continue; } MeterInfo = MeterGroup.MeterGroup[i]; foreach (string _Key in MeterInfo.MeterSpecialErrs.Keys) { int rowIndex = Dgw_Data.Rows.Add(); Dgw_Data["表位", rowIndex].Value = MeterInfo.ToString(); Dgw_Data["项目名称", rowIndex].Value = MeterInfo.MeterSpecialErrs[_Key].Mse_PrjName; Dgw_Data["项目结论", rowIndex].Value = " " + MeterInfo.MeterSpecialErrs[_Key].Mse_Result; string[] Arr_Err = MeterInfo.MeterSpecialErrs[_Key].Mse_Wc.Split('|'); if (Arr_Err.Length != 4) { continue; } Dgw_Data[3, rowIndex].Value = Arr_Err[0]; Dgw_Data[4, rowIndex].Value = Arr_Err[1]; Dgw_Data[5, rowIndex].Value = Arr_Err[2]; Dgw_Data[6, rowIndex].Value = Arr_Err[3]; } base.SetData(MeterInfo, allowedit); } }
private void Xiugai(MeterInfo temp, string state) { string re = temp.Meteriport; string[] tip = re.Split('@'); switch (tip[3]) { case "PlatComs": Myadapter_p.UpdatePlatCom(state, int.Parse(tip[0])); break; case "PlatIcs": Myadapter_p.UpdatePlatIc(state, int.Parse(tip[0])); break; case "PlatChus_msb": Myadapter_p.UpdatePlatChu_msb(state, int.Parse(tip[0])); break; case "PlatComs_xzy": Myadapter_p.UpdatePlatChu_xzy(state, int.Parse(tip[0])); break; case "PlatComs_csb": Myadapter_p.UpdatePlatChu_csb(state, int.Parse(tip[0])); break; case "PlatZhos": Myadapter_p.UpdatePlatZho(state, int.Parse(tip[0])); break; } }
private bool GetMeterInfo(FileStream fs, ref MeterInfo mInfo) { int meterInfoFirstByte = 0x0123; mInfo = new MeterInfo(); fs.Seek(meterInfoFirstByte, SeekOrigin.Begin); try { int fsPosition = (int)fs.Position; byte[] buffer = new byte[fs.Length]; int bytesRead = fs.Read(buffer, fsPosition, 3); byte[] tmpSerialBuffer1 = new byte[1]; byte[] tmpSerialBuffer2 = new byte[2]; Array.Copy(buffer, fsPosition + 2, tmpSerialBuffer1, 0, 1); Array.Copy(buffer, fsPosition, tmpSerialBuffer2, 0, 2); Int16 serial2 = BitConverter.ToInt16(tmpSerialBuffer2, 0); mInfo.serialNumber = BitConverter.ToString(tmpSerialBuffer1) + "-" + serial2.ToString(); return(true); } catch (Exception ex) { return(false); } }
private void SetDellValue(int MeterID, MeterInfo meterInfo) { if (Settings.Person.Accounts.Count == 0) { return; } int currentDay = DateTime.Now.Day; if (meterInfo.ValuesCanAdd) { Label del = new Label(); del.TextColor = (Color)Application.Current.Resources["MainColor"]; del.Text = "Удалить"; del.TextDecorations = TextDecorations.Underline; del.FontAttributes = FontAttributes.Bold; del.VerticalOptions = LayoutOptions.Center; del.VerticalTextAlignment = TextAlignment.Center; del.HorizontalTextAlignment = TextAlignment.Center; del.HorizontalOptions = LayoutOptions.FillAndExpand; count1Stack.Children[1] = del; var dellClick = new TapGestureRecognizer(); RestClientMP server = new RestClientMP(); dellClick.Tapped += async(s, e) => { Configurations.LoadingConfig = new LoadingConfig { IndicatorColor = (Color)Application.Current.Resources["MainColor"], OverlayColor = Color.Black, Opacity = 0.8, DefaultMessage = "", }; bool displayAlert = await Settings.mainPage.DisplayAlert("", AppResources.DellCouneter, AppResources.Yes, AppResources.Cancel); if (displayAlert) { await Loading.Instance.StartAsync(async progress => { CommonResult result = await server.DeleteMeterValue(MeterID); if (result.Error == null) { MessagingCenter.Send <Object>(this, "UpdateCounters"); } else { await Settings.mainPage.DisplayAlert(AppResources.ErrorTitle, result.Error, "OK"); } // }); }); } }; del.GestureRecognizers.Add(dellClick); } }
public static HealthMeter Create(MeterInfo info, bool inGamePlay) { var meter = new HealthMeter(); meter.LoadInfo(info); meter.inGamePlay = inGamePlay; if (inGamePlay) { allMeters.Add(meter); } return(meter); }
public MeterInvoiceDetailInfo CalculateUnitInvoice(MeterInfo meter, ConsumeProfile consume, ConsumeType consumeType) { decimal AGPrice = TariffPriceList.Where(t => t.StartPeriod <= consume.Period && t.EndPeriod >= consume.Period).Select(t => t.AGDistributionUnitPrice).FirstOrDefault(); decimal OGPrice = TariffPriceList.Where(t => t.StartPeriod <= consume.Period && t.EndPeriod >= consume.Period).Select(t => t.OGDistributionUnitPrice).FirstOrDefault(); decimal energyPrice = Math.Round(consume.Consume * 0.167M, 2); decimal distributionPrice; if (consume.AGOG == (int)AGOG.AG) { distributionPrice = Math.Round(AGPrice * consume.Consume, 2); } else { distributionPrice = Math.Round(OGPrice * consume.Consume, 2); } decimal municipalityTax; if (consume.CalculateMunicipalityTax) { municipalityTax = Math.Round(energyPrice * 0.01M, 2); } else { municipalityTax = 0M; } decimal energyFundTax = Math.Round(energyPrice * 0.01M, 2); decimal trtTax = Math.Round(energyPrice * 0.02M, 2); var meterInvoice = new MeterInvoiceDetailInfo() { EnergyPrice = energyPrice, DistributionPrice = distributionPrice, MunicipalityTax = municipalityTax, EnergyFundTax = energyFundTax, TRTTax = trtTax, Consume = consume.Consume, ConsumeType = consumeType }; return(meterInvoice); }
public static MeterInfo LoadMeter(XElement meterNode, string basePath) { MeterInfo meter = new MeterInfo(); meter.Name = meterNode.TryAttribute <string>("name") ?? ""; meter.Position = new PointF(meterNode.GetAttribute <float>("x"), meterNode.GetAttribute <float>("y")); XAttribute imageAttr = meterNode.RequireAttribute("image"); meter.TickImage = FilePath.FromRelative(imageAttr.Value, basePath); XAttribute backAttr = meterNode.Attribute("background"); if (backAttr != null) { meter.Background = FilePath.FromRelative(backAttr.Value, basePath); } bool horiz = false; XAttribute dirAttr = meterNode.Attribute("orientation"); if (dirAttr != null) { horiz = (dirAttr.Value == "horizontal"); } meter.Orient = horiz ? MegaMan.Common.MeterInfo.Orientation.Horizontal : MegaMan.Common.MeterInfo.Orientation.Vertical; int x = meterNode.TryAttribute <int>("tickX"); int y = meterNode.TryAttribute <int>("tickY"); meter.TickOffset = new Point(x, y); XElement soundNode = meterNode.Element("Sound"); if (soundNode != null) { meter.Sound = IncludeFileXmlReader.LoadSound(soundNode, basePath); } XElement bindingNode = meterNode.Element("Binding"); if (bindingNode != null) { meter.Binding = LoadSceneBinding(bindingNode); } return(meter); }
/// <summary> /// 从成功和失败的表中查询表 /// 判断表的总结果是否为成功,表的测试状态为准备下发81命令 /// </summary> /// <param name="session"></param> /// <param name="requestInfo"></param> public override void ExecuteCommand(MySession session, MyRequestInfo requestInfo) { lock (obj3) { Myadapter_r = new DT_ResultTableAdapter(); DataTable dt = new DataTable(); MeterInfo tempmeter = new MeterInfo(); bool f = true; Thread.Sleep(1000); var info = requestInfo; dt = Myadapter_r.GetDataBy_r(info.EquipmentID, "合格", "初始", "失败"); if (dt != null && dt.Rows.Count > 0) { tempmeter = DataHelper.Dt2Ob(dt); } else { f = false; } if (tempmeter != null && f) { DateTime dtime = DateTime.Now; tempmeter.MeterTime = dtime; //成功的下发81修改网络参数,失败的不处理 if ((tempmeter.MeterState.Equals("合格") || tempmeter.MeterCancel.Equals("合格")) && tempmeter.MeterTest.Equals("准备")) { string ip = CommonFunction.dicBooks["strJituanHostIP"]; string port = CommonFunction.dicBooks["strJituanHostPort"]; string domain = CommonFunction.dicBooks["strJituanHostDomain"]; string send81 = DownCommond.GenerateSendFrame(DownCommond.GenerateCore81(ip, port, true, domain, tempmeter.MeterRand_num), info, false, true); ArraySegment <byte> f2 = new ArraySegment <byte>(DataHelper.Str2Byte(send81)); session.Send(f2); tempmeter.MeterTest = "就绪"; //更新测试状态和修改时间 Myadapter_r.Update_wait(tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId); } else { LogHelper.Info("燃气表错误发送恢复出厂设置"); } } else { LogHelper.Info("表不在检测列表中"); } } }
/// <summary> /// 更新数据到meter_test中 /// </summary> /// <param name="tempmeter"></param> /// <param name="type"></param> private void Up_test(MeterInfo tempmeter, string type) { try { switch (type) { case "com": Myadapter.UpdateMeterCom( tempmeter.MeterComState, tempmeter.MeterTest, tempmeter.MeterTime, tempmeter.MeterEvery, tempmeter.MeterId); break; case "ic": Myadapter.UpdateMeterIc( tempmeter.MeterIcState, tempmeter.MeterTest, tempmeter.MeterTime, tempmeter.MeterEvery, tempmeter.MeterId); break; case "chu": Myadapter.UpdateMeterChu( tempmeter.MeterChuState, tempmeter.MeterTest, tempmeter.MeterTime, tempmeter.MeterEvery, tempmeter.MeterId); break; case "zho": Myadapter.UpdateMeterZho( tempmeter.MeterZhongState, tempmeter.MeterTest, tempmeter.MeterTime, tempmeter.MeterEvery, tempmeter.MeterId); break; } } catch (Exception e) { throw; } }
private static bool CheckPeriod(int currDay, MeterInfo meterInfo) { //#if DEBUG // return true; //#endif if (meterInfo.ValuesEndDay < meterInfo.ValuesStartDay) { return(MetersThreeCell.GetPeriodEnabled() || (meterInfo.ValuesStartDay == 0 && meterInfo.ValuesEndDay == 0)); } return((meterInfo.ValuesStartDay <= currDay && meterInfo.ValuesEndDay >= currDay) || (meterInfo.ValuesStartDay == 0 && meterInfo.ValuesEndDay == 0)); }
void SetEditButton(string Period, MeterInfo mInfo) { frameBtn.IsVisible = false; var stack = frame.Content as StackLayout; try { int currDay = DateTime.Now.Day; if (mInfo.ValuesCanAdd) { int indexOf = stack.Children.IndexOf(editLabel); int index = stack.Children.IndexOf(labelЗPeriod); int indexframeBtn = stack.Children.IndexOf(frameBtn); if (indexframeBtn != -1) { stack.Children.RemoveAt(indexframeBtn); } if (indexOf != -1 && index != -1) { stack.Children.RemoveAt(indexOf); stack.Children.RemoveAt(index); } labelЗPeriod = new Label() { Text = $"{AppResources.PenencePassed} {Period}", FontSize = 14, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center }; stack.Children.Add(labelЗPeriod); editLabel = new Label() { Text = AppResources.ChangePenance, FontAttributes = FontAttributes.Bold, TextColor = (Color)Application.Current.Resources["MainColor"], VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center }; stack.Children.Add(editLabel); } } catch (Exception e) { } }
/// <summary> /// 总状态为成功的表 /// </summary> /// <param name="tempmeter"></param> /// <param name="session"></param> private void Xiugaisuc(MeterInfo tempmeter, MySession session, MyRequestInfo info) { try { //修改总结果为成功 tempmeter.MeterState = "成功"; //下发8f,8E, 改变测试状态为准备,正准备修改到正式服务器 string send8F = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8F(tempmeter.MeterRand_num), info, true, false); string send8E = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8E(tempmeter.MeterRand_num), info, false, false); ArraySegment <byte> f = new ArraySegment <byte>(DataHelper.Str2Byte(send8F)); ArraySegment <byte> f2 = new ArraySegment <byte>(DataHelper.Str2Byte(send8E)); session.Send(f); Thread.Sleep(1000); session.Send(f2); LogHelper.Info("发送命令" + send8F); LogHelper.Info("发送命令" + send8E); //修改测试状态为准备 +++++++++++++++++++++++++++++++ tempmeter.MeterTest = "准备"; //Myadapter.UpdateMeterState(tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterTest, tempmeter.MeterId); Myadapter_r.InsertMeter(tempmeter.MeterId, tempmeter.MeterType, tempmeter.MeterComState, tempmeter.MeterIcState, tempmeter.MeterChuState, tempmeter.MeterZhongState, tempmeter.MeterState, tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.Meteriport, tempmeter.MeterTime, tempmeter.MeterCancel, tempmeter.MeterEvery, tempmeter.MeterPrivilege, tempmeter.CheckTime, tempmeter.ManufactureName_id, tempmeter.Subtime); Myadapter.DeleteMeter(tempmeter.MeterId); //CommonFunction.platm.ChangeSuc(); } catch (Exception e) { LogHelper.Info(tempmeter.MeterId + e); } }
private void button1_Click(object sender, EventArgs e) { try { foreach (string key in CommonFunction.dic_cancel.Keys) { MeterInfo tempmeter = new MeterInfo(); tempmeter = DataHelper.Dt2Ob(Myadapter.GetDataBy1(key)); if (tempmeter != null) { Myadapter_r.InsertMeter(tempmeter.MeterId, tempmeter.MeterType, tempmeter.MeterComState, tempmeter.MeterIcState, tempmeter.MeterChuState, tempmeter.MeterZhongState, CommonFunction.dic_cancel[key], tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.Meteriport, tempmeter.MeterTime, CommonFunction.dic_cancel[key], tempmeter.MeterEvery, tempmeter.MeterPrivilege, tempmeter.CheckTime, tempmeter.ManufactureName_id, tempmeter.Subtime); Myadapter.DeleteMeter(key); } } } catch (Exception) { LogHelper.Error("取消测试失败"); MessageBox.Show("取消测试失败"); } CommonFunction.platm.ChangeMeter(); CommonFunction.platm.ChangeHG(); CommonFunction.platm.ChangeBHG(); CommonFunction.platm.ChangeSB(); CommonFunction.dic_cancel.Clear(); this.Close(); }
private void XiugaiSF(MeterInfo tempmeter, MySession session, MyRequestInfo info) { try { tempmeter.MeterState = "不合格"; Myadapter_r.Update_wait( tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId); CommonFunction.platm.ChangeBHG(); CommonFunction.platm.ChangeHG(); } catch (Exception e) { LogHelper.Error("从成功移到失败失败!" + e); } }
public void AddPowerScout(MeterInfo meterInfo) { var powerScoutQuery = @"INSERT INTO MeterDetails(PowerScout,Breaker_details,BuildingId,UTCConversionTime) VALUES (@PowerScout,@Breaker_details,@BuildingId,@UTCConversionTime)"; using (SqlConnection sqlConnection = new SqlConnection(ApplicationConfiguration.SqlConnectionString)) { using (SqlCommand sqlCommand = new SqlCommand(powerScoutQuery, sqlConnection)) { sqlCommand.Parameters.Add(new SqlParameter("@PowerScout", meterInfo.PowerScout)); sqlCommand.Parameters.Add(new SqlParameter("@Breaker_details", meterInfo.Breaker_details)); sqlCommand.Parameters.Add(new SqlParameter("@BuildingId", meterInfo.BuildingId)); sqlCommand.Parameters.Add(new SqlParameter("@UTCConversionTime", meterInfo.UTCConversionTime)); sqlCommand.ExecuteNonQuery(); } sqlConnection.Close(); } }
/// <summary> /// 总状态为失败的表 /// </summary> /// <param name="tempmeter"></param> /// <param name="session"></param> private void Xiugaifai(MeterInfo tempmeter, MySession session, MyRequestInfo info) { try { //修改测试总结果为失败,将其从检测列表中转移到检测失败的表中 tempmeter.MeterState = "失败"; //下发8f 8e回复出厂设置 (1F?)+++++++++++++++++++++++++++++++ string send8F = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8F(tempmeter.MeterRand_num), info, true, false); string send8E = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8E(tempmeter.MeterRand_num), info, false, false); ArraySegment <byte> f = new ArraySegment <byte>(DataHelper.Str2Byte(send8F)); ArraySegment <byte> f2 = new ArraySegment <byte>(DataHelper.Str2Byte(send8E)); session.Send(f); session.Send(f2); LogHelper.Info("发送命令" + send8F); LogHelper.Info("发送命令" + send8E); tempmeter.MeterTest = "准备"; //Myadapter.UpdateMeterState(tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterTest, tempmeter.MeterId); Myadapter_r.InsertMeter(tempmeter.MeterId, tempmeter.MeterType, tempmeter.MeterComState, tempmeter.MeterIcState, tempmeter.MeterChuState, tempmeter.MeterZhongState, tempmeter.MeterState, tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.Meteriport, tempmeter.MeterTime, tempmeter.MeterCancel, tempmeter.MeterEvery, tempmeter.MeterPrivilege, tempmeter.CheckTime, tempmeter.ManufactureName_id, tempmeter.Subtime); Myadapter.DeleteMeter(tempmeter.MeterId); CommonFunction.platm.ChangeSB(); } catch (Exception e) { LogHelper.Info(tempmeter.MeterId + e); } }
private void LoadInfo(MeterInfo info) { this.info = info; positionX = info.Position.X; positionY = info.Position.Y; if (info.Binding != null) { this.binding = Binding.Create(info.Binding, this); MaxValue = 1; // use 0 - 1 range for values } horizontal = (info.Orient == MeterInfo.Orientation.Horizontal); tickOffset = new MegaMan.Common.Geometry.Point(info.TickOffset.X, info.TickOffset.Y); if (info.Sound != null) { sound = Engine.Instance.SoundSystem.EffectFromInfo(info.Sound); } }
/// <summary> /// 取消测试的表 /// </summary> /// <param name="tempmeter"></param> /// <param name="session"></param> /// <param name="info"></param> private void Cancel_meter(MeterInfo tempmeter, MySession session, MyRequestInfo info) { try { //下发8f 8e回复出厂设置 string send8F = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8F(tempmeter.MeterRand_num), info, true, false); string send8E = DownCommond.GenerateSendFrame(DownCommond.GenerateCore8E(tempmeter.MeterRand_num), info, false, false); ArraySegment <byte> f = new ArraySegment <byte>(DataHelper.Str2Byte(send8F)); ArraySegment <byte> f2 = new ArraySegment <byte>(DataHelper.Str2Byte(send8E)); session.Send(f); session.Send(f2); LogHelper.Info("发送命令" + send8F); LogHelper.Info("发送命令" + send8E); tempmeter.MeterTest = "准备"; Myadapter_r.Update_wait(tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.MeterTime, tempmeter.MeterState, tempmeter.MeterId); } catch (Exception e) { LogHelper.Info(tempmeter.MeterId + e); } }
/// <summary> /// 显示所有要检电表的数据 /// </summary> /// <param name="MeterGroup"></param> /// <param name="allowedit"></param> public override void SetData(CLDC_DataCore.Model.DnbModel.DnbGroupInfo MeterGroup, bool allowedit) { Dgw_Data.Rows.Clear(); for (int i = 0; i < MeterGroup._Bws; i++) { if (MeterGroup.MeterGroup[i].YaoJianYn == false) { continue; } MeterInfo = MeterGroup.MeterGroup[i]; if (MeterInfo.MeterResults.ContainsKey(ItemKey)) { int rowIndex = Dgw_Data.Rows.Add(); Dgw_Data["表位", rowIndex].Value = MeterInfo.ToString(); Dgw_Data["项目名称", rowIndex].Value = MeterInfo.MeterResults[ItemKey].Mr_chrRstName; Dgw_Data["项目结论", rowIndex].Value = " " + MeterInfo.MeterResults[ItemKey].Mr_chrRstValue; } } SpanRow(0, Dgw_Data.Rows.Count, 0); base.SetData(MeterGroup, allowedit); }
public void ProcessData([ServiceBusTrigger("PowerScout_HalfHours")] PowerScoutData powerScoutData, TextWriter logger) { using (SqlConnection sqlConnection = new SqlConnection(ApplicationConfiguration.SqlConnectionString)) { if (!this.buildings.ContainsKey(powerScoutData.Building)) { var buildingId = this.powerScoutService.AddBuilding(powerScoutData.Building); this.buildings.Add(powerScoutData.Building, buildingId); } if (!this.powerScouts.Any(p => p.Equals(powerScoutData.PowerScout))) { var meterInfo = new MeterInfo { Breaker_details = powerScoutData.Breaker_details, PowerScout = powerScoutData.PowerScout, BuildingId = this.buildings[powerScoutData.Building], UTCConversionTime = powerScoutData.UTCConversionTime }; this.powerScoutService.AddPowerScout(meterInfo); } this.powerScoutService.AddPowerScoutData(powerScoutData); } }
private bool Up_Dj(MeterInfo tempmeter, bool is_complete, string type) { try { if (is_complete) { tempmeter.MeterState = tempmeter.MeterChuState.Equals("不合格") || tempmeter.MeterIcState.Equals("不合格") || tempmeter.MeterComState.Equals("不合格") || tempmeter.MeterZhongState.Equals("不合格") ? "不合格" : "完成"; Myadapter_r.InsertMeter( tempmeter.MeterId, tempmeter.MeterType, tempmeter.MeterComState, tempmeter.MeterIcState, tempmeter.MeterChuState, tempmeter.MeterZhongState, tempmeter.MeterState, tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.Meteriport, tempmeter.MeterTime, tempmeter.MeterCancel, tempmeter.MeterEvery, tempmeter.MeterPrivilege, tempmeter.CheckTime, tempmeter.ManufactureName_id, tempmeter.Subtime); Myadapter.DeleteMeter(tempmeter.MeterId); } else { Up_test(tempmeter, type); } return(true); } catch (Exception) { LogHelper.Info("单机测试结果更新失败:" + tempmeter.MeterId); return(false); } }
/// <summary> /// 将datatable转为meterinfo对象 /// </summary> /// <param name="dt"></param> /// <returns>不是一条结果就返回null</returns> public static MeterInfo Dt2Ob(DataTable dt) { try { if (dt == null) { return(null); } else { MeterInfo temp = (MeterInfo)Activator.CreateInstance(typeof(MeterInfo)); PropertyInfo[] propertys = temp.GetType().GetProperties(); foreach (PropertyInfo pi in propertys) { for (int i = 0; i < dt.Columns.Count; i++) { if (pi.Name.Equals(dt.Columns[i].ColumnName)) { if (dt.Rows[0][i] != DBNull.Value) { pi.SetValue(temp, dt.Rows[0][i], null); } else { pi.SetValue(temp, null, null); } break; } } } return(temp); } } catch (Exception) { return(null); } }
/// <summary> /// 收到检测平台的检测结果 /// ip+port+cmd+num+(id+AA/55+单项+修改网络参数是否成功+是否是单机)*num /// 字节4+2+1+2+(6+1+单项)*n /// AA通过;55不合格但修改网络参数成功 /// 修改表测试状态为空闲,表对应的检测项结果,表在meterinfo表中 /// 修改检测平台为空闲 /// /// 单机操作:1.temper对象,修改对象属性为测试结果 2.判断是否测完 3.未测完,更新meter_test的数据库 4.测完,表移到meter_result中 /// 1.前提获取测试类型和表类型。 /// /// </summary> /// <param name="session"></param> /// <param name="requestInfo"></param> public override void ExecuteCommand(MySession session, MyRequestInfo requestInfo) { lock (obj_22) { Myadapter = new Dt_MeterInfoTableAdapter(); Myadapter_r = new DT_ResultTableAdapter(); Myadapter_p = new Dt_PlateInfoTableAdapter(); var info = requestInfo; string ip = DataHelper.Str2IP(info.Data.Substring(2, 8)); string port = Convert.ToInt32(info.Data.Substring(10, 4), 16).ToString(); string cmd_isauto = info.Data.Substring(14, 1); string cmd_type = info.Data.Substring(15, 1); int num = Convert.ToInt32(info.Data.Substring(16, 4), 16); StringBuilder info_sb = new StringBuilder(); info_sb.Append("22"); info_sb.Append(info.Data.Substring(16, 4)); switch (cmd_type) { //膜式表 case "1": len = 24; len_every = 10; starti = 0; break; //IC case "2": len = 18; len_every = 4; starti = 10; break; //命令 case "3": len = 20; len_every = 6; starti = 14; break; //终检 case "4": len = 26; len_every = 12; starti = 20; break; } for (int i = 0; i < num; i++) { string id = info.Data.Substring(20 + i * len, 12); string result = info.Data.Substring(32 + i * len, 2); string re_every = info.Data.Substring(34 + i * len, len_every); info_sb.Append(id); bool is_danji = re_every.Substring(len_every - 2, 1).Equals("1") ? true : false; bool isscu = re_every.Substring(re_every.Length - 1, 1).Equals("A") ? true : false; try { dt = Myadapter.GetDataBy1(id); tempmeter = DataHelper.Dt2Ob(dt); if (tempmeter == null) { dt = Myadapter_r.GetDataBy_r(id, "合格", "初始", "失败"); tempmeter = DataHelper.Dt2Ob(dt); } } catch (Exception e) { info_sb.Append("55"); LogHelper.Error("数据库连接异常" + e); } if (tempmeter != null) { //更新单项测试结果 StringBuilder re_ev = new StringBuilder(tempmeter.MeterEvery); string oldchar = tempmeter.MeterEvery.Substring(starti, len_every); re_ev.Replace(oldchar, re_every, starti, len_every); tempmeter.MeterEvery = re_ev.ToString(); DateTime dtime = DateTime.Now; tempmeter.MeterTime = dtime; if (!is_danji) { string re = tempmeter.Meteriport; string[] tip = re.Split('@'); tempmeter.MeterTest = "空闲"; if (result.Equals("AA")) { string st = "合格"; if (Xiugai(tip, st, tempmeter.MeterCancel, true, isscu, is_danji)) { info_sb.Append("AA"); } else { info_sb.Append("55"); } } else if (result.Equals("55")) { string st = "不合格"; if (Xiugai(tip, st, tempmeter.MeterCancel, false, isscu, is_danji)) { info_sb.Append("AA"); } else { info_sb.Append("55"); } } else { LogHelper.Info("错误的22命令"); } } else { string type = ""; switch (cmd_type) { case "1": tempmeter.MeterChuState = result.Equals("AA") ? "合格" : "不合格"; type = "chu"; break; case "2": tempmeter.MeterIcState = result.Equals("AA") ? "合格" : "不合格"; type = "ic"; break; case "3": tempmeter.MeterComState = result.Equals("AA") ? "合格" : "不合格"; type = "com"; break; case "4": tempmeter.MeterZhongState = result.Equals("AA") ? "合格" : "不合格"; type = "zho"; break; } bool is_complete = tempmeter.MeterChuState.Equals("待测") || tempmeter.MeterIcState.Equals("待测") || tempmeter.MeterComState.Equals("待测") || tempmeter.MeterZhongState.Equals("待测") ? false : true; if (Up_Dj(tempmeter, is_complete, type)) { info_sb.Append("AA"); } else { info_sb.Append("55"); } } } else { info_sb.Append("55"); LogHelper.Info("表具不在检测列表中"); } Thread.Sleep(100); } try { IPAddress Ip = IPAddress.Parse(ip); int Port = Convert.ToInt32(port); string send22 = DownCommond.GenerateSendFrame(info_sb.ToString(), info, false, false); Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(Ip, Port); socket.Send(DataHelper.Str2Byte(send22)); socket.Close(); LogHelper.Info("回复22:" + send22); } catch (Exception e) { LogHelper.Error("回复22命令连接检测平台异常" + e); LogHelper.Info("检测平台通信异常"); } //更新界面 CommonFunction.platm.ChangeMeter(); CommonFunction.platm.ChangePlat(); CommonFunction.platm.ChangeBHG(); Thread.Sleep(500); } }
void ext(MeterInfo mInfo, List <MeterValueInfo> Values, int DecimalPoint, int MeterID, bool IsDisabled, string Resource, string Address, string CustomName, string FactoryNumber, string UniqueNum, string Units, string CheckupDate, string RecheckInterval, string Tariff1Name, string Tariff2Name, string Tariff3Name) { var editName = new TapGestureRecognizer(); editName.Tapped += async(s, e) => { if (PopupNavigation.Instance.PopupStack.FirstOrDefault(x => x is EditCounterNameDialog) == null) { await PopupNavigation.Instance.PushAsync( new EditCounterNameDialog((Color)Application.Current.Resources["MainColor"], UniqueNum)); } }; if (Edit.GestureRecognizers.Count > 0) { Edit.GestureRecognizers[0] = editName; } else { Edit.GestureRecognizers.Add(editName); } string name = (!string.IsNullOrWhiteSpace(CustomName)) ? CustomName : Resource; FormattedString formattedResource = new FormattedString(); formattedResource.Spans.Add(new Span { Text = name + ", " + Units, TextColor = Color.Black, FontAttributes = FontAttributes.Bold, FontSize = 18 }); resource.FormattedText = formattedResource; adress.Text = Address; number.Text = FactoryNumber; checkup_date.Text = CheckupDate; recheckup.Text = RecheckInterval + " лет"; GetFormat(DecimalPoint); if (Values.Count == 1) { counterDate1.Text = Values[0].Period.Equals("01.01.0001")? "-" : Values[0].Period; count1.Text = String.Format(GetFormat(DecimalPoint), Values[0].Value); if (Values[0].ValueT2 != null) { count1t2.Text = String.Format(GetFormat(DecimalPoint), Values[0].ValueT2); count1t2Stack.IsVisible = true; } else { } if (Values[0].ValueT3 != null) { count1t3.Text = String.Format(GetFormat(DecimalPoint), Values[0].ValueT3); count1t3Stack.IsVisible = true; } else { count1t3Stack.IsVisible = false; } count2Stack.IsVisible = count3Stack.IsVisible = false; } else if (Values.Count == 2) { counterDate1.Text = Values[0].Period.Equals("01.01.0001")? "-" : Values[0].Period; count1.Text = String.Format(GetFormat(DecimalPoint), Values[0].Value); //.ToString(CultureInfo.InvariantCulture); if (Values[0].ValueT2 != null) { count1t2.Text = String.Format(GetFormat(DecimalPoint), Values[0].ValueT2); count1t2Stack.IsVisible = true; } else { count1t2Stack.IsVisible = false; } if (Values[0].ValueT3 != null) { count1t3.Text = String.Format(GetFormat(DecimalPoint), Values[0].ValueT3); count1t3Stack.IsVisible = true; } else { count1t3Stack.IsVisible = false; } counterDate2.Text = Values[1].Period.Equals("01.01.0001")? "-" : Values[1].Period; count2.Text = String.Format(GetFormat(DecimalPoint), Values[1].Value); //.ToString(CultureInfo.InvariantCulture); if (Values[1].ValueT2 != null) { count2t2.Text = String.Format(GetFormat(DecimalPoint), Values[1].ValueT2); count2t2Stack.IsVisible = true; } else { count2t2Stack.IsVisible = false; } if (Values[1].ValueT3 != null) { count2t3.Text = String.Format(GetFormat(DecimalPoint), Values[1].ValueT3); count2t3Stack.IsVisible = true; } else { count2t3Stack.IsVisible = false; } count3Stack.IsVisible = false; } else if (Values.Count == 3) { counterDate1.Text = Values[0].Period.Equals("01.01.0001")? "-" : Values[0].Period; count1.Text = String.Format(GetFormat(DecimalPoint), Values[0].Value); if (Values[0].ValueT2 != null) { count1t2.Text = String.Format(GetFormat(DecimalPoint), Values[0].ValueT2); count1t2Stack.IsVisible = true; } else { count1t2Stack.IsVisible = false; } if (Values[0].ValueT3 != null) { count1t3.Text = String.Format(GetFormat(DecimalPoint), Values[0].ValueT3); count1t3Stack.IsVisible = true; } else { count1t3Stack.IsVisible = false; } counterDate2.Text = Values[1].Period.Equals("01.01.0001")? "-" : Values[1].Period; count2.Text = String.Format(GetFormat(DecimalPoint), Values[1].Value); //.ToString(CultureInfo.InvariantCulture); if (Values[1].ValueT2 != null) { count2t2.Text = String.Format(GetFormat(DecimalPoint), Values[1].ValueT2); count2t2Stack.IsVisible = true; } else { count2t2Stack.IsVisible = false; } if (Values[1].ValueT3 != null) { count2t3.Text = String.Format(GetFormat(DecimalPoint), Values[1].ValueT3); count2t3Stack.IsVisible = true; } else { count2t3Stack.IsVisible = false; //count2t3.IsVisible = false; } counterDate3.Text = Values[2].Period.Equals("01.01.0001")? "-" : Values[2].Period; count3.Text = String.Format(GetFormat(DecimalPoint), Values[2].Value); //.ToString(CultureInfo.InvariantCulture); if (Values[2].ValueT2 != null) { count3t2.Text = String.Format(GetFormat(DecimalPoint), Values[2].ValueT2); count3t2Stack.IsVisible = true; } else { count3t2Stack.IsVisible = false; } if (Values[2].ValueT3 != null) { count3t3.Text = String.Format(GetFormat(DecimalPoint), Values[2].ValueT3); count3t3Stack.IsVisible = true; } else { count3t3Stack.IsVisible = false; } } else if (Values.Count == 0) { count1Stack.IsVisible = count2Stack.IsVisible = count3Stack.IsVisible = false; //count1t2Stack.IsVisible = count1t3Stack.IsVisible = count2t2Stack.IsVisible = count2t3Stack.IsVisible = count3t2Stack.IsVisible = count3t3Stack.IsVisible = false; } if (IsDisabled) { labelDisable.IsVisible = true; Edit.IsVisible = false; try { var stack = frame.Content as StackLayout; stack.Children.RemoveAt(stack.Children.IndexOf(frameBtn)); } catch (Exception e) { Console.WriteLine(e); } } else if (Values.Count > 0 && Values[0].IsCurrentPeriod && !meterInfo.AutoValueGettingOnly) { SetEditButton(Values[0].Period, mInfo); SetDellValue(MeterID, mInfo); } else { frameBtn.IsVisible = true; var stack = frame.Content as StackLayout; try { stack.Children.RemoveAt(stack.Children.IndexOf(editLabel)); stack.Children.RemoveAt(stack.Children.IndexOf(labelЗPeriod)); } catch (Exception e) { Console.WriteLine(e); } stack.Children.Add(frameBtn); if (Values.Count > 0) { Label lines = new Label(); lines.HeightRequest = 1; lines.BackgroundColor = Color.LightGray; lines.VerticalOptions = LayoutOptions.Center; lines.HorizontalOptions = LayoutOptions.FillAndExpand; count1Stack.Children[1] = lines; } } if (Resource.ToLower().Contains("холодное") || Resource.ToLower().Contains("хвс")) { img.Source = ImageSource.FromFile("ic_cold_water"); } else if (Resource.ToLower().Contains("горячее") || Resource.ToLower().Contains("гвс") || Resource.ToLower().Contains("подог") || Resource.ToLower().Contains("отопл")) { img.Source = ImageSource.FromFile("ic_heat_water"); } else if (Resource.ToLower().Contains("эле")) { img.Source = ImageSource.FromFile("ic_electr"); } else { img.Source = ImageSource.FromFile("ic_cold_water"); } string month = AppResources.CountersCurrentMonth; if (mInfo.ValuesEndDay < mInfo.ValuesStartDay) { month = AppResources.NextMonth; } int currDay = DateTime.Now.Day; // currDay = 16; frameBtn.IsVisible = true; canCount.IsVisible = false; if (Settings.Person != null) { if (Settings.Person.Accounts != null) { if (Settings.Person.Accounts.Count > 0) { FormattedString formattedDate = new FormattedString(); formattedDate.Spans.Add(new Span { Text = $"{AppResources.CountersInfo1} ", TextColor = (Color)Application.Current.Resources["MainColor"], FontAttributes = FontAttributes.None, FontSize = 12 }); if (mInfo.ValuesStartDay != null && mInfo.ValuesEndDay != null) { if (mInfo.ValuesStartDay != 0 && mInfo.ValuesEndDay != 0) { formattedDate.Spans.Add(new Span { Text = $"{AppResources.From} " + mInfo.ValuesStartDay + $" {AppResources.To} " + mInfo.ValuesEndDay + " числа ", TextColor = (Color)Application.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontSize = 12 }); formattedDate.Spans.Add(new Span { Text = month, TextColor = (Color)Application.Current.Resources["MainColor"], FontAttributes = FontAttributes.None, FontSize = 12 }); } else { formattedDate.Spans.Add(new Span { Text = month, TextColor = (Color)Application.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontSize = 12 }); } } else { formattedDate.Spans.Add(new Span { Text = AppResources.CountersCurrentMonth, TextColor = (Color)Application.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontSize = 12 }); } canCount.FormattedText = formattedDate; if (mInfo.ValuesCanAdd) { frameBtn.IsVisible = true; canCount.IsVisible = false; } else { frameBtn.IsVisible = false; canCount.IsVisible = true; } } } } if (meterInfo.AutoValueGettingOnly) { var stack = frame.Content as StackLayout; var auto_label = new Label { Text = AppResources.AutoPennance, FontAttributes = FontAttributes.Bold, TextColor = (Color)Application.Current.Resources["MainColor"], VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center }; stack.Children.Add(auto_label); canCount.IsVisible = false; frameBtn.IsVisible = false; } }
/// <summary> /// 取消测试的命令(若表没在测试怎么办,在ll哪处理吗) /// 将表的cancel字段改为是,将表的总状态改为失败。等到22命令的时候将表以失败移到meter_result中,可以发送8e命令,让其休眠。 /// </summary> /// <param name="session"></param> /// <param name="requestInfo"></param> public override void ExecuteCommand(MySession session, MyRequestInfo requestInfo) { string send = "00"; Myadapter = new Dt_MeterInfoTableAdapter(); Myadapter_r = new DT_ResultTableAdapter(); DataTable dt = null; MeterInfo tempmeter = null; var info = requestInfo; int id = Convert.ToInt32(info.Data.Substring(2, 2), 16); string ip = DataHelper.Str2IP(info.Data.Substring(4, 8)); string port = Convert.ToInt32(info.Data.Substring(12, 4), 16).ToString(); string type = info.Data.Substring(16, 2); string meterid = info.Data.Substring(18, 12); try { dt = Myadapter.GetDataBy1(meterid); tempmeter = DataHelper.Dt2Ob(dt); } catch (Exception e) { send = "55"; LogHelper.Error("77命令:" + e); } if (tempmeter != null) { string[] re = tempmeter.Meteriport.Split('@'); tempmeter.MeterCancel = "是"; tempmeter.MeterState = "失败"; try { Myadapter_r.InsertMeter( tempmeter.MeterId, tempmeter.MeterType, tempmeter.MeterComState, tempmeter.MeterIcState, tempmeter.MeterChuState, tempmeter.MeterZhongState, tempmeter.MeterState, tempmeter.MeterTest, tempmeter.MeterRand_num, tempmeter.Meteriport, tempmeter.MeterTime, tempmeter.MeterCancel, tempmeter.MeterEvery, tempmeter.MeterPrivilege, tempmeter.CheckTime, tempmeter.ManufactureName_id, tempmeter.Subtime ); Myadapter.DeleteMeter(meterid); send = "AA"; } catch (Exception e) { send = "55"; LogHelper.Info("取消测试失败:" + meterid); } } else { LogHelper.Info("检测平台不存在需要取消测试表" + meterid); send = send.Equals("55") ? "55" : "BB"; } //回复检测平台,是否取消测试成功 IPAddress Ip = IPAddress.Parse(ip); int Port = Convert.ToInt32(port); string send_77 = DownCommond.GenerateSendFrame("77" + send, info, true, false); Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(Ip, Port); socket.Send(DataHelper.Str2Byte(send_77)); socket.Close(); LogHelper.Info("回复77:" + send_77); }
private async void Tap_Tapped(object sender, EventArgs e) { int currDay = DateTime.Now.Day; MeterInfo select = ((MetersThreeCell)sender).meterInfo; // as MeterInfo; if (select != null) { if (select.IsDisabled || select.AutoValueGettingOnly) { return; } if (Settings.Person != null) { if (Settings.Person.Accounts != null) { if (Settings.Person.Accounts.Count > 0) { if (select.ValuesCanAdd) { if (select.Values != null && select.Values.Count >= 1) { // int monthCounter; // var parceMonthOk = int.TryParse(select.Values[0].Period.Split('.')[1], out monthCounter) ; // if(parceMonthOk) // { if (select.Values[0].IsCurrentPeriod) { var counterThisMonth = select.Values[0].Value; var counterThisMonth2 = select.Values.Count >= 2 ? select.Values[1].Value : 0; if (Navigation.NavigationStack.FirstOrDefault(x => x is AddMetersPage) == null) { await Navigation.PushAsync(new AddMetersPage(select, _meterInfo, this, counterThisMonth, counterThisMonth2)); } } else { var counterThisMonth = select.Values[0].Value; if (Navigation.NavigationStack.FirstOrDefault(x => x is AddMetersPage) == null) { await Navigation.PushAsync(new AddMetersPage(select, _meterInfo, this, 0, counterThisMonth)); } } // } // else // { // var counterThisMonth = select.Values[0].Value; // if (Navigation.NavigationStack.FirstOrDefault(x => x is AddMetersPage) == null) // await Navigation.PushAsync(new AddMetersPage(select, _meterInfo, this, 0, // counterThisMonth)); // } } else { //var counterThisMonth = 0; if (Navigation.NavigationStack.FirstOrDefault(x => x is AddMetersPage) == null) { await Navigation.PushAsync(new AddMetersPage(select, _meterInfo, this, 0, 0)); } } //if (select.Values.Count >= 1 && int.Parse(select.Values[0].Period.Split('.')[1]) == // DateTime.Now.Month) //{ // var counterThisMonth = (select.Values.Count >= 1) ? select.Values[0].Value : 0; // var counterThisMonth2 = (select.Values.Count >= 2) ? select.Values[1].Value : 0; // await Navigation.PushAsync(new AddMetersPage(select, _meterInfo, this, // counterThisMonth, // counterThisMonth2)); //} //else //{ // var counterThisMonth = (select.Values.Count >= 1) ? select.Values[0].Value : 0; // await Navigation.PushAsync(new AddMetersPage(select, _meterInfo, this, 0, // counterThisMonth)); //} } } } } } }
public MetersThreeCell(/*List<MeterValueInfo> Values, int DecimalPoint, int MeterID, bool IsDisabled, string Resource, string Address, * string CustomName, string UniqueNum, string Units, string CheckupDate, string RecheckInterval,*/MeterInfo mInfo) { meterInfo = mInfo; frame.SetAppThemeColor(Frame.BorderColorProperty, (Color)Application.Current.Resources["MainColor"], Color.White); frame.HorizontalOptions = LayoutOptions.FillAndExpand; frame.VerticalOptions = LayoutOptions.Start; frame.BackgroundColor = Color.White; frame.SetOnAppTheme(Frame.HasShadowProperty, false, true); frame.SetOnAppTheme(MaterialFrame.ElevationProperty, 0, 20); frame.Margin = new Thickness(10, 0, 10, 10); frame.Padding = new Thickness(15, 15, 15, 15); frame.CornerRadius = 30; StackLayout container = new StackLayout(); container.Orientation = StackOrientation.Vertical; StackLayout header = new StackLayout(); header.Orientation = StackOrientation.Horizontal; header.HorizontalOptions = LayoutOptions.Center; resource.FontSize = 15; resource.TextColor = Color.Black; resource.HorizontalTextAlignment = TextAlignment.Center; img.WidthRequest = 25; // imgEdit.WidthRequest = 20; // imgEdit.HeightRequest = 20; // imgEdit.Source = "edit"; // imgEdit.Foreground = (Color)Application.Current.Resources["MainColor"]; Edit = new SvgCachedImage(); Edit.WidthRequest = 25; Edit.HeightRequest = 25; Edit.ReplaceStringMap = new Dictionary <string, string> { { "#000000", $"#{Settings.MobileSettings.color}" } }; Edit.Source = "resource://xamarinJKH.Resources.edit.svg"; header.Children.Add(img); header.Children.Add(resource); header.Children.Add(Edit); StackLayout addressStack = new StackLayout(); addressStack.Orientation = StackOrientation.Horizontal; addressStack.HorizontalOptions = LayoutOptions.FillAndExpand; StackLayout grid = new StackLayout(); grid.Orientation = StackOrientation.Horizontal; grid.HorizontalOptions = LayoutOptions.FillAndExpand; StackLayout grid0 = new StackLayout(); grid0.Orientation = StackOrientation.Horizontal; grid0.HorizontalOptions = LayoutOptions.FillAndExpand; grid0.VerticalOptions = LayoutOptions.Start; Label adressLbl = new Label(); adressLbl.Text = $"{AppResources.Adress}:"; adressLbl.FontSize = 15; adressLbl.TextColor = Color.FromHex("#A2A2A2"); adressLbl.HorizontalTextAlignment = TextAlignment.Start; adressLbl.HorizontalOptions = LayoutOptions.Fill; adressLbl.MinimumWidthRequest = 60; grid0.Children.Add(adressLbl); BoxView b = new BoxView(); b.VerticalOptions = LayoutOptions.Center; b.HeightRequest = 1; b.Margin = new Thickness(0, 2, 0, 0); b.HorizontalOptions = LayoutOptions.FillAndExpand; b.Color = Color.LightGray; b.MinimumWidthRequest = 10; grid0.Children.Add(b); grid.Children.Add(grid0); adress.FontSize = 15; adress.TextColor = Color.Black; adress.HorizontalTextAlignment = TextAlignment.End; adress.HorizontalOptions = LayoutOptions.Fill; adress.MaxLines = 3; if (Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Width < 700) { adress.WidthRequest = 450; adressLbl.FontSize = 13; adress.FontSize = 13; } else if (Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Width < 800) { adress.WidthRequest = 500; adressLbl.FontSize = 14; adress.FontSize = 14; } else { adress.WidthRequest = Convert.ToInt32(Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Width * 0.7); } grid.Children.Add(adress); container.Children.Add(header); container.Children.Add(grid); StackLayout numberStack = new StackLayout(); numberStack.Orientation = StackOrientation.Horizontal; numberStack.HorizontalOptions = LayoutOptions.FillAndExpand; Label numberLbl = new Label(); numberLbl.Text = AppResources.FacNum; numberLbl.FontSize = 12; numberLbl.TextColor = Color.FromHex("#A2A2A2"); numberLbl.HorizontalTextAlignment = TextAlignment.Start; numberLbl.HorizontalOptions = LayoutOptions.Start; numberLbl.MaxLines = 1; number.FontSize = 12; number.HorizontalOptions = LayoutOptions.End; number.TextColor = Color.Black; number.HorizontalTextAlignment = TextAlignment.End; number.MaxLines = 1; Label linesNumb = new Label(); linesNumb.HeightRequest = 1; linesNumb.BackgroundColor = Color.LightGray; linesNumb.Margin = new Thickness(0, 2, 0, 0); linesNumb.VerticalOptions = LayoutOptions.Center; linesNumb.HorizontalOptions = LayoutOptions.FillAndExpand; numberStack.Children.Add(numberLbl); numberStack.Children.Add(linesNumb); numberStack.Children.Add(number); container.Children.Add(numberStack); StackLayout checkupDateStack = new StackLayout(); checkupDateStack.Orientation = StackOrientation.Horizontal; checkupDateStack.HorizontalOptions = LayoutOptions.FillAndExpand; checkupDateStack.Margin = new Thickness(0, -7, 0, 0); Label checkupDateLbl = new Label(); checkupDateLbl.Text = AppResources.LastCheck; checkupDateLbl.FontSize = 12; checkupDateLbl.TextColor = Color.FromHex("#A2A2A2"); checkupDateLbl.HorizontalTextAlignment = TextAlignment.Start; checkupDateLbl.HorizontalOptions = LayoutOptions.Start; checkupDateLbl.MaxLines = 1; checkup_date.FontSize = 12; checkup_date.TextColor = Color.Black; checkup_date.HorizontalTextAlignment = TextAlignment.End; checkup_date.HorizontalOptions = LayoutOptions.End; checkup_date.MaxLines = 1; Label linesPover = new Label(); linesPover.HeightRequest = 1; linesPover.BackgroundColor = Color.LightGray; ; linesPover.VerticalOptions = LayoutOptions.Center; linesPover.Margin = new Thickness(0, 2, 0, 0); linesPover.HorizontalOptions = LayoutOptions.FillAndExpand; checkupDateStack.Children.Add(checkupDateLbl); checkupDateStack.Children.Add(linesPover); checkupDateStack.Children.Add(checkup_date); container.Children.Add(checkupDateStack); StackLayout recheckStack = new StackLayout(); recheckStack.Orientation = StackOrientation.Horizontal; recheckStack.HorizontalOptions = LayoutOptions.FillAndExpand; recheckStack.Margin = new Thickness(0, -7, 0, 0); Label recheckLbl = new Label(); recheckLbl.Text = AppResources.CheckInterval; recheckLbl.FontSize = 12; recheckLbl.TextColor = Color.FromHex("#A2A2A2"); recheckLbl.HorizontalTextAlignment = TextAlignment.Start; recheckLbl.HorizontalOptions = LayoutOptions.Start; recheckLbl.MaxLines = 1; // recheckLbl.WidthRequest = 150; recheckup.FontSize = 12; recheckup.TextColor = Color.Black; recheckup.HorizontalTextAlignment = TextAlignment.End; recheckup.HorizontalOptions = LayoutOptions.End; recheckup.MaxLines = 1; Label linesInterv = new Label(); linesInterv.HeightRequest = 1; linesInterv.BackgroundColor = Color.LightGray; ; linesInterv.VerticalOptions = LayoutOptions.Center; linesInterv.Margin = new Thickness(0, 2, 0, 0); linesInterv.HorizontalOptions = LayoutOptions.FillAndExpand; recheckStack.Children.Add(recheckLbl); recheckStack.Children.Add(linesInterv); recheckStack.Children.Add(recheckup); container.Children.Add(recheckStack); Label separator = new Label(); separator.HeightRequest = 1; separator.BackgroundColor = Color.LightGray; separator.Margin = new Thickness(0, 5, 0, 5); container.Children.Add(separator); tarif1.FontSize = 13; tarif1.TextColor = Color.FromHex("#A2A2A2"); //Color.Red; tarif1.HorizontalTextAlignment = TextAlignment.Center; if (mInfo.TariffNumberInt > 1) { tarif1.Text = string.IsNullOrWhiteSpace(mInfo.Tariff1Name) ? AppResources.tarif1 : mInfo.Tariff1Name; } else { tarif1.IsVisible = false; } //tarif1t2.FontSize = 13; //tarif1t2.TextColor = Color.FromHex("#A2A2A2"); //Color.Red; //tarif1t2.HorizontalTextAlignment = TextAlignment.Center; //tarif1t3.FontSize = 13; //tarif1t3.TextColor = Color.FromHex("#A2A2A2"); //Color.Red; //tarif1t3.HorizontalTextAlignment = TextAlignment.Center; //tarif2.FontSize = 13; //tarif2.TextColor = Color.FromHex("#A2A2A2"); //tarif2.HorizontalTextAlignment = TextAlignment.Center; //tarif2.Text = string.IsNullOrWhiteSpace(mInfo.Tariff2Name) ? AppResources.tarif2 : mInfo.Tariff2Name; //tarif3.FontSize = 13; //tarif3.TextColor = Color.FromHex("#A2A2A2"); //tarif3.HorizontalTextAlignment = TextAlignment.Center; //tarif3.Text = string.IsNullOrWhiteSpace(mInfo.Tariff3Name) ? AppResources.tarif3 : mInfo.Tariff3Name; count1Stack.Orientation = StackOrientation.Horizontal; count1Stack.HorizontalOptions = LayoutOptions.FillAndExpand; counterDate1.FontSize = 15; counterDate1.TextColor = Color.FromHex("#A2A2A2"); counterDate1.HorizontalTextAlignment = TextAlignment.Start; counterDate1.HorizontalOptions = LayoutOptions.Start; counterDate1.MaxLines = 1; count1.FontSize = 15; count1.TextColor = Color.Black; count1.HorizontalTextAlignment = TextAlignment.End; count1.HorizontalOptions = LayoutOptions.End; count1.VerticalOptions = LayoutOptions.Start; count1.MaxLines = 1; count1t2.FontSize = 15; count1t2.TextColor = Color.Black; count1t2.HorizontalTextAlignment = TextAlignment.End; count1t2.HorizontalOptions = LayoutOptions.End; count1t2.VerticalOptions = LayoutOptions.Start; count1t2.MaxLines = 1; //#if DEBUG // count1t2.Text = "100500.111"; //#endif count1t3.FontSize = 15; count1t3.TextColor = Color.Black; count1t3.HorizontalTextAlignment = TextAlignment.End; count1t3.HorizontalOptions = LayoutOptions.End; count1t3.VerticalOptions = LayoutOptions.Start; count1t3.MaxLines = 1; //#if DEBUG // count1t3.Text = "100502.213"; //#endif BoxView lines = new BoxView(); lines.HeightRequest = 1; //lines.BackgroundColor = Color.LightGray; lines.Color = Color.LightGray; lines.VerticalOptions = LayoutOptions.Center; lines.HorizontalOptions = LayoutOptions.FillAndExpand; count1Stack.Children.Add(counterDate1); count1Stack.Children.Add(lines); count1Stack.Children.Add(tarif1); count1Stack.Children.Add(count1); container.Children.Add(count1Stack); count1t2Stack.Orientation = StackOrientation.Horizontal; count1t2Stack.HorizontalOptions = LayoutOptions.End; var t21 = new Label() { FontSize = 13, TextColor = Color.FromHex("#A2A2A2"), HorizontalTextAlignment = TextAlignment.Center }; t21.Text = string.IsNullOrWhiteSpace(mInfo.Tariff2Name) ? AppResources.tarif2 : mInfo.Tariff2Name; count1t2Stack.Children.Add(t21); count1t2Stack.Children.Add(count1t2); container.Children.Add(count1t2Stack); count1t3Stack.Orientation = StackOrientation.Horizontal; count1t3Stack.HorizontalOptions = LayoutOptions.End; var t31 = new Label() { FontSize = 13, TextColor = Color.FromHex("#A2A2A2"), HorizontalTextAlignment = TextAlignment.Center }; t31.Text = string.IsNullOrWhiteSpace(mInfo.Tariff2Name) ? AppResources.tarif2 : mInfo.Tariff2Name; count1t3Stack.Children.Add(t31); count1t3Stack.Children.Add(count1t3); container.Children.Add(count1t3Stack); count2Stack.Orientation = StackOrientation.Horizontal; count2Stack.HorizontalOptions = LayoutOptions.FillAndExpand; counterDate2.FontSize = 15; counterDate2.TextColor = Color.FromHex("#A2A2A2"); counterDate2.HorizontalTextAlignment = TextAlignment.Start; counterDate2.HorizontalOptions = LayoutOptions.Start; counterDate2.MaxLines = 1; // counterDate2.WidthRequest = 150; count2.FontSize = 15; count2.TextColor = Color.Black; count2.HorizontalTextAlignment = TextAlignment.End; count2.HorizontalOptions = LayoutOptions.End; count2.VerticalOptions = LayoutOptions.Center; count2.MaxLines = 1; count2t2.FontSize = 15; count2t2.TextColor = Color.Black; count2t2.HorizontalTextAlignment = TextAlignment.End; count2t2.HorizontalOptions = LayoutOptions.End; count2t2.VerticalOptions = LayoutOptions.Start; count2t2.MaxLines = 1; //#if DEBUG // count2t2.Text = "200500.111"; //#endif count2t3.FontSize = 15; count2t3.TextColor = Color.Black; count2t3.HorizontalTextAlignment = TextAlignment.End; count2t3.HorizontalOptions = LayoutOptions.End; count2t3.VerticalOptions = LayoutOptions.Start; count2t3.MaxLines = 1; //#if DEBUG // count2t3.Text = "200502.213"; //#endif Label lines2 = new Label(); lines2.HeightRequest = 1; lines2.BackgroundColor = Color.LightGray; lines2.VerticalOptions = LayoutOptions.Center; lines2.HorizontalOptions = LayoutOptions.FillAndExpand; count2Stack.Children.Add(counterDate2); count2Stack.Children.Add(lines2); //count2Stack.Children.Add(tarif1); Label t1 = new Label() { FontSize = 13, TextColor = Color.FromHex("#A2A2A2"), HorizontalTextAlignment = TextAlignment.Center }; if (mInfo.TariffNumberInt > 1) { if (!string.IsNullOrWhiteSpace(mInfo.Tariff1Name)) { t1.Text = string.IsNullOrWhiteSpace(mInfo.Tariff1Name) ? AppResources.tarif1 : mInfo.Tariff1Name; } else { t1.IsVisible = false; } } count2Stack.Children.Add(t1); //tarif1.FontSize = 13; //tarif1.TextColor = Color.FromHex("#A2A2A2"); //Color.Red; //tarif1.HorizontalTextAlignment = TextAlignment.Center; //if (mInfo.TariffNumberInt > 1) // if (!string.IsNullOrWhiteSpace(mInfo.Tariff1Name)) // tarif1.Text = string.IsNullOrWhiteSpace(mInfo.Tariff1Name) ? AppResources.tarif1 : mInfo.Tariff1Name; // else // tarif1.IsVisible = false; count2Stack.Children.Add(count2); container.Children.Add(count2Stack); count2t2Stack.Orientation = StackOrientation.Horizontal; count2t2Stack.HorizontalOptions = LayoutOptions.End; var t22 = new Label() { FontSize = 13, TextColor = Color.FromHex("#A2A2A2"), HorizontalTextAlignment = TextAlignment.Center }; t22.Text = string.IsNullOrWhiteSpace(mInfo.Tariff2Name) ? AppResources.tarif2 : mInfo.Tariff2Name; count2t2Stack.Children.Add(t22); count2t2Stack.Children.Add(count2t2); container.Children.Add(count2t2Stack); count2t3Stack.Orientation = StackOrientation.Horizontal; count2t3Stack.HorizontalOptions = LayoutOptions.End; var t32 = new Label() { FontSize = 13, TextColor = Color.FromHex("#A2A2A2"), HorizontalTextAlignment = TextAlignment.Center }; t32.Text = string.IsNullOrWhiteSpace(mInfo.Tariff3Name) ? AppResources.tarif3 : mInfo.Tariff3Name; count2t3Stack.Children.Add(t32); count2t3Stack.Children.Add(count2t3); container.Children.Add(count2t3Stack); count3Stack.Orientation = StackOrientation.Horizontal; count3Stack.HorizontalOptions = LayoutOptions.FillAndExpand; counterDate3.FontSize = 15; counterDate3.TextColor = Color.FromHex("#A2A2A2"); counterDate3.HorizontalTextAlignment = TextAlignment.Start; counterDate3.HorizontalOptions = LayoutOptions.Start; counterDate3.MaxLines = 1; // counterDate3.WidthRequest = 150; count3.FontSize = 15; count3.TextColor = Color.Black; count3.HorizontalTextAlignment = TextAlignment.End; count3.HorizontalOptions = LayoutOptions.End; count3.VerticalOptions = LayoutOptions.Center; count3.MaxLines = 1; count3t2.FontSize = 15; count3t2.TextColor = Color.Black; count3t2.HorizontalTextAlignment = TextAlignment.End; count3t2.HorizontalOptions = LayoutOptions.End; count3t2.VerticalOptions = LayoutOptions.Start; count3t2.MaxLines = 1; //#if DEBUG // count3t2.Text = "100500.111"; //#endif count3t3.FontSize = 15; count3t3.TextColor = Color.Black; count3t3.HorizontalTextAlignment = TextAlignment.End; count3t3.HorizontalOptions = LayoutOptions.End; count3t3.VerticalOptions = LayoutOptions.Start; count3t3.MaxLines = 1; //#if DEBUG // count3t3.Text = "100502.213"; //#endif Label lines3 = new Label(); lines3.HeightRequest = 1; lines3.BackgroundColor = Color.LightGray; lines3.VerticalOptions = LayoutOptions.Center; lines3.HorizontalOptions = LayoutOptions.FillAndExpand; count3Stack.Children.Add(counterDate3); count3Stack.Children.Add(lines3); Label t2 = new Label() { FontSize = 13, TextColor = Color.FromHex("#A2A2A2"), HorizontalTextAlignment = TextAlignment.Center }; if (mInfo.TariffNumberInt > 1) { if (!string.IsNullOrWhiteSpace(mInfo.Tariff1Name)) { t2.Text = string.IsNullOrWhiteSpace(mInfo.Tariff1Name) ? AppResources.tarif1 : mInfo.Tariff1Name; } else { t2.IsVisible = false; } } count3Stack.Children.Add(t2); //count3Stack.Children.Add(tarif1); count3Stack.Children.Add(count3); container.Children.Add(count3Stack); count3t2Stack.Orientation = StackOrientation.Horizontal; count3t2Stack.HorizontalOptions = LayoutOptions.End; var t23 = new Label() { FontSize = 13, TextColor = Color.FromHex("#A2A2A2"), HorizontalTextAlignment = TextAlignment.Center }; t23.Text = string.IsNullOrWhiteSpace(mInfo.Tariff2Name) ? AppResources.tarif2 : mInfo.Tariff2Name; count3t2Stack.Children.Add(t23); count3t2Stack.Children.Add(count3t2); container.Children.Add(count3t2Stack); count3t3Stack.Orientation = StackOrientation.Horizontal; count3t3Stack.HorizontalOptions = LayoutOptions.End; var t33 = new Label() { FontSize = 13, TextColor = Color.FromHex("#A2A2A2"), HorizontalTextAlignment = TextAlignment.Center }; t33.Text = string.IsNullOrWhiteSpace(mInfo.Tariff3Name) ? AppResources.tarif3 : mInfo.Tariff3Name; count3t3Stack.Children.Add(t33); count3t3Stack.Children.Add(count3t3); container.Children.Add(count3t3Stack); //container.Children.Add(count3t2); //container.Children.Add(count3t3); frameBtn.HorizontalOptions = LayoutOptions.FillAndExpand; frameBtn.VerticalOptions = LayoutOptions.Start; frameBtn.BackgroundColor = (Color)Application.Current.Resources["MainColor"]; frameBtn.CornerRadius = 10; frameBtn.Margin = new Thickness(0, 10, 0, 0); frameBtn.Padding = 12; frameBtn.SetOnAppTheme(Frame.HasShadowProperty, false, true); frameBtn.SetOnAppTheme(MaterialFrame.ElevationProperty, 0, 20); containerBtn.Orientation = StackOrientation.Horizontal; containerBtn.HorizontalOptions = LayoutOptions.CenterAndExpand; Label btn = new Label(); btn.Margin = new Thickness(0, 0, 0, 0); btn.TextColor = Color.White; btn.FontAttributes = FontAttributes.Bold; btn.VerticalTextAlignment = TextAlignment.Center; btn.FontSize = 15; btn.Text = AppResources.PassPenance; containerBtn.Children.Add(new SvgCachedImage { Source = "resource://xamarinJKH.Resources.ic_counter.svg", ReplaceStringMap = new Dictionary <string, string> { { "#000000", "#FFFFFF" } }, HeightRequest = 20 }); containerBtn.Children.Add(btn); frameBtn.Content = containerBtn; container.Children.Add(frameBtn); canCount.Text = AppResources.MetersThreeCellCanCount; canCount.FontSize = 12; canCount.TextDecorations = TextDecorations.Underline; canCount.FontAttributes = FontAttributes.Bold; canCount.TextColor = Color.Black; canCount.HorizontalTextAlignment = TextAlignment.End; canCount.HorizontalOptions = LayoutOptions.CenterAndExpand; canCount.HorizontalTextAlignment = TextAlignment.Center; labelDisable = new Label() { Text = AppResources.CounterLeave, FontSize = 14, IsVisible = false, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center }; container.Children.Add(canCount); container.Children.Add(labelDisable); frame.Content = container; ext(mInfo, mInfo.Values, mInfo.NumberOfDecimalPlaces, mInfo.ID, mInfo.IsDisabled, mInfo.Resource, mInfo.Address, mInfo.CustomName, mInfo.FactoryNumber, mInfo.UniqueNum, mInfo.Units, mInfo.NextCheckupDate, mInfo.RecheckInterval.ToString(), mInfo.Tariff1Name, mInfo.Tariff2Name, mInfo.Tariff3Name); Children.Add(frame); }