コード例 #1
0
        public void Create()
        {
            Name = Name.Replace(".", "_");

            List <PropertyData> listOfPropertyData_Code   = new List <PropertyData>();
            List <PropertyData> listOfPropertyData_Name   = new List <PropertyData>();
            List <PropertyData> listOfPropertyData_Others = new List <PropertyData>();

            foreach (PropertyData propertyData in ListOfProperties)
            {
                if (propertyData.Name.Equals("code"))
                {
                    listOfPropertyData_Code.Add(propertyData);
                }
                else if (propertyData.Name.Equals("name"))
                {
                    listOfPropertyData_Name.Add(propertyData);
                }
                else
                {
                    listOfPropertyData_Others.Add(propertyData);
                }
            }

            ListOfProperties = new List <PropertyData>();
            ListOfProperties.AddRange(listOfPropertyData_Code);
            ListOfProperties.AddRange(listOfPropertyData_Name);
            ListOfProperties.AddRange(listOfPropertyData_Others);


            ListOfGroups = new Dictionary <string, GroupData>();

            ListOfGroupsReport     = new Dictionary <string, GroupData>();
            ListOfPropertiesReport = new List <PropertyData>();

            GroupData rootGroupData = new GroupData("default");

            rootGroupData.Root      = true;
            rootGroupData.ClassData = this;
            rootGroupData.Report    = false;
            ListOfGroups.Add("default", rootGroupData);

            GroupData rootReportGroupData = new GroupData("default");

            rootReportGroupData.Root      = true;
            rootReportGroupData.ClassData = this;
            rootReportGroupData.Report    = true;


            string sel = "";
            List <PropertyData> listOfDates = new List <PropertyData>();

            foreach (PropertyData propertyData in ListOfProperties)
            {
                if (propertyData.Typage.Equals("date") || propertyData.Typage.Equals("datetime") || propertyData.Typage.Equals("time"))
                {
                    listOfDates.Add(propertyData);
                    ListOfPropertiesReport.Add(propertyData);
                }
            }

            if (listOfDates.Count > 0)
            {
                sel += "('date', 'Date'),";
            }

            if (!sel.Equals(""))
            {
                PropertyData property = new PropertyData();
                property.Name   = "filtrerpar";
                property.Alias  = "Filtrer par";
                property.Typage = "selection";

                sel = sel.Substring(0, sel.Length - 1);
                property.Selection = "[" + sel + "]";


                PageData pageFilter = new PageData("Filtres");
                pageFilter.ListOfGroups["default"]           = new GroupData("default");
                pageFilter.ListOfGroups["default"].ClassData = this;
                pageFilter.ListOfGroups["default"].ListOfProperties.Add(property);
                ListOfPropertiesReport.Add(property);

                if (listOfDates.Count > 0)
                {
                    pageFilter.ListOfGroups["default"].ListOfGroups.Add("dates", new GroupData("Dates", this));
                    pageFilter.ListOfGroups["default"].ListOfGroups["dates"].ListOfProperties = listOfDates;
                }

                rootReportGroupData.ListOfPages.Add("filter", pageFilter);
            }


            rootReportGroupData.ListOfPages.Add("avances", new PageData("Avancés"));
            rootReportGroupData.ListOfPages.Add("options", new PageData("Options"));

            ListOfGroupsReport.Add("default", rootReportGroupData);

            foreach (PropertyData propertyData in ListOfProperties)
            {
                bool dontthread = false;

                if (!propertyData.Name.Equals(Name + "_id"))
                {
                    propertyData.Update();


                    if ((propertyData.Name.Equals("state")) && (propertyData.Typage.Equals("selection")))
                    {
                        dontthread    = true;
                        StateWorkflow = true;
                        StateProperty = propertyData;

                        propertyData.Readonly = "1";
                        propertyData.Select   = "1";

                        ListOfWorkFlowButton   = new Dictionary <string, ButtonData>();
                        ListOfWorkFlowFunction = new Dictionary <string, OperationData>();
                        foreach (KeyValuePair <string, string> KeyValue in propertyData.SelectionData.ListOfValues)
                        {
                            OperationData operationData = GetOperation(propertyData.TypageInitial, KeyValue.Key);

                            if (operationData != null)
                            {
                                ButtonData buttonData = new ButtonData();
                                buttonData.States = KeyValue.Key;

                                if (operationData.CallBy.Equals("button"))
                                {
                                    buttonData.Text = KeyValue.Value;
                                    buttonData.Name = operationData.Name;
                                }
                                else if (operationData.CallBy.Equals(""))
                                {
                                    buttonData.RenderXML = false;
                                    ListOfWorkFlowFunction.Add(KeyValue.Key, operationData);

                                    operationData.ReturnType = "boolean";
                                }

                                ListOfWorkFlowButton.Add(KeyValue.Key, buttonData);
                            }
                        }
                    }
                    else if (propertyData.Name.Equals("name"))
                    {
                        //
                    }
                    else if (propertyData.Name.Equals("code"))
                    {
                        if (!Code.Equals(""))
                        {
                            CodeProperty      = propertyData;
                            propertyData.Uniq = true;
                        }
                    }
                    else if (propertyData.Name.Equals("sequence"))
                    {
                        //
                    }
                    else if (propertyData.Name.Equals("parent_id"))
                    {
                        //
                    }



                    if (!dontthread)
                    {
                        if (propertyData.Typage.Equals("text"))
                        {
                            if (propertyData.Group.Equals("") && propertyData.Page.Equals(""))
                            {
                                propertyData.Page      = propertyData.Alias;
                                propertyData.ColSpan   = "6";
                                propertyData.ShowLabel = false;
                            }
                        }
                        else if (propertyData.Typage.Equals("selection") || (propertyData.LinkData != null))
                        {
                            ListOfGroupsReport["default"].ListOfProperties.Add(propertyData);
                            ListOfPropertiesReport.Add(propertyData);
                        }


                        if (propertyData.Group.Equals(string.Empty) && propertyData.Page.Equals(string.Empty))
                        {
                            ListOfGroups["default"].ListOfProperties.Add(propertyData);
                        }
                        else if (!propertyData.Group.Equals(string.Empty) && propertyData.Page.Equals(string.Empty))
                        {
                            if (!ListOfGroups["default"].ListOfGroups.ContainsKey(propertyData.Group))
                            {
                                ListOfGroups["default"].ListOfGroups.Add(propertyData.Group, new GroupData(propertyData.Group, this));
                            }

                            ListOfGroups["default"].ListOfGroups[propertyData.Group].ListOfProperties.Add(propertyData);
                        }
                        else if (propertyData.Group.Equals(string.Empty) && !propertyData.Page.Equals(string.Empty))
                        {
                            if (!ListOfGroups["default"].ListOfPages.ContainsKey(propertyData.Page))
                            {
                                ListOfGroups["default"].ListOfPages.Add(propertyData.Page, new PageData(propertyData.Page));
                                ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups.Add("default", new GroupData("default", this));
                            }

                            ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups["default"].ListOfProperties.Add(propertyData);
                        }
                        else if (!propertyData.Group.Equals(string.Empty) && !propertyData.Page.Equals(string.Empty))
                        {
                            if (!ListOfGroups["default"].ListOfPages.ContainsKey(propertyData.Page))
                            {
                                ListOfGroups["default"].ListOfPages.Add(propertyData.Page, new PageData(propertyData.Page));
                                ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups.Add("default", new GroupData("default", this));
                            }

                            if (!ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups.ContainsKey(propertyData.Group))
                            {
                                ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups.Add(propertyData.Group, new GroupData(propertyData.Group, this));
                            }

                            ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups[propertyData.Group].ListOfProperties.Add(propertyData);
                        }
                    }
                    else
                    {
                        if (propertyData.Typage.Equals("selection") || (propertyData.LinkData != null))
                        {
                            ListOfGroupsReport["default"].ListOfProperties.Add(propertyData);
                            ListOfPropertiesReport.Add(propertyData);
                        }
                    }
                }
            }

            foreach (PropertyData propertyData in ListOfProperties)
            {
                if (propertyData.Typage.Equals("one2many"))
                {
                    foreach (PropertyData property in ListOfProperties)
                    {
                        if (!propertyData.Equals(property))
                        {
                            if (!property.ShareTo.Equals(""))
                            {
                                string[] shareto = property.ShareTo.Split(new char[] { '.' });

                                string clssppt = Parent.ClassicName + "." + shareto[0];

                                if (clssppt.Equals(propertyData.LinkManyClass))
                                {
                                    ClassData clssData = Parent.GetClass(propertyData.LinkManyClass.Split(new char[] { '.' })[1]);

                                    PropertyData propData = clssData.GetProperty(shareto[1]);

                                    propData.MaxUse = Name + "." + propData.Name;
                                }
                            }
                        }
                    }
                }
            }

            Dictionary <string, PageData> ListOfPages  = new Dictionary <string, PageData>();
            Dictionary <string, PageData> ListOfPages2 = new Dictionary <string, PageData>();

            foreach (KeyValuePair <string, PageData> pageData in ListOfGroups["default"].ListOfPages)
            {
                if ((pageData.Value.ListOfGroups != null) && (pageData.Value.ListOfGroups.Count > 0) &&
                    (pageData.Value.ListOfGroups.ContainsKey("default")) && (pageData.Value.ListOfGroups["default"].ListOfProperties != null) &&
                    (pageData.Value.ListOfGroups["default"].ListOfProperties.Count > 0) && (pageData.Value.ListOfGroups["default"].ListOfProperties[0].Typage.Equals("text")))
                {
                    ListOfPages2.Add(pageData.Value.Label, pageData.Value);
                }
                else
                {
                    ListOfPages.Add(pageData.Value.Label, pageData.Value);
                }
            }

            foreach (KeyValuePair <string, PageData> pageData in ListOfPages2)
            {
                ListOfPages.Add(pageData.Value.Label, pageData.Value);
            }

            ListOfGroups["default"].ListOfPages = ListOfPages;

            ListOfButton = new List <ButtonData>();
            foreach (KeyValuePair <string, OperationData> operationDataKV in ListOfOperations)
            {
                OperationData operationData = operationDataKV.Value;

                if ((operationData.CallBy.Equals("button")) && (operationData.State.Equals("")))
                {
                    ButtonData buttonData = new ButtonData(operationData);

                    ListOfButton.Add(buttonData);
                }
                else if ((operationData.CallBy.Equals("button")) && (!operationData.State.Equals("")))
                {
                    FunctionModel pythonCode = Utils.GetFunctionModel("function_caller_action_wkf", FunctionUsage.Classic);

                    string[] states = operationData.State.Split(new char[] { '.' });

                    string state = states[1].Trim(); //GetNextState(states[1].Trim());

                    if (!state.Equals(""))
                    {
                        /*Dictionary<string, string> pythonCode_values = new Dictionary<string, string>();
                         * pythonCode_values["function_name"] = operationData.Name;
                         * pythonCode_values["action_wkf"] = "action_" + state + "_wkf";
                         *
                         * pythonCode.Content = Utils.replaceValues(pythonCode.Content, pythonCode_values) + "\r\n\t";*/

                        pythonCode.ReplaceValues(operationData.Name, "action_" + state + "_wkf");

                        operationData.PythonCode = pythonCode.Content;
                    }
                }
                else if (!operationData.CallBy.Equals("button") && !operationData.CallBy.Equals(""))
                {
                    PropertyData propertyData = GetProperty(operationData.CallBy);

                    string param = "";
                    foreach (ParameterData parameterData in operationData.ListOfParameter)
                    {
                        param += parameterData.Name + ", ";
                    }

                    if (!param.Equals(""))
                    {
                        param = param.Substring(0, param.Length - 2);
                    }

                    propertyData.OnChange = operationData.Name + "(" + param + ")";
                }
            }

            ListOfGroups["default"].ListOfButtons = ListOfButton;

            PyGenerator.CreateClass(this);
            PyGenerator.CreateReportModel(this);
            PyGenerator.CreateReportWizardModel(this);

            XmlGenerator.CreateView(this);
            XmlGenerator.CreateReportView(this);
            XmlGenerator.CreateWizardReportView(this, MenuRapport);

            if (CodeProperty != null)
            {
                XmlGenerator.CreateDatas(this);
            }

            if (StateWorkflow)
            {
                XmlGenerator.CreateWorkFlow(this);
            }

            XslGenerator.CreateReport(this);
        }