Example #1
0
        public ResResultModel SaveMesOrder(MesOrderModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, ""));
                }
                var bll      = new MesOrder();
                var effect   = 0;
                var oldModel = bll.GetModel(model.OBarcode, model.PBarcode, model.PdBarcode, model.PtBarcode);
                if (oldModel != null)
                {
                    oldModel.Qty += model.Qty;
                    effect        = bll.Update(oldModel);
                }
                else
                {
                    var currTime  = DateTime.Now;
                    var modelInfo = new MesOrderInfo(Guid.Empty, WebCommon.GetUserId(), model.OBarcode, model.PBarcode, model.PdBarcode, model.PtBarcode, model.Qty, currTime, currTime, 0, "", currTime);
                    effect = bll.Insert(modelInfo);
                }

                return(ResResult.Response(true, MC.M_Save_Ok, ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #2
0
        private void UploadSitePicture(HttpContext context, string funType)
        {
            HttpFileCollection files = context.Request.Files;

            if (files.Count == 0)
            {
                context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}");
                return;
            }

            var          userId = WebCommon.GetUserId();
            int          effect = 0;
            ImagesHelper ih     = new ImagesHelper();

            using (TransactionScope scope = new TransactionScope())
            {
                foreach (string item in files.AllKeys)
                {
                    HttpPostedFile file = files[item];
                    if (file == null || file.ContentLength == 0)
                    {
                        continue;
                    }

                    int fileSize       = file.ContentLength;
                    int uploadFileSize = int.Parse(WebConfigurationManager.AppSettings["UploadFileSize"]);
                    if (fileSize > uploadFileSize)
                    {
                        throw new ArgumentException("文件【" + file.FileName + "】大小超出字节" + uploadFileSize + ",无法上传,请正确操作!");
                    }
                    if (!UploadFilesHelper.IsFileValidated(file.InputStream, fileSize))
                    {
                        throw new ArgumentException("文件【" + file.FileName + "】为受限制的文件,请正确操作!");
                    }

                    //string fileName = file.FileName;
                    var bll = new SitePicture();
                    //if (bll.IsExist(userId, file.FileName, fileSize)) throw new ArgumentException("文件【" + file.FileName + "】已存在,请勿重复上传!");

                    string originalUrl = UploadFilesHelper.UploadOriginalFile(file, "SitePicture");

                    var model = new SitePictureInfo(Guid.Empty, userId, VirtualPathUtility.GetFileName(originalUrl), fileSize, VirtualPathUtility.GetExtension(originalUrl).ToLower(), VirtualPathUtility.GetDirectory(originalUrl.Replace("~", "")), Path.GetFileNameWithoutExtension(context.Server.MapPath(originalUrl)), funType, DateTime.Now);
                    CreateThumbnailImage(context, ih, context.Server.MapPath(originalUrl));

                    bll.Insert(model);
                    effect++;
                }

                scope.Complete();
            }

            if (effect > 0)
            {
                context.Response.Write("{\"success\": true,\"message\": \"已成功上传文件数:" + effect + "个\"}");
            }
            else
            {
                context.Response.Write("{\"success\": false,\"message\": \"上传失败,请检查!\"}");
            }
        }
Example #3
0
        public ResResultModel SavePandianDown(PdaPandianFmModel model)
        {
            try
            {
                var userId = WebCommon.GetUserId();
                if (userId.Equals(Guid.Empty))
                {
                    return(ResResult.Response((int)ResCode.未登录, MC.Login_NotExist, ""));
                }

                var gId = Guid.Empty;
                if (!Guid.TryParse(model.Id.ToString(), out gId))
                {
                    return(ResResult.Response(false, "参数不正确", ""));
                }

                var bll = new Pandian();
                if (bll.UpdateIsDown(gId) < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, ""));
                }

                return(ResResult.Response(true, MC.M_Save_Ok, ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #4
0
        public ResResultModel SaveContentType(ContentTypeFmModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                if (string.IsNullOrWhiteSpace(model.Named) || string.IsNullOrWhiteSpace(model.AppCode))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                var Id       = Guid.Empty;
                var parentId = Guid.Empty;
                if (model.Id != null && !string.IsNullOrWhiteSpace(model.Id.ToString()))
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                if (model.ParentId != null && !string.IsNullOrWhiteSpace(model.ParentId.ToString()))
                {
                    Guid.TryParse(model.ParentId.ToString(), out parentId);
                }
                var openness = (byte)EnumData.Openness.完全公开;
                var currTime = DateTime.Now;
                var bll      = new ContentType();
                int effect   = 0;

                if (bll.IsExistCode(model.Coded, Id))
                {
                    return(ResResult.Response(false, MC.GetString(MC.Params_CodeExistError, model.Coded), Id));
                }

                var modelInfo = new ContentTypeInfo(model.AppCode, Id, WebCommon.GetUserId(), model.Coded, model.Named, parentId, model.Step.Trim(','), model.FlagName, openness, model.Sort, model.Remark, currTime, currTime);
                if (modelInfo.Id.Equals(Guid.Empty))
                {
                    MenusDataProxy.ValidateAccess((int)EnumData.OperationAccess.新增, true);
                    modelInfo.Id   = Guid.NewGuid();
                    modelInfo.Step = modelInfo.Id.ToString() + "," + modelInfo.Step;
                    effect         = bll.InsertByOutput(modelInfo);
                }
                else
                {
                    MenusDataProxy.ValidateAccess((int)EnumData.OperationAccess.编辑, true);
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, null));
                }

                return(ResResult.Response(true, MC.M_Save_Ok, modelInfo.Id));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, null));
            }
        }
Example #5
0
        public ResResultModel GetPandianList(PdaPandianModel model)
        {
            try
            {
                var userId = WebCommon.GetUserId();
                if (userId.Equals(Guid.Empty))
                {
                    return(ResResult.Response((int)ResCode.未登录, MC.Login_NotExist, ""));
                }

                if (model.PageIndex < 1)
                {
                    model.PageIndex = 1;
                }
                if (model.PageSize < 10)
                {
                    model.PageSize = 10;
                }
                int totalRecord = 0;

                var sqlWhere = new StringBuilder(300);
                var parms    = new ParamsHelper();

                Auth.CreateSearchItem(ref sqlWhere, ref parms, new string[] { "pd.DepmtId" });

                sqlWhere.AppendFormat("and pd.Status < {0} ", (int)EnumPandianStatus.已完成);

                if (model.PandianId != null)
                {
                    var pandianId = Guid.Empty;
                    Guid.TryParse(model.PandianId.ToString(), out pandianId);
                    if (!pandianId.Equals(Guid.Empty))
                    {
                        sqlWhere.Append("and Id = @PandianId ");
                        var parm = new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier);
                        parm.Value = pandianId;
                        parms.Add(parm);
                    }
                }

                var bll = new Pandian();

                var list = bll.GetListByJoin(model.PageIndex, model.PageSize, out totalRecord, sqlWhere.ToString(), parms.ToArray());
                if (totalRecord == 0)
                {
                    return(ResResult.Response(true, "", "{\"total\":0,\"rows\":[]}"));
                }

                var dgData = "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + "}";
                return(ResResult.Response(true, "", dgData));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #6
0
        public ResResultModel GetPandianAssetList(PdaPandianAssetModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, ""));
                }

                var userId = WebCommon.GetUserId();
                if (model.PageIndex < 1)
                {
                    model.PageIndex = 1;
                }
                if (model.PageSize < 10)
                {
                    model.PageSize = 10;
                }
                int totalRecord = 0;

                var pandianId = Guid.Empty;
                if (model.PandianId != null)
                {
                    Guid.TryParse(model.PandianId.ToString(), out pandianId);
                }

                var          sqlWhere = new StringBuilder(300);
                var          parms    = new ParamsHelper();
                SqlParameter parm     = null;

                sqlWhere.AppendFormat("and pda.Status = {0} ", (int)EnumPandianAssetStatus.未盘点);
                if (!pandianId.Equals(Guid.Empty))
                {
                    sqlWhere.Append("and PandianId = @PandianId ");
                    parm       = new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier);
                    parm.Value = pandianId;
                    parms.Add(parm);
                }

                var bll  = new PandianAsset();
                var list = bll.GetListByJoin(model.PageIndex, model.PageSize, out totalRecord, sqlWhere.ToString(), parms.ToArray());

                var totals = bll.GetTotal(pandianId);

                var dgData = "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + ",\"footer\":[{\"TotalPan\":" + totals[0] + ",\"TotalYpan\":" + totals[1] + ",\"TotalNotPan\":" + totals[2] + "}]}";
                return(ResResult.Response(true, "", dgData));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #7
0
        private void ImportDeviceRepairRecord(HttpContext context, HttpPostedFile file)
        {
            var dt  = OpenXmlHelper.Import(file.InputStream);
            var drc = dt.Rows;

            if (drc.Count == 0)
            {
                context.Response.Write(ResResult.ResJsonString(false, MC.Import_NotDataError, ""));
                return;
            }

            var      currTime = DateTime.Now;
            DateTime time     = DateTime.MinValue;
            var      list     = new List <InfoneDeviceRepairRecordInfo>();
            var      userId   = WebCommon.GetUserId();

            foreach (DataRow dr in drc)
            {
                if (dr["日期"] != null)
                {
                    DateTime.TryParse(dr["日期"].ToString(), out time);
                }
                if (time == DateTime.MinValue)
                {
                    throw new ArgumentException(MC.Import_InvalidError);
                }
                var backDate = DateTime.MinValue;
                DateTime.TryParse(dr["归还日期"].ToString(), out backDate);
                if (backDate == DateTime.MinValue)
                {
                    backDate = DateTime.Parse("1754-01-01");
                }

                var modelInfo = new InfoneDeviceRepairRecordInfo(Guid.Empty, userId, time, dr["客户"].ToString(), dr["序列号"].ToString(), dr["型号"].ToString(), dr["故障原因"].ToString(), dr["解决方案"].ToString(), dr["客户问题"].ToString(), dr["配件"].ToString(), dr["处理情况"].ToString(), dr["是否修好"].ToString(), dr["交接人"].ToString(), dr["是否归还"].ToString() == "是" ? true : false, backDate, dr["登记人"].ToString(), dr["备注"].ToString(), currTime);
                list.Add(modelInfo);
            }

            var bll   = new InfoneDeviceRepairRecord();
            var index = 0;

            foreach (var model in list)
            {
                model.UserId = userId;
                if (bll.Insert(model) < 1)
                {
                    throw new ArgumentException(string.Format("{0}", index > 0 ? "部分数据已经成功导入,但是执行到第“" + index + "”行时发生异常" : "数据导入失败,行“" + index + "”发生异常"));
                }
                index++;
            }
            context.Response.Write(ResResult.ResJsonString(true, "导入成功", ""));
        }
