Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        public static Annotation GetAnnotationDetail(Guid annotationId, SqlDataAccess sda)
        {
            Annotation returnValue = new Annotation();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
                                    A.AnnotationId
                                    ,A.MimeType
                                    ,A.FileName
                                    ,A.DocumentBody
                                FROM
                                    Annotation A
                                WHERE
                                    A.AnnotationId = '{0}'";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, annotationId));
                if (dt != null && dt.Rows.Count > 0)
                {
                    returnValue.AnnotationId = (Guid)dt.Rows[0]["AnnotationId"];
                    returnValue.MimeType = dt.Rows[0]["MimeType"] != DBNull.Value ? dt.Rows[0]["MimeType"].ToString() : string.Empty;
                    returnValue.FileName = dt.Rows[0]["FileName"] != DBNull.Value ? dt.Rows[0]["FileName"].ToString() : string.Empty;
                    returnValue.File = dt.Rows[0]["DocumentBody"] != DBNull.Value ? dt.Rows[0]["DocumentBody"].ToString() : string.Empty;
                }
            }
            catch (Exception)
            {

            }
            return returnValue;
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        public ServiceProcess(SqlDataAccess sda, IOrganizationService service)
        {
            _sda = sda;
            _service = service;

            LOG_PATH = Globals.FileLogPath;
            ERROR_LOG_PATH = Globals.FileLogPath;

            SMTP_USERNAME = ConfigurationManager.AppSettings["username"].ToString();
            SMTP_PASSWORD = ConfigurationManager.AppSettings["password"].ToString();
            FROM_MAILADDRESS = ConfigurationManager.AppSettings["mailaddress"].ToString();
            MAIL_HOST = ConfigurationManager.AppSettings["hostaddress"].ToString();
            PORT = ConfigurationManager.AppSettings["port"].ToString();
        }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
        public static MsCrmResultObject GetArticleCategoryInfo(Guid categoryId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT DISTINCT
                                    E.new_articlecategoryId AS Id
                                    ,E.new_name Name
                                    ,E.new_portalId PortalId
                                    ,E.new_portalIdName PortalIdName
                                    ,E.new_imageurl AS ImageUrl
                                FROM
                                new_articlecategory AS E (NOLOCK)
                                WHERE
                                    E.new_articlecategoryId = '{0}'
                                    AND
                                    E.statuscode=1 --Active";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, categoryId));
                if (dt != null && dt.Rows.Count > 0)
                {
                    EntityReference er = new EntityReference()
                    {
                        Id = (Guid)dt.Rows[0]["Id"],
                        Name = dt.Rows[0]["Name"].ToString(),
                        LogicalName = dt.Rows[0]["ImageUrl"] != DBNull.Value ? dt.Rows[0]["ImageUrl"].ToString() : "no_image_available.png"
                    };

                    returnValue.Success = true;
                    returnValue.ReturnObject = er;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M024";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
Ejemplo n.º 10
0
        public static MsCrmResultObject GetPointCodeInfo(string code, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |

                string sqlQuery = @"SELECT
                                        pc.new_pointcodeId AS Id
                                        ,pc.new_name AS Name
                                        ,pc.new_portalid AS PortalId
                                        ,pc.new_portalidName AS PortalIdName
                                        ,'new_portal' AS PortalIdTypeName
                                        ,pc.new_group AS GroupCode
                                        ,pc.new_code AS Code
                                        ,pc.new_point AS Point
                                        ,pc.statuscode AS Status
                                    FROM
                                    new_pointcode AS pc (NOLOCK)
                                    WHERE
                                    pc.new_code='{0}'";

                #endregion

                DataTable dt = sda.getDataTable(string.Format(sqlQuery, code));

                if (dt.Rows.Count > 0)
                {
                    List<PointCode> pCode = dt.ToList<PointCode>();

                    returnValue.Success = true;
                    returnValue.ReturnObject = pCode[0];
                }
                else
                {
                    returnValue.Result = "Kod bulunamadı.";
                }
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
Ejemplo n.º 11
0
        public ServiceProcess(SqlDataAccess sda, IOrganizationService service)
        {
            _sda = sda;
            _service = service;

            LOG_PATH = Globals.FileLogPath;
            ERROR_LOG_PATH = Globals.FileLogPath;

            MsCrmResultObject resultSmsConf = SMSHelper.GetSmsConfigurationInfo(new Guid(Globals.SmsConfigurationDoluHayatId), sda);

            if (!resultSmsConf.Success)
            {
                FileLogHelper.LogFunction(this.GetType().Name,"SendSms_ServiceProcess_NOCONFIG_DEFINATION", LOG_PATH);
            }

            SMS_CONFIG = (SmsConfiguration)resultSmsConf.ReturnObject;

            _smsApi = new smsService.smsservice();
        }
Ejemplo n.º 12
0
        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;
        }
Ejemplo n.º 13
0
        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;
        }
Ejemplo n.º 14
0
        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;
        }
Ejemplo n.º 15
0
        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;
        }
Ejemplo n.º 16
0
        public static int GetUserLoginCount(Guid portalId, Guid portalUserId, DateTime start, DateTime end, SqlDataAccess sda)
        {
            int returnValue = 0;

            try
            {
                #region | SQL QUERY |

                string sqlQuery = @"SELECT
                                    COUNT(0)
                                FROM
                                    new_loginlog AS ll (NOLOCK)
                                WHERE
                                    ll.new_portalId=@PortalId
                                AND
                                    ll.new_userId=@UserId
                                AND
                                    ll.new_logindate BETWEEN @start AND @end
                                AND
                                    ll.StateCode=0";

                #endregion

                SqlParameter[] parameters = {
                                            new SqlParameter("@PortalId",portalId)
                                            ,new SqlParameter("@UserId",portalUserId)
                                            ,new SqlParameter("@start",start)
                                            ,new SqlParameter("@end",end)
                                        };

                returnValue = (int)sda.ExecuteScalar(sqlQuery, parameters);

            }
            catch (Exception ex)
            {

            }

            return returnValue;
        }
Ejemplo n.º 17
0
        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;
        }
Ejemplo n.º 18
0
        public void Process(SqlDataAccess sda)
        {
            FileLogHelper.LogFunction(this.GetType().Name, "SendNpsSurvey_ServiceProcess_Process_TRIGGERED", LOG_PATH);

            SqlParameter[] parameters = new SqlParameter[]{
                new SqlParameter("@statusCode",(int)NpsSurveyStatus.Created)
            };

            try
            {
                DataTable dt = _sda.getDataTable(Constants.QUERY_GET_NPS_SURVEY_RECORDS_BY_STATUSCODE, parameters);

                FileLogHelper.LogFunction(this.GetType().Name, "SendNpsSurvey_ServiceProcess_Process_SurveyRecordCount:" + dt.Rows.Count.ToString(), LOG_PATH);

                foreach (DataRow row in dt.Rows)
                {
                    SendSurveyMail((Guid)row["Id"], row["EmailAddress"].ToString(), (Guid)row["RequestId"]);
                }
            }
            catch (Exception ex)
            {
                FileLogHelper.LogFunction(this.GetType().Name, "SendNpsSurvey_ServiceProcess_Process_EXCEPTION:" + ex.Message, ERROR_LOG_PATH);
            }
        }
Ejemplo n.º 19
0
        public void Process(SqlDataAccess sda)
        {
            FileLogHelper.LogFunction(this.GetType().Name,"SendSms_ServiceProcess_Process_TRIGGERED", LOG_PATH);

            SqlParameter[] parameters = new SqlParameter[]{
                new SqlParameter("@statusCode",(int)SmsStatusCode.WaitingSend)
            };

            try
            {
                DataTable dt = _sda.getDataTable(Constants.QUERY_GET_SMS_RECORDS_BY_STATUSCODE, parameters);

                FileLogHelper.LogFunction(this.GetType().Name,"SendSms_ServiceProcess_Process_SmsRecordCount:" + dt.Rows.Count.ToString(), LOG_PATH);

                foreach (DataRow row in dt.Rows)
                {
                    SendSms((Guid)row["Id"], row["PhoneNumber"].ToString(), row["Message"].ToString());
                }
            }
            catch (Exception ex)
            {
                FileLogHelper.LogFunction(this.GetType().Name,"SendSms_ServiceProcess_Process_EXCEPTION:" + ex.Message, ERROR_LOG_PATH);
            }
        }
Ejemplo n.º 20
0
        public static MsCrmResultObject GetGraffities(Guid portalId, int commentCount, int startRow, int endRow, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
                                    A.*
                                FROM
                                (
                                    SELECT
                                        PG.new_graffitiId GraffitiId
                                        ,PG.new_content [Description]
                                        ,PG.new_userId PortalUserId
                                        ,PG.new_userIdName PortalUserIdName
                                        ,PG.new_portalId BrandId
                                        ,PG.new_portalIdName BrandIdName
                                        ,PG.new_imageurl [Image]
                                        ,U.new_imageurl UserImage
                                        ,CAST({4}.dbo.fn_UTCToTzSpecificLocalTime(PG.CreatedOn, us.TimeZoneBias, us.TimeZoneDaylightBias,us.TimeZoneDaylightYear, us.TimeZoneDaylightMonth, us.TimeZoneDaylightDay, us.TimeZoneDaylightHour,us.TimeZoneDaylightMinute, us.TimeZoneDaylightSecond, 0, us.TimeZoneDaylightDayOfWeek,us.TimeZoneStandardBias, us.TimeZoneStandardYear, us.TimeZoneStandardMonth, us.TimeZoneStandardDay,us.TimeZoneStandardHour, us.TimeZoneStandardMinute, us.TimeZoneStandardSecond, 0,us.TimeZoneStandardDayOfWeek) as DATETIME) CreatedOn
                                        ,ROW_NUMBER() OVER(ORDER BY PG.CreatedOn DESC) AS RowNumber
                                        ,(
                                            SELECT
                                                COUNT(0)
                                            FROM
                                                new_comment AS c (NOLOCK)
                                            WHERE
                                                c.new_graffitiId=PG.new_graffitiId
                                        ) AS CommentCount
                                        ,(
                                            SELECT
                                                COUNT(0)
                                            FROM
                                                new_likerecord AS lr (NOLOCK)
                                            WHERE
                                                lr.new_graffitiId=PG.new_graffitiId
                                        ) AS LikeCount
                                    FROM
                                        new_graffiti PG (NoLock)
                                    INNER JOIN
                                        new_user U (NoLock)
                                        ON
                                        PG.new_portalId = '{0}'
                                        AND
                                        PG.statecode = 0
                                        AND
                                        U.new_userId = PG.new_userId
                                    INNER JOIN
                                        dbo.UserSettingsBase US (NoLock)
                                        ON
                                        US.SystemUserId ='{1}'
                                    WHERE
                                        PG.statecode=0
                                    AND
                                        PG.statuscode=1 --Active
                                )A
                                WHERE
                                    A.RowNumber BETWEEN {2} AND {3}
                                ORDER BY
                                    A.RowNumber ASC";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalId, Globals.AdminId, startRow, endRow, Globals.DatabaseName));
                if (dt != null && dt.Rows.Count > 0)
                {
                    List<Graffiti> returnList = new List<Graffiti>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Graffiti _graffiti = new Graffiti();
                        _graffiti.GraffitiId = (Guid)dt.Rows[i]["GraffitiId"];
                        _graffiti.Description = dt.Rows[i]["Description"] != DBNull.Value ? dt.Rows[i]["Description"].ToString() : string.Empty;
                        _graffiti.ImagePath = dt.Rows[i]["Image"] != DBNull.Value ? dt.Rows[i]["Image"].ToString() : string.Empty;
                        _graffiti.PortalUserImage = dt.Rows[i]["UserImage"] != DBNull.Value ? dt.Rows[i]["UserImage"].ToString() : "nouserprofile.jpg";
                        _graffiti.CreatedOnString = dt.Rows[i]["CreatedOn"] != DBNull.Value ? ((DateTime)dt.Rows[i]["CreatedOn"]).ToString("dd MMMM yyyy, HH:mm", new CultureInfo("tr-TR", false)) : string.Empty;
                        _graffiti.HasMedia = dt.Rows[i]["Image"] != DBNull.Value ? true : false;

                        _graffiti.LikeCount = (int)dt.Rows[i]["LikeCount"];
                        _graffiti.CommentCount = (int)dt.Rows[i]["CommentCount"];

                        if (dt.Rows[i]["CreatedOn"] != DBNull.Value)
                        {
                            _graffiti.CreatedOn = (DateTime)dt.Rows[i]["CreatedOn"];
                        }

                        if (dt.Rows[i]["PortalUserId"] != DBNull.Value)
                        {
                            EntityReference er = new EntityReference();
                            er.LogicalName = "new_user";
                            er.Id = (Guid)dt.Rows[i]["PortalUserId"];
                            if (dt.Rows[i]["PortalUserIdName"] != DBNull.Value) { er.Name = dt.Rows[i]["PortalUserIdName"].ToString(); }

                            _graffiti.PortalUser = er;
                        }

                        if (dt.Rows[i]["BrandId"] != DBNull.Value)
                        {
                            EntityReference er = new EntityReference();
                            er.LogicalName = "new_brand";
                            er.Id = (Guid)dt.Rows[i]["BrandId"];
                            if (dt.Rows[i]["BrandIdName"] != DBNull.Value) { er.Name = dt.Rows[i]["BrandIdName"].ToString(); }

                            _graffiti.Portal = er;
                        }

                        #region | GET COMMENTS |
                        MsCrmResultObject commentResult = CommentHelper.GetGraffitiComments(_graffiti.GraffitiId, 0, commentCount, sda);
                        //MsCrmResultObject commentResult = CommentHelper.GetGraffitiComments(_graffiti.GraffitiId, sda);
                        if (commentResult.Success)
                        {
                            _graffiti.CommentList = (List<Comment>)commentResult.ReturnObject;
                        }
                        #endregion

                        returnList.Add(_graffiti);
                    }

                    returnValue.Success = true;
                    returnValue.ReturnObject = returnList;
                }
                else
                {
                    returnValue.Success = true;
                    returnValue.Result = "M013"; //"Duvar yazısı bulunamadı!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
Ejemplo n.º 21
0
        public static int GetUserGraffitiCount(Guid portalId, Guid portalUserId, DateTime start, DateTime end, bool hasMedia, SqlDataAccess sda)
        {
            int returnValue = 0;

            try
            {
                #region | SQL QUERY |

                string sqlQuery = @"SELECT
                                        COUNT(0)
                                    FROM
                                        new_graffiti AS gr (NOLOCK)
                                    WHERE
                                        gr.new_portalId=@PortalId
                                    AND
                                        gr.new_userId=@UserId
                                    AND
                                        gr.CreatedOn BETWEEN @start AND @end
                                    AND
                                        gr.StateCode=0
                                    AND
                                        gr.statuscode=1 --Etkin
                                    AND
                                        gr.new_imageurl  " + (hasMedia ? " IS NOT NULL" : " IS NULL");

                #endregion

                SqlParameter[] parameters = {
                                            new SqlParameter("@PortalId",portalId)
                                            ,new SqlParameter("@UserId",portalUserId)
                                            ,new SqlParameter("@start",start)
                                            ,new SqlParameter("@end",end)
                                        };

                returnValue = (int)sda.ExecuteScalar(sqlQuery, parameters);

            }
            catch (Exception ex)
            {

            }

            return returnValue;
        }
Ejemplo n.º 22
0
        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();
            }
        }
