Exemple #1
0
        public ActionResult InvIndex(string userId)
        {
            marketShopApp shopApp = new marketShopApp();
            List <marketSalesShopEntity> shops = new List <marketSalesShopEntity>();

            shops.AddRange(shopApp.getShopByUserId(userId));
            marketSalesApp      userapp  = new marketSalesApp();
            UserInfoResultModel userinfo = userapp.GetUserInfo(userId);

            shops.AddRange(shopApp.getAllShopByEmpCode(userinfo.SalesNo));

            var t = from e in shops
                    group e by new { Code = e.CUSTOMER_CODE, Name = e.CUSTOMER_NAME } into g
                select new CusModel {
                CustomerCode = g.Key.Code, CustomerName = g.Key.Name
            };

            /*
             * marketShopApp shopApp = new marketShopApp();
             * List<marketSalesShopEntity> shops = shopApp.getShopByUserId(userId);
             * List<CusModel> vModel = new List<CusModel>();
             * foreach (var shop in shops)
             * {
             *  if (vModel.Find(p => p.CustomerCode.Equals(shop.CUSTOMER_CODE)) == null)
             *  {
             *      vModel.Add(new CusModel() { CustomerCode = shop.CUSTOMER_CODE, CustomerName = shop.CUSTOMER_NAME });
             *  }
             * }*/
            ViewData["vModel"] = t.OrderBy(p => p.CustomerName).ToList();;
            ViewData["userId"] = userId;
            return(View("InvQinView"));
        }
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();
            var salesApp    = new marketSalesApp();

            string userName = salesApp.findUserNameBy(context.UserName);

            if (userName == null)
            {
                context.SetError("invalid_grant", "用户名不正确。");
                return;
            }
            ApplicationUser user = await userManager.FindAsync(userName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", "用户密码不正确。");
                return;
            }

            ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                OAuthDefaults.AuthenticationType);

            ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                  CookieAuthenticationDefaults.AuthenticationType);

            AuthenticationProperties properties = CreateProperties(user.UserName);
            AuthenticationTicket     ticket     = new AuthenticationTicket(oAuthIdentity, properties);

            context.Validated(ticket);
            context.Request.Context.Authentication.SignIn(cookiesIdentity);
        }
Exemple #3
0
        public ActionResult cmQty(sQtyModel model)
        {
            PSIApp         psiApp   = new PSIApp();
            marketSalesApp salesApp = new marketSalesApp();

            psiApp.cQty(model.prodect, model.userid, model.userid, salesApp.getOrginfoBySubId(model.orgId, "BU").id, model.orgId, model.qty, model.day, model.BrandCode);
            return(Content("提交成功!"));
        }
        public UserInfoModel GetUserInfo()
        {
            try {
                marketSalesApp app = new marketSalesApp();

                UserInfoResultModel t = app.GetUserInfo(User.Identity.GetUserId());

                UserInfoModel model = new UserInfoModel
                {
                    No              = t.No,
                    Name            = t.Name,
                    PhoneNumber     = t.PhoneNumber,
                    SalesNo         = t.SalesNo
                    , POP_TYPE_CODE = t.POP_TYPE_CODE, id = User.Identity.GetUserId(),

                    PICUrl = "https://iretailerapp.flnet.com/userPic.jpg"

                             /// ShopNo = t.ShopNo
                };
                String         appKey     = "y745wfm8y1y6v";
                String         appSecret  = "njmewTIin5p";
                RongCloud      rongcloud  = RongCloud.getInstance(appKey, appSecret);
                JsonSerializer serializer = new JsonSerializer();


                // 获取 Token 方法
                TokenReslut usergetTokenResult = rongcloud.user.getToken(model.id, model.Name, model.PICUrl);
                if (usergetTokenResult.getCode() == 200)
                {
                    model.IMToken = usergetTokenResult.getToken();
                }

                marketShopApp shopApp = new marketShopApp();
                List <marketSalesShopEntity> shops = shopApp.getShopByUserId(User.Identity.GetUserId());
                model.Shops = new List <UserShopInfoModel>();
                foreach (marketSalesShopEntity shop in shops)
                {
                    UserShopInfoModel shopmodel = new UserShopInfoModel()
                    {
                        CustomerCode = shop.CUSTOMER_CODE, CustomerName = shop.CUSTOMER_NAME, ShopCode = shop.SHOP_CODE, ShopName = shop.SHOP_NAME, LATITUDE = shop.LATITUDE.Value, LONGITUDE = shop.LONGITUDE.Value
                    };
                    model.Shops.Add(shopmodel);
                }
                return(model);
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent(ex.ToString()),
                    ReasonPhrase = "error"
                };
                throw new HttpResponseException(resp);
            }
        }
        public UserInfoModel UserInfoTest()
        {
            marketSalesApp app = new marketSalesApp();

            UserInfoResultModel t = app.GetUserInfo();

            UserInfoModel model = new UserInfoModel
            {
                No = t.No,
                /// ShopNo = t.ShopNo
            };

            return(model);
        }
Exemple #6
0
        public ActionResult shTag(shTagModel model)
        {
            if (model.type == 1)
            {
                JS5_S12_SALES_TARGET_BILL_DTableAdapter dad = new JS5_S12_SALES_TARGET_BILL_DTableAdapter();
                int totalQty = (int)dad.QtyQuery(model.BrandCode, model.PorgId, model.prodect, model.bllNo);
                //var tagEnt = tagAd.GetDataByNo(model.bllNo);
                if (totalQty <= 0)
                {
                    return(Content("分配失败,未找到目标!"));
                }
                marketSalesApp salesApp = new marketSalesApp();
                //查询城市列表
                //JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter orgInfo = new JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter();

                // List<DataSynchronizationLib.SCM.JS5_S12_SALES_MANAGE_ORG_INFORow> citys = new List<DataSynchronizationLib.SCM.JS5_S12_SALES_MANAGE_ORG_INFORow>();

                // var orgs = orgInfo.GetDataByPid(model.PorgId);
                //foreach (var org in orgs)
                //{

                //  foreach (var orgCity in orgInfo.GetDataByPid(org.ID))
                //{
                //  citys.Add(orgCity);
                //}

                //}

                var    orgs   = salesApp.getOrginfoByPCode(model.PorgId, "CITY");
                PSIApp psiApp = new PSIApp();
                foreach (var org in orgs)
                {
                    int qty   = (totalQty / orgs.Count) + 1;
                    var sales = salesApp.getUserInfoByOrgId(org.id);
                    if (sales != null)
                    {
                        psiApp.shTag(model.prodect, sales.id, model.userid, model.PorgId, org.id, model.month, qty, model.BrandCode);
                    }
                }
            }
            else
            {
                PSIApp psiApp = new PSIApp();
                psiApp.shTag(model.prodect, model.userid, model.userid, model.PorgId, model.orgId, model.month, model.qty, model.BrandCode);
            }

            return(Content("分配成功!"));
        }
