Example #1
0
        public void Test1()
        {
            var id   = NumUtil.SnowNum().ToString();
            var time = DateTime.Now.ToUtcSeconds();

            var addRes = UserInfoRep.Instance.Add(new UserInfo()
            {
                id        = id,
                user_name = $"test_name_{id}",
                add_time  = time,
                m_time    = time
            }).Result;

            Assert.True(addRes.IsSuccess());

            var updateRes = UserInfoRep.Instance.UpdateName(id, $"test_update_name{id}").Result;

            Assert.True(updateRes.IsSuccess());


            var getRes = UserInfoRep.Instance.Get(id).Result;

            Assert.True(getRes.IsSuccess());

            var getListRes = UserInfoRep.Instance.GetList().Result;

            Assert.True(getListRes.IsSuccess());
        }
Example #2
0
        public object listAllqrandom(string id)
        {
            var qrandom = _context.TestQRandoms.Include(i => i.SubjectSub).Where(w => 1 == 1);

            var tID = NumUtil.ParseInteger(id);

            if (tID > 0)
            {
                qrandom = qrandom.Where(w => w.TestID == tID);
            }

            return(qrandom.Select(s => new
            {
                id = s.ID,
                questiontype = s.QuestionType.toQuestionTypeMin(),
                questiontypeid = s.QuestionType,
                testid = s.TestID,
                subid = s.SubjectSubID,
                sub = s.SubjectSub.Name,
                veryeasy = s.VeryEasy,
                easy = s.Easy,
                mid = s.Mid,
                hard = s.Hard,
                veryhard = s.VeryHard,
                create_on = DateUtil.ToDisplayDateTime(s.Create_On),
                create_by = s.Create_By,
                update_on = DateUtil.ToDisplayDateTime(s.Update_On),
                update_by = s.Update_By,
            }).OrderBy(o => o.questiontypeid).ThenBy(o => o.sub).ToArray()
                   );
        }
        public async Task <IActionResult> Update(int?id, string tab, string code)
        {
            if (!_loginServices.isInAdminRoles(this.GetRoles()))
            {
                return(RedirectToAction("Login", "Accounts"));
            }
            var model = this._context.Privileges
                        .Include(i => i.Merchant)
                        .Include(i => i.PrivilegeImages)
                        .Include(i => i.Merchant.MerchantCategories)
                        .Include(i => i.PrivilegeCustomerClasses)
                        .Include(i => i.PrivilegeCodes)
                        .Where(w => w.PrivilegeID == id).FirstOrDefault();

            if (model != null)
            {
                if (model.CustomerClassList.Count <= 0)
                {
                    model.PrivilegeCustomerClasses = new List <PrivilegeCustomerClass>();
                }

                int pageno = 1;
                if (this.RouteData.Values["pno"] != null)
                {
                    pageno = NumUtil.ParseInteger(this.RouteData.Values["pno"].ToString());
                    if (pageno == 0)
                    {
                        pageno = 1;
                    }
                }
                var modelcode = new ModelReportBaseDTO();
                modelcode.search_code      = code;
                modelcode.pno              = pageno;
                modelcode.pmax             = 10;
                modelcode.search_privilege = model.PrivilegeID;
                var codes = await _priRepo.ListCode(modelcode);

                ViewBag.ItemCount  = modelcode.totalrow;
                ViewBag.PageLength = (ViewBag.ItemCount / 10);
                if (ViewBag.ItemCount % 10 > 0)
                {
                    ViewBag.PageLength += 1;
                }
                ViewBag.PageNo       = pageno;
                model.PrivilegeCodes = codes;


                //if (model.PrivilegeCodeList.Count <= 0)
                //   model.PrivilegeCodes = new Collection<PrivilegeCode>() { new PrivilegeCode() { Status = StatusType.Active } };

                model.sDate = DateUtil.ToDisplayDate(model.StartDate);
                model.eDate = DateUtil.ToDisplayDate(model.EndDate);
                model.tab   = tab;
            }
            ViewBag.ListMerchant      = this._context.Merchants.Include(i => i.MerchantCategories).OrderBy(o => o.MerchantName);
            ViewBag.ListType          = this._context.MerchantCategories.Where(w => w.Status == StatusType.Active).OrderBy(o => o.Index);
            ViewBag.TotalQuantity     = this._context.Redeems.Where(w => w.PrivilegeID == id).Count();
            ViewBag.ListCustomerClass = this._context.CustomerClasses;
            return(View("PrivilegeInfo", model));
        }
Example #4
0
        /// <summary>
        /// 微盟-更新订单标记(ec/order/updateOrderFlag)
        /// </summary>
        public void UpdateOrderFlagToWm(DateTime startDate, DateTime endDate)
        {
            string preMsg = "微盟 更新订单标记 ";

            string    sql     = @"select a.F_BillStatus, a.F_BillID 
                        from T_OrderLogisticsInformation a ";
            DataTable dtOrder = sd.GetDataTable(sql);

            Log.WriteLog(preMsg + "取得的记录数:" + dtOrder.Rows.Count + "行。", 1);
            if (dtOrder.Rows.Count == 0)
            {
                return;
            }


            foreach (DataRow drDetail in dtOrder.Rows)
            {
                UpdateOrderFlagRequest request = new UpdateOrderFlagRequest();
                request.flagRank    = NumUtil.ToInt(drDetail["F_BillStatus"]);
                request.orderNoList = new List <string> {
                    drDetail["F_BillID"].ToString()
                };
                UpdateOrderFlagResponse response = HttpPostToWm <UpdateOrderFlagResponse>("ec/order/updateOrderFlag", request, preMsg);
            }
        }
Example #5
0
        /// <summary>
        /// 微盟-商品信息-批量上下架(ec/goods/updateGoodsShelfStatus)
        /// </summary>
        public void UpdateGoodsShelfStatusToWm(DateTime startDate, DateTime endDate)
        {
            string preMsg = "微盟 批量上下架 ";

            string sql = @"select a.F_ID, F_GoodsID, F_Stop
                            from v_Item_NoPic a 
                            where a.F_UpdateTime >= '" + startDate.ToString("yyyy-MM-dd HH:mm:ss") + @"'
                              and a.F_UpdateTime < '" + endDate.ToString("yyyy-MM-dd HH:mm:ss") + @"'
                              and a.F_GoodsID is not null ";

            DataTable dtItem = sd.GetDataTable(sql);

            Log.WriteLog(preMsg + "取得的记录数:" + dtItem.Rows.Count + "行。", 1);
            if (dtItem.Rows.Count == 0)
            {
                return;
            }

            foreach (DataRow drItem in dtItem.Rows)
            {
                UpdateGoodsShelfStatusRequest request = new UpdateGoodsShelfStatusRequest();

                List <long> goodsIdList = new List <long>();

                goodsIdList.Add(NumUtil.GetVal_Long(drItem["F_GoodsID"]));
                request.goodsIdList = goodsIdList;
                request.isPutAway   = NumUtil.ToInt(drItem["F_Stop"]);

                UpdateGoodsShelfStatusResponse response = HttpPostToWm <UpdateGoodsShelfStatusResponse>("ec/goods/updateGoodsShelfStatus", request, preMsg);
            }
        }
Example #6
0
        public JsonResult GetDeliveryDetails(string DeliveryID)
        {
            List <CMSDeliveryDetailWModels> SyncDatas = new List <CMSDeliveryDetailWModels>();
            var cmsService  = new CMSService();
            int Delivery_ID = NumUtil.ParseInteger(DeliveryID);
            var cri         = new DeliveryCriteria();

            cri.Delivery_ID = Delivery_ID;
            var result = cmsService.GetCMSDelivery(cri);

            if (result.Code == ReturnCode.SUCCESS)
            {
                var deliverys = result.Object as List <CMS_Delivery>;
                if (deliverys != null && deliverys.Count() == 1)
                {
                    var delivery = deliverys.FirstOrDefault();
                    foreach (var row in delivery.CMS_Delivery_Detail)
                    {
                        var lrow = new CMSDeliveryDetailWModels();
                        lrow.CMS_Delivery_Detail_ID = row.CMS_Delivery_Detail_ID;
                        if (!string.IsNullOrEmpty(row.Product_Code))
                        {
                            lrow.Product_ID   = 1; //remove after improve code in mobile
                            lrow.Product_Code = row.Product_Code;
                            lrow.Product_Name = "";
                        }
                        SyncDatas.Add(lrow);
                    }
                }
            }
            return(Json(SyncDatas, JsonRequestBehavior.AllowGet));
        }
Example #7
0
        public static double CalcAverageMz(Peak peak, int[] indx, double[,] mzCalibrationPar,
                                           double[,] intensityCalibrationPar, double absoluteCalibration)
        {
            if (double.IsNaN(absoluteCalibration))
            {
                absoluteCalibration = 0;
            }
            double norm1 = 0;
            double m     = 0;

            if (mzCalibrationPar == null)
            {
                foreach (int index0 in indx)
                {
                    norm1 += peak.origIntensity[index0];
                    double mz = peak.centerMz[index0];
                    m += peak.origIntensity[index0] * mz;
                }
                m /= norm1;
                return(m);
            }
            foreach (int index0 in indx)
            {
                norm1 += peak.origIntensity[index0];
                double mz = peak.centerMz[index0] * (1 + 1e-6 * NumUtil.RelativeCorrection(peak.centerMz[index0], mzCalibrationPar,
                                                                                           intensityCalibrationPar,
                                                                                           peak.origIntensity[index0],
                                                                                           peak.massRange[index0]) +
                                                     1e-6 * absoluteCalibration);
                m += peak.origIntensity[index0] * mz;
            }
            m /= norm1;
            return(m);
        }
