Exemplo n.º 1
0
        private void AddTemplate()
        {
            var dte2 = this.GetService(typeof(SDTE)) as EnvDTE80.DTE2;

            var project = dte2.GetSelectedProject();

            if (string.IsNullOrWhiteSpace(project?.FullName))
            {
                throw new UserException("Please select a project first");
            }

            AddTemplate m = new AddTemplate(dte2, project);

            m.Closed += (sender, e) =>
            {
                // logic here Will be called after the child window is closed
                if (((AddTemplate)sender).Canceled == true)
                {
                    return;
                }

                var templatePath = Path.GetFullPath(Path.Combine(project.GetProjectDirectory(), m.Props.Template));  //GetFullpath removes un-needed relative paths  (ie if you are putting something in the solution directory)
                var configPath   = Path.GetFullPath(Path.Combine(project.GetProjectDirectory(), "codegeneratorconfig.json"));

                AddFileToProject(project, m, configPath);

                AddFileToProject(project, m, templatePath, true);
            };
            m.ShowModal();
        }
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            IInstancedEntity targetEntity = null;

            // Fall back to self it no target is selected
            if ((targetEntity = character.Playfield.FindByIdentity(target)) == null)
            {
                targetEntity = character;
            }

            IItemContainer container = targetEntity as IItemContainer;

            // Does this entity have a BaseInventory?
            if (container != null)
            {
                int lowId;
                int highId;
                int ql;
                if (!int.TryParse(args[1], out lowId))
                {
                    character.Playfield.Publish(ChatText.CreateIM(character, "LowId is no number"));
                    return;
                }

                if (!int.TryParse(args[2], out ql))
                {
                    character.Playfield.Publish(ChatText.CreateIM(character, "QualityLevel is no number"));
                    return;
                }

                // Determine low and high id depending on ql
                lowId  = ItemLoader.ItemList[lowId].GetLowId(ql);
                highId = ItemLoader.ItemList[lowId].GetHighId(ql);

                Item item = new Item(ql, lowId, highId);
                if (ItemLoader.ItemList[lowId].IsStackable())
                {
                    item.MultipleCount = ItemLoader.ItemList[lowId].getItemAttribute(212);
                }

                InventoryError err = container.BaseInventory.TryAdd(item);
                if (err != InventoryError.OK)
                {
                    character.Playfield.Publish(
                        ChatText.CreateIM(character, "Could not add to inventory. (" + err + ")"));
                }

                if (targetEntity as Character != null)
                {
                    AddTemplate.Send((targetEntity as Character).Client, item);
                }
            }
            else
            {
                character.Playfield.Publish(ChatText.CreateIM(character, "Target has no Inventory."));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="quality">
        /// </param>
        public static void TradeSkillBuildPressed(ZoneClient client, int quality)
        {
            TradeSkillInfo source = client.Character.TradeSkillSource;
            TradeSkillInfo target = client.Character.TradeSkillTarget;

            Item sourceItem = client.Character.BaseInventory.GetItemInContainer(source.Container, source.Placement);
            Item targetItem = client.Character.BaseInventory.GetItemInContainer(target.Container, target.Placement);

            TradeSkillEntry ts = TradeSkill.Instance.GetTradeSkillEntry(sourceItem.HighID, targetItem.HighID);

            quality = Math.Min(quality, ItemLoader.ItemList[ts.ResultHighId].Quality);
            if (ts != null)
            {
                if (WindowBuild(client, quality, ts, sourceItem, targetItem))
                {
                    Item           newItem        = new Item(quality, ts.ResultLowId, ts.ResultHighId);
                    InventoryError inventoryError = client.Character.BaseInventory.TryAdd(newItem);
                    if (inventoryError == InventoryError.OK)
                    {
                        AddTemplate.Send(client, newItem);

                        // Delete source?
                        if ((ts.DeleteFlag & 1) == 1)
                        {
                            client.Character.BaseInventory.RemoveItem(source.Container, source.Placement);
                            DeleteItem.Send(client, source.Container, source.Placement);
                        }

                        // Delete target?
                        if ((ts.DeleteFlag & 2) == 2)
                        {
                            client.Character.BaseInventory.RemoveItem(target.Container, target.Placement);
                            DeleteItem.Send(client, target.Container, target.Placement);
                        }

                        client.Character.Playfield.Publish(
                            ChatText.CreateIM(
                                client.Character,
                                SuccessMessage(
                                    sourceItem,
                                    targetItem,
                                    new Item(quality, ts.ResultLowId, ts.ResultHighId))));

                        client.Character.Stats[StatIds.xp].Value += CalculateXP(quality, ts);
                    }
                }
            }
            else
            {
                client.Character.Playfield.Publish(
                    ChatText.CreateIM(
                        client.Character,
                        "It is not possible to assemble those two items. Maybe the order was wrong?"));
                client.Character.Playfield.Publish(ChatText.CreateIM(client.Character, "No combination found!"));
            }
        }
Exemplo n.º 4
0
        public void SpawnItem(int lowid, int highid, int ql)
        {
            // TODO: Add check for full inventory!
            InventoryEntries mi = new InventoryEntries();
            AOItem           it = ItemHandler.interpolate(lowid, highid, ql);

            mi.Item      = it;
            mi.Container = 104;
            mi.Placement = this.TalkingTo.GetNextFreeInventory(104);
            this.TalkingTo.Inventory.Add(mi);
            AddTemplate.Send(this.TalkingTo.Client, mi);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Метод сохранения шаблона в БД
 /// </summary>
 /// <param name="angular">Сам шаблон</param>
 /// <returns></returns>
 public string TemplateSave(AngularTemplate angular)
 {
     try
     {
         var save = new AddTemplate();
         return(save.SaveTemplate(angular));
     }
     catch (Exception e)
     {
         Loggers.Log4NetLogger.Error(e);
         return(e.Message);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            IInstancedEntity targetEntity = null;

            if ((targetEntity = client.Playfield.FindByIdentity(target)) != null)
            {
                IItemContainer container = targetEntity as IItemContainer;

                // Does this entity have a BaseInventory?
                if (container != null)
                {
                    int lowId;
                    int highId;
                    int ql;
                    if (!int.TryParse(args[1], out lowId))
                    {
                        client.SendChatText("LowId is no number");
                        return;
                    }

                    if (!int.TryParse(args[2], out highId))
                    {
                        client.SendChatText("HighId is no number");
                        return;
                    }

                    if (!int.TryParse(args[3], out ql))
                    {
                        client.SendChatText("QualityLevel is no number");
                        return;
                    }

                    Item           item = new Item(ql, lowId, highId);
                    InventoryError err  = container.BaseInventory.TryAdd(item);
                    if (err != InventoryError.OK)
                    {
                        client.SendChatText("Could not add to inventory." + (int)err);
                    }

                    if (targetEntity as Character != null)
                    {
                        AddTemplate.Send((targetEntity as Character).Client, item);
                    }
                }
                else
                {
                    client.SendChatText("Target has no Inventory.");
                    return;
                }
            }
        }
Exemplo n.º 7
0
        private void AddFileToProject(Project project, AddTemplate m, string templatePath, bool runCustomTool = false)
        {
            if (File.Exists(templatePath))
            {
                var results = VsShellUtilities.ShowMessageBox(ServiceProvider.GlobalProvider, "'" + templatePath + "' already exists, are you sure you want to overwrite?", "Overwrite", OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                if (results != 6)
                {
                    return;
                }

                //if the window is open we have to close it before we overwrite it.
                ProjectItem pi = project.GetProjectItem(m.Props.Template);
                pi?.Document?.Close(vsSaveChanges.vsSaveChangesNo);
            }

            var templateSamplesPath = Path.Combine(DteHelper.AssemblyDirectory(), @"Resources\Templates");
            var defaultTemplatePath = Path.Combine(templateSamplesPath, m.DefaultTemplate.SelectedValue.ToString());

            if (!File.Exists(defaultTemplatePath))
            {
                throw new UserException("T4Path: " + defaultTemplatePath + " is missing or you can access it.");
            }

            var dir = Path.GetDirectoryName(templatePath);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            Status.Update("Adding " + templatePath + " to project");
            // When you add a TT file to visual studio, it will try to automatically compile it,
            // if there is error (and there will be error because we have custom generator)
            // the error will persit until you close Visual Studio. The solution is to add
            // a blank file, then overwrite it
            // http://stackoverflow.com/questions/17993874/add-template-file-without-custom-tool-to-project-programmatically
            var blankTemplatePath = Path.Combine(DteHelper.AssemblyDirectory(), @"Resources\Templates\Blank.tt");

            File.Copy(blankTemplatePath, templatePath, true);

            var p = project.ProjectItems.AddFromFile(templatePath);

            p.Properties.SetValue("CustomTool", "");

            File.Copy(defaultTemplatePath, templatePath, true);

            if (runCustomTool)
            {
                p.Properties.SetValue("CustomTool", typeof(CrmCodeGenerator2011).Name);
            }
        }
Exemplo n.º 8
0
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            Client targetClient = null;

            if ((targetClient = FindClient.FindClientByName(args[1])) != null)
            {
                int firstfree = 64;
                firstfree = targetClient.Character.GetNextFreeInventory(104);
                if (firstfree <= 93)
                {
                    InventoryEntries mi = new InventoryEntries();
                    AOItem           it = ItemHandler.GetItemTemplate(Convert.ToInt32(args[2]));
                    mi.Placement    = firstfree;
                    mi.Container    = 104;
                    mi.Item.LowID   = Convert.ToInt32(args[2]);
                    mi.Item.HighID  = Convert.ToInt32(args[3]);
                    mi.Item.Quality = Convert.ToInt32(args[4]);
                    if (it.ItemType != 1)
                    {
                        mi.Item.MultipleCount = Math.Max(1, it.getItemAttribute(212));
                    }
                    else
                    {
                        bool found = false;
                        foreach (AOItemAttribute a in mi.Item.Stats)
                        {
                            if (a.Stat != 212)
                            {
                                continue;
                            }
                            found   = true;
                            a.Value = Math.Max(1, it.getItemAttribute(212));
                            break;
                        }
                        if (!found)
                        {
                            AOItemAttribute aoi = new AOItemAttribute();
                            aoi.Stat  = 212;
                            aoi.Value = Math.Max(1, it.getItemAttribute(212));
                            mi.Item.Stats.Add(aoi);
                        }
                    }
                    targetClient.Character.Inventory.Add(mi);
                    AddTemplate.Send(targetClient, mi);
                }
                else
                {
                    client.SendChatText("Your Inventory is full");
                }
            }
        }
Exemplo n.º 9
0
        private int SpawnItem()
        {
            int firstfree = this.client.Character.GetNextFreeInventory(104);

            if (firstfree <= 93)
            {
                InventoryEntries mi = new InventoryEntries();
                AOItem           it = ItemHandler.GetItemTemplate(this.ResultLowId);
                mi.Placement    = firstfree;
                mi.Container    = 104;
                mi.Item.LowID   = this.ResultLowId;
                mi.Item.HighID  = this.ResultHighId;
                mi.Item.Quality = this.Quality;
                if (it.ItemType != 1)
                {
                    mi.Item.MultipleCount = Math.Max(1, it.getItemAttribute(212));
                }
                else
                {
                    bool found = false;
                    foreach (AOItemAttribute a in mi.Item.Stats)
                    {
                        if (a.Stat != 212)
                        {
                            continue;
                        }
                        found   = true;
                        a.Value = Math.Max(1, it.getItemAttribute(212));
                        break;
                    }
                    if (!found)
                    {
                        AOItemAttribute aoi = new AOItemAttribute();
                        aoi.Stat  = 212;
                        aoi.Value = Math.Max(1, it.getItemAttribute(212));
                        mi.Item.Stats.Add(aoi);
                    }
                }
                this.client.Character.Inventory.Add(mi);
                AddTemplate.Send(this.client, mi);

                return(firstfree);
            }
            else
            {
                this.client.SendChatText("Your Inventory is full");
                return(0);
            }
        }
Exemplo n.º 10
0
 public DataTable InsertUpdateTemplate(Int64 Id, AddTemplate obj)
 {
     using (SqlCommand sqlCommand = new SqlCommand())
     {
         sqlCommand.CommandType = CommandType.StoredProcedure;
         sqlCommand.CommandText = Procedures.InsertUpdateTemplate;
         sqlCommand.Parameters.AddWithValue("@UserId", Id);
         sqlCommand.Parameters.AddWithValue("@TemplateId", obj.TemplateId);
         sqlCommand.Parameters.AddWithValue("@TemplateType", obj.TemplateType);
         sqlCommand.Parameters.AddWithValue("@TemplateFor", obj.TemplateFor);
         sqlCommand.Parameters.AddWithValue("@Subject", obj.Subject);
         sqlCommand.Parameters.AddWithValue("@Body", obj.Body);
         sqlCommand.Parameters.AddWithValue("@IsActive", obj.TemplateStatus);
         sqlCommand.Parameters.AddWithValue("@NotificationType", obj.NotificationType);
         return(DAL.GetDataTable(ConfigurationHelper.connectionString, sqlCommand));
     }
 }
Exemplo n.º 11
0
        public async void AddNewTemplate()
        {
            Value = true;
            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Warning,
                    Languages.CheckConnection,
                    Languages.Ok);

                return;
            }
            if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Description))
            {
                Value = true;
                return;
            }
            var _template = new AddTemplate
            {
                name        = Name,
                description = Description,
                template    = "<!DOCTYPE html>↵<html>↵<head>↵</head>↵<body>↵<p>" + Template + "</p>↵</body>↵</html>"
            };
            var cookie = Settings.Cookie;  //.Split(11, 33)
            var res    = cookie.Substring(11, 32);

            var response = await apiService.Save <AddTemplate>(
                "https://portalesp.smart-path.it",
                "/Portalesp",
                "/diagnosticTemplate/save",
                res,
                _template);

            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok");

                return;
            }
            Value = false;
            MessagingCenter.Send((App)Application.Current, "OnSaved");
            DependencyService.Get <INotification>().CreateNotification("PortalSP", "Template Added");
            await App.Current.MainPage.Navigation.PopPopupAsync(true);
        }
