private MsCrmResult SendMail(string emailAddress, string subject, string mailBody) { MsCrmResult returnValue = new MsCrmResult(); try { MailAddress to = new MailAddress(emailAddress); MailAddress from = new MailAddress(FROM_MAILADDRESS); MailMessage mail = new MailMessage(from, to); mail.Subject = subject; mail.Body = mailBody; SmtpClient smtp = new SmtpClient(); smtp.Host = MAIL_HOST; smtp.Port = Convert.ToInt32(PORT); smtp.Credentials = new NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD); smtp.EnableSsl = false; smtp.Send(mail); returnValue.Success = true; } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CheckOldPasswordCorrect(Guid portalUserId, string oldPassword, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string sqlQuery = @"SELECT COUNT(0) AS RecCount FROM new_user AS u (NOLOCK) WHERE u.new_userId='{0}' AND u.new_password='******'"; #endregion int recCount = (int)sda.ExecuteScalar(string.Format(sqlQuery, portalUserId, oldPassword.Trim())); if (recCount > 0) { returnValue.Success = true; returnValue.Result = "Eski şifre ile bilgiler eşleşti."; } else { returnValue.Result = "Eski şifre bilginiz yanlıştır.<br />Lütfen kontrol ediniz."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult AnswerSurvey(SurveyAnswer answer, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_surveyanswer"); ent["new_name"] = answer.PortalUser.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy HH:mm"); ent["new_portalid"] = answer.Portal; ent["new_userid"] = answer.PortalUser; ent["new_surveyid"] = answer.Survey; ent["new_surveychoiceid"] = answer.SurveyChoice; returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "M053"; //"Anket cevabınız alınmıştır. <br /> Katılımınız için teşekkür ederiz."; } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CheckPhoneNumberMatch(string userName, string phoneNumber, string portalId, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string sqlQuery = @"SELECT u.new_userId AS PortalUserId ,c.ContactId ,c.MobilePhone FROM new_user AS u (NOLOCK) JOIN new_new_user_new_role AS ur (NOLOCK) ON u.new_userId=ur.new_userid JOIN new_role AS r (NOLOCK) ON r.new_roleId=ur.new_roleid AND r.new_portalId='{2}' JOIN Contact AS c (NOLOCK) ON c.ContactId=u.new_contactId WHERE u.new_name='{0}' AND u.statecode=0 AND u.statuscode=1 --Active AND c.MobilePhone='{1}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, userName, phoneNumber, portalId)); if (dt.Rows.Count > 0) { returnValue.Success = true; returnValue.Result = dt.Rows[0]["ContactId"].ToString(); returnValue.CrmId = (Guid)dt.Rows[0]["PortalUserId"]; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CheckPhoneNumberMatch(string userName, string phoneNumber, string portalId, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string sqlQuery = @"SELECT u.new_userId AS PortalUserId ,c.ContactId ,c.MobilePhone FROM new_user AS u (NOLOCK) JOIN new_new_user_new_role AS ur (NOLOCK) ON u.new_userId=ur.new_userid JOIN new_role AS r (NOLOCK) ON r.new_roleId=ur.new_roleid AND r.new_portalId='{2}' JOIN Contact AS c (NOLOCK) ON c.ContactId=u.new_contactId WHERE u.new_name='{0}' AND u.statecode=0 AND u.statuscode=1 --Active AND c.MobilePhone='{1}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, userName, phoneNumber, portalId)); if (dt.Rows.Count > 0) { returnValue.Success = true; returnValue.Result = dt.Rows[0]["ContactId"].ToString(); returnValue.CrmId = (Guid)dt.Rows[0]["PortalUserId"]; } } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public MsCrmResult Process(SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); #region | SQL QUERY | string sqlQuery = @"SELECT opp.OpportunityId ,opp.Name ,opp.CustomerId ,opp.CustomerIdName ,opp.OwnerIdName ,sm.Value AS Status ,opp.new_relatedactivitystatusidName AS ActivityStatus ,opp.CreatedOn ,opp.ActualCloseDate FROM Opportunity AS opp (NOLOCK) JOIN StringMap AS sm (NOLOCK) ON sm.ObjectTypeCode=3 AND sm.AttributeName='statuscode' AND sm.AttributeValue=opp.StatusCode WHERE opp.OwningBusinessUnit='4D2ABB3A-C2B1-E411-80C7-005056A60603'"; #endregion try { DataTable dt = sda.getDataTable(sqlQuery); if (dt.Rows.Count > 0) { XLWorkbook wb = new XLWorkbook(); IXLWorksheet ws = wb.Worksheets.Add(dt, _dataType.ToString()); wb.SaveAs(@Environment.CurrentDirectory + @"\files\" + _dataType.ToString() + ".xlsx"); } returnValue.Success = true; returnValue.Result = string.Format("[{0}] adet data gönderildi.[{1}]", dt.Rows.Count.ToString(), _dataType.ToString()); } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResult SaveOrUpdateGraffiti(Graffiti graffiti, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_graffiti"); ent["new_name"] = graffiti.PortalUser.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy HH:mm"); ent["new_hasmedia"] = graffiti.HasMedia; if (graffiti.PortalUser != null) { ent["new_userid"] = graffiti.PortalUser; } if (graffiti.Portal != null) { ent["new_portalid"] = graffiti.Portal; } if (!string.IsNullOrEmpty(graffiti.Description)) { ent["new_content"] = graffiti.Description; } if (!string.IsNullOrEmpty(graffiti.ImagePath)) { ent["new_imageurl"] = graffiti.ImagePath; } if (graffiti.GraffitiId != Guid.Empty) { ent["new_graffitiid"] = graffiti.GraffitiId; service.Update(ent); returnValue.Success = true; returnValue.Result = "M014"; //"Duvar yazısı güncellendi."; } else { returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "M015"; //"Duvar yazısı oluşturuldu."; } } catch (Exception ex) { returnValue.Result = ex.Message; returnValue.Success = false; } return(returnValue); }
private MsCrmResult SendToService(DiscoveryForm discoveryForm) { MsCrmResult returnValue = new MsCrmResult(); try { lotusService.UcretsizKesifService lotus = new WindowsServices.ProcessDiscoveryForms.lotusService.UcretsizKesifService(); //lotusService.RESPONSE result = lotus.CREATERECORD("A3108", 1, discoveryForm.FirstName, discoveryForm.LastName, discoveryForm.Email, discoveryForm.PhoneNumber // , discoveryForm.VisitHour.Value, discoveryForm.CityId.Name, discoveryForm.TownId.Name, discoveryForm.HomeType.Value // , "", ((DateTime)discoveryForm.VisitDate).ToString("dd.MM.yyyy HH:mm"), discoveryForm.InformedBy.Value); FileLogHelper.LogFunction(this.GetType().Name, "DefaultPortalId:" + Globals.DefaultPortalId, @Globals.FileLogPath); FileLogHelper.LogFunction(this.GetType().Name, "UserParameter:" + (discoveryForm.UserId != null ? discoveryForm.UserId.Id.ToString() : "No User Info"), @Globals.FileLogPath); MsCrmResultObject resultUser = PortalUserHelper.GetPortalUserDetail(new Guid(Globals.DefaultPortalId), discoveryForm.UserId.Id, _sda); string userName = ""; if (resultUser.Success) { PortalUser portalUser = (PortalUser)resultUser.ReturnObject; userName = portalUser.ContactInfo.Title; } else { userName = discoveryForm.UserId.Name; } lotusService.RESPONSE result = lotus.CREATERECORD("A3108", Convert.ToDouble(discoveryForm.FormCode), discoveryForm.FirstName, discoveryForm.LastName, discoveryForm.Email, discoveryForm.PhoneNumber , string.Empty, discoveryForm.CityId.Name, discoveryForm.TownId.Name, string.Empty , "", string.Empty, string.Empty, userName); if (result.ERRORCODE == 0) { returnValue.Success = true; returnValue.Result = "Servise Gönderildi."; } else { returnValue.Result = result.ERRORCODE + "|" + result.ERRORDESCRIPTION; } } catch (Exception ex) { returnValue.Result = ex.StackTrace; } return(returnValue); }
public MsCrmResult GetToken(string userName, string password) { MsCrmResult returnValue = new MsCrmResult(); try { if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password)) { _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); returnValue = LoginHelper.LoginControl(new Guid(Globals.DefaultPortalId), userName, password, _sda); //returnValue.Success = true; if (returnValue.Success) { Guid systemUserId = returnValue.CrmId; _service = MSCRM.GetOrgService(true); string ipAddress = HttpContext.Current.Request.UserHostAddress; MsCrmResult logResult = LoginHelper.LogLogIn(returnValue.CrmId, new Guid(Globals.DefaultPortalId), DateTime.Now, ipAddress, _service); returnValue.Result = Guid.NewGuid().ToString().Replace("-", ""); MsCrmResult sessionResult = SetUserSession(returnValue.Result, new Guid(Globals.DefaultPortalId), systemUserId); if (!sessionResult.Success) { return(sessionResult); } } } else { returnValue.Result = "Eksik Parametre."; } } catch (Exception ex) { returnValue.Result = ex.Message; } finally { if (_sda != null) { _sda.closeConnection(); } } return(returnValue); }
public MsCrmResult GetToken(string portalId, string userName, string password) { MsCrmResult returnValue = new MsCrmResult(); try { if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(portalId)) { _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); returnValue = LoginHelper.LoginControl(new Guid(portalId), userName, password, _sda); //returnValue.Success = true; if (returnValue.Success) { Guid systemUserId = returnValue.CrmId; IOrganizationService service = MSCRM.GetOrgService(true); string ipAddress = HttpContext.Current.Request.UserHostAddress; MsCrmResult logResult = LoginHelper.LogLogIn(returnValue.CrmId, new Guid(portalId), DateTime.Now, ipAddress, service); returnValue.Result = Guid.NewGuid().ToString().Replace("-", ""); MsCrmResult sessionResult = SetUserSession(returnValue.Result, new Guid(portalId), systemUserId); if (!sessionResult.Success) { return sessionResult; } } } else { returnValue.Result = "Eksik Parametre."; } } catch (Exception ex) { returnValue.Result = ex.Message; } finally { if (_sda != null) { _sda.closeConnection(); } } return returnValue; }
public static MsCrmResult SaveObjectProfileImage(Annotation note, string fieldName, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { IOrganizationService service = MSCRM.GetOrgService(true); int splitLength = note.FileName.Split('.').Length; note.FilePath = Guid.NewGuid() + "." + note.FileName.Split('.')[splitLength - 1].ToLower(); byte[] data = Convert.FromBase64String(note.File); //File.WriteAllBytes(HostingEnvironment.MapPath("~/attachments") + "/" + note.FilePath, data); File.WriteAllBytes(@Globals.AttachmentFolder + @"\" + note.FilePath, data); #region | DELETE PREVIOUS IMAGE FILE | string fileName = AttachmentFileHelper.GetEntityProfileImageFileName(note.Object.Id.ToString(), note.Object.LogicalName, fieldName, sda); if (!string.IsNullOrEmpty(fileName)) { //string filePath = HostingEnvironment.MapPath("~/attachments") + "/" + fileName; string filePath = @Globals.AttachmentFolder + @"\" + fileName; if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } } #endregion #region | UPDATE CRM ENTITY | Entity ent = new Entity(note.Object.LogicalName.ToLower()); ent[note.Object.LogicalName.ToLower() + "id"] = note.Object.Id; ent[fieldName] = note.FilePath; service.Update(ent); #endregion returnValue.Success = true; returnValue.Result = note.FilePath; } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResult CreateOrUpdateAuthorityDocument(AuthorityDocument document, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_registrationdoc"); if (document.Product != null) { ent["new_productid"] = document.Product; } if (document.Contact != null) { ent["new_authorizingpersonid"] = document.Contact; } if (document.StartDate != null) { ent["new_startofauthority"] = document.StartDate; } if (document.EndDate != null) { ent["new_endofauthority"] = document.EndDate; } if (document.Name != null) { ent["new_name"] = document.Name; } ent["new_isimportauthoritydoc"] = true; if (document.AuthorityDocumentId.HasValue) { ent.Id = document.AuthorityDocumentId.Value; returnValue.CrmId = document.AuthorityDocumentId.Value; service.Update(ent); ProductHelper.UpdateProductAuthorityDoc(document, service); returnValue.Success = true; returnValue.Result = "Yetki Doküman kaydı başarıyla güncelleştirildi."; } else { returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "Yetki Doküman kaydı başarıyla oluşturuldu."; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return(returnValue); }
public void Execute(IServiceProvider serviceProvider) { SqlDataAccess sda = null; try { sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); #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 | CREATE PRODUCT PRICE LEVEL | if (entity.Contains("price") && entity["price"] != null && entity.Contains("transactioncurrencyid") && entity["transactioncurrencyid"] != null) { MsCrmResult resultProductPriceList = ProductHelper.CreateProductPriceLists(((Money)entity["price"]).Value, (EntityReference)entity["transactioncurrencyid"], entity.Id, sda, service); if (!resultProductPriceList.Success) { throw new Exception(resultProductPriceList.Result); } } #endregion } catch (Exception ex) { throw new InvalidPluginExecutionException(ex.Message); } finally { if (sda != null) { sda.closeConnection(); } } }
public static MsCrmResult CreateOrUpdateFinancialAccount(FinancialAccount financial, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_financialaccount"); if (!string.IsNullOrEmpty(financial.Name)) { ent["new_name"] = financial.Name; } if (financial.Contact != null && financial.Contact.Id != Guid.Empty) { ent["new_contactid"] = new EntityReference("contact", financial.Contact.Id); } else { ent["new_contactid"] = null; } if (financial.Account != null && financial.Account.Id != Guid.Empty) { ent["new_accountid"] = new EntityReference("account", financial.Account.Id); } else { ent["new_accountid"] = null; } if (financial.FinancialAccountId == Guid.Empty) { returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "Kayıt başarıyla eklendi"; } else { ent["new_financialaccountid"] = financial.FinancialAccountId; service.Update(ent); returnValue.Success = true; returnValue.Result = "Bilgiler başarıyla güncellendi"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResult SendMail() { MsCrmResult returnValue = new MsCrmResult(); try { } catch (Exception) { throw; } return(returnValue); }
public MsCrmResult ConfirmForm(string token, int formCode) { MsCrmResult returnValue = new MsCrmResult(); LoginSession ls = new LoginSession(); try { _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); #region | CHECK SESSION | MsCrmResultObject sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return(returnValue); } else { ls = (LoginSession)sessionResult.ReturnObject; } #endregion MsCrmResultObject resultFormInfo = DiscoveryFormHelper.GetDiscoveryFormInfo(formCode, _sda); if (resultFormInfo.Success) { DiscoveryForm formInfo = (DiscoveryForm)resultFormInfo.ReturnObject; formInfo.Status = new OptionSetValueWrapper() { AttributeValue = (int)DiscoveryFormStatus.LotusConfirmed }; DiscoveryFormHelper.UpdateDiscoveryForm(formInfo, _service); } else { returnValue.Result = resultFormInfo.Result; } } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
private static MsCrmResult CancelFoldhome(MobilService client, CustomerDetailResult customerDetailReturn, string customerId, CustomerType customerType, string foldhomeId) { Foldhome foldhomeActivity = new Foldhome(); foldhomeActivity.FoldhomeId = foldhomeId; string result = client.UpdateStatusFoldhome(foldhomeActivity); JavaScriptSerializer set = new JavaScriptSerializer(); set.MaxJsonLength = Int32.MaxValue; MsCrmResult returnValue = set.Deserialize <MsCrmResult>(result); return(returnValue); }
public static MsCrmResult CreateAnnotation(Annotation note, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("annotation"); if (note.AttachmentFile != null) { ent["objectid"] = note.AttachmentFile; } if (!string.IsNullOrEmpty(note.Subject)) { ent["subject"] = note.Subject; } if (!string.IsNullOrEmpty(note.File)) { ent["documentbody"] = note.File; } if (!string.IsNullOrEmpty(note.FileName)) { ent["filename"] = note.FileName; } if (!string.IsNullOrEmpty(note.MimeType)) { ent["mimetype"] = note.MimeType; } if (!string.IsNullOrEmpty(note.Text)) { ent["notetext"] = note.Text; } returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "Dosya Ekleme başarıyla gerçekleşti."; } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResult SaveOrUpdateArticle(Article article, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_article"); if (!string.IsNullOrEmpty(article.Name)) { ent["new_name"] = article.Name; } if (!string.IsNullOrEmpty(article.Summary)) { ent["new_summary"] = article.Summary; } if (!string.IsNullOrEmpty(article.Description)) { ent["new_content"] = article.Description; } if (!string.IsNullOrEmpty(article.ImagePath)) { ent["new_imageurl"] = article.ImagePath; } if (article.ArticleId != Guid.Empty) { ent["new_articleid"] = article.ArticleId; service.Update(ent); returnValue.Success = true; returnValue.Result = "Makale başarıyla güncellendi"; } else { returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "Makale başarıyla oluşturuldu"; } } catch (Exception) { throw; } return(returnValue); }
static void Main(string[] args) { Console.WriteLine("Ürün Import uygulaması çalışıyor..."); MsCrmResult result = ImportProduct.Process(); Console.SetCursorPosition(0, 8); Console.WriteLine(result.Result); Console.SetCursorPosition(0, 9); Console.WriteLine("Çıkış için bir tuşa basınız..."); //Console.ReadKey(); }
public static MsCrmResult CreateAnnotation(Annotation note, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("annotation"); if (note.AttachmentFile != null) { ent["objectid"] = note.AttachmentFile; } if (!string.IsNullOrEmpty(note.Subject)) { ent["subject"] = note.Subject; } if (!string.IsNullOrEmpty(note.File)) { ent["documentbody"] = note.File; } if (!string.IsNullOrEmpty(note.FileName)) { ent["filename"] = note.FileName; } if (!string.IsNullOrEmpty(note.MimeType)) { ent["mimetype"] = note.MimeType; } if (!string.IsNullOrEmpty(note.Text)) { ent["notetext"] = note.Text; } returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "Dosya Ekleme başarıyla gerçekleşti."; } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return returnValue; }
private void ProcessRequests(Guid portalId) { MsCrmResultObject resultRequestList = GiftHelper.GetGiftReuqestListByStatus(portalId, GiftStatus.Confirmed, _sda); if (resultRequestList.Success) { try { List <UserGiftRequest> lstRequests = resultRequestList.GetReturnObject <List <UserGiftRequest> >(); FileLogHelper.LogFunction(this.GetType().Name, "RequestCount:" + lstRequests.Count.ToString(), @Globals.FileLogPath); foreach (UserGiftRequest req in lstRequests) { MsCrmResult result = SendToServiceBirIleri(req); if (result.Success) { req.OrderCode = result.Result; req.Status = new OptionSetValueWrapper() { AttributeValue = (int)GiftStatus.ServiceSent }; } else { req.ErrorDesc = result.Result; req.Status = new OptionSetValueWrapper() { AttributeValue = (int)GiftStatus.ServiceError }; FileLogHelper.LogFunction(this.GetType().Name, "SendToService::" + result.Result, @Globals.FileLogPath); } GiftHelper.UpdateGiftRequest(req, _service); } } catch (Exception ex) { FileLogHelper.LogFunction(this.GetType().Name, ex.Message, @Globals.FileLogPath); } } else { FileLogHelper.LogFunction(this.GetType().Name, resultRequestList.Result, @Globals.FileLogPath); } }
public static MsCrmResult QuoteHasPrePayment(Guid quoteId, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string query = @"SELECT P.new_paymentId PaymentId FROM new_payment AS P WITH (NOLOCK) WHERE P.new_type = {0} AND P.new_quoteid = '{1}' AND P.StateCode = 0"; #endregion IOrganizationService service = MSCRM.GetOrgService(true); DataTable dt = sda.getDataTable(string.Format(query, (int)PaymentTypes.KaporaOdemesi, quoteId)); Entity product = GetProductByQuoteId(service, quoteId); if (product == null) { returnValue.Success = false; return(returnValue); } Guid projectId = product.Contains("new_projectid") ? ((EntityReference)product.Attributes["new_projectid"]).Id : Guid.Empty; EntityCollection list = GetProjectSalesCollaborateList(service, projectId); if (dt != null && (dt.Rows.Count >= list.Entities.Count))//Ortaklık yapısı 2 olduğu için ÖDeme kaydı 2 adet oluşuyor { returnValue.CrmId = (Guid)dt.Rows[0]["PaymentId"]; returnValue.Result = "Satışla ilgili kapora kaydı bulunmaktadır!"; returnValue.Success = true; } //else if (dt != null && dt.Rows.Count == 0) else { returnValue.Result = "Satışla ilgili kapora kaydı bulunmamaktadır!"; returnValue.Success = false; } } catch (Exception) { throw; } return(returnValue); }
protected void btnSave_ServerClick(object sender, EventArgs e) { lblError.Visible = false; int status = Convert.ToInt32(slctType.Items[slctType.SelectedIndex].Value); if (status == 0) { lblError.Visible = true; lblError.InnerHtml = "İşlem Tipi seçiniz..."; return; } QuoteStatus quoteStatus = (QuoteStatus)status; string quoteNo = txtSalesNo.Value; Dictionary <Guid, QuoteStatus> quoteInfo = GetQuoteId(quoteNo); if (quoteInfo == null) { lblError.Visible = true; lblError.InnerHtml = "Satış bulunamadı..."; return; } else { if (quoteStatus == QuoteStatus.MuhasebeyeAktarıldı) { MsCrmResult result = QuoteHelper.Muhasebelestir(quoteInfo.Keys.FirstOrDefault().ToString()); lblError.Visible = true; lblError.InnerHtml = result.Result; return; } else //if(quoteStatus==QuoteStatus.İptalEdildi) { //if(quoteInfo.Values.FirstOrDefault()==QuoteStatus.İptalEdildi || quoteInfo.Values.FirstOrDefault()==QuoteStatus.İptalAktarıldı) //{ MsCrmResult resultIptal = IptalEt(quoteInfo.Keys.FirstOrDefault().ToString()); lblError.Visible = true; lblError.InnerHtml = resultIptal.Result; return; //} } } }
private void ProcessForms() { MsCrmResultObject resultRequestList = DiscoveryFormHelper.GetGiftReuqestListByStatus(DiscoveryFormStatus.Waiting, _sda); if (resultRequestList.Success) { try { List <DiscoveryForm> lstForms = resultRequestList.GetReturnObject <List <DiscoveryForm> >(); FileLogHelper.LogFunction(this.GetType().Name, "DiscoveryFormCount:" + lstForms.Count.ToString(), @Globals.FileLogPath); foreach (DiscoveryForm form in lstForms) { MsCrmResult result = SendToService(form); if (result.Success) { form.Status = new OptionSetValueWrapper() { AttributeValue = (int)DiscoveryFormStatus.ServiceSent }; } else { form.Status = new OptionSetValueWrapper() { AttributeValue = (int)DiscoveryFormStatus.ServiceError }; FileLogHelper.LogFunction(this.GetType().Name, "SendToService::" + result.Result, @Globals.FileLogPath); } DiscoveryFormHelper.UpdateDiscoveryForm(form, _service); } } catch (Exception ex) { FileLogHelper.LogFunction(this.GetType().Name, ex.Message, @Globals.FileLogPath); } } else { FileLogHelper.LogFunction(this.GetType().Name, resultRequestList.Result, @Globals.FileLogPath); } }
public MsCrmResult ConfirmForm(string token, int formCode) { MsCrmResult returnValue = new MsCrmResult(); LoginSession ls = new LoginSession(); try { _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); #region | CHECK SESSION | MsCrmResultObject sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return returnValue; } else { ls = (LoginSession)sessionResult.ReturnObject; } #endregion MsCrmResultObject resultFormInfo = DiscoveryFormHelper.GetDiscoveryFormInfo(formCode, _sda); if (resultFormInfo.Success) { DiscoveryForm formInfo = (DiscoveryForm)resultFormInfo.ReturnObject; formInfo.Status = new OptionSetValueWrapper() { AttributeValue = (int)DiscoveryFormStatus.LotusConfirmed }; } else { returnValue.Result = resultFormInfo.Result; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; JavaScriptSerializer serializer = new JavaScriptSerializer(); string message = string.Empty; var op = context.Request.QueryString["operation"]; if (op != null && op == "1") { var base64Data = context.Request.Form["data"]; var quoteId = context.Request.Form["quoteid"]; IOrganizationService service = MSCRM.GetOrgService(true); Entity attach = new Entity("annotation"); attach["filename"] = context.Request.Form["name"]; attach["mimetype"] = context.Request.Form["type"]; attach["filesize"] = context.Request.Form["size"]; attach["subject"] = context.Request.Form["name"]; attach["documentbody"] = base64Data; attach["objecttypecode"] = 1084; attach["isdocument"] = true; attach["objectid"] = new EntityReference("quote", new Guid(quoteId)); service.Create(attach); var data = serializer.Serialize(true); context.Response.Write(data); } else if (op == "2") { var data = context.Request.Form["data"]; JavaScriptSerializer js = new JavaScriptSerializer(); List <Activity> phoneCallList = js.Deserialize <List <Activity> >(data); MsCrmResult result = ExportPhoneCall(phoneCallList); var dataRes = serializer.Serialize(result); context.Response.Write(dataRes); } }
public static MsCrmResult SendMail(Guid ObjectId, string ObjectType, Entity[] fromPartyArray, Entity[] toPartyArray, string subject, string mailBody, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { #region Create Email Entity email = new Entity("email"); email["to"] = toPartyArray; email["from"] = fromPartyArray; email["subject"] = subject; email["description"] = mailBody; email["directioncode"] = true; if (ObjectId != Guid.Empty && !string.IsNullOrEmpty(ObjectType)) { EntityReference regardingObject = new EntityReference(ObjectType, ObjectId); email.Attributes.Add("regardingobjectid", regardingObject); } returnValue.CrmId = service.Create(email); #endregion #region Send Email if (Globals.IsSendMailActive == "1") { var req = new SendEmailRequest { EmailId = returnValue.CrmId, TrackingToken = string.Empty, IssueSend = true }; var res = (SendEmailResponse)service.Execute(req); } #endregion returnValue.Success = true; } catch (Exception ex) { } return(returnValue); }
public static MsCrmResult CreateSmsRecord(IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { returnValue.Success = true; returnValue.CrmId = Guid.NewGuid(); returnValue.Result = "Sms kaydı oluşturuldu."; } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public MsCrmResult Process() { MsCrmResult returnValue = new MsCrmResult(); string[] filePaths = Directory.GetFiles(@_dataFolder, "*.xlsx"); if (filePaths.Length > 0) { for (int i = 0; i < filePaths.Length; i++) { //MsCrmResult resultUpload = SendFile(filePaths[i], Path.GetFileName(filePaths[i])); //upload(Path.GetFileName(filePaths[i]), filePaths[i]); UploadViaSftp(filePaths[i]); } } return(returnValue); }
/// <summary> /// Konut önceden aktiviteye ilgilendiği konut olarak eklenmiş mi kontrol eder. /// Telefon görüşmesine ve randevuyu ayrı ayrı kontrol etmek için ikiside parametre olarak alınmıştır. /// </summary> /// <param name="productId"></param> /// <param name="phonecallId"></param> /// <param name="appointmentId"></param> /// <param name="sda"></param> /// <returns></returns> public static MsCrmResult HasAddedInterestedHouse(Guid productId, Guid phonecallId, Guid appointmentId, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string query = @"SELECT COUNT(0) Sonuc FROM new_interestedproducts IP WITH (NOLOCK) WHERE IP.new_productid = '{0}' AND IP.StateCode = 0" ; if (phonecallId != Guid.Empty) { query += " AND IP.new_phonecallid = '{1}'"; query = string.Format(query, productId, phonecallId); } else { query += " AND IP.new_appointmentid = '{1}'"; query = string.Format(query, productId, appointmentId); } #endregion int sonuc = (int)sda.ExecuteScalar(query); if (sonuc > 0) { returnValue.Success = false; returnValue.Result = "Seçilen konut aktivitede ilgilendiği konut olarak bulunmaktadır!"; } else { returnValue.Success = true; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return(returnValue); }
static void Main(string[] args) { MsCrmResult resultExpenseCenter = ExpenseCenterProcess.Process(); if (resultExpenseCenter.Success) { Console.SetCursorPosition(0, 5); Console.WriteLine(resultExpenseCenter.Result); } MsCrmResult resultSales = SalesProcess.Process(); if (resultSales.Success) { Console.SetCursorPosition(0, 6); Console.WriteLine(resultSales.Result); } }
public MsCrmResult AnswerNpsSurvey(string npsSurveyId, int suggest, int suggestPoint) { MsCrmResult returnValue = new MsCrmResult(); try { IOrganizationService service = MSCRM.GetOrgService(true); returnValue = AssemblyRequestHelper.AnswerNpsSurvey(new Guid(npsSurveyId), suggest, suggestPoint, service); } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CheckIdentityNumber(string identityNumber) { MsCrmResult returnValue = new MsCrmResult(); returnValue.Success = true; if (identityNumber.Length != 11) { returnValue.Success = false; returnValue.Result = "Müşterinin Tc Kimlik Numarası eksik girildi!"; return(returnValue); } int pr1 = int.Parse(identityNumber.Substring(0, 1)); int pr2 = int.Parse(identityNumber.Substring(1, 1)); int pr3 = int.Parse(identityNumber.Substring(2, 1)); int pr4 = int.Parse(identityNumber.Substring(3, 1)); int pr5 = int.Parse(identityNumber.Substring(4, 1)); int pr6 = int.Parse(identityNumber.Substring(5, 1)); int pr7 = int.Parse(identityNumber.Substring(6, 1)); int pr8 = int.Parse(identityNumber.Substring(7, 1)); int pr9 = int.Parse(identityNumber.Substring(8, 1)); int pr10 = int.Parse(identityNumber.Substring(9, 1)); int pr11 = int.Parse(identityNumber.Substring(10, 1)); if ((pr1 + pr3 + pr5 + pr7 + pr9 + pr2 + pr4 + pr6 + pr8 + pr10) % 10 != pr11) { returnValue.Success = false; returnValue.Result = "Müşterinin TC Kimlik Numarası hatalı!"; return(returnValue); } if (((pr1 + pr3 + pr5 + pr7 + pr9) * 7 + (pr2 + pr4 + pr6 + pr8) * 9) % 10 != pr10) { returnValue.Success = false; returnValue.Result = "Müşterinin TC Kimlik Numarası hatalı!"; return(returnValue); } if (((pr1 + pr3 + pr5 + pr7 + pr9) * 8) % 10 != pr11) { returnValue.Success = false; returnValue.Result = "Müşterinin TC Kimlik Numarası hatalı!"; return(returnValue); } return(returnValue); }
public static MsCrmResult CreateUserGiftRequest(UserGiftRequest userGiftRequest, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = userGiftRequest.ToCrmEntity(); returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = userGiftRequest.Point.ToString() + " puana sahip hediye talebiniz alınmıştır."; } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult UpdateDiscoveryForm(DiscoveryForm discoveryForm, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = discoveryForm.ToCrmEntity(); service.Update(ent); returnValue.Success = true; returnValue.Result = "Form kaydedildi."; } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResult UpdateGiftRequest(UserGiftRequest userGiftRequest, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = userGiftRequest.ToCrmEntity(); service.Update(ent); returnValue.Success = true; returnValue.Result = "Hediye talebi güncellendi"; } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResult CreateUserGiftRequest(UserGiftRequest userGiftRequest, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = userGiftRequest.ToCrmEntity(); returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = userGiftRequest.Point.ToString() + " puana sahip hediye talebiniz alınmıştır."; } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResult CreateUserCodeUsage(UserCodeUsage userCodeUsage, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = userCodeUsage.ToCrmEntity(); returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = userCodeUsage.Point.ToString() + " puan kazandınız."; } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CreateDiscoveryForm(DiscoveryForm discoveryForm, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = discoveryForm.ToCrmEntity(); returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "Form kaydedildi."; } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult UpdateProfileImage(Guid userId, string fileName, string fieldName, SqlDataAccess sda, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { #region | DELETE PREVIOUS IMAGE FILE | string oldFileName = AttachmentFileHelper.GetEntityProfileImageFileName(userId.ToString(), "new_user", fieldName, sda); if (!string.IsNullOrEmpty(oldFileName)) { //string filePath = HostingEnvironment.MapPath("~/attachments") + "/" + oldFileName; string filePath = @Globals.AttachmentFolder + @"\" + oldFileName; if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } } #endregion #region | UPDATE CRM ENTITY | Entity ent = new Entity("new_user"); ent.Id = userId; ent[fieldName] = fileName; service.Update(ent); #endregion returnValue.Success = true; returnValue.Result = fileName; } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResult GetPortalId(string url, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string query = @"SELECT u.new_portalId AS BrandId FROM new_portalurl AS u (NOLOCK) JOIN new_portal AS b (NOLOCK) ON b.new_portalId=u.new_portalId AND b.statecode=0 AND b.statuscode=1 --Active WHERE u.new_name='{0}' AND u.statecode=0"; #endregion DataTable dt = sda.getDataTable(string.Format(query, url)); if (dt != null && dt.Rows.Count > 0) { returnValue.CrmId = (Guid)dt.Rows[0]["BrandId"]; returnValue.Success = true; } else { returnValue.Result = "M004"; //"Girmiş olduğunuz adres herhangi bir portala ait değil."; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CheckIsUserYourFriend(Guid portalId, Guid portalUserId, Guid selectedUserId, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string query = @"SELECT f.new_friendshipId AS Id FROM new_friendship AS f (NOLOCK) WHERE f.new_portalId='{0}' AND f.statecode=0 AND ( (f.new_partyoneId='{1}' AND f.new_partytwoId='{2}') OR (f.new_partyoneId='{2}' AND f.new_partytwoId='{1}') )"; #endregion DataTable dt = sda.getDataTable(string.Format(query, portalId, portalUserId, selectedUserId)); if (dt != null && dt.Rows.Count > 0) { returnValue.Success = true; returnValue.CrmId = (Guid)dt.Rows[0]["Id"]; } else { returnValue.Success = false; returnValue.Result = "M039"; //"Kullanıcı arkadaşınız değildir!"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CreateAssemblyRequest(AssemblyRequestInfo requestInfo, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = requestInfo.ToCrmEntity(); returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "Talep kaydedildi."; } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } return returnValue; }
public MsCrmResult AnswerSurvey(string token, SurveyAnswer answer) { MsCrmResult returnValue = new MsCrmResult(); LoginSession ls = new LoginSession(); try { if (!string.IsNullOrEmpty(token)) { #region | CHECK SESSION | MsCrmResultObject sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return returnValue; } else { ls = (LoginSession)sessionResult.ReturnObject; } #endregion IOrganizationService service = MSCRM.GetOrgService(true); returnValue = SurveyHelper.AnswerSurvey(answer, service); } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-AnswerSurvey"; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult GetPageContent(Guid portalId, PageNames pageName, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string sqlQuery = @"SELECT pc.new_content AS Content FROM new_pagecontent AS pc (NOLOCK) WHERE pc.new_portalId='{0}' AND pc.new_page={1} AND pc.statecode=0"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, portalId, ((int)pageName).ToString())); if (dt.Rows.Count > 0) { if (dt.Rows[0]["Content"] != DBNull.Value) { returnValue.Success = true; returnValue.Result = dt.Rows[0]["Content"].ToString(); } } else { returnValue.Result = "M051"; //"Sayfa içeriği hazırlanmamıştır."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult LoginControl(Guid portalId, string userName, string password, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string query = @"SELECT U.new_userId UserId FROM new_user U (NoLock) WHERE U.new_name = '{0}' AND U.new_password = '******' AND U.statecode = 0 AND U.statuscode = {2}"; #endregion DataTable dt = sda.getDataTable(string.Format(query, userName, password, (int)PortalUserStatus.Active)); if (dt != null && dt.Rows.Count > 0) { returnValue.CrmId = (Guid)dt.Rows[0]["UserId"]; MsCrmResultObject roleResult = PortalUserHelper.GetPortalUserRoles(portalId, returnValue.CrmId, sda); returnValue.Success = roleResult.Success; returnValue.Result = roleResult.Result; } else { returnValue.Success = false; returnValue.Result = "M035"; //"Hatalı kullanıcı adı veya şifre!"; } } catch (Exception ex) { throw ex; } return returnValue; }
public static MsCrmResult CloseFriendshipRequest(Guid requestId, FriendshipRequestStatus statusCode, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { SetStateRequest setStateReq = new SetStateRequest(); setStateReq.EntityMoniker = new EntityReference("new_friendshiprequest", requestId); setStateReq.State = new OptionSetValue(1); setStateReq.Status = new OptionSetValue((int)statusCode); SetStateResponse response = (SetStateResponse)service.Execute(setStateReq); returnValue.Success = true; returnValue.Result = "M041"; //"Arkadaşlık talebiniz durumu güncellendi."; } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CloseFriendship(Guid friendshipId, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { SetStateRequest setStateReq = new SetStateRequest(); setStateReq.EntityMoniker = new EntityReference("new_friendship", friendshipId); setStateReq.State = new OptionSetValue(1); setStateReq.Status = new OptionSetValue(2); SetStateResponse response = (SetStateResponse)service.Execute(setStateReq); returnValue.Success = true; returnValue.Result = "M044"; //"Arkadaşlığınız iptal edilmiştir."; } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult DislikeEntity(Guid portalId, Guid portalUserId, Guid entityId, string entityName, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_likerecord"); ent["new_name"] = DateTime.Now.ToString("dd.MM.yyyy HH:mm"); ent["new_portalid"] = new EntityReference("new_portal", portalId); ent["new_userid"] = new EntityReference("new_user", portalUserId); ent["new_liketype"] = false; ent[entityName + "id"] = new EntityReference(entityName, entityId); returnValue.CrmId = service.Create(ent); returnValue.Result = "M055"; returnValue.Success = true; } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CreateScore(Score score, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_score"); ent["new_name"] = score.ScoreType.ToString() + "-" + score.User.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy HH:mm"); ent["new_portalid"] = score.Portal; ent["new_userid"] = score.User; ent["new_point"] = score.Point; ent["new_scoretype"] = new OptionSetValue((int)score.ScoreType); returnValue.CrmId = service.Create(ent); returnValue.Success = true; } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult AnswerNpsSurvey(Guid npsSurveyId, int suggest, int suggestPoint, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_npssurvey"); ent.Id = npsSurveyId; ent["new_issuggest"] = new OptionSetValue(suggest); ent["new_suggestpoint"] = suggestPoint; ent["statuscode"] = new OptionSetValue((int)NpsSurveyStatus.Answered); service.Update(ent); returnValue.Success = true; returnValue.Result = "Nps Survey güncellendi."; } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult SaveOrUpdateGraffiti(Graffiti graffiti, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_graffiti"); ent["new_name"] = graffiti.PortalUser.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy HH:mm"); ent["new_hasmedia"] = graffiti.HasMedia; if (graffiti.PortalUser != null) { ent["new_userid"] = graffiti.PortalUser; } if (graffiti.Portal != null) { ent["new_portalid"] = graffiti.Portal; } if (!string.IsNullOrEmpty(graffiti.Description)) { ent["new_content"] = graffiti.Description; } if (!string.IsNullOrEmpty(graffiti.ImagePath)) { ent["new_imageurl"] = graffiti.ImagePath; } if (graffiti.GraffitiId != Guid.Empty) { ent["new_graffitiid"] = graffiti.GraffitiId; service.Update(ent); returnValue.Success = true; returnValue.Result = "M014"; //"Duvar yazısı güncellendi."; } else { returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "M015"; //"Duvar yazısı oluşturuldu."; } } catch (Exception ex) { returnValue.Result = ex.Message; returnValue.Success = false; } return returnValue; }
public static MsCrmResult IsUserLikedBefore(Guid entityId, string entityName, Guid portalUserId, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string query = @"SELECT COUNT(0) AS RecCount FROM new_likerecord AS l (NOLOCK) WHERE l.{1}Id='{0}' AND l.new_userId='{2}' AND l.statecode=0"; #endregion int reCount = (int)sda.ExecuteScalar(string.Format(query, entityId, entityName, portalUserId)); if (reCount > 0) { returnValue.Success = true; returnValue.Result = "M054"; //"Önceden beğeni kaydınız vardır."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult ReportImproperContent(Guid portalId, Guid portalUserId, Guid entityId, string entityName, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity(entityName.ToLower()); ent[entityName.ToLower() + "id"] = entityId; ent["new_isimpropercontent"] = true; service.Update(ent); returnValue.Result = "M096"; returnValue.Success = true; } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult CreateOrUpdateProfile(Contact contact, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("contact"); if (!string.IsNullOrEmpty(contact.MobilePhone)) { ent["mobilephone"] = contact.MobilePhone; } if (!string.IsNullOrEmpty(contact.WorkPhone)) { ent["telephone1"] = contact.WorkPhone; } if (!string.IsNullOrEmpty(contact.IdentityNumber)) { ent["new_identitynumber"] = contact.IdentityNumber; } if (contact.Gender != null) { ent["gendercode"] = new OptionSetValue((int)contact.Gender); } if (contact.BirthDate != null) { ent["birthdate"] = contact.BirthDate; } if (!string.IsNullOrEmpty(contact.Description)) { ent["description"] = contact.Description; } if (!string.IsNullOrEmpty(contact.EmailAddress)) { ent["emailaddress1"] = contact.EmailAddress; } if (!string.IsNullOrEmpty(contact.FirstName)) { ent["firstname"] = contact.FirstName; } if (!string.IsNullOrEmpty(contact.LastName)) { ent["lastname"] = contact.LastName; } if (!string.IsNullOrEmpty(contact.Title)) { ent["jobtitle"] = contact.Title; } if (!string.IsNullOrEmpty(contact.FunctionName)) { ent["new_functionname"] = contact.FunctionName; } if (contact.ParentAccount != null) { ent["parentaccountid"] = contact.ParentAccount; } if (contact.CityId != null) { ent["new_cityid"] = contact.CityId; } if (contact.TownId != null) { ent["new_townid"] = contact.TownId; } if (!string.IsNullOrEmpty(contact.AddressDetail)) { ent["new_addressdetail"] = contact.AddressDetail; } if (contact.MarkContact != null) { ent["new_markcontact"] = contact.MarkContact; } if (contact.ContactId != Guid.Empty) { ent["contactid"] = contact.ContactId; service.Update(ent); returnValue.Success = true; returnValue.Result = "M009"; //"Profil güncellendi."; } else { returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "M010"; //"Profil oluşturuldu."; } } catch (Exception ex) { throw ex; } return returnValue; }
public static MsCrmResult HasUserQuestionLimit(Guid portalUserId, Guid portalId, SqlDataAccess sda) { MsCrmResult returnValue = new MsCrmResult(); try { #region | SQL QUERY | string query = @" DECLARE @now DATETIME DECLARE @startDate DATETIME DECLARE @endDate DATETIME DECLARE @current INT DECLARE @limit INT DECLARE @hasLimit BIT SET @now=GETUTCDATE() SELECT @limit=sl.new_frequency ,@startDate= CASE WHEN sl.new_scoreperiod=100000000 --DAILY THEN {2}.dbo.fn_BeginOfToday(@now) ELSE CASE WHEN sl.new_scoreperiod=100000001 --WEEKLY THEN {2}.dbo.fn_BeginOfThisWeek(@now) ELSE CASE WHEN sl.new_scoreperiod=100000002 --MONTHLY THEN {2}.dbo.fn_BeginOfThisMonth(@now) ELSE {2}.dbo.fn_BeginOfThisYear(@now) END END END ,@endDate= CASE WHEN sl.new_scoreperiod=100000000 --DAILY THEN {2}.dbo.fn_EndOfToday(@now) ELSE CASE WHEN sl.new_scoreperiod=100000001 --WEEKLY THEN {2}.dbo.fn_EndOfThisWeek(@now) ELSE CASE WHEN sl.new_scoreperiod=100000003 --MONTHLY THEN {2}.dbo.fn_EndOfThisMonth(@now) ELSE {2}.dbo.fn_EndOfThisYear(@now) END END END FROM new_scorelimit AS sl (NOLOCK) WHERE sl.new_scoretype=100000000 --InfoCube SELECT @current = COUNT(0) FROM new_questionanswers AS ans (NOLOCK) WHERE ans.new_portalId='{1}' AND ans.new_userId='{0}' AND ans.statecode=0 AND ans.statuscode=1 --Active AND ans.CreatedOn BETWEEN @startDate AND @endDate SELECT @hasLimit= CASE WHEN @current < @limit OR @limit IS NULL THEN 1 ELSE 0 END SELECT @hasLimit"; #endregion returnValue.Success = (bool)sda.ExecuteScalar(string.Format(query, portalUserId, portalId, Globals.DatabaseName)); } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult PassiveCode(Guid pointCodeId, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { SetStateRequest setStateReq = new SetStateRequest(); setStateReq.EntityMoniker = new EntityReference("new_pointcode", pointCodeId); setStateReq.State = new OptionSetValue(1); setStateReq.Status = new OptionSetValue(2); SetStateResponse response = (SetStateResponse)service.Execute(setStateReq); returnValue.Success = true; returnValue.Result = "Kod kullanıldı"; } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResult SaveOrUpdateAnswer(Answer answer, IOrganizationService service) { MsCrmResult returnValue = new MsCrmResult(); try { Entity ent = new Entity("new_questionanswers"); ent["new_name"] = answer.User.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy"); ent["new_istrust"] = answer.IsTrust; ent["new_istimeover"] = answer.IsTimeOverlap; ent["new_isrefreshorback"] = answer.IsRefreshOrBack; #region | SET POINT | ent["new_point"] = 0; if (answer.IsCorrect) { if (answer.IsTrust) { ent["new_point"] = 2 * answer.Point; } else { ent["new_point"] = answer.Point; } } if (answer.IsTrust && (!answer.IsCorrect || answer.IsRefreshOrBack || answer.IsTimeOverlap)) { ent["new_point"] = -1 * answer.Point; } #endregion if (answer.Question != null) { ent["new_questionid"] = answer.Question; } if (answer.Portal != null) { ent["new_portalid"] = answer.Portal; } if (answer.Choice != null) { ent["new_questionchoiceid"] = answer.Choice; } if (answer.User != null) { ent["new_userid"] = answer.User; } if (answer.Id != Guid.Empty) { ent["new_questionanswersid"] = answer.Id; service.Update(ent); returnValue.Success = true; returnValue.Result = "Cevap kaydı güncellendi."; } else { returnValue.CrmId = service.Create(ent); returnValue.Success = true; returnValue.Result = "M031"; //"Cevap kaydı oluşturuldu."; } } catch (Exception) { throw; } return returnValue; }
public MsCrmResult SetUserSession(string token, Guid portalId, Guid portalUserId) { MsCrmResult returnValue = new MsCrmResult(); try { LoginSession ls = new LoginSession() { Token = token, PortalId = portalId, PortalUserId = portalUserId }; HttpContext.Current.Cache.Add(token, ls, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null); returnValue.Success = true; returnValue.Result = "Oturum bilgileri işlendi"; } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }