void _callBack_NewInstanceEvent(object sender, EventArgs e)
        {
            InstanceEventArgs   ie = (InstanceEventArgs)e;
            ServiceInstanceInfo serviceInstanceInfo = ie.instanceStateOutcomerInfo;

            BindingData.UpdateInstances(new ServiceInstanceInfo[] { serviceInstanceInfo });
        }
 public void InstanceEvent(ServiceInstanceInfo StateOutcomerInfo)
 {
     NewInstanceEvent(this, new InstanceEventArgs()
     {
         instanceStateOutcomerInfo = StateOutcomerInfo
     });
 }
Beispiel #3
0
        private static ServiceInstance GetService(ServiceInstanceInfo info)
        {
            if (_AvaServiceInstances.Count == 0)
            {
                _CreateInstance();
            }
            var ins = _AvaServiceInstances[0];

            _ServiceInstances.Add(ins, info);
            _AvaServiceInstances.Remove(ins);

            Logger.Log <string>(LogLevel.Information, new EventId(), null, null, (o, ex) => { return("ServiceInstance-Recover-" + DateTime.Now); });
            return(ins);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="HashToken">HashToken</param>
        /// <param name="ServiceNotFindCallback">ServiceNotFind Callback</param>
        /// <returns></returns>
        public static ServiceInstance RecoverService(string HashToken, Action <string> ServiceNotFindCallback)
        {
            var list = (from t in _IntServiceInstancesInfos.Values
                        where t.Value.LoginHashToken == HashToken &&
                        t.Value.LoginHashToken != null
                        select t.Value).ToList();

            ServiceInstanceInfo info = list.Count > 0 ? list[0] : null;

            if (info == null)
            {
                ServiceNotFindCallback.Invoke(HashToken);
                return(GetService());
            }
            return(GetService(info));
        }
        public static ServiceInstanceInfo GetServiceInstance(Guid serviceInstanceGuid)
        {
            var serviceManagementServer = WrapperFactory.Instance.GetServiceManagementServerWrapper(null);

            using (serviceManagementServer.BaseAPIServer?.Connection)
            {
                var serviceInstanceXml = serviceManagementServer.GetServiceInstanceCompact(serviceInstanceGuid);
                if (string.IsNullOrEmpty(serviceInstanceXml))
                {
                    return(null);
                }
                else
                {
                    return(ServiceInstanceInfo.Create(serviceInstanceXml));
                }
            }
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="delivery"></param>
        /// <param name="conflictBehavior">Indicates how conflicting deliveries will be handled.</param>
        /// <param name="importManager">The import manager that will be used to handle conflicting deliveries.</param>
        public void HandleConflicts(DeliveryImportManager importManager, DeliveryConflictBehavior defaultConflictBehavior, bool getBehaviorFromConfiguration = true)
        {
            if (this.Delivery.Outputs.Count < 1)
            {
                return;
            }

            ServiceInstanceInfo parent = this.Instance;

            while (parent.ParentInstance != null)
            {
                parent = parent.ParentInstance;
            }


            foreach (DeliveryOutput output in this.Delivery.Outputs)
            {
                if (!output.PipelineInstanceID.HasValue)
                {
                    output.PipelineInstanceID = parent.InstanceID;
                }
            }

            this.Delivery.Save();

            // ================================
            // Conflict behavior

            DeliveryConflictBehavior behavior = defaultConflictBehavior;

            if (getBehaviorFromConfiguration)
            {
                string configuredBehavior;
                if (Instance.Configuration.Options.TryGetValue("ConflictBehavior", out configuredBehavior))
                {
                    behavior = (DeliveryConflictBehavior)Enum.Parse(typeof(DeliveryConflictBehavior), configuredBehavior);
                }
            }


            var processing = new List <DeliveryOutput>();
            var committed  = new List <DeliveryOutput>();

            foreach (DeliveryOutput output in this.Delivery.Outputs)
            {
                DeliveryOutput[] conflicts = output.GetConflicting();

                foreach (DeliveryOutput conflict in conflicts)
                {
                    if (conflict.PipelineInstanceIsRunning)
                    {
                        processing.Add(conflict);
                    }

                    if (conflict.Status == DeliveryOutputStatus.Committed || conflict.Status == DeliveryOutputStatus.Staged)
                    {
                        committed.Add(conflict);
                    }
                }
            }
            if (processing.Count > 0)
            {
                foreach (var output in Delivery.Outputs)
                {
                    output.Status = DeliveryOutputStatus.Canceled;
                }

                this.Delivery.Save();
                throw new DeliveryConflictException("There are outputs with the same signatures currently being processed:")
                      {
                          ConflictingOutputs = processing.ToArray()
                      };                                                                                                                                                                    // add list of output ids
            }

            if (behavior == DeliveryConflictBehavior.Ignore)
            {
                return;
            }

            if (committed.Count > 0)
            {
                foreach (var output in Delivery.Outputs)
                {
                    output.Status = DeliveryOutputStatus.Canceled;
                }


                this.Delivery.Save();
                throw new DeliveryConflictException("There are outputs with the same signatures are already committed\\staged:")
                      {
                          ConflictingOutputs = committed.ToArray()
                      };                                                                                                                                                                       // add list of output ids
            }
        }
Beispiel #7
0
 internal static void SetServiceInstanceInfo(ServiceInstance Instance, ServiceInstanceInfo Info)
 {
     _ServiceInstances[Instance] = Info;
 }
Beispiel #8
0
        protected override void OnInit()
        {
            string sp = Instance.Configuration.GetOption("Procedure");


            SendResultByEmail = Convert.ToBoolean(Instance.Configuration.GetOption("SendResultByEmail"));

            // Check for a custom connection string
            string        connString = Instance.Configuration.GetOption("ConnectionString");
            SqlConnection conn       = new SqlConnection(connString);

            // Check for a custom timeout
            string   timeoutStr = Instance.Configuration.GetOption("ConnectionTimeout", false);
            TimeSpan _cmdTimeOut;

            if (TimeSpan.TryParse(timeoutStr, out _cmdTimeOut))
            {
                DataManager.CommandTimeout = (Int32)(_cmdTimeOut.TotalSeconds);
            }

            // Build the command
            Cmd = DataManager.CreateCommand(sp, System.Data.CommandType.StoredProcedure);
            DataManager.ConnectionString = connString;
            Cmd.Connection = conn;

            //Getting SQL Parameters from configuration
            foreach (SqlParameter param in Cmd.Parameters)
            {
                string name = param.ParameterName.Remove(0, 1);
                string configVal;
                if (!Instance.Configuration.Options.TryGetValue("param." + name, out configVal))                 // remove the s from params
                {
                    param.Value = DBNull.Value;
                    continue;
                }

                // Apply the configuration value, before we check if we need to parse it
                object value = configVal;

                // Dynamic Params
                if (configVal.StartsWith("{") && configVal.EndsWith("}"))
                {
                    ServiceInstanceInfo targetInstance = Instance;
                    string dynamicParam = configVal.Substring(1, configVal.Length - 2);

                    // Go up levels ../../InstanceID
                    int levelsUp = Regex.Matches(dynamicParam, @"\.\.\/").Count;
                    for (int i = 0; i < levelsUp; i++)
                    {
                        targetInstance = targetInstance.ParentInstance;
                    }

                    // Split properties into parts (Configuration.Options.BlahBlah);
                    dynamicParam = dynamicParam.Replace("../", string.Empty);
                    string[] dynamicParamParts = dynamicParam.Split('.');

                    // Get the matching property
                    if (dynamicParamParts[0] == "Configuration" && dynamicParamParts.Length > 1)
                    {
                        if (dynamicParamParts[1] == "Options" && dynamicParamParts.Length > 2)
                        {
                            // Asked for an option
                            value = targetInstance.Configuration.Options[dynamicParamParts[2]];
                        }
                        else
                        {
                            // Asked for some other configuration value
                            PropertyInfo property = typeof(ServiceElement).GetProperty(dynamicParamParts[1]);
                            value = property.GetValue(targetInstance.Configuration, null);
                        }
                    }
                    else if (dynamicParamParts[0] == "TimePeriod")                     //Getting time period
                    {
                        PropertyInfo property = typeof(PipelineService).GetProperty(dynamicParamParts[0]);

                        if (dynamicParamParts[1] == "Start" && dynamicParamParts.Length >= 2)
                        {
                            value = this.TimePeriod.Start.ToDateTime();
                        }
                        else                         //TimePeriod.End
                        {
                            value = this.TimePeriod.End.ToDateTime();
                        }
                    }
                    else
                    {
                        // Asked for an instance value
                        PropertyInfo property = typeof(ServiceInstanceInfo).GetProperty(dynamicParamParts[0]);
                        if (!property.PropertyType.FullName.Equals("System.DateTime"))
                        {
                            value = property.GetValue(targetInstance, null);
                        }
                        else
                        {
                            value = ((DateTimeSpecification)(property.GetValue(targetInstance, null))).ToDateTime().ToString("yyyyMMdd");
                        }
                    }
                }

                param.Value = value;
                Log.Write(string.Format("ExecuteStoredProcedureService Value{0} ", value), LogMessageType.Information);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Hi M8, This function create a Dictionary with the fields from the required
        /// section in the configuration.
        /// </summary>
        /// <param name="fields">A Dictionary that contain the fields from the required
        /// section in the configuration.</param>
        /// <param name="sectionName">The section name from the configuration to load.</param>
        protected virtual void InitalizeGatewayNameMapping(Dictionary <string, string> fields, string sectionName)
        {
            //***************************
            // ANTI-YANIV HACK
            ServiceInstanceInfo targetInstance = Instance;
            string trackerParamsRaw            = string.Empty;

            if (sectionName == "GatewayName")
            {
                while (targetInstance != null)
                {
                    trackerParamsRaw = targetInstance.Configuration.Options["TrackingParameters"];
                    if (string.IsNullOrEmpty(trackerParamsRaw))
                    {
                        targetInstance = targetInstance.ParentInstance;
                    }
                    else
                    {
                        break;
                    }
                }

                if (trackerParamsRaw != null)
                {
                    string[] trackerParamPairs = trackerParamsRaw.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string trackerParamPair in trackerParamPairs)
                    {
                        string[] pair = trackerParamPair.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        if (pair.Length < 2)
                        {
                            continue;
                        }
                        else
                        {
                            fields.Add(pair[0], pair[1]);
                        }
                    }

                    // If we found anything ignore the rest of this horrible function
                    if (fields.Count >= 1) //fix by alon changed from >1 to >=1 we need at least 1 25/11
                    {
                        return;
                    }
                }
            }
            // ANTI-YANIV HACK
            //***************************

            try
            {
                // Load the proper report paramters by the report name.
                FieldElementSection fes = (FieldElementSection)ConfigurationManager.GetSection(sectionName);

                // Initalize the hash table with the fields of the the report.
                foreach (FieldElement fe in fes.Fields)
                {
                    fields.Add(fe.Key, fe.Value);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("Error get configuration Data from {0} section.", sectionName), ex);
            }
        }
Beispiel #10
0
        protected override void OnInit()
        {
            string sp = Instance.Configuration.Options["Procedure"];

            if (String.IsNullOrEmpty(sp))
            {
                throw new ConfigurationException("Missing configuration option \"Procedure\".");
            }

            // Check for a custom connection string
            string conn;

            if (Instance.Configuration.Options.TryGetValue("ConnectionString", out conn))
            {
                DataManager.ConnectionString = conn;
            }


            // Check for a custom timeout
            string   timeoutStr;
            TimeSpan _cmdTimeOut; // Bug fix Shay 27.02.11

            if (Instance.Configuration.Options.TryGetValue("ConnectionTimeout", out timeoutStr))
            {
                if (TimeSpan.TryParse(timeoutStr, out _cmdTimeOut))
                {
                    DataManager.CommandTimeout = (Int32)(_cmdTimeOut.TotalSeconds);
                }
            }

            // Build the command
            _cmd = DataManager.CreateCommand(sp, System.Data.CommandType.StoredProcedure);
            foreach (SqlParameter param in _cmd.Parameters)
            {
                string name = param.ParameterName.Remove(0, 1);                                  //fix by alon on 20/1/2001 remove the '@'
                string configVal;
                if (!Instance.Configuration.Options.TryGetValue("param." + name, out configVal)) //also remove the s from params
                {
                    continue;
                }

                // Apply the configuration value, before we check if we need to parse it
                object value = configVal;

                // Dynamic Params
                if (configVal.StartsWith("{") && configVal.EndsWith("}"))
                {
                    ServiceInstanceInfo targetInstance = Instance;
                    string dynamicParam = configVal.Substring(1, configVal.Length - 2);

                    // Go up levels ../../InstanceID
                    int levelsUp = Regex.Matches(dynamicParam, @"\.\.\/").Count;
                    for (int i = 0; i < levelsUp; i++)
                    {
                        targetInstance = targetInstance.ParentInstance;
                    }

                    // Split properties into parts (Configuration.Options.BlahBlah);
                    dynamicParam = dynamicParam.Replace("../", string.Empty);
                    string[] dynamicParamParts = dynamicParam.Split('.');

                    // Get the matching property
                    if (dynamicParamParts[0] == "Configuration" && dynamicParamParts.Length > 1)
                    {
                        if (dynamicParamParts[1] == "Options" && dynamicParamParts.Length > 2)
                        {
                            // Asked for an option
                            value = targetInstance.Configuration.Options[dynamicParamParts[2]];
                        }
                        else
                        {
                            // Asked for some other configuration value
                            PropertyInfo property = typeof(ServiceElement).GetProperty(dynamicParamParts[1]);
                            value = property.GetValue(targetInstance.Configuration, null);
                        }
                    }
                    else
                    {
                        // Asked for an instance value
                        //Alon & Shay Bug fix = incorrect date format ( daycode )
                        PropertyInfo property = typeof(ServiceInstanceInfo).GetProperty(dynamicParamParts[0]);
                        if (!property.PropertyType.FullName.Equals("System.DateTime"))
                        {
                            value = property.GetValue(targetInstance, null);
                        }
                        else
                        {
                            value = ((DateTime)property.GetValue(targetInstance, null)).ToString("yyyyMMdd");
                            // Log.Write("Delete Days - DayCode " + (string)value, LogMessageType.Information);
                        }
                    }
                }

                param.Value = value;
                Log.Write(string.Format("ExecuteStoredProcedureService Value{0} ", value), LogMessageType.Information);
            }
        }