public ActionResult Index([FromForm] UserPageReq ReqModel) { //当前页数 var nowpage = (ReqModel.start + ReqModel.length) / ReqModel.length; Expression <Func <SystemUser, bool> > exp = p => p.Id > 0; if (!string.IsNullOrEmpty(ReqModel.Name)) { exp = p => p.Email.Contains(ReqModel.Name) || p.Account.Contains(ReqModel.Name) || p.Phone.Contains(ReqModel.Name); } var dataList = SystemUserHelper.GetPage(exp, pageSize: ReqModel.length, currentPage: nowpage); long total = dataList.TotalPages; var itemList = dataList.Items; var totalPage = Math.Ceiling(Convert.ToDouble(total / ReqModel.length)); var model = new List <SystemUserRes>(); foreach (var item in itemList) { model.Add(new SystemUserRes() { UseCode = item.Id, CreatedTime = item.CreatedTime, Status = item.Status, Name = item.NickName, Account = item.Account, Email = item.Email, HeadImg = string.IsNullOrEmpty(item.HeadImage) ? _configuration.GetSection("ResourceInfo:ResourceApi").Value + "/assets/layouts/layout/img/avatar3_small.jpg" : _configuration.GetSection("ImgURL").Value + item.HeadImage, Phone = item.Phone }); } return(Json(new { data = model, draw = ReqModel.draw, recordsTotal = total, recordsFiltered = total })); }
public ActionResult Edit([FromForm] SystemUserEdit model) { if (model.Id == 1) { return(Json(ResponseHelper.Error("该用户不可被编辑"))); } if (!string.IsNullOrEmpty(model.Pwd)) { if (model.Pwd.Length < 6 || model.Pwd.Length > 16) { return(Json(ResponseHelper.Error("密码长度不能少于6位大于16位!"))); } } var UserModel = SystemUserHelper.GetModel(model.Id); //查询是否存重名 if (SystemUserHelper.Exists(p => p.Id != model.Id && (p.Phone.Equals(model.Phone) || p.Email.Equals(model.Email)))) { return(Json(new { status = 0, msg = "已存在相同的手机号或者邮箱,请修改!" })); } UserModel.Email = model.Email; UserModel.Status = model.IsUse; UserModel.NickName = model.Name; UserModel.Phone = model.Phone; if (!string.IsNullOrEmpty(model.Pwd)) { UserModel.Password = AESUtil.Md5(model.Pwd); } SystemUserHelper.Update(UserModel); return(Json(ResponseHelper.Success("ok"))); }
/// <summary> /// Add the specified <c>Principal</c> to the list of <c>Queue</c> members. /// <para> /// For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.addprincipaltoqueuerequest(v=crm.8).aspx /// </para> /// </summary> /// <param name="queueId"><c>Queue</c> Id</param> /// <param name="principalType"><c>System User</c> or <c>Team</c>. If the passed-in <c>PrincipalType.Team</c> , add each team member to the queue.</param> /// <param name="principalId"><c>Principal</c> Id</param> /// <returns> /// <see cref="AddPrincipalToQueueResponse"/> /// </returns> public AddPrincipalToQueueResponse AddPrincipalToQueue(Guid queueId, PrincipalType principalType, Guid principalId) { ExceptionThrow.IfGuidEmpty(queueId, "queueId"); ExceptionThrow.IfGuidEmpty(principalId, "principalId"); Entity principalEntity = null; switch (principalType) { case PrincipalType.SystemUser: SystemUserHelper systemuserHelper = new SystemUserHelper(this.OrganizationService); principalEntity = systemuserHelper.Get(principalId, "fullname"); break; case PrincipalType.Team: TeamHelper teamHelper = new TeamHelper(this.OrganizationService); principalEntity = teamHelper.Get(principalId, "name"); break; } ExceptionThrow.IfNull(principalEntity, "principal", string.Format("Principal not found with '{0}'", principalId.ToString())); AddPrincipalToQueueRequest request = new AddPrincipalToQueueRequest() { QueueId = queueId, Principal = principalEntity }; return((AddPrincipalToQueueResponse)this.OrganizationService.Execute(request)); }
public ActionResult ChangeStatus() { var status = Convert.ToInt16(Request.Form["status"]); var code = int.Parse(Request.Form["id"]); SystemUserHelper.Update(new SystemUser { Id = code, Status = status }, SystemUserHelper.Columns.Status); return(new JsonResult(ResponseHelper.Success("ok"))); }
public ActionResult SignIn([FromForm] SignInModel model) { try { var UserString = HttpContext.Session.GetString("UserInfo"); if (!string.IsNullOrEmpty(UserString)) { return(Json(ResponseHelper.Success(JsonConvert.DeserializeObject <SessionUser>(UserString)))); } // TODO: Add login logic here var password = AESUtil.Md5(model.Password); var user = SystemUserHelper.GetModel(p => p.Password == password && (p.Email == model.Account || p.Account == model.Account || p.Phone == model.Account)); if (user == null) { return(Json(ResponseHelper.Error("账户或密码错误,请确认后再试!"))); } if (user.Status != SystemUser_Status_Enum.正常) { return(Json(ResponseHelper.Error("账户已被冻结!"))); } //获取用户角色 var role = SystemUserRoleMappingHelper.GetRoleBy(user.Id); if (role == null) { return(Json(ResponseHelper.Error("该账户还未分配角色请联系管理员!"))); } var roleAuthList = RoleAuthMappingHelper.GetList(p => p.RoleId == role.Id); if (roleAuthList.Count < 1) { return(Json(ResponseHelper.Error("角色未拥有权限,请联系下管理员处理"))); } var token = Guid.NewGuid().ToString("N"); //存session var UserCache = new SessionUser { HeadImg = user.HeadImage, Token = token, UId = user.Id.ToString(), UserName = user.NickName, RoleId = role.Id, Email = user.Email, RoleName = role.Name, AuthMenu = roleAuthList.Select(p => p.MenuId).ToList() }; HttpContext.Session.SetString("UserInfo", JsonConvert.SerializeObject(UserCache)); //返回用户信息 return(Json(ResponseHelper.Success(UserCache))); } catch { return(View()); } }
public ActionResult Index() { try { var contact = SystemUserHelper.SystemUserTest(SuperOfficeAuthHelper.Context.SystemToken, SuperOfficeAuthHelper.Context.ContextIdentifier); return(RedirectToAction("Index", "ContactEntity", new { id = contact.ContactId })); } catch (Exception) { return(View()); } }
protected void Page_Load(object sender, EventArgs e) { try { lblUserId.Value = Environment.UserName; if (!string.IsNullOrEmpty(Environment.UserName)) { sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); SystemUser sInfo = SystemUserHelper.GetSystemUserByDomainName(Environment.UserName, sda); if (sInfo != null && sInfo.SystemUserId != Guid.Empty) { lblUserId.Value = sInfo.SystemUserId.ToString(); } else { //bdy.Style.Add("background-color", "white"); //bdy.InnerHtml = "<center><br /> <img src='images/warning.png' height='144' /> <br /><h1>Kullanıcı bilgileriniz CRM'de tanımlı değildir.<br> BT ekibi ile irtibata geçebilirsiniz.<h1></center>"; //return; //lblUserId.Value = "12979C4A-368C-E411-80C1-005056A62B8A"; //lblUserId.Value = "8B126813-8A8B-E411-80C1-005056A62B8A"; //Nef Test //lblUserId.Value = "246d808b-8774-e411-80e4-005056b0203a"; //ınnthebox test lblUserId.Value = "8A5D461F-A6A7-E411-80C5-005056A62B8A"; //ınnthebox test Pilot // lblUserId.Value = "19C13874-4FAB-E311-BC40-00155D010409"; // pilot iş gyo //lblUserId.Value = "5A49C200-5A97-E411-80C0-005056A60603"; //ınnthebox test Live // lblUserId.Value = "B0E2D6C9-7D7B-E311-9E00-00155D5A1714"; //Paris //lblUserType.Value = ((int)UserTypes.SatisDanismani).ToString(); //lblUserType.Value = ((int)UserTypes.CallCenter).ToString(); return; } } } catch (Exception ex) { } finally { sda.closeConnection(); } }
protected void Page_Load(object sender, EventArgs e) { try { lblUserId.Value = Environment.UserName; if (!string.IsNullOrEmpty(Environment.UserName)) { sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); //string userName = @"NEF\zeynep.bulbul"; // RESEPSIYONIST //string userName = @"NEF\demet.durgut"; //SATIŞ //string userName = @"NEF\KWBornova"; //DIŞ BAYİ //string userName = @"NEF\indibox"; //string userName = @"NEF\erkan.ozvar"; //SystemUser sInfo = SystemUserHelper.GetSystemUserByDomainName(userName, sda); SystemUser sInfo = SystemUserHelper.GetSystemUserByDomainName(Environment.UserName, sda); if (sInfo != null && sInfo.SystemUserId != Guid.Empty) { if (((int)sInfo.UserType) == ((int)UserTypes.IkinciElSatisDanismani) || ((int)sInfo.UserType) == ((int)UserTypes.IkinciElSatisDirektoru) || ((int)sInfo.UserType) == ((int)UserTypes.IkinciElSatisYoneticisi)) { lblUserId.Value = sInfo.SystemUserId.ToString(); lblUserType.Value = ((int)sInfo.UserType).ToString(); } else { bdy.Style.Add("background-color", "white"); bdy.InnerHtml = "<center><br /> <img src='images/warning.png' height='144' /> <br /><h1>Kullanıcı bilgileriniz CRM'de tanımlı değildir.<br> BT ekibi ile irtibata geçebilirsiniz.<h1></center>"; return; } } else { bdy.Style.Add("background-color", "white"); bdy.InnerHtml = "<center><br /> <img src='images/warning.png' height='144' /> <br /><h1>Kullanıcı bilgileriniz CRM'de tanımlı değildir.<br> BT ekibi ile irtibata geçebilirsiniz.<h1></center>"; return; } } } catch (Exception ex) { } finally { sda.closeConnection(); } }
public ActionResult Edit() { var useCode = Request.Query["code"]; if (string.IsNullOrEmpty(useCode)) { return(Redirect("/home/error")); } var data = SystemUserHelper.GetModel(int.Parse(useCode)); if (data == null) { return(new RedirectResult("/home/errormsg?msg=" + WebUtility.UrlEncode("用户不存在"))); } return(View(data)); }
public ActionResult Create([FromForm] SystemUserCreate model) { if (SystemUserHelper.Exists(p => p.NickName == model.Name || p.Phone == model.Phone || p.Email == model.Email)) { return(Json(ResponseHelper.Error("该用户已经存在!"))); } var UserModel = new SystemUser { Account = model.Account, CreatedTime = DateTime.Now, Email = model.Email, HeadImage = "", NickName = model.Name, Password = AESUtil.Md5(model.Pwd), Phone = model.Phone, Status = model.IsUse }; SystemUserHelper.Insert(UserModel); return(Json(ResponseHelper.Success("ok"))); }
public ActionResult Login(string userName, string password) { var _userService = InstanceFactory.GetInstance <IUserService>(); var user = _userService.GetUser(userName); if (user == null) { return(this.RedirectWithAlertMessage("Kullanıcı Adı Hatalı", "Login")); } else { if (user != null && user.Password == password) { SystemUserHelper.LoginUser(user.Id); return(RedirectToAction("Index", "Products")); } else { return(this.RedirectWithAlertMessage("Şifre Hatalı", "Login")); } } }
public void Execute(IServiceProvider serviceProvider) { SqlDataAccess sda = null; sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); try { #region | SERVICE | IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); #region | Validate Request | //Target yoksa veya Entity tipinde değilse, devam etme. if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity)) { return; } #endregion IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); #endregion Entity entity = (Entity)context.InputParameters["Target"]; if (entity.Attributes.Contains("new_productid")) { EntityReference createdUser = (EntityReference)entity["ownerid"]; EntityReference proc = (EntityReference)entity["new_productid"]; DateTime optionDate = (DateTime)entity["new_optiondate"]; TimeSpan fark = optionDate - DateTime.Now; Product product = ProductHelper.GetProductDetail(proc.Id, sda); if (product.StatusCode.Value != (int)ProductStatuses.Bos) { throw new Exception("Opsiyon ekleyebilme için konutun durumu BOŞ olmalıdır."); } if (product.Project != null) { QuoteControlSetting control = ProductHelper.GetControlSettingByProject(product.Project.Id, sda); if (control.QuoteControlSettingId != Guid.Empty) { SystemUser su = SystemUserHelper.GetSystemUserInfo(createdUser.Id, sda); if (su.UserType == UserTypes.SatisDanismani) { if (fark.Days > control.ConsultantOptionDay) { throw new Exception("En fazla " + control.ConsultantOptionDay + " gün opsiyonlayabilirsiniz!"); } else { #region | SET PRODUCT STATUS | MsCrmResult productStatusResult = ProductHelper.UpdateHouseStatus(product.ProductId, ProductStatuses.YoneticiOpsiyonlu, service, optionDate); if (!productStatusResult.Success) { throw new Exception(productStatusResult.Result); } #endregion } } else if (su.UserType == UserTypes.SatisMuduru || su.UserType == UserTypes.IsGyoSatisMuduru) { if (fark.Days > control.ManagerOptionDay) { throw new Exception("En fazla " + control.ManagerOptionDay + " gün opsiyonlayabilirsiniz!"); } else { #region | SET PRODUCT STATUS | MsCrmResult productStatusResult = ProductHelper.UpdateHouseStatus(product.ProductId, ProductStatuses.YoneticiOpsiyonlu, service, optionDate); if (!productStatusResult.Success) { throw new Exception(productStatusResult.Result); } #endregion } } else if (su.UserType == UserTypes.SatisDirektoru) { if (fark.Days > control.DirectorOptionDay) { throw new Exception("En fazla " + control.DirectorOptionDay + " gün opsiyonlayabilirsiniz!"); } else { #region | SET PRODUCT STATUS | MsCrmResult productStatusResult = ProductHelper.UpdateHouseStatus(product.ProductId, ProductStatuses.YoneticiOpsiyonlu, service, optionDate); if (!productStatusResult.Success) { throw new Exception(productStatusResult.Result); } #endregion } } else { throw new Exception("Konut opsiyonlama yetkiniz bulunmamaktadır!"); } } } } } catch (Exception ex) { throw new InvalidPluginExecutionException(ex.Message); } finally { if (sda != null) { sda.closeConnection(); } } }
public void Execute(IServiceProvider serviceProvider) { SqlDataAccess sda = null; sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); try { #region | SERVICE | IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); #region | Validate Request | //Target yoksa veya Entity tipinde değilse, devam etme. if (!context.InputParameters.Contains("EntityMoniker") || !(context.InputParameters["EntityMoniker"] is EntityReference)) { return; } #endregion IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); Guid phoneCallId = ((EntityReference)context.InputParameters["EntityMoniker"]).Id; Entity postImage = service.Retrieve("phonecall", phoneCallId, new ColumnSet(true)); #endregion #region | TELEFON GÖRÜŞMESİ SONUCU İLGİLİ İSE YAPILACAKLAR | Directions direction = (bool)postImage["directioncode"] ? Directions.Giden : Directions.Gelen; if (!postImage.Attributes.Contains("to") && postImage["to"] != null || !postImage.Attributes.Contains("from") && postImage["from"] != null) { throw new Exception("Lütfen aranacak kişi ve arama kaynağı bilgisini doldurunuz!"); } EntityReference customer = direction == Directions.Giden ? (EntityReference)((EntityCollection)(postImage["to"])).Entities[0]["partyid"] : (EntityReference)((EntityCollection)(postImage["from"])).Entities[0]["partyid"];; if (postImage.Attributes.Contains("new_activitystatus") && postImage["new_activitystatus"] != null) //activitystatusid si şimdilik { MsCrmResultObject activityStatusResult = ActivityHelper.GetActivityStatusDetail(((EntityReference)postImage["new_activitystatus"]).Id, sda); if (activityStatusResult.Success) { ActivityStatus _activiyStatus = (ActivityStatus)activityStatusResult.ReturnObject; if (_activiyStatus.ActivityStatusCode == ActivityStatusCodes.Ilgili) { bool hasOpenOpportunity = false; Guid ownerId = ((EntityReference)postImage["ownerid"]).Id; Guid opportunityId = Guid.Empty; #region | OPPORTUNITY PROCESS | MsCrmResult opportunityControlResult = OpportunityHelper.HasOpenOpportunityToSalesConsultantAndContact(customer.Id, ownerId, sda); if (opportunityControlResult.Success) { hasOpenOpportunity = true; opportunityId = opportunityControlResult.CrmId; Entity oppEnt = new Entity("opportunity"); oppEnt["opportunityid"] = opportunityId; oppEnt["new_relatedactivitystatusid"] = (EntityReference)postImage["new_activitystatusdetail"]; service.Update(oppEnt); } else { Opportunity opportunity = new Opportunity(); opportunity.Contact = customer; opportunity.ActivityStatusDetail = (EntityReference)postImage["new_activitystatusdetail"]; opportunity.Owner = ((EntityReference)postImage["ownerid"]); MsCrmResult opportunityResult = OpportunityHelper.CreateOrUpdateOpportunity(opportunity, service); if (opportunityResult.Success) { opportunityId = opportunityResult.CrmId; } else { throw new Exception(opportunityResult.Result); } } #endregion #region | SEY ACTIVITY REGARDING OBJECT AS OPPORTUNITY | Entity activity = new Entity("phonecall"); activity.Id = postImage.Id; activity["regardingobjectid"] = new EntityReference("opportunity", opportunityId); service.Update(activity); #endregion #region | OPPORTUNITY PRODUCT PROCESS | MsCrmResultObject activityProductsResult = InterestProductHelper.GetActivityInterestedProjects(postImage.Id, sda); if (activityProductsResult.Success) { List <InterestProduct> relatedProducts = (List <InterestProduct>)activityProductsResult.ReturnObject; #region | FIRSATIN FİYAT LİSTESİ ÜRÜNÜN FİYAT LİSTESİ İLE SET EDİLİR | Entity ent = new Entity("opportunity"); ent.Id = opportunityId; ent["pricelevelid"] = relatedProducts[0].InterestedProduct.PriceList; service.Update(ent); #endregion for (int i = 0; i < relatedProducts.Count; i++) { Product _proc = relatedProducts[i].InterestedProduct; if (hasOpenOpportunity) { MsCrmResult hasProductAddedOppProc = OpportunityHelper.HasOpportunityProduct(opportunityId, _proc.ProductId, sda); if (!hasProductAddedOppProc.Success) { OpportunityHelper.CreateOpportunityProduct(opportunityId, _proc, service); } } else { OpportunityHelper.CreateOpportunityProduct(opportunityId, _proc, service); } } } #endregion } } else { throw new Exception(activityStatusResult.Result); } } #endregion #region | SAHİPLİK İLE İLGİLİ İŞLEMLER | //Eğer kişi ve firma resepsiyonist tarafından oluşturulmuş ise, ilk aktivenin sahibi atanır. Entity ownerEntity = service.Retrieve(customer.LogicalName, customer.Id, new ColumnSet("ownerid")); EntityReference owner = (EntityReference)ownerEntity["ownerid"]; SystemUser su = SystemUserHelper.GetSystemUserInfo(owner.Id, sda); if (su.SystemUserId != null) { if (su.UserType == UserTypes.Resepsiyonist) { AssignRequest assign = new AssignRequest { Assignee = (EntityReference)postImage["ownerid"], Target = customer }; // Execute the Request service.Execute(assign); } } #endregion #region | WEBFORM KAYDI VAR İSE YAPILACAKLAR | //Birden fazla web form kaydı var ise 1. si "Tamamlandı - Temas Kuruldu" olarak diğerleri "Tamamlandı - Başka Bir Temas Nedeniyle" olarak kapatılır. MsCrmResultObject webFormResult = WebFormHelper.GetContactWebForms(customer.Id, sda); if (webFormResult.Success && webFormResult.ReturnObject != null) { List <WebForm> webFormList = (List <WebForm>)webFormResult.ReturnObject; if (webFormList.Count > 0) { WebForm firstForm = webFormList[0]; WebFormHelper.WebFormClose(firstForm.WebFormId, 1, 2, service); //Tamamlandı - Temas Kuruldu if (webFormList.Count > 1) { for (int i = 0; i < webFormList.Count; i++) { WebForm form = webFormList[i]; WebFormHelper.WebFormClose(form.WebFormId, 1, 100000000, service); //Tamamlandı - Başka Bir Temas Nedeniyle } } } } #endregion } catch (Exception ex) { throw new InvalidPluginExecutionException(ex.Message); } finally { if (sda != null) { sda.closeConnection(); } } }
protected void Page_Load(object sender, EventArgs e) { try { lblUserId.Value = Environment.UserName; if (!string.IsNullOrEmpty(Environment.UserName)) { sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); //string userName = @"NEF\zeynep.bulbul"; // RESEPSIYONIST //string userName = @"NEF\demet.durgut"; //SATIŞ //string userName = @"NEF\KWBornova"; //DIŞ BAYİ string userName = @"NEF\indibox"; SystemUser sInfo = SystemUserHelper.GetSystemUserByDomainName(userName, sda); //SystemUser sInfo = SystemUserHelper.GetSystemUserByDomainName(Environment.UserName, sda); if (sInfo != null && sInfo.SystemUserId != Guid.Empty) { lblUserId.Value = sInfo.SystemUserId.ToString(); lblUserType.Value = ((int)sInfo.UserType).ToString(); } else { bdy.Style.Add("background-color", "white"); bdy.InnerHtml = "<center><br /> <img src='images/warning.png' height='144' /> <br /><h1>Kullanıcı bilgileriniz CRM'de tanımlı değildir.<br> BT ekibi ile irtibata geçebilirsiniz.<h1></center>"; return; //lblUserId.Value = "12979C4A-368C-E411-80C1-005056A62B8A"; //lblUserId.Value = "8B126813-8A8B-E411-80C1-005056A62B8A"; //Nef Test //lblUserId.Value = "246d808b-8774-e411-80e4-005056b0203a"; //ınnthebox test // lblUserId.Value = "8A5D461F-A6A7-E411-80C5-005056A62B8A"; //ınnthebox test Pilot //lblUserId.Value = "19C13874-4FAB-E311-BC40-00155D010409"; // pilot iş gyo //lblUserId.Value = "5A49C200-5A97-E411-80C0-005056A60603"; //ınnthebox test Live //lblUserType.Value = ((int)UserTypes.SatisDanismani).ToString(); //lblUserId.Value = "359BA910-ACC0-E311-B9D9-00155D011C0A"; //lblUserType.Value = ((int)UserTypes.CallCenter).ToString(); //is GYO Satis Test User //lblUserId.Value = "0F3DA178-CDEC-E411-80D0-005056A60603"; //lblUserType.Value = ((int)UserTypes.IsGyoCallCenter).ToString(); //lblUserId.Value = "B0E2D6C9-7D7B-E311-9E00-00155D5A1714"; //Paris //lblUserType.Value = ((int)UserTypes.MusteriIliskileri).ToString(); //lblUserType.Value = ((int)UserTypes.CallCenter).ToString(); //lblUserType.Value = ((int)UserTypes.Resepsiyonist).ToString(); //lblUserType.Value = ((int)UserTypes.CallCenter).ToString(); // return; } } } catch (Exception ex) { } finally { sda.closeConnection(); } }
public ActionResult Logout() { SystemUserHelper.LogoutUser(); return(RedirectToAction("Login")); }
public void Execute(IServiceProvider serviceProvider) { SqlDataAccess sda = null; sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); try { #region | SERVICE | IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); #region | Validate Request | //Target yoksa veya Entity tipinde değilse, devam etme. if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity)) { return; } #endregion IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); #endregion Entity entity = (Entity)context.InputParameters["Target"]; #region | ADD PHONECALL QUEUE | Guid ownerId = entity.Attributes.Contains("ownerid") ? ((EntityReference)entity["ownerid"]).Id : Guid.Empty; if (ownerId != Guid.Empty) { SystemUser user = SystemUserHelper.GetSystemUserInfo(ownerId, sda); if (user.SystemUserId != Guid.Empty) { if (user.UserType != null && user.UserType == UserTypes.CallCenter) //Telefon görüşmesinin sahibi Call Center kullanıcısı ise { MsCrmResultObject callCenterQueueResult = GeneralHelper.GetQueues(QueueTypes.CallCenter, sda); if (callCenterQueueResult.Success) { Queue callCenterQueue = ((List <Queue>)callCenterQueueResult.ReturnObject)[0]; MsCrmResult phoneQueueResult = ActivityHelper.AddPhoneCallToQueue(entity.Id, callCenterQueue.QueueId, service); if (!phoneQueueResult.Success) { throw new Exception(phoneQueueResult.Result); } } } } } if (entity.Attributes.Contains("regardingobjecttypecode")) { } #endregion #region | ADD PHONECALL QUEUE | Kuyruk lookup'ında hangi kuyruk seçilirse create anında kaydı otomatik olarak o kuyruğa atanır. Guid queueId = entity.Attributes.Contains("new_queueid") ? ((EntityReference)entity["new_queueid"]).Id : Guid.Empty; if (queueId != Guid.Empty) { MsCrmResult phoneQueueResult = ActivityHelper.AddPhoneCallToQueue(entity.Id, queueId, service); if (!phoneQueueResult.Success) { throw new Exception(phoneQueueResult.Result); } } #endregion } catch (Exception ex) { throw new InvalidPluginExecutionException(ex.Message); } finally { if (sda != null) { sda.closeConnection(); } } }