Beispiel #1
0
        public string QueryPm()
        {
            gcMgr = new GroupCallerMgr(connectionString);
            paraMgr = new ParameterMgr(connectionString);
            fgMgr = new FgroupMgr(connectionString);
            muMgr = new ManageUserMgr(connectionString);
            groupCaller gc = new groupCaller();
            Fgroup fg = new Fgroup();
            string json = string.Empty;

            try
            {
                List<Parametersrc> parstore = paraMgr.QueryUsed(new Parametersrc { ParameterType = "vendor_pm" }).ToList();

                if (parstore.Count != 0)
                {
                    fg.groupCode = parstore[0].ParameterCode;
                    //  fg.groupName = parstore[0].parameterName;//parameterName是可變的不可依此查詢 edit by shuangshuang0420j 2015.07.28 09:48
                    Fgroup pmfg = fgMgr.GetSingle(fg);
                    if (pmfg != null)
                    {
                        gc.groupId = pmfg.rowid;
                        string pm = gcMgr.QueryCallidById(gc);
                        StringBuilder stb = new StringBuilder("");
                        stb.Append("{");
                        stb.Append("success:true,item:[");
                        //stb.Append("{");
                        //stb.AppendFormat("\"userId\":\"{0}\",\"userName\":\"{1}\"", 0, "請選擇");
                        //stb.Append("}");
                        string nameStr = string.Empty;

                        string[] pmar = pm.Split(',').ToArray();
                        foreach (var item in pmar)
                        {
                            int total = 0;
                            ManageUserQuery mu = muMgr.GetManageUserList(new ManageUserQuery { user_email = item, search_status = "-1" }, out total).FirstOrDefault();
                            if (total == 1 && mu != null)
                            {
                                stb.Append("{");
                                stb.AppendFormat("\"userId\":\"{0}\",\"userName\":\"{1}\"", mu.user_id, mu.user_username);
                                stb.Append("}");
                            }
                        }
                        stb.Append("]}");
                        json = stb.ToString().Replace("}{", "},{");
                    }
                    //else
                    //{
                    //    json = "{success:false,error:1}";
                    //}
                }
                //else
                //{
                //    json = "{success:false,error:0}";
                //}
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "[]";
            }

            return json;

        }
Beispiel #2
0
        public string QueryCallidById()
        {
            gcMgr = new GroupCallerMgr(mySqlConnectionString);
            string json = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(Request.Form["groupId"]))
                {
                    gc.groupId = Convert.ToInt32(Request.Form["groupId"]);
                }
                json = gcMgr.QueryCallidById(gc);
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "[]";
            }

            return json;
        }