SessionFactory not found - dotcmis

I'm just starting using CMIS. I'm trying to get the first sample from the Apache site to work (https://chemistry.apache.org/dotnet/getting-started-with-dotcmis.html) but the compiler does not accept the SessionFactory. What am I doing wrong?
using System;
using System.Collections.Generic;
using System.Linq;
using DotCMIS;
using DotCMIS.Client;
namespace CMIS_TestAndExplore
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters[SessionParameter.BindingType] = BindingType.AtomPub;
parameters[SessionParameter.AtomPubUrl] = "http://<http://localhost:8081/inmemory/atom";
parameters[SessionParameter.User] = "test";
parameters[SessionParameter.Password] = "";
SessionFactory factory = SessionFactory.NewInstance();
ISession session = factory.GetRepositories(parameters)[0].CreateSession();
}
}
}

It turns out I was just missing a using statement. I just had to add:
using DotCMIS.Client.Impl;

Related

Inference for custom vision model hosted on Azure Cognitive Services stopped working in December for me

I have a service that has been successfully performing inferences for 2 years, but API stopped working in December. I have created a simple App based on documentation from Microsoft to reproduce the problem. Please see code below.
Is anybody else experience this problem?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction;
using static System.Net.Mime.MediaTypeNames;
namespace TestCustomVision
{
class Program
{
public static void Main()
{
string imageFilePath = <My Image>;
MakePredictionRequest(imageFilePath).Wait();
Console.WriteLine("\n\nHit ENTER to exit...");
Console.ReadLine();
}
public static async Task MakePredictionRequest(string imageFilePath)
{
var client = new HttpClient();
// Request headers - replace this example key with your valid Prediction-Key.
client.DefaultRequestHeaders.Add("Prediction-Key", <My key>);
// Prediction URL - replace this example URL with your valid Prediction URL.
string url = <Prediction URL>;
HttpResponseMessage response;
// Request body. Try this sample with a locally stored image.
byte[] byteData = GetImageAsByteArray(imageFilePath);
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response = await client.PostAsync(url, content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
private static byte[] GetImageAsByteArray(string imageFilePath)
{
FileStream fileStream = new FileStream(imageFilePath, FileMode.Open, FileAccess.Read);
BinaryReader binaryReader = new BinaryReader(fileStream);
return binaryReader.ReadBytes((int)fileStream.Length);
}
}
}

Create Button Under Actions To Redirect To Report In Acumatica

I am trying to add an option under Actions in Acumatica on the Checks & Payment screen AP302000. See below what I am trying to achieve:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using PX.Common;
using PX.Data;
using PX.Objects.CM;
using PX.Objects.CA;
using PX.Objects.CS;
using PX.Objects.GL;
using PX.Objects.CR;
using PX.Objects;
using PX.Objects.AP;
namespace PX.Objects.AP
{
public class APPaymentEntry_Extension:PXGraphExtension<APPaymentEntry>
{
#region Event Handlers
public PXAction<APPayment> ShowURL;
[PXUIField(DisplayName = "Print Remittance")]
[PXButton]
protected virtual void showURL()
{
APPayment doc = Document.Current;
if (doc.RefNbr != null) {
throw new PXReportRequiredException(doc.RefNbr, "AP991000", null);
}
}
#endregion
}
}
This is however telling me that there is no definition and no extension method for 'APPayment'. Can someone please walk me through how to achieve what I am trying to do?
Note that the report has only 1 parameter (RefNbr)
Thanks,
G
To Add a new Action in existing Actions Menu, you should override the Initialize() method and use AddMenuAction.
public class APPaymentEntry_Extension : PXGraphExtension<APPaymentEntry>
{
public override void Initialize()
{
Base.action.AddMenuAction(ShowURL);
}
public PXAction<APPayment> ShowURL;
[PXUIField(DisplayName = "Print Remittance")]
[PXButton]
protected virtual void showURL()
{
APPayment doc = Base.Document.Current;
if (doc.RefNbr != null)
{
throw new PXReportRequiredException(doc, "AP991000", null);
}
}
}
Document.Current should be accessed as Base.Document.Current in Extensions. You need to pass the DAC as first parameter in PXReportRequiredException if DAC has the appropriate parameter value. Alternatively, you can build parameters and pass it to PXReportRedirectException.
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["ParameterName1"] = <Parameter Value>;
...
throw new PXReportRequiredException(parameters, <reportID>, "Report")

error : is a field but used as a type

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication5
{
public class ClientContext
{
private string p;
public ClientContext(string p)
{
// TODO: Complete member initialization
this.p = p;
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//First construct client context, the object which will be responsible for
//communication with SharePoint:
private ClientContext context = new ClientContext("#url");
//then get a hold of the list item you want to download, for example
public List list;
public ClientContext
{
list = context.Web.Lists.GetByTitle("001_CFR_DPV_COST_REV_SHARING");
}
//note that data has not been loaded yet. In order to load the data
//you need to tell SharePoint client what you want to download:
context.Load(result, items=>items.Include(
item => item["Title"],
item => item["FileRef"]
));
//now you get the data
context.ExecuteQuery();
//here you have list items, but not their content (files). To download file
//you'll have to do something like this:
var item = items.First();
//get the URL of the file you want:
var fileRef = item["FileRef"];
//get the file contents:
FileInformation fileInfo = File.OpenBinaryDirect(context, fileRef.ToString());
using (var memory = new MemoryStream())
{
byte[] buffer = new byte[1024 * 64];
int nread = 0;
while ((nread = fileInfo.Stream.Read(buffer, 0, buffer.Length)) > 0)
{
memory.Write(buffer, 0, nread);
}
memory.Seek(0, SeekOrigin.Begin);
// ... here you have the contents of your file in memory,
// do whatever you want
}
}
}
this is the complete code.
I don't know why it is showing error. I searched for the error "is a field but used as a type" and I tried that but it didn't help. Please help with a solution Code to this since I am new to this. Thank you in advance.
What are you trying to achieve by this lines of code?
public partial class Form1 : Form
{
...
public ClientContext
{
list = context.Web.Lists.GetByTitle("001_CFR_DPV_COST_REV_SHARING");
}
}
What is public ClientContext {} inside class Form1 ?
It seems that you intended to create constructor to a class in another class and for compiler it looks more like a property but without accessors (get, set) as if it is a Type or smth like this.
Try to put get; set; accessors inside if you intended to create property:
public List Context
{
get
{
list = context.Web.Lists.GetByTitle("001_CFR_DPV_COST_REV_SHARING");
return list;
}
}
Or change it to method instead :
public void GetClientContext()
{
list = context.Web.Lists.GetByTitle("001_CFR_DPV_COST_REV_SHARING");
}

dotCmis .CreateDocument with Sharepoint 2013

Good morning,
i need to create a bunch of documents with Apache chemistry dotcmis. However even in the most trivial case SharePoint triggers a CmisConstraintException when calling folder.CreateDocument. I have tested with all VersioningStates available, but that does not solve the issue. I use dotCmis 0.6. The Alfresco part of my application runs fine, btw..
-Armin
Here's my mock up.
using DotCMIS;
using DotCMIS.Client;
using DotCMIS.Client.Impl;
using DotCMIS.Data.Impl;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, string> parameters;
parameters = new Dictionary<string, string>();
parameters[SessionParameter.BindingType] = BindingType.AtomPub;
parameters[SessionParameter.AtomPubUrl] = "http://coretwo/" + "websites/migrationtest" + "/_vti_bin/cmis/rest?getRepositories";
parameters[SessionParameter.User] = "joe#test.org";
parameters[SessionParameter.Password] = "whoknows";
var session = SessionFactory.NewInstance().GetRepositories(parameters).Single(r => r.Name.Equals("Dokumente")).CreateSession();
var rFolder = session.GetRootFolder();
IDictionary<string, object> properties = new Dictionary<string, object>();
properties[PropertyIds.Name] = "Hello World Document";
properties[PropertyIds.ObjectTypeId] = "cmis:document";
byte[] content = UTF8Encoding.UTF8.GetBytes("Hello World!");
ContentStream contentStream = new ContentStream();
contentStream.FileName = "hello-world.txt";
contentStream.MimeType = "text/plain";
contentStream.Length = content.Length;
contentStream.Stream = new MemoryStream(content);
IDocument doc = rFolder.CreateDocument(properties, contentStream, null);
}
}
}
Murphy is everywhere...i found the answer minutes after posting here. The trick is to use DotCMIS.Enums.VersioningState.CheckedOut when calling CreateDocument and do the checkin thereafter.
So here is what works for me:
IDocument doc = rFolder.CreateDocument(properties, contentStream, DotCMIS.Enums.VersioningState.CheckedOut);
doc.CheckIn(true, null, null, "Checkin", null, null, null);

