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


C# HttpStatusCode.Equals方法代码示例

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


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

示例1: SendCrmRequest

        public bool SendCrmRequest(ref string RespBody, ref HttpStatusCode RespStatus)
        {
            logger.Info("CRM4cInterfaceAccessManager::SendCrmRequest() called ");

            bool ret = false;
            bool exitFlag = false;

            int retryDelay = Convert.ToInt32(ServiceConfigurationManager._CRMConnectionDetails["RETRYWAITDURATION"]);
            int retryDelay4CRM = Convert.ToInt32(ServiceConfigurationManager._CRMConnectionDetails["FAILOVERTIME"]);

            while(!exitFlag)
            {
                // retry mechanism (N + 1)
                int retries = Convert.ToInt32(ServiceConfigurationManager._CRMConnectionDetails["RETRYNUMBERS"]) + 1;
                int retryNumCount = 0;

                // to find out message processed CRMs
                switch (CRM4cInterfaceAvailabilityManager.getActiveCRMName.ToUpper())
                {
                    case "P":
                        CRM4cInterfaceAvailabilityManager.IsMsgGoing2Primary = true;
                        break;
                    case "B":
                        CRM4cInterfaceAvailabilityManager.IsMsgGoing2Backup = true;
                        break;
                    default:
                        CRM4cInterfaceAvailabilityManager.IsMsgGoing2Primary = true;
                        break;
                }

                while (retries > 0)
                {

                    TimeSpan reqSendTS = System.DateTime.Now.TimeOfDay;
                    logger.Info(string.Format("Request send to CRM 4c REST Interface at...  {0}", reqSendTS));

                    ret = SendRequest(ref RespBody, ref RespStatus);
                    TimeSpan resRecTS = System.DateTime.Now.TimeOfDay;

                    logger.Info(string.Format("Response received from CRM 4c REST Interface at...  {0}", resRecTS));
                    logger.Info(string.Format("Total Process Time...  {0}  [{1}  -  {2}]", resRecTS.Subtract(reqSendTS), resRecTS, reqSendTS));

                    // If success, jump out of while loop
                    if (ret)
                    {
                        exitFlag = true;
                        break;
                    }

                   // go for retry, If CRM returned error code matchs with service configuration HTTPErrorCodes / time out error occurs
                    if (ServiceConfigurationManager._lst4cRetryErrorCodes.Contains(RespBody) || RespStatus.Equals(HttpStatusCode.RequestTimeout) || ServiceConfigurationManager._lst4cRetryErrorCodes.Contains(Convert.ToInt32(RespStatus).ToString()))
                    {
                          retries--;
                          if (retries>0) // not required for 0
                          {
                              logger.Info(string.Format("Active CRM Name...  {0}  ||  Retry...  {1}", CRM4cInterfaceAvailabilityManager.getActiveCRMFullName, ++retryNumCount));
                              Thread.Sleep(retryDelay);
                              logger.Info(string.Format("Service waited {0} secs. before proceeding next try", retryDelay / 1000));
                          }
                    }
                    else // jumping out of while loop for other scenarios
                    {
                        exitFlag = true;
                        break;
                    }

                }

                // jump out of outer while loop for success or Backup CRM is not available in the service config file
                if (exitFlag || (!CRM4cInterfaceAvailabilityManager.IsBackupCRMExist))
                {
                    break;
                }

                // If both CRMs failed, reset the flags & jump out of outer while loop
                if (CRM4cInterfaceAvailabilityManager.IsMsgGoing2Primary && CRM4cInterfaceAvailabilityManager.IsMsgGoing2Backup)
                {
                    logger.Error("Sending message to both Primary & Backup CRMs failed");
                    CRM4cInterfaceAvailabilityManager.IsMsgGoing2Primary = false;
                    CRM4cInterfaceAvailabilityManager.IsMsgGoing2Backup = false;
                    CRM4cInterfaceAvailabilityManager.IsAllCRMsFailed = true;
                    CRM4cInterfaceAvailabilityManager.ActiveCRMURL = CRM4cInterfaceAvailabilityManager.changeActiveCRM(CRM4cInterfaceAvailabilityManager.getActiveCRMName);
                    break;
                }

                logger.Error(string.Format("{0} tries failed to get response from {1} ", retryNumCount, CRM4cInterfaceAvailabilityManager.ActiveCRMURL));

                CRM4cInterfaceAvailabilityManager.ActiveCRMURL = CRM4cInterfaceAvailabilityManager.changeActiveCRM(CRM4cInterfaceAvailabilityManager.getActiveCRMName);
                logger.Info(string.Format("Switching the CRM to {0} ", CRM4cInterfaceAvailabilityManager.ActiveCRMURL));

                Thread.Sleep(retryDelay4CRM);
                logger.Info(string.Format("Service is waited {0} secs before start processing messages with switched CRM", retryDelay4CRM / 1000));

            }

            logger.Info(string.Format("CRM4cInterfaceAccessManager::SendCrmRequest() returned {0}", ret));
            return ret;
        }
开发者ID:hari316,项目名称:Projects,代码行数:98,代码来源:CRM4cInterfaceAccessManager.cs


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