Example #8
0
        public ResResultModel SaveContentDetail(ContentDetailFmModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                if (string.IsNullOrWhiteSpace(model.AppCode) || string.IsNullOrWhiteSpace(model.Title))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                Guid Id = Guid.Empty;
                if (model.Id != null)
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                Guid contentTypeId = Guid.Empty;
                if (model.ContentTypeId != null)
                {
                    Guid.TryParse(model.ContentTypeId.ToString(), out contentTypeId);
                }
                var userId    = WebCommon.GetUserId();
                var currTime  = DateTime.Now;
                var modelInfo = new ContentDetailInfo(model.AppCode, Id, userId, contentTypeId, model.Title, model.Keyword, model.Descr, model.ContentText, model.Openness, model.Sort, currTime, currTime);

                var bll    = new ContentDetail();
                int effect = -1;

                if (Id.Equals(Guid.Empty))
                {
                    modelInfo.Id = Guid.NewGuid();
                    effect       = bll.InsertByOutput(modelInfo);
                }
                else
                {
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, ""));
                }

                return(ResResult.Response(true, "", modelInfo.Id));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #9
0
        public ResResultModel GetPandianAssetByBarcode(string appKey, string userName, object pandianId, string barcode)
        {
            try
            {
                var userId = WebCommon.GetUserId();

                if (string.IsNullOrWhiteSpace(barcode))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, ""));
                }

                var gId = Guid.Empty;
                if (pandianId != null)
                {
                    Guid.TryParse(pandianId.ToString(), out gId);
                }
                if (gId.Equals(Guid.Empty))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, ""));
                }

                var            sqlWhere = @"and pd.Id = @PandianId and ais.Barcode = @Barcode ";
                SqlParameter[] parms    =
                {
                    new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier),
                    new SqlParameter("@Barcode",   SqlDbType.VarChar, 36)
                };
                parms[0].Value = gId;
                parms[1].Value = barcode;

                var bll  = new PandianAsset();
                var list = bll.GetListByJoin(sqlWhere, parms.ToArray());
                if (list == null || list.Count == 0)
                {
                    return(ResResult.Response(false, MC.GetString(MC.Params_Data_NotExist, barcode)));
                }

                var item = list[0];

                return(ResResult.Response(true, MC.Response_Ok, JsonConvert.SerializeObject(item)));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #10
0
        protected void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
        {
            AnonymousIdentificationModule.ClearAnonymousIdentifier();

            try
            {
                var userId    = WebCommon.GetUserId();
                var menuBll   = new SiteMenus();
                var accessIds = new List <string>();
                accessIds.Add(userId.ToString());
                Task[] tasks = new Task[3];
                tasks[0] = Task.Factory.StartNew(() =>
                {
                    var roleIds = new SiteRoles().GetAspnetRoleIds(Roles.GetRolesForUser());
                    foreach (var item in roleIds)
                    {
                        accessIds.Add(item.ToString());
                    }
                });
                var userProfileInfo = new UserProfileInfo();
                tasks[1] = Task.Factory.StartNew(() =>
                {
                    var fuInfo = new FeatureUser().GetModel(userId, "UserProfile");
                    if (fuInfo != null)
                    {
                        userProfileInfo.SiteCode    = fuInfo.SiteCode;
                        userProfileInfo.SiteTitle   = fuInfo.SiteTitle;
                        userProfileInfo.SiteLogo    = string.IsNullOrWhiteSpace(fuInfo.SiteLogo) ? "" : WebCommon.GetSiteAppName() + fuInfo.SiteLogo;
                        userProfileInfo.CultureName = fuInfo.CultureName;
                    }
                });
                IList <SiteMenusInfo> maList = new List <SiteMenusInfo>();
                tasks[2] = Task.Factory.StartNew(() =>
                {
                    maList = menuBll.GetMenusAccess(Membership.ApplicationName, accessIds.ToArray(), User.IsInRole("Administrators"));
                });
                Task.WaitAll(tasks);

                var Profile = new CustomProfileCommon();
                Profile.UserMenus = JsonConvert.SerializeObject(maList);
                Profile.UserInfo  = JsonConvert.SerializeObject(userProfileInfo);

                Profile.Save();
            }
            catch { }
        }
Example #11
0
        public ResResultModel SavePandianProduct(PandianProductFmModel model)
        {
            try
            {
                var bll    = new PandianProduct();
                int effect = -1;

                var oldInfo = bll.GetModel(model.PandianId, model.ProductId, model.CustomerId);
                if (oldInfo == null)
                {
                    throw new ArgumentException(MC.Data_NotExist);
                }

                oldInfo.UserId                = WebCommon.GetUserId();
                oldInfo.Qty                   = model.Qty;
                oldInfo.FailQty               = oldInfo.StayQty - model.Qty;
                oldInfo.UpdatedZones          = model.Zones;
                oldInfo.UpdatedStockLocations = HttpUtility.UrlDecode(model.StockLocations);
                if (oldInfo.Qty > 0)
                {
                    if (oldInfo.FailQty == 0)
                    {
                        oldInfo.Status = EnumData.EnumOrderStatus.已完成.ToString();
                    }
                    else
                    {
                        oldInfo.Status = EnumData.EnumOrderStatus.待完成.ToString();
                    }
                }
                oldInfo.LastUpdatedDate = DateTime.Now;
                effect  = bll.Update(oldInfo);
                effect += new Pandian().UpdateStatus(oldInfo.PandianId, EnumData.EnumOrderStatus.待完成.ToString());

                if (effect < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, ""));
                }

                return(ResResult.Response(true, "", ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #12
0
        protected void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
        {
            AnonymousIdentificationModule.ClearAnonymousIdentifier();
            Membership.DeleteUser(args.AnonymousID, true);

            try
            {
                string[] userRoles          = Roles.GetRolesForUser();
                var      menuBll            = new Menus();
                var      userMenuAccessList = menuBll.GetUserMenuAccessList(WebCommon.GetUserId(), userRoles);

                CustomProfileCommon profile = new CustomProfileCommon();
                profile.UserMenus = JsonConvert.SerializeObject(userMenuAccessList);
                profile.Save();
            }
            catch {
            }
        }
Example #13
0
        private void Bind()
        {
            var list = ErnieDataProxy.GetLatest();

            if (list == null || list.Count == 0)
            {
                ltrMyData.Text = "<div id=\"myDataAppend\" style=\"display:none;\" startTime=\"\" endTime=\"\" totalMls=\"0\" status=\"100\"></div>";
                return;
            }

            var model = list[0];

            if (!((DateTime.Now >= model.StartTime) && (DateTime.Now < model.EndTime)))
            {
                if (DateTime.Now < model.StartTime)
                {
                    hTotalMls.Value = "" + (model.StartTime - DateTime.Now).TotalMilliseconds + "";
                    ltrMyData.Text  = "<div id=\"myDataAppend\" style=\"display:none;\" startTime=\"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\" endTime=\"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\" totalMls=\"" + (model.StartTime - DateTime.Now).TotalMilliseconds + "\" status=\"0\"></div>";
                    return;
                }
                if (DateTime.Now > model.EndTime)
                {
                    ltrMyData.Text = "<div id=\"myDataAppend\" style=\"display:none;\" startTime=\"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\" endTime=\"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\" totalMls=\"0\" status=\"100\"></div>";
                    return;
                }
            }

            UserErnie ueBll         = new UserErnie();
            var       totalBetCount = ueBll.GetTotalBetCount(WebCommon.GetUserId(), model.ErnieId);
            int       remainTimes   = model.UserBetMaxCount - totalBetCount;

            if (remainTimes < 0)
            {
                remainTimes = 0;
            }

            ltrMyData.Text = "<div id=\"myDataAppend\" style=\"display:none;\" startTime=\"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\" endTime=\"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\" totalMls=\"0\" status=\"1\" remainTimes=\"" + remainTimes + "\"></div>";
        }
Example #14
0
        public ResResultModel SaveOrderMake(OrderMakeFmModel model)
        {
            try
            {
                Guid Id = Guid.Empty;
                if (model.Id != null)
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                DateTime takeTime = DateTime.MinValue;
                if (model.TakeTime != null)
                {
                    DateTime.TryParse(model.TakeTime, out takeTime);
                }
                if (takeTime == DateTime.MinValue)
                {
                    takeTime = DateTime.Parse("1754-01-01");
                }
                DateTime reachTime = DateTime.MinValue;
                if (!string.IsNullOrWhiteSpace(model.ReachTime))
                {
                    DateTime.TryParse(model.ReachTime, out reachTime);
                }
                if (reachTime == DateTime.MinValue)
                {
                    reachTime = DateTime.Parse("1754-01-01");
                }
                int pieceQty = 0;
                if (!string.IsNullOrWhiteSpace(model.PieceQty))
                {
                    int.TryParse(model.PieceQty, out pieceQty);
                }
                double weight = 0d;
                if (!string.IsNullOrWhiteSpace(model.Weight))
                {
                    double.TryParse(model.Weight, out weight);
                }
                decimal tranPrice = 0;
                if (!string.IsNullOrWhiteSpace(model.TranPrice))
                {
                    decimal.TryParse(model.TranPrice, out tranPrice);
                }
                decimal increServicePrice = 0;
                if (!string.IsNullOrWhiteSpace(model.IncreServicePrice))
                {
                    decimal.TryParse(model.IncreServicePrice, out increServicePrice);
                }
                decimal totalPrice = 0;
                if (!string.IsNullOrWhiteSpace(model.TotalPrice))
                {
                    decimal.TryParse(model.TotalPrice, out totalPrice);
                }
                var currTime = DateTime.Now;
                var userId   = WebCommon.GetUserId();

                CustomProfileCommon Profile = new CustomProfileCommon();
                var upi = JsonConvert.DeserializeObject <UserProfileInfo>(Profile.UserInfo);

                var modelInfo = new OrderMakeInfo(Id, upi.SiteCode, userId, model.CustomerCode, model.OrderCode, model.FromName, model.FromAddress, model.FromPhone, model.ToCity, model.ToName, model.ToAddress, model.ToPhone, model.StaffCode, model.StaffCodeOfTake, takeTime, reachTime, model.CargoName, model.ServiceProduct, pieceQty, weight, tranPrice, increServicePrice, totalPrice, model.PayWay, model.Remark, currTime, currTime);

                var bll    = new OrderMake();
                int effect = -1;

                if (Id.Equals(Guid.Empty))
                {
                    effect = bll.Insert(modelInfo);
                }
                else
                {
                    var oldInfo = bll.GetModel(Id);
                    modelInfo.RecordDate = oldInfo.RecordDate;
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, ""));
                }

                return(ResResult.Response(true, "", ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #15
0
        private void OnUploadPictureAdStartup(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string errorMsg = "";

            try
            {
                HttpFileCollection files = context.Request.Files;
                if (files.Count == 0)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}");
                    return;
                }

                int effect            = 0;
                UploadFilesHelper ufh = new UploadFilesHelper();
                ImagesHelper      ih  = new ImagesHelper();

                foreach (string item in files.AllKeys)
                {
                    HttpPostedFile file = files[item];
                    if (file == null || file.ContentLength == 0)
                    {
                        continue;
                    }

                    int fileSize       = file.ContentLength;
                    int uploadFileSize = int.Parse(ConfigHelper.GetValueByKey("UploadFileSize"));
                    if (fileSize > uploadFileSize)
                    {
                        throw new ArgumentException("文件【" + file.FileName + "】大小超出字节" + uploadFileSize + ",无法上传,请正确操作!");
                    }
                    if (!UploadFilesHelper.IsFileValidated(file.InputStream, fileSize))
                    {
                        throw new ArgumentException("文件【" + file.FileName + "】为受限制的文件,请正确操作!");
                    }

                    string fileName = file.FileName;

                    var bll = new PictureAdStartup();
                    if (bll.IsExist(file.FileName, fileSize))
                    {
                        throw new ArgumentException("文件【" + file.FileName + "】已存在,请勿重复上传!");
                    }

                    string originalUrl  = UploadFilesHelper.UploadOriginalFile(file, "PictureAdStartup");
                    string randomFolder = string.Format("{0}_{1}", DateTime.Now.ToString("MMdd"), UploadFilesHelper.GetRandomFolder("padsu"));

                    var model = new PictureAdStartupInfo();
                    model.FileName        = VirtualPathUtility.GetFileName(originalUrl);
                    model.FileSize        = fileSize;
                    model.FileExtension   = VirtualPathUtility.GetExtension(originalUrl).ToLower();
                    model.FileDirectory   = VirtualPathUtility.GetDirectory(originalUrl.Replace("~", ""));
                    model.RandomFolder    = randomFolder;
                    model.LastUpdatedDate = DateTime.Now;
                    model.UserId          = WebCommon.GetUserId();

                    bll.Insert(model);

                    string rndDirFullPath = context.Server.MapPath(string.Format("~{0}{1}", model.FileDirectory, model.RandomFolder));
                    if (!Directory.Exists(rndDirFullPath))
                    {
                        Directory.CreateDirectory(rndDirFullPath);
                    }
                    File.Copy(context.Server.MapPath(originalUrl), string.Format("{0}\\{1}{2}", rndDirFullPath, randomFolder, model.FileExtension), true);

                    string[] platformNames = Enum.GetNames(typeof(EnumData.Platform));
                    foreach (string name in platformNames)
                    {
                        string platformUrl         = string.Format("{0}/{1}/{2}", model.FileDirectory, model.RandomFolder, name);
                        string platformUrlFullPath = context.Server.MapPath("~" + platformUrl);
                        if (!Directory.Exists(platformUrlFullPath))
                        {
                            Directory.CreateDirectory(platformUrlFullPath);
                        }
                        string   sizeAppend = ConfigHelper.GetValueByKey(name);
                        string[] sizeArr    = sizeAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < sizeArr.Length; i++)
                        {
                            string   bmsPicUrl = string.Format("{0}\\{1}_{2}{3}", platformUrlFullPath, model.RandomFolder, i, model.FileExtension);
                            string[] wh        = sizeArr[i].Split('*');

                            ih.CreateThumbnailImage(context.Server.MapPath(originalUrl), bmsPicUrl, int.Parse(wh[0]), int.Parse(wh[1]), "DB", model.FileExtension);
                        }
                    }

                    effect++;
                }

                if (effect == 0)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"已成功上传文件数:" + effect + "个\"}");

                return;
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            context.Response.Write("{\"success\": false,\"message\": \"" + errorMsg + "\"}");
        }
        /// <summary>
        /// 内容相册上传
        /// </summary>
        /// <param name="context"></param>
        private void OnUploadPictureContent(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string errorMsg = "";

            try
            {
                HttpFileCollection files = context.Request.Files;
                if (files.Count == 0)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}");
                    return;
                }

                object            userId = WebCommon.GetUserId();
                int               effect = 0;
                UploadFilesHelper ufh    = new UploadFilesHelper();
                ImagesHelper      ih     = new ImagesHelper();

                using (TransactionScope scope = new TransactionScope())
                {
                    foreach (string item in files.AllKeys)
                    {
                        HttpPostedFile file = files[item];
                        if (file == null || file.ContentLength == 0)
                        {
                            continue;
                        }

                        int fileSize       = file.ContentLength;
                        int uploadFileSize = int.Parse(WebConfigurationManager.AppSettings["UploadFileSize"]);
                        if (fileSize > uploadFileSize)
                        {
                            throw new ArgumentException("文件【" + file.FileName + "】大小超出字节" + uploadFileSize + ",无法上传,请正确操作!");
                        }
                        if (!UploadFilesHelper.IsFileValidated(file.InputStream, fileSize))
                        {
                            throw new ArgumentException("文件【" + file.FileName + "】为受限制的文件,请正确操作!");
                        }

                        string fileName = file.FileName;

                        PictureContent bll = new PictureContent();
                        if (bll.IsExist(userId, file.FileName, fileSize))
                        {
                            throw new ArgumentException("文件【" + file.FileName + "】已存在,请勿重复上传!");
                        }

                        string originalUrl = UploadFilesHelper.UploadOriginalFile(file, "PictureContent");

                        //获取随机生成的文件名代码
                        string randomFolder = UploadFilesHelper.GetRandomFolder(originalUrl);

                        PictureContentInfo model = new PictureContentInfo();
                        model.UserId          = userId;
                        model.FileName        = VirtualPathUtility.GetFileName(originalUrl);
                        model.FileSize        = fileSize;
                        model.FileExtension   = VirtualPathUtility.GetExtension(originalUrl).ToLower();
                        model.FileDirectory   = VirtualPathUtility.GetDirectory(originalUrl.Replace("~", ""));
                        model.RandomFolder    = randomFolder;
                        model.LastUpdatedDate = DateTime.Now;

                        bll.Insert(model);

                        CreateThumbnailImage(context, ih, originalUrl, model.FileDirectory, model.RandomFolder, model.FileExtension);

                        effect++;
                    }

                    scope.Complete();
                }

                if (effect == 0)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"已成功上传文件数:" + effect + "个\"}");

                return;
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            context.Response.Write("{\"success\": false,\"message\": \"" + errorMsg + "\"}");
        }
Example #17
0
        private void ImportByAssetInStore(HttpContext context, HttpPostedFile file)
        {
            //NpoiHelper npoi = new NpoiHelper();
            //var dt = npoi.GetExcelData(Path.GetExtension(file.FileName), file.InputStream);
            var dt  = new DataTable();
            var drc = dt.Rows;

            if (drc.Count == 0)
            {
                context.Response.Write(ResResult.ResJsonString(false, "导入的数据不能为空字符串", ""));
                return;
            }
            Category cBll  = new Category();
            OrgDepmt odBll = new OrgDepmt();
            Region   rBll  = new Region();
            decimal  d     = decimal.MinValue;
            DateTime time  = DateTime.MinValue;
            var      list  = new List <AssetInStoreInfo>();

            foreach (DataRow dr in drc)
            {
                if (string.IsNullOrWhiteSpace(dr["资产条码"].ToString()) || string.IsNullOrWhiteSpace(dr["资产名称"].ToString()) || string.IsNullOrWhiteSpace(dr["资产类别编码"].ToString()) || string.IsNullOrWhiteSpace(dr["使用公司编码"].ToString()) || string.IsNullOrWhiteSpace(dr["存放地点"].ToString()) || string.IsNullOrWhiteSpace(dr["所属公司编码"].ToString()) || string.IsNullOrWhiteSpace(dr["购入时间"].ToString()))
                {
                    throw new ArgumentException("带有“*”的列为必填项,请正确操作");
                }
                var model = new AssetInStoreInfo();
                model.Barcode = dr["资产条码"].ToString();
                model.Named   = dr["资产名称"].ToString();
                var categoryModel = cBll.GetModelByCode(dr["资产类别编码"].ToString().Trim());
                if (categoryModel == null)
                {
                    throw new ArgumentException("资产类别编码“" + dr["资产类别编码"].ToString().Trim() + "”对应的数据不存在或已被删除");
                }
                model.CategoryId = categoryModel.Id;

                if (!decimal.TryParse(dr["金额"].ToString(), out d))
                {
                    throw new ArgumentException("金额“" + dr["金额"].ToString() + "”不正确");
                }
                model.Price     = d;
                model.SpecModel = dr["规格型号"].ToString();
                model.Unit      = dr["计量单位"].ToString();

                var useCompanyModel = odBll.GetModelByCode(dr["使用公司编码"].ToString());
                if (useCompanyModel == null)
                {
                    throw new ArgumentException("使用公司编码“" + dr["使用公司编码"].ToString() + "”对应的数据不存在或已被删除");
                }
                var orgdModel = odBll.GetModelByCode(dr["使用部门编码"].ToString());
                if (orgdModel == null)
                {
                    throw new ArgumentException("使用部门编码“" + dr["使用部门编码"].ToString() + "”对应的数据不存在或已被删除");
                }

                model.UseCompanyId = useCompanyModel.Id;
                model.UseDepmtId   = orgdModel.Id;

                var rModel = rBll.GetModelByCode(dr["区域编码"].ToString());
                if (rModel == null)
                {
                    throw new ArgumentException("区域编码“" + dr["区域编码"].ToString() + "”对应的数据不存在或已被删除");
                }
                model.RegionId = rModel.Id;

                var ownedCompanyModel = odBll.GetModelByCode(dr["所属公司编码"].ToString());
                if (ownedCompanyModel == null)
                {
                    throw new ArgumentException("所属公司编码“" + dr["所属公司编码"].ToString() + "”对应的数据不存在或已被删除");
                }
                model.OwnedCompanyId = ownedCompanyModel.Id;

                model.UsePerson     = dr["使用人"].ToString();
                model.StoreLocation = dr["存放地点"].ToString();
                model.Manager       = dr["管理员姓名"].ToString();
                if (!DateTime.TryParse(dr["购入时间"].ToString(), out time))
                {
                    throw new ArgumentException("购入时间“" + dr["购入时间"].ToString() + "”不正确");
                }
                model.BuyDate  = time;
                model.Supplier = dr["供应商"].ToString();
                model.Remark   = dr["备注"].ToString();
                model.SNCode   = dr["SN号"].ToString();

                model.UseExpireMonth  = 1200;
                model.PictureId       = Guid.Empty;
                model.LastUpdatedDate = DateTime.Now;

                list.Add(model);
            }

            AssetInStore aisBll = new AssetInStore();
            var          index  = 0;
            var          userId = WebCommon.GetUserId();

            foreach (var model in list)
            {
                model.UserId = userId;
                if (aisBll.Insert(model) < 1)
                {
                    throw new ArgumentException(string.Format("{0}", index > 0 ? "部分数据已经成功导入,但是执行到第“" + index + "”行时发生异常" : "数据导入失败,行“" + index + "”发生异常"));
                }
                index++;
            }
            context.Response.Write(ResResult.ResJsonString(true, "导入成功", ""));
        }
Example #18
0
        /// <summary>
        /// 导入资产信息
        /// </summary>
        /// <param name="context"></param>
        private void OnImportProduct(HttpContext context)
        {
            var files = context.Request.Files;

            if (files.Count == 0)
            {
                throw new ArgumentException(MC.M_UploadFileNotExist);
            }

            var appCode = context.Request.Form["AppCode"];
            var userId  = WebCommon.GetUserId();
            var orgId   = new Staff().GetOrgId(userId);

            var bll      = new Product();
            var orgBll   = new OrgDepmt();
            var spBll    = new StoragePlace();
            var cBll     = new Category();
            int effect   = 0;
            var currTime = DateTime.Now;

            foreach (string item in files.AllKeys)
            {
                HttpPostedFile file = files[item];
                if (file == null || file.ContentLength == 0)
                {
                    continue;
                }
                var dt = ExcelHelper.Import(file.InputStream);
                if (dt == null || dt.Rows.Count == 0)
                {
                    throw new CustomException(MC.M_UploadFileDataNotExist);
                }
                //var id = Guid.Empty;

                var drc = dt.Rows;
                foreach (DataRow dr in drc)
                {
                    var currInfo = new ProductInfo();

                    #region 请求参数集

                    if (dr["资产分类编码"] != null)
                    {
                        currInfo.CategoryCode = dr["资产分类编码"].ToString().Trim();
                    }
                    if (dr["资产分类"] != null)
                    {
                        currInfo.CategoryName = dr["资产分类"].ToString().Trim();
                    }

                    if (string.IsNullOrWhiteSpace(currInfo.CategoryCode) || string.IsNullOrWhiteSpace(currInfo.CategoryName))
                    {
                        throw new CustomException(MC.GetString(MC.Request_InvalidArgument, "资产编码、资产名称"));
                    }
                    var oldCategoryInfo = cBll.GetModel(currInfo.CategoryCode, currInfo.CategoryName);
                    if (oldCategoryInfo == null)
                    {
                        throw new CustomException(MC.GetString(MC.P_InvalidError, string.Format("资产分类编码“{0}”、资产分类为“{1}”", currInfo.CategoryCode, currInfo.CategoryName)));
                    }
                    currInfo.CategoryId = oldCategoryInfo.Id;

                    //if (dr["资产编码"] != null) currInfo.Coded = dr["资产编码"].ToString().Trim();
                    if (dr["资产名称"] != null)
                    {
                        currInfo.Named = dr["资产名称"].ToString().Trim();
                    }
                    //if (bll.IsExist(currInfo.Coded, currInfo.Named)) continue;
                    var sCoded = bll.GetRndCode(oldCategoryInfo.Coded, 8);
                    currInfo.Coded = sCoded;
                    var qty = 0;
                    if (dr["数量"] != null)
                    {
                        int.TryParse(dr["数量"].ToString(), out qty);
                    }
                    currInfo.Qty = 1;
                    if (qty < 1)
                    {
                        throw new CustomException(string.Format("数量为“{0}”", qty));
                    }
                    if (dr["规格型号"] != null)
                    {
                        currInfo.SpecModel = dr["规格型号"].ToString().Trim();
                    }
                    var price = 0m;
                    if (dr["单价"] != null && decimal.TryParse(dr["单价"].ToString(), out price))
                    {
                        currInfo.Price = price;
                    }
                    var amount = 0m;
                    if (dr["金额"] != null && decimal.TryParse(dr["金额"].ToString(), out amount))
                    {
                        currInfo.Amount = amount;
                    }
                    if (dr["计量单位"] != null)
                    {
                        currInfo.MeterUnit = dr["计量单位"].ToString().Trim();
                    }
                    var pieceQty = 0;
                    //if (dr["件数"] != null && int.TryParse(dr["件数"].ToString(),out pieceQty)) currInfo.PieceQty = pieceQty;
                    if (dr["资产属性"] != null)
                    {
                        currInfo.Pattr = dr["资产属性"].ToString().Trim();
                    }
                    if (dr["资产来源"] != null)
                    {
                        currInfo.SourceFrom = dr["资产来源"].ToString().Trim();
                    }
                    if (dr["供应商"] != null)
                    {
                        currInfo.Supplier = dr["供应商"].ToString().Trim();
                    }
                    var buyDate = DateTime.MinValue;
                    if (dr["购入日期"] != null)
                    {
                        DateTime.TryParse(dr["购入日期"].ToString(), out buyDate);
                    }
                    if (buyDate == DateTime.MinValue)
                    {
                        buyDate = DateTime.Parse("1754-01-01");
                    }
                    currInfo.BuyDate = buyDate;
                    var enableDate = DateTime.MinValue;
                    if (dr["启用日期"] != null && DateTime.TryParse(dr["启用日期"].ToString(), out enableDate))
                    {
                        currInfo.EnableDate = enableDate.ToString("yyyy-MM-dd");
                    }
                    if (dr["使用期限"] != null)
                    {
                        currInfo.UseDateLimit = dr["使用期限"].ToString().Trim();
                    }
                    if (dr["使用部门"] != null)
                    {
                        currInfo.UseOrgName = dr["使用部门"].ToString().Trim();
                    }
                    if (dr["使用部门编码"] != null)
                    {
                        currInfo.UseOrgCode = dr["使用部门编码"].ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(currInfo.UseOrgCode) || !string.IsNullOrEmpty(currInfo.UseOrgName))
                    {
                        var useOrgInfo = orgBll.GetModel(currInfo.UseOrgCode, currInfo.UseOrgName);
                        if (useOrgInfo == null)
                        {
                            throw new CustomException(MC.GetString(MC.P_InvalidError, string.Format("使用部门编码“{0}”、使用部门“{1}”", currInfo.UseOrgCode, currInfo.UseOrgName)));
                        }
                        currInfo.UseDepmtId = useOrgInfo.Id;
                    }

                    if (dr["实物管理部门"] != null)
                    {
                        currInfo.MgrOrgName = dr["实物管理部门"].ToString().Trim();
                    }
                    if (dr["实物管理部门编码"] != null)
                    {
                        currInfo.MgrOrgCode = dr["实物管理部门编码"].ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(currInfo.MgrOrgCode) || !string.IsNullOrEmpty(currInfo.MgrOrgName))
                    {
                        var mgrOrgInfo = orgBll.GetModel(currInfo.MgrOrgCode, currInfo.MgrOrgName);
                        if (mgrOrgInfo == null)
                        {
                            throw new CustomException(MC.GetString(MC.P_InvalidError, string.Format("实物管理部门编码“{0}”、实物管理部门“{1}”", currInfo.MgrOrgCode, currInfo.MgrOrgName)));
                        }
                        currInfo.MgrDepmtId = mgrOrgInfo.Id;
                    }

                    if (dr["存放地点"] != null)
                    {
                        currInfo.StoragePlaceName = dr["存放地点"].ToString().Trim();
                    }
                    if (dr["存放地点编码"] != null)
                    {
                        currInfo.StoragePlaceCode = dr["存放地点编码"].ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(currInfo.StoragePlaceCode) || !string.IsNullOrEmpty(currInfo.StoragePlaceName))
                    {
                        var storagePlaceInfo = spBll.GetModel(currInfo.StoragePlaceCode, currInfo.StoragePlaceName);
                        if (storagePlaceInfo == null)
                        {
                            throw new CustomException(MC.GetString(MC.P_InvalidError, string.Format("存放地点编码“{0}”、存放地点“{1}”", currInfo.StoragePlaceCode, currInfo.StoragePlaceName)));
                        }
                        currInfo.StoragePlaceId = storagePlaceInfo.Id;
                    }

                    if (dr["使用人"] != null)
                    {
                        currInfo.UsePersonName = dr["使用人"].ToString().Trim();
                    }

                    #endregion

                    currInfo.AppCode         = appCode;
                    currInfo.UserId          = userId;
                    currInfo.DepmtId         = orgId;
                    currInfo.RecordDate      = currTime;
                    currInfo.LastUpdatedDate = currTime;

                    effect += bll.Insert(currInfo);

                    if (qty > 1)
                    {
                        for (var i = 1; i < qty; i++)
                        {
                            currInfo.Coded = bll.GetRndCode(sCoded, 11);
                            effect        += bll.Insert(currInfo);
                        }
                    }
                }
            }
            if (effect < 1)
            {
                context.Response.Write(ResResult.ResJsonString(false, MC.M_Save_Error, ""));
            }
            else
            {
                context.Response.Write(ResResult.ResJsonString(true, MC.M_Save_Ok, effect));
            }
        }
Example #19
0
        /// <summary>
        /// 导入组织机构
        /// </summary>
        /// <param name="context"></param>
        private void OnImportOrgDepmt(HttpContext context)
        {
            var files = context.Request.Files;

            if (files.Count == 0)
            {
                throw new ArgumentException(MC.M_UploadFileNotExist);
            }

            var appCode = context.Request.Form["AppCode"];
            var userId  = WebCommon.GetUserId();
            var orgId   = new Staff().GetOrgId(userId);

            var bll    = new OrgDepmt();
            int effect = 0;

            var categories = bll.GetList();

            foreach (string item in files.AllKeys)
            {
                HttpPostedFile file = files[item];
                if (file == null || file.ContentLength == 0)
                {
                    continue;
                }
                var dt = ExcelHelper.Import(file.InputStream);
                if (dt == null || dt.Rows.Count == 0)
                {
                    throw new ArgumentException(MC.M_UploadFileDataNotExist);
                }
                var currTime = DateTime.Now;
                var sEmpty   = string.Empty;

                var drc = dt.Rows;
                foreach (DataRow dr in drc)
                {
                    #region 请求参数集

                    string coded = string.Empty;
                    if (dr["资产分类编码"] != null)
                    {
                        coded = dr["资产分类编码"].ToString().Trim();
                    }
                    string named = string.Empty;
                    if (dr["资产分类名称"] != null)
                    {
                        named = dr["资产分类名称"].ToString().Trim();
                    }
                    string parentCode = string.Empty;
                    if (dr["所属上级分类编码"] != null)
                    {
                        parentCode = dr["所属上级分类编码"].ToString().Trim();
                    }
                    string parentName = string.Empty;
                    if (dr["所属上级分类"] != null)
                    {
                        parentName = dr["所属上级分类"].ToString().Trim();
                    }
                    int sort = 0;
                    if (dr["排序"] != null)
                    {
                        int.TryParse(dr["排序"].ToString(), out sort);
                    }
                    if (string.IsNullOrWhiteSpace(coded) || string.IsNullOrWhiteSpace(named))
                    {
                        continue;
                    }

                    var id       = Guid.NewGuid();
                    var parentId = Guid.Empty;
                    if (string.IsNullOrWhiteSpace(parentCode))
                    {
                        parentCode = named;
                    }
                    var parentInfo = bll.GetModel(parentCode, parentName);
                    var step       = id.ToString();
                    var ids        = new List <Guid>();
                    if (parentInfo != null)
                    {
                        parentId = parentInfo.Id;
                        bll.GetStep(categories, parentId, ref ids);
                        if (ids.Count > 0)
                        {
                            Array.Reverse(ids.ToArray());
                            step += "," + string.Join(",", ids.ToArray());
                        }
                    }

                    var currInfo = new OrgDepmtInfo(id, appCode, userId, orgId, parentId, coded, named, step, sort, sEmpty, currTime, currTime);
                    effect += bll.Insert(currInfo);

                    #endregion
                }
            }
            if (effect < 1)
            {
                context.Response.Write(ResResult.ResJsonString(false, MC.M_Save_Error, ""));
            }
            else
            {
                context.Response.Write(ResResult.ResJsonString(true, MC.M_Save_Ok, effect));
            }
        }
Example #20
0
        /// <summary>
        /// 导入存放地点
        /// </summary>
        /// <param name="context"></param>
        private void OnImportStoragePlace(HttpContext context)
        {
            var files = context.Request.Files;

            if (files.Count == 0)
            {
                throw new ArgumentException(MC.M_UploadFileNotExist);
            }

            var appCode = context.Request.Form["AppCode"];
            var userId  = WebCommon.GetUserId();
            var orgId   = new Staff().GetOrgId(userId);

            var bll    = new StoragePlace();
            int effect = 0;

            foreach (string item in files.AllKeys)
            {
                HttpPostedFile file = files[item];
                if (file == null || file.ContentLength == 0)
                {
                    continue;
                }
                var dt = ExcelHelper.Import(file.InputStream);
                if (dt == null || dt.Rows.Count == 0)
                {
                    throw new ArgumentException(MC.M_UploadFileDataNotExist);
                }
                var currTime = DateTime.Now;
                var id       = Guid.Empty;

                var drc = dt.Rows;
                foreach (DataRow dr in drc)
                {
                    #region 请求参数集

                    string coded = string.Empty;
                    if (dr["存放地点编码"] != null)
                    {
                        coded = dr["存放地点编码"].ToString().Trim();
                    }
                    string named = string.Empty;
                    if (dr["存放地点"] != null)
                    {
                        named = dr["存放地点"].ToString().Trim();
                    }

                    if (!string.IsNullOrWhiteSpace(named))
                    {
                        if (string.IsNullOrWhiteSpace(coded))
                        {
                            coded = bll.GetRndCode(6);
                        }
                        if (bll.GetModel(null, named) != null)
                        {
                            continue;
                        }
                        var currInfo = new StoragePlaceInfo(id, appCode, userId, orgId, coded, named, currTime, currTime);
                        effect += bll.Insert(currInfo);
                    }

                    #endregion
                }
            }
            if (effect < 1)
            {
                context.Response.Write(ResResult.ResJsonString(false, MC.M_Save_Error, ""));
            }
            else
            {
                context.Response.Write(ResResult.ResJsonString(true, MC.M_Save_Ok, effect));
            }
        }
Example #21
0
        private void GetLogisticsDistributionList(HttpContext context, int pageIndex, int pageSize, string keyword)
        {
            var           bll         = new LogisticsDistribution();
            int           totalRecord = 0;
            StringBuilder sqlWhere    = null;
            ParamsHelper  parms       = null;
            var           isSelfView  = false;

            if (HttpContext.Current.User.IsInRole("SelfView"))
            {
                isSelfView = true;
                if (sqlWhere == null)
                {
                    sqlWhere = new StringBuilder(1000);
                }
                sqlWhere.AppendFormat("and lgd.CompanyId in (select FeatureId from FeatureUser fu where fu.UserId = '{0}' and TypeName = 'Company') ", WebCommon.GetUserId());
            }
            if (!string.IsNullOrWhiteSpace(keyword))
            {
                if (sqlWhere == null)
                {
                    sqlWhere = new StringBuilder(1000);
                }
                parms = new ParamsHelper();
                sqlWhere.Append("and (lgd.OrderCode like @Keyword) ");
                var parm = new SqlParameter("@Keyword", SqlDbType.NVarChar, 50);
                parm.Value = "%" + keyword + "%";
                parms.Add(parm);
            }

            var list = bll.GetListByJoin(pageIndex, pageSize, out totalRecord, sqlWhere == null ? null : sqlWhere.ToString(), parms == null ? null : parms.ToArray());

            context.Response.Write(ResResult.ResJsonString(true, "", "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + ",\"IsSelfView\":\"" + isSelfView + "\"}"));
        }
Example #22
0
        private void UploadContentFile(HttpContext context)
        {
            #region 请求参数集

            var contentId = Guid.Empty;
            if (context.Request.Form["ContentId"] != null)
            {
                Guid.TryParse(context.Request.Form["ContentId"], out contentId);
            }
            if (contentId.Equals(Guid.Empty))
            {
                throw new ArgumentException(MC.Request_Params_InvalidError);
            }
            var appCode = context.Request.Form["AppCode"];
            if (string.IsNullOrWhiteSpace(appCode))
            {
                throw new ArgumentException(MC.Request_Params_InvalidError);
            }
            var userId = WebCommon.GetUserId();
            if (userId.Equals(Guid.Empty))
            {
                throw new ArgumentException(MC.L_InvalidError);
            }
            var currTime = DateTime.Now;
            var effect   = 0;

            #endregion

            HttpFileCollection files = context.Request.Files;
            if (files.Count > 0)
            {
                var          ufh = new UploadFilesHelper();
                ImagesHelper ih  = new ImagesHelper();
                foreach (string item in files.AllKeys)
                {
                    HttpPostedFile file = files[item];
                    if (file == null || file.ContentLength == 0)
                    {
                        continue;
                    }
                    var ext = Path.GetExtension(file.FileName);

                    FileValidated(file);

                    string originalUrl  = ufh.UploadOriginalFile(file, "ContentFiles", currTime);
                    var    originalPath = UploadFilesHelper.ToFullPath(originalUrl);
                    var    htmlFullPath = string.Empty;
                    if (ext == ".doc" || ext == ".docx")
                    {
                        htmlFullPath = OoxmlConvert.WordToHtml(originalPath, Path.GetFileNameWithoutExtension(file.FileName));
                    }
                    else if (ext == ".xls" || ext == ".xlsx")
                    {
                        htmlFullPath = AsposeConvert.ExcelToHtml(originalPath, Path.GetFileNameWithoutExtension(file.FileName));
                    }

                    var cfInfo = new ContentFileInfo(Guid.Empty, appCode.Trim(), userId, contentId, file.FileName, file.ContentLength, VirtualPathUtility.GetExtension(file.FileName).ToLower(), originalUrl.Trim('~'), UploadFilesHelper.ToVirtualPath(htmlFullPath), currTime);
                    var cfBll  = new ContentFile();
                    effect += cfBll.Insert(cfInfo);

                    //if (ufh.IsImage(file))
                    //    CreateThumbnailImage(context, ih, context.Server.MapPath(originalUrl));
                }
            }

            if (effect > 0)
            {
                context.Response.Write(ResResult.ResJsonString(true, MC.M_Save_Ok, null));
            }
            else
            {
                context.Response.Write(ResResult.ResJsonString(false, MC.M_Save_Error, ""));
            }
        }