Example #8
0
        public object getsendresultsetup(string group_searh, string subject_search)
        {
            var groupid   = NumUtil.ParseInteger(group_searh);
            var subjectid = NumUtil.ParseInteger(subject_search);
            var setup     = _context.SendResultSetups.Where(w => w.SubjectGroupID == groupid & w.SubjectID == subjectid).Select(s => new
            {
                result      = ResultCode.Success,
                message     = ResultMessage.Success,
                id          = s.ID,
                group       = s.SubjectGroup.Name,
                groupid     = s.SubjectGroupID,
                subject     = s.Subject.Name,
                subjectid   = s.SubjectID,
                other       = s.Other,
                sendbyemail = s.SendByEmail,
                sendbypost  = s.SendByPost,
                description = s.Description,
                create_on   = DateUtil.ToDisplayDateTime(s.Create_On),
                create_by   = s.Create_By,
                update_on   = DateUtil.ToDisplayDateTime(s.Update_On),
                update_by   = s.Update_By,
            }).FirstOrDefault();

            if (setup != null)
            {
                return(setup);
            }
            return(CreatedAtAction(nameof(getsendresultsetup), new { result = ResultCode.DataHasNotFound, message = ResultMessage.DataHasNotFound }));
        }
Example #9
0
        public static double[][] GetIsotopeDistribution(int n, double[] masses, double[] composition)
        {
            int len = masses.Length;

            int[][]  partitions = NumUtil.GetPartitions(n, len);
            double[] ms         = new double[partitions.Length];
            double[] weights    = new double[partitions.Length];
            for (int i = 0; i < partitions.Length; i++)
            {
                weights[i] = 1;
                int[] partition = partitions[i];
                for (int j = 0; j < len; j++)
                {
                    ms[i] += partition[j] * masses[j];
                    for (int k = 0; k < partition[j]; k++)
                    {
                        weights[i] *= composition[j];
                    }
                }
                weights[i] *= NumUtil.Multinomial(n, partition);
            }
            int[] o = ArrayUtil.Order(ms);
            ms      = ArrayUtil.SubArray(ms, o);
            weights = ArrayUtil.SubArray(weights, o);
            double[][] x = FilterWeights(ms, weights, null, 1e-6);
            ms      = x[0];
            weights = x[1];
            x       = FilterMasses(ms, weights, null, 0.2);
            ms      = x[0];
            weights = x[1];
            return(new double[][] { ms, weights });
        }
Example #10
0
        public object listAllqcustom(string id)
        {
            var qcustom = _context.TestQCustoms.Include(i => i.Question).Where(w => 1 == 1);

            var tID = NumUtil.ParseInteger(id);

            if (tID > 0)
            {
                qcustom = qcustom.Where(w => w.TestID == tID);
            }

            var questioncnt = qcustom.Where(w => w.Question.QuestionType != QuestionType.ReadingText && w.Question.QuestionType != QuestionType.MultipleMatching).Count();

            questioncnt += _context.Questions.Where(w => w.QuestionParentID.HasValue && qcustom.Select(s => s.Question.ID).Contains(w.QuestionParentID.Value)).Count();
            return(CreatedAtAction(nameof(listAlltest), new
            {
                data = qcustom.Select(s => new
                {
                    id = s.ID,
                    testid = s.TestID,
                    order = s.Order,
                    questionid = s.QuestionID,
                    questionth = s.Question.QuestionTh,
                    questionen = s.Question.QuestionEn,
                    questionlevel = s.Question.QuestionLevel.toQuestionLevelName(),
                    questiontype = s.Question.QuestionType.toQuestionTypeMin2(),
                    childcnt = _context.Questions.Where(w => w.QuestionParentID == s.QuestionID).Count(),
                    create_on = DateUtil.ToDisplayDateTime(s.Create_On),
                    create_by = s.Create_By,
                    update_on = DateUtil.ToDisplayDateTime(s.Update_On),
                    update_by = s.Update_By,
                }).OrderBy(o => o.order).ToArray(),
                questioncnt = questioncnt,
            }));
        }
        public IActionResult Index(PointConditionDTO model)
        {
            if (!_loginServices.isInAdminRoles(this.GetRoles()))
            {
                return(RedirectToAction("Login", "Accounts"));
            }

            int pageno = 1;

            if (this.RouteData.Values["pno"] != null)
            {
                pageno = NumUtil.ParseInteger(this.RouteData.Values["pno"].ToString());
                if (pageno == 0)
                {
                    pageno = 1;
                }
            }
            int skipRows = (pageno - 1) * 100;

            model.PointConditions = this._context.PointConditions
                                    .Include(s => s.PointConditionProducts)
                                    .OrderBy(c => c.TransacionTypeID).ThenBy(o => o.OutletCode).ThenBy(o => o.ConditionCode);


            ViewBag.ItemCount  = model.PointConditions.Count();
            ViewBag.PageLength = (ViewBag.ItemCount / 100);
            if (ViewBag.ItemCount % 100 > 0)
            {
                ViewBag.PageLength += 1;
            }
            ViewBag.PageNo        = pageno;
            model.PointConditions = model.PointConditions.Skip(skipRows).Take(100);

            return(View("Condition", model));
        }
Example #12
0
    /// <summary>
    /// 一个文件下载完成,更新通知当前文件下载完毕,包括更新下载进度等
    /// </summary>
    /// <param name="vf"></param>
    public void DownFileFinish(VFStruct vf)
    {
        string tts = NumUtil.GetFormatFileSize(totalSize);

        currentSize += vf.size;
        string crs = NumUtil.GetFormatFileSize(currentSize);

        Debug.Log("下载中:" + crs + "/" + tts);
    }
Example #13
0
 public long Add(ActionInfo model)
 {
     model.Id = NumUtil.SnowNum();
     if (_ActionInfoRepository.Add(model) > 0)
     {
         return(model.Id);
     }
     return(0);
 }
Example #14
0
 protected static void SetBaseInfo <T>(T t)
     where T : BaseMo
 {
     if (t.id == 0)
     {
         t.id = NumUtil.SubTimeNum(MemberShiper.Identity.Id);
     }
     t.create_time = DateTime.Now.ToUtcSeconds();
 }
Example #15
0
 public static HexFacing Apply(this HexFacing facing, HexRotation rot)
 {
     if (facing == HexFacing.bad)
     {
         return(HexFacing.bad);
     }
     else
     {
         return((HexFacing)NumUtil.WrapPos((int)facing - rot.CWcount, 6));
     }
 }
Example #16
0
        public HexCoords LerpTo(HexCoords other, float t)
        {
            const float eX = 1E-6F;
            const float eY = 2E-6F;
            const float eZ = -3E-6F;

            return(Round(
                       NumUtil.Lerp(x + eX, other.x + eX, t),
                       NumUtil.Lerp(y + eY, other.y + eY, t),
                       NumUtil.Lerp(z + eZ, other.z + eZ, t)));
        }
Example #17
0
        public static MvcHtmlString AppTextboxDecimal(this HtmlHelper htmlHelper, string name, object value, object htmlAttributes)
        {
            if (value != null)
            {
                if (NumUtil.IsNumeric(value))
                {
                    value = NumUtil.ParseDecimal(value.ToString());
                }
            }

            return(AppText(htmlHelper, new RenderTextboxDecimal(), name, value, htmlAttributes));
        }
        public IActionResult Index(PrivilegeDTO model)
        {
            if (!_loginServices.isInAdminRoles(this.GetRoles()))
            {
                return(RedirectToAction("Login", "Accounts"));
            }

            int pageno = 1;

            if (this.RouteData.Values["pno"] != null)
            {
                pageno = NumUtil.ParseInteger(this.RouteData.Values["pno"].ToString());
                if (pageno == 0)
                {
                    pageno = 1;
                }
            }
            int skipRows = (pageno - 1) * 25;

            model.Privileges = this._context.Privileges
                               .Include(s => s.Merchant)
                               .Include(s => s.MerchantCategory)
                               .Include(s => s.Redeems)
                               .OrderBy(c => c.Index).ThenByDescending(o => o.PrivilegeID);

            if (model.CategoryID.HasValue)
            {
                model.Privileges = model.Privileges.Where(w => w.CategoryID == model.CategoryID);
            }
            if (!string.IsNullOrEmpty(model.search_text))
            {
                var text = model.search_text.ToLower();
                model.Privileges = model.Privileges
                                   .Where(c => (!string.IsNullOrEmpty(c.PrivilegeName) && c.PrivilegeName.ToLower().Contains(text))
                                          | (!string.IsNullOrEmpty(c.Merchant.MerchantName) && c.Merchant.MerchantName.ToLower().Contains(text))
                                          | (!string.IsNullOrEmpty(c.Allowable_Outlet) && c.Allowable_Outlet.ToLower().Contains(text))
                                          | (!string.IsNullOrEmpty(c.PrivilegeCondition) && c.PrivilegeCondition.ToLower().Contains(text))
                                          | (!string.IsNullOrEmpty(c.PrivilegeDesc) && c.PrivilegeDesc.ToLower().Contains(text))
                                          );
            }

            ViewBag.ItemCount  = model.Privileges.Count();
            ViewBag.PageLength = (ViewBag.ItemCount / 25);
            if (ViewBag.ItemCount % 25 > 0)
            {
                ViewBag.PageLength += 1;
            }
            ViewBag.PageNo          = pageno;
            model.Privileges        = model.Privileges.Skip(skipRows).Take(25);
            model.MerchantCategorys = this._context.MerchantCategories.Where(w => w.Status == StatusType.Active).OrderBy(o => o.Index);
            return(View("Privilege", model));
        }
Example #19
0
        public ActionResult GlobalLookup(GlobalLookupViewModel model, ServiceResult msgresult)
        {
            var uService = new UserService(User.Identity.GetUserId());
            var prole    = uService.ValidatePageRole(User.Identity.GetUserId(), Page_Code.P0014);

            if (prole == null)
            {
                return(RedirectToAction("ErrorPage", "Account", new ErrorViewModel()
                {
                    Message = Resource.Message_Access_Denied
                }));
            }
            if (prole.View == null || prole.View == false)
            {
                return(RedirectToAction("ErrorPage", "Account", new ErrorViewModel()
                {
                    Message = Resource.Message_Access_Denied
                }));
            }

            ModelState.Clear();
            if (model.operation == Operation.D)
            {
                return(GlobalLookup(model));
            }

            model.result = msgresult;
            model.Modify = prole.Modify;
            model.View   = prole.View;

            var cService = new ComboService();

            model.cGlobalDefList = cService.LstLookupDef();
            if (model.cGlobalDefList.Count > 0 && !model.search_Def_ID.HasValue)
            {
                model.search_Def_ID = NumUtil.ParseInteger(model.cGlobalDefList[0].Value);
            }

            if (model.search_Def_ID.HasValue)
            {
                var gService = new GlobalLookupService();
                var cri      = new GlobalLookupCriteria();
                cri.Def_ID = model.search_Def_ID;
                var result = gService.GetGlobalLookupData(cri);
                if (result.Code == ReturnCode.SUCCESS)
                {
                    model.GlobalDataList = result.Object as List <Global_Lookup_Data>;
                }
            }
            return(View(model));
        }
Example #20
0
        public object listAllsubject(string text_search, string status_search, string group_search)
        {
            var subject = _context.Subjects.Include(i => i.SubjectGroup).Where(w => 1 == 1);

            if (!string.IsNullOrEmpty(status_search))
            {
                subject = subject.Where(w => w.Status == status_search.toStatus());
            }
            if (!string.IsNullOrEmpty(group_search))
            {
                var groupID = NumUtil.ParseInteger(group_search);
                if (groupID > 0)
                {
                    subject = subject.Where(w => w.SubjectGroupID == groupID);
                }
            }
            var subjects = new List <Subject>();

            if (!string.IsNullOrEmpty(text_search))
            {
                var text_splits = text_search.Split(",", StringSplitOptions.RemoveEmptyEntries);
                foreach (var text_split in text_splits)
                {
                    if (!string.IsNullOrEmpty(text_split))
                    {
                        var text = text_split.Trim();
                        subjects.AddRange(subject.Where(w => w.Name.Contains(text)));
                    }
                }
                subjects = subjects.Distinct().ToList();
            }
            else
            {
                subjects = subject.ToList();
            }


            return(subjects.Select(s => new
            {
                id = s.ID,
                name = s.Name,
                description = s.Description,
                order = s.Order,
                status = s.Status.toStatusName(),
                group = s.SubjectGroup.Name,
                create_on = DateUtil.ToDisplayDateTime(s.Create_On),
                create_by = s.Create_By,
                update_on = DateUtil.ToDisplayDateTime(s.Update_On),
                update_by = s.Update_By,
            }).OrderBy(o => o.group).ThenBy(o2 => o2.order).ToArray());
        }
        public object listlog(string student_search, string from_search, string to_search, int pageno = 1)
        {
            var id   = NumUtil.ParseInteger(student_search);
            var logs = _context.LoginStudentHistorys.Include(i => i.Student).Where(w => 1 == 1);

            if (id > 0)
            {
                logs = logs.Where(w => w.StudentID == id);
            }

            if (!string.IsNullOrEmpty(from_search))
            {
                var date = DateUtil.ToDate(from_search).Value.Date;
                logs = logs.Where(w => w.Update_On.Value.Date >= date);
            }
            if (!string.IsNullOrEmpty(to_search))
            {
                var date = DateUtil.ToDate(to_search).Value.Date;
                logs = logs.Where(w => w.Update_On.Value.Date <= date);
            }

            int skipRows = (pageno - 1) * 25;
            var itemcnt  = logs.Count();
            var pagelen  = itemcnt / 25;

            if (itemcnt % 25 > 0)
            {
                pagelen += 1;
            }

            return(CreatedAtAction(nameof(listlog), new
            {
                data = logs.Select(s => new
                {
                    id = s.ID,
                    prefix = s.Student.Prefix.toPrefixName(),
                    firstname = s.Student.FirstName,
                    lastname = s.Student.LastName,
                    firstnameen = s.Student.FirstNameEn,
                    lastnameen = s.Student.LastNameEn,
                    authtype = s.AuthType.toAuthType(),
                    create_on = DateUtil.ToDisplayDateTime(s.Create_On),
                    create_by = s.Create_By,
                    update_on = DateUtil.ToDisplayDateTime(s.Update_On),
                    update_by = s.Update_By,
                    date = s.Update_On,
                }).OrderByDescending(o => o.date).Skip(skipRows).Take(25).ToArray(),
                pagelen = pagelen,
                itemcnt = itemcnt,
            }));;
        }
