public SendSms() { InitializeComponent(); try { LOG_PATH = Globals.FileLogPath; ERROR_LOG_PATH = Globals.FileLogPath; _tokenSource = new CancellationTokenSource(); _token = _tokenSource.Token; _timer = new System.Timers.Timer(); _timer.Interval = Convert.ToDouble(ConfigurationManager.AppSettings["serviceInterval"]); _timer.AutoReset = true; _timer.Enabled = true; _timer.Elapsed += timer_Elapsed; _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); _service = MSCRM.GetOrgService(true); _serviceProcess = new ServiceProcess(_sda, _service); } catch (Exception ex) { FileLogHelper.LogFunction(this.GetType().Name, "SendSms_SendSms_EXCEPTION:" + ex.Message, ERROR_LOG_PATH); } }
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 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 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 |DEFINE IMAGE IF EXISTS| Entity postImage = null; if (context.PostEntityImages.Contains("PostImage") && context.PostEntityImages["PostImage"] is Entity) { postImage = (Entity)context.PostEntityImages["PostImage"]; } #endregion #region | VARIABLES | List<ScoreLimit> lstLimits = new List<ScoreLimit>(); EntityReference portal = null; EntityReference user = null; if (postImage.Contains("new_portalid") && postImage["new_portalid"] != null) { portal = (EntityReference)postImage["new_portalid"]; } if (postImage.Contains("new_userid") && postImage["new_userid"] != null) { user = (EntityReference)postImage["new_userid"]; } #endregion if (entity.Contains("statuscode") && entity["statuscode"] != null && ((OptionSetValue)entity["statuscode"]).Value == 1) { MsCrmResultObject limitRes = ScoreHelper.GetScoreLimitsByType(ScoreType.ForumSubject, sda); if (limitRes.Success) { lstLimits = (List<ScoreLimit>)limitRes.ReturnObject; for (int i = 0; i < lstLimits.Count; i++) { int recCount = 0; DateTime start = GeneralHelper.GetStartDateByScorePeriod(lstLimits[i].Period); DateTime end = GeneralHelper.GetEndDateByScorePeriod(lstLimits[i].Period); recCount = ForumHelper.GetUserForumSubjectCount(portal.Id, user.Id, start, end, sda); if (lstLimits[i].Frequency >= recCount) { Score sc = new Score() { Point = lstLimits[i].Point, Portal = portal, User = user, ScoreType = ScoreType.ForumSubject }; MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service); break; } } } } } catch (Exception ex) { //LOG throw new InvalidPluginExecutionException(ex.Message); } finally { if (sda != null) sda.closeConnection(); } }
public void ProcessRequest(HttpContext context) { FileLogHelper.LogEvent("Kale-uploadHelper", @"C:\DO\"); context.Response.ContentType = "application/json"; object returnValue = null; JavaScriptSerializer serializer = new JavaScriptSerializer(); try { _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); string operation = context.Request.QueryString["operation"]; string userId = context.Request.QueryString["userid"]; string graffitiId = context.Request.QueryString["graffitiId"]; if (operation == "1" && !string.IsNullOrEmpty(userId)) //Profile resmi güncelleme { returnValue = new MsCrmResult(); _service = MSCRM.GetOrgService(true); HttpPostedFile file = context.Request.Files[0]; returnValue = SaveProfileImage(userId, file, context); } else if (operation == "2" && !string.IsNullOrEmpty(graffitiId)) //Duvar yazısı resim ekleme { returnValue = new MsCrmResult(); _service = MSCRM.GetOrgService(true); HttpPostedFile file = context.Request.Files[0]; returnValue = SaveGraffitiImage(new Guid(graffitiId), file, context); } else { ((MsCrmResultObject)returnValue).Result = "Eksik veya yanlış parametre."; } } catch (Exception ex) { returnValue = new MsCrmResult(); ((MsCrmResult)returnValue).HasException = true; ((MsCrmResult)returnValue).Result = ex.Message; } finally { if (_sda != null) { _sda.closeConnection(); } } var dataRes = serializer.Serialize(returnValue); context.Response.Write(dataRes); }
public MsCrmResult CheckIsUserYourFriend(string token, string selectedUserId) { MsCrmResult returnValue = new MsCrmResult(); LoginSession ls = new LoginSession(); try { if (!string.IsNullOrEmpty(token) && !string.IsNullOrEmpty(selectedUserId)) { #region | CHECK SESSION | MsCrmResultObject sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return returnValue; } else { ls = (LoginSession)sessionResult.ReturnObject; } #endregion sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = FriendshipHelper.CheckIsUserYourFriend(ls.PortalId, ls.PortalUserId, new Guid(selectedUserId), sda); } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-CheckIsUserYourFriend"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message + "-CheckIsUserYourFriend"; } finally { if (sda != null) { sda.closeConnection(); } } return returnValue; }
public List<Annotation> GetAnnotations(string objectId) { List<Annotation> returnList = new List<Annotation>(); try { if (!string.IsNullOrEmpty(objectId)) { sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnList = AnnotationHelper.GetAnnotationListByObject(new Guid(objectId), sda); } } catch (Exception) { } finally { if (sda != null) { sda.closeConnection(); } } return returnList; }
public MsCrmResult DislikeEntity(string token, string entityId, string entityName) { 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 sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = LikeHelper.IsUserLikedBefore(new Guid(entityId), entityName, ls.PortalUserId, sda); if (!returnValue.Success) { IOrganizationService service = MSCRM.GetOrgService(true); returnValue = LikeHelper.DislikeEntity(ls.PortalId, ls.PortalUserId, new Guid(entityId), entityName, service); } else { returnValue.Success = false; } } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-LikeEntity"; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public MsCrmResult SaveAnswer(string token, Answer 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 sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); IOrganizationService service = MSCRM.GetOrgService(true); if (!answer.IsRefreshOrBack && !answer.IsTimeOverlap && answer.Choice != null && answer.Choice.Id != Guid.Empty) { List<QuestionChoices> choices = (List<QuestionChoices>)QuestionHelper.GetQuestionChoices(answer.Question.Id, sda).ReturnObject; var query = (from a in choices where a.IsCorrect == true && a.Id == answer.Choice.Id select a).ToList(); if (query.Count > 0) { answer.IsCorrect = true; } else { answer.IsCorrect = false; } } returnValue = AnswerHelper.SaveOrUpdateAnswer(answer, service); if (returnValue.Success) { if (!answer.IsRefreshOrBack && !answer.IsTimeOverlap && answer.Choice != null && answer.Choice.Id != Guid.Empty) { if (answer.IsCorrect) { returnValue.Result = "Cevabınız doğru " + (answer.IsTrust ? (2 * answer.Point).ToString() : answer.Point.ToString()) + " puan kazandınız!"; } else { returnValue.Success = false; returnValue.Result = "Cevabınız yanlış.<br /><strong>" + (answer.IsTrust ? answer.Point.ToString() + " puan kaybettiniz." : string.Empty) + "</strong>"; } } else { returnValue.Success = false; returnValue.Result = (answer.IsTimeOverlap ? "<p>Zaman doldu!<br /><strong>" : "Sayfadan çıktınız!<br /><strong>") + (answer.IsTrust ? answer.Point.ToString() + " puan kaybettiniz." : string.Empty) + "</strong></p>"; } } } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-SaveAnswer"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message + "-SaveAnswer"; } finally { if (sda != null) sda.closeConnection(); } return returnValue; }
public string HasUserRequestWithYou(string token, string selectedUserId) { MsCrmResultObject returnValue = new MsCrmResultObject(); LoginSession ls = new LoginSession(); JavaScriptSerializer ser = new JavaScriptSerializer(); string json = string.Empty; try { if (!string.IsNullOrEmpty(token) && !string.IsNullOrEmpty(selectedUserId)) { #region | CHECK SESSION | MsCrmResultObject sessionResult = GetUserSession(token); if (!sessionResult.Success) { json = ser.Serialize(sessionResult); return json; } else { ls = (LoginSession)sessionResult.ReturnObject; } #endregion sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = FriendshipHelper.HasUserRequestWithYou(ls.PortalId, ls.PortalUserId, new Guid(selectedUserId), sda); } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-HasUserRequestWithYou"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message + "-HasUserRequestWithYou"; } finally { if (sda != null) { sda.closeConnection(); } } json = ser.Serialize(returnValue); return json; }
public MsCrmResult HasUserQuestionLimit(string token) { 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 sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = QuestionHelper.HasUserQuestionLimit(ls.PortalUserId, ls.PortalId, sda); if (!returnValue.Success) { returnValue.Result = "M034"; //"Limitiniz dolmuştur. <br /> İşlem limitleri hakkında bilgi almak için ilgili birim ile görüşünüz."; } } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-HasUserQuestionLimit"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message + "-HasUserQuestionLimit"; } finally { if (sda != null) sda.closeConnection(); } return returnValue; }
public MsCrmResult CloseFriendshipRequest(string token, string requestId, int statusCode) { 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 sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); IOrganizationService service = MSCRM.GetOrgService(true); returnValue = FriendshipHelper.CloseFriendshipRequest(new Guid(requestId), (FriendshipRequestStatus)statusCode, service); if (returnValue.Success) { FriendshipRequest req = new FriendshipRequest(); MsCrmResultObject reqResult = FriendshipHelper.GetFriendshipRequestInfo(new Guid(requestId), sda); if (reqResult.Success && ((FriendshipRequestStatus)statusCode) == FriendshipRequestStatus.Accepted) { req = (FriendshipRequest)reqResult.ReturnObject; Friendship fr = new Friendship(); fr.PartyOne = req.From; fr.PartyTwo = req.To; fr.Portal = req.Portal; fr.FriendshipRequest = new EntityReference("new_friendshiprequest", req.Id); returnValue = FriendshipHelper.CreateFriendship(fr, service); } } } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-CloseFriendshipRequest"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message; } finally { if (sda != null) sda.closeConnection(); } return returnValue; }
public string GetVideoCategoryInfo(string token, string categoryId) { MsCrmResultObject returnValue = new MsCrmResultObject(); LoginSession ls = new LoginSession(); JavaScriptSerializer ser = new JavaScriptSerializer(); string json = string.Empty; try { if (!string.IsNullOrEmpty(token)) { #region | CHECK SESSION | MsCrmResultObject sessionResult = GetUserSession(token); if (!sessionResult.Success) { json = ser.Serialize(sessionResult); return json; } else { ls = (LoginSession)sessionResult.ReturnObject; } #endregion sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = VideoHelper.GetVideoCategoryInfo(new Guid(categoryId), sda); } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre! } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message + "-GetVideoCategoryInfo"; } finally { if (sda != null) { sda.closeConnection(); } } json = ser.Serialize(returnValue); return json; }
public string GetUserRecentContacts(string token) { List<MessageInfo> userRecentMessages = null; LoginSession loginSession = new LoginSession(); try { if (!string.IsNullOrEmpty(token)) { MsCrmResultObject userSession = this.GetUserSession(token); if (userSession.Success) { loginSession = (LoginSession)userSession.ReturnObject; sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); userRecentMessages = MessageHelper.GetUserRecentContacts(loginSession.PortalId, loginSession.PortalUserId, sda); } } } finally { if (this.sda != null) { this.sda.closeConnection(); } } JavaScriptSerializer ser = new JavaScriptSerializer(); string json = ser.Serialize(userRecentMessages); return json; }
public List<EntityReference> GetTowns(string cityId) { List<EntityReference> returnValue = new List<EntityReference>(); try { sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); #region | SQL QUERY | string sqlQuery = @"SELECT t.new_townId AS Id ,t.new_name AS Name ,'new_town' AS LogicalName FROM new_town AS t (NOLOCK) WHERE t.new_cityId='{0}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, cityId)); returnValue = dt.ToList<EntityReference>(); } catch (Exception ex) { } finally { if (sda != null) sda.closeConnection(); } return returnValue; }
public MsCrmResult CreateUserGiftRequest(string token, string giftId) { 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); sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); MsCrmResultObject resultGetGiftInfo = GiftHelper.GetGiftInfo(new Guid(giftId), sda); MsCrmResultObject resultUserInfo = PortalUserHelper.GetPortalUserDetail(ls.PortalId, ls.PortalUserId, sda); int userPoint = ScoreHelper.GetUserScore(ls.PortalId, ls.PortalUserId, sda); if (resultGetGiftInfo.Success) { Gift gift = resultGetGiftInfo.GetReturnObject<Gift>(); PortalUser userInfo = resultUserInfo.GetReturnObject<PortalUser>(); TelephoneNumber telNo = ValidationHelper.CheckTelephoneNumber(userInfo.ContactInfo.MobilePhone); if (!telNo.isFormatOK) { returnValue.Success = false; returnValue.Result = "Cep telefonu bilginiz eksik veya formatı hatalıdır. Profilim bölümünden Cep telefpnu bilginizi güncelleyebilirsiniz."; return returnValue; } #region | POINT CONTROL | if (userPoint < gift.Point) { returnValue.Success = false; returnValue.Result = "Mevcut puanınız: " + userPoint.ToString() + ", hediye talebi için yeterli değildir."; return returnValue; } #endregion #region | ADDRESS CONTROL | if (userInfo.ContactInfo.CityId == null || userInfo.ContactInfo.TownId == null || string.IsNullOrEmpty(userInfo.ContactInfo.AddressDetail)) { returnValue.Success = false; returnValue.Result = "Adres bilgilerinizin tam olması gerekmektedir. Lütfen Profilim sayfasından Adres Bilgilerinizi güncelleyiniz"; return returnValue; } #endregion UserGiftRequest req = new UserGiftRequest(); req.Name = gift.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy"); req.PortalId = new EntityReferenceWrapper() { Id = ls.PortalId, LogicalName = "new_portal" }; req.UserId = new EntityReferenceWrapper() { Id = ls.PortalUserId, LogicalName = "new_user" }; req.GiftId = new EntityReferenceWrapper() { Id = gift.Id, Name = gift.Name, LogicalName = "new_gift" }; req.Point = gift.Point; returnValue = GiftHelper.CreateUserGiftRequest(req, service); if (returnValue.Success) { Score sc = new Score() { Point = gift.Point * -1, Portal = req.PortalId.ToCrmEntityReference(), User = req.UserId.ToCrmEntityReference(), ScoreType = ScoreType.UsePoint }; MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service); } } else { returnValue.Result = resultGetGiftInfo.Result; } } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-CreateForumSubject"; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public MsCrmResult SaveDiscoveryForm(string token, DiscoveryForm discForm) { 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 #region | VALIDATION | if (string.IsNullOrEmpty(discForm.FirstName)) { returnValue.Result = "Ad alanı boş olamaz"; return returnValue; } if (string.IsNullOrEmpty(discForm.LastName)) { returnValue.Result = "Soyadı alanı boş olamaz"; return returnValue; } if (string.IsNullOrEmpty(discForm.PhoneNumber)) { returnValue.Result = "Telefon Numarası alanı boş olamaz"; return returnValue; } if (string.IsNullOrEmpty(discForm.Email)) { returnValue.Result = "Email alanı boş olamaz"; return returnValue; } if (discForm.CityId == null || discForm.CityId.Id == Guid.Empty) { returnValue.Result = "İl alanı boş olamaz"; return returnValue; } if (discForm.TownId == null || discForm.TownId.Id == Guid.Empty) { returnValue.Result = "İlçe alanı boş olamaz"; return returnValue; } //if (discForm.HomeType == null || discForm.HomeType.AttributeValue == null || discForm.HomeType.AttributeValue == 0) //{ // returnValue.Result = "Konut Tipi alanı boş olamaz"; // return returnValue; //} //if (discForm.VisitDate == null) //{ // returnValue.Result = "En Uygun Tarih alanı boş olamaz"; // return returnValue; //} //if (discForm.VisitHour == null || discForm.VisitHour.AttributeValue == null || discForm.VisitHour.AttributeValue == 0) //{ // returnValue.Result = "En Uygun Saat alanı boş olamaz"; // return returnValue; //} //if (discForm.InformedBy == null || discForm.InformedBy.AttributeValue == null || discForm.InformedBy.AttributeValue == 0) //{ // returnValue.Result = "Kale 7/24'ü nereden duydunuz? alanı boş olamaz"; // return returnValue; //} #endregion IOrganizationService service = MSCRM.GetOrgService(true); sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); discForm.Name = discForm.UserId.Name + "|" + DateTime.Now.ToString("dd.MM.yyyy HH:mm"); returnValue = DiscoveryFormHelper.CreateDiscoveryForm(discForm, service); } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!"; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public string GetAnnotationDetail(string objectId) { MsCrmResultObject returnValue = new MsCrmResultObject(); try { if (!string.IsNullOrEmpty(objectId)) { sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = AnnotationHelper.GetAnnotationDetailByObject(new Guid(objectId), sda); } else { returnValue.Success = false; returnValue.Result = "Eksik parametre!-GetAnnotationDetail"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message + "-GetAnnotationDetail"; } finally { if (sda != null) { sda.closeConnection(); } } JavaScriptSerializer ser = new JavaScriptSerializer(); string json = ser.Serialize(returnValue); return json; }
public MsCrmResult CompleteRequest(string token, string requestId) { MsCrmResult returnValue = new MsCrmResult(); LoginSession ls = new LoginSession(); try { if (!string.IsNullOrEmpty(token) || !string.IsNullOrEmpty(requestId)) { #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); sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); AssemblyRequestInfo req = new AssemblyRequestInfo() { Id = new Guid(requestId), StatusCode = new OptionSetValueWrapper() { AttributeValue = (int)AssemblyRequestStatus.Completed } }; returnValue = AssemblyRequestHelper.UpdateAssemblyRequest(req, service); } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!"; } } catch (Exception ex) { returnValue.Result = ex.Message; } finally { if (sda != null) { sda.closeConnection(); } } return returnValue; }
public string GetAnnouncementList(string token, int start, int end) { MsCrmResultObject returnValue = new MsCrmResultObject(); LoginSession ls = new LoginSession(); JavaScriptSerializer ser = new JavaScriptSerializer(); string json = string.Empty; try { if (!string.IsNullOrEmpty(token)) { #region | CHECK SESSION | MsCrmResultObject sessionResult = GetUserSession(token); if (!sessionResult.Success) { json = ser.Serialize(sessionResult); return json; } else { ls = (LoginSession)sessionResult.ReturnObject; } #endregion sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = AnnouncementHelper.GetAnnouncementList(ls.PortalId, ls.PortalUserId, start, end, sda); } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-GetAnnouncementList"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message + "-GetAnnouncementList"; } finally { if (sda != null) { sda.closeConnection(); } } json = ser.Serialize(returnValue); return json; }
public List<SelectValue> SearchUserTokenize(string token, string search) { List<SelectValue> selectValues = null; LoginSession loginSession = new LoginSession(); try { try { if (!string.IsNullOrEmpty(token)) { MsCrmResultObject userSession = this.GetUserSession(token); if (userSession.Success) { loginSession = (LoginSession)userSession.ReturnObject; sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); string str = loginSession.PortalId.ToString(); Guid portalUserId = loginSession.PortalUserId; selectValues = FriendshipHelper.SearchFriend(str, portalUserId.ToString(), search, sda); } else { return selectValues; } } } catch (Exception ex) { } } finally { if (sda != null) { sda.closeConnection(); } } return selectValues; }
private void StartOperation() { _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); _service = MSCRM.GetOrgService(true); _timer = new System.Timers.Timer(); _timer.Interval = SERVICE_INTERVAL; _timer.AutoReset = true; _timer.Enabled = true; _timer.Elapsed += _timer_Elapsed; _timer.Start(); }
public string SelectSurvey(string token) { MsCrmResultObject returnValue = new MsCrmResultObject(); LoginSession ls = new LoginSession(); JavaScriptSerializer ser = new JavaScriptSerializer(); string json = string.Empty; try { if (!string.IsNullOrEmpty(token)) { #region | CHECK SESSION | MsCrmResultObject sessionResult = GetUserSession(token); if (!sessionResult.Success) { json = ser.Serialize(sessionResult); return json; } else { ls = (LoginSession)sessionResult.ReturnObject; } #endregion sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = SurveyHelper.SelectSurvey(ls.PortalId, ls.PortalUserId, sda); } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-SelectSurvey"; } } catch (Exception ex) { returnValue.Result = ex.Message; } json = ser.Serialize(returnValue); return json; }
public void ProcessRequest(HttpContext context) { try { var operation = context.Request.QueryString["operation"]; if (context.Request.QueryString["upload"] != null && operation != null && operation != "3") { string pathrefer = context.Request.UrlReferrer.ToString(); //string Serverpath = @"C:\DO\Web\GK.Web.GkPortal\attachments"; //string Serverpath = HttpContext.Current.Server.MapPath("attachments"); string Serverpath = @Globals.AttachmentFolder; var postedFile = context.Request.Files[0]; string file; //For IE to get file name if (HttpContext.Current.Request.Browser.Browser.ToLower() == "internetexplorer") { string[] files = postedFile.FileName.Split(new char[] { '\\' }); file = files[files.Length - 1]; } else { file = postedFile.FileName; } if (!Directory.Exists(Serverpath)) Directory.CreateDirectory(Serverpath); string fileDirectory = Serverpath; if (context.Request.QueryString["fileName"] != null) { file = context.Request.QueryString["fileName"]; if (File.Exists(fileDirectory + "\\" + file)) { File.Delete(fileDirectory + "\\" + file); } } string ext = Path.GetExtension(fileDirectory + "\\" + file); file = Guid.NewGuid() + ext; fileDirectory = Serverpath + "\\" + file; postedFile.SaveAs(fileDirectory); context.Response.AddHeader("Vary", "Accept"); try { if (context.Request["HTTP_ACCEPT"].Contains("application/json")) context.Response.ContentType = "application/json"; else context.Response.ContentType = "text/plain"; } catch { context.Response.ContentType = "text/plain"; } #region | CRM OPERATIONS AFTER SAVE | if (context.Request.QueryString["operation"] != null) { var relationName = context.Request.QueryString["relationname"]; var entityName = context.Request.QueryString["entityname"]; var entityId = context.Request.QueryString["entityid"]; var portalId = context.Request.QueryString["portalid"]; var isImage = context.Request.QueryString["isimage"]; IOrganizationService service = MSCRM.GetOrgService(true); SqlDataAccess sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); Annotation note = new Annotation(); if (operation != "3") { note.FileName = postedFile.FileName; note.FilePath = file; note.MimeType = ext; note.Object = new EntityReference(entityName, new Guid(entityId)); if (operation == "1") { note.Portal = new EntityReference("new_portal", new Guid(portalId)); } } if (operation == "1") //Save attachment to entity { MsCrmResult resultCreate = AttachmentFileHelper.CreateAttachmentFile(note, service); AttachmentFileHelper.AssociateAttachmentToEntity(resultCreate.CrmId, note.Object, relationName, service); } else if (operation == "2") //Save Entity Profile Image { string fieldName = "new_imageurl"; if (entityName == "new_video" && isImage != "true") { fieldName = "new_videourl"; } #region | DELETE PREVIOUS IMAGE FILE | string fileName = AttachmentFileHelper.GetEntityProfileImageFileName(entityId, entityName, fieldName, sda); if (!string.IsNullOrEmpty(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(entityName); ent.Id = new Guid(entityId); ent[fieldName] = note.FilePath; service.Update(ent); #endregion } //else if (operation == "3") //Delete profile image //{ // string fieldName = "new_imageurl"; // if (entityName == "new_video") // { // fieldName = "new_imageurl"; // } // string fileName = AttachmentFileHelper.GetEntityProfileImageFileName(entityId, entityName, fieldName, sda); // AttachmentFileHelper.DeleteProfileImage(entityId, entityName, fieldName, fileName); //} } #endregion context.Response.Write(file); } else if (operation == "3") { var entityName = context.Request.QueryString["entityname"]; var entityId = context.Request.QueryString["entityid"]; string fieldName = "new_imageurl"; if (entityName == "new_video") { fieldName = "new_imageurl"; } SqlDataAccess sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); string fileName = AttachmentFileHelper.GetEntityProfileImageFileName(new Guid(entityId).ToString(), entityName, fieldName, sda); AttachmentFileHelper.DeleteProfileImage(new Guid(entityId).ToString(), entityName, fieldName, fileName); context.Response.Write("success"); } } catch (Exception exp) { context.Response.Write(exp.StackTrace); } }
public MsCrmResult SendMyPassword(string userName) { MsCrmResult returnValue = new MsCrmResult(); try { if (!string.IsNullOrEmpty(userName)) { sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = PortalUserHelper.SendContactPassword(userName, sda); } else { returnValue.Success = false; returnValue.Result = "Kulanıcı adı bilgisi boş!-SendMyPassword"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message + "-SendMyPassword"; } finally { if (sda != null) { sda.closeConnection(); } } 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 | VARIABLES | EntityReference userId = null; EntityReference cityId = null; EntityReference townId = null; AssemblerInfo assemblerInfo = null; string customerFirstName = null; string customerLastName = null; string customerMobilePhone = null; string customerFullName = null; string assemblerFullName = null; if (entity.Contains("new_userid") && entity["new_userid"] != null) { userId = (EntityReference)entity["new_userid"]; MsCrmResultObj<AssemblerInfo> resultAssembler = AssemblyRequestHelper.GetAssemblerInfo(userId.Id, sda); if (resultAssembler.Success) { assemblerInfo = resultAssembler.ReturnObject; } else { throw new Exception("Anahtarcı bilgisi alınamadı.Hata:" + resultAssembler.Result); } } if (entity.Contains("new_cityid") && entity["new_cityid"] != null) { cityId = (EntityReference)entity["new_cityid"]; } if (entity.Contains("new_townid") && entity["new_townid"] != null) { townId = (EntityReference)entity["new_townid"]; } if (entity.Contains("new_firstname") && entity["new_firstname"] != null) { customerFirstName = entity["new_firstname"].ToString(); } if (entity.Contains("new_lastname") && entity["new_lastname"] != null) { customerLastName = entity["new_lastname"].ToString(); } if (entity.Contains("new_mobilephone") && entity["new_mobilephone"] != null) { customerMobilePhone = entity["new_mobilephone"].ToString(); } if (!string.IsNullOrWhiteSpace(customerFirstName) && !string.IsNullOrWhiteSpace(customerLastName)) { customerFullName = customerFirstName + " " + customerLastName; } if (assemblerInfo != null && !string.IsNullOrWhiteSpace(assemblerInfo.FirstName) && !string.IsNullOrWhiteSpace(assemblerInfo.LastName)) { assemblerFullName = assemblerInfo.FirstName + " " + assemblerInfo.LastName; } #endregion #region | CREATE SMSs | if (!string.IsNullOrWhiteSpace(customerMobilePhone) && !string.IsNullOrWhiteSpace(customerFirstName) && !string.IsNullOrWhiteSpace(customerLastName) && assemblerInfo != null) { string customerSmsText = @"Sayın {0}, www.kalekilitesatis.com.tr sitemizden yaptığınız alışveriş için teşekkür ederiz. Montaj için anahtarcı bilgileri: {1}, Tel: {2}"; Entity ent = new Entity("new_sms"); ent["new_message"] = string.Format(customerSmsText, customerFullName, assemblerFullName, assemblerInfo.MobilePhoneNumber); ent["new_phonenumber"] = customerMobilePhone; ent["new_name"] = customerFirstName + " " + customerLastName + "|Montaj Talebi Mesajı"; service.Create(ent); } if (!string.IsNullOrWhiteSpace(assemblerInfo.MobilePhoneNumber) && !string.IsNullOrWhiteSpace(customerFirstName) && !string.IsNullOrWhiteSpace(customerLastName) && assemblerInfo != null && userId != null) { string customerSmsText = @"Sayın {0}, www.kalekilitesatis.com.tr sitemizden satışı yapılan ürünün montajı için müşteri bilgileri: {1} Tel: {2} şeklindedir. Müşterimizle irtibata geçmenizi rica ederiz."; Entity ent = new Entity("new_sms"); ent["new_message"] = string.Format(customerSmsText, assemblerFullName, customerFullName, customerMobilePhone); ent["new_phonenumber"] = assemblerInfo.MobilePhoneNumber; ent["new_name"] = customerFirstName + " " + customerLastName + "|Montaj Talebi Mesajı"; ent["new_userid"] = userId; service.Create(ent); } #endregion #region | CREATE NPS Survey | Entity entSurvey = new Entity("new_npssurvey"); entSurvey["new_name"] = customerFullName + "|" + DateTime.Now.ToString("dd.MM.yyyy HH:mm"); entSurvey["new_asseblyrequestid"] = entity.ToEntityReference(); service.Create(entSurvey); #endregion } catch (Exception ex) { //LOG throw new InvalidPluginExecutionException(ex.Message + "->>>" + ex.StackTrace); } finally { if (sda != null) sda.closeConnection(); } }
public MsCrmResult SendPasswordSMS(string portalUserId, string portalId, string phoneNumber, string contactId) { Thread.Sleep(1000); MsCrmResult returnValue = new MsCrmResult(); string token = string.Empty; try { if (!string.IsNullOrEmpty(portalUserId) && !string.IsNullOrEmpty(portalId) && !string.IsNullOrEmpty(phoneNumber)) { IOrganizationService service = MSCRM.GetOrgService(true); mService = new MessageServices(); sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); MsCrmResultObject resultSmsConf = SMSHelper.GetSmsConfigurationInfo(new Guid(Globals.SmsConfigurationDoluHayatId), sda); if (!resultSmsConf.Success) { returnValue.Result = resultSmsConf.Result; return returnValue; } SmsConfiguration smsConf = (SmsConfiguration)resultSmsConf.ReturnObject; token = Guid.NewGuid().ToString().Replace("-", "");// resultSmsRecord.CrmId.ToString().Replace("-", ""); returnValue = SetPasswordSession(token, portalUserId, portalId, phoneNumber); if (returnValue.Success) { SendSmsRecord smsRec = new SendSmsRecord() { Name = "Şifre Hatırlatma", PhoneNumber = phoneNumber, SmsConfiguration = smsConf, PrefferedSendDate = DateTime.Now.AddHours(-2), Portal = new EntityReference() { Id = new Guid(portalId), LogicalName = "new_portal" }, Contact = new EntityReference("contact", new Guid(contactId)), Content = "Kale Anahtarcılar Kulübü Doğrulama Kodunuz: " + returnValue.Result, }; //MsCrmResult resultSmsRecord = SMSHelper.CreateOrUpdateSendSmsRecord(smsRec, service); //if (!resultSmsRecord.Success) //{ // returnValue = resultSmsRecord; // return returnValue; //} string sessionId = GetSession(smsConf); SendSmsResult resultSms = SendSms(sessionId, smsConf, smsRec); if (!resultSms.StatusCode.Contains("ERR")) { smsRec.IsSent = true; smsRec.MessageId = resultSms.MessageId; smsRec.ResultCode = resultSms.StatusCode; smsRec.StatusCode = 100000000; //İşlendi MsCrmResult resultSmsRecord = SMSHelper.CreateOrUpdateSendSmsRecord(smsRec, service); returnValue = resultSmsRecord; returnValue.Result = token; returnValue.Success = true; } else { smsRec.Error = resultSms.StatusCode; returnValue.Result = resultSms.StatusCode; } } } else { returnValue.Success = false; returnValue.Result = "M003"; } } catch (Exception ex) { returnValue.Result = ex.Message; } finally { if (sda != null) sda.closeConnection(); } return returnValue; }
public MsCrmResult UpdateMyProfile(string token, string newPassword, string oldPassword, Contact contact) { MsCrmResult returnValue = new MsCrmResult(); LoginSession ls = new LoginSession(); try { if (!string.IsNullOrEmpty(token) && contact != null) { #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); sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); returnValue = ContactHelper.CreateOrUpdateProfile(contact, service); if (!string.IsNullOrEmpty(newPassword) && !string.IsNullOrEmpty(oldPassword)) { returnValue = PortalUserHelper.UpdateUserPassword(ls.PortalUserId, newPassword, oldPassword, service, sda); if (returnValue.Success) { returnValue.Result = "M012"; //"Profile bilgileriniz ve " + returnValue.Result; } } } else { returnValue.Success = false; returnValue.Result = "M003"; //"Kulanıcı bilgisi boş!-UpdateMyProfile"; } } catch (Exception ex) { returnValue.Success = false; returnValue.Result = ex.Message + "-UpdateMyProfile"; } finally { if (sda != null) { sda.closeConnection(); } } return returnValue; }
public MsCrmResult UsePointCode(string token, string pointCode) { 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); sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); MsCrmResultObject resultGetPointCodeInfo = PointCodeHelper.GetPointCodeInfo(pointCode, sda); if (resultGetPointCodeInfo.Success) { PointCode pCode = resultGetPointCodeInfo.GetReturnObject<PointCode>(); if (pCode.Status.AttributeValue == 1) //Etkin ise { returnValue = PointCodeHelper.PassiveCode(pCode.Id, service); if (returnValue.Success) { UserCodeUsage userCodeUsage = new UserCodeUsage(); userCodeUsage.Name = pointCode; userCodeUsage.Point = pCode.Point; userCodeUsage.PointCodeId = new EntityReferenceWrapper() { Id = pCode.Id, Name = pCode.Name, LogicalName = "new_pointcode" }; userCodeUsage.PortalId = new EntityReferenceWrapper() { Id = ls.PortalId, LogicalName = "new_portal" }; userCodeUsage.UserId = new EntityReferenceWrapper() { Id = ls.PortalUserId, LogicalName = "new_user" }; returnValue = PointCodeHelper.CreateUserCodeUsage(userCodeUsage, service); Score sc = new Score() { Point = pCode.Point, Portal = userCodeUsage.PortalId.ToCrmEntityReference(), User = userCodeUsage.UserId.ToCrmEntityReference(), ScoreType = ScoreType.PointCode }; MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service); } } else { returnValue.Result = "Girmiş olduğunuz kod önceden kullanılmıştır."; } } else { returnValue.Result = resultGetPointCodeInfo.Result; } } else { returnValue.Success = false; returnValue.Result = "M003"; //"Eksik parametre!-CreateForumSubject"; } } catch (Exception ex) { 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 | VARIABLES | bool hasMedia = false; List<ScoreLimit> lstLimits = new List<ScoreLimit>(); EntityReference portal = null; EntityReference user = null; if (entity.Contains("new_hasmedia") && entity["new_hasmedia"] != null) { hasMedia = (bool)entity["new_hasmedia"]; } if (entity.Contains("new_portalid") && entity["new_portalid"] != null) { portal = (EntityReference)entity["new_portalid"]; } if (entity.Contains("new_userid") && entity["new_userid"] != null) { user = (EntityReference)entity["new_userid"]; } #endregion MsCrmResultObject limitRes = new MsCrmResultObject(); if (hasMedia) limitRes = ScoreHelper.GetScoreLimitsByType(ScoreType.GraffitiMedia, sda); else limitRes = ScoreHelper.GetScoreLimitsByType(ScoreType.GraffitiText, sda); if (limitRes.Success) { lstLimits = (List<ScoreLimit>)limitRes.ReturnObject; for (int i = 0; i < lstLimits.Count; i++) { int recCount = 0; DateTime start = GeneralHelper.GetStartDateByScorePeriod(lstLimits[i].Period); DateTime end = GeneralHelper.GetEndDateByScorePeriod(lstLimits[i].Period); recCount = GraffitiHelper.GetUserGraffitiCount(portal.Id, user.Id, start, end, hasMedia, sda); if (lstLimits[i].Frequency >= recCount) { Score sc = new Score() { Point = lstLimits[i].Point, Portal = portal, User = user, ScoreType = (hasMedia ? ScoreType.GraffitiMedia : ScoreType.GraffitiText) }; MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service); break; } } } } catch (Exception ex) { //LOG throw new InvalidPluginExecutionException(ex.Message); } finally { if (sda != null) sda.closeConnection(); } }
public static void CreateLogBySql(string applicationName, string functionName, string detail, string createdBy, string businessUnit, EventType eventType) { try { SqlDataAccess sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); string sqlQuery = @"DECLARE @EventLogID uniqueidentifier SET @EventLogID=NEWID() INSERT INTO new_eventlogBase (new_eventlogId ,CreatedOn ,CreatedBy ,ModifiedOn ,ModifiedBy ,OwnerId ,OwningBusinessUnit ,statecode ,statuscode ) VALUES ( @EventLogID ,@CreatedOn ,@CreatedBy ,@CreatedOn ,@CreatedBy ,@CreatedBy ,@BusinessUnit ,0 ,1 ) INSERT INTO new_eventlogExtensionBase ( new_eventlogId ,new_name ,new_applicationname ,new_detail ,new_eventtype ,new_function ) VALUES ( @EventLogID ,@Title ,@ApplicationName ,@Detail ,@EventType ,@FunctionName )"; string title = string.Format("{0} - {1} - {2}", applicationName, functionName, DateTime.Now.ToString("dd.MM.yyyy HH:mm")); List <SqlParameter> li = new List <SqlParameter>(); li.Add(new SqlParameter("@CreatedOn", DateTime.UtcNow)); li.Add(new SqlParameter("@CreatedBy", new Guid(createdBy))); li.Add(new SqlParameter("@CreatedBy", new Guid(businessUnit))); li.Add(new SqlParameter("@Title", title)); li.Add(new SqlParameter("@ApplicationName", applicationName)); li.Add(new SqlParameter("@Detail", detail)); li.Add(new SqlParameter("@EventType", (int)eventType)); li.Add(new SqlParameter("@FunctionName", functionName)); sda.ExecuteNonQuery(sqlQuery, li.ToArray()); sda.closeConnection(); } catch (Exception ex) { } }