Exemple #7
0
        public PartialViewResult CustomerView(string userId)
        {
            marketShopApp shopApp = new marketShopApp();
            List <marketSalesShopEntity> shops = new List <marketSalesShopEntity>();

            shops.AddRange(shopApp.getShopByUserId(userId));
            marketSalesApp      userapp  = new marketSalesApp();
            UserInfoResultModel userinfo = userapp.GetUserInfo(userId);

            shops.AddRange(shopApp.getAllShopByEmpCode(userinfo.SalesNo));

            var t = from e in shops
                    group e by new { Code = e.CUSTOMER_CODE, Name = e.CUSTOMER_NAME } into g
                select new CusModel {
                CustomerCode = g.Key.Code, CustomerName = g.Key.Name
            };

            return(PartialView("_InvQinCustomerPartialPage", t.OrderBy(p => p.CustomerName).ToList()));
        }
        public async Task <IHttpActionResult> UpdateUserInfo(UpdateBindingModel model)
        {
            if (!this.RequestContext.IsLocal)
            {
                return(BadRequest("API禁止被访问"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var    salesApp = new marketSalesApp();
            string userName = salesApp.findUserNameByEmpCode(model.EMPLOYEE_CODE);

            if (userName == null)
            {
                return(BadRequest("用户不存在"));
            }
            ApplicationUser user   = UserManager.FindByName(userName);
            IdentityResult  result = await UserManager.ChangePasswordAsync(user.Id, user.LOGIN_PASSWORD,
                                                                           model.Password);

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            user.UserName       = model.EMPLOYEE_CODE;
            user.PhoneNumber    = model.PhoneNumber;
            user.Email          = model.Email;
            user.EMPLOYEE_NAME  = model.EMPLOYEE_NAME;
            user.EMPLOYEE_CODE  = model.EMPLOYEE_CODE;
            user.LOGIN_PASSWORD = model.Password;
            user.Last_sync_Time = System.DateTime.Now;
            result = await UserManager.UpdateAsync(user);

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            return(Ok());
        }
 public TaskUsers GetTaskUsers(string taskId)
 {
     try
     {
         TaskUsers users = new TaskUsers();
         users.participateUser    = new List <TaskUser>();
         users.responsibilityUser = new List <TaskUser>();
         marketSalesApp salesApp = new marketSalesApp();
         TaskPopApp     popApp   = new TaskPopApp();
         var            ents     = popApp.getTaskPop(taskId);
         foreach (var ent in ents)
         {
             if (ent.userType == 1)
             {
                 users.responsibilityUser.Add(new TaskUser()
                 {
                     userId = ent.UserId, userName = salesApp.GetUserInfo(ent.UserId).Name
                 });
             }
             else
             {
                 users.participateUser.Add(new TaskUser()
                 {
                     userId = ent.UserId, userName = salesApp.GetUserInfo(ent.UserId).Name
                 });
             }
         }
         return(users);
     }
     catch (Exception ex)
     {
         var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content      = new StringContent(ex.ToString()),
             ReasonPhrase = "error"
         };
         throw new HttpResponseException(resp);
     }
 }
        public async Task <IHttpActionResult> ModifyTask(TaskModel model)
        {
            try
            {
                String         userid   = User.Identity.GetUserId();
                marketSalesApp salesApp = new marketSalesApp();
                TaskMastApp    MastApp  = new TaskMastApp();
                MastApp.modifyTask(new TaskMastEntity()
                {
                    id            = model.id,
                    alertType     = model.alertType,
                    createdUserId = userid,
                    CustomerCode  = model.CustomerCode,
                    CustomerName  = model.CustomerName,
                    desc          = model.desc,
                    endTime       = model.endTime,
                    freqType      = model.freqType,
                    importantType = model.importantType,
                    starTime      = model.starTime,
                    taskName      = model.taskName,
                    taskType      = model.taskType,
                    taskTypeName  = model.taskTypeName,
                    fileId        = model.fileId,
                    isAll         = model.isAll,
                    modifyTime    = System.DateTime.Now, fileName = model.fileName, fileExt = model.fileExt,
                    taskSource    = salesApp.GetUserInfo(userid).Name, Location = model.Location, address = model.address
                });
                TaskPopApp popApp = new TaskPopApp();
                popApp.deletePop(model.id);
                popApp.createTaskPop(new TaskPopEntity()
                {
                    id = System.Guid.NewGuid().ToString(), status = 2, taskId = model.id, UserId = userid, userType = 1
                });
                foreach (string pUserid in model.responsibilityUser)
                {
                    if (pUserid.Equals(userid))
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = model.id, UserId = pUserid, userType = 1
                        });
                    }
                    else
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 1, taskId = model.id, UserId = pUserid, userType = 1
                        });
                    }
                }
                foreach (string pUserid in model.participateUser)
                {
                    if (pUserid.Equals(userid))
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = model.id, UserId = pUserid, userType = 2
                        });
                    }
                    else
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 1, taskId = model.id, UserId = pUserid, userType = 2
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }



            return(Ok());
        }
        public List <TaskReport> GetReports()
        {
            try
            {
                marketSalesApp    salesApp = new marketSalesApp();
                List <TaskReport> models   = new List <TaskReport>();
                TaskReportApp     app      = new TaskReportApp();
                var ents = app.getReports(User.Identity.GetUserId());
                foreach (var ent in ents)
                {
                    var model = new TaskReport()
                    {
                        id         = ent.id,
                        context    = ent.context,
                        reportTime = ent.reportTime.Value,
                        reportType = ent.reportType,
                        state      = ent.state,
                        title      = ent.title,
                        userId     = ent.userId,
                        userName   = salesApp.GetUserInfo(ent.userId).Name,

                        users = new TaskReportUsers()
                        {
                            AllowUser = new List <TaskUser>(), ReadUser = new List <TaskUser>()
                        }
                    };
                    if (ent.fileId != null)
                    {
                        string patch = ent.reportTime.Value.ToString("yyyyMM");
                        model.fileId   = ent.fileId;
                        model.fileExt  = ent.fileExt;
                        model.fileName = ent.fileName;
                        model.fileUrl  = "https://iretailerapp.flnet.com/Messages/APPUploadFile/" + patch + "/" + ent.fileId + "." + ent.fileExt;
                    }
                    if (ent.audoFileId != null)
                    {
                        string patch = ent.reportTime.Value.ToString("yyyyMM");
                        model.audoFileId  = ent.audoFileId;
                        model.audoFileUrl = "https://iretailerapp.flnet.com/Messages/APPUploadFile/" + patch + "/" + ent.audoFileId + ".aac";
                    }
                    var users = app.getReportUsers(ent.id);

                    foreach (var user in users)
                    {
                        if (user.userType == 1)
                        {
                            model.users.AllowUser.Add(new TaskUser()
                            {
                                userId = user.userId, userName = salesApp.GetUserInfo(user.userId).Name
                            });
                        }
                        else
                        {
                            model.users.ReadUser.Add(new TaskUser()
                            {
                                userId = user.userId, userName = salesApp.GetUserInfo(user.userId).Name
                            });
                        }
                    }
                    models.Add(model);
                }
                return(models);
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent(ex.ToString()),
                    ReasonPhrase = "error"
                };
                throw new HttpResponseException(resp);
            }
        }
        public async Task <IHttpActionResult> CreateUser(RegisterBindingModel model)
        {
            try
            {
                if (!this.RequestContext.IsLocal)
                {
                    return(BadRequest("API禁止被访问"));
                }


                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var salesApp = new marketSalesApp();



                string userName = salesApp.findUserNameByEmpCode(model.EMPLOYEE_CODE);
                if (userName != null)
                {
                    ApplicationUser user    = UserManager.FindByName(userName);
                    IdentityResult  result1 = await UserManager.ChangePasswordAsync(user.Id, user.LOGIN_PASSWORD,
                                                                                    model.Password);

                    if (!result1.Succeeded)
                    {
                        return(GetErrorResult(result1));
                    }

                    user.UserName       = model.EMPLOYEE_CODE;
                    user.PhoneNumber    = model.PhoneNumber;
                    user.Email          = model.Email;
                    user.EMPLOYEE_NAME  = model.EMPLOYEE_NAME;
                    user.EMPLOYEE_CODE  = model.EMPLOYEE_CODE;
                    user.LOGIN_PASSWORD = model.Password;
                    user.Last_sync_Time = System.DateTime.Now;
                    user.active         = model.Active;
                    result1             = await UserManager.UpdateAsync(user);

                    if (!result1.Succeeded)
                    {
                        return(GetErrorResult(result1));
                    }
                }
                else
                {
                    ApplicationUser user = new ApplicationUser()
                    {
                        UserName       = model.EMPLOYEE_CODE,
                        PhoneNumber    = model.PhoneNumber,
                        Email          = model.Email,
                        EMPLOYEE_NAME  = model.EMPLOYEE_NAME,
                        EMPLOYEE_CODE  = model.EMPLOYEE_CODE,
                        active         = model.Active,
                        LOGIN_PASSWORD = model.Password,
                        Last_sync_Time = System.DateTime.Now
                    };
                    IdentityResult result = await UserManager.CreateAsync(user, model.Password);

                    if (!result.Succeeded)
                    {
                        return(GetErrorResult(result));
                    }
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #13
0
        // GET: PSI
        public ActionResult Index(string userId)
        {
            if (userId.Equals(null))
            {
                return(View("_NoFunction"));
            }
            // UserRoleAd.GetDataByCode();
            marketSalesApp salesApp = new marketSalesApp();
            var            userInfo = salesApp.getUserInfoBySalesNo(userId);

            if (userInfo == null)
            {
                return(View("_NoFunction"));
            }
            userId = userInfo.id;
            var           empEntitys = salesApp.getEmpOrgBySalesNo(userInfo.SalesNo);
            List <string> rolues     = new List <string>();

            foreach (var empEnt in empEntitys)
            {
                if (!rolues.Exists(p => p.Equals(empEnt.JOB_CODE)) && (empEnt.JOB_CODE.Equals("BUManager") || empEnt.JOB_CODE.Equals("Citymanager")))
                {
                    rolues.Add(empEnt.JOB_CODE);
                }
            }

            int type = 1;

            //判断用户角色
            if (rolues.Count <= 0)
            {
                return(View("_NoFunction"));
            }
            else
            {
                if (rolues.Exists(p => p.Equals("BUManager")) && rolues.Exists(p => p.Equals("Citymanager")))//表示是多角色需要进入多角色选择画面
                {
                    ViewData["userInfo"] = new userInfo()
                    {
                        userId = userInfo.id, salesCode = userInfo.SalesNo
                    };
                    return(View("_SelectRoue"));
                }
                else if (rolues.Exists(p => p.Equals("BUManager")))//进入战区长功能
                {
                    type = 1;
                }
                else//进入城市经理功能
                {
                    type = 2;
                }
            }



            PModel model = new PModel();

            model.Month = new List <KeyValueModel>();
            DateTime now = DateTime.Now;

            model.Month.Add(new KeyValueModel()
            {
                key = now.AddMonths(-2).ToString("yyyyMM"), keyValue = now.AddMonths(-2).ToString("yyyy年MM月"), isSelected = false
            });
            model.Month.Add(new KeyValueModel()
            {
                key = now.AddMonths(-1).ToString("yyyyMM"), keyValue = now.AddMonths(-1).ToString("yyyy年MM月"), isSelected = false
            });
            model.Month.Add(new KeyValueModel()
            {
                key = now.ToString("yyyyMM"), keyValue = now.ToString("yyyy年MM月"), isSelected = true
            });
            model.Month.Add(new KeyValueModel()
            {
                key = now.AddMonths(1).ToString("yyyyMM"), keyValue = now.AddMonths(1).ToString("yyyy年MM月"), isSelected = false
            });
            model.Month.Add(new KeyValueModel()
            {
                key = now.AddMonths(2).ToString("yyyyMM"), keyValue = now.AddMonths(2).ToString("yyyy年MM月"), isSelected = false
            });
            model.Brand = new List <KeyValueModel>();
            JS5_S12_BRAND_INFOTableAdapter ad = new JS5_S12_BRAND_INFOTableAdapter();
            var ents = ad.GetDataBy();

            foreach (var ent in ents)
            {
                model.Brand.Add(new KeyValueModel()
                {
                    key = ent.BRAND_CODE, keyValue = ent.BRAND_NAME, isSelected = false
                });
            }
            model.Brand.First().isSelected = true;
            model.Prodect = new List <KeyValueModel>();
            var ad2   = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter();
            var ents2 = ad2.GetDataBy();

            foreach (var ent in ents2)
            {
                model.Prodect.Add(new KeyValueModel()
                {
                    key = ent.ID, keyValue = ent.TREE_NODE_NAME, isSelected = false
                });
            }
            model.Prodect.First().isSelected = true;
            model.UserId    = userId;
            model.type      = type;
            model.salesCode = userInfo.SalesNo;
            if (type == 1)
            {
                model.OrgList = new List <KeyValueModel>();
                var orglist = salesApp.getEmpOrgBySalesNo(userInfo.SalesNo, "BUManager");
                foreach (var org in orglist)
                {
                    var orginfo = salesApp.getOrgInfo(org.ORG_ID);
                    model.OrgList.Add(new KeyValueModel()
                    {
                        key = orginfo.id, keyValue = orginfo.MANAGE_ORG_NAME
                    });
                }
                model.OrgList.First().isSelected = true;
                ViewData["VModel"] = getdata(model.Brand.First().key, model.Prodect.First().key, now.ToString("yyyyMM"), userId, type, userInfo.SalesNo, model.OrgList.First().key);
            }
            else if (type == 2)
            {
                model.CityList = new List <KeyValueModel>();
                var orglist = salesApp.getEmpOrgBySalesNo(userInfo.SalesNo, "Citymanager");
                foreach (var org in orglist)
                {
                    var orginfo = salesApp.getOrgInfo(org.ORG_ID);
                    model.CityList.Add(new KeyValueModel()
                    {
                        key = orginfo.id, keyValue = orginfo.MANAGE_ORG_NAME
                    });
                }
                model.CityList.First().isSelected = true;
                ViewData["VModel"] = getdata(model.Brand.First().key, model.Prodect.First().key, now.ToString("yyyyMM"), userId, type, userInfo.SalesNo, model.CityList.First().key);
            }



            ViewData["PModel"] = model;
            //ViewData["ValueModel"] = model;
            return(View("PSIView"));
        }
Exemple #14
0
        public ActionResult Index2(string userId, string type, string SalesNo)
        {
            int typeValue = int.Parse(type);

            PModel model = new PModel();

            model.Month = new List <KeyValueModel>();
            DateTime now = DateTime.Now;

            model.Month.Add(new KeyValueModel()
            {
                key = now.AddMonths(-2).ToString("yyyyMM"), keyValue = now.AddMonths(-2).ToString("yyyy年MM月"), isSelected = false
            });
            model.Month.Add(new KeyValueModel()
            {
                key = now.AddMonths(-1).ToString("yyyyMM"), keyValue = now.AddMonths(-1).ToString("yyyy年MM月"), isSelected = false
            });
            model.Month.Add(new KeyValueModel()
            {
                key = now.ToString("yyyyMM"), keyValue = now.ToString("yyyy年MM月"), isSelected = true
            });
            model.Month.Add(new KeyValueModel()
            {
                key = now.AddMonths(1).ToString("yyyyMM"), keyValue = now.AddMonths(1).ToString("yyyy年MM月"), isSelected = false
            });
            model.Month.Add(new KeyValueModel()
            {
                key = now.AddMonths(2).ToString("yyyyMM"), keyValue = now.AddMonths(2).ToString("yyyy年MM月"), isSelected = false
            });
            model.Brand = new List <KeyValueModel>();
            JS5_S12_BRAND_INFOTableAdapter ad = new JS5_S12_BRAND_INFOTableAdapter();
            var ents = ad.GetDataBy();

            foreach (var ent in ents)
            {
                model.Brand.Add(new KeyValueModel()
                {
                    key = ent.BRAND_CODE, keyValue = ent.BRAND_NAME, isSelected = false
                });
            }
            model.Brand.First().isSelected = true;
            model.Prodect = new List <KeyValueModel>();
            var ad2   = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter();
            var ents2 = ad2.GetDataBy();

            foreach (var ent in ents2)
            {
                model.Prodect.Add(new KeyValueModel()
                {
                    key = ent.ID, keyValue = ent.TREE_NODE_NAME, isSelected = false
                });
            }
            model.Prodect.First().isSelected = true;
            marketSalesApp salesApp          = new marketSalesApp();

            model.UserId    = userId;
            model.type      = typeValue;
            model.salesCode = SalesNo;
            if (typeValue == 1)
            {
                model.OrgList = new List <KeyValueModel>();
                var orglist = salesApp.getEmpOrgBySalesNo(SalesNo, "BUManager");
                foreach (var org in orglist)
                {
                    var orginfo = salesApp.getOrgInfo(org.ORG_ID);
                    model.OrgList.Add(new KeyValueModel()
                    {
                        key = orginfo.id, keyValue = orginfo.MANAGE_ORG_NAME
                    });
                }
                model.OrgList.First().isSelected = true;
                ViewData["VModel"] = getdata(model.Brand.First().key, model.Prodect.First().key, now.ToString("yyyyMM"), userId, typeValue, SalesNo, model.OrgList.First().key);
            }
            else if (typeValue == 2)
            {
                model.CityList = new List <KeyValueModel>();
                var orglist = salesApp.getEmpOrgBySalesNo(SalesNo, "Citymanager");
                foreach (var org in orglist)
                {
                    var orginfo = salesApp.getOrgInfo(org.ORG_ID);
                    model.CityList.Add(new KeyValueModel()
                    {
                        key = orginfo.id, keyValue = orginfo.MANAGE_ORG_NAME
                    });
                }
                model.CityList.First().isSelected = true;
                ViewData["VModel"] = getdata(model.Brand.First().key, model.Prodect.First().key, now.ToString("yyyyMM"), userId, typeValue, SalesNo, model.CityList.First().key);
            }


            ViewData["PModel"] = model;
            //ViewData["ValueModel"] = model;
            return(View("PSIView"));
        }
        public TaskModel CreateTask(TaskModel model)
        {
            try
            {
                String         userid   = User.Identity.GetUserId();
                String         taskId   = System.Guid.NewGuid().ToString();
                TaskMastApp    MastApp  = new TaskMastApp();
                marketSalesApp salesApp = new marketSalesApp();
                MastApp.createTask(new TaskMastEntity()
                {
                    id            = taskId,
                    alertType     = model.alertType,
                    createdUserId = userid,
                    CustomerCode  = model.CustomerCode,
                    CustomerName  = model.CustomerName,
                    desc          = model.desc,
                    endTime       = model.endTime,
                    freqType      = model.freqType,
                    importantType = model.importantType,
                    starTime      = model.starTime,
                    taskName      = model.taskName,
                    taskType      = model.taskType,
                    isAll         = model.isAll,
                    taskTypeName  = model.taskTypeName,
                    fileId        = model.fileId, createdTime = System.DateTime.Now, modifyTime = System.DateTime.Now,
                    taskSource    = salesApp.GetUserInfo(userid).Name,
                    fileName      = model.fileName,
                    fileExt       = model.fileExt, address = model.address, Location = model.Location
                });
                model.id = taskId;
                TaskPopApp popApp = new TaskPopApp();
                popApp.createTaskPop(new TaskPopEntity()
                {
                    id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = userid, userType = 1
                });
                foreach (string pUserid in model.responsibilityUser)
                {
                    if (pUserid.Equals(userid))
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = pUserid, userType = 1
                        });
                    }
                    else
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 1, taskId = taskId, UserId = pUserid, userType = 1
                        });
                    }
                }
                foreach (string pUserid in model.participateUser)
                {
                    if (pUserid.Equals(userid))
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = pUserid, userType = 2
                        });
                    }
                    else
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 1, taskId = taskId, UserId = pUserid, userType = 2
                        });
                    }
                }
                return(model);
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent(ex.ToString()),
                    ReasonPhrase = "error"
                };
                throw new HttpResponseException(resp);
            }



            //return Ok();
        }