Example #23
0
        private void GetBetResult(HttpContext context)
        {
            var list = ErnieDataProxy.GetLatest();

            if (list == null || list.Count == 0)
            {
                int index = 0;
                while (true)
                {
                    Thread.Sleep(5000);
                    list = ErnieDataProxy.GetLatest();
                    if (list.Count > 0)
                    {
                        break;
                    }
                    index++;
                    if (index > 5)
                    {
                        break;
                    }
                }
            }
            if (list != null && list.Count > 0)
            {
                var ernieModel = list[0];
                if (!((DateTime.Now >= ernieModel.StartTime) && (DateTime.Now <= ernieModel.EndTime)))
                {
                    context.Response.Write("{\"success\": true,\"message\": \"\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\"}");
                    return;
                }

                var userId = WebCommon.GetUserId();
                if (userId.Equals(Guid.Empty))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"请先登录\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\"}");
                    return;
                }

                UserErnie ueBll = new UserErnie();
                Dictionary <string, string> dic = new Dictionary <string, string>();

                var listT = list.ToList();
                var g     = listT.GroupBy(m => m.NumType);
                foreach (var gk in g)
                {
                    var keyList = listT.FindAll(m => m.NumType == gk.Key);
                    var ga      = keyList.GroupBy(m => m.AppearRatio);

                    GLBfb[] arrGLBfb = new GLBfb[ga.Count()];
                    int     i        = 0;
                    foreach (var gak in ga)
                    {
                        arrGLBfb[i]     = new GLBfb();
                        arrGLBfb[i].Bfb = (int)(gak.Key * 100);
                        var currList = keyList.FindAll(m => m.AppearRatio == gak.Key);
                        foreach (var model in currList)
                        {
                            var numArr = model.Num.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (var num in numArr)
                            {
                                arrGLBfb[i].SjsList.Add(num);
                            }
                        }
                        i++;
                    }

                    RandomForWeight rdfw = new RandomForWeight(arrGLBfb);

                    dic.Add(gk.Key, rdfw.GetGLNumber());
                }

                string gold   = "0";
                string silver = "0";
                string times  = "0";
                foreach (KeyValuePair <string, string> kvp in dic)
                {
                    switch (kvp.Key)
                    {
                    case "倍数":
                        times = kvp.Value;
                        break;

                    case "金币":
                        gold = kvp.Value;
                        break;

                    case "元宝":
                        silver = kvp.Value;
                        break;

                    default:
                        break;
                    }
                }

                int remainTimes = 0;
                using (TransactionScope scope = new TransactionScope())
                {
                    var totalBetCount = ueBll.GetTotalBetCount(userId, ernieModel.ErnieId);
                    remainTimes = ernieModel.UserBetMaxCount - totalBetCount;
                    if (remainTimes < 0)
                    {
                        totalBetCount = 0;
                    }
                    if (remainTimes < 1)
                    {
                        context.Response.Write("{\"success\": false,\"message\": \"摇奖机会还剩 " + 0 + " 次\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\",\"remainTimes\":\"0\"}");
                        return;
                    }

                    UserErnieInfo ueModel = new UserErnieInfo();
                    ueModel.UserId          = userId;
                    ueModel.ErnieId         = ernieModel.ErnieId;
                    ueModel.LastUpdatedDate = DateTime.Now;
                    ueModel.WinGold         = int.Parse(gold) * int.Parse(times);
                    ueModel.WinSilver       = int.Parse(silver) * int.Parse(times);

                    ueBll.Insert(ueModel);

                    UserBaseQueueClient ubqClient = new UserBaseQueueClient();
                    TygaSoft.Services.HnztcQueueService.UserLevelInfo userLevelInfo = new TygaSoft.Services.HnztcQueueService.UserLevelInfo();
                    userLevelInfo.UserId        = userId;
                    userLevelInfo.IsReduce      = false;
                    userLevelInfo.TotalGold     = ueModel.WinGold;
                    userLevelInfo.TotalSilver   = ueModel.WinSilver;
                    userLevelInfo.TotalIntegral = 0;
                    ubqClient.SaveUserLevel(userLevelInfo);

                    scope.Complete();

                    remainTimes = remainTimes - 1;
                }

                context.Response.Write("{\"success\": true,\"message\": \"摇奖机会还剩 " + remainTimes + " 次\",\"gold\": \"" + gold + "\",\"silver\": \"" + silver + "\",\"times\": \"" + times + "\",\"remainTimes\":\"" + remainTimes + "\"}");
            }
            else
            {
                context.Response.Write("{\"success\": true,\"message\": \"\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\"}");
            }
        }
Example #24
0
        private void SaveProduct(HttpContext context)
        {
            string  Id             = context.Request.Form["ctl00$cphMain$hId"].Trim();
            string  sProductName   = context.Request.Form["ctl00$cphMain$txtProductName"].Trim();
            string  sSubTitle      = context.Request.Form["ctl00$cphMain$txtSubTitle"].Trim();
            decimal dOriginalPrice = 0;
            decimal dProductPrice  = 0;
            float   discount       = 0;

            decimal.TryParse(context.Request.Form["ctl00$cphMain$txtOriginalPrice"].Trim(), out dOriginalPrice);
            decimal.TryParse(context.Request.Form["ctl00$cphMain$txtProductPrice"].Trim(), out dProductPrice);
            float.TryParse(context.Request.Form["ctl00$cphMain$txtDiscount"].Trim(), out discount);
            string sDiscountDescri = context.Request.Form["ctl00$cphMain$txtDiscountDescri"].Trim();
            int    stockNum        = 0;

            int.TryParse(context.Request.Form["ctl00$cphMain$txtStockNum"].Trim(), out stockNum);
            string sProductPictureId = context.Request.Form["productPictureId"].Trim();
            Guid   productPictureId  = Guid.Empty;

            Guid.TryParse(sProductPictureId, out productPictureId);
            string sCategoryId = context.Request.Form["categoryId"].Trim();
            Guid   categoryId  = Guid.Empty;

            Guid.TryParse(sCategoryId, out categoryId);
            string sBrandId = context.Request.Form["brandId"].Trim();
            Guid   brandId  = Guid.Empty;

            Guid.TryParse(sBrandId, out brandId);
            Guid customMenuId = Guid.Empty;

            Guid.TryParse(context.Request.Form["customMenuId"].Trim(), out customMenuId);
            string sOtherPicture = context.Request.Form["otherPic"].Trim();
            string sSizeItem     = context.Request.Form["sizeItem"].Trim();
            string sSizePicture  = context.Request.Form["sizePicture"].Trim();
            string sPayOption    = "";

            string content = context.Request.Form["txtContent"].Trim();

            content = HttpUtility.HtmlDecode(content);
            Guid gId = Guid.Empty;

            if (Id != "")
            {
                Guid.TryParse(Id, out gId);
            }

            ProductInfo model = new ProductInfo();

            model.Id               = gId;
            model.UserId           = WebCommon.GetUserId();
            model.LastUpdatedDate  = DateTime.Now;
            model.ProductName      = sProductName;
            model.SubTitle         = sSubTitle;
            model.OriginalPrice    = dOriginalPrice;
            model.ProductPrice     = dProductPrice;
            model.Discount         = discount;
            model.DiscountDescri   = sDiscountDescri;
            model.ProductPictureId = productPictureId;
            model.StockNum         = stockNum;
            model.CustomMenuId     = customMenuId;

            Product         bll   = new Product();
            ProductItem     piBll = new ProductItem();
            CategoryProduct cpBll = new CategoryProduct();
            BrandProduct    bpBll = new BrandProduct();

            ProductItemInfo piModel = new ProductItemInfo();

            piModel.OtherPicture = sOtherPicture;
            piModel.SizeItem     = sSizeItem;
            piModel.SizePicture  = sSizePicture;
            piModel.PayOption    = sPayOption;
            piModel.CustomAttr   = string.Empty;
            piModel.Descr        = content;
            piModel.ProductId    = gId;

            int effect = -1;

            if (!gId.Equals(Guid.Empty))
            {
                bll.Update(model);
                piBll.Update(piModel);

                CategoryProductInfo cpModel = cpBll.GetModel(gId);
                BrandProductInfo    bpModel = bpBll.GetModel(gId);

                #region 所属分类

                if (!categoryId.Equals(Guid.Empty))
                {
                    if (cpModel == null)
                    {
                        cpModel            = new CategoryProductInfo();
                        cpModel.ProductId  = gId;
                        cpModel.CategoryId = categoryId;
                        cpBll.Insert(cpModel);
                    }
                    else
                    {
                        if (!cpModel.CategoryId.Equals(categoryId))
                        {
                            cpModel.CategoryId = categoryId;
                            cpBll.Update(cpModel);
                        }
                    }
                }
                else
                {
                    if (cpModel != null)
                    {
                        cpBll.Delete(gId, cpModel.CategoryId);
                    }
                }

                #endregion
                #region 所属品牌

                if (!brandId.Equals(Guid.Empty))
                {
                    if (bpModel == null)
                    {
                        bpModel           = new BrandProductInfo();
                        bpModel.ProductId = gId;
                        bpModel.BrandId   = brandId;
                        bpBll.Insert(bpModel);
                    }
                    else
                    {
                        if (!bpModel.BrandId.Equals(brandId))
                        {
                            bpModel.BrandId = brandId;
                            bpBll.Update(bpModel);
                        }
                    }
                }
                else
                {
                    if (bpModel != null)
                    {
                        bpBll.Delete(gId, bpModel.BrandId);
                    }
                }

                #endregion

                effect = 1;
            }
            else
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    Guid productId = bll.Insert(model);
                    piModel.ProductId = productId;
                    piBll.Insert(piModel);
                    if (!categoryId.Equals(Guid.Empty))
                    {
                        CategoryProductInfo cpModel = new CategoryProductInfo();
                        cpModel.CategoryId = categoryId;
                        cpModel.ProductId  = productId;
                        cpBll.Insert(cpModel);
                    }
                    if (!brandId.Equals(Guid.Empty))
                    {
                        BrandProductInfo bpModel = new BrandProductInfo();
                        bpModel.BrandId   = brandId;
                        bpModel.ProductId = productId;
                        bpBll.Insert(bpModel);
                    }

                    effect = 1;

                    scope.Complete();
                }
            }

            if (effect != 1)
            {
                context.Response.Write("{\"success\": false,\"message\": \"操作失败,请正确输入\"}");
                return;
            }

            context.Response.Write("{\"success\": true,\"message\": \"操作成功\"}");
        }
