Beispiel #1
0
        /// <summary>
        /// 人員管理
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase AddCallid()//modify by mengjuan0826j 2015/6/8 處理供應商pm設定 增加條件設置:若pm存在于供應商,則不能執行刪除動作!
        {
            gcMgr = new GroupCallerMgr(mySqlConnectionString);
            venMgr = new VendorMgr(mySqlConnectionString);
            string json = string.Empty;
            bool delete = true;
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["groupId"]))
                {
                    gc.groupId = Int32.Parse(Request.Form["groupId"]);
                }

                if (!string.IsNullOrEmpty(Request.Form["callid"]))
                {
                    string[] callid = Request.Form["callid"].IndexOf(",") != -1 ? Request.Form["callid"].Split(',') : new string[] { Request.Form["callid"] };

                    if (gc.groupId == GetVebdorPMGroup())//判定是否為供應商群組管理員
                    {
                        List<ManageUser> muStore = venMgr.GetVendorPM();//獲取供應商pm
                        if (muStore.Count != 0)
                        {
                            foreach (var item in muStore)//遍歷供應商pm,若該人員存在于供應商pm,則不能刪除,直接提示!
                            {
                                if (!callid.Contains(item.user_email))
                                {
                                    delete = false;
                                    json = "{success:false,msg:\"人員 " + item.user_username + " 為現有供應商PM,不能移除\"}";
                                    break;
                                }
                            }
                        }
                    }
                    if (delete)
                    {
                        gcMgr.Delete(gc);
                        foreach (string id in callid)
                        {
                            if (!string.IsNullOrEmpty(id))
                            {
                                gc.callid = id;
                                gcMgr.Save(gc);
                            }
                        }
                        json = "{success:true,msg:\"新增成功\"}";
                    }
                }
                else
                {
                    json = "{success:true,msg:\"新增失敗\"}";
                }

            }
            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 = "{success:true,msg:\"新增失败\"}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }