Пример #1
0
        private void HandleDeleteMessureParam(MessureParam a)
        {
            var delmodel = _selectedMessureParam;
            var msg      = new DialogMessage(string.Format("确定要删除参数:{0}吗?", delmodel.ParamName), result =>
            {
                if (result == System.Windows.MessageBoxResult.Yes)
                {
                    try
                    {
                        _messureParams.Remove(delmodel);
                        _allParams.Remove(delmodel);
                    }
                    catch (Exception ex)
                    {
                        Messenger.Default.Send <Exception>(ex);
                    }
                }
            });

            msg.Caption = "确定要删除吗?";
            msg.Button  = MessageBoxButton.YesNo;
            msg.Icon    = MessageBoxImage.Question;

            Messenger.Default.Send <DialogMessage>(msg);
        }
Пример #2
0
        private void HandleAddMessureParam(MessureParam a)
        {
            int          num = _messureParams.Count() + 1;
            MessureParam cp  = new MessureParam();

            cp.Id           = Guid.NewGuid();
            cp.ParamName    = "计算参数" + num.ToString();
            cp.PrecisionNum = 2;
            cp.ParamSymbol  = "m" + num.ToString();
            cp.Order        = (byte)num;
            cp.UnitSymbol   = "no symbol";
            cp.AppId        = App.Id;

            _messureParams.Add(cp);
            _allParams.Add(cp);
        }
Пример #3
0
        protected override void Seed(Hammergo.Data.DamWCFContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            var type1 = new ApparatusType();

            type1.Id       = Guid.NewGuid();
            type1.TypeName = "第一种类型";



            var type2 = new ApparatusType();

            type2.Id       = Guid.NewGuid();
            type2.TypeName = "第二种类型";

            context.ApparatusTypes.AddOrUpdate(type1, type2);

            //添加工程部位
            var root = new ProjectPart()
            {
                Id         = Guid.NewGuid(),
                PartName   = "root",
                ParentPart = null,
            };

            var p1 = new ProjectPart()
            {
                Id         = Guid.NewGuid(),
                PartName   = "p1",
                ParentPart = root.Id,
            };

            var p2 = new ProjectPart()
            {
                Id         = Guid.NewGuid(),
                PartName   = "p2",
                ParentPart = root.Id,
            };


            context.ProjectParts.AddOrUpdate(root, p1, p2);


            //添加仪器
            var app1 = new App();

            app1.Id            = Guid.NewGuid();
            app1.AppName       = "第一支仪器";
            app1.CalculateName = "FirstApp";
            app1.AppTypeID     = type1.Id;
            app1.ProjectPartID = p1.Id;

            var app2 = new App();

            app2.Id            = Guid.NewGuid();
            app2.AppName       = "第二支仪器";
            app2.CalculateName = "SecondApp";
            app2.AppTypeID     = type2.Id;
            app2.ProjectPartID = p2.Id;


            var app3 = new App();

            app3.Id            = Guid.NewGuid();
            app3.AppName       = "第三支仪器";
            app3.CalculateName = "ThirdApp";
            app3.AppTypeID     = type2.Id;
            app3.ProjectPartID = p2.Id;

            context.Apps.AddOrUpdate(app1, app2, app3);



            var remark3 = new Remark()
            {
                Id         = Guid.NewGuid(),
                Date       = DateTime.Now,
                RemarkText = "remark",
                AppId      = app2.Id,
            };

            context.Remarks.AddOrUpdate(remark3);

            var conParam1 = new ConstantParam()
            {
                Id           = Guid.NewGuid(),
                AppId        = app1.Id,
                ParamName    = "c1",
                ParamSymbol  = "c1",
                PrecisionNum = 2,
                UnitSymbol   = "no",
                Val          = 1,
                Order        = 1,
                Description  = "no description",
            };

            var mesParam1 = new MessureParam()
            {
                Id           = Guid.NewGuid(),
                AppId        = app1.Id,
                ParamName    = "m1",
                ParamSymbol  = "m1",
                PrecisionNum = 2,
                UnitSymbol   = "no",
                Order        = 1,
                Description  = "no description",
            };


            var calcParam1 = new CalculateParam()
            {
                Id           = Guid.NewGuid(),
                AppId        = app1.Id,
                ParamName    = "cal1",
                ParamSymbol  = "cal1",
                PrecisionNum = 2,
                UnitSymbol   = "no",
                Order        = 1,
                Description  = "no description",
            };

            context.AppParams.AddOrUpdate(conParam1, mesParam1, calcParam1);
            //添加第一支仪器的数据
            DateTimeOffset date  = DateTimeOffset.Now;
            int            count = 20;

            for (int i = 0; i < count; i++)
            {
                MessureValue mv = new MessureValue()
                {
                    Id      = Guid.NewGuid(),
                    ParamId = mesParam1.Id,
                    Date    = date.AddDays(-i),
                    Val     = i
                };

                CalculateValue cv = new CalculateValue()
                {
                    Id      = Guid.NewGuid(),
                    ParamId = calcParam1.Id,
                    Date    = date.AddDays(-i),
                    Val     = i
                };

                var remark = new Remark()
                {
                    Id         = Guid.NewGuid(),
                    Date       = date.AddDays(-i),
                    RemarkText = "remark" + i,
                    AppId      = app1.Id,
                };


                context.MessureValues.AddOrUpdate(mv);
                context.CalculateValues.AddOrUpdate(cv);
                context.Remarks.AddOrUpdate(remark);
            }

            //添加第三支仪器的参数
            var conParam1_third = new ConstantParam()
            {
                Id           = Guid.NewGuid(),
                AppId        = app3.Id,
                ParamName    = "c1",
                ParamSymbol  = "c1",
                PrecisionNum = 2,
                UnitSymbol   = "no",
                Val          = 1,
                Order        = 1,
                Description  = "no description",
            };

            var mesParam1_third = new MessureParam()
            {
                Id           = Guid.NewGuid(),
                AppId        = app3.Id,
                ParamName    = "m1",
                ParamSymbol  = "m1",
                PrecisionNum = 2,
                UnitSymbol   = "no",
                Order        = 1,
                Description  = "no description",
            };


            var calcParam1_third = new CalculateParam()
            {
                Id           = Guid.NewGuid(),
                AppId        = app3.Id,
                ParamName    = "cal1",
                ParamSymbol  = "cal1",
                PrecisionNum = 2,
                UnitSymbol   = "no",
                Order        = 1,
                Description  = "no description",
            };

            context.AppParams.AddOrUpdate(conParam1_third, mesParam1_third, calcParam1_third);

            ///first app fomula

            var formula = new Formula()
            {
                Id                = Guid.NewGuid(),
                ParamId           = calcParam1.Id,
                StartDate         = DateTimeOffset.MinValue,
                EndDate           = DateTimeOffset.MaxValue,
                CalculateOrder    = 1,
                FormulaExpression = "c1+m1"
            };

            context.Formulae.AddOrUpdate(formula);


            var formula_third = new Formula()
            {
                Id                = Guid.NewGuid(),
                ParamId           = calcParam1_third.Id,
                StartDate         = DateTimeOffset.MinValue,
                EndDate           = DateTimeOffset.MaxValue,
                CalculateOrder    = 1,
                FormulaExpression = "c1+m1+FirstApp.cal1"
            };

            context.Formulae.AddOrUpdate(formula_third);



            //添加第三支仪器的数据
            count = 10;
            for (int i = 0; i < count; i++)
            {
                MessureValue mv = new MessureValue()
                {
                    Id      = Guid.NewGuid(),
                    ParamId = mesParam1_third.Id,
                    Date    = date.AddDays(-i),
                    Val     = i + 1
                };

                CalculateValue cv = new CalculateValue()
                {
                    Id      = Guid.NewGuid(),
                    ParamId = calcParam1_third.Id,
                    Date    = date.AddDays(-i),
                    Val     = i + 2
                };

                var remark = new Remark()
                {
                    Id         = Guid.NewGuid(),
                    Date       = date.AddDays(-i),
                    RemarkText = "remark" + i + 1,
                    AppId      = app3.Id,
                };


                context.MessureValues.AddOrUpdate(mv);
                context.CalculateValues.AddOrUpdate(cv);
                context.Remarks.AddOrUpdate(remark);
            }
        }
Пример #4
0
        private void HandleCreateApp(object param)
        {
            List <object> addedList = new List <object>();

            try
            {
                //
                int childrenCnt = (from i in DbContext.ProjectParts
                                   where i.ParentPart == Part.Id
                                   select i).Count();
                if (childrenCnt > 0)
                {
                    throw new Exception("只能在没有子结点的部位创建测点");
                }

                int appCnt = (from s in DbContext.Apps
                              where s.AppName == NewApp.AppName || s.CalculateName == NewApp.CalculateName
                              select s).Count();
                if (appCnt > 0)
                {
                    throw new Exception("新测点的名称或计算名称已存在,无法创建");
                }

                App needAddApp = new App();


                needAddApp.Id            = Guid.NewGuid();
                needAddApp.ProjectPartID = Part.Id;

                needAddApp.AppName       = NewApp.AppName;
                needAddApp.CalculateName = NewApp.CalculateName;
                needAddApp.BuriedTime    = NewApp.BuriedTime;
                needAddApp.X             = NewApp.X;
                needAddApp.Y             = NewApp.Y;
                needAddApp.Z             = NewApp.Z;
                needAddApp.OtherInfo     = NewApp.OtherInfo;



                DbContext.AddToApps(needAddApp);
                addedList.Add(needAddApp);


                DbContext.SaveChanges();
                _currentApps.Add(needAddApp);

                if (AllowClone)
                {
                    //clone app params

                    if (CloneAppName.Trim().Length == 0)
                    {
                        throw new Exception("当选择克隆时,模板测点不能为空");
                    }

                    if (cloneApp == null)
                    {
                        cloneApp = (from s in DbContext.Apps
                                    where s.AppName == CloneAppName
                                    select s).FirstOrDefault();
                        if (cloneApp == null)
                        {
                            throw new Exception(string.Format("找不到测点编号为{0}的测点", CloneAppName));
                        }
                    }

                    DbContext.LoadProperty(cloneApp, "AppParams");


                    var paramsList  = new List <AppParam>();
                    var formulaList = new List <Formula>();

                    foreach (var item in cloneApp.AppParams)
                    {
                        AppParam newParam = null;
                        if (item is ConstantParam)
                        {
                            newParam = new ConstantParam();
                            (newParam as ConstantParam).Val = (item as ConstantParam).Val;
                        }
                        else if (item is MessureParam)
                        {
                            newParam = new MessureParam();
                        }
                        else if (item is CalculateParam)
                        {
                            newParam = new CalculateParam();
                        }

                        //set values
                        newParam.Id           = Guid.NewGuid();
                        newParam.AppId        = needAddApp.Id;
                        newParam.ParamName    = item.ParamName;
                        newParam.ParamSymbol  = item.ParamSymbol;
                        newParam.PrecisionNum = item.PrecisionNum;
                        newParam.UnitSymbol   = item.UnitSymbol;
                        newParam.Order        = item.Order;
                        newParam.Description  = item.Description;

                        paramsList.Add(newParam);

                        //DbContext.AddToAppParams(newParam);
                        //addedList.Add(newParam);

                        //clone formules
                        if (item is CalculateParam)
                        {
                            CalculateParam cp       = item as CalculateParam;
                            var            formulae = (from i in DbContext.Formulae
                                                       where i.ParamId == cp.Id
                                                       select i).ToList();
                            foreach (var fl in formulae)
                            {
                                Formula newfl = new Formula();
                                newfl.Id                = Guid.NewGuid();
                                newfl.ParamId           = newParam.Id;
                                newfl.FormulaExpression = fl.FormulaExpression;
                                newfl.StartDate         = fl.StartDate;
                                newfl.EndDate           = fl.EndDate;
                                newfl.CalculateOrder    = fl.CalculateOrder;

                                formulaList.Add(newfl);
                                //DbContext.AddToFormulae(newfl);
                                //addedList.Add(newfl);
                            }
                        }
                    }

                    ParamsDTO dto = new ParamsDTO();
                    dto.AddedParams   = paramsList;
                    dto.AddedFormulae = formulaList;

                    DbContext.UpdateAppParams(dto);
                }



                var msg = new DialogMessage("测点创建成功并已添加到相关的工程部位中。", result =>
                {
                });

                msg.Caption = "创建成功";
                msg.Button  = MessageBoxButton.OK;
                msg.Icon    = MessageBoxImage.Information;

                Messenger.Default.Send <DialogMessage>(msg);
            }
            catch (Exception ex)
            {
                Messenger.Default.Send <Exception>(ex);
                //reject the changes
                foreach (object item in addedList)
                {
                    DbContext.Detach(item);
                }
            }
            finally
            {
                // DbContext.Detach(NewApp);
            }
        }
Пример #5
0
        /// <summary>
        /// 将实际的值填充到参数列表中,如果参数没有相应的值,将被赋初值0
        /// </summary>
        /// <param name="list">参数列表</param>
        /// <param name="appCalcName">测点的计算名称</param>
        /// <param name="date">日期</param>
        /// <param name="appendDot">是否将计算名称和点加在参数的前面</param>
        /// <param name="simpleInfo">测点数据信息</param>
        internal static void fillListByCalcName_Date(hammergo.caculator.MyList list, DateTimeOffset date, bool appendDot, AppIntegratedInfo simpleInfo)
        {
            string appCalcName = simpleInfo.CurrentApp.CalculateName;

            foreach (ConstantParam cp in simpleInfo.ConstantParams)
            {
                string key = cp.ParamSymbol;
                if (appendDot)
                {
                    key = String.Format("{0}.{1}", appCalcName, key);
                }
                list.add(key, cp.Val);
            }

            //赋初值0

            foreach (MessureParam mp in simpleInfo.MesParams)
            {
                string key = mp.ParamSymbol;
                if (appendDot)
                {
                    key = String.Format("{0}.{1}", appCalcName, key);
                }
                list.add(key, 0);
            }

            //赋初值0
            foreach (CalculateParam cp in simpleInfo.CalcParams)
            {
                string key = cp.ParamSymbol;
                if (appendDot)
                {
                    key = String.Format("{0}.{1}", appCalcName, key);
                }
                list.add(key, 0);
            }

            //加快速度
            foreach (MessureValue mv in simpleInfo.MesValues.Where(s => s.Date == date))
            {
                MessureParam mp = simpleInfo.MesParams.Find(delegate(MessureParam item) { return(item.Id == mv.ParamId); });

                string key = mp.ParamSymbol;
                if (appendDot)
                {
                    key = String.Format("{0}.{1}", appCalcName, key);
                }

                list[key] = mv.Val.Value;
            }

            //加快速度
            foreach (CalculateValue cv in simpleInfo.CalcValues.Where(s => s.Date == date))
            {
                CalculateParam cp  = simpleInfo.CalcParams.Find(delegate(CalculateParam item) { return(item.Id == cv.ParamId); });
                string         key = cp.ParamSymbol;
                if (appendDot)
                {
                    key = String.Format("{0}.{1}", appCalcName, key);
                }

                list[key] = cv.Val.Value;
            }
        }