Example #22
0
        private static MvcHtmlString AppTextboxDecimalFor <TModel, TProperty>(HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, int colspan, object htmlAttributes)
        {
            ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);

            if (metadata.Model != null)
            {
                if (NumUtil.IsNumeric(metadata.Model))
                {
                    metadata.Model = NumUtil.FormatCurrency(NumUtil.ParseDecimal(metadata.Model.ToString()), false);
                }
            }

            return(AppTextFor(htmlHelper, expression, new RenderTextboxDecimal(), colspan, htmlAttributes));
        }
Example #23
0
        /// <summary>
        /// 发网>创建出入库单接口;采购入库、调拨出库
        /// </summary>
        public void AddOutInToFw(DateTime startDate, DateTime endDate)
        {
            string preMsg = "发网 创建出入库单 ";

            string sql = @"select a.F_ShopID, a.F_Billid, a.F_Remark
                            from t_StockOrder a 
                            where a.F_CreateTime >= '" + startDate.ToString("yyyy-MM-dd HH:mm:ss") + @"'
                              and a.F_CreateTime < '" + endDate.ToString("yyyy-MM-dd HH:mm:ss") + "'";

            DataTable dtStockOrder = sd.GetDataTable(sql);

            Log.WriteLog(preMsg + "取得的记录数:" + dtStockOrder.Rows.Count + "行。", 1);
            if (dtStockOrder.Rows.Count == 0)
            {
                return;
            }

            foreach (DataRow drStockOrder in dtStockOrder.Rows)
            {
                FwPurchaseOutinorderAddRequest   request  = new FwPurchaseOutinorderAddRequest();
                WmsPurchaseOutinorderAddResponse response = new WmsPurchaseOutinorderAddResponse();
                request.ActionType    = "IN";
                request.WareHouseCode = drStockOrder["F_ShopID"].ToString();
                request.SyncId        = drStockOrder["F_Billid"].ToString();
                request.Remark        = drStockOrder["F_Remark"].ToString();
                List <FwPurchaseOutinorderAddRequest.Item> products = new List <FwPurchaseOutinorderAddRequest.Item>();

                DataTable dtDetail = sd.GetDataTable("select b.F_BarCode, a.F_Order, a.F_Qty, a.F_Price  from t_StockOrderDetail a " +
                                                     "  left join v_Item_NoPic b on a.F_ItemID = b.F_ID and a.F_ColorID = b.F_ColorID and a.F_SizeID = b.F_SizeID" +
                                                     " where F_Billid = '" + drStockOrder["F_Billid"] + "'");
                foreach (DataRow drDetail in dtDetail.Rows)
                {
                    products.Add(new FwPurchaseOutinorderAddRequest.Item()
                    {
                        BarCode       = drDetail["F_BarCode"].ToString(),
                        InventoryType = "NORMAL",
                        Quantity      = (int)NumUtil.ToDouble(drDetail["F_Qty"]),
                        LineNo        = StrUtil.ConvToStr(drDetail["F_Order"]),
                        UnitPrice     = NumUtil.ToDouble(drDetail["F_Price"]),
                        TotalPrice    = NumUtil.ToDouble(drDetail["F_Price"]) * NumUtil.ToDouble(drDetail["F_Qty"])
                    });
                }

                request.Items = products;
                response      = HttpPostToFw <WmsPurchaseOutinorderAddResponse>(request, preMsg);
            }

            Log.WriteLog(preMsg + "完成。" + startDate.ToString("yyyy-MM-dd HH:mm:ss") + " ~ " + endDate.ToString("yyyy-MM-dd HH:mm:ss"), 1);
        }
