Ejemplo n.º 1
0
        public string GetParameterText()
        {
            string shortTypeName = StatusDisplay.GetShortPrimitiveTypeName(type);
            bool   displayable   = shortTypeName != type.Name;

            if (value == null)
            {
                return(shortTypeName + " " + name);
            }
            if (!displayable)
            {
                return(shortTypeName + " " + name + " [undisplayable]");
            }
            return(shortTypeName + " " + name + " [" + value + "]");
        }
Ejemplo n.º 2
0
      public bool Process(string filename)
      {
         if (filename == null)
            throw new ArgumentNullException(nameof(filename));

         string outputFilename = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
         StatusDisplay.Show("Detecting .NET and EF versions");

         if (TryParseAssembly(filename, @"Parsers\EF6ParserFmwk.exe", outputFilename) == 0 ||
             TryParseAssembly(filename, @"Parsers\EFCoreParserFmwk.exe", outputFilename) == 0 ||
             TryParseAssembly(filename, @"Parsers\EFCoreParser.exe", outputFilename) == 0)
            return DoProcessing(outputFilename);

         ErrorDisplay.Show("Error procesing assembly");
         return false;
      }
Ejemplo n.º 3
0
      private void ProcessClasses(ModelRoot modelRoot, List<ParsingModels.ModelClass> classDataList)
      {
         RemoveDuplicateBidirectionalAssociations(classDataList);

         foreach (ParsingModels.ModelClass data in classDataList)
         {
            StatusDisplay.Show($"Processing {data.FullName}");

            ModelClass element = modelRoot.Classes.FirstOrDefault(x => x.FullName == data.FullName);

            if (element == null)
            {
               element = new ModelClass(Store,
                                        new PropertyAssignment(ModelClass.NameDomainPropertyId, data.Name),
                                        new PropertyAssignment(ModelClass.NamespaceDomainPropertyId, data.Namespace),
                                        new PropertyAssignment(ModelClass.CustomAttributesDomainPropertyId, data.CustomAttributes),
                                        new PropertyAssignment(ModelClass.CustomInterfacesDomainPropertyId, data.CustomInterfaces),
                                        new PropertyAssignment(ModelClass.IsAbstractDomainPropertyId, data.IsAbstract),
                                        new PropertyAssignment(ModelClass.BaseClassDomainPropertyId, data.BaseClass),
                                        new PropertyAssignment(ModelClass.TableNameDomainPropertyId, data.TableName),
                                        new PropertyAssignment(ModelClass.IsDependentTypeDomainPropertyId, data.IsDependentType));

               modelRoot.Classes.Add(element);
            }
            else
            {
               element.Name = data.Name;
               element.Namespace = data.Namespace;
               element.CustomAttributes = data.CustomAttributes;
               element.CustomInterfaces = data.CustomInterfaces;
               element.IsAbstract = data.IsAbstract;
               element.BaseClass = data.BaseClass;
               element.TableName = data.TableName;
               element.IsDependentType = data.IsDependentType;
            }

            ProcessProperties(element, data.Properties);
         }


         // classes are all created, so we can work the associations
         foreach (ParsingModels.ModelClass data in classDataList)
         {
            ProcessUnidirectionalAssociations(data);
            ProcessBidirectionalAssociations(data);
         }
      }
Ejemplo n.º 4
0
 // 클라이언트 핸들
 public void InitClientPtr()
 {
     try
     {
         //Console.WriteLine("InitClientPtr");
         clientPtr = GlobalClientData.clientProcess.MainWindowHandle;
         //Console.WriteLine(clientPtr.ToString());
         if (clientPtr.ToInt32() == 0)
         {
             clientPtr = GlobalClientData.clientProcess.MainWindowHandle;
             //Console.WriteLine(clientPtr.ToString());
         }
     }
     catch
     {
         StatusDisplay status = new StatusDisplay("클라이언트 초기화 오류!", StatusDisplay.enumType.Warning);
     }
 }
Ejemplo n.º 5
0
        public void test5()
        {
            initQueuesTest2();
            RuntimeStatistics.addToExtractedUrls(1);
            RuntimeStatistics.addToFeedUrls(5000);
            RankFrointer rankFrontier   = new RankFrointer(feedback, serverQueues);
            Thread       frontierThread = new Thread(new ThreadStart(rankFrontier.sceduleTasks));

            frontierThread.Start();
            Thread workerThread = new Thread(new ThreadStart(workerSimulator4));

            workerThread.Start();

            while (true)
            {
                Thread.Sleep(1000);
                StatusDisplay.DisplayOnScreen(feedback, serverQueues);
            }
        }