Пример #6
0
        //重新计算相关值,并反映在gridview中
        public static void redirectToObjects(AppIntegratedInfo appInfo, DataRow row, string feildName)
        {
            DateTimeOffset date = (DateTimeOffset)row[PubConstant.timeColumnName];
            MessureParam   mp   = appInfo.MesParams.FirstOrDefault(s => s.ParamName == feildName);

            if (mp != null)
            {
                MessureValue editedValue = appInfo.MesValues.Find(delegate(MessureValue item)
                {
                    return(item.Date == date && item.ParamId == mp.Id);
                });

                if (editedValue == null)
                {
                    //create new object
                    editedValue         = new MessureValue();
                    editedValue.Date    = date;
                    editedValue.ParamId = mp.Id;
                    appInfo.MesValues.Add(editedValue);

                    appInfo.DbContext.AddToMessureValues(editedValue);
                }


                editedValue.Val = (double)row[feildName];

                appInfo.DbContext.UpdateObject(editedValue);

                //recalculate the calc values
                reCalcValues(appInfo, row, date);
            }
            else
            {
                //直接编辑成果值,所有不用计算本测点的数据,但需要更新引用测点的数据
                CalculateParam cp = appInfo.CalcParams.Find(delegate(CalculateParam item)
                {
                    return(item.ParamName == feildName);
                });

                if (cp != null)
                {
                    CalculateValue calcValue = appInfo.CalcValues.Find(delegate(CalculateValue item)
                    {
                        return(item.Date == date && item.ParamId == cp.Id);
                    });

                    if (calcValue == null)
                    {
                        //create new object
                        calcValue         = new CalculateValue();
                        calcValue.Date    = date;
                        calcValue.ParamId = cp.Id;
                        appInfo.CalcValues.Add(calcValue);

                        appInfo.DbContext.AddToCalculateValues(calcValue);
                    }

                    calcValue.Val = (double)row[feildName];

                    //dbcontext标记要更新
                    appInfo.DbContext.UpdateObject(calcValue);
                }
            }

            //may be need reset the filter to null
        }
Пример #7
0
        protected override void bgw_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            try
            {
                using (DamWCFContext dam6Entities = new DamWCFContext(false))
                {
                    ResetConnectionString(dam6Entities);

                    using (EF5x.Models.DamDBContext dam5Entities = new EF5x.Models.DamDBContext())
                    {
                        ResetConnectionString(dam5Entities);
                        _allRowCnt = dam5Entities.MessureParams.Count();
                        foreach (var item in dam5Entities.MessureParams.AsNoTracking())
                        {
                            var id = (from i in dam6Entities.Apps.AsNoTracking()
                                      where i.AppName == item.appName
                                      select i).First().Id;

                            if (dam6Entities.MessureParams.FirstOrDefault(i => i.Id == item.MessureParamID) == null)
                            {
                                var newItem = new MessureParam();

                                newItem.AppId       = id;
                                newItem.Id          = item.MessureParamID;
                                newItem.Description = item.Description;

                                newItem.Order = item.Order == null?(byte)0:item.Order.Value;

                                newItem.ParamName   = item.ParamName;
                                newItem.ParamSymbol = item.ParamSymbol;

                                newItem.PrecisionNum = item.PrecisionNum == null ? (byte)0 : item.PrecisionNum.Value;

                                newItem.UnitSymbol = item.UnitSymbol;


                                dam6Entities.MessureParams.Add(newItem);


                                dam6Entities.SaveChanges();
                                dam6Entities.Entry(newItem).State = System.Data.Entity.EntityState.Detached;;
                            }
                            handledCnt++;
                            reportProgress();
                        }
                    }
                }
                reportProgress();

                bgwResult = "导入成功!";
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    bgwResult = ex.InnerException.Message;
                }
                else
                {
                    bgwResult = ex.Message;
                }
            }
        }
