当前位置: 首页>>代码示例>>C#>>正文


C# SqlDataAccess.closeConnection方法代码示例

本文整理汇总了C#中GK.Library.Utility.SqlDataAccess.closeConnection方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataAccess.closeConnection方法的具体用法?C# SqlDataAccess.closeConnection怎么用?C# SqlDataAccess.closeConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GK.Library.Utility.SqlDataAccess的用法示例。


在下文中一共展示了SqlDataAccess.closeConnection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        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();
            }
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:99,代码来源:PostCreate.cs

示例2: Execute

        public void Execute(IServiceProvider serviceProvider)
        {
            SqlDataAccess sda = null;

            try
            {
                sda = new SqlDataAccess();
                sda.openConnection(Globals.ConnectionString);

                #region | SERVICE |
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

                #region | Validate Request |
                //Target yoksa veya Entity tipinde değilse, devam etme.
                if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity))
                {
                    return;
                }
                #endregion

                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

                #endregion

                Entity entity = (Entity)context.InputParameters["Target"];

                #region |DEFINE IMAGE IF EXISTS|
                Entity postImage = null;
                if (context.PostEntityImages.Contains("PostImage") && context.PostEntityImages["PostImage"] is Entity)
                {
                    postImage = (Entity)context.PostEntityImages["PostImage"];
                }
                #endregion

                #region | VARIABLES |
                List<ScoreLimit> lstLimits = new List<ScoreLimit>();

                EntityReference portal = null;
                EntityReference user = null;

                if (postImage.Contains("new_portalid") && postImage["new_portalid"] != null)
                {
                    portal = (EntityReference)postImage["new_portalid"];
                }

                if (postImage.Contains("new_userid") && postImage["new_userid"] != null)
                {
                    user = (EntityReference)postImage["new_userid"];
                }
                #endregion

                if (entity.Contains("statuscode") && entity["statuscode"] != null && ((OptionSetValue)entity["statuscode"]).Value == 1)
                {
                    MsCrmResultObject limitRes = ScoreHelper.GetScoreLimitsByType(ScoreType.ForumSubject, sda);

                    if (limitRes.Success)
                    {
                        lstLimits = (List<ScoreLimit>)limitRes.ReturnObject;

                        for (int i = 0; i < lstLimits.Count; i++)
                        {
                            int recCount = 0;
                            DateTime start = GeneralHelper.GetStartDateByScorePeriod(lstLimits[i].Period);
                            DateTime end = GeneralHelper.GetEndDateByScorePeriod(lstLimits[i].Period);

                            recCount = ForumHelper.GetUserForumSubjectCount(portal.Id, user.Id, start, end, sda);

                            if (lstLimits[i].Frequency >= recCount)
                            {
                                Score sc = new Score()
                                {
                                    Point = lstLimits[i].Point,
                                    Portal = portal,
                                    User = user,
                                    ScoreType = ScoreType.ForumSubject
                                };

                                MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service);

                                break;
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                //LOG
                throw new InvalidPluginExecutionException(ex.Message);
            }
            finally
            {
                if (sda != null)
                    sda.closeConnection();
            }
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:98,代码来源:PostUpdate.cs

示例3: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            FileLogHelper.LogEvent("Kale-uploadHelper", @"C:\DO\");

            context.Response.ContentType = "application/json";

            object returnValue = null;

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            try
            {
                _sda = new SqlDataAccess();
                _sda.openConnection(Globals.ConnectionString);

                string operation = context.Request.QueryString["operation"];
                string userId = context.Request.QueryString["userid"];
                string graffitiId = context.Request.QueryString["graffitiId"];

                if (operation == "1" && !string.IsNullOrEmpty(userId)) //Profile resmi güncelleme
                {
                    returnValue = new MsCrmResult();

                    _service = MSCRM.GetOrgService(true);
                    HttpPostedFile file = context.Request.Files[0];

                    returnValue = SaveProfileImage(userId, file, context);
                }
                else if (operation == "2" && !string.IsNullOrEmpty(graffitiId)) //Duvar yazısı resim ekleme
                {
                    returnValue = new MsCrmResult();

                    _service = MSCRM.GetOrgService(true);
                    HttpPostedFile file = context.Request.Files[0];

                    returnValue = SaveGraffitiImage(new Guid(graffitiId), file, context);
                }
                else
                {
                    ((MsCrmResultObject)returnValue).Result = "Eksik veya yanlış parametre.";
                }
            }
            catch (Exception ex)
            {
                returnValue = new MsCrmResult();
                ((MsCrmResult)returnValue).HasException = true;
                ((MsCrmResult)returnValue).Result = ex.Message;

            }
            finally
            {
                if (_sda != null)
                {
                    _sda.closeConnection();

                }
            }

            var dataRes = serializer.Serialize(returnValue);
            context.Response.Write(dataRes);
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:61,代码来源:uploadHelper.ashx.cs

示例4: GetTowns

        public List<EntityReference> GetTowns(string cityId)
        {
            List<EntityReference> returnValue = new List<EntityReference>();

            try
            {
                sda = new SqlDataAccess();
                sda.openConnection(Globals.ConnectionString);

                #region | SQL QUERY |

                string sqlQuery = @"SELECT
                                    t.new_townId AS Id
                                    ,t.new_name AS Name
                                    ,'new_town' AS LogicalName
                                FROM
                                new_town AS t (NOLOCK) WHERE t.new_cityId='{0}'";
                #endregion

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

                returnValue = dt.ToList<EntityReference>();
            }
            catch (Exception ex)
            {

            }
            finally
            {
                if (sda != null)
                    sda.closeConnection();
            }

            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:35,代码来源:CrmService.svc.cs

示例5: GetCities

        public List<EntityReference> GetCities()
        {
            List<EntityReference> returnValue = new List<EntityReference>();

            try
            {
                sda = new SqlDataAccess();
                sda.openConnection(Globals.ConnectionString);

                #region | SQL QUERY |

                string sqlQuery = @"SELECT
                                    c.new_cityId AS Id
                                    ,c.new_name AS Name
                                    ,'new_city' AS LogicalName
                                FROM
                                new_city AS c (NOLOCK)";
                #endregion

                DataTable dt = sda.getDataTable(sqlQuery);

                returnValue = dt.ToList<EntityReference>();

            }
            catch (Exception ex)
            {

            }
            finally
            {
                if (sda != null)
                    sda.closeConnection();
            }

            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:36,代码来源:CrmService.svc.cs

示例6: GetTowns

        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;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:43,代码来源:EmosService.svc.cs

示例7: GetAssemblerList

        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;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:43,代码来源:EmosService.svc.cs


注:本文中的GK.Library.Utility.SqlDataAccess.closeConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。