Beispiel #1
0
        public IConditionRule Create(int index, Value val)
        {
            ConditionRule c = null;

            switch (CType)
            {
            case ConditionType.CContain:
            {
                c = new ConditionContains();
                break;
            }

            case ConditionType.CEqual:
            {
                c = new ConditionEqual();
                break;
            }

            case ConditionType.CLess:
            {
                c = new ConditionLess();
                break;
            }
            }
            c.Index     = index;
            c.Reference = val;
            if (OIndex == 0) // TODO copy for safety
            {
                return(c);
            }
            return(new ConditionNot()
            {
                ToNegate = c
            });
        }
Beispiel #2
0
        public void Test1()
        {
            var rule = new ConditionRule
            {
                Condition = new AllMatch
                {
                    Conditions =
                    {
                        new CustomerAge     {
                            From = 10
                        },
                        new False(),
                        new ProductQuantity {
                            To = 50
                        },
                        new OrderDate       {
                            From = DateTime.Today
                        }
                    }
                }
            };

            var xaml = SimpleXamlSerializer.ToXaml(rule);

            Debug.Print(XElement.Parse(xaml).ToString());
        }
Beispiel #3
0
 protected override RuleImp VisitRuleElement(ConditionRule info)
 {
     return(new ConditionRuleImp
     {
         Name = info.Name,
         Condition = Visit(info.Condition),
         Rule = Visit(info.Rule)
     });
 }
Beispiel #4
0
 public AttachedEventData(
     IProperty property,
     ConditionRule conditions,
     string value,
     int attachmentID
     ) : this(property, conditions, value)
 {
     AttachmentID = attachmentID;
 }
Beispiel #5
0
        /// <summary>
        /// Directly invokes the condition rule associated with the current condition type instance.
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public void When(object target)
        {
            if (ConditionRule == null)
            {
                throw new NotSupportedException("The current condition type, " + Code + ", does not have an associated condition rule.");
            }

            ConditionRule.Invoke(ModelContext.Current.GetModelType(target).GetModelInstance(target), null);
        }
Beispiel #6
0
 public EventData(int id, int baseEventID, int valueID, ConditionRule conditions, int actorEventID, string value)
 {
     ID           = id;
     BaseEventID  = baseEventID;
     ValueID      = valueID;
     Conditions   = conditions;
     ActorEventID = actorEventID;
     Value        = value;
     Date         = DateTime.UtcNow;
 }
