private static DateTime CalculateEscalationDatePrivate(string zoneName, DateTime startDate, int seconds) { WorkflowManagementServer mngServer = null; try { mngServer = new WorkflowManagementServer("localhost", 5555); //fairly safe to do this as inline function runs on K2 Server. mngServer.Open(); //http://www.k2underground.com/forums/p/8275/31827.aspx mngServer.ZoneLoad(zoneName); return(mngServer.ZoneCalculateEvent(zoneName, startDate, new TimeSpan(0, 0, 0, seconds))); } catch (Exception ex) { //more detailed error in the k2server logs throw new Exception(string.Format("Error: {0}{1}", ex.Message, ex.StackTrace), ex); } finally { if (mngServer != null) { if (mngServer.Connection != null) { mngServer.Connection.Dispose(); } mngServer = null; } } }
private static DateTime CalculateEscalationDatePrivate(string zoneName, DateTime startDate, int seconds) { WorkflowManagementServer mngServer = null; try { mngServer = new WorkflowManagementServer("localhost", 5555); //fairly safe to do this as inline function runs on K2 Server. mngServer.Open(); //http://www.k2underground.com/forums/p/8275/31827.aspx mngServer.ZoneLoad(zoneName); return mngServer.ZoneCalculateEvent(zoneName, startDate, new TimeSpan(0, 0, 0, seconds)); } catch (Exception ex) { //more detailed error in the k2server logs throw new Exception(string.Format("Error: {0}{1}", ex.Message, ex.StackTrace), ex); } finally { if (mngServer != null) { if (mngServer.Connection != null) { mngServer.Connection.Dispose(); } mngServer = null; } } }
private void ZoneCalculateEvent() { string ZoneName = base.GetStringProperty(Constants.SOProperties.WorkingHoursConfiguration.ZoneName, true); string Start = base.GetStringProperty(Constants.SOProperties.WorkingHoursConfiguration.StartDateTime, true); int DurationHours = base.GetIntProperty(Constants.SOProperties.WorkingHoursConfiguration.DurationHours); int DurationMinutes = base.GetIntProperty(Constants.SOProperties.WorkingHoursConfiguration.DurationMinutes); int DurationSeconds = base.GetIntProperty(Constants.SOProperties.WorkingHoursConfiguration.DurationSeconds); base.ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable(); DataTable results = base.ServiceBroker.ServicePackage.ResultTable; WorkflowManagementServer mngServer = new WorkflowManagementServer(); using (mngServer.CreateConnection()) { mngServer.Open(BaseAPIConnectionString); if (!mngServer.ZoneExists(ZoneName)) { throw new ApplicationException(Constants.ErrorMessages.ZoneDoesNotExist + ZoneName + "."); } else { TimeSpan Duration = new TimeSpan(DurationHours, DurationMinutes, DurationSeconds); DateTime dt; if (!DateTime.TryParse(Start, out dt)) { throw new ApplicationException(Constants.ErrorMessages.DateNotValid); } AvailabilityZone zone = mngServer.ZoneLoad(ZoneName); if (zone.AvailabilityHoursList == null || zone.AvailabilityHoursList.Count == 0) { throw new ApplicationException(Constants.ErrorMessages.WorkingHoursNotSet); } DataRow dRow = results.NewRow(); dRow[Constants.SOProperties.WorkingHoursConfiguration.FinishDateTime] = mngServer.ZoneCalculateEvent(ZoneName, dt, Duration); results.Rows.Add(dRow); } } }
private void ZoneCalculateEvent() { string ZoneName = base.GetStringProperty(Constants.SOProperties.WorkingHoursConfiguration.ZoneName, true); string Start = base.GetStringProperty(Constants.SOProperties.WorkingHoursConfiguration.StartDateTime, true); int DurationHours = base.GetIntProperty(Constants.SOProperties.WorkingHoursConfiguration.DurationHours); int DurationMinutes = base.GetIntProperty(Constants.SOProperties.WorkingHoursConfiguration.DurationMinutes); int DurationSeconds = base.GetIntProperty(Constants.SOProperties.WorkingHoursConfiguration.DurationSeconds); base.ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable(); DataTable results = base.ServiceBroker.ServicePackage.ResultTable; WorkflowManagementServer mngServer = this.ServiceBroker.K2Connection.GetConnection <WorkflowManagementServer>(); using (mngServer.Connection) { if (!mngServer.ZoneExists(ZoneName)) { throw new ApplicationException(Resources.ZoneDoesNotExist + ZoneName + "."); } else { TimeSpan Duration = new TimeSpan(DurationHours, DurationMinutes, DurationSeconds); DateTime dt; if (!DateTime.TryParse(Start, out dt)) { throw new ApplicationException(Resources.DateNotValid); } AvailabilityZone zone = mngServer.ZoneLoad(ZoneName); if (zone.AvailabilityHoursList == null || zone.AvailabilityHoursList.Count == 0) { throw new ApplicationException(Resources.WorkingHoursNotSet); } DataRow dRow = results.NewRow(); dRow[Constants.SOProperties.WorkingHoursConfiguration.FinishDateTime] = mngServer.ZoneCalculateEvent(ZoneName, dt, Duration); results.Rows.Add(dRow); } } }