Exemplo n.º 12
0
        public Result InsertUpdateTemplate(Int32 Id, AddTemplate obj)
        {
            Result objR = new Result();

            objR.Status  = "Failure";
            objR.Message = "Something went wrong. Please try again.";
            objTDS       = new TemplateDataService();
            DataTable dt = objTDS.InsertUpdateTemplate(Id, obj);

            if (dt != null && dt.Rows.Count > 0)
            {
                objR.Status  = "success";
                objR.Message = Convert.ToString(dt.Rows[0]["Message"]);
                objR.Id      = Convert.ToInt64(dt.Rows[0]["TemplateId"]);
            }
            return(objR);
        }
Exemplo n.º 13
0
 public ActionResult New(Website model)
 {
     if (Session["id"] != null)
     {
         var sta   = new Statistic();
         int total = sta.getSessionTemplate((int)Session["id"]);
         if (AddTemplate.Add(model, (int)Session["id"]))
         {
             ViewBag.success = 1;
             return(View(total));
         }
         ViewBag.error = 1;
         return(View());
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
Exemplo n.º 14
0
        public void TemplatePatternTest_Add()
        {
            var result = new AddTemplate().Calculate(1, 2);

            result.Should().Be(3);
        }
Exemplo n.º 15
0
        public static void Read(byte[] packet, Client client, Dynel dynel)
        {
            PacketReader reader       = new PacketReader(packet);
            PacketWriter packetWriter = new PacketWriter();
            Header       header       = reader.PopHeader();

            reader.PopByte();
            reader.PopInt();                       // unknown
            byte     action    = reader.PopByte(); // unknown
            Identity ident     = reader.PopIdentity();
            int      container = reader.PopInt();
            int      place     = reader.PopInt();

            Character character  = (Character)FindDynel.FindDynelById(ident.Type, ident.Instance);
            Character chaffected =
                (Character)FindDynel.FindDynelById(header.AffectedId.Type, header.AffectedId.Instance);

            // If target is a NPC, call its Action 0
            if ((character is NonPlayerCharacterClass) && (action == 0))
            {
                if (((NonPlayerCharacterClass)character).KnuBot != null)
                {
                    character.KnuBotTarget = character;
                    ((NonPlayerCharacterClass)character).KnuBot.TalkingTo = chaffected;
                    ((NonPlayerCharacterClass)character).KnuBot.Action(0);
                }
                return;
            }

            int cashDeduct = 0;
            int inventoryCounter;
            InventoryEntries inventoryEntry;

            switch (action)
            {
            case 1:     // end trade
                inventoryCounter = client.Character.Inventory.Count - 1;
                while (inventoryCounter >= 0)
                {
                    inventoryEntry = client.Character.Inventory[inventoryCounter];
                    AOItem aoItem;
                    if (inventoryEntry.Container == -1)
                    {
                        int nextFree = client.Character.GetNextFreeInventory(104);
                        aoItem = ItemHandler.GetItemTemplate(inventoryEntry.Item.LowID);
                        int price = aoItem.getItemAttribute(74);
                        int mult  = aoItem.getItemAttribute(212);    // original multiplecount
                        if (mult == 0)
                        {
                            mult = 1;
                            inventoryEntry.Item.MultipleCount = 1;
                        }
                        // Deduct Cash (ie.item.multiplecount) div mult * price
                        cashDeduct +=
                            Convert.ToInt32(
                                mult * price
                                *
                                (100
                                 - Math.Floor(Math.Min(1500, client.Character.Stats.ComputerLiteracy.Value) / 40.0))
                                / 2500);
                        // Add the Shop modificator and exchange the CompLit for skill form vendortemplate table
                        inventoryEntry.Placement = nextFree;
                        inventoryEntry.Container = 104;
                        if (!aoItem.isStackable())
                        {
                            int multiplicator = inventoryEntry.Item.MultipleCount;
                            inventoryEntry.Item.MultipleCount = 0;
                            while (multiplicator > 0)
                            {
                                AddTemplate.Send(client, inventoryEntry);
                                multiplicator--;
                            }
                        }
                        else
                        {
                            AddTemplate.Send(client, inventoryEntry);
                        }
                    }
                    if (inventoryEntry.Container == -2)
                    {
                        aoItem = ItemHandler.interpolate(
                            inventoryEntry.Item.LowID, inventoryEntry.Item.HighID, inventoryEntry.Item.Quality);
                        double multipleCount = aoItem.getItemAttribute(212);     // original multiplecount
                        int    price         = aoItem.getItemAttribute(74);
                        if (multipleCount == 0.0)
                        {
                            multipleCount = 1.0;
                        }
                        else
                        {
                            multipleCount = inventoryEntry.Item.MultipleCount / multipleCount;
                        }
                        cashDeduct -=
                            Convert.ToInt32(
                                multipleCount * price
                                *
                                (100
                                 + Math.Floor(Math.Min(1500, client.Character.Stats.ComputerLiteracy.Value) / 40.0))
                                / 2500);
                        // Add the Shop modificator and exchange the CompLit for skill form vendortemplate table
                        client.Character.Inventory.Remove(inventoryEntry);
                    }
                    inventoryCounter--;
                }

                client.Character.Stats.Cash.Set((uint)(client.Character.Stats.Cash.Value - cashDeduct));
                //                    Packets.Stat.Set(client, 61, client.Character.Stats.Cash.StatValue - cashdeduct, false);
                byte[] reply0 = new byte[32];
                Array.Copy(packet, reply0, 32);

                // pushing in server ID
                reply0[8]  = 0;
                reply0[9]  = 0;
                reply0[10] = 12;
                reply0[11] = 14;

                // pushing in Client ID
                reply0[12] = (byte)(client.Character.Id >> 24);
                reply0[13] = (byte)(client.Character.Id >> 16);
                reply0[14] = (byte)(client.Character.Id >> 8);
                reply0[15] = (byte)(client.Character.Id);

                packetWriter.PushBytes(reply0);
                packetWriter.PushByte(1);
                packetWriter.PushByte(4);
                packetWriter.PushIdentity(client.Character.LastTrade);
                packetWriter.PushIdentity(client.Character.LastTrade);
                client.Character.LastTrade = new Identity {
                    Instance = 0, Type = 0
                };

                byte[] reply2 = packetWriter.Finish();
                client.SendCompressed(reply2);
                break;

            case 2:
                // Decline trade
                inventoryCounter = client.Character.Inventory.Count - 1;
                while (inventoryCounter >= 0)
                {
                    inventoryEntry = client.Character.Inventory[inventoryCounter];
                    if (inventoryEntry.Container == -1)
                    {
                        client.Character.Inventory.Remove(inventoryEntry);
                    }
                    else
                    {
                        if (inventoryEntry.Container == -2)
                        {
                            inventoryEntry.Placement = client.Character.GetNextFreeInventory(104);
                            inventoryEntry.Container = 104;
                        }
                    }
                    inventoryCounter--;
                }

                byte[] replyCopy = new byte[50];
                Array.Copy(packet, replyCopy, 50);

                // pushing in server ID
                replyCopy[8]  = 0;
                replyCopy[9]  = 0;
                replyCopy[10] = 12;
                replyCopy[11] = 14;

                // pushing in Client ID
                replyCopy[12] = (byte)(client.Character.Id >> 24);
                replyCopy[13] = (byte)(client.Character.Id >> 16);
                replyCopy[14] = (byte)(client.Character.Id >> 8);
                replyCopy[15] = (byte)(client.Character.Id);

                packetWriter.PushBytes(replyCopy);
                byte[] rep1 = packetWriter.Finish();

                client.SendCompressed(rep1);
                break;

            case 3:
                break;

            case 4:
                break;

            case 5:     // add item to trade window
            case 6:     // remove item from trade window
                byte[] reply = new byte[50];
                Array.Copy(packet, reply, 50);
                if (character.Inventory.Count == 0)
                {
                    ((VendingMachine)character).LoadTemplate(((VendingMachine)character).TemplateId);
                }

                // pushing in server ID
                reply[8]  = 0;
                reply[9]  = 0;
                reply[10] = 12;
                reply[11] = 14;

                // pushing in Client ID
                reply[12] = (byte)(client.Character.Id >> 24);
                reply[13] = (byte)(client.Character.Id >> 16);
                reply[14] = (byte)(client.Character.Id >> 8);
                reply[15] = (byte)(client.Character.Id);

                //PacketWriter pw = new PacketWriter();
                packetWriter.PushBytes(reply);
                byte[] replyRemoveItemFromTradeWindow = packetWriter.Finish();
                client.SendCompressed(replyRemoveItemFromTradeWindow);

                if (client.Character == character)
                {
                    if (action == 5)
                    {
                        inventoryEntry           = character.GetInventoryAt(place);
                        inventoryEntry.Placement = character.GetNextFreeInventory(-2);
                        inventoryEntry.Container = -2;
                    }
                    if (action == 6)
                    {
                        inventoryEntry           = character.GetInventoryAt(place, -2);
                        inventoryEntry.Placement = character.GetNextFreeInventory(104);
                        inventoryEntry.Container = 104;
                    }
                }
                else
                {
                    InventoryEntries inew = new InventoryEntries
                    {
                        Container = -1, Placement = character.GetNextFreeInventory(-1)
                    };
                    int oldPlacement         = ((packet[46] >> 24) + (packet[47] >> 16) + (packet[48] >> 8) + packet[49]);
                    InventoryEntries totrade = character.GetInventoryAt(oldPlacement);
                    inew.Item.LowID         = totrade.Item.LowID;
                    inew.Item.HighID        = totrade.Item.HighID;
                    inew.Item.MultipleCount = totrade.Item.MultipleCount;
                    if (action == 6)     // Remove item from trade window
                    {
                        inew.Item.MultipleCount = -inew.Item.MultipleCount;
                    }
                    inew.Item.Quality = totrade.Item.Quality;
                    chaffected.InventoryReplaceAdd(inew);
                }
                break;
            }
        }
Exemplo n.º 16
0
        public IHttpActionResult AddUpdateTemplate(Int32 Id, AddTemplate obj)
        {
            TemplateBussinessService objTBS = new TemplateBussinessService();

            return(Ok(objTBS.InsertUpdateTemplate(Id, obj)));
        }
Exemplo n.º 17
0
 private void Initialize()
 {
     _typeAddTemplate   = typeof(AddTemplate);
     _objectAddTemplate = CreateInstance(_typeAddTemplate);
     InitializeSession();
 }
Exemplo n.º 18
0
        private async Task AddTemplateAsync()
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync(DisposalToken);

            var dte2 = await GetServiceAsync(typeof(SDTE)) as DTE2;

            Assumes.Present(dte2);

            var project = dte2.GetSelectedProject();

            if (project == null || string.IsNullOrWhiteSpace(project.FullName))
            {
                throw new UserException("Please select a project first");
            }

            var m = new AddTemplate(dte2, project);

            m.Closed +=
                (sender, e) =>
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                // logic here Will be called after the child window is closed
                if (((AddTemplate)sender).Canceled)
                {
                    return;
                }

                var templatePath = Path.GetFullPath(Path.Combine(project.GetPath(), m.Props.Template));
                //GetFullpath removes un-needed relative paths  (ie if you are putting something in the solution directory)

                if (File.Exists(templatePath))
                {
                    var results = VsShellUtilities.ShowMessageBox(ServiceProvider.GlobalProvider,
                                                                  "'" + templatePath + "' already exists, are you sure you want to overwrite?", "Overwrite",
                                                                  OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL,
                                                                  OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    if (results != 6)
                    {
                        return;
                    }

                    //if the window is open we have to close it before we overwrite it.
                    var pi = project.GetProjectItem(m.Props.Template);
                    if (pi != null && pi.Document != null)
                    {
                        pi.Document.Close(vsSaveChanges.vsSaveChangesNo);
                    }
                }

                var templateSamplesPath = Path.Combine(DteHelper.AssemblyDirectory(), @"Resources\Templates");
                var defaultTemplatePath = Path.Combine(templateSamplesPath, m.DefaultTemplate.SelectedValue.ToString());
                if (!File.Exists(defaultTemplatePath))
                {
                    throw new UserException("T4Path: " + defaultTemplatePath + " is missing or you can't access it.");
                }

                var dir = Path.GetDirectoryName(templatePath);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                Status.Update("[Template] Adding " + templatePath + " to project ... ");
                // When you add a TT file to visual studio, it will try to automatically compile it,
                // if there is error (and there will be error because we have custom generator)
                // the error will persit until you close Visual Studio. The solution is to add
                // a blank file, then overwrite it
                // http://stackoverflow.com/questions/17993874/add-template-file-without-custom-tool-to-project-programmatically
                var blankTemplatePath = Path.Combine(DteHelper.AssemblyDirectory(), @"Resources\Templates\_Blank.tt");
                // check out file if in TFS
                try
                {
                    var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(templatePath);

                    if (workspaceInfo != null)
                    {
                        var server    = new TfsTeamProjectCollection(workspaceInfo.ServerUri);
                        var workspace = workspaceInfo.GetWorkspace(server);
                        workspace.PendEdit(templatePath);
                        Status.Update("[Template] Checked out template file from TFS' current workspace.");
                    }
                }
                catch (Exception)
                {
                    // ignored
                }

                try
                {
                    File.Copy(blankTemplatePath, templatePath, true);
                }
                catch (Exception ex)
                {
                    var error = ex.Message + "\n" + ex.StackTrace;
                    MessageBox.Show(error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    throw;
                }

                Status.Update("[Template] [DONE] Adding template file to project.");

                var p = project.ProjectItems.AddFromFile(templatePath);
                p.Properties.SetValue("CustomTool", "");

                File.Copy(defaultTemplatePath, templatePath, true);
                p.Properties.SetValue("CustomTool", nameof(CrmCodeGenerator2011));
            };

            m.ShowModal();
        }
Exemplo n.º 19
0
        private void button3_Click(object sender, EventArgs e)
        {
            AddTemplate form = new AddTemplate();

            form.ShowDialog();
        }
Exemplo n.º 20
0
        private void AddTemplate()
        {
            var dte2 = this.GetService(typeof(SDTE)) as EnvDTE80.DTE2;

            var project = dte2.GetSelectedProject();

            if (project == null || string.IsNullOrWhiteSpace(project.FullName))
            {
                throw new UserException("Please select a project first");
            }

            var m = new AddTemplate(dte2, project);

            m.Closed += (sender, e) =>
            {
                // logic here Will be called after the child window is closed
                if (((AddTemplate)sender).Canceled == true)
                {
                    return;
                }

                var templatePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(project.GetProjectDirectory(), m.Props.Template));  //GetFullpath removes un-needed relative paths  (ie if you are putting something in the solution directory)

                if (System.IO.File.Exists(templatePath))
                {
                    var results = VsShellUtilities.ShowMessageBox(ServiceProvider.GlobalProvider, "'" + templatePath + "' already exists, are you sure you want to overwrite?", "Overwrite", OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    if (results != 6)
                    {
                        return;
                    }

                    //if the window is open we have to close it before we overwrite it.
                    var pi = project.GetProjectItem(m.Props.Template);
                    if (pi != null && pi.Document != null)
                    {
                        pi.Document.Close(vsSaveChanges.vsSaveChangesNo);
                    }
                }

                var templateSamplesPath = System.IO.Path.Combine(DteHelper.AssemblyDirectory(), @"Resources\Templates");
                var defaultTemplatePath = System.IO.Path.Combine(templateSamplesPath, m.DefaultTemplate.SelectedValue.ToString());
                if (!System.IO.File.Exists(defaultTemplatePath))
                {
                    throw new UserException("T4Path: " + defaultTemplatePath + " is missing or you can access it.");
                }

                var dir = System.IO.Path.GetDirectoryName(templatePath);
                if (!System.IO.Directory.Exists(dir))
                {
                    System.IO.Directory.CreateDirectory(dir);
                }

                Status.Update("Adding " + templatePath + " to project");
                // When you add a TT file to visual studio, it will try to automatically compile it,
                // if there is error (and there will be error because we have custom generator)
                // the error will persit until you close Visual Studio. The solution is to add
                // a blank file, then overwrite it
                // http://stackoverflow.com/questions/17993874/add-template-file-without-custom-tool-to-project-programmatically
                var blankTemplatePath = System.IO.Path.Combine(DteHelper.AssemblyDirectory(), @"Resources\Templates\Blank.tt");
                System.IO.File.Copy(blankTemplatePath, templatePath, true);

                var p = project.ProjectItems.AddFromFile(templatePath);
                p.Properties.SetValue("CustomTool", "");

                System.IO.File.Copy(defaultTemplatePath, templatePath, true);
                p.Properties.SetValue("CustomTool", typeof(CrmCodeGenerator2011).Name);
            };
            m.ShowModal();
        }