Beispiel #7
0
 public AttachedEventData(
     IProperty property,
     ConditionRule conditions,
     string value
     )
 {
     Property   = property;
     Conditions = conditions;
     Value      = value;
 }
 public AttachedRelationData(
     IRelation relation,
     bool required,
     int cardinality,
     bool mutable,
     int?permission,
     ConditionRule conditions
     ) : this(relation, required, cardinality, mutable, permission, conditions, null)
 {
     PropertyProvider = new PropertyProviderData();
 }
        public async Task <string> ToReadable(ConditionRule rule)
        {
            if (rule is ConditionRule.EventConditionRule eventRule)
            {
                var e = await storage.GetEvent(eventRule.EventID);

                return($"[{eventRule.EventID}] {e.EventValue.Value}");
            }
            else if (rule is ConditionRule.ComplexConditionRule complexRule && 1 == complexRule.Values.Count())
            {
                return(await ToReadable(complexRule.Values.Single()));
            }
Beispiel #10
0
 public AttachedAttrData(
     AttrData attr,
     bool required,
     int cardinality,
     bool mutable,
     int?permission,
     IBoxedValue defaultValue,
     ConditionRule conditions
     ) : this(attr, required, cardinality, mutable, permission, defaultValue, conditions, null)
 {
     PropertyProvider = new PropertyProviderData();
     AttachmentID     = null;
 }
Beispiel #11
0
 public AttachedRelationData(
     IRelation relation,
     bool required,
     int cardinality,
     bool mutable,
     int?permission,
     PropertyProviderData provider,
     ConditionRule conditions,
     int attachmentID
     ) : this(relation, required, cardinality, mutable, permission, conditions, provider)
 {
     AttachmentID = attachmentID;
 }
Beispiel #12
0
 public AttachedAttrData(
     AttrData attr,
     bool required,
     int cardinality,
     bool mutable,
     int?permission,
     IBoxedValue defaultValue,
     PropertyProviderData provider,
     ConditionRule conditions,
     int attachmentID
     ) : this(attr, required, cardinality, mutable, permission, defaultValue, conditions, provider)
 {
     AttachmentID = attachmentID;
 }
Beispiel #13
0
        private async Task <int> ProcessEvent(int baseEventID, int valueID, ConditionRule conditions, string value)
        {
            var id = Engine.Position;
            var e  = new EventData(
                id,
                baseEventID,
                valueID,
                conditions,
                Credentials.CurrentActor.IndividualID,
                value
                );
            await Engine.ProcessEvent(e);

            return(id);
        }
Beispiel #14
0
        private List <ConditionRule> ParseQuery(string s)
        {
            List <ConditionRule> result = new List <ConditionRule>();

            string[] lines = s.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string line in lines)
            {
                ConditionRule c = ConvertToCondition(line);
                if (c == null)
                {
                    return(null);
                }
                result.Add(c);
            }
            return(result);
        }
        public override Expression BuildExpression(params ParameterExpression[] parameters)
        {
            if (parameters == null || parameters.Length != 1 || parameters[0].Type != typeof(T1))
            {
                throw new RuleEngineException($"{nameof(BuildExpression)} must call with one parameter of {typeof(T1)}");
            }

            var returnLabel = Expression.Label(typeof(T2), "returnLabel");

            var conditionalExpression = ConditionRule.BuildExpression(parameters);

            if (!(conditionalExpression is LambdaExpression))
            {
                conditionalExpression = Expression.Lambda(conditionalExpression, parameters);
            }

            var trueExpression = TrueRule.BuildExpression(parameters);

            if (!(trueExpression is LambdaExpression))
            {
                trueExpression = Expression.Lambda(trueExpression, parameters);
            }

            var falseExpression = FalseRule.BuildExpression(parameters);

            if (!(falseExpression is LambdaExpression))
            {
                falseExpression = Expression.Lambda(falseExpression, parameters);
            }

            var ifThenElseExpression = Expression.IfThenElse(
                Expression.Invoke(conditionalExpression, parameters.Cast <Expression>()),
                Expression.Return(returnLabel, Expression.Invoke(trueExpression, parameters.Cast <Expression>())),
                Expression.Return(returnLabel, Expression.Invoke(falseExpression, parameters.Cast <Expression>()))
                );

            Debug.WriteLine($"ConditionRule:{Environment.NewLine}{ConditionRule.ExpressionDebugView()}");
            Debug.WriteLine($"TrueRule:{Environment.NewLine}{TrueRule.ExpressionDebugView()}");
            Debug.WriteLine($"FalseRule:{Environment.NewLine}{FalseRule.ExpressionDebugView()}");

            var defaultForReturnLabel = Expression.Convert(Expression.Constant(default(T2)), typeof(T2));

            ExpressionForThisRule = Expression.Block(ifThenElseExpression,
                                                     Expression.Label(returnLabel, defaultForReturnLabel));
            return(ExpressionForThisRule);
        }
Beispiel #16
0
 protected IEnumerable <ConditionRule> TraverseConditions(ConditionRule stack)
 {
     if (stack is ConditionRule.ComplexConditionRule complex)
     {
         foreach (var rule in complex.Values)
         {
             foreach (var subRule in TraverseConditions(rule))
             {
                 yield return(subRule);
             }
         }
     }
     else
     {
         yield return(stack);
     }
 }
Beispiel #17
0
 private AttachedRelationData(
     IRelation relation,
     bool required,
     int cardinality,
     bool mutable,
     int?permission,
     ConditionRule conditions,
     PropertyProviderData provider
     )
 {
     Relation         = relation;
     Required         = required;
     Mutable          = mutable;
     Cardinality      = cardinality;
     Permission       = permission;
     Conditions       = conditions;
     PropertyProvider = provider;
 }
Beispiel #18
0
 private AttachedAttrData(
     AttrData attr,
     bool required,
     int cardinality,
     bool mutable,
     int?permission,
     IBoxedValue defaultValue,
     ConditionRule conditions,
     PropertyProviderData provider
     )
 {
     Attribute        = attr;
     Required         = required;
     Cardinality      = cardinality;
     Mutable          = mutable;
     Permission       = permission;
     Conditions       = conditions;
     DefaultValue     = defaultValue;
     PropertyProvider = provider;
 }
Beispiel #19
0
        private void GenerateContent(ref Gtk.Table tableSystem, string label, int xPos, Condition cd, bool isResolution)
        {
            ListStore lstorePlatform = new ListStore(typeof(int), typeof(int), typeof(string));

            int selectRule = 0;

            if (conditionRules_Old.Count > 0)
            {
                ConditionRule cr = conditionRules_Old.Find(x => x.ConditionId == cd.Id);
                if (cr != null)
                {
                    selectRule = cr.RuleId;
                }
            }

            Label lblPlatform = new Label(label);

            lblPlatform.Name   = "lbl_" + label;
            lblPlatform.Xalign = 1F;
            lblPlatform.Yalign = 0.5F;

            ComboBox cboxPlatform = new ComboBox();

            cboxPlatform.Name = "cd_" + label;

            CellRendererText textRenderer = new CellRendererText();

            cboxPlatform.PackStart(textRenderer, true);
            cboxPlatform.AddAttribute(textRenderer, "text", 2);

            cboxPlatform.WidthRequest = 200;
            cboxPlatform.Model        = lstorePlatform;

            tableSystem.Attach(lblPlatform, 0, 1, (uint)(xPos - 1), (uint)xPos, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2);
            tableSystem.Attach(cboxPlatform, 1, 2, (uint)(xPos - 1), (uint)xPos, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2);

            TreeIter selectIter = lstorePlatform.AppendValues(0, cd.Id, "Unset");

            foreach (Rule rl in cd.Rules)
            {
                if (!isResolution)
                {
                    if (rl.Id == selectRule)
                    {
                        selectIter = lstorePlatform.AppendValues(rl.Id, cd.Id, rl.Name);
                    }
                    else
                    {
                        lstorePlatform.AppendValues(rl.Id, cd.Id, rl.Name);
                    }
                }
                else
                {
                    string name = String.Format("{0} ({1}x{2})", rl.Name, rl.Width, rl.Height);
                    if (rl.Id == selectRule)
                    {
                        selectIter = lstorePlatform.AppendValues(rl.Id, cd.Id, name);
                    }
                    else
                    {
                        lstorePlatform.AppendValues(rl.Id, cd.Id, name);
                    }
                }
            }
            cboxPlatform.SetActiveIter(selectIter);

            cboxPlatform.Changed += delegate(object sender, EventArgs e) {
                if (sender == null)
                {
                    return;
                }

                ComboBox combo = sender as ComboBox;

                TreeIter iter;
                if (combo.GetActiveIter(out iter))
                {
                    int ruleId = (int)combo.Model.GetValue(iter, 0);
                    int condId = (int)combo.Model.GetValue(iter, 1);
                    if (ruleId != 0)
                    {
                        ConditionRule cr = conditionRules.Find(x => x.ConditionId == condId);                                //cd.Id);
                        if (cr != null)
                        {
                            cr.RuleId = ruleId;
                        }
                        else
                        {
                            conditionRules.Add(new ConditionRule(condId, ruleId));
                        }
                    }
                    else
                    {
                        ConditionRule cr = conditionRules.Find(x => x.ConditionId == condId);
                        if (cr != null)
                        {
                            conditionRules.Remove(cr);
                        }
                    }
                    isChanged = true;
                }
            };
        }
Beispiel #20
0
        public async Task ShouldReturnManySheetsForManyTimesAttendedDepartment()
        {
            var organizationClient = new OrganizationClient();
            await organizationClient.SetupOrganization(builder =>
                                                       builder
                                                       .SetupStampsCount(5)
                                                       .SetupPath((1, 3))
                                                       .AddDepartment(Department.WithConditionRule(1, new ConditionRule(2, (1, 5, 3), (1, 5, 2))))
                                                       .AddDepartment(Department.WithSimpleRule(2, (2, 3, 1)))
                                                       .AddDepartment(Department.WithSimpleRule(3, (3, 4, -1))));

            var response = await organizationClient.GetSheetsInDepartment(1);

            Assert.IsTrue(IsExpectedResponse(response, RouteStatus.Attended, new HashSet <int> {
                1
            },
                                             new HashSet <int> {
                1, 2
            }));
        }
Beispiel #21
0
 public static Department WithConditionRule(int number, ConditionRule conditionRule)
 {
     return(new Department(number, conditionRule));
 }
Beispiel #22
0
 public ConditionStatementRule(ConditionRule condition, ExtraConditionRule extraCondition)
 {
     Condition      = Guard.NonNull(() => condition);
     ExtraCondition = extraCondition;
 }
Beispiel #23
0
        public async Task ShouldGoToEndWithDifferentRules()
        {
            var organizationClient = new OrganizationClient();
            await organizationClient.SetupOrganization(builder =>
                                                       builder
                                                       .SetupStampsCount(5)
                                                       .SetupPath((1, 2))
                                                       .AddDepartment(Department.WithConditionRule(1, new ConditionRule(1, (1, 2, 2), (2, 5, 2))))
                                                       .AddDepartment(Department.WithSimpleRule(2, (3, 2, -1))));

            var response = await organizationClient.GetSheetsInDepartment(2);

            Assert.IsTrue(IsExpectedResponse(response, RouteStatus.Attended, new HashSet <int> {
                3
            }));
        }
Beispiel #24
0
        private void setConditionsRecursive(string path, int condId, int ruleId)
        {
            if (!Directory.Exists(path))
            {
                return;
            }

            DirectoryInfo di = new DirectoryInfo(path);

            foreach (DirectoryInfo d in di.GetDirectories())
            {
                int indx = -1;
                indx = MainClass.Settings.IgnoresFolders.FindIndex(x => x.Folder == d.Name && x.IsForIde);
                if (indx < 0)
                {
                    string   relativePath = MainClass.Workspace.GetRelativePath(d.FullName);
                    FileItem fi           = project.FilesProperty.Find(x => x.SystemFilePath == relativePath);
                    if (fi == null)
                    {
                        fi = new FileItem(relativePath, false);
                        fi.ConditionValues = new List <ConditionRule>();
                        fi.IsDirectory     = true;
                        project.FilesProperty.Add(fi);
                    }


                    if (fi.ConditionValues == null)
                    {
                        fi.ConditionValues = new List <ConditionRule>();
                    }

                    ConditionRule cr = fi.ConditionValues.Find(x => x.ConditionId == condId);
                    if (ruleId != 0)
                    {
                        if (cr != null)
                        {
                            cr.RuleId = ruleId;
                        }
                        else
                        {
                            fi.ConditionValues.Add(new ConditionRule(condId, ruleId));
                        }
                    }
                    else
                    {
                        //cd.Id);
                        if (cr != null)
                        {
                            fi.ConditionValues.Remove(cr);
                        }
                    }
                    setConditionsRecursive(d.FullName, condId, ruleId);
                }
            }

            foreach (FileInfo f in di.GetFiles())
            {
                if (!MainClass.Tools.IsIgnoredExtension(f.Extension))
                {
                    int indx = -1;
                    indx = MainClass.Settings.IgnoresFiles.FindIndex(x => x.Folder == f.Name && x.IsForIde);
                    if (indx > -1)
                    {
                        continue;
                    }


                    string   relativePath = MainClass.Workspace.GetRelativePath(f.FullName);
                    FileItem fi           = project.FilesProperty.Find(x => x.SystemFilePath == relativePath);
                    if (fi == null)
                    {
                        fi = new FileItem(relativePath, false);
                        fi.ConditionValues = new List <ConditionRule>();
                        project.FilesProperty.Add(fi);
                    }

                    if (fi.ConditionValues == null)
                    {
                        fi.ConditionValues = new List <ConditionRule>();
                    }

                    ConditionRule cr = fi.ConditionValues.Find(x => x.ConditionId == condId);
                    if (ruleId != 0)
                    {
                        if (cr != null)
                        {
                            cr.RuleId = ruleId;
                        }
                        else
                        {
                            fi.ConditionValues.Add(new ConditionRule(condId, ruleId));
                        }
                    }
                    else
                    {
                        if (cr != null)
                        {
                            fi.ConditionValues.Remove(cr);
                        }
                    }
                }
            }
        }
Beispiel #25
0
 public Event(IDataContext context, IEventData e)
 {
     Context    = context;
     EventValue = e;
     Conditions = e.Conditions;
 }
Beispiel #26
0
 public async Task <int> AssignProviderEvent(int providerID, int propertyID, string value, ConditionRule conditions) =>
 await ProcessEvent(providerID, propertyID, conditions, value);
Beispiel #27
0
 public async Task <int> AssignProviderRelation(int providerID, int relationID, ConditionRule conditions) =>
 await ProcessEvent(providerID, StaticEvent.Relation, conditions, relationID.ToString());
Beispiel #28
0
 public async Task <int> AssignProviderAttribute(int providerID, int attributeID, ConditionRule conditions) =>
 await ProcessEvent(providerID, StaticEvent.Attribute, conditions, attributeID.ToString());
Beispiel #29
0
 public bool Eval(ConditionRule con)
 {
     return(con.Accept(this));
 }
Beispiel #30
0
        public bool ExecuteTask()
        {
            //MessageDialogs md =  new MessageDialogs(MessageDialogs.DialogButtonType.Cancel, "Cancel Publish.", filename, Gtk.MessageType.Question);
            Tool.Logger.LogDebugInfo("Publish no sign", null);

            /*if (MainClass.Settings.ClearConsoleBeforRuning){
             *      Tool.Logger.LogDebugInfo("CLEAR CONSOLE");
             *      MainClass.MainWindow.OutputConsole.Clear();
             * }*/

            if (MainClass.Workspace.ActualProject == null)
            {
                SetError(MainClass.Languages.Translate("no_project_selected"));
                Tool.Logger.LogDebugInfo(MainClass.Languages.Translate("no_project_selected"), null);
                return(false);
            }

            project = MainClass.Workspace.ActualProject;
            Tool.Logger.LogDebugInfo(String.Format("Project -> {0}", MainClass.Workspace.ActualProject), null);

            ShowInfo("Publish project", MainClass.Workspace.ActualProject.ProjectName);

            if (String.IsNullOrEmpty(project.ProjectOutput))
            {
                if (!String.IsNullOrEmpty(MainClass.Workspace.OutputDirectory))
                {
                    project.ProjectOutput = MainClass.Workspace.OutputDirectory;
                }
                else
                {
                    project.ProjectOutput = project.AbsolutProjectDir;
                }
                Tool.Logger.LogDebugInfo(String.Format("Project Output-> {0}", project.ProjectOutput), null);
            }

            if (!Directory.Exists(project.OutputMaskToFullPath))
            {
                try{
                    Tool.Logger.LogDebugInfo(String.Format("CREATE DIR Output-> {0}", project.OutputMaskToFullPath), null);
                    Directory.CreateDirectory(project.OutputMaskToFullPath);
                }catch
                {
                    SetError(MainClass.Languages.Translate("cannot_create_output"));
                    return(false);
                }
            }

            List <string> filesList = new List <string>();

            //project.GetAllFiles(ref filesList);
            GetAllFiles(ref filesList, project.AbsolutProjectDir);

            string tempDir = MainClass.Paths.TempPublishDir;             //System.IO.Path.Combine(MainClass.Settings.PublishDirectory,"_temp");

            Tool.Logger.LogDebugInfo(String.Format("Temp Directory-> {0}", tempDir), null);

            if (!Directory.Exists(tempDir))
            {
                try{
                    Tool.Logger.LogDebugInfo(String.Format("CREATE Temp Directory-> {0}", tempDir), null);
                    Directory.CreateDirectory(tempDir);
                } catch {
                    SetError(MainClass.Languages.Translate("cannot_create_temp_f1", tempDir));
                    return(false);
                }
            }

            if ((listCombinePublish == null) || (listCombinePublish.Count < 1))
            {
                Tool.Logger.LogDebugInfo("Publish list empty", null);
                SetError(MainClass.Languages.Translate("publish_list_is_empty"));
                return(false);
                //project.GeneratePublishCombination();
            }

            bool isAndroid = false;

            foreach (CombinePublish ccc in  listCombinePublish)
            {
                CombineCondition crPlatform = ccc.combineRule.Find(x => x.ConditionId == MainClass.Settings.Platform.Id);
                if (crPlatform != null)
                {
                    if ((crPlatform.RuleId == (int)DeviceType.Android_1_6) ||
                        (crPlatform.RuleId == (int)DeviceType.Android_2_2))
                    {
                        isAndroid = true;
                        //Console.WriteLine("ANDROID FOUND");
                        CheckJava();
                    }
                }
            }

            if (!isJavaInstaled && isAndroid)
            {
                ShowError(MainClass.Languages.Translate("java_missing"), MainClass.Languages.Translate("java_missing_title"));

                /*MessageDialogsUrl md = new MessageDialogsUrl(MessageDialogsUrl.DialogButtonType.Ok,MainClass.Languages.Translate("java_missing"), MainClass.Languages.Translate("java_missing_title"),"http://moscrif.com/java-requirement", Gtk.MessageType.Error,ParentWindow);
                 * md.ShowDialog();*/
            }

            /*if (listCombinePublish.Count > 0) {
             *
             *      double step = 1 / (listCombinePublish.Count * 1.0);
             *      MainClass.MainWindow.ProgressStart(step, MainClass.Languages.Translate("publish"));
             *      progressDialog = new ProgressDialog(MainClass.Languages.Translate("publishing"),ProgressDialog.CancelButtonType.Cancel,listCombinePublish.Count,ParentWindow);//MainClass.MainWindow
             * }*/

            foreach (CombinePublish ccc in  listCombinePublish)            //listCC ){
            //if (!ccc.IsSelected) continue;
            //Console.WriteLine(ccc.ToString());

            {
                if (stopProcess)
                {
                    break;
                }

                if (String.IsNullOrEmpty(project.ProjectArtefac))
                {
                    project.ProjectArtefac = System.IO.Path.GetFileNameWithoutExtension(project.RelativeAppFilePath);
                }
                string fileName = project.ProjectArtefac;

                List <ConditionDevice> condList = new List <ConditionDevice>();


                foreach (CombineCondition cr in ccc.combineRule)
                {
                    ConditionDevice cd = new ConditionDevice(cr.ConditionName, cr.RuleName);
                    //condList.Add(new ConditionDevice(cr.ConditionName,cr.RuleName));
                    if (cr.ConditionId == MainClass.Settings.Resolution.Id)
                    {
                        Rule rl = MainClass.Settings.Resolution.Rules.Find(x => x.Id == cr.RuleId);
                        if (rl != null)
                        {
                            cd.Height = rl.Height;
                            cd.Width  = rl.Width;
                        }
                    }
                    condList.Add(cd);

                    fileName = fileName.Replace(String.Format("$({0})", cr.ConditionName), cr.RuleName);
                }

                parentTask         = new TaskMessage("Publishing", fileName, null);
                devicePublishError = false;

                ShowInfo("Publishing", fileName);

                /*if (progressDialog != null)
                 *       progressDialog.SetLabel (fileName );*/

                if (Directory.Exists(tempDir))
                {
                    try{
                        DirectoryInfo di = new DirectoryInfo(tempDir);
                        foreach (DirectoryInfo d in di.GetDirectories())
                        {
                            d.Delete(true);
                        }
                        foreach (FileInfo f in di.GetFiles())
                        {
                            f.Delete();
                        }
                    } catch {
                    }
                }

                CombineCondition crPlatform  = ccc.combineRule.Find(x => x.ConditionId == MainClass.Settings.Platform.Id);
                CombineCondition crRsolution = ccc.combineRule.Find(x => x.ConditionId == MainClass.Settings.Resolution.Id);

                if (crPlatform == null)
                {
                    SetError(MainClass.Languages.Translate("platform_not_found", MainClass.Settings.Platform.Name), parentTask);
                    continue;
                }

                Device dvc = project.DevicesSettings.Find(x => x.TargetPlatformId == crPlatform.RuleId);

                if (dvc == null)
                {
                    SetError(MainClass.Languages.Translate("device_not_found", crPlatform.ConditionName, crPlatform.RuleName), parentTask);
                    continue;
                }

                if (((crPlatform.RuleId == (int)DeviceType.Android_1_6) ||
                     (crPlatform.RuleId == (int)DeviceType.Android_2_2)) &&
                    (!isJavaInstaled))
                {
                    SetError(MainClass.Languages.Translate("java_missing"), parentTask);
                    ShowError(MainClass.Languages.Translate("java_missing"), fileName);
                    continue;
                }

                string dirPublish = MainClass.Tools.GetPublishDirectory(dvc.Platform.Specific);                //System.IO.Path.Combine(MainClass.Settings.PublishDirectory,dvc.Platform.Specific);//crPlatform.RuleName);

                if (!Directory.Exists(dirPublish))
                {
                    SetError(MainClass.Languages.Translate("publish_tool_not_found"), parentTask);
                    continue;
                }

                if (String.IsNullOrEmpty(dirPublish))
                {
                    SetError(MainClass.Languages.Translate("publish_tool_not_found_f1"), parentTask);
                    continue;
                }

                dvc.Application = project.AppFile.Name;                 // TTT

                if (String.IsNullOrEmpty(project.ProjectOutput))
                {
                    if (!String.IsNullOrEmpty(MainClass.Workspace.OutputDirectory))
                    {
                        project.ProjectOutput = MainClass.Workspace.OutputDirectory;
                    }
                    else
                    {
                        project.ProjectOutput = project.AbsolutProjectDir;
                    }
                }

                dvc.Output_Dir = project.OutputMaskToFullPath;

                dvc.Temp = tempDir;

                dvc.Temp       = LastSeparator(dvc.Temp);
                dvc.Publish    = LastSeparator(MainClass.Settings.PublishDirectory);
                dvc.Root       = LastSeparator(MainClass.Workspace.RootDirectory);
                dvc.Output_Dir = LastSeparator(dvc.Output_Dir);

                dvc.Conditions = condList.ToArray();

                List <int> mergeResolutions = new List <int>();
                string     resolution       = crRsolution.RuleName;
                mergeResolutions.Add(crRsolution.RuleId);

                // Ak je zaskrtnute Merge All Resolution
                // Najdem vsetky publishovatelne combinacie danej platformy (napr. vsetky publishovane andrroidy)
                // a vytiahnem z nich rezolution a spojim do string odeleneho &
                if (dvc.Includes.Skin != null)
                {
                    dvc.Includes.Skin.ResolutionJson = dvc.Includes.Skin.Resolution;
                    if (!String.IsNullOrEmpty(dvc.Includes.Skin.Name))
                    {
                        if (project.IncludeAllResolution)
                        {
                            resolution = "";
                            mergeResolutions.Clear();
                            foreach (CombinePublish cp in  listCombinePublish)
                            {
                                CombineCondition crPlatform2 = cp.combineRule.Find(x => x.ConditionId == MainClass.Settings.Platform.Id && x.RuleId == crPlatform.RuleId);
                                if (crPlatform2 != null)
                                {
                                    CombineCondition crResolution2 = cp.combineRule.Find(x => x.ConditionId == MainClass.Settings.Resolution.Id);
                                    if (crResolution2 != null)
                                    {
                                        resolution = resolution + crResolution2.RuleName + "&";
                                        mergeResolutions.Add(crResolution2.RuleId);
                                    }
                                }
                            }
                            resolution = resolution.Remove(resolution.Length - 1, 1);
                            ConditionDevice cd = condList.Find(x => x.Name == MainClass.Settings.Resolution.Name);
                            if (cd != null)
                            {
                                cd.Value       = resolution;
                                dvc.Conditions = condList.ToArray();
                            }
                        }
                    }
                }

                List <string> filesForPublish = new List <string>();

                foreach (string file in filesList)
                {
                    if (System.IO.Path.GetExtension(file) == ".msc")
                    {
                        continue;
                    }

                    string fileUpdate = FileUtility.AbsoluteToRelativePath(MainClass.Workspace.RootDirectory, file);

                    if (project.FilesProperty != null)
                    {
                        // vyhldam property suborov a pozriem ci nemam nejake conditiony nastavene
                        FileItem fi = project.FilesProperty.Find(x => x.SystemFilePath == fileUpdate);
                        if (fi != null)
                        {
                            if (fi.IsExcluded)
                            {
                                continue;
                            }

                            if (fi.ConditionValues == null)                             // nema ziadne konditions tak ho pridam
                            {
                                goto nav1;
                                //continue;
                            }
                            foreach (CombineCondition cr in ccc.combineRule)
                            {
                                ConditionRule conRile = fi.ConditionValues.Find(x => x.ConditionId == cr.ConditionId);
                                if (conRile != null)
                                {
                                    //if ((conRile.RuleId != cr.RuleId)) // subor ma condition daneho typu, ale nastavenu na inu hodnotu
                                    //goto nav;

                                    int resolutionId = -1;

                                    if (conRile.ConditionId == MainClass.Settings.Resolution.Id)
                                    {
                                        resolutionId = mergeResolutions.FindIndex(x => x == conRile.RuleId);
                                        //continue;
                                    }

                                    // mam merge resolution a subor patri do niektoreho mergnuteho resolution
                                    if ((conRile.ConditionId == MainClass.Settings.Resolution.Id) && (resolutionId > -1))
                                    {
                                        goto nav1;
                                    }

                                    // subor ma condition daneho typu, ale nastavenu na inu hodnotu
                                    if ((conRile.RuleId != cr.RuleId))
                                    {
                                        string msg1 = String.Format("File {0} REMOVE {1}-> {0}", fileUpdate, conRile.RuleId);
                                        Tool.Logger.LogDebugInfo(msg1, null);
                                        Console.WriteLine(msg1);
                                        goto nav;
                                    }
                                }
                            }
                        }
                    }
nav1:
                    fileUpdate = FileUtility.AbsoluteToRelativePath(project.AbsolutProjectDir, file);
                    fileUpdate = FileUtility.TrimStartingDotCharacter(fileUpdate);
                    fileUpdate = FileUtility.TrimStartingDirectorySeparator(fileUpdate);
                    filesForPublish.Add(fileUpdate);

                    /*string msg =String.Format("Add File to Publish-> {0}",fileUpdate);
                     * Tool.Logger.LogDebugInfo(msg,null);
                     * Console.WriteLine(msg);*/

                    nav :;
                }
                dvc.Includes.Files = filesForPublish.ToArray();

                List <string> fontForPublish = new List <string>();
                foreach (string fnt in dvc.Includes.Fonts)
                {
                    string tmp = fnt;
                    tmp = tmp.Replace('/', System.IO.Path.DirectorySeparatorChar);
                    tmp = tmp.Replace('\\', System.IO.Path.DirectorySeparatorChar);

                    fontForPublish.Add(tmp);
                }
                dvc.Includes.Fonts = fontForPublish.ToArray();

                dvc.Output_Name = fileName;

                dvc.PublishPropertisFull = new List <PublishProperty>();

                foreach (PublishProperty pp in dvc.PublishPropertisMask)
                {
                    PublishProperty ppFull = new PublishProperty(pp.PublishName);
                    ppFull.PublishValue = pp.PublishValue;
                    dvc.PublishPropertisFull.Add(ppFull);

                    if (pp.PublishName == Project.KEY_PERMISSION)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_CODESIGNINGIDENTITY)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_STOREPASSWORD)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_KEYPASSWORD)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_SUPPORTEDDEVICES)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_INSTALLOCATION)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_BUNDLEIDENTIFIER)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_ALIAS)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_APPLICATIONID)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_PASSWORD)
                    {
                        continue;
                    }

                    ppFull.PublishValue = project.ConvertProjectMaskPathToFull(pp.PublishValue);
                }

                //

                /*if(dvc.Includes.Skin != null){
                 *      dvc.Includes.Skin.ResolutionJson = dvc.Includes.Skin.Resolution;
                 *      if(!String.IsNullOrEmpty(dvc.Includes.Skin.Name)){
                 *              if(project.IncludeAllResolution){
                 *                      dvc.Includes.Skin.ResolutionJson = "*";
                 *              }
                 *      }
                 * }*/
                dvc.LogDebug        = MainClass.Settings.LogPublish;
                dvc.ApplicationType = project.ApplicationType;

                dvc.FacebookAppID = project.FacebookAppID;

                if (String.IsNullOrEmpty(project.FacebookAppID))
                {
                    dvc.FacebookAppID = "";
                }

                string path = System.IO.Path.Combine(dirPublish, "settings.mso");               //fileName+".mso"); //dvc.TargetPlatform + "_settings.mso");
                string json = dvc.GenerateJson();

                if (String.IsNullOrEmpty(json))
                {
                    SetError(MainClass.Languages.Translate("cannot_generate_mso"), parentTask);
                    continue;
                }

                try {
                    using (StreamWriter file = new StreamWriter(path)) {
                        file.Write(json);
                        file.Close();
                    }
                } catch {
                    SetError(MainClass.Languages.Translate("cannot_generate_mso"), parentTask);
                    continue;
                }

                //var platformRule = MainClass.Settings.Platform.Rules.Find(x => x.Id == dvc.TargetPlatformId);

                string appFile     = dvc.Platform.Specific + ".app"; /*dvc.TargetPlatform*/          //platformRule.Specific + ".app";
                string fullAppPath = System.IO.Path.Combine(MainClass.Settings.PublishDirectory, appFile);

                if (!System.IO.File.Exists(fullAppPath))
                {
                    SetError(MainClass.Languages.Translate("publish_tool_not_found_f2"), parentTask);
                    continue;
                }

                RunPublishTool(appFile, parentTask);

                /*if (RunPublishTool(appFile,parentTask) ){
                 *      parentTask.Message =MainClass.Languages.Translate("publish_successfully_done");
                 *      output.Add(parentTask);
                 *
                 *      //output.Add(new TaskMessage(MainClass.Languages.Translate("publish_successfully_done"),dvc.Platform.Specific,null));
                 * } else {
                 *      parentTask.Message =MainClass.Languages.Translate("publish_error");
                 *      Console.WriteLine(parentTask.Child.Message);
                 *      output.Add(parentTask);
                 *      //output.Add(new TaskMessage(MainClass.Languages.Translate("publish_error"),dvc.Platform.Specific,null));
                 * }*/
                if (MainClass.Platform.IsMac)
                {
                    ExitPublish(null, null);
                }

                if (devicePublishError)
                {
                    parentTask.Message = StateEnum.ERROR.ToString();
                    allPublishError    = true;
                    ShowError(StateEnum.ERROR.ToString(), " ");
                    //ShowError(lastMessage.Trim(),fileName);
                }
                else
                {
                    parentTask.Message = StateEnum.OK.ToString();
                    ShowInfo(" ", StateEnum.OK.ToString());
                }
                //parentTask.Message = //this.StateTask.ToString();
                //Console.WriteLine(parentTask.Child.Message);
                output.Add(parentTask);

                MainClass.MainWindow.ProgressStep();

                /*if (progressDialog != null)
                 *      cancelled = progressDialog.Update (fileName );*/
            }

            MainClass.MainWindow.ProgressEnd();

            /*if(progressDialog!= null){
             *      progressDialog.Destroy();
             * }*/
            //Console.WriteLine("allPublishError -> {0}",allPublishError);
            if (allPublishError)
            {
                this.stateTask = StateEnum.ERROR;
                string s = allErrors.ToString();

                if (s.Length > 120)
                {
                    s = s.Substring(0, 120);
                    s = s + " ... and more.";
                }

                ShowError(MainClass.Languages.Translate("publish_error"), " ");
                return(false);
            }
            if (stopProcess)
            {
                this.stateTask = StateEnum.CANCEL;
                ShowInfo(MainClass.Languages.Translate("Canceled"), " ", -1);

                return(false);
            }
            else
            {
                this.stateTask = StateEnum.OK;

                ShowInfo(" ", MainClass.Languages.Translate("publish_successfully_done"), 1);

                /*if(MainClass.Settings.OpenOutputAfterPublish){
                 *      if (!String.IsNullOrEmpty(project.ProjectOutput)){
                 *              MainClass.Tools.OpenFolder(project.OutputMaskToFullPath);
                 *      }
                 * }*/
                return(true);
            }
        }