public static MsCrmResultObj <AssemblerInfo> GetAssemblerInfo(string emailAddress, string password, SqlDataAccess sda) { MsCrmResultObj <AssemblerInfo> returnValue = new MsCrmResultObj <AssemblerInfo>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT DISTINCT u.new_userId AS Id ,u.new_name AS IdName ,'new_user' AS IdTypeName ,c.FirstName ,c.LastName ,c.JobTitle AS CompanyName ,c.MobilePhone AS MobilePhoneNumber ,c.Telephone1 AS WorkPhoneNumber ,c.new_cityId AS CityId ,c.new_cityIdName AS CityIdName ,'new_city' AS CityIdTypeName ,c.new_townId AS TownId ,c.new_townIdName AS TownIdName ,'new_town' AS TownIdTypeName ,c.new_addressdetail AS AddressDetail FROM new_user AS u (NOLOCK) JOIN Contact AS c (NOLOCK) ON u.new_contactId=c.ContactId WHERE c.EmailAddress1='{0}' AND u.new_password='******'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, emailAddress, password)); if (dt.Rows.Count > 0) { List <AssemblerInfo> assemblerList = dt.ToList <AssemblerInfo>(); returnValue.Success = true; returnValue.ReturnObject = assemblerList.FirstOrDefault(); } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } return(returnValue); }
private MsCrmResultObj <LoginSession> GetUserSession(string token) { MsCrmResultObj <LoginSession> returnValue = new MsCrmResultObj <LoginSession>(); try { var session = HttpContext.Current.Cache[token]; if (session != null) { LoginSession ls = (LoginSession)session; returnValue.Success = true; returnValue.Result = "Session bilgisi çekildi."; returnValue.ReturnObject = ls; } else { returnValue.Result = "M001"; } } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResultObj <AssemblyRequestInfo> GetAssemblyRequestInfo(Guid requestId, SqlDataAccess sda) { MsCrmResultObj <AssemblyRequestInfo> returnValue = new MsCrmResultObj <AssemblyRequestInfo>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT req.new_assemblyrequestId AS Id ,req.new_name AS Name ,req.new_firstname AS FirstName ,req.new_lastname AS LastName ,req.new_mobilephone AS MobilePhoneNumber ,req.new_workphone AS WorkPhoneNumber ,req.new_emailaddress AS EmailAddress ,req.new_cityid AS CityId ,req.new_cityidName AS CityIdName ,'new_city' AS CityIdTypeName ,req.new_townid AS TownId ,req.new_townidName AS TownIdName ,'new_town' AS TownIdTypeName ,req.new_addressdetail AS AddressDetail ,req.new_userid AS AssemblerId ,req.new_useridName AS AssemblerIdName ,'new_user' AS AssemblerIdTypeName ,req.statuscode AS StatusCode ,req.CreatedOn FROM new_assemblyrequest AS req (NOLOCK) WHERE req.new_assemblyrequestId='{0}'" ; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, requestId)); if (dt.Rows.Count > 0) { List <AssemblyRequestInfo> assemblyRequestList = dt.ToList <AssemblyRequestInfo>(); returnValue.Success = true; returnValue.ReturnObject = assemblyRequestList.FirstOrDefault(); } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResultObj <List <Town> > GetTowns(string cityCode, SqlDataAccess sda) { MsCrmResultObj <List <Town> > returnValue = new MsCrmResultObj <List <Town> >(); try { #region | SQL QUERY | string sqlQuery = @"SELECT t.new_townId AS Id ,t.new_name AS Name ,t.new_towncode AS Code ,t.new_cityId AS CityId ,t.new_cityIdName AS CityIdName ,'new_city' AS CityIdTypeName FROM new_town AS t (NOLOCK) JOIN new_city AS c (NOLOCK) ON t.new_cityId=c.new_cityId WHERE c.new_citycode='{0}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, cityCode)); if (dt.Rows.Count > 0) { List <Town> townList = dt.ToList <Town>(); returnValue.Success = true; returnValue.ReturnObject = townList; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.Result = ex.Message; returnValue.HasException = true; } return(returnValue); }
public static MsCrmResultObj<List<Town>> GetAllTowns(SqlDataAccess sda) { MsCrmResultObj<List<Town>> returnValue = new MsCrmResultObj<List<Town>>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT t.new_townId AS Id ,t.new_name AS Name ,t.new_towncode AS Code ,t.new_cityId AS CityId ,t.new_cityIdName AS CityIdName ,'new_city' AS CityIdTypeName FROM new_town AS t (NOLOCK) JOIN new_city AS c (NOLOCK) ON t.new_cityId=c.new_cityId"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery)); if (dt.Rows.Count > 0) { List<Town> townList = dt.ToList<Town>(); returnValue.Success = true; returnValue.ReturnObject = townList; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.Result = ex.Message; returnValue.HasException = true; } return returnValue; }
public MsCrmResultObj <List <AssemblerInfo> > GetAllMemberList(string token) { MsCrmResultObj <List <AssemblerInfo> > returnValue = new MsCrmResultObj <List <AssemblerInfo> >(); LoginSession ls = new LoginSession(); try { #region | CHECK SESSION | MsCrmResultObj <LoginSession> sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return(returnValue); } else { ls = sessionResult.ReturnObject; } #endregion _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); returnValue = AssemblyRequestHelper.GetAllMemberList(new Guid(Globals.DefaultPortalId), _sda); } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } finally { if (_sda != null) { _sda.closeConnection(); } } return(returnValue); }
public MsCrmResultObj <AssemblerInfo> GetUser(string token, string emailaddress, string password) { MsCrmResultObj <AssemblerInfo> returnValue = new MsCrmResultObj <AssemblerInfo>(); LoginSession ls = new LoginSession(); try { #region | CHECK SESSION | MsCrmResultObj <LoginSession> sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return(returnValue); } else { ls = sessionResult.ReturnObject; } #endregion _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); returnValue = AssemblyRequestHelper.GetAssemblerInfo(emailaddress, password, _sda); } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } finally { if (_sda != null) { _sda.closeConnection(); } } return(returnValue); }
public MsCrmResultObj <List <City> > GetCitites(string token) { MsCrmResultObj <List <City> > returnValue = new MsCrmResultObj <List <City> >(); LoginSession ls = new LoginSession(); try { #region | CHECK SESSION | MsCrmResultObj <LoginSession> sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return(returnValue); } else { ls = sessionResult.ReturnObject; } #endregion _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); returnValue = LocationHelper.GetCities(_sda); } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } finally { if (_sda != null) { _sda.closeConnection(); } } return(returnValue); }
public static MsCrmResultObj <List <City> > GetCities(SqlDataAccess sda) { MsCrmResultObj <List <City> > returnValue = new MsCrmResultObj <List <City> >(); try { #region | SQL QUERY | string sqlQuery = @"SELECT c.new_cityId AS Id ,c.new_name AS Name ,c.new_citycode AS Code FROM new_city AS c (NOLOCK) WHERE c.new_countryId='F55A5B6D-B32E-E511-80C4-000D3A216510'"; #endregion DataTable dt = sda.getDataTable(sqlQuery); if (dt.Rows.Count > 0) { List <City> cityList = dt.ToList <City>(); returnValue.Success = true; returnValue.ReturnObject = cityList; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResultObj<List<City>> GetCities(SqlDataAccess sda) { MsCrmResultObj<List<City>> returnValue = new MsCrmResultObj<List<City>>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT c.new_cityId AS Id ,c.new_name AS Name ,c.new_citycode AS Code FROM new_city AS c (NOLOCK) WHERE c.new_countryId='F55A5B6D-B32E-E511-80C4-000D3A216510'"; #endregion DataTable dt = sda.getDataTable(sqlQuery); if (dt.Rows.Count > 0) { List<City> cityList = dt.ToList<City>(); returnValue.Success = true; returnValue.ReturnObject = cityList; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResultObj <City> GetCityInfo(string cityCode, SqlDataAccess sda) { MsCrmResultObj <City> returnValue = new MsCrmResultObj <City>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT c.new_cityId AS Id ,c.new_name AS Name ,c.new_citycode AS Code FROM new_city AS c (NOLOCK) WHERE c.new_citycode='{0}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, cityCode)); if (dt.Rows.Count > 0) { List <City> cityList = dt.ToList <City>(); returnValue.Success = true; returnValue.ReturnObject = cityList[0]; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
private void SendSurveyMail(Guid npsSurveyId, string emailAddress, Guid requestId) { MsCrmResultObj <AssemblyRequestInfo> resultRequestInfo = AssemblyRequestHelper.GetAssemblyRequestInfo(requestId, _sda); AssemblyRequestInfo requestInfo; if (resultRequestInfo.Success) { requestInfo = resultRequestInfo.ReturnObject; } else { FileLogHelper.LogFunction(this.GetType().Name, "SendNpsSurvey_ServiceProcess_SenSurveydMail_REQUEST_INFO_NULL:" + resultRequestInfo.Result, ERROR_LOG_PATH); UpdateNpsSurveyEntityStatusCode(npsSurveyId, NpsSurveyStatus.NotSent); return; } if (!string.IsNullOrWhiteSpace(requestInfo.EmailAddress) && !string.IsNullOrWhiteSpace(requestInfo.FirstName) && !string.IsNullOrWhiteSpace(requestInfo.LastName)) { string fullName = requestInfo.FirstName + " " + requestInfo.LastName; string mailBody = string.Format(Constants.SURVEY_MAILD_BODY, fullName, npsSurveyId.ToString()); FileLogHelper.LogFunction(this.GetType().Name, "SendNpsSurvey_ServiceProcess_SendSurveydMail_INFO:" + requestInfo.EmailAddress, ERROR_LOG_PATH); MsCrmResult resultSendMail = SendMail(requestInfo.EmailAddress, "Kale Anahtar Değerlendirme Anketi", mailBody); if (resultSendMail.Success) { UpdateNpsSurveyEntityStatusCode(npsSurveyId, NpsSurveyStatus.Sent); } else { FileLogHelper.LogFunction(this.GetType().Name, "SendNpsSurvey_ServiceProcess_SendMail_EXCEPTION:" + resultSendMail.Result, ERROR_LOG_PATH); UpdateNpsSurveyEntityStatusCode(npsSurveyId, NpsSurveyStatus.NotSent); } } }
private MsCrmResultObj<LoginSession> GetUserSession(string token) { MsCrmResultObj<LoginSession> returnValue = new MsCrmResultObj<LoginSession>(); try { var session = HttpContext.Current.Cache[token]; if (session != null) { LoginSession ls = (LoginSession)session; returnValue.Success = true; returnValue.Result = "Session bilgisi çekildi."; returnValue.ReturnObject = ls; } else { returnValue.Result = "M001"; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResultObj<List<AssemblerInfo>> GetAllAssemblerList(Guid portalId, SqlDataAccess sda) { MsCrmResultObj<List<AssemblerInfo>> returnValue = new MsCrmResultObj<List<AssemblerInfo>>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT DISTINCT u.new_userId AS Id ,u.new_name AS IdName ,'new_user' AS IdTypeName ,c.FirstName ,c.LastName ,c.JobTitle AS CompanyName ,c.MobilePhone AS MobilePhoneNumber ,c.Telephone1 AS WorkPhoneNumber ,c.new_cityId AS CityId ,c.new_cityIdName AS CityIdName ,'new_city' AS CityIdTypeName ,c.new_townId AS TownId ,c.new_townIdName AS TownIdName ,'new_town' AS TownIdTypeName ,c.new_addressdetail AS AddressDetail FROM new_user AS u (NOLOCK) JOIN new_new_user_new_role AS ur (NOLOCK) ON ur.new_userid=u.new_userId JOIN new_role AS r (NOLOCK) ON ur.new_roleid=r.new_roleId AND r.statecode=0 AND r.statuscode=1 --Active AND r.new_portalId='{0}' JOIN Contact AS c (NOLOCK) ON u.new_contactId=c.ContactId WHERE u.statecode=0 AND u.statuscode=1 --Active AND c.new_markcontact=1 AND c.new_cityId IS NOT NULL AND c.new_townId IS NOT NULL"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, portalId)); if (dt.Rows.Count > 0) { List<AssemblerInfo> assemblerList = dt.ToList<AssemblerInfo>(); returnValue.Success = true; returnValue.ReturnObject = assemblerList; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResultObj<List<AssemblyRequestInfo>> GetAssemblyRequestList(Guid userId, SqlDataAccess sda) { MsCrmResultObj<List<AssemblyRequestInfo>> returnValue = new MsCrmResultObj<List<AssemblyRequestInfo>>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT req.new_assemblyrequestId AS Id ,req.new_name AS Name ,req.new_firstname AS FirstName ,req.new_lastname AS LastName ,req.new_mobilephone AS MobilePhoneNumber ,req.new_workphone AS WorkPhoneNumber ,req.new_emailaddress AS EmailAddress ,req.new_cityid AS CityId ,req.new_cityidName AS CityIdName ,'new_city' AS CityIdTypeName ,req.new_townid AS TownId ,req.new_townidName AS TownIdName ,'new_town' AS TownIdTypeName ,req.new_addressdetail AS AddressDetail ,req.new_userid AS AssemblerId ,req.new_useridName AS AssemblerIdName ,'new_user' AS AssemblerIdTypeName ,req.statuscode AS StatusCode ,req.CreatedOn FROM new_assemblyrequest AS req (NOLOCK) WHERE req.new_userid='{0}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, userId)); if (dt.Rows.Count > 0) { List<AssemblyRequestInfo> assemblyRequestList = dt.ToList<AssemblyRequestInfo>(); returnValue.Success = true; returnValue.ReturnObject = assemblyRequestList; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResultObj<AssemblerInfo> GetAssemblerInfo(Guid userId, SqlDataAccess sda) { MsCrmResultObj<AssemblerInfo> returnValue = new MsCrmResultObj<AssemblerInfo>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT DISTINCT u.new_userId AS Id ,u.new_name AS IdName ,'new_user' AS IdTypeName ,c.FirstName ,c.LastName ,c.JobTitle AS CompanyName ,c.MobilePhone AS MobilePhoneNumber ,c.Telephone1 AS WorkPhoneNumber ,c.new_cityId AS CityId ,c.new_cityIdName AS CityIdName ,'new_city' AS CityIdTypeName ,c.new_townId AS TownId ,c.new_townIdName AS TownIdName ,'new_town' AS TownIdTypeName ,c.new_addressdetail AS AddressDetail FROM new_user AS u (NOLOCK) JOIN Contact AS c (NOLOCK) ON u.new_contactId=c.ContactId WHERE u.new_userId='{0}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, userId)); if (dt.Rows.Count > 0) { List<AssemblerInfo> assemblerList = dt.ToList<AssemblerInfo>(); returnValue.Success = true; returnValue.ReturnObject = assemblerList[0]; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } return returnValue; }
public static MsCrmResultObj <List <SteelDoor> > GetUserSteelDoors(Guid userId, SqlDataAccess sda) { MsCrmResultObj <List <SteelDoor> > returnValue = new MsCrmResultObj <List <SteelDoor> >(); #region | SQL QUERY | string sqlQuery = @"SELECT DISTINCT pc.new_steeldoorId AS Id ,pc.new_name AS Name ,pc.new_firstname AS FirstName ,pc.new_lastname AS LastName ,pc.new_phonenumber AS PhoneNumber ,pc.new_email AS Email ,pc.new_cityid AS CityId ,pc.new_cityidName AS CityIdName ,'new_city' AS CityIdTypeName ,pc.new_townid AS TownId ,pc.new_townidName AS TownIdName ,'new_town' AS TownIdTypeName ,pc.new_userid AS UserId ,pc.new_useridName AS UserIdName ,'new_user' AS UserIdTypeName ,pc.new_portalid AS PortalId ,pc.new_portalidName AS PortalIdName ,'new_portal' AS PortalIdTypeName ,pc.statuscode AS Status ,sm.Value AS StatusValue ,pc.CreatedOn AS CreatedOn FROM new_steeldoor AS pc (NOLOCK) JOIN Entity AS e (NOLOCK) ON e.Name='new_steeldoor' JOIN StringMap AS sm (NOLOCK) ON sm.ObjectTypeCode=e.ObjectTypeCode AND sm.AttributeName='statuscode' AND sm.AttributeValue=pc.statuscode WHERE pc.new_userid='{0}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, userId)); if (dt.Rows.Count > 0) { List <SteelDoor> steelDoors = dt.ToList <SteelDoor>(); returnValue.Success = true; returnValue.ReturnObject = steelDoors; } else { returnValue.Result = "Kayıt bulunamadı."; } return(returnValue); }
public static MsCrmResultObj <List <DiscoveryForm> > GetUserDiscoveryFormList(Guid userId, SqlDataAccess sda) { MsCrmResultObj <List <DiscoveryForm> > returnValue = new MsCrmResultObj <List <DiscoveryForm> >(); try { #region | SQL QUERY | string sqlQuery = @"SELECT pc.new_discoveryformId AS Id ,pc.new_name AS Name ,pc.new_firstname AS FirstName ,pc.new_lastname AS LastName ,pc.new_phonenumber AS PhoneNumber ,pc.new_email AS Email ,pc.new_cityid AS CityId ,pc.new_cityidName AS CityIdName ,'new_city' AS CityIdTypeName ,pc.new_townid AS TownId ,pc.new_townidName AS TownIdName ,'new_town' AS TownIdTypeName ,pc.new_userid AS UserId ,pc.new_useridName AS UserIdName ,'new_user' AS UserIdTypeName ,pc.new_portalid AS PortalId ,pc.new_portalidName AS PortalIdName ,'new_portal' AS PortalIdTypeName ,pc.new_hometype AS HomeType ,pc.new_informedby AS InformedBy ,pc.new_visithour AS VisitHour ,pc.new_visitdate AS VisitDate ,pc.new_formcode AS FormCode ,pc.statuscode AS Status ,sm.Value AS StatusValue ,pc.CreatedOn AS CreatedOn FROM new_discoveryform AS pc (NOLOCK) JOIN StringMap AS sm (NOLOCK) ON sm.ObjectTypeCode=(SELECT TOP 1 ObjectTypeCode FROM Entity WHERE Name='new_discoveryform') AND sm.AttributeName='statuscode' AND sm.AttributeValue=pc.statuscode WHERE pc.new_userid='{0}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, userId)); if (dt.Rows.Count > 0) { List <DiscoveryForm> discoveryForm = dt.ToList <DiscoveryForm>(); returnValue.Success = true; returnValue.ReturnObject = discoveryForm; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResultObj<City> GetCityInfo(string cityCode, SqlDataAccess sda) { MsCrmResultObj<City> returnValue = new MsCrmResultObj<City>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT c.new_cityId AS Id ,c.new_name AS Name ,c.new_citycode AS Code FROM new_city AS c (NOLOCK) WHERE c.new_citycode='{0}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, cityCode)); if (dt.Rows.Count > 0) { List<City> cityList = dt.ToList<City>(); returnValue.Success = true; returnValue.ReturnObject = cityList[0]; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public MsCrmResultObj<List<Town>> GetTowns(string token, Guid cityId) { MsCrmResultObj<List<Town>> returnValue = new MsCrmResultObj<List<Town>>(); LoginSession ls = new LoginSession(); try { #region | CHECK SESSION | MsCrmResultObj<LoginSession> sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return returnValue; } else { ls = sessionResult.ReturnObject; } #endregion _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); returnValue = LocationHelper.GetTowns(cityId, _sda); } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } finally { if (_sda != null) { _sda.closeConnection(); } } return returnValue; }
public MsCrmResult CreateAsseblyRequest(string token, AssemblyRequestInfo requestInfo) { MsCrmResult returnValue = new MsCrmResult(); LoginSession ls = new LoginSession(); try { #region | CHECK SESSION | MsCrmResultObj <LoginSession> sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return(returnValue); } else { ls = sessionResult.ReturnObject; } #endregion _service = MSCRM.GetOrgService(true); //_sda = new SqlDataAccess(); //_sda.openConnection(Globals.ConnectionString); #region | DATA VALIDATION | if (string.IsNullOrWhiteSpace(requestInfo.FirstName)) { returnValue.Result = "Ad alanı boş olamaz."; return(returnValue); } if (string.IsNullOrWhiteSpace(requestInfo.LastName)) { returnValue.Result = "Soyad alanı boş olamaz."; return(returnValue); } if (string.IsNullOrWhiteSpace(requestInfo.MobilePhoneNumber)) { returnValue.Result = "Cep Telefonu alanı boş olamaz."; return(returnValue); } if (!ValidationHelper.CheckTelephoneNumber(requestInfo.MobilePhoneNumber).isFormatOK) { returnValue.Result = "Cep Telefonu formatı hatalıdır. Örn:+90-5xx-xxxxxxx şeklinde olmalıdır."; return(returnValue); } if (string.IsNullOrWhiteSpace(requestInfo.EmailAddress)) { returnValue.Result = "Email adresi alanı boş olamaz."; return(returnValue); } if (string.IsNullOrWhiteSpace(requestInfo.AddressDetail)) { returnValue.Result = "Adres detayı alanı boş olamaz."; return(returnValue); } if (requestInfo.RequestCityId == null || requestInfo.RequestCityId == Guid.Empty) { returnValue.Result = "İl alanı boş olamaz."; return(returnValue); } if (requestInfo.RequestTownId == null || requestInfo.RequestTownId == Guid.Empty) { returnValue.Result = "İlçe alanı boş olamaz."; return(returnValue); } #endregion requestInfo.Name = requestInfo.Name + "|" + requestInfo.LastName + "|" + DateTime.Now.ToString("dd.MM.yyyy HH:mm"); returnValue = AssemblyRequestHelper.CreateAssemblyRequest(requestInfo, _service); } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } finally { if (_sda != null) { _sda.closeConnection(); } } return(returnValue); }
public static MsCrmResultObj<Town> GetTownInfo(string townCode, SqlDataAccess sda) { MsCrmResultObj<Town> returnValue = new MsCrmResultObj<Town>(); try { #region | SQL QUERY | string sqlQuery = @"SELECT t.new_townId AS Id ,t.new_name AS Name ,t.new_towncode AS Code ,t.new_cityId AS CityId ,t.new_cityIdName AS CityIdName ,'new_city' AS CityIdTypeName FROM new_town AS t (NOLOCK) WHERE t.new_towncode='{0}'"; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, townCode)); if (dt.Rows.Count > 0) { List<Town> townList = dt.ToList<Town>(); returnValue.Success = true; returnValue.ReturnObject = townList[0]; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return returnValue; }
public MsCrmResultObj<List<AssemblyRequestInfo>> GetRequests(string token, string userId) { MsCrmResultObj<List<AssemblyRequestInfo>> returnValue = new MsCrmResultObj<List<AssemblyRequestInfo>>(); LoginSession ls = new LoginSession(); try { if (!string.IsNullOrEmpty(token) || !string.IsNullOrEmpty(userId)) { #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 = AssemblyRequestHelper.GetAssemblyRequestList(new Guid(userId), sda); } 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 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 static MsCrmResultObj <List <AssemblerInfo> > GetAllAssemblerList(Guid portalId, SqlDataAccess sda) { MsCrmResultObj <List <AssemblerInfo> > returnValue = new MsCrmResultObj <List <AssemblerInfo> >(); try { #region | SQL QUERY | string sqlQuery = @"SELECT DISTINCT u.new_userId AS Id ,u.new_name AS IdName ,'new_user' AS IdTypeName ,u.new_password AS ClearPassword ,c.FirstName ,c.LastName ,c.JobTitle AS CompanyName ,c.MobilePhone AS MobilePhoneNumber ,c.Telephone1 AS WorkPhoneNumber ,c.EmailAddress1 AS EmailAddress ,c.new_cityId AS CityId ,c.new_cityIdName AS CityIdName ,'new_city' AS CityIdTypeName ,c.new_townId AS TownId ,c.new_townIdName AS TownIdName ,'new_town' AS TownIdTypeName ,c.new_addressdetail AS AddressDetail FROM new_user AS u (NOLOCK) JOIN new_new_user_new_role AS ur (NOLOCK) ON ur.new_userid=u.new_userId JOIN new_role AS r (NOLOCK) ON ur.new_roleid=r.new_roleId AND r.statecode=0 AND r.statuscode=1 --Active AND r.new_portalId='{0}' JOIN Contact AS c (NOLOCK) ON u.new_contactId=c.ContactId WHERE u.statecode=0 AND u.statuscode=1 --Active AND c.new_markcontact=1 AND c.new_cityId IS NOT NULL AND c.new_townId IS NOT NULL" ; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, portalId)); if (dt.Rows.Count > 0) { List <AssemblerInfo> assemblerList = dt.ToList <AssemblerInfo>(); returnValue.Success = true; returnValue.ReturnObject = assemblerList; } else { returnValue.Result = "Kayıt bulunamadı."; } } catch (Exception ex) { returnValue.HasException = true; 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 |DEFINE IMAGE IF EXISTS| Entity preImage = null; if (context.PreEntityImages.Contains("PreImage") && context.PreEntityImages["PreImage"] is Entity) { preImage = (Entity)context.PreEntityImages["PreImage"]; } #endregion #region | VARIABLES | string customerFirstName = null; string customerLastName = null; string customerMobilePhone = null; string customerFullName = null; string assemblerFullName = null; int statusCode = 0; int oldStatusCode = 0; AssemblerInfo assemblerInfo = null; List <ScoreLimit> lstLimits = new List <ScoreLimit>(); EntityReference portal = null; EntityReference user = null; if (preImage.Contains("new_portalid") && preImage["new_portalid"] != null) { portal = (EntityReference)preImage["new_portalid"]; } if (preImage.Contains("new_userid") && preImage["new_userid"] != null) { user = (EntityReference)preImage["new_userid"]; MsCrmResultObj <AssemblerInfo> resultAssembler = AssemblyRequestHelper.GetAssemblerInfo(user.Id, sda); if (resultAssembler.Success) { assemblerInfo = resultAssembler.ReturnObject; } else { throw new Exception("Anahtarcı bilgisi alınamadı.Hata:" + resultAssembler.Result); } } if (preImage.Contains("new_firstname") && preImage["new_firstname"] != null) { customerFirstName = preImage["new_firstname"].ToString(); } if (preImage.Contains("new_lastname") && preImage["new_lastname"] != null) { customerLastName = preImage["new_lastname"].ToString(); } if (preImage.Contains("new_mobilephone") && preImage["new_mobilephone"] != null) { customerMobilePhone = preImage["new_mobilephone"].ToString(); } if (!string.IsNullOrWhiteSpace(customerFirstName) && !string.IsNullOrWhiteSpace(customerLastName)) { customerFullName = customerFirstName + " " + customerLastName; } if (entity.Contains("statuscode") && entity["statuscode"] != null) { statusCode = ((OptionSetValue)entity["statuscode"]).Value; } if (preImage.Contains("statuscode") && preImage["statuscode"] != null) { oldStatusCode = ((OptionSetValue)preImage["statuscode"]).Value; } #endregion if (statusCode != oldStatusCode && (statusCode == (int)DiscoveryFormStatus.CrmConfirmed || statusCode == (int)DiscoveryFormStatus.Result_Negative)) { string statusText = string.Empty; if (statusCode == (int)DiscoveryFormStatus.CrmConfirmed) { statusText = "Kale Onayladı"; } else if (statusCode == (int)DiscoveryFormStatus.Result_Negative) { statusText = "Sonuç Olumsuz"; } string customerSmsText = @"Sayın {0}, {1} müşterisine ait Ücretsiz Keşif Formu durumu {2} olarak değişmiştir. Bilgilerinize."; Entity ent = new Entity("new_sms"); ent["new_message"] = string.Format(customerSmsText, assemblerFullName, customerFullName, statusText); ent["new_phonenumber"] = assemblerInfo.MobilePhoneNumber; ent["new_name"] = customerFirstName + " " + customerLastName + "|KGS Formu Durum Değişimi"; ent["new_userid"] = user; service.Create(ent); } if (entity.Contains("statuscode") && entity["statuscode"] != null && ((OptionSetValue)entity["statuscode"]).Value == (int)DiscoveryFormStatus.CrmConfirmed) { MsCrmResultObject limitRes = ScoreHelper.GetScoreLimitsByType(ScoreType.KGSSales, sda); if (limitRes.Success) { lstLimits = (List <ScoreLimit>)limitRes.ReturnObject; for (int i = 0; i < lstLimits.Count; i++) { Score sc = new Score() { Point = lstLimits[i].Point, Portal = portal, User = user, ScoreType = ScoreType.KGSSales }; MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service); if (scoreRes.Success) { break; } } } } } catch (Exception ex) { //LOG throw new InvalidPluginExecutionException(ex.Message); } finally { if (sda != null) { sda.closeConnection(); } } }
public MsCrmResultObj<List<AssemblerInfo>> GetAssemblerList(string token, Guid cityId, Guid townId) { MsCrmResultObj<List<AssemblerInfo>> returnValue = new MsCrmResultObj<List<AssemblerInfo>>(); LoginSession ls = new LoginSession(); try { #region | CHECK SESSION | MsCrmResultObj<LoginSession> sessionResult = GetUserSession(token); if (!sessionResult.Success) { returnValue.Result = sessionResult.Result; return returnValue; } else { ls = sessionResult.ReturnObject; } #endregion _sda = new SqlDataAccess(); _sda.openConnection(Globals.ConnectionString); returnValue = AssemblyRequestHelper.GetAssemblerList(new Guid(Globals.DefaultPortalId), cityId, townId, _sda); } catch (Exception ex) { returnValue.HasException = true; returnValue.Result = ex.Message; } finally { if (_sda != null) { _sda.closeConnection(); } } return returnValue; }