Ejemplo n.º 1
0
        public ActionResponse Add(SDC newSDC)
        {
            try
            {
                var district = unitWork.DistrictRepository.GetByID(newSDC.DistrictId);
                if (district == null)
                {
                    response.Success = false;
                    response.Message = msgHelper.GetNotFoundMessage("District");
                    return(response);
                }

                using (var scope = new TransactionScope())
                {
                    var SDC = new EFSDC()
                    {
                        Title    = newSDC.Title,
                        District = district
                    };
                    unitWork.SDCRepository.Insert(SDC);
                    unitWork.Save();
                    scope.Complete();
                    response.Success    = true;
                    response.ReturnedId = SDC.Id;
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Edit(int?id, SDC sdc)
        {
            ViewBag.Error = null;
            List <SDC> sdcs = new List <SDC>();

            if (!ModelState.IsValid)
            {
                return(View());
            }
            try
            {
                var response = await client.PutAsJsonAsync(apiBaseUrl + "/SDC/" + id.ToString(), sdc);

                if (response.IsSuccessStatusCode)
                {
                    ViewData["Message"] = "New SDC added successfully";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Error = response.Content.ReadAsStringAsync().Result;
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View("Edit"));
            }
            return(View("Index", sdcs));
        }
Ejemplo n.º 3
0
        public override FakeRow Populate(GDID parentGdid)
        {
            var dt = DateTime.Now.AddHours(Ambient.Random.NextScaledRandomInteger(1, 12)).AddMinutes(Ambient.Random.NextScaledRandomInteger(1, 60));

            CARRIER    = $"R{Ambient.Random.NextScaledRandomInteger(100, 300)}";
            MEMBERID   = $"{Ambient.Random.NextScaledRandomInteger(10_0000, 2_000_000) }*{NaturalTextGenerator.GenerateWord(3, 6)}";
            PERSONCODE = parentGdid.ID % 2 == 0 ? (short)1 : (short)Ambient.Random.NextScaledRandomInteger(1, 4);
            FILLDATE   = dt;
            QUANTITY   = parentGdid.ID % 2 == 0 ? 30 : parentGdid.ID % 3 == 0 ? 90 : 60;
            MPAMARK    = parentGdid.ID % 4 == 0 ? "X" : null;
            GROUPID    = Ambient.Random.NextScaledRandomInteger(10_0000, 20_000).ToString();

            COPAYDED = parentGdid.ID % 2 == 0 ? Math.Round(Ambient.Random.NextScaledRandomDouble(1, 5_000), 2) : 0;
            COPAYIG  = parentGdid.ID % 11 == 0 ? Math.Round(Ambient.Random.NextScaledRandomDouble(1, 5_000), 2) : 0;
            COPAYOG  = parentGdid.ID % 10 == 0 ? Math.Round(Ambient.Random.NextScaledRandomDouble(1, 5_000), 2) : 0;
            COPAYUG  = parentGdid.ID % 9 == 0 ? Math.Round(Ambient.Random.NextScaledRandomDouble(1, 5_000), 2) : 0;

            COPAY          = COPAYDED + COPAYIG + COPAYOG + COPAYUG;
            ORIGINALCOPAY  = COPAY;
            ENTEREDDATE    = dt;
            LICS           = Ambient.Random.NextScaledRandomInteger(0, 5);
            LICSLEVEL      = LICS.ToString();
            MONY           = parentGdid.ID % 5 == 0 ? "M" : null;
            BILLDISPFEE    = COPAY.HasValue && COPAY.Value > 50D ? Math.Round(Ambient.Random.NextScaledRandomDouble(1, 5), 2) : default(double?);
            BILLCOST       = COPAY.HasValue ? Math.Round(Ambient.Random.NextScaledRandomDouble(1, COPAY.Value), 2) : default(double?);
            BILLTAX        = parentGdid.ID % 20 == 0 ? Math.Round(Ambient.Random.NextScaledRandomDouble(1, 2), 2) : default(double?);
            SDC            = parentGdid.ID % 50 == 0 ? Ambient.Random.NextScaledRandomInteger(0, 5) > 2 ? "xxxxxxxxxxxxxxx" : "zzzzzz" : null;
            PPP            = SDC.IsNotNullOrWhiteSpace() ? (decimal)Math.Round(Ambient.Random.NextScaledRandomDouble(0, 2), 2) : default(decimal?);
            PTR            = PPP;
            GROUPBILLCOPAY = QUANTITY == 90 ? BILLCOST : null;
            NDC            = Math.Round(Ambient.Random.NextScaledRandomDouble(0, 10_000_000_000), 0).ToString("00000000000");
            DRUGCRITERIA   = parentGdid.ID % 12 == 0 ? "Y" : null;
            AUTHNUMBER     = Math.Round(Ambient.Random.NextScaledRandomDouble(0, 10_000_000_000), 0).ToString("000000000000000");
            REVERSEDAUTH   = parentGdid.ID % 5000 == 0 ? "R" + Math.Round(Ambient.Random.NextScaledRandomDouble(0, 10_000_000_000), 0).ToString("000000000000000") : null;
            TIER           = Ambient.Random.NextScaledRandomInteger(1, 6).ToString();
            LICSDED        = parentGdid.ID % 12 == 0 ? Math.Round(Ambient.Random.NextScaledRandomDouble(1, 5_000), 2) : default(double?);
            LICSIG         = 0;
            LICSOG         = 0;
            LICSUG         = 0;
            PLANPAYDED     = COPAY.HasValue && COPAY.Value > 500 ? Math.Round(Ambient.Random.NextScaledRandomDouble(1, 500), 2) : COPAYDED;
            PLANPAYUG      = COPAYUG;
            PLANPAYIG      = COPAYIG;
            PLANPAYOG      = COPAYOG;
            RXNUMBER       = Math.Abs((long)Ambient.Random.NextRandomUnsignedLong);
            NABP           = Math.Round(Ambient.Random.NextScaledRandomDouble(0, 10_000_000_000), 0).ToString("00000000000");
            OTHERTROOP     = 0;
            //F406 = null;
            SCRIPTTAG = parentGdid.ID % 200 == 0 ? "xxxx" : null;
            //UT004 = null;
            //UT024 = null;
            //UM028 = null;
            SUBGROUP    = GROUPID;
            FORMULARYID = Ambient.Random.NextScaledRandomInteger(2021000, 2021999).ToString();
            //F107 = null;

            ID = parentGdid;

            return(this);
        }
Ejemplo n.º 4
0
 // PUT api/sdc/5
 public IHttpActionResult Put(int id, [FromBody] SDC sdc)
 {
     sdcService = new SDCService();
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     sdcService.Update(id, sdc);
     return(StatusCode(HttpStatusCode.OK));
 }
Ejemplo n.º 5
0
        // POST api/sdc
        public IHttpActionResult Post([FromBody] SDC sdc)
        {
            sdcService = new SDCService();
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var response = sdcService.Add(sdc);

            if (response.Success)
            {
                return(Ok(response.ReturnedId));
            }
            return(Content(HttpStatusCode.BadRequest, response.Message));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Create(SDC sdc)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create"));
            }

            var response = await client.PostAsJsonAsync(apiBaseUrl + "/SDC", sdc);

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            SelectList districts = new SelectList(new List <string>());

            ViewBag.DistrictId = districts;
            ViewBag.Error      = response.ReasonPhrase;
            return(View(sdc));
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var response = await client.GetAsync(apiBaseUrl + "/SDC/" + id.ToString());

            SDC sdc = null;

            if (response.IsSuccessStatusCode)
            {
                var data = response.Content.ReadAsStringAsync().Result;
                sdc = JsonConvert.DeserializeObject <SDC>(data);
            }
            SelectList districts = new SelectList(new List <string>());

            ViewBag.DistrictId = districts;
            ViewBag.Title      = "Edit SDC";
            return(View(sdc));
        }
Ejemplo n.º 8
0
        public ActionResponse Update(int id, SDC updatedSDC)
        {
            try
            {
                if (updatedSDC != null)
                {
                    var district = unitWork.DistrictRepository.GetByID(updatedSDC.DistrictId);
                    if (district == null)
                    {
                        response.Success = false;
                        response.Message = msgHelper.GetNotFoundMessage("District");
                        return(response);
                    }

                    using (var scope = new TransactionScope())
                    {
                        var SDC = unitWork.SDCRepository.GetByID(id);
                        if (SDC != null)
                        {
                            SDC.Title    = updatedSDC.Title;
                            SDC.District = district;
                            unitWork.SDCRepository.Update(SDC);
                            unitWork.Save();
                            scope.Complete();
                            response.Success = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            char loopEnd;

            loopEnd = 'Z';

            switch (SDC.ToString())
            {
            case "CO":
                loopEnd = 'W';
                break;
            }

            user = ((PageBaseWI)Page).UserValues;

            for (char myChar = 'A'; myChar <= loopEnd; myChar++)
            {
                if ((myChar != 'Q') && (myChar != 'X'))
                {
                    LiteralControl mySpacer = new LiteralControl();
                    mySpacer.Text = " ";

                    HyperLink myLink = new HyperLink();
                    myLink.ID   = "myLink" + myChar;
                    myLink.Text = myChar.ToString();

                    String qString = user.GetBaseQueryString();
                    qString            = QueryStringUtils.ReplaceQueryString(qString, "SEARCHTYPE", SDC.ToString());
                    qString            = QueryStringUtils.ReplaceQueryString(qString, "L", myChar.ToString());
                    myLink.NavigateUrl = user.CreateURL("~/SchoolScript.aspx", qString.ToString());

                    this.PlaceHolder1.Controls.Add(mySpacer);
                    this.PlaceHolder1.Controls.Add(myLink);
                }
            }
        }
Ejemplo n.º 10
0
 public static int Get4LevelIndex(SDC sdc)
 {
     return(_map[(byte)sdc]);
 }
Ejemplo n.º 11
0
        public AdditionalInfo(char[] outFile)
        {
            /*
             * outFile format:
             * 0th line: 0 + '\r\n'
             * 1st line: output path + '\r\n'
             * 2nd line: rvt file name + '\t' + bldg name + '\t' + bldg usage + '\t' + structural type + '\t' + built year + '\t\r\n'
             * 3rd line: unchecked level index(uli1) + '\t' + uli2 + '\t' + ...(num uncertain) + '\r\n'
             *                      uli indicates the index of the corresponding level in MyLevel
             * 4th line: moment frame type + '\t' + sdc + '\t' + angle tol + '\t' + floor tol + '\t\r\n'...(so far 4) + '\r\n'
             *          MFtype: 0-SMF, 1-comfirmedMF, 2-IMF, 3-OMF, 4-uncomfirmedMF
             *          SDC: 0-A, 1-B, 2-C, 3-D, 4-E, 5-F, 6-OSHPD
             * 5th line: checked component(cc1) + '\t' + price1 + '\t' + cc2 + '\t' + price2 + '\t' + ...(num uncertain) + '\r\n'
             *          cc: 0-beam column joints, 1-shear wall, 2-gyp walls, 3-curtain walls
             *          price: 0.00 if default
             * 6th line: material type name(mtn1) + '\t' + mtn2 + '\t' + ... + '\r\n'
             *          check EnumLib.PGMaterialType for names and sequence
             * 7th line: default setting(ds1) + '\t' + ds2 + '\t' + ... + '\r\n'
             */
            int    i = 3, hot = 3;
            string temp      = null;
            int    tempIndex = 0;

            //1: output path
            while (outFile[i] != '\r')
            {
                ++i;
            }
            outPath = new string(outFile, hot, i - hot);
            hot     = i += 2;
            //2: basic info
            while (outFile[i] != '\t')
            {
                ++i;
            }
            rvtFileName = new string(outFile, hot, i - hot);
            hot         = ++i;
            while (outFile[i] != '\t')
            {
                ++i;
            }
            bldgName = new string(outFile, hot, i - hot);
            hot      = ++i;
            while (outFile[i] != '\t')
            {
                ++i;
            }
            bldgUse = new string(outFile, hot, i - hot);
            hot     = ++i;
            while (outFile[i] != '\t')
            {
                ++i;
            }
            struType = new string(outFile, hot, i - hot);
            hot      = ++i;
            while (outFile[i] != '\t')
            {
                ++i;
            }
            builtYear = new string(outFile, hot, i - hot);
            hot       = i += 3;
            //3: levels
            if (outFile[i] == '\r')
            {
                hot = i += 2;
            }
            else
            {
                while (outFile[i] != '\r')
                {
                    ++i;
                    if (outFile[i] == '\t')
                    {
                        temp = new string(outFile, hot, i - hot);
                        unCheckedLevel[(int.Parse(temp))] = 1;
                        hot = ++i;
                    }
                }
                hot = i += 2;
            }
            //4: structural info
            //MFType
            switch (outFile[i])
            {
            case '0':
                mfType = MomentFrameType.SMF;
                break;

            case '1':
                mfType = MomentFrameType.confirmedMF;
                break;

            case '2':
                mfType = MomentFrameType.IMF;
                break;

            case '3':
                mfType = MomentFrameType.OMF;
                break;

            case '4':
                mfType = MomentFrameType.unconfirmedMF;
                break;

            default:
                ErrorWriter.GetWriter().WriteError("ClassLib.AdditionalInfo: MFType not found.");
                break;
            }
            //SDC
            i += 2;
            switch (outFile[i])
            {
            case '0':
                sdc = SDC.A;
                break;

            case '1':
                sdc = SDC.B;
                break;

            case '2':
                sdc = SDC.C;
                break;

            case '3':
                sdc = SDC.D;
                break;

            case '4':
                sdc = SDC.E;
                break;

            case '5':
                sdc = SDC.F;
                break;

            case '6':
                sdc = SDC.OSHPD;
                break;

            default:
                ErrorWriter.GetWriter().WriteError("ClassLib.AdditionalInfo: SDC not found.");
                break;
            }
            hot = i += 2;
            while (outFile[i] != '\t')
            {
                ++i;
            }
            ConstSet.SetAngleTol(Double.Parse(new string(outFile, hot, i - hot)));
            hot = ++i;
            while (outFile[i] != '\t')
            {
                ++i;
            }
            ConstSet.SetFloorTol(Double.Parse(new string(outFile, hot, i - hot)));
            hot = i += 3;
            //5: component
            if (outFile[i] != '\r')
            {
                while (outFile[i] != '\r')
                {
                    ++i;
                    if (outFile[i] == '\t')
                    {
                        temp      = new string(outFile, hot, i - hot);
                        tempIndex = int.Parse(temp);
                        requiredComp[tempIndex] = true;
                        hot = ++i;
                        while (outFile[i] != '\t')
                        {
                            ++i;
                        }
                        temp = new string(outFile, hot, i - hot);
                        prices[tempIndex] = double.Parse(temp);
                        hot = ++i;
                    }
                }
            }
            //6: material type
            hot = i += 2;
            int count_material = 0;

            while (outFile[i] != '\r')
            {
                ++i;
                if (outFile[i] == '\t')
                {
                    materialTypes[count_material++] = new string(outFile, hot, i - hot);
                    hot = ++i;
                }
            }
            //7: default setting
            hot = i += 2;
            int count_setting = 0;

            while (outFile[i] != '\r')
            {
                ++i;
                if (outFile[i] == '\t')
                {
                    defaultSet[count_setting++] = int.Parse(new string(outFile, hot, i - hot));
                    hot = ++i;
                }
            }
            //End
        }
Ejemplo n.º 12
0
            public static bool Recognization(Pipe pipe)
            {
                _pipe = pipe;
                try
                {
                    _diameter = pipe.Diameter * 12;
                }
                catch
                {
                    _abandonWriter.WriteAbandonment(pipe, AbandonmentTable.Pipe_NonCircular);
                    return(false);
                }
                _length = pipe.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
                _level  = _doc.GetElement(pipe.get_Parameter(BuiltInParameter.RBS_START_LEVEL_PARAM).AsElementId()) as Level;
                _offset = pipe.get_Parameter(BuiltInParameter.RBS_START_OFFSET_PARAM).AsDouble();
                bool isFound;

                _floor = _myLevel.GetFloor(out isFound, _level, _offset) - 1;
                if (_floor == MyLevel.GetLevelNum() || _floor < 0)
                {
                    _abandonWriter.WriteAbandonment(pipe, AbandonmentTable.LevelOutOfRoof);
                    return(false);
                }
                SDC sdc = _addiInfo.sdc;

                _material = ((Material)_doc.GetElement(pipe.get_Parameter(BuiltInParameter.RBS_PIPE_MATERIAL_PARAM).AsElementId())).MaterialCategory;
                _pipeType = PipeType.Unknown;
                try
                {
                    PipingSystem     pipingSys     = pipe.MEPSystem as PipingSystem;
                    PipingSystemType pipingSysType = _doc.GetElement(pipingSys.GetTypeId()) as PipingSystemType;
                    FluidType        fluidType     = _doc.GetElement(pipingSysType.FluidType) as FluidType;
                    String           pstName       = pipingSysType.Name;

                    if (pstName.Contains("冷水"))
                    {
                        _pipeType = PipeType.ColdWater;
                    }
                    if (pstName.Contains("热水"))
                    {
                        _pipeType = PipeType.HotWater;
                    }
                    if (pstName.Contains("卫生"))
                    {
                        _pipeType = PipeType.SanitaryWater;
                    }
                    if (pstName.Contains("冷却"))
                    {
                        _pipeType = PipeType.ChilledWater;
                    }
                    if (pstName.Contains("蒸汽"))
                    {
                        _pipeType = PipeType.Steam;
                    }
                    if (pstName.Contains("消防"))
                    {
                        _pipeType = PipeType.FireSprinkler;
                    }

                    if (_pipeType == PipeType.Unknown)
                    {
                        double temperature = pipingSysType.FluidTemperature - 273.15;
                        if (5 < temperature && temperature < 15)
                        {
                            _pipeType = PipeType.ColdWater;
                        }
                        else if (30 < temperature && temperature < 100)
                        {
                            _pipeType = PipeType.HotWater;
                        }
                        else if (temperature <= 5)
                        {
                            _pipeType = PipeType.ChilledWater;
                        }
                        else if (100 <= temperature)
                        {
                            _pipeType = PipeType.Steam;
                        }
                        else
                        {
                            _abandonWriter.WriteAbandonment(pipe, AbandonmentTable.Pipe_TypeUnknown);
                            return(false);
                        }
                    }
                }
                catch
                {
                    _abandonWriter.WriteAbandonment(pipe, AbandonmentTable.Pipe_TypeUnknown);
                    return(false);
                }
                if (_pipeType != PipeType.ColdWater && !IsValidMaterial(_material))
                {
                    _abandonWriter.WriteAbandonment(_pipe, AbandonmentTable.Pipe_MatlOOR);
                    return(false);
                }

                return(true);
            }