Ejemplo n.º 23
0
        public static MsCrmResultObject SearchContact(Guid portalId, Guid userId, string key, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |
                string query = @"SELECT DISTINCT
                                        u.new_userId AS UserId
                                        ,u.new_name AS UserName
                                        ,u.new_imageurl AS ImageUrl
                                        ,c.FullName
                                        ,c.JobTitle
                                        ,CASE WHEN fr.new_friendshipId IS NOT NULL THEN 1 ELSE 0 END AS IsFriend
                                    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
                                        LEFT JOIN
                                            new_friendship AS fr (NOLOCK)
                                                ON
                                                '{2}' IN (fr.new_partyOneId,fr.new_partyTwoId)
                                                AND
                                                u.new_userId IN (fr.new_partyOneId,fr.new_partyTwoId)
                                                AND
                                                fr.statecode=0
                                    WHERE
                                        u.statecode=0
                                    AND
                                        u.new_userId!='{2}'
                                    AND
                                        u.statuscode=1 --Active
                                    AND
                                        c.FullName LIKE '%{1}%'";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalId, key, userId));

                if (dt != null && dt.Rows.Count > 0)
                {
                    List<UserFriends> lstUser = new List<UserFriends>();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        UserFriends uf = new UserFriends()
                        {
                            UserId = (Guid)dt.Rows[i]["UserId"],
                            UserName = dt.Rows[i]["UserName"].ToString(),
                            FullName = dt.Rows[i]["FullName"].ToString(),
                            ImageUrl = dt.Rows[i]["ImageUrl"] != DBNull.Value ? dt.Rows[i]["ImageUrl"].ToString() : "nouserprofile.jpg",
                            JobTitle = dt.Rows[i]["JobTitle"] != DBNull.Value ? dt.Rows[i]["JobTitle"].ToString() : "---",
                            UserType = (int)dt.Rows[i]["IsFriend"]
                        };

                        lstUser.Add(uf);
                    }

                    returnValue.Success = true;
                    returnValue.ReturnObject = lstUser;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M057"; //"Herhangi bir kayıt bulunamadı!";
                }

            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
Ejemplo n.º 24
0
        public static MsCrmResultObject GetContactInfo(Guid contactId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
                                     C.ContactId
                                    ,C.FirstName
                                    ,C.LastName
                                    ,C.JobTitle
                                    ,C.new_functionname FunctionName
                                    ,C.AccountId
                                    ,C.AccountIdName
                                    ,C.EMailAddress1 EmailAddress
                                    ,C.MobilePhone
                                    ,C.Telephone1
                                    ,C.new_identitynumber AS IdentityNo
                                    ,C.GenderCode
                                    ,DATEADD(HH,3,C.BirthDate) AS BirthDate
                                    ,C.Description
                                    ,C.new_cityId AS CityId
                                    ,C.new_cityIdName AS CityIdName
                                    ,C.new_townId AS TownId
                                    ,C.new_townIdName AS TownIdName
                                    ,C.new_addressdetail AS AddressDetail
                                    ,C.new_markcontact AS MarkContact
                                FROM
                                    Contact C (NoLock)
                                WHERE
                                    C.ContactId = '{0}'
                                    AND
                                    C.StateCode = 0";
                #endregion
                DataTable dt = sda.getDataTable(string.Format(query, contactId));
                if (dt != null && dt.Rows.Count > 0)
                {
                    Contact _contact = new Contact();
                    _contact.ContactId = (Guid)dt.Rows[0]["ContactId"];
                    _contact.FirstName = dt.Rows[0]["FirstName"] != DBNull.Value ? dt.Rows[0]["FirstName"].ToString() : string.Empty;
                    _contact.LastName = dt.Rows[0]["LastName"] != DBNull.Value ? dt.Rows[0]["LastName"].ToString() : string.Empty;
                    _contact.Title = dt.Rows[0]["JobTitle"] != DBNull.Value ? dt.Rows[0]["JobTitle"].ToString() : string.Empty;
                    _contact.FunctionName = dt.Rows[0]["FunctionName"] != DBNull.Value ? dt.Rows[0]["FunctionName"].ToString() : string.Empty;
                    _contact.EmailAddress = dt.Rows[0]["EmailAddress"] != DBNull.Value ? dt.Rows[0]["EmailAddress"].ToString() : string.Empty;
                    _contact.MobilePhone = dt.Rows[0]["MobilePhone"] != DBNull.Value ? dt.Rows[0]["MobilePhone"].ToString() : string.Empty;
                    _contact.WorkPhone = dt.Rows[0]["Telephone1"] != DBNull.Value ? dt.Rows[0]["Telephone1"].ToString() : string.Empty;
                    _contact.IdentityNumber = dt.Rows[0]["IdentityNo"] != DBNull.Value ? dt.Rows[0]["IdentityNo"].ToString() : string.Empty;
                    if (dt.Rows[0]["GenderCode"] != DBNull.Value) { _contact.Gender = (int)dt.Rows[0]["GenderCode"]; }
                    if (dt.Rows[0]["BirthDate"] != DBNull.Value) { _contact.BirthDate = (DateTime)dt.Rows[0]["BirthDate"]; }
                    _contact.Description = dt.Rows[0]["Description"] != DBNull.Value ? dt.Rows[0]["Description"].ToString() : string.Empty;

                    _contact.MarkContact = dt.Rows[0]["MarkContact"] != DBNull.Value ? (bool)dt.Rows[0]["MarkContact"] : false;

                    if (dt.Rows[0]["AccountId"] != DBNull.Value)
                    {
                        EntityReference er = new EntityReference();
                        er.LogicalName = "account";
                        er.Id = (Guid)dt.Rows[0]["AccountId"];
                        if (dt.Rows[0]["AccountIdName"] != DBNull.Value) { er.Name = dt.Rows[0]["AccountIdName"].ToString(); }

                        _contact.ParentAccount = er;
                    }

                    if (dt.Rows[0]["CityId"] != DBNull.Value)
                    {
                        EntityReference er = new EntityReference();
                        er.LogicalName = "new_city";
                        er.Id = (Guid)dt.Rows[0]["CityId"];
                        if (dt.Rows[0]["CityIdName"] != DBNull.Value) { er.Name = dt.Rows[0]["CityIdName"].ToString(); }

                        _contact.CityId = er;
                    }

                    if (dt.Rows[0]["TownId"] != DBNull.Value)
                    {
                        EntityReference er = new EntityReference();
                        er.LogicalName = "new_town";
                        er.Id = (Guid)dt.Rows[0]["TownId"];
                        if (dt.Rows[0]["TownIdName"] != DBNull.Value) { er.Name = dt.Rows[0]["TownIdName"].ToString(); }

                        _contact.TownId = er;
                    }

                    if (dt.Rows[0]["AccountId"] != DBNull.Value)
                    {
                        EntityReference er = new EntityReference();
                        er.LogicalName = "account";
                        er.Id = (Guid)dt.Rows[0]["AccountId"];
                        if (dt.Rows[0]["AccountIdName"] != DBNull.Value) { er.Name = dt.Rows[0]["AccountIdName"].ToString(); }

                        _contact.ParentAccount = er;
                    }

                    _contact.AddressDetail = dt.Rows[0]["AddressDetail"] != DBNull.Value ? dt.Rows[0]["AddressDetail"].ToString() : string.Empty;

                    returnValue.ReturnObject = _contact;
                    returnValue.Success = true;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M007"; //"No contact info found!";
                }

            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
Ejemplo n.º 25
0
        public static string GetCityCode(Guid cityId, SqlDataAccess sda)
        {
            string returnValue = string.Empty;

            #region | SQL QUERY |

            string sqlQuery = @"SELECT c.new_citycode AS Code FROM new_city AS c (NOLOCK) WHERE c.new_cityId='{0}'";
            #endregion

            DataTable dt = sda.getDataTable(string.Format(sqlQuery, cityId));

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["Code"] != DBNull.Value)
                {
                    returnValue = dt.Rows[0]["Code"].ToString();
                }
            }

            return returnValue;
        }
Ejemplo n.º 26
0
        public static MsCrmResultObject SelectQuestion(Guid portalUserId, Guid portalId, Guid questionLevelId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT TOP 1
                                    q.new_questionId AS QUestionId
                                FROM
                                    new_question AS q (NOLOCK)
                                WHERE
                                    q.new_portalId='{0}'
                                AND
                                    q.new_questionlevelId='{1}'
                                AND
                                    q.statecode=0
                                AND
                                    q.statuscode=1 --Active
                                AND
                                    q.new_questionId NOT IN
                                    (
                                        SELECT
                                            q.new_questionId
                                        FROM
                                            new_questionanswers AS a (NOLOCK)
                                        WHERE
                                            a.new_questionId=q.new_questionId
                                        AND
                                            a.new_userId='{2}'
                                        AND
                                            a.new_point IS NOT NULL AND a.new_point != 0
                                        AND
                                            a.statecode=0
                                    )
                                ORDER BY NEWID()";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalId, questionLevelId, portalUserId));

                if (dt != null && dt.Rows.Count > 0)
                {
                    returnValue = GetQuestionInfo((Guid)dt.Rows[0]["QuestionId"], sda);

                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M029"; //"Soru seviyesine ait uygun soru bulunamadı.";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
Ejemplo n.º 27
0
        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;
        }
Ejemplo n.º 28
0
        public static MsCrmResultObject GetUserCubeStatus(Guid portalUserId, Guid portalId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
                                *
                                FROM
                                (
                                    SELECT
                                        *
                                        ,DENSE_RANK() OVER (ORDER BY B.TotalPoint DESC) AS Ranking
                                    FROM
                                    (
                                        SELECT
                                            A.UserId
                                            ,ISNULL(SUM(A.Point),0) AS TotalPoint
                                        FROM
                                        (
                                            SELECT DISTINCT
                                                u.new_userId AS UserId
                                                ,a.new_point AS Point
                                                ,a.new_questionanswersId AS AnswerId
                                            FROM
                                                new_user AS u (NOLOCK)
                                                    LEFT JOIN
                                                        new_questionanswers AS a (NOLOCK)
                                                            ON
                                                            u.new_userId=a.new_userId
                                                            AND
                                                            a.statecode=0
                                                    JOIN
                                                        new_new_user_new_role AS urd (NOLOCK)
                                                            ON
                                                            u.new_userId=urd.new_userid
                                                    JOIN
                                                        new_role AS rd (NOLOCK)
                                                            ON
                                                            urd.new_roleid=rd.new_roleId
                                                            AND
                                                            rd.statecode=0
                                                            AND
                                                            rd.statuscode=1 --Active
                                                            AND
                                                            rd.new_portalId='{1}'
                                            WHERE
                                                u.statecode=0
                                            AND
                                                u.statuscode=1 --Active
                                        ) AS A
                                        GROUP BY
                                            A.UserId
                                    ) AS B
                                ) AS C
                                WHERE
                                    C.UserId='{0}'";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalUserId, portalId));

                if (dt != null && dt.Rows.Count > 0)
                {
                    UserCubeStatus _cubeStatus = new UserCubeStatus();

                    if (dt.Rows[0]["UserId"] != DBNull.Value)
                    {
                        EntityReference er = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["UserId"]
                        };

                        _cubeStatus.UserId = er;
                    }

                    _cubeStatus.Point = dt.Rows[0]["TotalPoint"] != DBNull.Value ? Convert.ToInt32(dt.Rows[0]["TotalPoint"]) : 0;
                    _cubeStatus.Rank = dt.Rows[0]["Ranking"] != DBNull.Value ? Convert.ToInt32(dt.Rows[0]["Ranking"]) : 0;

                    returnValue.Success = true;
                    returnValue.ReturnObject = _cubeStatus;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M032"; //"Kullanıcı soru cevaplarına ait bilgiler bulunamadı.";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
Ejemplo n.º 29
0
        public static MsCrmResultObject GetAnnouncementInfo(Guid announcementId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
                                    A.new_announcementId Id
                                    ,A.new_name Name
                                    ,A.new_content Content
                                    ,A.new_imageurl ImageUrl
                                    ,CAST({2}.dbo.fn_UTCToTzSpecificLocalTime(A.CreatedOn, us.TimeZoneBias, us.TimeZoneDaylightBias,us.TimeZoneDaylightYear, us.TimeZoneDaylightMonth, us.TimeZoneDaylightDay, us.TimeZoneDaylightHour,us.TimeZoneDaylightMinute, us.TimeZoneDaylightSecond, 0, us.TimeZoneDaylightDayOfWeek,us.TimeZoneStandardBias, us.TimeZoneStandardYear, us.TimeZoneStandardMonth, us.TimeZoneStandardDay,us.TimeZoneStandardHour, us.TimeZoneStandardMinute, us.TimeZoneStandardSecond, 0,us.TimeZoneStandardDayOfWeek) as DATETIME) CreatedOn
                                FROM
                                    new_announcement A (NoLock)
                                INNER JOIN
                                    SystemUser SU (NoLock)
                                    ON
                                    SU.SystemUserId = '{1}'
                                INNER JOIN
                                    dbo.UserSettingsBase US (NoLock)
                                    ON
                                    US.SystemUserId =SU.SystemUserId
                                WHERE
                                    A.new_announcementId = '{0}'
                                ORDER BY
                                    A.CreatedOn DESC";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, announcementId, Globals.AdminId, Globals.DatabaseName));

                if (dt != null && dt.Rows.Count > 0)
                {
                    Announcement _announcement = new Announcement();
                    _announcement.AnnouncementId = (Guid)dt.Rows[0]["Id"];
                    _announcement.Caption = dt.Rows[0]["Name"] != DBNull.Value ? dt.Rows[0]["Name"].ToString() : string.Empty;
                    _announcement.Description = dt.Rows[0]["Content"] != DBNull.Value ? dt.Rows[0]["Content"].ToString() : string.Empty;
                    _announcement.ImagePath = dt.Rows[0]["ImageUrl"] != DBNull.Value ? dt.Rows[0]["ImageUrl"].ToString() : "no_image_available.png";

                    if (dt.Rows[0]["CreatedOn"] != DBNull.Value)
                    {
                        _announcement.CreatedOnString = dt.Rows[0]["CreatedOn"] != DBNull.Value ? ((DateTime)dt.Rows[0]["CreatedOn"]).ToString("dd MMMM yyyy ddddd HH:mm", new CultureInfo("tr-TR", false)) : string.Empty;
                        _announcement.CreatedOn = (DateTime)dt.Rows[0]["CreatedOn"];
                    }

                    #region | GET ATTACHMENTS |
                    MsCrmResultObject attachmentResult = AttachmentFileHelper.GetAnnouncementAttachmentFiles(announcementId, sda);
                    if (attachmentResult.Success)
                    {
                        _announcement.AttachmentFileList = (List<AttachmentFile>)attachmentResult.ReturnObject;
                    }
                    #endregion

                    returnValue.Success = true;
                    returnValue.ReturnObject = _announcement;
                }
                else
                {
                    returnValue.Result = "M026"; //"İlgili duyuruya ait bilgiye ulaşılamadı.";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
Ejemplo n.º 30
0
        public static MsCrmResultObject GetAnnouncementList(Guid portalId, Guid portalUserId, int start, int end, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"DECLARE @Date DATETIME = GETUTCDATE()
                        SELECT
                        *
                        FROM
                        (
                            SELECT
                                D.*
                                ,COUNT(0) OVER() AS TotalRow
                            FROM
                            (
                                    SELECT
                                     B.*
                                    ,ROW_NUMBER() OVER(ORDER BY B.CreatedOn DESC) AS RowNumber
                                    FROM
                                    (
                                        SELECT DISTINCT
                                            A.new_announcementId Id
                                            ,A.new_name Name
                                            ,A.new_content Content
                                            ,A.new_imageurl ImageUrl
                                            ,CAST({1}.dbo.fn_UTCToTzSpecificLocalTime(A.CreatedOn, us.TimeZoneBias, us.TimeZoneDaylightBias,us.TimeZoneDaylightYear, us.TimeZoneDaylightMonth, us.TimeZoneDaylightDay, us.TimeZoneDaylightHour,us.TimeZoneDaylightMinute, us.TimeZoneDaylightSecond, 0, us.TimeZoneDaylightDayOfWeek,us.TimeZoneStandardBias, us.TimeZoneStandardYear, us.TimeZoneStandardMonth, us.TimeZoneStandardDay,us.TimeZoneStandardHour, us.TimeZoneStandardMinute, us.TimeZoneStandardSecond, 0,us.TimeZoneStandardDayOfWeek) as DATETIME) CreatedOn
                                        FROM
                                            new_announcement A (NoLock)
                                        JOIN
                                            new_new_user_new_role AS UR (NOLOCK)
                                                ON
                                                UR.new_userid='{2}'
                                        JOIN
                                            new_role AS RD (NOLOCK)
                                                ON
                                                RD.new_roleId=UR.new_roleid
                                                AND
                                                Rd.statecode=0
                                                AND
                                                RD.statuscode=1 --Active
                                        JOIN
                                            new_new_announcement_new_role AS ERDF (NOLOCK)
                                                ON
                                                ERDF.new_announcementid=A.new_announcementId
                                                AND
                                                ERDF.new_roleid=RD.new_roleId
                                        INNER JOIN
                                            dbo.UserSettingsBase US (NoLock)
                                            ON
                                            US.SystemUserId ='{0}'
                                        WHERE
                                            @Date BETWEEN A.new_startdate AND A.new_enddate
                                        AND
                                            A.new_portalId='{3}'
                                        AND
                                            A.StateCode = 0
                                        AND
                                            A.StatusCode=1 --Active
                                    ) AS B
                                ) AS D
                            ) AS C
                                    WHERE
                                        C.RowNumber BETWEEN {4} AND {5}
                                    ORDER BY
                                        C.RowNumber ASC";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, Globals.AdminId, Globals.DatabaseName, portalUserId, portalId.ToString(), start.ToString(), end.ToString()));

                if (dt != null && dt.Rows.Count > 0)
                {
                    List<Announcement> returnList = new List<Announcement>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Announcement _announcement = new Announcement();
                        _announcement.AnnouncementId = (Guid)dt.Rows[i]["Id"];
                        _announcement.Caption = dt.Rows[i]["Name"] != DBNull.Value ? dt.Rows[i]["Name"].ToString() : string.Empty;
                        _announcement.Description = dt.Rows[i]["Content"] != DBNull.Value ? dt.Rows[i]["Content"].ToString() : string.Empty;
                        _announcement.ImagePath = dt.Rows[i]["ImageUrl"] != DBNull.Value ? dt.Rows[i]["ImageUrl"].ToString() : string.Empty;

                        if (dt.Rows[i]["TotalRow"] != DBNull.Value)
                        {
                            returnValue.RecordCount = (int)dt.Rows[i]["TotalRow"];
                        }

                        if (dt.Rows[i]["CreatedOn"] != DBNull.Value)
                        {
                            _announcement.CreatedOn = (DateTime)dt.Rows[i]["CreatedOn"];
                            _announcement.CreatedOnString = dt.Rows[i]["CreatedOn"] != DBNull.Value ? ((DateTime)dt.Rows[i]["CreatedOn"]).ToString("dd MMMM yyyy ddddd HH:mm", new CultureInfo("tr-TR", false)) : string.Empty;
                        }

                        returnList.Add(_announcement);
                    }

                    returnValue.Success = true;
                    returnValue.ReturnObject = returnList;
                }
                else
                {
                    returnValue.Success = true;
                    returnValue.Result = "M025"; //"Duyuru kaydı bulunamadı!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
Ejemplo n.º 31
0
        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)
            {
            }
        }