Пример #1
0
        private async Task GetSelectedSolutionAsync()
        {
            comboBoxSolutions.Items.Clear();
            solutions = new List <SolutionDetail>();

            try
            {
                var entity = await RetrieveSolutionAsync(detail);

                var solDetail = new SolutionDetail()
                {
                    SolutionId      = entity.Id,
                    UniqueName      = entity.GetAttributeValue <string>("uniquename"),
                    FriendlyName    = entity.GetAttributeValue <string>("friendlyname"),
                    PublisherPrefix = entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix") == null ? null : entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix").Value.ToString()
                };

                if (solutions == null)
                {
                    solutions = new List <SolutionDetail>();
                }

                solutions.Add(solDetail);
                comboBoxSolutions.Items.Add(new Solution {
                    SolutionDetail = solDetail
                });
                comboBoxSolutions.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                var errorMessage = CrmExceptionHelper.GetErrorMessage(ex, false);
                MessageBox.Show(this, "An error occured while retrieving solutions: " + errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        internal static SolutionDetail NewSolutionDetail(Faker faker, string solutionId)
        {
            var sd = new SolutionDetail
            {
                SolutionDetailId     = Guid.NewGuid(),
                SolutionId           = solutionId,
                AboutUrl             = faker.Internet.Url(),
                Features             = GenerateFeatures(5, faker),
                ClientApplication    = ClientApplicationStringBuilder.GetClientAppString(clientApplicationTypes: "Browser-based, Native mobile or tablet, Native desktop"),
                Summary              = faker.Lorem.Paragraphs(1),
                FullDescription      = faker.Lorem.Paragraphs(7),
                RoadMap              = faker.Rant.Review(),
                Hosting              = CompleteHostingTypes,
                IntegrationsUrl      = faker.Internet.Url(),
                ImplementationDetail = faker.Lorem.Sentences(2)
            };

            if (sd.Summary.Length > 300)
            {
                sd.Summary = sd.Summary.Remove(299);
            }

            if (sd.FullDescription.Length > 1000)
            {
                sd.FullDescription = sd.FullDescription.Remove(999);
            }

            return(sd);
        }
Пример #3
0
 public void SaveSolutionDetail(Sender sender, SolutionDetail item)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy(true))
         {
             SolutionDetail obj = new SolutionDetail();
             obj.CabinetID = item.CabinetID;
             if (op.LoadSolutionDetailByItemID(obj) == 0)
             {
                 item.Created    = DateTime.Now;
                 item.CreatedBy  = sender.UserCode + "." + sender.UserName;
                 item.Modified   = DateTime.Now;
                 item.ModifiedBy = sender.UserCode + "." + sender.UserName;
                 op.InsertSolutionDetail(item);
             }
             else
             {
                 item.Modified   = DateTime.Now;
                 item.ModifiedBy = sender.UserCode + "." + sender.UserName;
                 op.UpdateSolutionDetailByItemID(item);
             }
             op.CommitTransaction();
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
        internal static void InsetSolutionDetail(string connectionString, SolutionDetail solutionDetail)
        {
            var query = @"INSERT INTO SolutionDetail (
                            Id, 
                            LastUpdatedBy, 
                            LastUpdated, 
                            SolutionId,
                            Features,
                            ClientApplication, 
                            AboutUrl, 
                            Summary, 
                            FullDescription, 
                            RoadMap, 
                            Hosting, 
                            IntegrationsUrl, 
                            ImplementationDetail ) 
                        VALUES (
                            @SolutionDetailId, 
                            @LastUpdatedBy, 
                            @LastUpdated, 
                            @SolutionId,
                            @Features,
                            @ClientApplication,
                            @AboutUrl,
                            @Summary,
                            @FullDescription,
                            @RoadMap,
                            @Hosting,
                            @IntegrationsUrl,
                            @ImplementationDetail)";

            SqlExecutor.Execute <SolutionDetail>(connectionString, query, solutionDetail);
        }
        public UITest()
        {
            solution       = CreateSolution.CreateNewSolution();
            solutionDetail = CreateSolutionDetails.CreateNewSolutionDetail(solution.Id, Guid.NewGuid(), 0, false);

            connectionString = EnvironmentVariables.GetConnectionString();
            SqlHelper.CreateBlankSolution(solution, solutionDetail, connectionString);

            url = $"{EnvironmentVariables.GetUrl()}/{solution.Id}";

            driver = new BrowserFactory().Driver;
            pages  = new PageActions(driver).PageActionCollection;

            driver.Navigate().GoToUrl(url);
        }
        public static void UpdateSolutionDetails(SolutionDetail solutionDetail, string connectionString)
        {
            var query = Queries.UpdateSolutionDetail;

            SqlParameter[] newParameters = new SqlParameter[]
            {
                new SqlParameter("@summary", solutionDetail.Summary),
                new SqlParameter("@solutionDetailsId", solutionDetail.SolutionDetailId),
                new SqlParameter("@solutionId", solutionDetail.SolutionId),
                new SqlParameter("@clientApplication", solutionDetail.ClientApplication),
                new SqlParameter("@features", solutionDetail.Features),
                new SqlParameter("@aboutUrl", solutionDetail.AboutUrl),
                new SqlParameter("@fullDescription", solutionDetail.FullDescription)
            };

            SqlReader.Read(connectionString, query, newParameters, DataReaders.NoReturn);
        }
        public UpdaterServiceResponse <SolutionDetail> RetrieveSolution(ConnectionDetail connectionDetail, Guid solutionId)
        {
            var response = new UpdaterServiceResponse <SolutionDetail>();

            try
            {
                Console.WriteLine("Requesting Solution retrieve");
                var             client = connectionDetail.GetCrmServiceClient(true);
                QueryExpression query  = new QueryExpression
                {
                    EntityName = "solution",
                    ColumnSet  = new ColumnSet(new string[] { "friendlyname", "uniquename", "publisherid" }),
                    Criteria   = new FilterExpression()
                };
                query.Criteria.AddCondition("isvisible", ConditionOperator.Equal, true);
                query.Criteria.AddCondition("solutionid", ConditionOperator.Equal, solutionId);

                query.LinkEntities.Add(new LinkEntity("solution", "publisher", "publisherid", "publisherid", JoinOperator.Inner));
                query.LinkEntities[0].Columns.AddColumns("customizationprefix");
                query.LinkEntities[0].EntityAlias = "publisher";

                var retrieveSolutionResponse = client.RetrieveMultiple(query);
                var entity = retrieveSolutionResponse.Entities.FirstOrDefault();
                if (entity == null)
                {
                    return(null);
                }
                var solution = new SolutionDetail()
                {
                    SolutionId      = entity.Id,
                    PublisherPrefix = entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix") == null ? null : entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix").Value.ToString()
                };

                response.Payload      = solution;
                response.IsSuccessful = true;
                return(response);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                response.Error        = ex.ToString();
                response.IsSuccessful = false;
                return(response);
            }
        }
