Exemple #1
0
        public JavaScriptResult SaveSoftContent(int SoftID, string Content)
        {
            string result = "";

            if (M.GetSoftContentDuplicateCount(SoftID, Content) < 1)
            {
                SoftwareContent newsoftcontent = new SoftwareContent {
                    SoftwareID = SoftID, Title = Content
                };
                int ContentID = M.SaveSoftContent(newsoftcontent);
                if (ContentID > 0)
                {
                    result = @" $(Here).empty(); $(TDIV).empty(); $.post('/Home/LoadSoftwareContents',{SID:" + SoftID + @"}); ";
                }
                else
                {
                    result = @" alert('New Content Save Failed'); ";
                }
            }
            else
            {
                result = @" alert('A title by that name already exists'); ";
            }
            return(JavaScript(result));
        }
        private void SaveBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            _view.Dispatcher.Invoke(DispatcherPriority.Render, (Action)(() =>
            {
                var dataResponse = new DataResponse(true, 1);
                if (IsAdding)
                {
                    Checksum = FileUtils.GetChecksum(_filePath);
                    dataResponse = ServiceManager.Upload(new FileUploadRequest
                    {
                        Name = Name,
                        SecurityKey = RequestResponseUtils.EncryptString(
                            AppSettings.GetConfig <string>(CommonConstants.MESSAGE_KEY)),
                        VirtualPath = _filePath
                    }, Checksum);
                }
                else
                {
                    if (_oriFileName != Executable)
                    {
                        Checksum = FileUtils.GetChecksum(_filePath);
                        //upload another file
                        ServiceManager.DeleteSoftwareFile(new List <string> {
                            Name
                        });
                        dataResponse = ServiceManager.Upload(new FileUploadRequest
                        {
                            Name = Name,
                            SecurityKey = RequestResponseUtils.EncryptString(
                                AppSettings.GetConfig <string>(CommonConstants.MESSAGE_KEY)),
                            VirtualPath = _filePath
                        }, Checksum);
                    }
                }

                if (!dataResponse.Status)
                {
                    DialogHelper.Error(dataResponse.Message, "Error on Upload file");
                    e.Result = false;
                    return;
                }

                var scontent = new SoftwareContent
                {
                    Id = Id,
                    Comment = Comment,
                    FileName = Executable,
                    LastUpdated = DateTime.Now,
                    Name = Name,
                    Parameters = Parameters,
                    Size = Size,
                    Version = Version,
                    Checksum = Checksum
                };
                var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <DataResponse>(
                                                                  sc.SoftwareInsertOrUpdate,
                                                                  scontent));
                Id = resultDeserialize.Result;
                e.Result = resultDeserialize.Status;
            }));
        }