Exemple #16
0
        public void insertTaskMember(List <TaskMemberDataEntity> ents, string bid)
        {
            LogApp logApp = new LogApp();

            foreach (var ent in ents)
            {
                rep.Insert(ent);
            }

            /*logApp.WriteDbLog(new LogEntity()
             * {
             *  F_Account = "",
             *  F_CreatorTime = System.DateTime.Now,
             *  F_Date = System.DateTime.Now,
             *  F_CreatorUserId = "",
             *  F_Description = "StartSend",
             *  F_Id = System.Guid.NewGuid().ToString(),
             *  F_ModuleId = "SendMessage",
             *  F_ModuleName = "SendMessage",
             *
             *
             * });
             */
            try
            {
                var shops = ents.GroupBy(p => p.shopCode);
                foreach (var shop in shops)
                {
                    string ShopCode = shop.Key;


                    var salesApp = new marketSalesApp();
                    var users    = salesApp.getGuidManByShop(ShopCode);
                    foreach (var user in users)
                    {
                        var            userinfo = salesApp.getUserInfoBySalesNo(user.sales_No);
                        string         taskId   = System.Guid.NewGuid().ToString();
                        TaskMastEntity ent      = new TaskMastEntity()
                        {
                            id                      = taskId,
                            alertType               = 1,
                            createdTime             = System.DateTime.Now,
                            createdUserId           = userinfo.id,
                            MESSAGE_BILL_NO         = bid,
                            MESSAGE_SUB_NO          = 0,
                            MESSAGE_REPLY_TYPE_CODE = "001",
                            MESSAGE_REPLY_TYPE_NAME = "不需回复",
                            RECEIVE_EMPLOYEE_CODE   = user.sales_No,
                            RECEIVE_EMPLOYEE_NAME   = user.sales_Name,
                            desc                    = "有会员进店,请接待",
                            freqType                = 1,
                            taskName                = "有会员进店,请接待",
                            starTime                = System.DateTime.Now,
                            endTime                 = System.DateTime.Now.AddMinutes(5),
                            importantType           = 1,
                            isAll                   = 1,
                            isRead                  = 0,
                            isReply                 = 0,

                            taskType          = "009",
                            taskTypeName      = "会员到店通知",
                            URGENCY_TYPE_CODE = "002",
                            URGENCY_TYPE_NAME = "紧急",
                            taskSource        = "系统",
                            isDelete          = 0,
                            taskUrl           = "{'shopCode':'" + ShopCode + "','bid':'" + bid + "'}"
                        };
                        taskRep.Insert(ent);

                        TaskPopApp popApp = new TaskPopApp();
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = userinfo.id, userType = 1
                        });


                        string AndroIdDevice = getDeviceTokens(userinfo.id, "Android");
                        if (AndroIdDevice.Length > 0)
                        {
                            AndroidPostJson postJson = new AndroidPostJson();
                            var             payload  = new AndroidPayload();
                            postJson.type          = CastType.listcast;
                            postJson.device_tokens = AndroIdDevice;

                            payload.display_type      = "notification";
                            payload.body              = new ContentBody();
                            payload.body.ticker       = ent.taskName;
                            payload.body.title        = ent.taskName;
                            payload.body.icon         = "appicon";
                            payload.body.play_lights  = "true";
                            payload.body.play_sound   = "true";
                            payload.body.play_vibrate = "true";
                            payload.body.text         = ent.taskName;
                            payload.body.after_open   = AfterOpenAction.go_app;
                            //payload.body.custom = "comment-notify";
                            var dic = new Dictionary <string, string>();
                            dic.Add("messageId", System.Guid.NewGuid().ToString());

                            payload.extra        = dic;
                            postJson.payload     = payload;
                            postJson.description = ent.taskName;
                            UMengMessagePush <AndroidPostJson> uMAndroidPush = new UMengMessagePush <AndroidPostJson>("59550725677baa17ce0003fe", "grpqx0ayqc1ovn45iqczlrovqrdtvujf");
                            ReturnJsonClass resu = uMAndroidPush.SendMessage(postJson);
                            foreach (var memberEnt in ents)
                            {
                                postJson               = new AndroidPostJson();
                                payload                = new AndroidPayload();
                                postJson.type          = CastType.unicast;
                                postJson.device_tokens = AndroIdDevice;

                                payload.display_type      = "notification";
                                payload.body              = new ContentBody();
                                payload.body.ticker       = ent.taskName;
                                payload.body.title        = ent.taskName;
                                payload.body.icon         = "appicon";
                                payload.body.play_lights  = "true";
                                payload.body.play_sound   = "true";
                                payload.body.play_vibrate = "true";
                                payload.body.text         = ent.taskName;
                                payload.body.after_open   = AfterOpenAction.go_app;
                                dic = new Dictionary <string, string>();
                                dic.Add("messageId", System.Guid.NewGuid().ToString());
                                dic.Add("mfMemberId", memberEnt.mfMemberId);
                                dic.Add("bid", bid);

                                payload.extra               = dic;
                                postJson.payload            = payload;
                                postJson.policy             = new AndroidPolicy();
                                postJson.policy.expire_time = DateTime.Now.AddMinutes(5).ToString("yyyy-MM-dd HH:mm:ss");
                                UMengMessagePush <AndroidPostJson> uMAndroidPush2 = new UMengMessagePush <AndroidPostJson>("5b3ae2eaf43e4808f6000112", "gljoyn3tebkcchaeyvksvp0itjagynqr");
                                ReturnJsonClass resu2 = uMAndroidPush2.SendMessage(postJson);

                                /*logApp.WriteDbLog(new LogEntity()
                                 * {
                                 *  F_Account = user.sales_No,
                                 *  F_CreatorTime = System.DateTime.Now,
                                 *  F_Date = System.DateTime.Now,
                                 *  F_CreatorUserId = user.sales_No,
                                 *  F_Description = resu2.ret,
                                 *  F_Id = System.Guid.NewGuid().ToString(),
                                 *  F_ModuleId = "SendMessage",
                                 *  F_ModuleName = "SendMessage",
                                 *
                                 * });*/
                            }

                            System.Console.WriteLine(resu.ret);
                        }
                        string IOSDevice = getDeviceTokens(userinfo.id, "IOS");
                        if (IOSDevice.Length > 0)
                        {
                            IOSPostJson postJson = new IOSPostJson();
                            postJson.type = CastType.unicast;
                            var aps = new Aps()
                            {
                                alert = "msg",
                                sound = "default"
                            };
                            var     payload = new IOSPayload(aps);
                            JObject jo      = JObject.FromObject(payload);
                            var     extra   = new Dictionary <string, string>();
                            //用户自定义内容,"d","p"为友盟保留字段,key不可以是"d","p"
                            extra.Add("open", "list");
                            extra.ToList().ForEach(x => jo.Add(x.Key, x.Value));

                            postJson.payload         = jo;
                            postJson.description     = ent.taskName;
                            postJson.device_tokens   = IOSDevice;
                            postJson.production_mode = "true";

                            UMengMessagePush <IOSPostJson> uMAndroidPush = new UMengMessagePush <IOSPostJson>("596791cbb27b0a673700001f", "siy2v7u9uzishzimgnslzdukyqkeofhp");
                            ReturnJsonClass resu = uMAndroidPush.SendMessage(postJson);
                            System.Console.WriteLine(resu.ret);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logApp.WriteDbLog(new LogEntity()
                {
                    F_Account       = "",
                    F_CreatorTime   = System.DateTime.Now,
                    F_Date          = System.DateTime.Now,
                    F_CreatorUserId = "",
                    F_Description   = ex.Message,
                    F_Id            = System.Guid.NewGuid().ToString(),
                    F_ModuleId      = "SendMessage",
                    F_ModuleName    = "SendMessage",
                });
            }
        }
Exemple #17
0
        private VModel getdata(string BrandValue, string ProdectValue, string MonthValue, string UserId, int type, string salesCode, string orgCode)
        {
            VModel         model    = new VModel();
            marketSalesApp salesApp = new marketSalesApp();

            //组织ID 219
            //查询目标总数
            model.type = type;
            DateTime m = DateTime.ParseExact(MonthValue, "yyyyMM", CultureInfo.CurrentCulture);

            if (type == 2)
            {
                string porgCode = salesApp.getOrginfoBySubId(orgCode, "BU").id;
                model.OrgId   = orgCode;
                model.OrgName = salesApp.getOrgInfo(orgCode).MANAGE_ORG_NAME;
                model.Prodect = ProdectValue;
                //查找Bill单号

                JS5_S12_SALES_TARGET_BILL_MTableAdapter ad = new JS5_S12_SALES_TARGET_BILL_MTableAdapter();
                var totalEnts = ad.GetDataBy(salesApp.getOrginfoBySubId(porgCode, "CHANNEL").id, model.Prodect, m.ToString("yyyy/MM"), BrandValue);

                if (totalEnts.Count <= 0)
                {
                    model.TotalTagQty = 0;
                    model.billNo      = null;
                }
                else
                {
                    model.billNo = totalEnts.First().BILL_NO;

                    JS5_S12_SALES_TARGET_BILL_DTableAdapter dad = new JS5_S12_SALES_TARGET_BILL_DTableAdapter();

                    model.TotalTagQty = (int)dad.QtyQuery(BrandValue, porgCode, model.Prodect, model.billNo);
                }
                model.Brand = BrandValue;
                JS5_S12_BRAND_INFOTableAdapter BandAd = new JS5_S12_BRAND_INFOTableAdapter();
                model.BrandName = BandAd.GetDataByCode(BrandValue).First().BRAND_NAME;

                model.Month     = MonthValue;
                model.MonthName = m.ToString("yyyy年MM月");

                JS5_S12_PRODUCT_TYPE_INFOTableAdapter prdAd = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter();
                model.ProdectName = prdAd.GetDataByCode(ProdectValue).First().TREE_NODE_NAME;

                //查询总共已提交数量

                PSIApp psiApp = new PSIApp();
                var    cents  = psiApp.CmList(model.Prodect, MonthValue, porgCode, BrandValue);
                model.TotalCQty = cents.Sum(p => p.cmQty).Value;//psiApp.TotalCmQty(ProdectValue, MonthValue, model.OrgId);
                model.UserId    = UserId;
                model.subModel  = new List <subVModel>();
                var ents = psiApp.CmList(model.Prodect, MonthValue, model.OrgId, UserId, BrandValue);

                model.SelfTotalTagQty = psiApp.TagList(model.Prodect, MonthValue, model.OrgId, UserId, BrandValue).Sum(p => p.totalTagQty).Value;


                model.SelfTotalCQty = ents.Sum(p => p.cmQty).Value;//psiApp.TotalCmQty(ProdectValue, MonthValue, model.OrgId,UserId);
                model.cQtyModel     = new List <qtyModel>();
                DateTime startDay = m;
                DateTime temp     = m;
                for (int i = 0; i < 35; i++)
                {
                    if (startDay.Month == temp.Month)
                    {
                        int isClose = 0;
                        if (DateTime.Compare(temp, DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture)) < 0)
                        {
                            isClose = 1;
                        }
                        var ent = ents.Find(p => p.day.Value.ToString("yyyy-MM-dd").Equals(temp.ToString("yyyy-MM-dd")));
                        if (ent != null)
                        {
                            model.cQtyModel.Add(new qtyModel()
                            {
                                day     = temp.ToString("yyyy-MM-dd"),
                                status  = ent.status.HasValue ? ent.status.Value : 0,
                                value   = ent.cmQty.Value,
                                isClose = isClose
                            });
                        }
                        else
                        {
                            model.cQtyModel.Add(new qtyModel()
                            {
                                day     = temp.ToString("yyyy-MM-dd"),
                                status  = 0,
                                value   = 0,
                                isClose = isClose
                            });
                        }
                    }
                    temp = temp.AddDays(1);
                }
            }
            else
            {
                model.OrgId   = orgCode;
                model.OrgName = salesApp.getOrgInfo(orgCode).MANAGE_ORG_NAME;
                model.Prodect = ProdectValue;

                //查找Bill单号

                JS5_S12_SALES_TARGET_BILL_MTableAdapter ad = new JS5_S12_SALES_TARGET_BILL_MTableAdapter();
                var totalEnts = ad.GetDataBy(salesApp.getOrginfoBySubId(orgCode, "CHANNEL").id, model.Prodect, m.ToString("yyyy/MM"), BrandValue);

                if (totalEnts.Count <= 0)
                {
                    model.TotalTagQty = 0;
                    model.billNo      = null;
                }
                else
                {
                    model.billNo = totalEnts.First().BILL_NO;

                    JS5_S12_SALES_TARGET_BILL_DTableAdapter dad = new JS5_S12_SALES_TARGET_BILL_DTableAdapter();

                    model.TotalTagQty = (int)dad.QtyQuery(BrandValue, orgCode, model.Prodect, model.billNo);
                }
                model.Brand = BrandValue;
                JS5_S12_BRAND_INFOTableAdapter BandAd = new JS5_S12_BRAND_INFOTableAdapter();
                model.BrandName = BandAd.GetDataByCode(BrandValue).First().BRAND_NAME;

                model.Month = MonthValue;

                model.MonthName = m.ToString("yyyy年MM月");

                JS5_S12_PRODUCT_TYPE_INFOTableAdapter prdAd = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter();
                model.ProdectName = prdAd.GetDataByCode(ProdectValue).First().TREE_NODE_NAME;

                //查询总共已提交数量

                PSIApp psiApp = new PSIApp();
                var    cents  = psiApp.CmList(model.Prodect, MonthValue, model.OrgId, model.Brand);
                model.TotalCQty = cents.Sum(p => p.cmQty).Value;//psiApp.TotalCmQty(ProdectValue, MonthValue, model.OrgId);
                model.UserId    = UserId;
                model.subModel  = new List <subVModel>();
                //查询城市列表
                //JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter orgInfo = new JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter();



                var orgs    = salesApp.getOrginfoByPCode(orgCode, "CITY");
                var tagEnts = psiApp.TagList(model.Prodect, MonthValue, model.OrgId, BrandValue);
                foreach (var org in orgs)
                {
                    var ent    = cents.Where(p => p.orgId.Equals(org.id));
                    var tagEnt = tagEnts.Find(p => p.orgId.Equals(org.id));

                    var sales = salesApp.getUserInfoByOrgId(org.id);
                    //if (sales != null)
                    //{
                    var subModel = new subVModel()
                    {
                        cmQty    = ent.Sum(p => p.cmQty).Value,
                        tagQty   = tagEnt == null ? 0 : tagEnt.totalTagQty.Value,
                        cityCode = org.id,
                        cityName = org.MANAGE_ORG_NAME,
                        popCode  = "",
                        popName  = "",
                    };

                    if (sales != null)
                    {
                        subModel.popCode = sales.id;
                        subModel.popName = sales.Name;
                    }
                    model.subModel.Add(subModel);
                    //}
                }
            }



            return(model);
        }