Example #24
0
        /// <summary>
        /// 发网>商品信息
        /// </summary>
        public void AddProductToFw(DateTime startDate, DateTime endDate)
        {
            string preMsg = "发网 商品信息 ";

            string sql = @"select a.F_BarCode, a.F_ID, a.F_Name, a.F_Unit, a.F_Safe, a.F_Spec
                            from v_Item_NoPic a 
                            where a.F_CreaterDate >= '" + startDate.ToString("yyyy-MM-dd HH:mm:ss") + @"'
                              and a.F_CreaterDate < '" + endDate.ToString("yyyy-MM-dd HH:mm:ss") + "'";

            DataTable dtItem = sd.GetDataTable(sql);

            Log.WriteLog(preMsg + "取得的记录数:" + dtItem.Rows.Count + "行。", 1);
            if (dtItem.Rows.Count == 0)
            {
                return;
            }

            WmsProductsSyncRequest             request  = new WmsProductsSyncRequest();
            WmsProductsSyncResponse            response = new WmsProductsSyncResponse();
            List <WmsProductsSyncRequest.Item> products = new List <WmsProductsSyncRequest.Item>();

            for (int i = 0; i < dtItem.Rows.Count; i++)
            {
                products.Add(new WmsProductsSyncRequest.Item()
                {
                    BarCode            = StrUtil.ConvToStr(dtItem.Rows[i]["F_BarCode"]),
                    ItemCode           = StrUtil.ConvToStr(dtItem.Rows[i]["F_ID"]),
                    ActionType         = "ADD",
                    ItemName           = StrUtil.ConvToStr(dtItem.Rows[i]["F_Name"]),
                    Unit               = StrUtil.ConvToStr(dtItem.Rows[i]["F_Unit"]),
                    AlterStorageAmount = NumUtil.ToInt(dtItem.Rows[i]["F_Safe"]),
                    PackageSpec        = StrUtil.ConvToStr(dtItem.Rows[i]["F_Spec"])
                });

                if (products.Count == 100)
                {
                    request.Items = products;
                    response      = HttpPostToFw <WmsProductsSyncResponse>(request, preMsg);
                    products.Clear();
                }
            }
            if (products.Count > 0)
            {
                request.Items = products;
                response      = HttpPostToFw <WmsProductsSyncResponse>(request, preMsg);
            }
            Log.WriteLog(preMsg + "完成。" + startDate.ToString("yyyy-MM-dd HH:mm:ss") + " ~ " + endDate.ToString("yyyy-MM-dd HH:mm:ss"), 1);
        }
Example #25
0
        public object chooseqcustom(string choose, string tid, string update_by)
        {
            if (choose == null)
            {
                return(CreatedAtAction(nameof(chooseqcustom), new { result = ResultCode.Success, message = ResultMessage.Success }));
            }

            var chs = choose.Split(";", StringSplitOptions.RemoveEmptyEntries);

            foreach (var ch in chs)
            {
                if (!string.IsNullOrEmpty(ch))
                {
                    var qid      = NumUtil.ParseInteger(ch);
                    var tqcustom = new TestQCustom();
                    tqcustom.QuestionID = qid;
                    tqcustom.TestID     = NumUtil.ParseInteger(tid);
                    tqcustom.Create_On  = DateUtil.Now();
                    tqcustom.Update_On  = DateUtil.Now();
                    tqcustom.Update_By  = update_by;
                    tqcustom.Create_By  = update_by;
                    _context.TestQCustoms.Add(tqcustom);
                }
            }
            _context.SaveChanges();
            var testID    = NumUtil.ParseInteger(tid);
            var i         = 1;
            var questions = _context.TestQCustoms.Where(w => w.TestID == testID).OrderBy(w => w.QuestionID);

            foreach (var q in questions)
            {
                q.Update_On = DateUtil.Now();
                q.Update_By = update_by;
                q.Order     = i;
                i++;
            }
            var test = _context.Tests.Where(w => w.ID == testID).FirstOrDefault();

            if (test != null)
            {
                test.Update_On   = DateUtil.Now();
                test.Update_By   = update_by;
                test.QuestionCnt = i - 1;
            }

            _context.SaveChanges();
            return(CreatedAtAction(nameof(chooseqcustom), new { result = ResultCode.Success, message = ResultMessage.Success }));
        }
Example #26
0
        public void TestMethod1()
        {
            var snowStr1 = NumUtil.SnowNum();
            var snowStr2 = NumUtil.SnowNum();

            Assert.IsTrue(snowStr2 != snowStr1);

            var timeNum1 = NumUtil.TimeMilliNum();
            var timeNum2 = NumUtil.TimeMilliNum() + 1;

            Assert.IsTrue(timeNum1 != timeNum2);

            var subTimeNum = NumUtil.SubTimeNum(timeNum1);

            Assert.IsTrue(timeNum1 % 10000 == subTimeNum % 10000);
        }
        public IActionResult Index(MerchantDTO model)
        {
            //var Cookies = Request.Cookies;
            if (!_loginServices.isInAdminRoles(this.GetRoles()))
            {
                return(RedirectToAction("Login", "Accounts"));
            }
            int pageno = 1;

            if (this.RouteData.Values["pno"] != null)
            {
                pageno = NumUtil.ParseInteger(this.RouteData.Values["pno"].ToString());
                if (pageno == 0)
                {
                    pageno = 1;
                }
            }
            int skipRows = (pageno - 1) * 25;


            model.Merchants = this._context.Merchants.OrderBy(c => c.MerchantName);
            if (model.CategoryID.HasValue)
            {
                model.Merchants = model.Merchants.Where(w => w.CategoryID == model.CategoryID);
            }

            if (!string.IsNullOrEmpty(model.search_text))
            {
                var text = model.search_text.ToLower();
                model.Merchants = model.Merchants
                                  .Where(c => (!string.IsNullOrEmpty(c.MerchantName) && c.MerchantName.ToLower().Contains(text))
                                         );
            }

            ViewBag.ItemCount  = model.Merchants.Count();
            ViewBag.PageLength = (ViewBag.ItemCount / 25);
            if (ViewBag.ItemCount % 25 > 0)
            {
                ViewBag.PageLength += 1;
            }
            ViewBag.PageNo          = pageno;
            model.Merchants         = model.Merchants.Skip(skipRows).Take(25);
            model.MerchantCategorys = this._context.MerchantCategories.Where(w => w.Status == StatusType.Active).OrderBy(o => o.Index);
            return(View("Merchant", model));
        }