Пример #8
0
        public async Task T_params_Composite()
        {
            using (var client = new HttpClient())
            {
                //get app

                Uri uri     = new Uri(TestConfig.serviceUrl);
                var context = new DamServiceRef.Container(uri);

                context.Format.UseJson();

                var appItem = context.Apps.Where(s => s.AppName == "第二支仪器").SingleOrDefault();


                var conParam1 = new ConstantParam()
                {
                    Id           = Guid.NewGuid(),
                    AppId        = appItem.Id,
                    ParamName    = "sc1",
                    ParamSymbol  = "sc1",
                    PrecisionNum = 2,
                    UnitSymbol   = "no",
                    Val          = 1,
                    Order        = 1,
                    Description  = "no description",
                };

                var mesParam1 = new MessureParam()
                {
                    Id           = Guid.NewGuid(),
                    AppId        = appItem.Id,
                    ParamName    = "sm1",
                    ParamSymbol  = "sm1",
                    PrecisionNum = 2,
                    UnitSymbol   = "no",
                    Order        = 1,
                    Description  = "no description",
                };


                var calParam1 = new CalculateParam()
                {
                    Id           = Guid.NewGuid(),
                    AppId        = appItem.Id,
                    ParamName    = "scal1",
                    ParamSymbol  = "scal1",
                    PrecisionNum = 2,
                    UnitSymbol   = "no",
                    Order        = 1,
                    Description  = "no description",
                };


                var formula1 = new Formula()
                {
                    Id                = Guid.NewGuid(),
                    ParamId           = calParam1.Id,
                    StartDate         = DateTimeOffset.MinValue,
                    EndDate           = DateTimeOffset.MaxValue,
                    CalculateOrder    = 1,
                    FormulaExpression = "sc1+sm1"
                };

                ParamsDTO dto = new ParamsDTO()
                {
                    Id = appItem.Id,
                };

                dto.AddedParams = new List <AppParam>()
                {
                    conParam1, mesParam1, calParam1
                };
                dto.AddedFormulae = new List <Formula>()
                {
                    formula1
                };


                // New code:
                client.BaseAddress = new Uri(TestConfig.baseAddress);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.PostAsJsonAsync("api/ParamsDTOs", dto);

                Assert.IsTrue(response.IsSuccessStatusCode, " insert param fail");


                //add updated ,delete
                var mesParam2 = new MessureParam()
                {
                    Id           = Guid.NewGuid(),
                    AppId        = appItem.Id,
                    ParamName    = "sm2",
                    ParamSymbol  = "sm2",
                    PrecisionNum = 2,
                    UnitSymbol   = "no",
                    Order        = 1,
                    Description  = "no description",
                };

                var calParam2 = new CalculateParam()
                {
                    Id           = Guid.NewGuid(),
                    AppId        = appItem.Id,
                    ParamName    = "scal2",
                    ParamSymbol  = "scal2",
                    PrecisionNum = 2,
                    UnitSymbol   = "no",
                    Order        = 1,
                    Description  = "no description",
                };


                var formula2 = new Formula()
                {
                    Id                = Guid.NewGuid(),
                    ParamId           = calParam2.Id,
                    StartDate         = DateTimeOffset.MinValue,
                    EndDate           = DateTimeOffset.MaxValue,
                    CalculateOrder    = 1,
                    FormulaExpression = "sm2+sc1"
                };

                dto = new ParamsDTO()
                {
                    Id = appItem.Id,
                };

                dto.AddedParams = new List <AppParam>()
                {
                    calParam2
                };
                dto.AddedFormulae = new List <Formula>()
                {
                    formula2
                };

                //  fail because no corresponding mesparam
                response = await client.PostAsJsonAsync("api/ParamsDTOs", dto);

                Assert.IsFalse(response.IsSuccessStatusCode, "constraint fail");

                //fail because delete mes1 which cal param1 use
                dto = new ParamsDTO()
                {
                    Id = appItem.Id,
                };
                dto.AddedParams = new List <AppParam>()
                {
                    mesParam2, calParam2
                };
                dto.AddedFormulae = new List <Formula>()
                {
                    formula2
                };
                dto.DeletedParams = new List <AppParam>()
                {
                    mesParam1
                };
                response = await client.PostAsJsonAsync("api/ParamsDTOs", dto);

                Assert.IsFalse(response.IsSuccessStatusCode, "constraint fail");

                //delete mes1 and calc1
                dto = new ParamsDTO()
                {
                    Id = appItem.Id,
                };

                conParam1.Val = 2;

                dto.AddedParams = new List <AppParam>()
                {
                    mesParam2, calParam2
                };
                dto.AddedFormulae = new List <Formula>()
                {
                    formula2
                };
                dto.UpdatedParams = new List <AppParam>()
                {
                    conParam1
                };
                dto.DeletedParams = new List <AppParam>()
                {
                    mesParam1, calParam1
                };
                dto.DeletedFormulae = new List <Formula>()
                {
                    formula1
                };
                response = await client.PostAsJsonAsync("api/ParamsDTOs", dto);

                Assert.IsTrue(response.IsSuccessStatusCode, "constraint fail");

                //delete all params

                dto = new ParamsDTO()
                {
                    Id = appItem.Id,
                };

                dto.DeletedParams = new List <AppParam>()
                {
                    conParam1, mesParam2, calParam2
                };
                dto.DeletedFormulae = new List <Formula>()
                {
                    formula2
                };


                response = await client.PostAsJsonAsync("api/ParamsDTOs", dto);

                Assert.IsTrue(response.IsSuccessStatusCode, "delete formulae fail");

                //reload mesparam

                context = new DamServiceRef.Container(uri);


                var cnt = context.AppParams.Where(s => s.Id == mesParam1.Id).Count();

                Assert.AreEqual(0, cnt, "delete test fail");
            }
        }