Example #25
0
        private void ImportProduct(HttpContext context, HttpPostedFile file)
        {
            var dt  = OpenXmlHelper.Import(file.InputStream);
            var drc = dt.Rows;

            if (drc.Count == 0)
            {
                context.Response.Write(ResResult.ResJsonString(false, MC.Import_NotDataError, ""));
                return;
            }

            var currTime = DateTime.Now;
            var list     = new List <ImportProductInfo>();

            foreach (DataRow dr in drc)
            {
                var sort = 0;
                if (dr["排序"] != null)
                {
                    Int32.TryParse(dr["排序"].ToString(), out sort);
                }

                var modelInfo = new ImportProductInfo();
                modelInfo.Sort         = sort;
                modelInfo.Coded        = dr["物料代码"].ToString().Trim();
                modelInfo.Name         = dr["物料名称"].ToString().Trim();
                modelInfo.FullName     = dr["全名"].ToString().Trim();
                modelInfo.SpeModels    = dr["规格型号"].ToString().Trim();
                modelInfo.Remark       = dr["备注"].ToString().Trim();
                modelInfo.CodeItems    = modelInfo.Coded.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                modelInfo.CodeItemsLen = modelInfo.CodeItems.Length;

                if (string.IsNullOrWhiteSpace(modelInfo.Coded) || string.IsNullOrWhiteSpace(modelInfo.Name))
                {
                    throw new ArgumentException("存在物料代码或物料名称为空字符串的行,请核对后再重试!");
                }
                modelInfo.IsCategory = modelInfo.Remark.Contains("类");

                list.Add(modelInfo);
            }

            var cBll    = new Category();
            var pBll    = new Product();
            var okIndex = 0;
            var userId  = WebCommon.GetUserId();

            var categoryList = list.Where(m => m.IsCategory).OrderBy(m => m.CodeItemsLen);
            var productList  = list.Where(m => !m.IsCategory).OrderBy(m => m.CodeItemsLen);
            var categoryRoot = cBll.GetRootModel();

            var cLen = categoryList.Count();
            var pLen = productList.Count();

            foreach (var item in categoryList)
            {
                var parentId = categoryRoot.Id;
                if (item.CodeItemsLen > 1)
                {
                    var parentCode = "";
                    for (var j = 0; j < (item.CodeItemsLen - 1); j++)
                    {
                        if (j > 0)
                        {
                            parentCode += ".";
                        }
                        parentCode += item.CodeItems[j];
                    }
                    var parentInfo = cBll.GetModelByCode(parentCode);
                    if (parentInfo != null)
                    {
                        parentId = parentInfo.Id;
                    }
                }
                var categoryInfo = cBll.GetModelByCode(item.Coded);
                if (categoryInfo == null)
                {
                    var currId = Guid.NewGuid();
                    categoryInfo = new CategoryInfo(currId, userId, parentId, item.Coded, item.Name, string.Format("{0},{1}", currId, parentId), item.Sort, item.Remark, currTime);
                    cBll.InsertByOutput(categoryInfo);
                    okIndex++;
                }
                var currCategoryProductList = productList.Where(m => m.Coded.StartsWith(item.Coded) && m.CodeItemsLen == (item.CodeItemsLen + 1));
                if (currCategoryProductList != null && currCategoryProductList.Count() > 0)
                {
                    foreach (var pItem in currCategoryProductList)
                    {
                        if (!pBll.IsExistCode(pItem.Coded, Guid.Empty))
                        {
                            var productInfo = new ProductInfo(Guid.NewGuid(), userId, categoryInfo.Id, Guid.Empty, pItem.Coded, pItem.Name, pItem.FullName, pItem.SpeModels, 0, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, pItem.Sort, pItem.Remark, false, currTime);
                            pBll.InsertByOutput(productInfo);
                            okIndex++;
                        }
                    }
                }
            }
            context.Response.Write(ResResult.ResJsonString(true, "导入成功", ""));
        }
Example #26
0
        public string SaveOrderScan(string orderCode, string customerCode, string orderStep, string loginId, string deviceId, string latlng)
        {
            try
            {
                new CustomException(string.Format("SaveOrderScan--orderCode:{0}--customerCode:{1}--orderStep:{2}--loginId:{3}--deviceId:{4}--latlng:{5}", orderCode, customerCode, orderStep, loginId, deviceId, latlng));

                orderCode    = orderCode.Trim();
                customerCode = customerCode.Trim();
                orderStep    = orderStep.Trim();
                loginId      = loginId.Trim();
                deviceId     = deviceId.Trim();
                latlng       = latlng.Trim();
                var ip              = HttpClientHelper.GetClientIp(HttpContext.Current);
                var currTime        = DateTime.Now;
                var latlngPlace     = string.Empty;
                var ipPlace         = string.Empty;
                var orderId         = Guid.Empty;
                var staffCodeOfTake = string.Empty;
                var staffCode       = string.Empty;
                var takeTime        = DateTime.Parse("1754-01-01");
                var reachTime       = takeTime;
                if (orderStep == "已取件")
                {
                    staffCode = loginId;
                    takeTime  = currTime;
                }
                else if (orderStep == "已送达")
                {
                    staffCodeOfTake = loginId;
                    reachTime       = currTime;
                }


                var oBll         = new OrderMake();
                var opBll        = new OrderProcess();
                var effect       = 0;
                var oldOrderInfo = oBll.GetModel(orderCode, customerCode);
                if (oldOrderInfo != null)
                {
                    orderId = oldOrderInfo.Id;
                    if (orderStep == "已送达")
                    {
                        oldOrderInfo.StaffCodeOfTake = staffCodeOfTake;
                        oldOrderInfo.ReachTime       = reachTime;
                        oBll.Update(oldOrderInfo);
                    }
                }
                else
                {
                    var userId = WebCommon.GetUserId();
                    if (userId.Equals(Guid.Empty))
                    {
                        throw new ArgumentException(MC.Login_NotExist);
                    }
                    var appCode = Auth.AppCode;
                    var fuInfo  = new FeatureUser().GetModel(userId, "UserProfile");
                    if (fuInfo != null)
                    {
                        appCode = fuInfo.SiteCode;
                    }

                    orderId      = Guid.NewGuid();
                    oldOrderInfo = new OrderMakeInfo(orderId, appCode, userId, customerCode, orderCode, "", "", "", "", "", "", "", staffCode, staffCodeOfTake, takeTime, reachTime, "", "", 0, 0, 0, 0, 0, "", "", currTime, currTime);
                    effect       = oBll.InsertByOutput(oldOrderInfo);
                }
                var opInfo    = new OrderProcessInfo(Guid.Empty, orderId, loginId, orderStep, "", deviceId, latlng, latlngPlace, ip, ipPlace, currTime, currTime);
                var oldOpInfo = opBll.GetModel(orderId, orderStep);
                if (oldOpInfo != null)
                {
                    opInfo.Id       = oldOpInfo.Id;
                    opInfo.Pictures = oldOpInfo.Pictures;
                    if (oldOpInfo.Ip == ip)
                    {
                        opInfo.IpPlace = oldOpInfo.IpPlace;
                    }
                    if (oldOpInfo.Latlng == latlng)
                    {
                        opInfo.LatlngPlace = oldOpInfo.LatlngPlace;
                    }
                    effect = opBll.Update(opInfo);
                }
                else
                {
                    opInfo.Id = Guid.NewGuid();
                    effect    = opBll.InsertByOutput(opInfo);
                }
                if (string.IsNullOrWhiteSpace(opInfo.IpPlace) || string.IsNullOrWhiteSpace(opInfo.LatlngPlace))
                {
                    new RunQueueAsyn().Insert(new RunQueueInfo(EnumData.EnumRunQueue.BaiduMapRestApi.ToString(), string.Format(@"{{""Latlng"":""{0}"",""Ip"":""{1}"",""OrderProcessId"":""{2}""}}", latlng, ip, opInfo.Id), EnumData.EnumRunQueue.BaiduMapRestApi.ToString(), 0));
                }
                if (effect > 0)
                {
                    return(ResResult.ResJsonString(true, "", opInfo.Id));
                }
                else
                {
                    return(ResResult.ResJsonString(false, MC.M_Save_Error, ""));
                }
            }
            catch (Exception ex)
            {
                new CustomException("SaveOrderScan--", ex);
                return(ResResult.ResJsonString(false, ex.Message, ""));
            }
        }
        public void SaveActivityPlayerNew(HttpContext context)
        {
            try
            {
                string id             = context.Request.Form["ctl00$cphMain$hId"].Trim();
                string sActivityId    = context.Request.Form["ctl00$cphMain$asId"].Trim();
                string sName          = context.Request.Form["ctl00$cphMain$txtName"].Trim();
                string sAge           = context.Request.Form["ctl00$cphMain$txtAge"].Trim();
                string sOccupation    = context.Request.Form["ctl00$cphMain$txtOccupation"].Trim();
                string sPhone         = context.Request.Form["ctl00$cphMain$txtPhone"].Trim();
                string sLocation      = context.Request.Form["ctl00$cphMain$txtLocation"].Trim();
                string sProfessional  = context.Request.Form["ctl00$cphMain$txtProfessional"].Trim();
                string sDescr         = context.Request.Form["ctl00$cphMain$txtDescr"].Trim();
                string sPictureIdList = context.Request.Form["pictureId"].TrimEnd(',');
                string sVoteCount     = context.Request.Form["ctl00$cphMain$txtActualVoteCount"].Trim();
                sVoteCount = sVoteCount == "" ? "0" : sVoteCount;
                string sVirtualVoteCount = context.Request.Form["ctl00$cphMain$txtUpdateVoteCount"].Trim();
                sVirtualVoteCount = sVirtualVoteCount == "" ? "0" : sVirtualVoteCount;
                string sIsDisable = context.Request.Form["isDisable"].Trim();

                ActivitySubjectNew     bllAS = new ActivitySubjectNew();
                ActivitySubjectNewInfo info  = new ActivitySubjectNewInfo();
                info = bllAS.GetModel(sActivityId);

                if (info.SignUpCount >= info.MaxVoteCount)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"报名数已达上限\"}");
                    return;
                }

                Guid gId = Guid.Empty;
                if (id != "")
                {
                    Guid.TryParse(id, out gId);
                }
                Guid activityId = Guid.Empty;
                Guid.TryParse(sActivityId, out activityId);

                ActivityPlayerNewInfo model = new ActivityPlayerNewInfo();
                model.LastUpdatedDate = DateTime.Now;
                model.Remark          = "";

                model.Id               = gId;
                model.ActivityId       = activityId;
                model.UserId           = WebCommon.GetUserId();
                model.Named            = sName;
                model.Age              = int.Parse(sAge);
                model.Occupation       = sOccupation;
                model.Phone            = sPhone;
                model.Location         = sLocation;
                model.Professional     = sProfessional;
                model.Descr            = sDescr;
                model.VoteCount        = int.Parse(sVoteCount);
                model.VirtualVoteCount = int.Parse(sVirtualVoteCount);
                model.IsDisable        = bool.Parse(sIsDisable);

                ActivityPlayerNew bll   = new ActivityPlayerNew();
                PlayerPictureNew  bllPP = new PlayerPictureNew();
                int effect = -1;

                if (!gId.Equals(Guid.Empty))
                {
                    effect = bll.Update(model);
                    if (effect > 0)
                    {
                        bllPP.Delete(model.Id);
                        int index = 1;
                        foreach (string sPictureId in sPictureIdList.Split(','))
                        {
                            PlayerPictureNewInfo infoPP = new PlayerPictureNewInfo();
                            Guid pictureId = Guid.Empty;
                            Guid.TryParse(sPictureId, out pictureId);
                            infoPP.PlayerId  = model.Id;
                            infoPP.PictureId = pictureId;
                            infoPP.Sort      = index;
                            infoPP.IsHeadImg = index == 1 ? true : false;
                            bllPP.Insert(infoPP);
                            index++;
                        }
                    }
                }
                else
                {
                    Guid playerId = bll.InsertByOutput(model);
                    if (!playerId.Equals(Guid.Empty))
                    {
                        effect = 1;
                        int index = 1;
                        foreach (string sPictureId in sPictureIdList.Split(','))
                        {
                            PlayerPictureNewInfo infoPP = new PlayerPictureNewInfo();
                            Guid pictureId = Guid.Empty;
                            Guid.TryParse(sPictureId, out pictureId);
                            infoPP.PlayerId  = playerId;
                            infoPP.PictureId = pictureId;
                            infoPP.Sort      = index;
                            infoPP.IsHeadImg = index == 1 ? true : false;
                            bllPP.Insert(infoPP);
                            index++;
                        }
                    }
                }

                if (effect == 110)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}");
                    return;
                }

                if (effect < 1)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Error + "\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"" + MessageContent.Submit_Success + "\"}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.AlertTitle_Ex_Error + ":" + ex.Message + "\"}");
            }
        }