how to add emoticons to richtextbox

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace abc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
EmoticonRender ab = new EmoticonRender();
private void button1_Click(object sender, EventArgs e)
{
string textie = ab.Parse(textBox1.Text);
richTextBox1.Text += textie+"\n";
}
}
public class EmoticonRender
{
private List<KeyValuePair<string, string>> _dictionary = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>(":-)", "a.png"),
new KeyValuePair<string, string>(";-(", "a.png"),
};
public string Parse(string text)
{
foreach(KeyValuePair<string, string> kvp in _dictionary)
{
text = text.Replace(kvp.Key, #"C:\Users\Buddiez\Documents\Visual Studio 2010\Projects\abc\abc\a.png");
}
return text;
}
}
}
im using these line of codes to insert smilyes into richtextbox but instead of showing smileye it is showing the path of the png imgae ie. C:\Users\Buddiez\Documents\Visual Studio 2010\Projects\abc\abc\a.png
Copy all the images which you have and navigate to >> visual studio select Project>>Properties.There select Resources and paste all copied images on the right side pane.
Hashtable emotions;
void CreateEmotions()
{
emotions= new Hashtable(6);
emotions.Add(":-)", Project.Properties.Resources.regular_smile);
emotions.Add(":)", Project.Properties.Resources.regular_smile);
}
void AddEmotions()
{
foreach (string emote in emotions.Keys)
{
while(richTextBox1.Text.Contains(emote))
{
int ind = richTextBox1.Text.IndexOf(emote);
richTextBox1.Select(ind, emote.Length);
Clipboard.SetImage((Image)emotions[emote]);
richTextBox1.Paste();
}
}
}
A good (and relatively new) solution could be using the open-source EmojiBox project.
There's not much code there so it's quite easy to follow, just note that in order to insert an emoji into the custom RichTextBox there, the text you type has to follow the template of :emoji_name:
Of course, if you don't want to use the whole list of unicode emojis, you could also replace the image files or their names/descriptions within the json file.

Resources