Пример #9
0
        public async Task T_paramsMes()
        {
            using (var client = new HttpClient())
            {
                //get app

                Uri uri     = new Uri(TestConfig.serviceUrl);
                var context = new DamServiceRef.Container(uri);

                context.Format.UseJson();

                var appItem = context.Apps.Where(s => s.AppName == "第一支仪器").SingleOrDefault();



                // New code:
                client.BaseAddress = new Uri(TestConfig.baseAddress);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                ParamsDTO dto = new ParamsDTO()
                {
                    Id = appItem.Id,
                };

                var param = new MessureParam()
                {
                    Id           = Guid.NewGuid(),
                    AppId        = appItem.Id,
                    ParamName    = "mtest2",
                    ParamSymbol  = "mtest2",
                    PrecisionNum = 2,
                    UnitSymbol   = "no",
                    Order        = 1,
                    Description  = "no description",
                };

                dto.AddedParams = new List <AppParam>()
                {
                    param
                };

                HttpResponseMessage response = await client.PostAsJsonAsync("api/ParamsDTOs", dto);

                Assert.IsTrue(response.IsSuccessStatusCode, "add param fail");



                //modify
                dto = new ParamsDTO()
                {
                    Id = appItem.Id,
                };

                param.Order += 1;

                dto.UpdatedParams = new List <AppParam>()
                {
                    param
                };

                response = await client.PostAsJsonAsync("api/ParamsDTOs", dto);

                Assert.IsTrue(response.IsSuccessStatusCode, "delete param fail");


                //now deleted added param
                dto = new ParamsDTO()
                {
                    Id = appItem.Id,
                };


                dto.DeletedParams = new List <AppParam>()
                {
                    param
                };

                response = await client.PostAsJsonAsync("api/ParamsDTOs", dto);

                Assert.IsTrue(response.IsSuccessStatusCode, "delete param fail");
            }
        }
Пример #10
0
 private void HandleSelectedItemChangedMes(MessureParam a)
 {
     _selectedMessureParam = a;
 }