Ejemplo n.º 6
0
        public static IEnumerable <ModelElement> HandleMultiDrop(Store store, IEnumerable <string> filenames)
        {
            List <ModelElement> newElements  = new List <ModelElement>();
            List <string>       filenameList = filenames?.ToList();

            if (store == null || filenameList == null)
            {
                return(newElements);
            }

            try
            {
                StatusDisplay.Show($"Processing {filenameList.Count} files");

                AssemblyProcessor assemblyProcessor = new AssemblyProcessor(store);
                TextFileProcessor textFileProcessor = new TextFileProcessor(store);

                try
                {
                    // may not work. Might not be a text file
                    textFileProcessor.LoadCache(filenameList);
                }
                catch
                {
                    // if not, no big deal. Either it's not a text file, or we'll just process suboptimally
                }

                foreach (string filename in filenameList)
                {
                    newElements.AddRange(Process(store, filename, assemblyProcessor, textFileProcessor));
                }
            }
            catch (Exception e)
            {
                ErrorDisplay.Show(store, e.Message);
            }
            finally
            {
                StatusDisplay.Show("Ready");
            }

            return(newElements);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Check if the program version is current.
        /// </summary>
        /// <returns>true if the program version is current.</returns>
        public static bool IsProgramUpdated()
        {
            bool updated = false;

            if (OpenConnection())
            {
                if (StatusDisplay != null)
                {
                    StatusDisplay.Info(Resources.SQLMessageVersionCheck);
                }
                String[] versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion.Split(new char[] { Resources.Period });

                using (MySqlCommand cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = MySQLCommandIsVersionCurrent;
                    cmd.Parameters.AddWithValue(MySQLParamVersionMajor, versionInfo[0]);
                    cmd.Parameters.AddWithValue(MySQLParamVersionMinor, versionInfo[1]);
                    cmd.Parameters.AddWithValue(mySqlParamVersionBuild, versionInfo[2]);
                    cmd.Parameters.AddWithValue(mySqlParamVersionRevision, versionInfo[3]);

                    try
                    {
                        using (MySqlDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                updated = true;
                                break;
                            }
                        }
                    }
                    catch (MySqlException e)
                    {
                        if (StatusDisplay != null)
                        {
                            StatusDisplay.Error(Resources.SQLMessageErrorGettingVersion);
                            StatusDisplay.Info(e.ToString());
                        }
                    }
                }
            }
            return(updated);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Download all new fish renames from the DB since a passed time.
        /// </summary>
        /// <param name="rodId">Rod ID</param>
        /// <param name="since">Time to download renames since</param>
        /// <returns>A Dictionary of <c>SQLFishie</c> to string name renamed to</returns>
        public static Dictionary <SQLFishie, string> DownloadRenamedFish(int rodId, DateTime since)
        {
            Dictionary <SQLFishie, string> fishies = new Dictionary <SQLFishie, string>();

            if (OpenConnection())
            {
                using (MySqlCommand cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = MySQLCommandGetRenamedFishSince;
                    cmd.Parameters.AddWithValue(MySQLParamRodID, rodId);
                    cmd.Parameters.AddWithValue(MySQLParamTime, since);
                    using (MySqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            string name   = string.Empty;
                            string id1    = string.Empty;
                            string id2    = string.Empty;
                            string id3    = string.Empty;
                            string toName = string.Empty;
                            try
                            {
                                name = rdr.GetString(MySQLParamFishName);
                                id1  = rdr.GetString(MySQLParamId1);
                                id2  = rdr.GetString(MySQLParamId2);
                                id3  = rdr.GetString(MySQLParamId3);
                                fishies.Add(new SQLFishie(name, rodId, id1, id2, id3, null, null), rdr.GetString(MySQLParamFishToName));
                            }
                            catch (MySqlException e)
                            {
                                if (StatusDisplay != null)
                                {
                                    StatusDisplay.Error(string.Format(Resources.SQLMessageFormatErrorGettingRenamedFishWithIDs, name, toName, id1, id2, id3));
                                    StatusDisplay.Info(e.ToString());
                                }
                            }
                        }
                    }
                }
            }
            CloseConnection();
            return(fishies);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Close an open connection
 /// </summary>
 /// <returns>True if connection was closed, false if some error happened</returns>
 internal static bool CloseConnection()
 {
     try
     {
         if (Connection.State != ConnectionState.Closed)
         {
             Connection.Close();
         }
         return(true);
     }
     catch (MySqlException e)
     {
         if (StatusDisplay != null)
         {
             StatusDisplay.Warning(Resources.SQLMessageWarningCloseConnection);
             StatusDisplay.Info(e.ToString());
         }
         return(false);
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Register a fish rename with the DB.
        /// </summary>
        /// <param name="fish">New fish name</param>
        /// <param name="oldName">Old fish name</param>
        /// <param name="rod">Rod name</param>
        /// <param name="ID1">Fish ID 1</param>
        /// <param name="ID2">Fish ID 2</param>
        /// <param name="ID3">Fish ID 3</param>
        /// <returns>True if fish was successfully renamed</returns>
        public static bool RenameFish(string fish, string oldName, string rod, string ID1, string ID2, string ID3)
        {
            if (OpenConnection())
            {
                int rodId = Dictionaries.rodDictionary[rod];
                int id1;
                int id2;
                int id3;

                int.TryParse(ID1, out id1);
                int.TryParse(ID2, out id2);
                int.TryParse(ID3, out id3);

                // Try renaming the fish
                using (MySqlCommand cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = MySQLCommandRenameFish;
                    cmd.Parameters.AddWithValue(MySQLParamFishFromName, oldName);
                    cmd.Parameters.AddWithValue(MySQLParamFishToName, fish);
                    cmd.Parameters.AddWithValue(MySQLParamRodID, rodId);
                    cmd.Parameters.AddWithValue(MySQLParamId1, id1);
                    cmd.Parameters.AddWithValue(MySQLParamId2, id2);
                    cmd.Parameters.AddWithValue(MySQLParamId3, id3);

                    try
                    {
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (MySqlException e)
                    {// Don't care
                        if (StatusDisplay != null)
                        {
                            StatusDisplay.Warning(string.Format(Resources.SQLMessageFormatErrorRenamingFish, oldName, fish));
                            StatusDisplay.Info(e.ToString());
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Open a connection to the database
        /// </summary>
        /// <returns>True if connection is open, false otherwise</returns>
        internal static bool OpenConnection()
        {
            if (Connection == null)
            {
                Initialize();
            }
            if (Connection.State == ConnectionState.Open)
            {
                return(true);
            }
            try
            {
                Connection.Open();
                return(Connection.State == ConnectionState.Open);
            }
            catch (MySqlException e)
            {
                if (!errored)
                {
                    string message;
                    switch (e.Number)
                    {
                    case 0:
                        message = Resources.SQLMessageErrorNoConnection;
                        break;

                    default:
                        message = string.Format(Resources.SQLMessageErrorCouldntConnect, e.Number);
                        break;
                    }
                    MessageBox.Show(message);
                    if (StatusDisplay != null)
                    {
                        StatusDisplay.Warning(message);
                        StatusDisplay.Info(e.ToString());
                    }
                    errored = true;
                }
                return(false);
            }
        }
Ejemplo n.º 12
0
        private static void Process(Store store, string filename, AssemblyProcessor assemblyProcessor, TextFileProcessor textFileProcessor)
        {
            try
            {
                Cursor.Current          = Cursors.WaitCursor;
                ModelRoot.BatchUpdating = true;

                if (IsAssembly(filename))
                {
                    using (Transaction tx = store.TransactionManager.BeginTransaction("Process dropped assembly"))
                    {
                        if (assemblyProcessor.Process(filename))
                        {
                            StatusDisplay.Show("Creating diagram elements. This might take a while...");
                            tx.Commit();

                            ModelDisplay.LayoutDiagram(store.ModelRoot().GetActiveDiagram() as EFModelDiagram);
                        }
                    }
                }
                else
                {
                    using (Transaction tx = store.TransactionManager.BeginTransaction("Process dropped class"))
                    {
                        if (textFileProcessor.Process(filename))
                        {
                            StatusDisplay.Show("Creating diagram elements. This might take a while...");
                            tx.Commit();
                        }
                    }
                }
            }
            finally
            {
                Cursor.Current          = Cursors.Default;
                ModelRoot.BatchUpdating = false;

                StatusDisplay.Show("");
            }
        }
Ejemplo n.º 13
0
 public void ShowStatus(StatusInfo info, StatusDisplay display)
 {
     if (_displayedStatus.TryGetValue(info.Type, out var displayed))
     {
         if (info.TurnCount <= 0)
         {
             _displayedStatus.Remove(info.Type);
             Destroy(displayed.gameObject);
         }
         else
         {
             displayed.SetData(display.statusIcon, info.TurnCount);
         }
     }
     else
     {
         var status = Instantiate(displayPrefab, content);
         status.SetData(display.statusIcon, info.TurnCount);
         _displayedStatus.Add(info.Type, status);
     }
     RefreshDisplay();
 }
Ejemplo n.º 14
0
      public bool Process(string inputFile, out List<ModelElement> newElements)
      {
         try
         {
            if (inputFile == null)
               throw new ArgumentNullException(nameof(inputFile));

            newElements = new List<ModelElement>();

            string outputFilename = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
            string logFilename = Path.ChangeExtension(outputFilename, "log");
            StatusDisplay.Show("Detecting .NET and EF versions");

            string[] parsers =
            {
               @"Parsers\EF6Parser.exe"
             , @"Parsers\EFCore2Parser.exe"
             , @"Parsers\EFCore3Parser.exe"
             , @"Parsers\EFCore5Parser.exe"
            };

            Dictionary<string,bool> contexts = new Dictionary<string, bool>();
            foreach (string parserPath in parsers)
            {
               if (TryProcess(inputFile, ref newElements, parserPath, outputFilename, logFilename, contexts))
                  return true;
            }

            foreach (string logEntry in File.ReadAllLines(logFilename))
               WarningDisplay.Show(logEntry);

            ErrorDisplay.Show(Store, $"Error processing assembly. See Output window or {logFilename} for further information");
            return false;
         }
         finally
         {
            StatusDisplay.Show("Ready");
         }
      }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (null != Session[SessionRedirectKey])
            {
                var args = Session[SessionRedirectKey] as PageVisitRefusedEventArgs;
                if (null != args)
                {
                    if (args.Reason == PageVisitRefusedReason.BlockedBySponsor ||
                        args.Reason == PageVisitRefusedReason.CantBuy ||
                        args.Reason == PageVisitRefusedReason.HardCashNoSuitablePaymentMethods ||
                        args.Reason == PageVisitRefusedReason.CartIsEmpty ||
                        args.Reason == PageVisitRefusedReason.InvalidDeliveryInfo ||
                        args.Reason == PageVisitRefusedReason.PurchasingLimitsExceeded ||
                        args.Reason == PageVisitRefusedReason.UnableToPrice)
                    {
                        if (!string.IsNullOrEmpty(args.Message))
                        {
                            StatusDisplay.AddMessage(StatusMessageType.Error, args.Message);
                        }
                        Session[SessionRedirectKey] = null;
                    }
                }
            }

            if (CantBuyCantVisitShoppingCart)
            {
                StatusDisplay.AddMessage(PlatformResources.GetGlobalResourceString("ErrorMessage", "CantOrder"));
            }

            if (CantBuyDueToTrainingInComplete)
            {
                string trainingIncomplete = string.Format("{0}<br><br>{1}",
                                                          PlatformResources.GetGlobalResourceString("ErrorMessage", "CantBuy"),
                                                          PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                                    "CantBuyBecauseofTraining"));
                StatusDisplay.AddMessage(trainingIncomplete);
            }
        }
Ejemplo n.º 16
0
    private IEnumerator SendEscapeShuttle(int seconds)
    {
        // departure countdown
        for (int i = seconds; i >= 0; i--)
        {
            CentComm.UpdateStatusDisplay(StatusDisplayChannel.EscapeShuttle, StatusDisplay.FormatTime(i, "Depart\nETA: "));
            yield return(WaitFor.Seconds(1));
        }

        shuttleSent = true;
        PrimaryEscapeShuttle.SendShuttle();

        // centcom round end countdown
        int timeToCentcom = ShuttleDepartTime * 2 - 2;

        for (int i = timeToCentcom - 1; i >= 0; i--)
        {
            CentComm.UpdateStatusDisplay(StatusDisplayChannel.EscapeShuttle, StatusDisplay.FormatTime(i, "CENTCOM\nETA: "));
            yield return(WaitFor.Seconds(1));
        }

        CentComm.UpdateStatusDisplay(StatusDisplayChannel.EscapeShuttle, string.Empty);
    }
Ejemplo n.º 17
0
        private static IEnumerable <ModelElement> Process(Store store, string filename, AssemblyProcessor assemblyProcessor, TextFileProcessor textFileProcessor)
        {
            List <ModelElement> newElements;
            Cursor prev = Cursor.Current;

            try
            {
                Cursor.Current          = Cursors.WaitCursor;
                ModelRoot.BatchUpdating = true;

                using (Transaction tx = store.TransactionManager.BeginTransaction("Process drop"))
                {
                    bool processingResult = IsAssembly(filename)
                                          ? assemblyProcessor.Process(filename, out newElements)
                                          : textFileProcessor.Process(filename, out newElements);

                    if (processingResult)
                    {
                        StatusDisplay.Show("Creating diagram elements. This might take a while...");
                        tx.Commit();
                    }
                    else
                    {
                        newElements = new List <ModelElement>();
                    }
                }
            }
            finally
            {
                Cursor.Current          = prev;
                ModelRoot.BatchUpdating = false;

                StatusDisplay.Show("Ready");
            }

            return(newElements);
        }
Ejemplo n.º 18
0
      private List<ModelElement> ProcessClasses(ModelRoot modelRoot, List<ParsingModels.ModelClass> classDataList)
      {
         List<ModelElement> result = new List<ModelElement>();
         RemoveDuplicateBidirectionalAssociations(classDataList);
         Dictionary<string, List<ModelClass>> baseClasses = new Dictionary<string, List<ModelClass>>();

         foreach (ParsingModels.ModelClass data in classDataList)
         {
            StatusDisplay.Show($"Processing {data.FullName}");

            ModelClass element = modelRoot.Classes.FirstOrDefault(x => x.FullName == data.FullName);

            if (element == null)
            {
               element = new ModelClass(Store,
                                        new PropertyAssignment(ModelClass.NameDomainPropertyId, data.Name),
                                        new PropertyAssignment(ModelClass.NamespaceDomainPropertyId, data.Namespace),
                                        new PropertyAssignment(ModelClass.CustomAttributesDomainPropertyId, data.CustomAttributes),
                                        new PropertyAssignment(ModelClass.CustomInterfacesDomainPropertyId, data.CustomInterfaces),
                                        new PropertyAssignment(ModelClass.IsAbstractDomainPropertyId, data.IsAbstract),
                                        new PropertyAssignment(ModelClass.TableNameDomainPropertyId, data.TableName),
                                        new PropertyAssignment(ModelClass.IsDependentTypeDomainPropertyId, data.IsDependentType));

               modelRoot.Classes.Add(element);
               result.Add(element);
            }
            else
            {
               element.Name = data.Name;
               element.Namespace = data.Namespace;
               element.CustomAttributes = data.CustomAttributes;
               element.CustomInterfaces = data.CustomInterfaces;
               element.IsAbstract = data.IsAbstract;
               element.TableName = data.TableName;
               element.IsDependentType = data.IsDependentType;
            }

            // if base class exists and isn't in the list yet, we can't hook it up to this class
            // so we'll defer base class linkage for all classes until we're sure they're all in the model
            if (!string.IsNullOrEmpty(data.BaseClass))
            {
               if (!baseClasses.ContainsKey(data.BaseClass))
                  baseClasses.Add(data.BaseClass, new List<ModelClass>());
               baseClasses[data.BaseClass].Add(element);
            }

            ProcessProperties(element, data.Properties);
         }

         // now we can fixup the generalization links
         foreach (string baseClassName in baseClasses.Keys)
         {
            foreach (ModelClass subClass in baseClasses[baseClassName])
            {
               ModelClass superClass = modelRoot.Classes.FirstOrDefault(s => s.Name == baseClassName);

               if (superClass == null)
               {
                  // we couldn't find the superclass, so we'll assume it's external to this assembly
                  superClass = new ModelClass(Store,
                                              new PropertyAssignment(ModelClass.NameDomainPropertyId, subClass.BaseClass),
                                              new PropertyAssignment(ModelClass.NamespaceDomainPropertyId, subClass.Namespace),
                                              new PropertyAssignment(ModelClass.GenerateCodeDomainPropertyId, false));
                  modelRoot.Classes.Add(superClass);
               }
               else
                  subClass.Superclass = superClass;

               subClass.BaseClass = baseClassName;
            }
         }

         // classes are all created, so we can work the associations
         foreach (ParsingModels.ModelClass data in classDataList)
         {
            ProcessUnidirectionalAssociations(data);
            ProcessBidirectionalAssociations(data);
         }

         return result;
      }
Ejemplo n.º 19
0
    public override string MouseOverText()
    {
        string type = StatusDisplay.GetShortPrimitiveTypeName(Type.GetType(variableType));

        return(type + " " + variableName + ";");
    }
Ejemplo n.º 20
0
        /**
         * Main method of the console application
         */
        public static void Main(String[] args)
        {
            bool toContinue = ParseArguements(args), needToRestart = false;

            if (toContinue == false)
            {
                return;
            }
            Queue <int> keepAlive = new Queue <int>();
            String      currentUser = "******", currentTask = "";

            LogDebuggerControl.getInstance().debugCategorization = false;
            LogDebuggerControl.getInstance().debugCategorizationInRanker = false;
            LogDebuggerControl.getInstance().debugRanker = false;

            while (true)
            {
                // select which task to invoke
                SelectTask(ref currentUser, ref currentTask);

                //update the WorkDetails class with the new taskId
                WorkDetails.setTaskId(currentTask);

                //Set ALL constants of the task
                SetAllConstants();

                // getting init data
                SetInitializer(currentTask);

                // init queues
                InitQueues(currentTask);

                // initing worker and frontier threads
                InvokeThreads();

                // polling to the user requests
                while (needToRestart == false)
                {
                    Thread.Sleep(_refreshRate * 1000);
                    StatusDisplay.DisplayOnScreen(_feedBackQueue, _serversQueues);
                    if (_operationMode == operationMode_t.Auto)
                    {
                        List <TaskStatus> tasks =
                            StorageSystem.StorageSystem.getInstance().getWorkDetails(currentUser, QueryOption.ActiveTasks);

                        needToRestart = true;
                        foreach (TaskStatus task in tasks)
                        {
                            if (task.getTaskID() == currentTask)
                            {
                                task.setTaskElapsedTime(task.getTaskElapsedTime() + _refreshRate);
                                StorageSystem.StorageSystem.getInstance().changeWorkDetails(task);
                                needToRestart = false;
                                continue;
                            }
                        }
                    }
                }

                // Terminate all the threads
                TerminateThreads();
                needToRestart = false;
                RuntimeStatistics.resetStatistics();
            }

            //RankerTest test = new RankerTest();
            //test.Test2();
        }
Ejemplo n.º 21
0
        public override void OnDragDrop(DiagramDragEventArgs diagramDragEventArgs)
        {
            // came from model explorer?
            ModelElement element = (diagramDragEventArgs.Data.GetData("Sawczyn.EFDesigner.EFModel.ModelClass") as ModelElement)
                                   ?? (diagramDragEventArgs.Data.GetData("Sawczyn.EFDesigner.EFModel.ModelEnum") as ModelElement);

            if (element != null)
            {
                ShapeElement newShape = AddExistingModelElement(this, element);

                if (newShape != null)
                {
                    using (Transaction t = element.Store.TransactionManager.BeginTransaction("Moving pasted shapes"))
                    {
                        if (newShape is NodeShape nodeShape)
                        {
                            nodeShape.Location = diagramDragEventArgs.MousePosition;
                        }

                        t.Commit();
                    }
                }
            }
            else
            {
                if (IsDroppingExternal)
                {
                    DisableDiagramRules();
                    Cursor prev = Cursor.Current;
                    Cursor.Current = Cursors.WaitCursor;

                    List <ModelElement> newElements = null;
                    try
                    {
                        try
                        {
                            // add to the model
                            string[] filenames;

                            if (diagramDragEventArgs.Data.GetData("Text") is string concatenatedFilenames)
                            {
                                filenames = concatenatedFilenames.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                            }
                            else if (diagramDragEventArgs.Data.GetData("FileDrop") is string[] droppedFilenames)
                            {
                                filenames = droppedFilenames;
                            }
                            else
                            {
                                ErrorDisplay.Show(Store, "Unexpected error dropping files. Please create an issue in Github.");
                                return;
                            }

                            string[] existingFiles = filenames.Where(File.Exists).ToArray();
                            newElements = FileDropHelper.HandleMultiDrop(Store, existingFiles).ToList();

                            string[] missingFiles = filenames.Except(existingFiles).ToArray();

                            if (missingFiles.Any())
                            {
                                if (missingFiles.Length > 1)
                                {
                                    missingFiles[missingFiles.Length - 1] = "and " + missingFiles[missingFiles.Length - 1];
                                }

                                ErrorDisplay.Show(Store, $"Can't find files {string.Join(", ", missingFiles)}");
                            }
                        }
                        finally
                        {
                            // TODO: how to add shapes to the current diagram without taking forever? The trick is disabling line routing, but how?
                            #region Come back to this later

                            //if (newElements != null)
                            //{
                            // add to the active diagram
                            //int elementCount = newElements.Count;
                            //List<ShapeElement> newShapes = new List<ShapeElement>();

                            //using (Transaction t = Store.TransactionManager.BeginTransaction("adding diagram elements"))
                            //{
                            //   for (int index = 0; index < elementCount; index++)
                            //   {
                            //      ModelElement newElement = newElements[index];
                            //      StatusDisplay.Show($"Adding element {index + 1} of {elementCount}");

                            //      ForceAddShape = true;
                            //      FixUpAllDiagrams.FixUp(this, newElement);
                            //      newShapes.Add(newElement.GetFirstShapeElement());
                            //      ForceAddShape = false;
                            //   }

                            //   t.Commit();
                            //}

                            //using (Transaction t = Store.TransactionManager.BeginTransaction("adding diagram links"))
                            //{
                            //   for (int index = 0; index < elementCount; index++)
                            //   {
                            //      ModelElement newElement = newElements[index];
                            //      StatusDisplay.Show($"Linking {index + 1} of {elementCount}");

                            //      // find all element links that are attached to our element where the ends are in the diagram but the link isn't already in the diagram
                            //      List<ElementLink> elementLinks = Store.GetAll<ElementLink>()
                            //                                            .Where(link => link.LinkedElements.Contains(newElement)
                            //                                                        && link.LinkedElements.All(linkedElement => DisplayedElements.Contains(linkedElement))
                            //                                                        && !DisplayedElements.Contains(link))
                            //                                            .ToList();

                            //      foreach (ElementLink elementLink in elementLinks)
                            //      {
                            //         BinaryLinkShape linkShape = CreateChildShape(elementLink) as BinaryLinkShape;
                            //         newShapes.Add(linkShape);
                            //         NestedChildShapes.Add(linkShape);

                            //         switch (elementLink)
                            //         {
                            //            case Association a:
                            //               linkShape.FromShape = a.Source.GetFirstShapeElement() as NodeShape;
                            //               linkShape.ToShape = a.Target.GetFirstShapeElement() as NodeShape;
                            //               break;
                            //            case Generalization g:
                            //               linkShape.FromShape = g.Subclass.GetFirstShapeElement() as NodeShape;
                            //               linkShape.ToShape = g.Superclass.GetFirstShapeElement() as NodeShape;
                            //               break;
                            //         }
                            //      }
                            //   }

                            //   AutoLayoutShapeElements(newShapes);
                            //   t.Commit();
                            //}
                            //}
                            #endregion

                            IsDroppingExternal = false;
                        }
                    }
                    finally
                    {
                        EnableDiagramRules();
                        Cursor.Current = prev;

                        MessageDisplay.Show(newElements == null || !newElements.Any()
                                         ? "Import dropped files: no new elements added"
                                         : BuildMessage(newElements));

                        StatusDisplay.Show("");
                    }
                }
                else
                {
                    try
                    {
                        base.OnDragDrop(diagramDragEventArgs);
                    }
                    catch (ArgumentException)
                    {
                        // ignore. byproduct of multiple diagrams
                    }
                }
            }

            StatusDisplay.Show("");
            Invalidate();

            string BuildMessage(List <ModelElement> newElements)
            {
                int           classCount    = newElements.OfType <ModelClass>().Count();
                int           propertyCount = newElements.OfType <ModelClass>().SelectMany(c => c.Attributes).Count();
                int           enumCount     = newElements.OfType <ModelEnum>().Count();
                List <string> messageParts  = new List <string>();

                if (classCount > 0)
                {
                    messageParts.Add($"{classCount} classes");
                }

                if (propertyCount > 0)
                {
                    messageParts.Add($"{propertyCount} properties");
                }

                if (enumCount > 0)
                {
                    messageParts.Add($"{enumCount} enums");
                }

                return($"Import dropped files: added {(messageParts.Count > 1 ? string.Join(", ", messageParts.Take(messageParts.Count - 1)) + " and " + messageParts.Last() : messageParts.First())}");
            }
        }
        protected FormWithStatusDisplay()
        {
            InitializeComponent();

            mainStatusDisplay = new StatusDisplay(this.toolStripProgressBar, this.toolStripStatusLabel);
        }
Ejemplo n.º 23
0
        public MainForm()
        {
            InitializeComponent();

            iptcView1.PreInit();
            exifGpsView1.PreInit();
            iptcGpsController                 = new IptcGpsController(this, this.iptcView1, this.exifGpsView1);
            this.buttonGpsViewSave.Click     += iptcGpsController.Save_Click;
            this.buttonGpsViewSaveAll.Click  += iptcGpsController.SaveToAll_Click;
            this.buttonIptcViewSave.Click    += iptcGpsController.Save_Click;
            this.buttonIptcViewSaveAll.Click += iptcGpsController.SaveToAll_Click;
            this.bindingSourceIptcGpsController.DataSource = iptcGpsController;

            renameView1.PreInit();
            renameController         = new RenameController(this, this.renameView1);
            this.buttonRename.Click += renameController.Rename_Click;
            renameController.ProcessFilesInSubdirectories = this.chkRenameSubdirs.Checked;

            pluginView1.PreInit();
            pluginController               = new PluginController(this, this.pluginView1);
            this.buttonPluginRun.Click    += this.pluginController.Execute_Click;
            this.buttonPluginRunAll.Click += this.pluginController.ExecuteForAll_Click;
            pluginController.ProcessFilesInSubdirectories = this.chkPluginSubdirs.Checked;

            exifDateView1.PreInit();
            exifDateController = new ExifDateController(this, exifDateView1);
            this.buttonExifDateViewSave.Click              += exifDateController.Save_Click;
            this.buttonExifDateViewSaveAll.Click           += exifDateController.SaveToAll_Click;
            this.bindingSourceExifDateController.DataSource = exifDateController;

            this.Icon = Resources.PTS;

            this.splitContainer1.Panel1MinSize = 100;
            this.splitContainer1.Panel2MinSize = 400;
            this.splitContainer2.Panel1MinSize = 100;
            this.splitContainer2.Panel2MinSize = 325;
            this.splitContainer3.Panel2MinSize = 100;
            this.splitContainer3.Panel1MinSize = 100;

            displayControls = new PictureDetailControlList();
            displayControls.Add(this.iptcGpsController);
            displayControls.Add(this.pictureDisplay);
            displayControls.Add(this.exifDisplay1);
            displayControls.Add(this.completeTagList1);
            displayControls.Add(this.imageDisplay1);
            displayControls.Add(this.renameController);
            displayControls.Add(this.pluginController);
            displayControls.Add(this.exifDateController);

            displayControls.RegisterEvents(this.RefreshDetailViews,
                                           this.RefreshCurrentDirectoryView,
                                           this.RefreshDirectoryTree,
                                           this.NavigateFiles,
                                           this.ListAllCheckedFiles,
                                           this.ListSelectedDirectory);

            // add the secondary status display
            this.toolStripProgressBar2         = new ToolStripProgressBar();
            this.toolStripProgressBar2.Margin  = new Padding(735, 3, 1, 3);
            this.toolStripProgressBar2.Name    = "toolStripProgressBar2";
            this.toolStripProgressBar2.Size    = new System.Drawing.Size(100, 16);
            this.toolStripProgressBar2.Visible = false;
            this.statusStrip.Items.Add(this.toolStripProgressBar2);
            secondStatusDisplay = new StatusDisplay(this.toolStripProgressBar2);
            this.pictureDisplay.SetStatusDisplay(secondStatusDisplay);

            UpdateRecentMacros();

            Default_PropertyChanged(null, new PropertyChangedEventArgs("VisibleTabs"));
            Settings.Default.PropertyChanged += new PropertyChangedEventHandler(Default_PropertyChanged);
        }
Ejemplo n.º 24
0
 void OnEnable()
 {
     instance = this;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HLConfigManager.Configurations.DOConfiguration.IsChina)
            {
                var meta = new HtmlMeta {
                    Name = "apple-itunes-app", Content = "app-id= 967364034"
                };
                Page.Header.Controls.Add(meta);
            }
            if (pnlAnnouncements != null)
            {
                if (HLConfigManager.Configurations.DOConfiguration.ShowBulletinBoard)
                {
                    pnlAnnouncements.Visible = true;
                    if (Session["showBulletinBoard"] == null)
                    {
                        Session["showBulletinBoard"] = true;
                    }
                    var annoInfo = Providers.China.CatalogProvider.GetAnnouncementInfo();
                    var str      = new StringBuilder();
                    if (annoInfo != null)
                    {
                        var countryCode = "CN";

                        var pageBase = this.Page as ProductsBase;
                        if (pageBase != null)
                        {
                            countryCode = pageBase.CountryCode;
                        }

                        var localDateTime = DateUtils.GetCurrentLocalTime(countryCode);

                        str.Append("<ul class=\"a\">");
                        str.Append("<ul>");
                        annoInfo.ForEach(a =>
                        {
                            var info = (AnnouncementInfo_V01)a;
                            if (info == null)
                            {
                                return;
                            }
                            if (info.IsUseNew == 0 && info.NewBeginDate <= localDateTime && info.NewEndDate >= localDateTime)
                            {
                                str.Append(string.Format(
                                               " <li> {0} <img id=\'newImg\' src=\'/Ordering/Images/China/new_head.gif\' /> </li> ",
                                               info.AnnouncementDesc));
                            }
                            else
                            {
                                str.Append(string.Format("<li>{0}</li>", info.AnnouncementDesc));
                            }
                        });
                        str.Append("</ul>");
                    }
                    litAnnouncementsInfo.Text = str.ToString();
                }
                else
                {
                    Session["showBulletinBoard"] = false;
                    pnlAnnouncements.Visible     = false;
                }
            }
            Master.IsleftNavMenuVisible   = false;
            Master.SetPageHeaderBySiteMap = false;

            //This needs to be figured out. ViewState is getting lost between different pages.
            if (!string.IsNullOrEmpty(Message))
            {
                ShowMessage("Error", Message);
                Message = string.Empty;
            }
            //Substitute method - use Session
            var message = Session[SessionMessageKey] as string;

            if (!string.IsNullOrEmpty(message))
            {
                //ShowMessage(string.Empty, message);
                //StatusDisplay.DisplayType = StatusDisplayType.Popup;
                Session[SessionMessageKey] = string.Empty;
                StatusDisplay.AddMessage(StatusMessageType.Error, message);
            }

            if (HLConfigManager.Configurations.DOConfiguration.ShowEOFTimer)
            {
                var now = DateUtils.GetCurrentLocalTime(Thread.CurrentThread.CurrentCulture.ToString().Substring(3));
                //var servDate = DateTime.Now;
                var eomDate   = ShoppingCartProvider.GetEOMDate(now, CultureInfo.CurrentCulture.Name.Substring(3, 2));
                var beginDate = eomDate.AddDays(-HLConfigManager.Configurations.DOConfiguration.EOMCounterDisplayDays);
                if (now >= beginDate)
                {
                    hTargetDate.Value = eomDate.ToString("yyyy MM dd HH mm ss", CultureInfo.InvariantCulture);
                    //hcurrentDate.Value = servDate.ToString("yyyy MM dd HH mm ss", CultureInfo.InvariantCulture);
                    hcurrentDate.Value = now.ToString("yyyy MM dd HH mm ss", CultureInfo.InvariantCulture);
                    counter.Visible    = true;
                }
            }

            MembershipUser <DistributorProfileModel> member = null;

            try
            {
                var memberBase = Membership.GetUser();
                member = (MembershipUser <DistributorProfileModel>)memberBase;
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format("Order.Master.cs Null member cast failed : {0} ", ex.Message));
            }

            if (member != null && member.Value != null)
            {
                var         user        = member.Value;
                SessionInfo sessionInfo = SessionInfo.GetSessionInfo(user.Id, CultureInfo.CurrentCulture.Name);
                var         page        = Page as ProductsBase;

                // Check if the page is ordering base to load the control
                if (!String.IsNullOrEmpty(sessionInfo.CustomerOrderNumber) && page != null)
                {
                    if (trCustomerOrder != null)
                    {
                        trCustomerOrder.Visible = true;
                    }
                    else
                    {
                        divCustomerOrder.Visible = true;
                    }
                    SetPageHeader(GetLocalResourceObject("CustomerOrderingHeader").ToString());
                    var customerOrderinfo =
                        LoadControl("~/Ordering/Controls/CustomerOrderInfo.ascx") as CustomerOrderInfo;
                    plCustomerOrder.Controls.Add((Control)customerOrderinfo);
                }
            }

            if (HLConfigManager.Configurations.DOConfiguration.IsResponsive && IsMobile())
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "var responsiveMode = true;", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "var responsiveMode = false;", true);
            }

            if (HLConfigManager.Configurations.DOConfiguration.AllowHAP && HttpContext.Current != null && member != null && member.Value != null)
            {
                string rawURL             = HttpContext.Current.Request.RawUrl;
                var    currentSessionInfo = SessionInfo.GetSessionInfo(member.Value.Id, CultureInfo.CurrentCulture.Name);
                if (currentSessionInfo.IsHAPMode || rawURL.Contains("HAPOrders.aspx"))
                {
                    counter.Visible = false;
                }
            }
        }
Ejemplo n.º 26
0
        public override void OnDragDrop(DiagramDragEventArgs diagramDragEventArgs)
        {
            // came from model explorer?
            ModelElement element = (diagramDragEventArgs.Data.GetData("Sawczyn.EFDesigner.EFModel.ModelClass") as ModelElement)
                                   ?? (diagramDragEventArgs.Data.GetData("Sawczyn.EFDesigner.EFModel.ModelEnum") as ModelElement);

            if (element != null)
            {
                ShapeElement newShape = AddExistingModelElement(this, element);

                if (newShape != null)
                {
                    using (Transaction t = element.Store.TransactionManager.BeginTransaction("Moving pasted shapes"))
                    {
                        if (newShape is NodeShape nodeShape)
                        {
                            nodeShape.Location = diagramDragEventArgs.MousePosition;
                        }

                        t.Commit();
                    }
                }
            }
            else
            {
                if (IsDroppingExternal)
                {
                    DisableDiagramRules();
                    Cursor prev = Cursor.Current;
                    Cursor.Current = Cursors.WaitCursor;

                    List <ModelElement> newElements = null;

                    try
                    {
                        try
                        {
                            // add to the model
                            string[] filenames;

                            if (diagramDragEventArgs.Data.GetData("Text") is string concatenatedFilenames)
                            {
                                filenames = concatenatedFilenames.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                            }
                            else if (diagramDragEventArgs.Data.GetData("FileDrop") is string[] droppedFilenames)
                            {
                                filenames = droppedFilenames;
                            }
                            else
                            {
                                ErrorDisplay.Show(Store, "Unexpected error dropping files. Please create an issue in Github.");

                                return;
                            }

                            string[] existingFiles = filenames.Where(File.Exists).ToArray();
                            newElements = FileDropHelper.HandleMultiDrop(Store, existingFiles).ToList();

                            string[] missingFiles = filenames.Except(existingFiles).ToArray();

                            if (missingFiles.Any())
                            {
                                if (missingFiles.Length > 1)
                                {
                                    missingFiles[missingFiles.Length - 1] = "and " + missingFiles[missingFiles.Length - 1];
                                }

                                ErrorDisplay.Show(Store, $"Can't find files {string.Join(", ", missingFiles)}");
                            }
                        }
                        finally
                        {
                            if (newElements?.Count > 0)
                            {
                                string message = $"Created {newElements.Count} new elements that have been added to the Model Explorer. "
                                                 + $"Do you want these added to the current diagram as well? It could take a while.";

                                if (BooleanQuestionDisplay.Show(Store, message) == true)
                                {
                                    AddElementsToActiveDiagram(newElements);
                                }
                            }

                            //string message = $"{newElements.Count} have been added to the Model Explorer. You can add them to this or any other diagram by dragging them from the Model Explorer and dropping them onto the design surface.";
                            //MessageDisplay.Show(message);

                            IsDroppingExternal = false;
                        }
                    }
                    finally
                    {
                        EnableDiagramRules();
                        Cursor.Current = prev;

                        MessageDisplay.Show(newElements == null || !newElements.Any()
                                         ? "Import dropped files: no new elements added"
                                         : BuildMessage(newElements));

                        StatusDisplay.Show("Ready");
                    }
                }
                else
                {
                    try
                    {
                        base.OnDragDrop(diagramDragEventArgs);
                    }
                    catch (ArgumentException)
                    {
                        // ignore. byproduct of multiple diagrams
                    }
                }
            }

            StatusDisplay.Show("Ready");
            Invalidate();

            string BuildMessage(List <ModelElement> newElements)
            {
                int           classCount    = newElements.OfType <ModelClass>().Count();
                int           propertyCount = newElements.OfType <ModelClass>().SelectMany(c => c.Attributes).Count();
                int           enumCount     = newElements.OfType <ModelEnum>().Count();
                List <string> messageParts  = new List <string>();

                if (classCount > 0)
                {
                    messageParts.Add($"{classCount} classes");
                }

                if (propertyCount > 0)
                {
                    messageParts.Add($"{propertyCount} properties");
                }

                if (enumCount > 0)
                {
                    messageParts.Add($"{enumCount} enums");
                }

                return($"Import dropped files: added {(messageParts.Count > 1 ? string.Join(", ", messageParts.Take(messageParts.Count - 1)) + " and " + messageParts.Last() : messageParts.First())}");
            }
        }
        /// <summary>
        /// Pumps all valves to either "10mB - 3 seconds" or "10mb" at once. This procedure roughly matches the original procedure of "pump to 30mB then evacuate for 5 seconds".
        /// </summary>
        public override Exception PrepareSimulatorForPressureMapping(CalibrationTypes type, IProgress <GenericSimulationProgress> progress = null)
        {
            if (bSimulatorIsInUse)
            {
                return new SimulatorExceptions.DeviceBusyException()
                       {
                           DeviceId = this.DeviceId
                       }
            }
            ;

            StatusDisplay.SetProgressBarValue(0);
            StatusDisplay.SetTextToStatus(SimulatorInterfaces.SimulatorStati.Inflate);
            Application.DoEvents();

            myPressureLevels = myPressureLevels.Select(v => v = 0).ToArray(); //invalidate the pressure levels
            Exception ex = null;

            this.bIsCurrentlyPreparingForAPressureMapping = true;

            if (type == CalibrationTypes.Liegesimulator)
            {
                //pump all valves to 10mB
                ex = PumpValve(255, 10, progress);

                StatusDisplay.SetTextToStatus(SimulatorInterfaces.SimulatorStati.Evacuate);

                if (!isDebugMode && ex == null)
                {
                    ex = EvacuateValveByTime(255, 18000, 0, progress); //we dont need to evacuate for 12*3 seconds here, as evacuating all tubes at once is a lot faster
                }
            }
            else if (type == CalibrationTypes.ErgonometerNL || type == CalibrationTypes.Liegesimulator2_0)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();

                //pump all valves to 10mB
                int baseValue = Liegesimulator2_0ProfileElements.EVACUATE_PRESSURE_BASE_VALUE; //the base value for evacuation is also the calibration value (10mb)
                ex = PumpValve(255, baseValue, progress);

                sw.Stop();

                if (ex == null && sw.Elapsed.TotalSeconds < 6) //start another cycle to make sure the target pressure is actually applied
                {
                    Logger.AddLogEntry(Logger.LogEntryCategories.Debug, "PrepareSimulatorForPressureMapping() took less than 6 seconds. Starting another cycle...", null, "CSerialSimulator");
                    ex = PumpValve(255, 10, progress);
                }
            }

            iCountMeasurements = 0;
            bSimulatorIsInUse  = this.bIsCurrentlyPreparingForAPressureMapping = false;

            if (ex != null)
            {
                StatusDisplay.SetTextToStatus(SimulatorInterfaces.SimulatorStati.NotReady);
                StatusDisplay.SetProgressBarValue(0);
                this.IsPreparedForPressureMapping = false;
                return(ex);
            }
            else
            {
                StatusDisplay.SetTextToStatus(SimulatorInterfaces.SimulatorStati.PreparedForMapping);
                StatusDisplay.SetProgressBarValue(100);
                this.IsPreparedForPressureMapping = true;
                this.OnPreparedForPressureMappingOccured(this);
            }

            return(null);
        }
 protected override void DeviceError(CBaseSimulator sender, Exception exception)
 {
     //  if (CAppConfig.ShowAllErrorMessages)
     StatusDisplay.SetTextToStatus(SimulatorInterfaces.SimulatorStati.Ready);
     OnErrorOccured(new Exception("Error for device with id: " + this.DeviceId, exception));
 }
Ejemplo n.º 29
0
      private List<ModelElement> ProcessClasses(ModelRoot modelRoot, List<ParsingModels.ModelClass> classDataList)
      {
         List<ModelElement> result = new List<ModelElement>();
         RemoveDuplicateBidirectionalAssociations(classDataList);
         Dictionary<string, List<ModelClass>> baseClasses = new Dictionary<string, List<ModelClass>>();

         // on the odd chance that a generic class passed through the parser, make sure we're not adding that to the model, since EF doesn't support that
         foreach (ParsingModels.ModelClass data in classDataList.Where(x => !x.FullName.Contains("<")))
         {
            StatusDisplay.Show($"Processing {data.FullName}");

            ModelClass element = modelRoot.Classes.FirstOrDefault(x => x.FullName == data.FullName);

            if (element == null)
            {
               element = new ModelClass(Store,
                                        new PropertyAssignment(ModelClass.NameDomainPropertyId, data.Name),
                                        new PropertyAssignment(ModelClass.NamespaceDomainPropertyId, data.Namespace),
                                        new PropertyAssignment(ModelClass.CustomAttributesDomainPropertyId, data.CustomAttributes),
                                        new PropertyAssignment(ModelClass.CustomInterfacesDomainPropertyId, data.CustomInterfaces),
                                        new PropertyAssignment(ModelClass.IsAbstractDomainPropertyId, data.IsAbstract),
                                        new PropertyAssignment(ModelClass.TableNameDomainPropertyId, data.TableName),
                                        new PropertyAssignment(ModelClass.IsDependentTypeDomainPropertyId, data.IsDependentType));

               modelRoot.Classes.Add(element);
               result.Add(element);
            }
            else
            {
               element.Name = data.Name;
               element.Namespace = data.Namespace;
               element.CustomAttributes = data.CustomAttributes;
               element.CustomInterfaces = data.CustomInterfaces;
               element.IsAbstract = data.IsAbstract;
               element.TableName = data.TableName;
               element.IsDependentType = data.IsDependentType;
            }

            // if base class exists and isn't in the list yet, we can't hook it up to this class
            // so we'll defer base class linkage for all classes until we're sure they're all in the model.
            // Note that we don't support generic base classes or System.Object, so we'll tell the user that they'll have to add that to the partial
            if (!string.IsNullOrEmpty(data.BaseClass) && data.BaseClass != "System.Object")
            {
               if (data.BaseClass.Contains("<"))
               {
                  string message = $"Found base class {data.BaseClass} for {element.FullName}. The designer doesn't support generic base classes. You will have to manually add this to a partial class for {element.FullName}.";
                  MessageDisplay.Show(message);
               }
               else
               {
                  if (!baseClasses.ContainsKey(data.BaseClass))
                     baseClasses.Add(data.BaseClass, new List<ModelClass>());

                  baseClasses[data.BaseClass].Add(element);
               }
            }

            ProcessProperties(element, data.Properties);
         }

         // now we can fixup the generalization links
         foreach (string baseClassKey in baseClasses.Keys.Where(x => x != "System.Object"))
         {
            string baseClassName = baseClassKey.StartsWith("global::") ? baseClassKey.Substring(8) : baseClassKey;

            foreach (ModelClass subClass in baseClasses[baseClassKey])
            {
               ModelClass superClass = modelRoot.Classes.FirstOrDefault(s => s.Name == baseClassName);

               if (superClass != null)
                  GeneralizationBuilder.Connect(subClass, superClass);
               else
               {
                  string message = $"Found base class {baseClassName} for {subClass.FullName}, but it's not a persistent entity. You will have to manually add this to a partial class for {subClass.FullName}.";
                  MessageDisplay.Show(message);
               }
            }
         }

         // classes are all created, so we can work the associations
         List<string> allModelClassNames = modelRoot.Classes.Select(c => c.FullName).ToList();

         foreach (ParsingModels.ModelClass data in classDataList.Where(cd => allModelClassNames.Contains(cd.FullName)))
         {
            ProcessUnidirectionalAssociations(data);
            ProcessBidirectionalAssociations(data);
         }

         return result;
      }
Ejemplo n.º 30
0
 protected virtual void Start()
 {
     statusDisplay = GameManager.instance.statusDisplay;
 }