Example #28
0
        private static int[][] GetPartitions(int maxNum, int nLabels)
        {
            int[][] p = NumUtil.GetPartitions(maxNum, nLabels + 1);
            for (int i = 0; i < p.Length; i++)
            {
                p[i] = ArrayUtil.SubArray(p[i], nLabels);
            }
            List <int[]> result = new List <int[]>();

            for (int i = 0; i < p.Length; i++)
            {
                if (ArrayUtil.Sum(p[i]) > 0)
                {
                    result.Add(p[i]);
                }
            }
            return(result.ToArray());
        }
Example #29
0
        public JsonResult SyncDownDeliveryByRecord(string DeliveryID)
        {
            var SyncData   = new CMSDeliveryWModels();
            var cmsService = new MobileService();
            var cri        = new MobileCri();

            cri.Delivery_ID        = NumUtil.ParseInteger(DeliveryID);
            cri.Sync_Not_Completed = true;
            cri.Is_Active          = true;
            var result = cmsService.GetCMSDelivery(cri);

            if (result.Code == ReturnCode.SUCCESS)
            {
                var DOlist = result.Object as List <CMS_Delivery>;
                if (DOlist != null && DOlist.Count > 0)
                {
                    var d = DOlist.FirstOrDefault();
                    if (d != null)
                    {
                        SyncData.Delivery_ID       = d.Delivery_ID;
                        SyncData.Delivery_Order_No = d.Delivery_Order_No;
                        SyncData.Update_On         = DateUtil.ToDisplayDateTime(d.Update_On);
                        SyncData.Record_Status     = d.Record_Status;
                        List <CMSDeliveryDetailWModels> details = new List <CMSDeliveryDetailWModels>();
                        foreach (var row2 in d.CMS_Delivery_Detail as List <CMS_Delivery_Detail> )
                        {
                            var detail = new CMSDeliveryDetailWModels();
                            detail.CMS_Delivery_Detail_ID = row2.CMS_Delivery_Detail_ID;
                            if (!string.IsNullOrEmpty(row2.Product_Code))
                            {
                                detail.Product_ID   = 1; //remove after improve code in mobile
                                detail.Product_Code = row2.Product_Code.Trim();
                                detail.Product_Name = "";
                            }
                            detail.No_Of_Containers = row2.No_Of_Containers.HasValue ? row2.No_Of_Containers.Value : 1;
                            details.Add(detail);
                        }
                        SyncData.DeliveryDetail = details;
                    }
                }
            }
            return(Json(SyncData, JsonRequestBehavior.AllowGet));
        }
Example #30
0
        public object uploadwalkin([FromBody] JsonElement json)
        {
            var model = JsonConvert.DeserializeObject <ChooseDTO>(json.GetRawText());

            var examidint = NumUtil.ParseInteger(model.examid);

            var chs = model.choose.Split(";");

            foreach (var ch in chs)
            {
                if (!string.IsNullOrEmpty(ch))
                {
                    var studentid = NumUtil.ParseInteger(ch);

                    var reged = _context.ExamRegisters.Where(w => w.StudentID == studentid & w.ExamID == examidint).FirstOrDefault();
                    if (reged == null)
                    {
                        var register = new ExamRegister();
                        register.StudentID        = studentid;
                        register.ExamID           = NumUtil.ParseInteger(model.examid);
                        register.ExamRegisterType = ExamRegisterType.WalkIn;
                        register.Create_On        = DateUtil.Now();
                        register.Update_On        = DateUtil.Now();
                        register.Create_By        = model.update_by;
                        register.Update_By        = model.update_by;
                        _context.ExamRegisters.Add(register);
                    }
                }
            }
            _context.SaveChanges();
            var exam = _context.Exams.Where(w => w.ID == examidint).FirstOrDefault();

            if (exam != null)
            {
                exam.RegisterCnt = _context.ExamRegisters.Where(w => w.ExamID == examidint).Count();
                exam.Update_On   = DateUtil.Now();
                exam.Update_By   = model.update_by;
                _context.SaveChanges();
                return(CreatedAtAction(nameof(upload), new { result = ResultCode.Success, message = ResultMessage.Success, registercnt = exam.RegisterCnt }));
            }
            return(CreatedAtAction(nameof(uploadwalkin), new { result = ResultCode.Success, message = ResultMessage.Success }));
        }