Example #28
0
        public ResResultModel SaveCustomer(CustomerFmModel model)
        {
            try
            {
                Guid Id = Guid.Empty;
                if (model.Id != null)
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                DateTime cooperateTime = DateTime.MinValue;
                if (model.CooperateTime != null)
                {
                    DateTime.TryParse(model.CooperateTime, out cooperateTime);
                }
                if (cooperateTime == DateTime.MinValue)
                {
                    cooperateTime = DateTime.Parse("1754-01-01");
                }
                DateTime agreementTimeout = DateTime.MinValue;
                if (model.AgreementTimeout != null)
                {
                    DateTime.TryParse(model.AgreementTimeout, out agreementTimeout);
                }
                if (agreementTimeout == DateTime.MinValue)
                {
                    agreementTimeout = DateTime.Parse("1754-01-01");
                }
                decimal joinPrice = 0;
                if (model.JoinPrice != null)
                {
                    decimal.TryParse(model.JoinPrice, out joinPrice);
                }
                string discountAbout = string.Empty;
                if (model.DiscountAbout != null)
                {
                    discountAbout = model.DiscountAbout.Trim();
                }
                var currTime = DateTime.Now;

                CustomProfileCommon Profile = new CustomProfileCommon();
                var upi = JsonConvert.DeserializeObject <UserProfileInfo>(Profile.UserInfo);

                var modelInfo = new CustomerInfo(Id, upi.SiteCode, WebCommon.GetUserId(), model.Coded, model.Named, model.ShortName, model.ContactMan, model.ContactPhone, model.TelPhone, model.Fax, model.PostCode, model.Address, model.CityName, model.TradeName, cooperateTime, agreementTimeout, joinPrice, discountAbout, model.PayWay, model.StaffCode, model.Remark, currTime, currTime);

                var bll    = new Customer();
                int effect = -1;

                if (Id.Equals(Guid.Empty))
                {
                    effect = bll.Insert(modelInfo);
                }
                else
                {
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, ""));
                }

                return(ResResult.Response(true, "", ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Example #29
0
        public ResResultModel SavePandianAsset(PdaPandianAssetFmModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, "请求参数集为空字符串", ""));
                }
                var userId = WebCommon.GetUserId();
                if (userId.Equals(Guid.Empty))
                {
                    return(ResResult.Response((int)ResCode.未登录, MC.Login_NotExist, ""));
                }
                var depmtId = new Staff().GetOrgId(userId);

                var pandianId = Guid.Empty;
                if (!Guid.TryParse(model.PandianId, out pandianId))
                {
                    return(ResResult.Response(false, "参数PandianId值为“" + model.PandianId + "”无效", ""));
                }

                var currTime = DateTime.Now;
                var gEmpty   = Guid.Empty;
                var minDate  = DateTime.Parse("1754-01-01");

                var pdaBll = new PandianAsset();
                var pBll   = new Product();
                var pdBll  = new Pandian();
                var effect = 0;

                foreach (var item in model.ItemList)
                {
                    var assetId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.AssetId))
                    {
                        Guid.TryParse(item.AssetId, out assetId);
                    }
                    var categoryId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.CategoryId))
                    {
                        Guid.TryParse(item.CategoryId, out categoryId);
                    }
                    var useDepmtId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.UseDepmtId))
                    {
                        Guid.TryParse(item.UseDepmtId, out useDepmtId);
                    }
                    var mgrDepmtId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.MgrDepmtId))
                    {
                        Guid.TryParse(item.MgrDepmtId, out mgrDepmtId);
                    }
                    var storeLocationId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.StoreLocationId))
                    {
                        Guid.TryParse(item.StoreLocationId, out storeLocationId);
                    }

                    ProductInfo productInfo = null;
                    if (item.Status == (int)EnumPandianAssetStatus.盘盈)
                    {
                        #region 盘盈

                        productInfo = new ProductInfo(GlobalConfig.SiteCode, userId, depmtId, Guid.NewGuid(), categoryId, item.Barcode, item.AssetName, item.Barcode, item.SpecModel, 1, 0, 0, item.Unit, 0, string.Empty, string.Empty, string.Empty, minDate, "1754-01-01", string.Empty, useDepmtId, item.UsePerson, mgrDepmtId, storeLocationId, string.Empty, item.Status, 0, true, currTime, currTime);
                        effect     += pBll.InsertByOutput(productInfo);
                        var pandianAssetInfo = new PandianAssetInfo(pandianId, productInfo.Id, productInfo.AppCode, productInfo.UserId, productInfo.DepmtId, gEmpty, gEmpty, gEmpty, string.Empty, 0, item.Remark, item.Status, currTime, currTime);
                        pdaBll.Insert(pandianAssetInfo);

                        #endregion
                    }
                    else
                    {
                        #region 非盘盈

                        productInfo = pBll.GetModel(assetId);
                        var pandianAssetInfo = pdaBll.GetModel(pandianId, assetId);
                        if (!useDepmtId.Equals(Guid.Empty) && !useDepmtId.Equals(productInfo.UseDepmtId))
                        {
                            pandianAssetInfo.LastUseDepmtId = useDepmtId;
                        }
                        if (!mgrDepmtId.Equals(Guid.Empty) && !mgrDepmtId.Equals(productInfo.MgrDepmtId))
                        {
                            pandianAssetInfo.LastMgrDepmtId = mgrDepmtId;
                        }
                        if (!storeLocationId.Equals(Guid.Empty) && !storeLocationId.Equals(productInfo.StoragePlaceId))
                        {
                            pandianAssetInfo.LastStoragePlaceId = storeLocationId;
                        }
                        if (!string.IsNullOrEmpty(item.UsePerson) && item.UsePerson != productInfo.UsePersonName)
                        {
                            pandianAssetInfo.LastUsePerson = item.UsePerson;
                        }
                        pandianAssetInfo.Status = item.Status;

                        effect += pdaBll.Update(pandianAssetInfo);

                        #endregion
                    }
                }

                if (effect < 1)
                {
                    return(ResResult.Response(false, "操作失败", ""));
                }

                return(ResResult.Response(true, "调用成功", ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }