Example #1
0
        public ActionResult PostDetails(Comment comment, ICreateService service, IDetailService serviceDetail)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                return(View(new DetailPostViewModels
                {
                    Comment = comment,
                    DetailPostDto = serviceDetail.GetDetail <DetailPostDto>(comment.PostId).Result
                }));
            }

            var response = service.Create(comment);

            if (response.IsValid)
            {
                TempData["message"] = response.SuccessMessage;
                return(RedirectToAction("PostDetails"));
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, comment);
            return(View(new DetailPostViewModels
            {
                Comment = comment,
                DetailPostDto = serviceDetail.GetDetail <DetailPostDto>(comment.PostId).Result
            }));
        }
Example #2
0
        //20170209 add by liwei1 for P001-170203001 ===end===

        private void InsertMR(DateTime report_datetime, string category, string recommendedOperations, DependencyObjectCollection resultColl, object docId) //20170209 modi by liwei1 for P001-170124001 增加参数:docId
        {
            DataTable dt = QueryForMoReceiptReq(report_datetime, category, recommendedOperations, docId);                                                   //20170209 modi by liwei1 for P001-170124001 增加参数:docId

            ValidateParaFilDoc(dt);                                                                                                                         //20161213 add by shenbao for B001-161213006
            DataTable dt_d = QueryForMoReceipt_D(category, report_datetime, recommendedOperations);

            if (dt.Rows.Count > 0)
            {
                IQueryService    qrySrv      = GetService <IQueryService>();//20170405 add by wangrm for P001-170328001
                ICreateService   createSrv   = GetService <ICreateService>("MO_RECEIPT_REQUISTION");
                DependencyObject entity      = createSrv.Create() as DependencyObject;
                ISaveService     saveService = this.GetService <ISaveService>("MO_RECEIPT_REQUISTION");
                List <IGrouping <object, DataRow> > groupDt          = dt_d.AsEnumerable().GroupBy(a => (a.Field <object>("MO_RECEIPT_REQUISTION_ID"))).ToList();
                IEFNETStatusStatusService           efnetSrv         = this.GetService <IEFNETStatusStatusService>();
                IDocumentNumberGenerateService      docNumberService = this.GetService <IDocumentNumberGenerateService>("MO_RECEIPT_REQUISTION");
                foreach (DataRow dr in dt.Rows)
                {
                    DependencyObject           newEntity      = new DependencyObject(entity.DependencyObjectType);
                    DependencyObjectCollection newEntityDColl = newEntity["MO_RECEIPT_REQUISTION_D"] as DependencyObjectCollection;
                    AddToEntity(newEntity, dr, dt.Columns, false);
                    newEntity["DOC_NO"] = docNumberService.NextNumber(dr["DOC_ID"], dr["DOC_DATE"].ToDate().Date);
                    List <IGrouping <object, DataRow> > entityDColl = groupDt.Where(c => c.Key.Equals(dr["MO_RECEIPT_REQUISTION_ID"])).ToList();
                    foreach (IGrouping <object, DataRow> groupDColl in entityDColl)
                    {
                        foreach (DataRow dr_d in groupDColl)
                        {
                            DependencyObject newEntityD = new DependencyObject(newEntityDColl.ItemDependencyObjectType);
                            AddToEntity(newEntityD, dr_d, dt_d.Columns, true);
                            newEntityDColl.Add(newEntityD);
                        }
                    }
                    //20170428 add by wangyq for P001-170427001  ============begin==========
                    DependencyObject resultObj = resultColl.AddNew();
                    resultObj["doc_no"] = newEntity["DOC_NO"];
                    //20170428 add by wangyq for P001-170427001  ============end==========

                    //20170628 modi by zhangcn for P001-170327001 ===begin===
                    try {
                        SetIgnoreWarningTag();       //忽略警告
                        saveService.Save(newEntity); //希望触发保存校验
                    }
                    finally {
                        ResetIgnoreWarningTag();// 重置警告
                    }
                    //20170628 modi by zhangcn for P001-170327001 ===end===

                    //7.3自动签核
                    efnetSrv.GetFormFlow("MO_RECEIPT_REQUISTION.I01", dr["DOC_ID"], dr["Owner_Org_ROid"],
                                         new List <object>()
                    {
                        dr["MO_RECEIPT_REQUISTION_ID"]
                    });
                }
            }
        }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="counting_type">盘点类型</param>
 /// <param name="site_no">营运据点</param>
 /// <param name="counting_no">盘点计划编号</param>
 /// <param name="scan"></param>
 public void UpdateCountingPlan(string counting_type, string site_no, string counting_no, DependencyObjectCollection scan)
 {
     if (string.IsNullOrEmpty(counting_no))
     {
         IInfoEncodeContainer infoContainer = this.GetService <IInfoEncodeContainer>();
         throw new BusinessRuleException(string.Format(infoContainer.GetMessage("A111201"), "counting_no"));
     }
     using (IConnectionService connectionService = this.GetService <IConnectionService>()) {
         _qurService = this.GetService <IQueryService>();
         CreateTempTable();           //创建临时表
         InsertToScan(site_no, scan); //临时表储存scan入参
         QueryNode queryScan                = QueryScan(counting_no);
         QueryNode querySumNode             = QuerySumForInsert(counting_no, queryScan);
         DependencyObjectCollection sumColl = _qurService.ExecuteDependencyObject(querySumNode);
         List <DependencyObject>    newList = new List <DependencyObject>();
         ISaveService saveService           = this.GetService <ISaveService>("COUNTING");
         if (sumColl.Count > 0)  //查询存在记录新增实体COUNTING
         {
             ICreateService   createSrv = GetService <ICreateService>("COUNTING");
             DependencyObject entity    = createSrv.Create() as DependencyObject;
             newList = InsertCOUNTING(counting_type, counting_no, sumColl, entity.DependencyObjectType);
         }
         ICreateService createSrvParaFil = this.GetService <ICreateService>("PARA_FIL");
         QueryNode      updateNode       = null;
         QueryNode      insertNode       = null;
         if (createSrvParaFil != null)   //表示该typekey存在
         {
             bool bcManagement = GetBcInventoryManagement();
             if (bcManagement)
             {
                 QueryNode querySumBarcodeNode = QuerySumBarcode(counting_no, queryScan);
                 updateNode = GetUpdateNode(counting_type, counting_no, querySumBarcodeNode);
                 insertNode = QueryNodeForInsert(counting_no, counting_type, querySumBarcodeNode);
             }
         }
         using (ITransactionService transActionService = this.GetService <ITransactionService>()) {
             if (newList.Count > 0)
             {
                 SetIgnoreWarningTag(true);
                 saveService.Save(newList.ToArray());
                 SetIgnoreWarningTag(false);
             }
             //更新条码盘点计划
             if (updateNode != null)  //启用条码库存管理更新
             {
                 _qurService.ExecuteNoQueryWithManageProperties(updateNode);
             }
             //新增条码盘点计划
             if (insertNode != null)  //启用条码库存管理更新
             {
                 _qurService.ExecuteNoQueryWithManageProperties(insertNode);
             }
             transActionService.Complete();
         }
     }
 }
Example #4
0
        public Task Create(User user)
        {
            user.Id         = Guid.NewGuid();
            user.CreateDate = DateTime.UtcNow;

            var sql = $"INSERT INTO \"{_tableName}\" " +
                      "(\"Id\", \"FirstName\", \"LastName\", \"Patronymic\", \"CreateDate\") " +
                      "VALUES(@Id, @FirstName, @LastName, @Patronymic, @CreateDate)";

            return(_userCreateService.Create(sql, user));
        }
Example #5
0
        public IActionResult Create([FromBody] ToggleRequest request)
        {
            if (request == null)
            {
                return(BadRequest());
            }

            var response = _createService.Create(request);

            return(CreatedAtRoute("GetToggle", new { id = response.Id }, response));
        }
Example #6
0
        public IActionResult Create(string application, [FromBody] AppOverrideRequest request)
        {
            if (request == null)
            {
                return(BadRequest());
            }

            request.Application = application;
            var newResource = _createService.Create(request);

            return(CreatedAtRoute("GetApplicationOverride", new { toggleId = newResource.ToggleId }, newResource));
        }
Example #7
0
File: Tools.cs Project: Ocun/VSTool
        public void creatTmp(string TypeKey, out DataTable dt, out DependencyObjectType targetType)
        {
            dt         = null;
            targetType = null;
            string[] spiltTypeKeys = null;
            bool     isColls       = false;
            string   primaryKey    = string.Empty;

            if (TypeKey.Contains(@"."))
            {
                spiltTypeKeys = TypeKey.Split(new[] { '.' });
                TypeKey       = spiltTypeKeys[0];
                primaryKey    = spiltTypeKeys[spiltTypeKeys.Length - 2];
                isColls       = true;
            }

            ICreateService createSrv = Provider.GetService(typeof(ICreateService), TypeKey) as ICreateService;

            if (createSrv == null)
            {
                return;
            }
            var entity = createSrv.Create() as DependencyObject;
            DependencyObjectType toType = entity.DependencyObjectType;

            if (isColls && spiltTypeKeys != null)
            {
                spiltTypeKeys.ToList().ForEach(key => {
                    if (!key.Equals(TypeKey))
                    {
                        toType =
                            ((ICollectionProperty)(toType.Properties[key])).ItemDataEntityType as DependencyObjectType;
                    }
                });
            }
            IBusinessTypeService businessTypeSrv =
                Provider.GetService(typeof(IBusinessTypeService), CallContext.TypeKey) as IBusinessTypeService;

            targetType = RegiesterType(toType, targetType);
            if (isColls)
            {
                string primaryKeyName = primaryKey + "_ID";

                targetType.RegisterSimpleProperty(primaryKeyName, businessTypeSrv.SimplePrimaryKeyType,
                                                  null, false, new Attribute[] {
                    businessTypeSrv.SimplePrimaryKey
                });
            }

            dt = CreateDt(targetType, dt);
        }
        public ActionResult Create(Blog blog, ICreateService service)
        {
            if (!ModelState.IsValid)
                //model errors so return immediately
                return View(blog);

            var response = service.Create(blog);
            if (response.IsValid)
            {
                TempData["message"] = response.SuccessMessage;
                return RedirectToAction("Index");
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, blog);
            return View(blog);
        }
        public JsonResult AjaxAddLineItem(CreateLineItemDto newOrder, ICreateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return errors
                return ModelState.ReturnModelErrorsAsJson();
            }

            var response = service.Create(newOrder);
            if (response.IsValid)
            {
                return Json(new { SuccessMessage = response.SuccessMessage });
            }

            //else errors, so send back the errors
            return response.ReturnErrorsAsJson(newOrder);
        }
        public ActionResult Create(CrudCustomerDto customer, ICreateService service)
        {
            if (!ModelState.IsValid)
                //model errors so return immediately
                return View(customer);

            var response = service.Create(customer);
            if (response.IsValid)
            {
                TempData["message"] = response.SuccessMessage + " You must now assign a password to this customer.";
                return RedirectToAction("NotCustomers");
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, customer);
            return View(customer);
        }
        public ActionResult AddAddress(CrudCustomerAddressDto customerAddress, ICreateService service)
        {
            if (!ModelState.IsValid)
                //model errors so return immediately
                return View(customerAddress);

            var response = service.Create(customerAddress);
            if (response.IsValid)
            {
                TempData["message"] = response.SuccessMessage;
                return RedirectToAction("Details", new { id = customerAddress.CustomerID });
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, customerAddress);
            return View(customerAddress);
        }
        /// <summary>
        /// 新增单头
        /// </summary>
        /// <param name="docId"></param>
        /// <param name="sequenceDigit"></param>
        /// <param name="report_datetime"></param>
        /// <param name="stockAction"></param>
        private List <DependencyObject> AddEntity(object docId, int sequenceDigit, DateTime report_datetime, string stockAction)
        {
            ICreateService   createSrv = GetService <ICreateService>("TRANSACTION_DOC");
            DependencyObject entity    = createSrv.Create() as DependencyObject;
            IDocumentNumberGenerateService DocumentNumberGenSrv = this.GetService <IDocumentNumberGenerateService>("TRANSACTION_DOC");
            DependencyObjectCollection     queryScanColl        = QueryForTD();
            DependencyObjectCollection     queryScanDetailColl  = QueryForTD_D(docId);

            string docNo = string.Empty;
            List <DependencyObject> newAddList = new List <DependencyObject>();

            foreach (DependencyObject tdObj in queryScanColl)
            {
                DependencyObject newTD = new DependencyObject(entity.DependencyObjectType);
                newTD["DOC_ID"]   = docId;
                newTD["DOC_DATE"] = report_datetime.Date;
                if (string.IsNullOrEmpty(docNo))
                {
                    docNo = UtilsClass.NextNumber(DocumentNumberGenSrv, "", docId, sequenceDigit, report_datetime.Date);
                }
                else
                {
                    docNo = UtilsClass.NextNumber(DocumentNumberGenSrv, docNo, docId, sequenceDigit, report_datetime.Date);
                }
                newTD["DOC_NO"]           = docNo;
                newTD["TRANSACTION_DATE"] = report_datetime.Date;
                newTD["CATEGORY"]         = "11";
                newTD["STOCK_ACTION"]     = stockAction;
                ((DependencyObject)newTD["Owner_Org"])["RTK"]  = "PLANT";
                ((DependencyObject)newTD["Owner_Org"])["ROid"] = tdObj["PLANT_ID"];
                newTD["Owner_Dept"]         = tdObj["ADMIN_UNIT_ID"];
                newTD["Owner_Emp"]          = tdObj["EMPLOYEE_ID"];
                newTD["TRANSACTION_DOC_ID"] = tdObj["ID"];
                newTD["COMPANY_ID"]         = tdObj["COMPANY_ID"];

                DependencyObjectCollection entityDColl    = newTD["TRANSACTION_DOC_D"] as DependencyObjectCollection;
                List <DependencyObject>    detailScanList = queryScanDetailColl.Where(c => c["info_lot_no"].ToStringExtension() == tdObj["info_lot_no"].ToStringExtension()).ToList();
                if (detailScanList.Count > 0)
                {
                    AddEntity_D(entityDColl, detailScanList);
                }
                newAddList.Add(newTD);
            }
            return(newAddList);
        }
Example #13
0
        public JsonResult AjaxAddLineItem(CreateLineItemDto newOrder, ICreateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return errors
                return(ModelState.ReturnModelErrorsAsJson());
            }

            var response = service.Create(newOrder);

            if (response.IsValid)
            {
                return(Json(new { SuccessMessage = response.SuccessMessage }));
            }

            //else errors, so send back the errors
            return(response.ReturnErrorsAsJson(newOrder));
        }
        public ActionResult Create(CrudCustomerDto customer, ICreateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                return(View(customer));
            }

            var response = service.Create(customer);

            if (response.IsValid)
            {
                TempData["message"] = response.SuccessMessage + " You must now assign a password to this customer.";
                return(RedirectToAction("NotCustomers"));
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, customer);
            return(View(customer));
        }
        public ActionResult AddAddress(CrudCustomerAddressDto customerAddress, ICreateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                return(View(customerAddress));
            }

            var response = service.Create(customerAddress);

            if (response.IsValid)
            {
                TempData["message"] = response.SuccessMessage;
                return(RedirectToAction("Details", new { id = customerAddress.CustomerID }));
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, customerAddress);
            return(View(customerAddress));
        }
Example #16
0
        public ActionResult Create(DetailPostDto dto, ICreateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                return(View(service.ResetDto(dto)));
            }

            var response = service.Create(dto);

            if (response.IsValid)
            {
                TempData["message"] = response.SuccessMessage;
                return(RedirectToAction("Index"));
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, dto);
            return(View(dto));
        }
        public ActionResult Create(User user, ICreateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                return(View(user));
            }

            var response = service.Create(user);

            if (response.IsValid)
            {
                Log.Info($"{user.Mail} ID:{user.UserId} user Created.");
                TempData["message"] = response.SuccessMessage;
                return(RedirectToAction("Index"));
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, user);
            return(View(user));
        }
Example #18
0
        public ActionResult NewOrder(NewOrderDto newOrder, ICreateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                service.ResetDto(newOrder);
                return(View(newOrder));
            }

            var response = service.Create(newOrder);

            if (response.IsValid)
            {
                //no success message as in a process
                return(RedirectToAction("EditLineItems", new { salesOrderId = newOrder.SalesOrderID }));
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, newOrder);
            return(View(newOrder));
        }
Example #19
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private string[] GetParaFIL()
        {
            ICreateService   createService = this.GetService <ICreateService>("PARA_FIL");
            DependencyObject filEntity     = createService.Create() as DependencyObject;

            string[] result = new string[] { string.Empty, string.Empty, string.Empty };
            if (filEntity.DependencyObjectType.Properties.Contains("BARCODE_SYMBOL_FOR_WH_BIN"))
            {
                QueryNode node = OOQL.Select(OOQL.CreateProperty("PARA_FIL.BC_INVENTORY_MANAGEMENT"),
                                             OOQL.CreateProperty("PARA_FIL.BARCODE_SYMBOL_FOR_WH_BIN"),
                                             OOQL.CreateProperty("PARA_FIL.ITEM_FEATURE_CONTROL"))
                                 .From("PARA_FIL", "PARA_FIL")
                                 .Where(OOQL.AuthFilter("PARA_FIL", "PARA_FIL"));
                DependencyObjectCollection filColl = this.GetService <IQueryService>().ExecuteDependencyObject(node);
                foreach (DependencyObject filObj in filColl)
                {
                    result[0] = filObj["BC_INVENTORY_MANAGEMENT"].ToBoolean() ? "Y" : "N";
                    if (string.IsNullOrEmpty(filObj["BARCODE_SYMBOL_FOR_WH_BIN"].ToStringExtension()))
                    {
                        result[1] = "@";
                    }
                    else
                    {
                        result[1] = filObj["BARCODE_SYMBOL_FOR_WH_BIN"].ToStringExtension();
                    }
                    result[2] = filObj["ITEM_FEATURE_CONTROL"].ToBoolean() ? "Y" : "N";
                    break;
                }
            }
            else
            {
                bool isInvertory = UtilsClass.IsBCInventoryManagement(this.GetService <IQueryService>());
                result[0] = isInvertory ? "Y" : "N";
                result[1] = "@";
                result[2] = "Y";
            }
            return(result);
        }
Example #20
0
        public IActionResult Create(CreateViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }
            if (_service.Create(model))
            {
                // 登録成功の場合はメニュー画面へ
                TempData["notification"] = "登録が完了しました。";
                return(RedirectToAction("index", "Menu"));
            }
            else
            {
                // 登録失敗
                model.Notification = "登録に失敗しました";
                return(View("Index", model));
            }
        }
Example #21
0
 public void shouldThrowExceptionOnMissingToggle()
 {
     Assert.Throws <ResourceNotFoundException>(() => victim.Create(buildRequest(20L)));
 }
        public ActionResult NewOrder(NewOrderDto newOrder, ICreateService service)
        {
            if (!ModelState.IsValid)
            {
                //model errors so return immediately
                service.ResetDto(newOrder);
                return View(newOrder);
            }

            var response = service.Create(newOrder);
            if (response.IsValid)
            {
                //no success message as in a process
                return RedirectToAction("EditLineItems", new { salesOrderId = newOrder.SalesOrderID});
            }

            //else errors, so copy the errors over to the ModelState and return to view
            response.CopyErrorsToModelState(ModelState, newOrder);
            return View(newOrder);
        }