private void CreateInstance()
        {
            if (CreatedHandler == null)
            {
                return;
            }

            InstanceLocation location;

            if (_isFolderLocation)
            {
                location = _selectedFolder;
            }
            else
            {
                location = new InstancePath {
                    Path = _instancePath
                };
            }

            var instance = new LocalInstance()
            {
                Name = _name, Version = _selectedVersion, InstanceLocation = location
            };
            var args = new CreateInstanceArgs()
            {
                Instance = instance
            };

            CreatedHandler(this, args);
        }
 public BuildDatabase()
 {
     local   = new LocalInstance();
     process = new Process();
     process.StartInfo.RedirectStandardOutput = true;
     process.StartInfo.UseShellExecute        = false;
 }
 public void AssertRemote()
 {
     if (LocalInstance != null)
     {
         throw new InvalidOperationException("Object " + LocalInstance.GetType().Name + " is not remote");
     }
 }
        public LocalInstanceMaintenanceService(LocalInstance l)
        {
            StabilizeIdleTimeMs = 3000;
            StabilizeSuccessorCacheIdleTimeMs = 3000;
            FixFingersIdleTimeMs = 3000;

            // initally stopped
            Status = MaintenanceStatus.Stopped;

            RunningTasks = new List<Task>();
            LocalInstance = l;
            TaskFactory = new TaskFactory(TaskCreationOptions.LongRunning | TaskCreationOptions.AttachedToParent, TaskContinuationOptions.None);
        }
        public void Database_Open(string connectionString, string databaseName)
        {
            using (new Hourglass())
            {
                var oldHandler = Handler;

                try
                {
                    Handler = new TabularModelHandler(connectionString, databaseName);

                    if (Handler.IsPbiDesktop)
                    {
                        if (Preferences.Current.AllowUnsupportedPBIFeatures)
                        {
                            MessageBox.Show("Experimental Power BI features is enabled. You can edit any object and property of this Power BI Desktop model, but be aware that many types of changes ARE NOT CURRENTLY SUPPORTED by Microsoft.\n\nKeep a backup of your .pbix file and proceed at your own risk.", "Power BI Desktop Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else if (Handler.PowerBIGovernance.GovernanceMode == TOMWrapper.PowerBI.PowerBIGovernanceMode.ReadOnly)
                        {
                            MessageBox.Show("Editing a Power BI Desktop model that does not use the Enhanced Model Metadata (V3) format is not allowed, unless you enable Experimental Power BI Features under File > Preferences.\n\nTabular Editor will still load the model in read-only mode.", "Power BI Desktop Model Read-only", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }

                    File_Current   = null;
                    File_Directory = null;
                    File_SaveMode  = ModelSourceType.Database;
                    if (Handler.IsPbiDesktop && ConnectForm.LocalInstance == null)
                    {
                        LocalInstance = PowerBIHelper.Instances.FirstOrDefault(i => i.Port.ToString() == Handler.Database.Server.ConnectionInfo.Port);
                    }
                    else
                    {
                        LocalInstance = ConnectForm.LocalInstance;
                    }
                    LoadTabularModelToUI();

                    Handler.OnExternalChange += Handler_OnExternalChange;
                    if (oldHandler != null)
                    {
                        oldHandler.OnExternalChange -= Handler_OnExternalChange;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error connecting to database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Handler = oldHandler;
                    LoadTabularModelToUI();
                }
            }
        }
Beispiel #6
0
    internal void AddLocalInstanceArray(int off, int len, XType ltype)
    {
        CCValues.AddTypeLayout(ltype);
        LocalInstance li;

        if (!instances.TryGetValue(off, out li))
        {
            instances[off] = new LocalInstance(len, ltype);
            return;
        }
        if (len != li.len)
        {
            throw new Exception("length mismatch for local instance array");
        }
    }
Beispiel #7
0
        public ValueTask <Type> GetObjectTypeAsync(CancellationToken cancellation)
        {
            if (!IsRemoteProxy)
            {
                return(new ValueTask <Type>(LocalInstance.GetType()));
            }

            if (Volatile.Read(ref _isActivated))
            {
                return(new ValueTask <Type>(_objectType));
            }

            var objectTypeTaskCompletionSource = GetObjectTypeTaskCompletionSource();

            var task = objectTypeTaskCompletionSource.Task.WithCancellation(cancellation);

            return(new ValueTask <Type>(task));
        }
Beispiel #8
0
        private void ConnectForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.Cancel)
            {
                return;
            }

            using (new Hourglass())
            {
                ConnectionString = connectPage.GetConnectionString();
                Server           = connectPage.GetServer();
                LocalInstance    = connectPage.LocalInstance;
                if (Server == null)
                {
                    e.Cancel = true;
                }
            }
        }
Beispiel #9
0
 internal void Merge(GOpFrame frame)
 {
     foreach (var kvp in frame.variables)
     {
         int           off = kvp.Key;
         LocalVariable lv  = kvp.Value;
         if (!variables.ContainsKey(off))
         {
             variables[off] = lv;
         }
     }
     foreach (var kvp in frame.instances)
     {
         int           off = kvp.Key;
         LocalInstance li  = kvp.Value;
         if (!instances.ContainsKey(off))
         {
             instances[off] = li;
         }
     }
 }
Beispiel #10
0
 internal bool CanMerge(GOpFrame frame)
 {
     foreach (var kvp in frame.variables)
     {
         int           off = kvp.Key;
         LocalVariable lv2 = kvp.Value;
         LocalVariable lv1;
         if (!variables.TryGetValue(off, out lv1))
         {
             continue;
         }
         if (lv1.ltype.IsRestricted || lv2.ltype.IsRestricted)
         {
             if (lv1.ltype != lv2.ltype)
             {
                 return(false);
             }
         }
         if (lv1.len != lv2.len)
         {
             return(false);
         }
     }
     foreach (var kvp in frame.instances)
     {
         int           off = kvp.Key;
         LocalInstance li2 = kvp.Value;
         LocalInstance li1;
         if (!instances.TryGetValue(off, out li1))
         {
             continue;
         }
         if (li1.ltype != li2.ltype)
         {
             return(false);
         }
     }
     return(true);
 }
        private void CreateInstance()
        {
            if (CreatedHandler == null)
                return;

            InstanceLocation location;
            if (_isFolderLocation)
            {
                location = _selectedFolder;
            }
            else
            {
                location = new InstancePath { Path = _instancePath };
            }
                
            var instance = new LocalInstance() { Name = _name, Version = _selectedVersion, InstanceLocation = location };
            var args = new CreateInstanceArgs() { Instance = instance };
            CreatedHandler(this, args);
        }
 public BuildInstance()
 {
     local = new LocalInstance();
 }
Beispiel #13
0
    internal void PrintLayout(TextWriter tw)
    {
        tw.WriteLine();
        tw.WriteLine("struct t1f_{0} {{ /* {1} */",
                     gf.Serial, Compiler.Encode(gf.fi.DebugName));
        Compiler.Indent(tw, 1);
        tw.WriteLine("void *t1g_header;");

        /*
         * Variables with restricted types; we output them in
         * decreasing sizes, so that optimal packing is applied.
         */
        for (int k = 6; k >= 3; k--)
        {
            foreach (var kvp in variables)
            {
                int           off = kvp.Key;
                LocalVariable lv  = kvp.Value;
                if (!lv.ltype.IsRestricted)
                {
                    continue;
                }
                if (BITSIZE[lv.ltype] != (1 << k))
                {
                    continue;
                }
                Compiler.Indent(tw, 1);
                tw.Write("{0} t1g_r_{1}",
                         Compiler.RestrictedCType(lv.ltype),
                         off);
                if (lv.len > 0)
                {
                    tw.Write("[{0}]", lv.len);
                }
                tw.WriteLine(";");
            }
        }

        /*
         * Variables with reference types.
         */
        foreach (var kvp in variables)
        {
            int           off = kvp.Key;
            LocalVariable lv  = kvp.Value;
            if (lv.ltype.IsRestricted)
            {
                continue;
            }
            Compiler.Indent(tw, 1);
            tw.Write("void *t1g_p_{0}", off);
            if (lv.len > 0)
            {
                tw.Write("[{0}]", lv.len);
            }
            tw.WriteLine(";");
        }

        /*
         * Local instances.
         */
        foreach (var kvp in instances)
        {
            int           off = kvp.Key;
            LocalInstance li  = kvp.Value;
            Compiler.Indent(tw, 1);
            tw.Write("struct t1s_{0} t1g_i_{1}",
                     Compiler.Encode(li.ltype.Name), off);
            if (li.len > 0)
            {
                tw.Write("[{0}]", li.len);
            }
            tw.WriteLine(";");
        }

        tw.WriteLine("};");
    }