Пример #8
0
        void BwGetSolutionsRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                string errorMessage = e.Error.Message;
                var    ex           = e.Error.InnerException;
                while (ex != null)
                {
                    errorMessage += "\r\nInner Exception: " + ex.Message;
                    ex            = ex.InnerException;
                }

                MessageBox.Show(this, "An error occured while retrieving solutions: " + errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                foreach (Entity entity in (DataCollection <Entity>)e.Result)
                {
                    var solutionDetail = new SolutionDetail()
                    {
                        SolutionId      = entity.Id,
                        UniqueName      = entity.GetAttributeValue <string>("uniquename"),
                        FriendlyName    = entity.GetAttributeValue <string>("friendlyname"),
                        PublisherPrefix = entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix") == null ? null : entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix").Value.ToString()
                    };

                    solutions.Add(solutionDetail);

                    comboBoxSolutions.Items.Add(new Solution()
                    {
                        SolutionDetail = solutionDetail
                    });
                    comboBoxSolutions.SelectedIndex = 0;
                }
                if (comboBoxSolutions.Items.Count > 0)
                {
                    comboBoxSolutions.Enabled = true;
                }
            }

            Cursor = Cursors.Default;
        }
Пример #9
0
        private void BwGetSolutionRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                string errorMessage = e.Error.Message;
                var    ex           = e.Error.InnerException;
                while (ex != null)
                {
                    errorMessage += "\r\nInner Exception: " + ex.Message;
                    ex            = ex.InnerException;
                }

                MessageBox.Show(this, "An error occured while retrieving organizations: " + errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (e.Result != null)
                {
                    var entity    = e.Result as Entity;
                    var solDetail = new SolutionDetail()
                    {
                        SolutionId      = entity.Id,
                        UniqueName      = entity.GetAttributeValue <string>("uniquename"),
                        FriendlyName    = entity.GetAttributeValue <string>("friendlyname"),
                        PublisherPrefix = entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix") == null ? null : entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix").Value.ToString()
                    };

                    if (solutions == null)
                    {
                        solutions = new List <SolutionDetail>();
                    }

                    solutions.Add(solDetail);
                    comboBoxSolutions.Items.Add(new Solution {
                        SolutionDetail = solDetail
                    });
                    comboBoxSolutions.SelectedIndex = 0;
                }
            }

            Cursor = Cursors.Default;
        }
Пример #10
0
 public SolutionDetail GetSolutionDetail(Sender sender, Guid ItemID)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             SolutionDetail obj = new SolutionDetail();
             obj.ItemID = ItemID;
             if (op.LoadSolutionDetailByItemID(obj) == 0)
             {
                 return(null);
             }
             return(obj);
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Пример #11
0
        public async Task <IEnumerable <SolutionDetail> > Solution(int id)
        {
            var currentUser = await GetRequestUser();

            var solutions = Repository.Solutions.GetSolutionByProblemId(id).ToList();

            var solutionDetails = new List <SolutionDetail>();

            foreach (var solution in solutions)
            {
                var currentUserName = currentUser?.Identity;
                var user            = solution.Author;
                var votes           = await Repository.Votes.GetCountForItemId(solution.SolutionId);

                var userVm = new UserViewModel(user, currentUserName);
                var svm    = new SolutionDetail(solution, userVm, votes, Url);

                solutionDetails.Add(svm);
            }

            return(solutionDetails.OrderByDescending(m => m.Votes).ThenBy(m => m.Passing != null && m.Passing.Value).ThenBy(m => m.Length).ToList());
        }
Пример #12
0
        public SolutionDetail GetSolutionDetailByBarcode(Sender sender, string Barcode)
        {
            try
            {
                using (ObjectProxy op = new ObjectProxy())
                {
                    SolutionDetail obj = new SolutionDetail();
                    obj.BarcodeNo = Barcode;

                    if (op.LoadSolutionDetailByBarcodeNo(obj) == 0)
                    {
                        return(null);
                    }
                    return(obj);
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }
Пример #13
0
        private bool IsSolutionBarcodeDuplicated(Sender sender, SolutionDetail item)
        {
            try
            {
                using (ObjectProxy op = new ObjectProxy())
                {
                    SolutionDetail obj = new SolutionDetail();
                    obj.BarcodeNo = item.BarcodeNo;

                    if (op.LoadSolutionDetailByBarcodeNo(obj) == 0)
                    {
                        return(false);
                    }
                    return(obj.ItemID != item.ItemID);
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }
        public static void CreateBlankSolution(Solution solution, SolutionDetail solutionDetail, string connectionString)
        {
            // Create a new solution that is absolutely bare bones
            var solutionQuery = Queries.CreateNewSolution;

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@solutionId", solution.Id),
                new SqlParameter("@solutionName", solution.Name),
                new SqlParameter("@solutionVersion", solution.Version),
                new SqlParameter("@lastUpdatedBy", Guid.Empty),
                new SqlParameter("@lastUpdated", DateTime.Now)
            };

            SqlReader.Read(connectionString, solutionQuery, parameters, DataReaders.NoReturn);

            // Create a record in the SolutionDetail table for the new solution
            var solutionDetailQuery = Queries.CreateSolutionDetail;

            SqlParameter[] newParameters = new SqlParameter[] {
                new SqlParameter("@solutionDetailId", solutionDetail.SolutionDetailId),
                new SqlParameter("@solutionId", solutionDetail.SolutionId),
                new SqlParameter("@lastUpdatedBy", Guid.Empty),
                new SqlParameter("@lastUpdated", DateTime.Now)
            };

            SqlReader.Read(connectionString, solutionDetailQuery, newParameters, DataReaders.NoReturn);

            var updateSolutionDetail = Queries.UpdateSolutionSolutionDetailId;

            SqlParameter[] updateSolId = new SqlParameter[] {
                new SqlParameter("@solutionDetailId", solutionDetail.SolutionDetailId),
                new SqlParameter("@solutionId", solution.Id)
            };

            SqlReader.Read(connectionString, updateSolutionDetail, updateSolId, DataReaders.NoReturn);
        }
Пример #15
0
        private async void BGetSolutionsClick(object sender, EventArgs e)
        {
            if (FillConnectionDetails())
            {
                var organization       = (Organization)comboBoxOrganizations.SelectedItem;
                var organizationDetail = organization.OrganizationDetail;

                detail.OrganizationId           = organizationDetail.OrganizationId.ToString();
                detail.OrganizationServiceUrl   = organizationDetail.Endpoints[EndpointType.OrganizationService];
                detail.Organization             = organizationDetail.UniqueName;
                detail.OrganizationUrlName      = organizationDetail.UrlName;
                detail.OrganizationFriendlyName = organizationDetail.FriendlyName;
                detail.OrganizationVersion      = organizationDetail.OrganizationVersion;


                // Launch organization retrieval
                comboBoxSolutions.Items.Clear();
                solutions             = new List <SolutionDetail>();
                Cursor                = Cursors.WaitCursor;
                bGetSolutions.Enabled = false;

                try
                {
                    var solutionsResponse = await RetrieveSolutionsAsync(detail);

                    foreach (Entity entity in solutionsResponse)
                    {
                        var solutionDetail = new SolutionDetail()
                        {
                            SolutionId      = entity.Id,
                            UniqueName      = entity.GetAttributeValue <string>("uniquename"),
                            FriendlyName    = entity.GetAttributeValue <string>("friendlyname"),
                            PublisherPrefix = entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix") == null ? null : entity.GetAttributeValue <AliasedValue>("publisher.customizationprefix").Value.ToString()
                        };

                        solutions.Add(solutionDetail);

                        comboBoxSolutions.Items.Add(new Solution()
                        {
                            SolutionDetail = solutionDetail
                        });
                        comboBoxSolutions.SelectedIndex = 0;
                    }
                    if (comboBoxSolutions.Items.Count > 0)
                    {
                        comboBoxSolutions.Enabled = true;
                    }
                }
                catch (Exception ex)
                {
                    var errorMessage = CrmExceptionHelper.GetErrorMessage(ex, false);
                    MessageBox.Show(this, "An error occured while retrieving solutions: " + errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                bGetSolutions.Enabled = true;
                Cursor = Cursors.Default;

                //var bw = new BackgroundWorker();
                //bw.DoWork += BwGetSolutionsDoWork;
                //bw.RunWorkerCompleted += BwGetSolutionsRunWorkerCompleted;
                //bw.RunWorkerAsync();
            }
        }
Пример #16
0
        private void BValidateClick(object sender, EventArgs e)
        {
            if (tbName.Text.Length == 0)
            {
                MessageBox.Show(this, "You must define a name for this connection!", "Warning", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            int serverPort = 80;

            if (tbServerPort.Text.Length > 0)
            {
                if (!int.TryParse(tbServerPort.Text, out serverPort))
                {
                    MessageBox.Show(this, "Server port must be a integer value!", "Warning", MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                    return;
                }
            }

            if (proposeToConnect && comboBoxOrganizations.Text.Length == 0 && comboBoxOrganizations.SelectedItem == null &&
                !(cbUseIfd.Checked || cbUseOSDP.Checked))
            {
                MessageBox.Show(this, "You must select an organization!", "Warning", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            if (tbUserPassword.Text.Length == 0 && (cbUseIfd.Checked || rbAuthenticationCustom.Checked))
            {
                MessageBox.Show(this, "You must define a password!", "Warning", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            if (detail == null)
            {
                detail = new ConnectionDetail();
            }

            // Save connection details in structure
            detail.ConnectionName = tbName.Text;
            detail.IsCustomAuth   = rbAuthenticationCustom.Checked;
            detail.UseSsl         = cbUseSsl.Checked;
            detail.UseOnline      = cbUseOnline.Checked;
            detail.UseOsdp        = cbUseOSDP.Checked;
            detail.ServerName     = (cbUseOSDP.Checked || cbUseOnline.Checked)
                ? cbbOnlineEnv.SelectedItem.ToString()
                : tbServerName.Text;
            detail.ServerPort   = serverPort;
            detail.UserDomain   = tbUserDomain.Text;
            detail.UserName     = tbUserLogin.Text;
            detail.UserPassword = tbUserPassword.Text;
            detail.SavePassword = chkSavePassword.Checked;
            detail.UseIfd       = cbUseIfd.Checked;
            detail.HomeRealmUrl = (tbHomeRealmUrl.Text.Length > 0 ? tbHomeRealmUrl.Text : null);

            TimeSpan timeOut;

            if (!TimeSpan.TryParse(tbTimeoutValue.Text, CultureInfo.InvariantCulture, out timeOut))
            {
                MessageBox.Show(this, "Wrong timeout value!\r\n\r\nExpected format : HH:mm:ss", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            detail.Timeout = timeOut;

            OrganizationDetail selectedOrganization = comboBoxOrganizations.SelectedItem != null
                ? ((Organization)comboBoxOrganizations.SelectedItem).OrganizationDetail
                : null;

            if (selectedOrganization != null)
            {
                detail.OrganizationServiceUrl   = selectedOrganization.Endpoints[EndpointType.OrganizationService];
                detail.WebApplicationUrl        = selectedOrganization.Endpoints[EndpointType.WebApplication];
                detail.Organization             = selectedOrganization.UniqueName;
                detail.OrganizationUrlName      = selectedOrganization.UrlName;
                detail.OrganizationFriendlyName = selectedOrganization.FriendlyName;
                detail.OrganizationVersion      = selectedOrganization.OrganizationVersion;
                detail.OrganizationId           = selectedOrganization.OrganizationId.ToString();
            }


            SolutionDetail selectedSolution = comboBoxSolutions.SelectedItem != null
                ? ((Solution)comboBoxSolutions.SelectedItem).SolutionDetail
                : null;

            if (selectedSolution != null)
            {
                detail.Solution             = selectedSolution.UniqueName;
                detail.SolutionFriendlyName = selectedSolution.FriendlyName;
                detail.SolutionId           = selectedSolution.SolutionId.ToString();
                detail.PublisherPrefix      = selectedSolution.PublisherPrefix;
            }

            try
            {
                if (proposeToConnect || isCreationMode)
                {
                    FillDetails();

                    if (proposeToConnect &&
                        MessageBox.Show(this, "Do you want to connect now to this server?", "Question",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        doConnect = true;
                    }
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception error)
            {
                if (detail.OrganizationServiceUrl != null && detail.OrganizationServiceUrl.IndexOf(detail.ServerName, StringComparison.Ordinal) < 0)
                {
                    var uri      = new Uri(detail.OrganizationServiceUrl);
                    var hostName = uri.Host;

                    const string format = "The server name you provided ({0}) is not the same as the one defined in deployment manager ({1}). Please make sure that the server name defined in deployment manager is reachable from you computer.\r\n\r\nError:\r\n{2}";
                    MessageBox.Show(this, string.Format(format, detail.ServerName, hostName, error.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(this, error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }